You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by so...@apache.org on 2008/01/28 23:27:02 UTC
svn commit: r616087 [1/3] - in /lenya/branches/revolution/1.3.x: ./ lib/
src/java/org/apache/lenya/cms/cocoon/components/modules/input/
src/java/org/apache/lenya/cms/cocoon/components/source/impl/
src/java/org/apache/lenya/cms/content/ src/java/org/apa...
Author: solprovider
Date: Mon Jan 28 14:26:58 2008
New Revision: 616087
URL: http://svn.apache.org/viewvc?rev=616087&view=rev
Log:
Integrated new Module package. Fixed Modules to work as Global.
Added:
lenya/branches/revolution/1.3.x/13DONE.txt
lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/ContentInputModule.java
lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/ContentSourceFactory.java
lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleGlobal.java
- copied, changed from r615141, lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/GlobalModule.java
lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleInputModule.java
lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModulePublication.java
- copied, changed from r615141, lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/PublicationModule.java
lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleSourceFactory.java
lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/PublicationModules.java
- copied, changed from r615137, lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/Modules.java
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/form/README.txt
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/lenya/
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/lenya/edit/
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/lenya/edit/addSourceTags.xsl
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/lenya/edit/removeSourceTags.xsl
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/lenya/exception/
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/lenya/exception/document-does-not-exist.xsl
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/lenya/exception/missing-language.xsl
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/lenya/exception/missing-language.xsp
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/lenya/module.xml
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/lenya/rc/
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/lenya/rc/toDoc.xsl
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/lenya/rc/view.xsp
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/lenya/system/
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/lenya/system/error2html.xslt
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/lenya/util/
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/lenya/util/empty.xml
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/lenya/util/page2xhtml.xsl
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/lenya/util/strip_namespaces.xsl
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/nav/README.txt
Removed:
lenya/branches/revolution/1.3.x/lib/cocoon-2.1.10.jar
lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/GlobalModule.java
lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/PublicationModule.java
lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/Modules.java
Modified:
lenya/branches/revolution/1.3.x/13ModuleXML.txt
lenya/branches/revolution/1.3.x/13TODO.txt
lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/modules/input/ContentModule.java
lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/modules/input/ModuleModule.java
lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/modules/input/Usecase2ModuleModule.java
lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/modules/input/VirtualModule.java
lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ContentSourceFactory.java
lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ModuleSourceFactory.java
lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/Content.java
lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/CreateRevisionTransformer.java
lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/Module.java
lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleSet.java
lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/Modules.java
lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/AbstractPublication.java
lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/Publication.java
lenya/branches/revolution/1.3.x/src/webapp/WEB-INF/cocoon-xconf.xsl
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/authoring/doctypes.xmap
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/authoring/module.xmap
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/authoring/module.xml
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/cache/module.xmap
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/cache/module.xml
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/flat/module.xmap
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/flat/module.xml
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/form/module.xml
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/homepage/module.xml
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/nav/module.xml
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/navigation/module.xmap
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/text/module.xml
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/xhtml/module.xmap
lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/xhtml/module.xml
Added: lenya/branches/revolution/1.3.x/13DONE.txt
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/13DONE.txt?rev=616087&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/13DONE.txt (added)
+++ lenya/branches/revolution/1.3.x/13DONE.txt Mon Jan 28 14:26:58 2008
@@ -0,0 +1,23 @@
+This file contains completed entries from the TODO file with the most recent entries at the top. Separate Commits with "---".
+======
+
+
+
+---
+DONE 20080127: Fix Publication Module loading and inheritance. Each Publication should build structure once per restart.
+[Modules.java]
+synchronize setting of static variables.
+Move inherit to static (publication.module.name=publication.module.name).
+Module variable inheritance must follow name changes (inherit="differentModuleName").
+Fix getVariable() to use inherit.
+New "inherit": publication.module -> list(array) of publication.module
+There may be more than one publication. Each Module inherits from only one Module name.
+Use for both File and Variable inheritance.
+[ModuleModule.java]
+module variables: publication.xconf (implemented), then get defaults from module.xconf, follow inheritance until found.
+DONE 20080127: Add reloadModules to publication. => Files are cached by filename so changes fo not require reset. Filename cache cleared by reset using double-colon.
+
+---
+FIXED?: CreateRevisionTransformer: Set creator and when properly.
+DONE 20080120: Xinha adds extra fields. Dialog1 - Dialog6 fields added to new revisions.
+
Modified: lenya/branches/revolution/1.3.x/13ModuleXML.txt
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/13ModuleXML.txt?rev=616087&r1=616086&r2=616087&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/13ModuleXML.txt (original)
+++ lenya/branches/revolution/1.3.x/13ModuleXML.txt Mon Jan 28 14:26:58 2008
@@ -6,16 +6,17 @@
maximum="" rem="Filter to not use above certain version of Lenya."
created="1.3" rem="Unused. Comment."
content="hierarchical|flat|all" <!-- Filter for content type if multiple modules with same id. Default=all"
- modified="1.3" rem="Filter for latest if multiple modules with same id and content type."
+ modified="20071231" rem="Filter for latest if multiple modules with same id and content type."
resource="/xml/xhtml" rem="Empty for non-resource modules. / for top-level resources: xml, file, link. /xml or /xml/xhtml for most custom resources. All modules on resource path are automatically inherited and required. Current id is not needed but is obviously needed in resource type."
>
<inherit priority="1" publication="parentPublicationId" id="parentId"/>
<inherit priority="2" publication="parentPublicationId2" id="parentId2"/>
- <required id="parentModuleId">Note why</required> <!-- All required modules will be loaded. Modules on resource path should not specified. -->
- <required id="parentModuleId2"/>
- <recommended id="recommendedModuleId">Suggestion to publication configurators.</recommended> <!-- Modules not required but increase functionality. -->
- <optional id="otherModuleID">Explanation for other developers about when other module may be used.</optional> <!-- Any modules not listed in another category that may be used by this module. -->
- <parameter name="parametername">parametervalue</parameter>
+ <required id="parentModuleId">Note why</required> <!-- All required modules will be loaded. Modules on resource path should not specified. -->
+ <required id="parentModuleId2"/>
+ <recommended id="recommendedModuleId">Suggestion to publication configurators.</recommended> <!-- Modules not required but increase functionality. -->
+ <optional id="otherModuleID">Explanation for other developers about when other module may be used.</optional> <!-- Any modules not listed in another category that may be used by this module. -->
+ <role name="rolename">description</role>
+ <parameter name="parametername">parametervalue</parameter>
<description>Short description of the module. This is an element to allow XHTML in future.</description>
<usage>
XHTML help documentation
Modified: lenya/branches/revolution/1.3.x/13TODO.txt
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/13TODO.txt?rev=616087&r1=616086&r2=616087&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/13TODO.txt (original)
+++ lenya/branches/revolution/1.3.x/13TODO.txt Mon Jan 28 14:26:58 2008
@@ -1,5 +1,18 @@
-Fix Publication Module loading and inheritance. Each Publication should build structure once per restart. See Modules.java below.
-Add reloadModules to publication.
+
+BUG: Lenya-1.2-style authoring. ERROR:
+F:\F:\lenya13\build\lenya\webapp\lenya\pubs\default12\xslt\page2xhtml.xsl (The filename, directory name, or volume label syntax is incorrect)
+rg.apache.cocoon.ProcessingException: Unable to get transformer handler for F:///F:/lenya13/build/lenya/webapp/lenya/modules/authoring/../../pubs/default12/xslt/page2xhtml-homepage.xsl
+ at [TransformerException] - file:///F:///F:/lenya13/build/lenya/webapp/lenya/modules/authoring/../../pubs/default12/xslt/page2xhtml-homepage.xsl:22:36
+ at <map:serialize type="xml"> - file:///F:/lenya13/build/lenya/webapp/lenya/modules/authoring/module.xmap:145:36
+ at <map:transform type="link-rewrite"> - file:///F:/lenya13/build/lenya/webapp/lenya/modules/authoring/module.xmap:142:44
+
+default12/xslt/page2xhtml-homepage.xsl cannot open page2xhtml.xsl because drive letter is duplicated:
+file:///F:///F:/lenya13/build/lenya/webapp/lenya/modules/authoring/../../pubs/default12/xslt/page2xhtml-homepage.xsl
+---
+
+Create New Resource: Publication has Resource Types. Use Generator. Choose Type. Create required languages. Use Transformer. Pass to Edit Module.
+
+Edit-Save must clear Cache.
Administration navigation - Create Resource, return from edit resource.
Add "Choose Lenya doc link" dialog to Xinha.
@@ -10,24 +23,11 @@
Xinha adds xmlns:xhtml="http://www.w3.org/1999/xhtml to some elements (P H1).
-FIXED?: CreateRevisionTransformer: Set creator and when properly.
-FIXED 20080120: Xinha adds extra fields. Dialog1 - Dialog6 fields added to new revisions.
==== ToDo List from 2006
=== 1.2.x Conversion
Session Module: login.xsp -> NullPointerException
-=== Modules.java
-synchronize setting of static variables.
-
-Move inherit to static (publication.module.name=publication.module.name).
-Module variable inheritance must follow name changes (inherit="differentModuleName").
-Fix getVariable() to use inherit.
-New "inherit": publication.module -> list(array) of publication.module
-There may be more than one publication. Each Module inherits from only one Module name.
-Use for both File and Variable inheritance.
-
-
=== CreateRevisionTransformer
Create new Resource if none specified or does not exist. Allow a Title parameter, and default to "NEW " + datetime.
@@ -64,8 +64,6 @@
Return specified variable from current Resource/Translation.
Use FlatIndexPart for retrieval?
-=== ModuleModule.java
-module variables: publication.xconf (implemented), then get defaults from module.xconf, follow inheritance until found.
=== XML Serializer
Automatically pass through i18n Transformer using current module and current language.
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/modules/input/ContentModule.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/modules/input/ContentModule.java?rev=616087&r1=616086&r2=616087&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/modules/input/ContentModule.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/modules/input/ContentModule.java Mon Jan 28 14:26:58 2008
@@ -1,101 +1,68 @@
package org.apache.lenya.cms.cocoon.components.modules.input;
-import java.io.File;
-import java.net.MalformedURLException;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
-import java.util.Set;
-import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.excalibur.source.Source;
-import org.apache.excalibur.source.SourceResolver;
-import org.apache.excalibur.source.SourceUtil;
-import org.apache.excalibur.source.URIAbsolutizer;
-import org.apache.cocoon.components.CocoonComponentManager;
-import org.apache.cocoon.components.ContextHelper;
import org.apache.lenya.cms.content.Content;
import org.apache.lenya.cms.content.Resource;
-import org.apache.lenya.cms.publication.Modules;
import org.apache.lenya.cms.publication.PageEnvelope;
import org.apache.lenya.cms.publication.Publication;
-
-
-
/**
* Retrieves Content Variables from the appropriate Resource
+ *
+ * @author solprovider
+ * @deprecated Use org.apache.lenya.cms.content.ContentModule
*/
-public class ContentModule extends AbstractPageEnvelopeModule implements Serviceable, Contextualizable, ThreadSafe {
- private ServiceManager manager;
- private org.apache.avalon.framework.context.Context context;
- /**
- * @see org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String,
- * org.apache.avalon.framework.configuration.Configuration, java.util.Map)
- */
-
- public Object getAttribute(String name, Configuration modeConf, Map objectModel) throws ConfigurationException {
- if(getLogger().isDebugEnabled()) {
- getLogger().debug("Resolving [" + name + "]");
- }
- PageEnvelope pe = getEnvelope(objectModel);
- Publication pub = pe.getPublication();
- String publication = pub.getId();
- Content content = pub.getContent();
- String unid = "";
- int pos = name.indexOf(":");
- if(pos < 1) return "error";
- unid = name.substring(pos + 1);
- name = name.substring(0, pos);
- Resource resource = content.getResource(unid);
- if(name.equalsIgnoreCase("type")) return resource.getType();
- if(name.equalsIgnoreCase("doctype") || name.equalsIgnoreCase("documenttype")) return resource.getDocumentType();
- if(name.equalsIgnoreCase("defaultlanguage")) return resource.getDefaultLanguage();
- return "";
- }
-
- /**
- * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeNames(org.apache.avalon.framework.configuration.Configuration,
- * java.util.Map)
- */
- public Iterator getAttributeNames(Configuration modeConf, Map objectModel) throws ConfigurationException {
- return Collections.EMPTY_SET.iterator();
- }
-
- /**
- * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeValues(java.lang.String,
- * org.apache.avalon.framework.configuration.Configuration, java.util.Map)
- */
- public Object[] getAttributeValues(String name, Configuration modeConf, Map objectModel)
- throws ConfigurationException {
- Object[] objects = { getAttribute(name, modeConf, objectModel) };
- return objects;
- }
-
- /**
- * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
- */
- public void service(ServiceManager manager) throws ServiceException {
- this.manager = manager;
- }
- /**
- * Contextualizable, get the object model
- */
- public void contextualize( Context context ) throws ContextException {
- this.context = context;
- }
- /**
- * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
- */
- public void configure(Configuration conf) throws ConfigurationException {
- super.configure(conf);
- }
+public class ContentModule extends AbstractPageEnvelopeModule implements ThreadSafe {
+ /**
+ * @see org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String,
+ * org.apache.avalon.framework.configuration.Configuration,
+ * java.util.Map)
+ */
+ public Object getAttribute(String name, Configuration modeConf, Map objectModel) throws ConfigurationException {
+ if(getLogger().isDebugEnabled()){
+ getLogger().debug("Resolving [" + name + "]");
+ }
+ PageEnvelope pe = getEnvelope(objectModel);
+ Publication pub = pe.getPublication();
+ Content content = pub.getContent();
+ String unid = "";
+ int pos = name.indexOf(":");
+ if(pos < 1)
+ return "error";
+ unid = name.substring(pos + 1);
+ name = name.substring(0, pos);
+ Resource resource = content.getResource(unid);
+ if(name.equalsIgnoreCase("type"))
+ return resource.getType();
+ if(name.equalsIgnoreCase("doctype") || name.equalsIgnoreCase("documenttype"))
+ return resource.getDocumentType();
+ if(name.equalsIgnoreCase("defaultlanguage"))
+ return resource.getDefaultLanguage();
+ return "";
+ }
+ /**
+ * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeNames(org.apache.avalon.framework.configuration.Configuration,
+ * java.util.Map)
+ */
+ public Iterator getAttributeNames(Configuration modeConf, Map objectModel) throws ConfigurationException {
+ return Collections.EMPTY_SET.iterator();
+ }
+ /**
+ * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeValues(java.lang.String,
+ * org.apache.avalon.framework.configuration.Configuration,
+ * java.util.Map)
+ */
+ public Object[] getAttributeValues(String name, Configuration modeConf, Map objectModel) throws ConfigurationException {
+ Object[] objects = {getAttribute(name, modeConf, objectModel)};
+ return objects;
+ }
+ /**
+ * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
+ */
+ public void configure(Configuration conf) throws ConfigurationException {
+ super.configure(conf);
+ }
}
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/modules/input/ModuleModule.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/modules/input/ModuleModule.java?rev=616087&r1=616086&r2=616087&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/modules/input/ModuleModule.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/modules/input/ModuleModule.java Mon Jan 28 14:26:58 2008
@@ -1,118 +1,91 @@
package org.apache.lenya.cms.cocoon.components.modules.input;
-import java.io.File;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.StringTokenizer;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.cocoon.components.ContextHelper;
-import org.apache.lenya.cms.publication.PageEnvelope;
-
-import java.net.MalformedURLException;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceResolver;
-import org.apache.lenya.cms.publication.Modules;
+import org.apache.lenya.cms.publication.PageEnvelope;
import org.apache.lenya.cms.publication.Publication;
-
-import org.apache.cocoon.components.CocoonComponentManager;
-import org.apache.avalon.framework.component.ComponentManager;
-import org.apache.excalibur.source.SourceUtil;
-import org.apache.excalibur.source.URIAbsolutizer;
-
+import org.apache.lenya.cms.publication.PublicationModules;
/**
* Retrieves Module Variables from publication.xconf and module.xml.
*
* Variables are specified as <module name="modulename"><variable name="{variablename}">{value}</variable></module>
+ *
+ * @author solprovider
+ * @deprecated Use org.apache.lenya.cms.modules.ModuleModule;
*/
-public class ModuleModule extends AbstractPageEnvelopeModule implements Serviceable, Contextualizable, ThreadSafe {
- private ServiceManager manager;
- private org.apache.avalon.framework.context.Context context;
- /**
- * @see org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String,
- * org.apache.avalon.framework.configuration.Configuration, java.util.Map)
- */
- private String module = "";
- private String program = ""; //Name of calling file
- private String process = ""; //Name of calling file without extension
- public Object getAttribute(String name, Configuration modeConf, Map objectModel) throws ConfigurationException {
- if(getLogger().isDebugEnabled()) {
- getLogger().debug("Resolving [" + name + "]");
- }
- init();
- //Standard Variables
- if(name.equalsIgnoreCase("module")) return module;
- //Module Variables
- PageEnvelope pe = getEnvelope(objectModel);
- Publication pub = pe.getPublication();
- String publication = pub.getId();
- Modules modules = pub.getModules();
- return modules.getVariable(publication, module, name);
- }
-
- /**
- * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeNames(org.apache.avalon.framework.configuration.Configuration,
- * java.util.Map)
- */
- public Iterator getAttributeNames(Configuration modeConf, Map objectModel) throws ConfigurationException {
- return Collections.EMPTY_SET.iterator();
- }
-
- /**
- * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeValues(java.lang.String,
- * org.apache.avalon.framework.configuration.Configuration, java.util.Map)
- */
- public Object[] getAttributeValues(String name, Configuration modeConf, Map objectModel)
- throws ConfigurationException {
- Object[] objects = { getAttribute(name, modeConf, objectModel) };
- return objects;
- }
-
- /**
- * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
- */
- public void service(ServiceManager manager) throws ServiceException {
- this.manager = manager;
- }
- /**
- * Contextualizable, get the object model
- */
- public void contextualize( Context context ) throws ContextException {
- this.context = context;
- }
- /**
- * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
- */
- public void configure(Configuration conf) throws ConfigurationException {
- super.configure(conf);
- }
+public class ModuleModule extends AbstractPageEnvelopeModule implements Serviceable, ThreadSafe {
+ private ServiceManager manager;
+ /**
+ * @see org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String, org.apache.avalon.framework.configuration.Configuration, java.util.Map)
+ */
+ private String module = "";
+ public Object getAttribute(String name, Configuration modeConf, Map objectModel) throws ConfigurationException {
+ if(getLogger().isDebugEnabled()){
+ getLogger().debug("Resolving [" + name + "]");
+ }
+ init();
+ // Standard Variables
+ if(name.equalsIgnoreCase("module"))
+ return module;
+ // Module Variables
+ PageEnvelope pe = getEnvelope(objectModel);
+ Publication pub = pe.getPublication();
+ PublicationModules modules = pub.getModules();
+ return modules.getVariable(module, name);
+ }
+ /**
+ * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeNames(org.apache.avalon.framework.configuration.Configuration, java.util.Map)
+ */
+ public Iterator getAttributeNames(Configuration modeConf, Map objectModel) throws ConfigurationException {
+ return Collections.EMPTY_SET.iterator();
+ }
+ /**
+ * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeValues(java.lang.String, org.apache.avalon.framework.configuration.Configuration, java.util.Map)
+ */
+ public Object[] getAttributeValues(String name, Configuration modeConf, Map objectModel) throws ConfigurationException {
+ Object[] objects = {getAttribute(name, modeConf, objectModel)};
+ return objects;
+ }
+ /**
+ * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
+ */
+ public void service(ServiceManager manager) throws ServiceException {
+ this.manager = manager;
+ }
+ /**
+ * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
+ */
+ public void configure(Configuration conf) throws ConfigurationException {
+ super.configure(conf);
+ }
private void init() {
- String uri = "";
- try{
- SourceResolver resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
- Source source = resolver.resolveURI("");
- uri = source.getURI();
- if (resolver != null) manager.release(resolver);
- }catch(org.apache.avalon.framework.service.ServiceException se){
- //Report Error?
- }catch(java.net.MalformedURLException mue){
- //Report Error?
- }catch(java.io.IOException ioe){
- //Report Error?
- }
-//TODO: Release resolver
- StringTokenizer tokens = new StringTokenizer(uri, "/");
- while(tokens.hasMoreTokens() && !(tokens.nextToken().equals("modules")));
- if(tokens.hasMoreTokens()) module = tokens.nextToken();
+ String uri = "";
+ try{
+ SourceResolver resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
+ Source source = resolver.resolveURI("");
+ uri = source.getURI();
+ if(resolver != null)
+ manager.release(resolver);
+ }catch(org.apache.avalon.framework.service.ServiceException se){
+ // Report Error?
+ }catch(java.net.MalformedURLException mue){
+ // Report Error?
+ }catch(java.io.IOException ioe){
+ // Report Error?
+ }
+ // XTODO: Release resolver
+ StringTokenizer tokens = new StringTokenizer(uri, "/");
+ while(tokens.hasMoreTokens() && !(tokens.nextToken().equals("modules")));
+ if(tokens.hasMoreTokens())
+ module = tokens.nextToken();
}
}
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/modules/input/Usecase2ModuleModule.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/modules/input/Usecase2ModuleModule.java?rev=616087&r1=616086&r2=616087&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/modules/input/Usecase2ModuleModule.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/modules/input/Usecase2ModuleModule.java Mon Jan 28 14:26:58 2008
@@ -1,15 +1,12 @@
package org.apache.lenya.cms.cocoon.components.modules.input;
-import java.io.File;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
@@ -18,93 +15,91 @@
import org.apache.lenya.cms.publication.PageEnvelope;
/**
* Converts querystring Usecases into Module format.
+ *
+ * @author solprovider
*/
public class Usecase2ModuleModule extends AbstractPageEnvelopeModule implements Serviceable, Contextualizable, ThreadSafe {
- private ServiceManager manager;
- private org.apache.avalon.framework.context.Context context;
- /**
- * @see org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String,
- * org.apache.avalon.framework.configuration.Configuration, java.util.Map)
- */
- public Object getAttribute(String name, Configuration modeConf, Map objectModel) throws ConfigurationException {
- if(getLogger().isDebugEnabled()) {
- getLogger().debug("Resolving [" + name + "]");
- }
- String resolvedUri = name;
- PageEnvelope pe = getEnvelope(objectModel);
- String publication = pe.getPublication().getId();
- Map contextmap = ContextHelper.getObjectModel(context);
- org.apache.cocoon.environment.http.HttpRequest req =
- (org.apache.cocoon.environment.http.HttpRequest) contextmap.get("request");
- String request = req.getRequestURI();
- String qs = req.getQueryString();
- String lu = req.getParameter("lenya.usecase");
- if(null == lu) lu = "";
-//STEP String ls = req.getParameter("lenya.step");
-//STEP if(null == ls) ls = "";
- String before = "";
- String after = "";
- int pos = request.indexOf(publication);
- if(pos > 0) {
- pos += publication.length();
- before = request.substring(0, pos + 1);
- pos = request.indexOf("/", pos + 1);
- if(pos > 0){
- after = request.substring(pos);
- if(lu.length() > 0){
- before += lu;
- }else{
- before = request.substring(0, pos);
- }
- }
-//STEP if(ls.length() > 0){
-//STEP before += "/" + ls;
-//STEP }
- qs = qs.replaceAll("lenya.usecase=" + lu, "");
-//STEP qs = qs.replaceAll("lenya.step=" + ls, "");
- //Cleanup
- qs = qs.replaceAll("&&", "&");
- qs = qs.replaceAll("\\?&", "\\?");
- qs = qs.replaceAll("&$", "");
- resolvedUri = before + after + "?" + qs;
- }
- return resolvedUri;
- }
-
- /**
- * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeNames(org.apache.avalon.framework.configuration.Configuration,
- * java.util.Map)
- */
- public Iterator getAttributeNames(Configuration modeConf, Map objectModel) throws ConfigurationException {
- return Collections.EMPTY_SET.iterator();
- }
-
- /**
- * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeValues(java.lang.String,
- * org.apache.avalon.framework.configuration.Configuration, java.util.Map)
- */
- public Object[] getAttributeValues(String name, Configuration modeConf, Map objectModel)
- throws ConfigurationException {
- Object[] objects = { getAttribute(name, modeConf, objectModel) };
- return objects;
- }
-
- /**
- * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
- */
- public void service(ServiceManager manager) throws ServiceException {
- this.manager = manager;
- }
- /**
- * Contextualizable, get the object model
- */
- public void contextualize( Context context ) throws ContextException {
- this.context = context;
- }
- /**
- * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
- */
- public void configure(Configuration conf) throws ConfigurationException {
- super.configure(conf);
- }
+ private org.apache.avalon.framework.context.Context context;
+ /**
+ * @see org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String,
+ * org.apache.avalon.framework.configuration.Configuration,
+ * java.util.Map)
+ */
+ public Object getAttribute(String name, Configuration modeConf, Map objectModel) throws ConfigurationException {
+ if(getLogger().isDebugEnabled()){
+ getLogger().debug("Resolving [" + name + "]");
+ }
+ String resolvedUri = name;
+ PageEnvelope pe = getEnvelope(objectModel);
+ String publication = pe.getPublication().getId();
+ Map contextmap = ContextHelper.getObjectModel(context);
+ org.apache.cocoon.environment.http.HttpRequest req = (org.apache.cocoon.environment.http.HttpRequest) contextmap.get("request");
+ String request = req.getRequestURI();
+ String qs = req.getQueryString();
+ String lu = req.getParameter("lenya.usecase");
+ if(null == lu)
+ lu = "";
+ // STEP String ls = req.getParameter("lenya.step");
+ // STEP if(null == ls) ls = "";
+ String before = "";
+ String after = "";
+ int pos = request.indexOf(publication);
+ if(pos > 0){
+ pos += publication.length();
+ before = request.substring(0, pos + 1);
+ pos = request.indexOf("/", pos + 1);
+ if(pos > 0){
+ after = request.substring(pos);
+ if(lu.length() > 0){
+ before += lu;
+ }else{
+ before = request.substring(0, pos);
+ }
+ }
+ // STEP if(ls.length() > 0){
+ // STEP before += "/" + ls;
+ // STEP }
+ qs = qs.replaceAll("lenya.usecase=" + lu, "");
+ // STEP qs = qs.replaceAll("lenya.step=" + ls, "");
+ // Cleanup
+ qs = qs.replaceAll("&&", "&");
+ qs = qs.replaceAll("\\?&", "\\?");
+ qs = qs.replaceAll("&$", "");
+ resolvedUri = before + after + "?" + qs;
+ }
+ return resolvedUri;
+ }
+ /**
+ * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeNames(org.apache.avalon.framework.configuration.Configuration,
+ * java.util.Map)
+ */
+ public Iterator getAttributeNames(Configuration modeConf, Map objectModel) throws ConfigurationException {
+ return Collections.EMPTY_SET.iterator();
+ }
+ /**
+ * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeValues(java.lang.String,
+ * org.apache.avalon.framework.configuration.Configuration,
+ * java.util.Map)
+ */
+ public Object[] getAttributeValues(String name, Configuration modeConf, Map objectModel) throws ConfigurationException {
+ Object[] objects = {getAttribute(name, modeConf, objectModel)};
+ return objects;
+ }
+ /**
+ * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
+ */
+ public void service(ServiceManager manager) throws ServiceException {
+ }
+ /**
+ * Contextualizable, get the object model
+ */
+ public void contextualize(Context context) throws ContextException {
+ this.context = context;
+ }
+ /**
+ * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
+ */
+ public void configure(Configuration conf) throws ConfigurationException {
+ super.configure(conf);
+ }
}
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/modules/input/VirtualModule.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/modules/input/VirtualModule.java?rev=616087&r1=616086&r2=616087&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/modules/input/VirtualModule.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/modules/input/VirtualModule.java Mon Jan 28 14:26:58 2008
@@ -1,76 +1,48 @@
package org.apache.lenya.cms.cocoon.components.modules.input;
-
-import java.io.File;
import java.util.Collections;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.cocoon.components.ContextHelper;
-
import org.apache.cocoon.components.modules.input.AbstractInputModule;
import org.apache.lenya.cms.cocoon.components.source.impl.VirtualSourceFactory;
-
-
/**
* {virtual:new} Reserves and returns a new Key for a VirtualSource.
* {virtual:Key} Releases Key for a VirtualSource.
*/
-public class VirtualModule extends AbstractInputModule implements Serviceable, Contextualizable, ThreadSafe {
- private ServiceManager manager;
- private org.apache.avalon.framework.context.Context context;
- /**
- * @see org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String,
- * org.apache.avalon.framework.configuration.Configuration, java.util.Map)
- */
- public Object getAttribute(String name, Configuration modeConf, Map objectModel) throws ConfigurationException {
- if(name.equalsIgnoreCase("new")) return VirtualSourceFactory.reserve();
- VirtualSourceFactory.releaseSource(name);
- return name;
- }
-
- /**
- * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeNames(org.apache.avalon.framework.configuration.Configuration,
- * java.util.Map)
- */
- public Iterator getAttributeNames(Configuration modeConf, Map objectModel) throws ConfigurationException {
- return Collections.EMPTY_SET.iterator();
- }
-
- /**
- * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeValues(java.lang.String,
- * org.apache.avalon.framework.configuration.Configuration, java.util.Map)
- */
- public Object[] getAttributeValues(String name, Configuration modeConf, Map objectModel)
- throws ConfigurationException {
- Object[] objects = { getAttribute(name, modeConf, objectModel) };
- return objects;
- }
-
- /**
- * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
- */
- public void service(ServiceManager manager) throws ServiceException {
- this.manager = manager;
- }
- /**
- * Contextualizable, get the object model
- */
- public void contextualize( Context context ) throws ContextException {
- this.context = context;
- }
- /**
- * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
- */
- public void configure(Configuration conf) throws ConfigurationException {
- super.configure(conf);
- }
+public class VirtualModule extends AbstractInputModule implements ThreadSafe {
+ /**
+ * @see org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String,
+ * org.apache.avalon.framework.configuration.Configuration,
+ * java.util.Map)
+ */
+ public Object getAttribute(String name, Configuration modeConf, Map objectModel) throws ConfigurationException {
+ if(name.equalsIgnoreCase("new"))
+ return VirtualSourceFactory.reserve();
+ VirtualSourceFactory.releaseSource(name);
+ return name;
+ }
+ /**
+ * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeNames(org.apache.avalon.framework.configuration.Configuration,
+ * java.util.Map)
+ */
+ public Iterator getAttributeNames(Configuration modeConf, Map objectModel) throws ConfigurationException {
+ return Collections.EMPTY_SET.iterator();
+ }
+ /**
+ * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeValues(java.lang.String,
+ * org.apache.avalon.framework.configuration.Configuration,
+ * java.util.Map)
+ */
+ public Object[] getAttributeValues(String name, Configuration modeConf, Map objectModel) throws ConfigurationException {
+ Object[] objects = {getAttribute(name, modeConf, objectModel)};
+ return objects;
+ }
+ /**
+ * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
+ */
+ public void configure(Configuration conf) throws ConfigurationException {
+ super.configure(conf);
+ }
}
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ContentSourceFactory.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ContentSourceFactory.java?rev=616087&r1=616086&r2=616087&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ContentSourceFactory.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ContentSourceFactory.java Mon Jan 28 14:26:58 2008
@@ -34,6 +34,8 @@
* <BR>== Content Impls == <BR>
* ContentHierarchical (Lenya 1.2) <BR>
* ContentFlat (Lenya 1.3)
+ * @author solprovider
+ * @deprecated Use org.apache.lenya.cms.content.ContentSourceFactory;
*/
public class ContentSourceFactory implements SourceFactory, ThreadSafe, URIAbsolutizer, Contextualizable {
private static final int REQUEST_DATA = 0;
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ModuleSourceFactory.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ModuleSourceFactory.java?rev=616087&r1=616086&r2=616087&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ModuleSourceFactory.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ModuleSourceFactory.java Mon Jan 28 14:26:58 2008
@@ -22,12 +22,16 @@
import org.apache.excalibur.source.SourceUtil;
import org.apache.excalibur.source.URIAbsolutizer;
import org.apache.excalibur.source.impl.FileSource;
-import org.apache.lenya.cms.publication.Modules;
+import org.apache.lenya.cms.publication.PublicationModules;
import org.apache.lenya.cms.publication.PageEnvelope;
import org.apache.lenya.cms.publication.PageEnvelopeFactory;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.PublicationFactory;
-
+/**
+ *
+ * @author solprovider
+ * @deprecated Use org.apache.lenya.cms.modules.ModuleSourceFactory.
+ */
public class ModuleSourceFactory implements SourceFactory, ThreadSafe, URIAbsolutizer, Contextualizable {
protected org.apache.avalon.framework.context.Context context;
private String servletContextPath;
@@ -68,7 +72,7 @@
globalPrefix = tmpPrefix + "modules" + File.separator;
pubsPrefix = tmpPrefix + "pubs" + File.separator;
String publication;
- Modules modules;
+ PublicationModules modules;
publications.clear();
try{
PageEnvelope envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(ContextHelper.getObjectModel(context));
@@ -160,13 +164,13 @@
}
publications.add(publication);
// Check inherited publication(s)
- if(null != modules){
- Source ret = getInheritedSource(publication, module, filepath, modules.getTemplates(module), parameters, resolver);
- if(null != ret){
- if(resolver != null) manager.release((Component) resolver);
- return ret;
- }
- }
+// if(null != modules){
+// Source ret = getInheritedSource(publication, module, filepath, modules.getTemplates(module), parameters, resolver);
+// if(null != ret){
+// if(resolver != null) manager.release((Component) resolver);
+// return ret;
+// }
+// }
// Check global
newlocation = globalPrefix + module + File.separator + filepath;
try{
@@ -203,7 +207,7 @@
String module = modulex;
int i = 0;
boolean found = false;
- Modules modules = (Modules) null;
+ PublicationModules modules = (PublicationModules) null;
String key = publication + "~" + module;
String newpublication = "";
if(moduleInheritance.containsKey(key)){
@@ -217,7 +221,7 @@
newpublication = templates[i];
// Do not repeat publication
if(!publications.contains(newpublication)){
- modules = (Modules) null;
+ modules = (PublicationModules) null;
Publication pub = getPublication(newpublication);
if(null != pub){
modules = pub.getModules();
@@ -237,12 +241,12 @@
}catch(java.net.MalformedURLException mue2){
}catch(java.io.IOException ioe1){
}
- if(null != modules){
- // First check if module name was overridden
- Source ret = getInheritedSource(newpublication, modules.getInheritedModule(module), filepath, modules.getTemplates(module), parameters, resolver);
- if(null != ret) return ret;
- return getInheritedSource(newpublication, module, filepath, modules.getTemplates(module), parameters, resolver);
- }
+// if(null != modules){
+// // First check if module name was overridden
+// Source ret = getInheritedSource(newpublication, modules.getInheritedModule(module), filepath, modules.getTemplates(module), parameters, resolver);
+// if(null != ret) return ret;
+// return getInheritedSource(newpublication, module, filepath, modules.getTemplates(module), parameters, resolver);
+// }
}
return (Source) null;
}
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/Content.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/Content.java?rev=616087&r1=616086&r2=616087&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/Content.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/Content.java Mon Jan 28 14:26:58 2008
@@ -1,10 +1,10 @@
package org.apache.lenya.cms.content;
-import org.apache.excalibur.source.Source;
-import org.apache.excalibur.source.SourceNotFoundException;
-import org.apache.lenya.cms.publication.Publication;
public interface Content{
+ public static final String TYPE_FLAT = "flat";
+ public static final String TYPE_HIERARCHICAL = "hierarchical";
+
public String getURI(String unid, String language, String revision);
public String getMetaURI(String unid, String language, String revision);
public String getNewURI(String unid, String language);
Added: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/ContentInputModule.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/ContentInputModule.java?rev=616087&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/ContentInputModule.java (added)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/ContentInputModule.java Mon Jan 28 14:26:58 2008
@@ -0,0 +1,102 @@
+package org.apache.lenya.cms.content;
+import java.io.File;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.avalon.framework.component.ComponentManager;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.excalibur.source.SourceUtil;
+import org.apache.excalibur.source.URIAbsolutizer;
+import org.apache.cocoon.components.CocoonComponentManager;
+import org.apache.cocoon.components.ContextHelper;
+import org.apache.lenya.cms.cocoon.components.modules.input.AbstractPageEnvelopeModule;
+import org.apache.lenya.cms.content.Content;
+import org.apache.lenya.cms.content.Resource;
+import org.apache.lenya.cms.publication.PublicationModules;
+import org.apache.lenya.cms.publication.PageEnvelope;
+import org.apache.lenya.cms.publication.Publication;
+
+
+
+/**
+ * Retrieves Content Variables from the appropriate Resource
+ */
+public class ContentInputModule extends AbstractPageEnvelopeModule implements Serviceable, Contextualizable, ThreadSafe {
+ private ServiceManager manager;
+ private org.apache.avalon.framework.context.Context context;
+ /**
+ * @see org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String,
+ * org.apache.avalon.framework.configuration.Configuration, java.util.Map)
+ */
+
+ public Object getAttribute(String name, Configuration modeConf, Map objectModel) throws ConfigurationException {
+ if(getLogger().isDebugEnabled()) {
+ getLogger().debug("Resolving [" + name + "]");
+ }
+ PageEnvelope pe = getEnvelope(objectModel);
+ Publication pub = pe.getPublication();
+ String publication = pub.getId();
+ Content content = pub.getContent();
+ String unid = "";
+ int pos = name.indexOf(":");
+ if(pos < 1) return "error";
+ unid = name.substring(pos + 1);
+ name = name.substring(0, pos);
+ Resource resource = content.getResource(unid);
+ if(name.equalsIgnoreCase("type")) return resource.getType();
+ if(name.equalsIgnoreCase("doctype") || name.equalsIgnoreCase("documenttype")) return resource.getDocumentType();
+ if(name.equalsIgnoreCase("defaultlanguage")) return resource.getDefaultLanguage();
+ return "";
+ }
+
+ /**
+ * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeNames(org.apache.avalon.framework.configuration.Configuration,
+ * java.util.Map)
+ */
+ public Iterator getAttributeNames(Configuration modeConf, Map objectModel) throws ConfigurationException {
+ return Collections.EMPTY_SET.iterator();
+ }
+
+ /**
+ * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeValues(java.lang.String,
+ * org.apache.avalon.framework.configuration.Configuration, java.util.Map)
+ */
+ public Object[] getAttributeValues(String name, Configuration modeConf, Map objectModel)
+ throws ConfigurationException {
+ Object[] objects = { getAttribute(name, modeConf, objectModel) };
+ return objects;
+ }
+
+ /**
+ * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
+ */
+ public void service(ServiceManager manager) throws ServiceException {
+ this.manager = manager;
+ }
+ /**
+ * Contextualizable, get the object model
+ */
+ public void contextualize( Context context ) throws ContextException {
+ this.context = context;
+ }
+ /**
+ * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
+ */
+ public void configure(Configuration conf) throws ConfigurationException {
+ super.configure(conf);
+ }
+}
\ No newline at end of file
Added: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/ContentSourceFactory.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/ContentSourceFactory.java?rev=616087&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/ContentSourceFactory.java (added)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/ContentSourceFactory.java Mon Jan 28 14:26:58 2008
@@ -0,0 +1,219 @@
+package org.apache.lenya.cms.content;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.Map;
+import java.util.StringTokenizer;
+import org.apache.avalon.framework.component.Component;
+import org.apache.avalon.framework.component.ComponentManager;
+import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.cocoon.components.CocoonComponentManager;
+import org.apache.cocoon.components.ContextHelper;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceFactory;
+import org.apache.excalibur.source.SourceNotFoundException;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.excalibur.source.SourceUtil;
+import org.apache.excalibur.source.URIAbsolutizer;
+import org.apache.lenya.cms.cocoon.components.source.impl.StringSource;
+import org.apache.lenya.cms.content.Content;
+import org.apache.lenya.cms.content.Resource;
+import org.apache.lenya.cms.publication.PageEnvelope;
+import org.apache.lenya.cms.publication.PageEnvelopeFactory;
+import org.apache.lenya.cms.publication.Publication;
+import org.w3c.dom.Document;
+
+/**
+ * Implements content: protocol. <BR>
+ * This should call the Content API that calls a Content Impl. <BR>
+ * <BR>== Content API == <BR>
+ * Source getResourceByUNID(String unid, String translation, String revision) <BR>
+ * Source getResourceByID(String structure, String id, String translation, String revision) <BR>
+ * <BR>== Content Impls == <BR>
+ * ContentHierarchical (Lenya 1.2) <BR>
+ * ContentFlat (Lenya 1.3)
+ */
+public class ContentSourceFactory implements SourceFactory, ThreadSafe, URIAbsolutizer, Contextualizable {
+ private static final int REQUEST_DATA = 0;
+ private static final int REQUEST_META = 1;
+ private static final int REQUEST_INFO = 2;
+ protected org.apache.avalon.framework.context.Context context;
+ // private String servletContextPath;
+ String pubsPrefix;
+ DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
+ SourceResolver resolver = null;
+ public void contextualize(org.apache.avalon.framework.context.Context context) throws ContextException {
+ this.context = context;
+ }
+ public Source getSource(String plocation, Map parameters) throws IOException, MalformedURLException {
+ String location = plocation;
+ int pos;
+ // Map contextmap = ContextHelper.getObjectModel(context);
+ // org.apache.cocoon.environment.http.HttpContext httpcontext = (org.apache.cocoon.environment.http.HttpContext) contextmap.get("context");
+ // servletContextPath = httpcontext.getRealPath("");
+ // TODO: Move resolver, pubsPrefix and other init out of getSource(). Make static?
+ ComponentManager manager = CocoonComponentManager.getSitemapComponentManager();
+ try{
+ resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
+ }catch(org.apache.avalon.framework.component.ComponentException ce){
+ }
+ if(null == resolver){ throw new SourceNotFoundException("No Resolver: " + plocation); }
+ String uri = resolver.resolveURI("").getURI();
+ pos = uri.indexOf("/pubs/");
+ if(pos > 0){
+ pubsPrefix = uri.substring(0, pos + 6);
+ }else{
+ pos = uri.indexOf("/modules/");
+ if(pos > 0){
+ pubsPrefix = uri.substring(0, pos) + "/pubs/";
+ }
+ }
+ // String publication;
+ // String contentpath;
+ Publication pub;
+ Content content;
+ try{
+ PageEnvelope envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(ContextHelper.getObjectModel(context));
+ pub = envelope.getPublication();
+ // publication = pub.getId();
+ content = pub.getContent();
+ // contentpath = pub.getContentDirectory().getAbsolutePath() + File.separator;
+ }catch(org.apache.lenya.cms.publication.PageEnvelopeException pee){
+ throw new MalformedURLException("Could not get Publication ID.");
+ }
+ // Revision
+ String revision = "live";
+ pos = location.lastIndexOf("!");
+ if(pos != -1){
+ revision = location.substring(pos + 1);
+ location = location.substring(0, pos);
+ }
+ // Language
+ String language = "";
+ pos = location.lastIndexOf("_");
+ if(pos != -1){
+ language = location.substring(pos + 1);
+ location = location.substring(0, pos);
+ }
+ // TODO: Set language to document or publication's default if not specified.
+ // System.out.println("LOC="+location);
+ // Decide Usage
+ StringTokenizer tokens = new StringTokenizer(location, "/:", true);
+ if(!tokens.hasMoreTokens()) throw new MalformedURLException("Nothing specified.");
+ String token = tokens.nextToken();
+ if(location.indexOf(":") > 0) token = tokens.nextToken(); // Remove protocol
+ int colonCount = 0;
+ while(token.equals(":")){
+ colonCount++;
+ token = (tokens.hasMoreTokens() ? tokens.nextToken() : "");
+ }
+ int slashCount = 0;
+ while(token.equals("/")){
+ slashCount++;
+ token = (tokens.hasMoreTokens() ? tokens.nextToken() : "");
+ }
+ int requestType = colonCount - 1;
+ boolean isFormat2 = false;
+ if(token.equals("DATA")){
+ requestType = REQUEST_DATA;
+ isFormat2 = true;
+ }else if(token.equals("META")){
+ requestType = REQUEST_META;
+ isFormat2 = true;
+ }else if(token.equals("INFO")){
+ requestType = REQUEST_INFO;
+ isFormat2 = true;
+ }
+ if(isFormat2){
+ token = tokens.nextToken();
+ int slashCount2 = 0;
+ while(token.equals("/")){
+ slashCount2++;
+ token = tokens.nextToken();
+ }
+ slashCount = (slashCount > slashCount2 ? slashCount : slashCount2);
+ }
+ // System.out.println("SL=" + slashCount + "TOK=" + token);
+ // ## Decide UNID
+ // String structure = "";
+ // String unid = "";
+ // String fullid = "";
+ // if(slashCount == 1){
+ // if(tokens.hasMoreTokens()){
+ // slashCount = 0;
+ // }else unid = token;
+ // }
+ // if((slashCount == 0) || (slashCount == 2)){
+ // structure = token;
+ // }
+ // if((slashCount == 0) || (slashCount == 2) || (slashCount == 3)){
+ // StringBuffer buffer = new StringBuffer();
+ // while(tokens.hasMoreTokens())
+ // buffer.append(tokens.nextToken());
+ // fullid = buffer.toString();
+ // }
+ // // Convert fullid to unid
+ // if(unid.length() < 1){
+ // unid = content.getUNID(structure, fullid);
+ // }
+ // ## 20070927 solprovider: This rewrite did not work. Simpler is good. Test later.
+ String structure = (2 < slashCount ? "" : token);
+ String unid = token;
+ StringBuffer buffer = new StringBuffer();
+ while(tokens.hasMoreTokens())
+ buffer.append(tokens.nextToken());
+ String fullid = buffer.toString();
+ if((1 < slashCount) || (0 < fullid.length())) unid = content.getUNID(structure, fullid);
+ // ASSUME: UNID
+ // ## Defaults
+ if(language.length() < 1){
+ Resource resource = content.getResource(unid);
+ if(resource != null) language = resource.getDefaultLanguage();
+ }
+ if(language.length() < 1) language = pub.getDefaultLanguage();
+ /** ******** Get Source (uses Content) ************ */
+ Source source;
+ if(REQUEST_INFO == requestType){
+ // TODO: Catch errors
+ Resource resource = content.getResource(unid);
+ if(resource == null) System.out.println("NO RESOURCE");
+ Document doc = resource.getInfoDocument();
+ if(doc == null) System.out.println("NO DOC");
+ source = new StringSource(manager, doc);
+ if(source == null) System.out.println("NO SOURCE");
+ return source;
+ }
+ if(REQUEST_META == requestType){
+ source = resolver.resolveURI(content.getMetaURI(unid, language, revision));
+ if(source.exists()){
+ if(resolver != null) manager.release((Component) resolver);
+ return source;
+ }
+ }
+ // System.out.println("CSF UNID=" + unid + " LANG=" + language + " REV=" + revision);
+ String curi = content.getURI(unid, language, revision);
+ // System.out.println("CSF CURI=" + curi);
+ source = resolver.resolveURI(curi);
+ if(source.exists()){
+ if(resolver != null) manager.release((Component) resolver);
+ return source;
+ }
+ if(resolver != null) manager.release((Component) resolver);
+ throw new SourceNotFoundException("Not found: " + plocation + " (" + curi + ")");
+ }
+ public void release(Source source1) {
+ }
+ public String absolutize(String baseURI, String location) {
+ return SourceUtil.absolutize(baseURI, location, false, false);
+ }
+ // private Publication getPublication(String publication) {
+ // try{
+ // return PublicationFactory.getPublication(publication, servletContextPath);
+ // }catch(org.apache.lenya.cms.publication.PublicationException pe){
+ // return (Publication) null;
+ // }
+ // }
+}
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/CreateRevisionTransformer.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/CreateRevisionTransformer.java?rev=616087&r1=616086&r2=616087&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/CreateRevisionTransformer.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/CreateRevisionTransformer.java Mon Jan 28 14:26:58 2008
@@ -1,5 +1,4 @@
package org.apache.lenya.cms.content.flat;
-
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
@@ -20,177 +19,190 @@
import org.apache.lenya.xml.NamespaceHelper;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-
/**
* @cocoon.sitemap.component.documentation This transformer creates a new Revision. It takes the UNID as the src parameter, uses the current language, and create a new Revision It will be enhanced to take "/structure/path/docid" as the src. That will be easy. If there is a slash, then convert using Content.getUNID().
* @author <a href="mailto:solprovider@apache.org">Paul Ercolino</a>
*/
public class CreateRevisionTransformer extends AbstractDOMTransformer {
- public static final String UPLOADASSET_PARAM_PREFIX = "dc.";
- public static final String UPLOADASSET_RETURN_FILESIZE = "file-size";
- public static final String UPLOADASSET_RETURN_MIMETYPE = "mime-type";
- public static final String CONTENT_PREFIX = "content";
- public static final String FILE_NAME_REGEXP = "[-a-zA-Z0-9_. ]+";
- // optional parameters for meta data according to dublin core
- public static final String[] DUBLIN_CORE_PARAMETERS = {"title", "creator", "subject", "description", "publisher", "contributor", "date", "type", "format", "identifier", "source", "language", "relation", "coverage", "rights" };
- protected org.w3c.dom.Document transform(org.w3c.dom.Document doc) {
- Request request = ObjectModelHelper.getRequest(super.objectModel);
- createRevision(request, this.source, doc, false);
- return doc;
- }
- static public org.w3c.dom.Document transformDocument(Request request, String unid, org.w3c.dom.Document doc, boolean setLive) {
- createRevision(request, unid, doc, setLive);
- return doc;
- }
- /**
- * @param request The request
- * @param doc The data to be inserted.
- */
- static private void createRevision(Request request, String punid, org.w3c.dom.Document doc, boolean setLive)
- // throws SAXException, IOException, ProcessingException
- {
- if(doc == null){
- System.out.println("CreateRevision: Document is required.");
- // throw new ProcessingException("CreateRevision: document is required.");
- }
- PageEnvelope envelope = (PageEnvelope) request.getAttribute(PageEnvelope.class.getName());
- Publication pub = envelope.getPublication();
- Content content = pub.getContent();
- String unid = punid;
- String language = envelope.getDocument().getLanguage(); // default
- // check if unid contains language
- int pos = unid.indexOf("_");
- if(pos > 0){
- unid = unid.substring(0, pos);
- language = unid.substring(pos);
- }
- System.out.println("CreateRevision TEST: u=" + unid + " l=" + language);
- String newFilename = content.getNewURI(unid, language);
- if(newFilename == null){
- System.out.println("CreateRevision: Could not get new filename.");
- // throw new ProcessingException("CreateRevision: Could not get new filename.");
- }
- File file = new File(newFilename);
- if(file.exists()){
- System.out.println("Revision '" + newFilename + "' already exists.");
- // throw new ProcessingException("Revision '" + newFilename + "' already exists.");
- }
- String filenameNoExtension = newFilename;
- pos = newFilename.lastIndexOf(".");
- if(pos > 0) filenameNoExtension = newFilename.substring(0, pos);
- String revision = (new File(filenameNoExtension)).getName();
- File assetFile;
- // determine if the upload is an asset or a content upload
- Map dublinCoreParams = getDublinCoreParameters(request);
- // upload the file to the uploadDir
- String extension = "";
- // Document metadoc = (Document) null;
- Element root = doc.getDocumentElement();
- if(root.hasAttribute("filefield")){
- Part part = (Part) request.get(root.getAttribute("filefield"));
- if(null != part){
- String filename = part.getFileName();
- pos = filename.lastIndexOf(".");
- if(pos > 0) extension = filename.substring(pos + 1);
- // System.out.println("Upload: EXT=" + extension);
- String mimeType = part.getMimeType();
- dublinCoreParams.put("format", mimeType);
- int fileSize = part.getSize();
- dublinCoreParams.put("extent", Integer.toString(fileSize));
- assetFile = new File(filenameNoExtension + "." + extension);
- try{
- saveFileFromPart(assetFile, part);
- }catch(java.lang.Exception e){
- System.out.println("CreateRevision: Exception saving upload.");
- }
- // Add Meta to doc
- addMeta(doc, dublinCoreParams);
- } // END - part not null
- } // END - doc has "file" attribute.
- // ASSUME: Upload is saved.
- // Store creator, when, revision and extension.
- root.setAttribute("revision", revision);
- String userid = "anonymous";
- Session session = request.getSession();
- if(session != null){
- Identity identity = (Identity) session.getAttribute(Identity.class.getName());
- if(identity != null){
- User user = identity.getUser();
- if(user != null) userid = user.getId();
+ public static final String UPLOADASSET_PARAM_PREFIX = "dc.";
+ public static final String UPLOADASSET_RETURN_FILESIZE = "file-size";
+ public static final String UPLOADASSET_RETURN_MIMETYPE = "mime-type";
+ public static final String CONTENT_PREFIX = "content";
+ public static final String FILE_NAME_REGEXP = "[-a-zA-Z0-9_. ]+";
+ // optional parameters for meta data according to dublin core
+ public static final String[] DUBLIN_CORE_PARAMETERS = {"title", "creator", "subject", "description", "publisher", "contributor", "date", "type", "format", "identifier", "source", "language", "relation", "coverage", "rights"};
+ protected org.w3c.dom.Document transform(org.w3c.dom.Document doc) {
+ Request request = ObjectModelHelper.getRequest(super.objectModel);
+ createRevision(request, this.source, doc, false);
+ return doc;
+ }
+ static public org.w3c.dom.Document transformDocument(Request request, String unid, org.w3c.dom.Document doc, boolean setLive) {
+ createRevision(request, unid, doc, setLive);
+ return doc;
+ }
+ /**
+ * @param request
+ * The request
+ * @param doc
+ * The data to be inserted.
+ */
+ static private void createRevision(Request request, String punid, org.w3c.dom.Document doc, boolean setLive) {
+ if(doc == null){
+ System.out.println("CreateRevision: Document is required.");
+ // throw new ProcessingException("CreateRevision: document is required.");
+ }
+ PageEnvelope envelope = (PageEnvelope) request.getAttribute(PageEnvelope.class.getName());
+ Publication pub = envelope.getPublication();
+ Content content = pub.getContent();
+ String unid = punid;
+ String language = envelope.getDocument().getLanguage(); // default
+ // check if unid contains language
+ int pos = unid.indexOf("_");
+ if(pos > 0){
+ unid = unid.substring(0, pos);
+ language = unid.substring(pos);
+ }
+ // System.out.println("CreateRevision TEST: u=" + unid + " l=" + language);
+ String newFilename = content.getNewURI(unid, language);
+ if(newFilename == null){
+ System.out.println("CreateRevision: Could not get new filename.");
+ // throw new ProcessingException("CreateRevision: Could not get new filename.");
+ }
+ File file = new File(newFilename);
+ if(file.exists()){
+ System.out.println("Revision '" + newFilename + "' already exists.");
+ // throw new ProcessingException("Revision '" + newFilename + "' already exists.");
+ }
+ String filenameNoExtension = newFilename;
+ pos = newFilename.lastIndexOf(".");
+ if(pos > 0)
+ filenameNoExtension = newFilename.substring(0, pos);
+ String revision = (new File(filenameNoExtension)).getName();
+ File assetFile;
+ // determine if the upload is an asset or a content upload
+ Map dublinCoreParams = getDublinCoreParameters(request);
+ // upload the file to the uploadDir
+ String extension = "";
+ // Document metadoc = (Document) null;
+ Element root = doc.getDocumentElement();
+ if(root.hasAttribute("filefield")){
+ Part part = (Part) request.get(root.getAttribute("filefield"));
+ if(null != part){
+ String filename = part.getFileName();
+ pos = filename.lastIndexOf(".");
+ if(pos > 0)
+ extension = filename.substring(pos + 1);
+ // System.out.println("Upload: EXT=" + extension);
+ String mimeType = part.getMimeType();
+ dublinCoreParams.put("format", mimeType);
+ int fileSize = part.getSize();
+ dublinCoreParams.put("extent", Integer.toString(fileSize));
+ assetFile = new File(filenameNoExtension + "." + extension);
+ try{
+ saveFileFromPart(assetFile, part);
+ }catch(java.lang.Exception e){
+ System.out.println("CreateRevision: Exception saving upload.");
}
- }
- root.setAttribute("creator", userid);
- root.setAttribute("when", getDateString());
- if(extension.length() > 0) root.setAttribute("extension", extension);
- try{
- DocumentHelper.writeDocument(doc, file);
- }catch(javax.xml.transform.TransformerConfigurationException tce){
- System.out.println("CreateRevision: TransformerConfigurationException");
- }catch(javax.xml.transform.TransformerException te){
- System.out.println("CreateRevision: TransformerException");
- }catch(java.io.IOException ioe){
- System.out.println("CreateRevision: IOException writing XML file.");
- }
- // Update Translation
- FlatResource resource = (FlatResource) ((FlatContent) content).getResource(unid, language, "edit");
- FlatTranslation translation = resource.getTranslation();
- translation.setEdit(revision);
- if(setLive) translation.setLive(revision);
- translation.save();
- }
- /**
- * Saves the asset to a file.
- * @param assetFile The asset file.
- * @param part The part of the multipart request.
- * @throws Exception if an error occurs.
- */
- static private void saveFileFromPart(File assetFile, Part part) throws Exception {
- if(!assetFile.exists()){
- boolean created = assetFile.createNewFile();
- if(!created){ throw new RuntimeException("The file [" + assetFile + "] could not be created."); }
- }
- byte[] buf = new byte[4096];
- FileOutputStream out = new FileOutputStream(assetFile);
- try{
- InputStream in = part.getInputStream();
- int read = in.read(buf);
- while(read > 0){
- out.write(buf, 0, read);
- read = in.read(buf);
- }
- }finally{
- out.close();
- }
- }
- /**
- * Retrieves optional parameters for the meta file which contains dublin core information from the request.
- * @param request The request.
- * @return A map.
- */
- static private Map getDublinCoreParameters(Request request) {
- HashMap dublinCoreParams = new HashMap();
- for(int i = 0; i < DUBLIN_CORE_PARAMETERS.length; i++){
- String paramName = DUBLIN_CORE_PARAMETERS[i];
- String paramValue = request.getParameter(UPLOADASSET_PARAM_PREFIX + paramName);
- if(paramValue == null) paramValue = "";
- dublinCoreParams.put(paramName, paramValue);
- }
- return dublinCoreParams;
- }
- static private void addMeta(Document doc, Map dublinCoreParams) {
- NamespaceHelper helper = new NamespaceHelper("http://purl.org/dc/elements/1.1/", "dc", doc);
- Element root = doc.getDocumentElement();
- // DESIGN CHANGE: No metadata element.
- // org.w3c.dom.Node meta = root.appendChild(helper.createElement("metadata"));
- Iterator iter = dublinCoreParams.keySet().iterator();
- while(iter.hasNext()){
- String tagName = (String) iter.next();
- String tagValue = (String) dublinCoreParams.get(tagName);
- // meta.appendChild(helper.createElement(tagName, tagValue));
- root.appendChild(helper.createElement(tagName, tagValue));
- }
- }
- static private String getDateString() {
- return Long.toString(new java.util.Date().getTime());
- }
+ // Add Meta to doc
+ addMeta(doc, dublinCoreParams);
+ } // END - part not null
+ } // END - doc has "file" attribute.
+ // ASSUME: Upload is saved.
+ // Store creator, when, revision and extension.
+ root.setAttribute("revision", revision);
+ String userid = "anonymous";
+ Session session = request.getSession();
+ if(session != null){
+ Identity identity = (Identity) session.getAttribute(Identity.class.getName());
+ if(identity != null){
+ User user = identity.getUser();
+ if(user != null)
+ userid = user.getId();
+ }
+ }
+ root.setAttribute("creator", userid);
+ root.setAttribute("when", getDateString());
+ if(extension.length() > 0)
+ root.setAttribute("extension", extension);
+ try{
+ DocumentHelper.writeDocument(doc, file);
+ }catch(javax.xml.transform.TransformerConfigurationException tce){
+ System.out.println("CreateRevision: TransformerConfigurationException");
+ }catch(javax.xml.transform.TransformerException te){
+ System.out.println("CreateRevision: TransformerException");
+ }catch(java.io.IOException ioe){
+ System.out.println("CreateRevision: IOException writing XML file.");
+ }
+ // Update Translation
+ FlatResource resource = (FlatResource) ((FlatContent) content).getResource(unid, language, "edit");
+ FlatTranslation translation = resource.getTranslation();
+ translation.setEdit(revision);
+ if(setLive)
+ translation.setLive(revision);
+ translation.save();
+ }
+ /**
+ * Saves the asset to a file.
+ *
+ * @param assetFile
+ * The asset file.
+ * @param part
+ * The part of the multipart request.
+ * @throws Exception
+ * if an error occurs.
+ */
+ static private void saveFileFromPart(File assetFile, Part part) throws Exception {
+ if(!assetFile.exists()){
+ boolean created = assetFile.createNewFile();
+ if(!created){
+ throw new RuntimeException("The file [" + assetFile + "] could not be created.");
+ }
+ }
+ byte[] buf = new byte[4096];
+ FileOutputStream out = new FileOutputStream(assetFile);
+ try{
+ InputStream in = part.getInputStream();
+ int read = in.read(buf);
+ while(read > 0){
+ out.write(buf, 0, read);
+ read = in.read(buf);
+ }
+ }finally{
+ out.close();
+ }
+ }
+ /**
+ * Retrieves optional parameters for the meta file which contains dublin core information from the request.
+ *
+ * @param request
+ * The request.
+ * @return A map.
+ */
+ static private Map getDublinCoreParameters(Request request) {
+ HashMap dublinCoreParams = new HashMap();
+ for(int i = 0; i < DUBLIN_CORE_PARAMETERS.length; i++){
+ String paramName = DUBLIN_CORE_PARAMETERS[i];
+ String paramValue = request.getParameter(UPLOADASSET_PARAM_PREFIX + paramName);
+ if(paramValue == null)
+ paramValue = "";
+ dublinCoreParams.put(paramName, paramValue);
+ }
+ return dublinCoreParams;
+ }
+ static private void addMeta(Document doc, Map dublinCoreParams) {
+ NamespaceHelper helper = new NamespaceHelper("http://purl.org/dc/elements/1.1/", "dc", doc);
+ Element root = doc.getDocumentElement();
+ // DESIGN CHANGE: No metadata element.
+ // org.w3c.dom.Node meta = root.appendChild(helper.createElement("metadata"));
+ Iterator iter = dublinCoreParams.keySet().iterator();
+ while(iter.hasNext()){
+ String tagName = (String) iter.next();
+ String tagValue = (String) dublinCoreParams.get(tagName);
+ // meta.appendChild(helper.createElement(tagName, tagValue));
+ root.appendChild(helper.createElement(tagName, tagValue));
+ }
+ }
+ static private String getDateString() {
+ return Long.toString(new java.util.Date().getTime());
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org