svn commit: r617035 [5/22] - in /lenya/branches/revolution/1.3.x: ./ src/java/org/apache/lenya/ac/ src/java/org/apache/lenya/ac/cache/ src/java/org/apache/lenya/ac/cifs/ src/java/org/apache/lenya/ac/file/ src/java/org/apache/lenya/ac/impl/ src/java/org...

[email protected]
Newsgroups gmane.comp.cms.lenya.cvs
Message-ID <[email protected]>
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/flow/FlowHelper.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/flow/FlowHelper.java?rev=617035&r1=617034&r2=617035&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/flow/FlowHelper.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/flow/FlowHelper.java Wed Jan 30 23:44:03 2008
@@ -14,16 +14,12 @@
  *  limitations under the License.
  *
  */
-
 /* $Id$  */
-
 package org.apache.lenya.cms.cocoon.flow;
-
 import java.io.File;
 import java.io.IOException;
 import java.util.Enumeration;
 import java.util.Map;
-
 import org.apache.cocoon.components.flow.javascript.fom.FOM_Cocoon;
 import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.cocoon.environment.Request;
@@ -46,191 +42,187 @@
 import org.apache.lenya.cms.workflow.WorkflowFactory;
 import org.apache.lenya.workflow.Situation;
 import org.apache.lenya.workflow.WorkflowException;
-import org.apache.log4j.Category;
-
+import org.apache.log4j.Logger;
 /**
- * Flowscript utility class.
- * The FOM_Cocoon object is not passed in the constructor to avoid
- * errors. This way, not the initial, but the current FOM_Cocoon
- * object is used by the methods.
+ * Flowscript utility class. The FOM_Cocoon object is not passed in the constructor to avoid errors. This way, not the initial, but the current FOM_Cocoon object is used by the methods.
  */
 public class FlowHelper {
-
-    private static final Category log = Category.getInstance(FlowHelper.class);
-
-    /**
-     * Ctor.
-     */
-    public FlowHelper() {
-    }
-
-    /**
-     * Returns the current workflow situation.
-     * @param cocoon The FOM_Cocoon object.
-     * @return A situation.
-     * @throws AccessControlException when something went wrong.
-     */
-    public Situation getSituation(FOM_Cocoon cocoon) throws AccessControlException {
-        Request request = ObjectModelHelper.getRequest(cocoon.getObjectModel());
-        Session session = request.getSession();
-        Identity identity = (Identity) session.getAttribute(Identity.class.getName());
-
-        String userId = "";
-        String ipAddress = "";
-
-        User user = identity.getUser();
-        if (user != null) {
-            userId = user.getId();
-        }
-
-        Machine machine = identity.getMachine();
-        if (machine != null) {
-            ipAddress = machine.getIp();
-        }
-
-        Role[] roles = PolicyAuthorizer.getRoles(request);
-        String[] roleIds = new String[roles.length];
-        for (int i = 0; i < roles.length; i++) {
-            roleIds[i] = roles[i].getId();
-        }
-
-        WorkflowFactory factory = WorkflowFactory.newInstance();
-        Situation situation = factory.buildSituation(roleIds, userId, ipAddress);
-        return situation;
-    }
-
-    /**
-     * Returns the current page envelope.
-     * @param cocoon The FOM_Cocoon object.
-     * @return A page envelope.
-     * @throws PageEnvelopeException when something went wrong.
-     */
-    public PageEnvelope getPageEnvelope(FOM_Cocoon cocoon) throws PageEnvelopeException {
-        PageEnvelopeFactory factory = PageEnvelopeFactory.getInstance();
-        return factory.getPageEnvelope(cocoon.getObjectModel());
-    }
-
-    /**
-     * Returns the request URI of the current request.
-     * @param cocoon The FOM_Cocoon object.
-     * @return A string.
-     */
-    public String getRequestURI(FOM_Cocoon cocoon) {
-        return cocoon.getRequest().getRequestURI();
-    }
-    
-    /**
-     * Returns the request object of the current request.
-     * @param cocoon The FOM_Cocoon object.
-     * @return A request object.
-     */
-    public Request getRequest(FOM_Cocoon cocoon) {
-        return cocoon.getRequest();
-    }
-
-    /**
-     * Returns the Cocoon Object Model
-     * @param cocoon The Flow Object Model of Cocoon
-     * @return The object model
-     */
-    public Map getObjectModel(FOM_Cocoon cocoon) {
-        return cocoon.getObjectModel();
-    }
-    
-    /**
-     * Returns a DocumentHelper instance.  
-     * @param cocoon The Flow Object Model of Cocoon 
-     * @return The document helper
-     * @see DocumentHelper
-     */
-    public DocumentHelper getDocumentHelper(FOM_Cocoon cocoon) {
-        return new DocumentHelper(cocoon.getObjectModel());
-    }
-    
-    public static final String SEPARATOR = ":";
-
-    /**
-     * Resolves the request parameter value for a specific name.
-     * The parameter names are encoded as <code>{name}:{value}.{axis}</code>.
-     * This is a workaround for the &lt;input type="image"/&gt;
-     * bug in Internet Explorer.
-     * @param cocoon The FOM_Cocoon object.
-     * @param parameterName The request parameter name.
-     * @return A string.
-     */
-    public String getImageParameterValue(FOM_Cocoon cocoon, String parameterName) {
-
-        log.debug("Resolving parameter value for name [" + parameterName + "]");
-
-        Request request = cocoon.getRequest();
-        String value = request.getParameter(parameterName);
-
-        if (value == null) {
-            String prefix = parameterName + SEPARATOR;
-            Enumeration e = request.getParameterNames();
-            while (e.hasMoreElements() && value == null) {
-                String name = (String) e.nextElement();
-                if (name.startsWith(prefix)) {
-                    log.debug("Complete parameter name: [" + name + "]");
-                    value = name.substring(prefix.length(), name.length() - 2);
-                    log.debug("Resolved value: [" + value + "]");
-                }
+   private static Logger log = Logger.getLogger(FlowHelper.class);
+   /**
+    * Ctor.
+    */
+   public FlowHelper() {
+   }
+   /**
+    * Returns the current workflow situation.
+    * 
+    * @param cocoon
+    *           The FOM_Cocoon object.
+    * @return A situation.
+    * @throws AccessControlException
+    *            when something went wrong.
+    */
+   public Situation getSituation(FOM_Cocoon cocoon) throws AccessControlException {
+      Request request = ObjectModelHelper.getRequest(cocoon.getObjectModel());
+      Session session = request.getSession();
+      Identity identity = (Identity) session.getAttribute(Identity.class.getName());
+      String userId = "";
+      String ipAddress = "";
+      User user = identity.getUser();
+      if(user != null){
+         userId = user.getId();
+      }
+      Machine machine = identity.getMachine();
+      if(machine != null){
+         ipAddress = machine.getIp();
+      }
+      Role[] roles = PolicyAuthorizer.getRoles(request);
+      String[] roleIds = new String[roles.length];
+      for(int i = 0; i < roles.length; i++){
+         roleIds[i] = roles[i].getId();
+      }
+      WorkflowFactory factory = WorkflowFactory.newInstance();
+      Situation situation = factory.buildSituation(roleIds, userId, ipAddress);
+      return situation;
+   }
+   /**
+    * Returns the current page envelope.
+    * 
+    * @param cocoon
+    *           The FOM_Cocoon object.
+    * @return A page envelope.
+    * @throws PageEnvelopeException
+    *            when something went wrong.
+    */
+   public PageEnvelope getPageEnvelope(FOM_Cocoon cocoon) throws PageEnvelopeException {
+      PageEnvelopeFactory factory = PageEnvelopeFactory.getInstance();
+      return factory.getPageEnvelope(cocoon.getObjectModel());
+   }
+   /**
+    * Returns the request URI of the current request.
+    * 
+    * @param cocoon
+    *           The FOM_Cocoon object.
+    * @return A string.
+    */
+   public String getRequestURI(FOM_Cocoon cocoon) {
+      return cocoon.getRequest().getRequestURI();
+   }
+   /**
+    * Returns the request object of the current request.
+    * 
+    * @param cocoon
+    *           The FOM_Cocoon object.
+    * @return A request object.
+    */
+   public Request getRequest(FOM_Cocoon cocoon) {
+      return cocoon.getRequest();
+   }
+   /**
+    * Returns the Cocoon Object Model
+    * 
+    * @param cocoon
+    *           The Flow Object Model of Cocoon
+    * @return The object model
+    */
+   public Map getObjectModel(FOM_Cocoon cocoon) {
+      return cocoon.getObjectModel();
+   }
+   /**
+    * Returns a DocumentHelper instance.
+    * 
+    * @param cocoon
+    *           The Flow Object Model of Cocoon
+    * @return The document helper
+    * @see DocumentHelper
+    */
+   public DocumentHelper getDocumentHelper(FOM_Cocoon cocoon) {
+      return new DocumentHelper(cocoon.getObjectModel());
+   }
+   public static final String SEPARATOR = ":";
+   /**
+    * Resolves the request parameter value for a specific name. The parameter names are encoded as <code>{name}:{value}.{axis}</code>. This is a workaround for the &lt;input type="image"/&gt; bug in Internet Explorer.
+    * 
+    * @param cocoon
+    *           The FOM_Cocoon object.
+    * @param parameterName
+    *           The request parameter name.
+    * @return A string.
+    */
+   public String getImageParameterValue(FOM_Cocoon cocoon, String parameterName) {
+      log.debug("Resolving parameter value for name [" + parameterName + "]");
+      Request request = cocoon.getRequest();
+      String value = request.getParameter(parameterName);
+      if(value == null){
+         String prefix = parameterName + SEPARATOR;
+         Enumeration e = request.getParameterNames();
+         while(e.hasMoreElements() && value == null){
+            String name = (String) e.nextElement();
+            if(name.startsWith(prefix)){
+               log.debug("Complete parameter name: [" + name + "]");
+               value = name.substring(prefix.length(), name.length() - 2);
+               log.debug("Resolved value: [" + value + "]");
             }
-        }
-
-        return value;
-    }
-    
-    /**
-     * Trigger a workflow event for the document associated with the current PageEnvelope.
-     * @param cocoon The Cocoon Flow Object Model
-     * @param event The name of the workflow event to trigger.
-     * @throws WorkflowException If an workflow error occurs
-     * @throws PageEnvelopeException Page envelope can not operate properly.
-     * @throws AccessControlException If an access control violation occurs.
-     */
-    public void triggerWorkflow(FOM_Cocoon cocoon, String event) 
-    throws WorkflowException, PageEnvelopeException, AccessControlException {
-        final WorkflowDocument wf = (WorkflowDocument)WorkflowFactory.newInstance().buildInstance(getPageEnvelope(cocoon).getDocument());
-        wf.invoke(getSituation(cocoon), event);
-    }
-    
-    /**
-     * Get a RevisionController instance.
-     * @param cocoon The Cocoon Flow Object Model
-     * @throws PageEnvelopeException Page envelope can not operate properly.
-     * @throws IOException If an IOException occurs.
-     * @see PageEnvelope
-     * @see RevisionController
-     */
-    public RevisionController getRevisionController(FOM_Cocoon cocoon) 
-    throws PageEnvelopeException, IOException {        
-        final Publication publication = getPageEnvelope(cocoon).getPublication();
-        final String publicationPath = publication.getDirectory().getAbsolutePath();
-        final RCEnvironment rcEnvironment = RCEnvironment.getInstance(publication.getServletContext().getAbsolutePath());
-        String rcmlDirectory = rcEnvironment.getRCMLDirectory();
-        rcmlDirectory = publicationPath + File.separator + rcmlDirectory;
-        String backupDirectory = rcEnvironment.getBackupDirectory();
-        backupDirectory = publicationPath + File.separator + backupDirectory;
-
-        return new RevisionController(rcmlDirectory, backupDirectory, publicationPath);    	
-    }
-    
-    /**
-     * Checkis in the current document from the PageEnvelope context.
-     * @param cocoon The Cocoon Flow Object Model
-     * @param backup Wether a new revision should be created.
-     * @throws FileReservedCheckInException 
-     * @throws Exception
-     * @see RevisionController#reservedCheckIn(String, String, boolean)
-     */
-    public void reservedCheckIn(FOM_Cocoon cocoon, boolean backup) 
-    throws FileReservedCheckInException, Exception
-    {
-        final Identity identity = (Identity) ObjectModelHelper.getRequest(cocoon.getObjectModel()).getSession().getAttribute(Identity.class.getName());
-        final PageEnvelope pageEnvelope = getPageEnvelope(cocoon);
-        final Publication publication = getPageEnvelope(cocoon).getPublication();
-        final String filename = pageEnvelope.getDocument().getFile().getAbsolutePath().substring(publication.getDirectory().getAbsolutePath().length());   
-        getRevisionController(cocoon).reservedCheckIn(filename, identity.getUser().getId(), backup);
-    }
+         }
+      }
+      return value;
+   }
+   /**
+    * Trigger a workflow event for the document associated with the current PageEnvelope.
+    * 
+    * @param cocoon
+    *           The Cocoon Flow Object Model
+    * @param event
+    *           The name of the workflow event to trigger.
+    * @throws WorkflowException
+    *            If an workflow error occurs
+    * @throws PageEnvelopeException
+    *            Page envelope can not operate properly.
+    * @throws AccessControlException
+    *            If an access control violation occurs.
+    */
+   public void triggerWorkflow(FOM_Cocoon cocoon, String event) throws WorkflowException, PageEnvelopeException, AccessControlException {
+      final WorkflowDocument wf = (WorkflowDocument) WorkflowFactory.newInstance().buildInstance(getPageEnvelope(cocoon).getDocument());
+      wf.invoke(getSituation(cocoon), event);
+   }
+   /**
+    * Get a RevisionController instance.
+    * 
+    * @param cocoon
+    *           The Cocoon Flow Object Model
+    * @throws PageEnvelopeException
+    *            Page envelope can not operate properly.
+    * @throws IOException
+    *            If an IOException occurs.
+    * @see PageEnvelope
+    * @see RevisionController
+    */
+   public RevisionController getRevisionController(FOM_Cocoon cocoon) throws PageEnvelopeException, IOException {
+      final Publication publication = getPageEnvelope(cocoon).getPublication();
+      final String publicationPath = publication.getDirectory().getAbsolutePath();
+      final RCEnvironment rcEnvironment = RCEnvironment.getInstance(publication.getServletContext().getAbsolutePath());
+      String rcmlDirectory = rcEnvironment.getRCMLDirectory();
+      rcmlDirectory = publicationPath + File.separator + rcmlDirectory;
+      String backupDirectory = rcEnvironment.getBackupDirectory();
+      backupDirectory = publicationPath + File.separator + backupDirectory;
+      return new RevisionController(rcmlDirectory, backupDirectory, publicationPath);
+   }
+   /**
+    * Checkis in the current document from the PageEnvelope context.
+    * 
+    * @param cocoon
+    *           The Cocoon Flow Object Model
+    * @param backup
+    *           Wether a new revision should be created.
+    * @throws FileReservedCheckInException
+    * @throws Exception
+    * @see RevisionController#reservedCheckIn(String, String, boolean)
+    */
+   public void reservedCheckIn(FOM_Cocoon cocoon, boolean backup) throws FileReservedCheckInException, Exception {
+      final Identity identity = (Identity) ObjectModelHelper.getRequest(cocoon.getObjectModel()).getSession().getAttribute(Identity.class.getName());
+      final PageEnvelope pageEnvelope = getPageEnvelope(cocoon);
+      final Publication publication = getPageEnvelope(cocoon).getPublication();
+      final String filename = pageEnvelope.getDocument().getFile().getAbsolutePath().substring(publication.getDirectory().getAbsolutePath().length());
+      getRevisionController(cocoon).reservedCheckIn(filename, identity.getUser().getId(), backup);
+   }
 }

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/generation/Configuration.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/generation/Configuration.java?rev=617035&r1=617034&r2=617035&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/generation/Configuration.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/generation/Configuration.java Wed Jan 30 23:44:03 2008
@@ -1,101 +1,84 @@
 package org.apache.lenya.cms.cocoon.generation;
-
-
 import java.net.URL;
 import java.util.Properties;
-
-import org.apache.log4j.Category;
-
-
+import org.apache.log4j.Logger;
 /**
  * Read configuration
  */
 public class Configuration {
-    static Category log = Category.getInstance(Configuration.class);
-    public static final String DEFAULT_CONFIGURATION_FILE = "org/apache/lenya/cms/cocoon/generation/conf.properties";
-    public static final String DEFAULT_CONFIGURATION_KEY = "lenya.configuration";
-    public static final String OVERRIDE_DEFAULT_CONFIGURATION_KEY = "override.lenya.configuration";
-    public String trustStore = null;
-    public String trustStorePassword = null;
-
-    /**
-     * Creates a new Configuration object.
-     */
-    public Configuration() {
-        getProperties(load());
-    }
-
-    /**
-     * DOCUMENT ME!
-     *
-     * @return DOCUMENT ME!
-     */
-    public static Properties load() {
-        String resourcePathRelativeToClasspath = System.getProperty(OVERRIDE_DEFAULT_CONFIGURATION_KEY);
-
-        if (resourcePathRelativeToClasspath == null) {
-            resourcePathRelativeToClasspath = System.getProperty(DEFAULT_CONFIGURATION_KEY, DEFAULT_CONFIGURATION_FILE);
-            log.debug(DEFAULT_CONFIGURATION_KEY + "=" + resourcePathRelativeToClasspath);
-        } else {
-            log.debug(OVERRIDE_DEFAULT_CONFIGURATION_KEY + "=" + resourcePathRelativeToClasspath);
-        }
-
-        URL url = Configuration.class.getClassLoader().getResource(resourcePathRelativeToClasspath);
-
-        if (url == null) {
-            log.error(".load(): Could not find resource on classpath: " + resourcePathRelativeToClasspath);
-        }
-
-        log.debug(url);
-
-        Properties properties = new Properties();
-
-        try {
-            properties.load(Configuration.class.getResourceAsStream("conf.properties"));
-        } catch (Exception e) {
-            log.error(e);
-        }
-
-        return properties;
-    }
-
-    /**
-     * DOCUMENT ME!
-     *
-     * @param properties DOCUMENT ME!
-     */
-    public void getProperties(Properties properties) {
-        if (properties != null) {
-            trustStore = getProperty(properties, "org.apache.lenya.cms.cocoon.generation.ProxyGenerator.trustStore");
-            trustStorePassword = getProperty(properties, "org.apache.lenya.cms.cocoon.generation.ProxyGenerator.trustStorePassword");
-        }
-    }
-
-    /**
-     * DOCUMENT ME!
-     *
-     * @param properties DOCUMENT ME!
-     * @param key DOCUMENT ME!
-     *
-     * @return DOCUMENT ME!
-     */
-    public String getProperty(Properties properties, String key) {
-        String value = properties.getProperty(key);
-
-        if (value != null) {
-            log.debug(key + "=" + value);
-
-            return value;
-        } else {
-            log.error("No such property: " + key);
-        }
-
-        return null;
-    }
-
-    /**
-     * DOCUMENT ME!
-     */
-    public static void register() {
-    }
+   private static Logger log = Logger.getLogger(Configuration.class);
+   public static final String DEFAULT_CONFIGURATION_FILE = "org/apache/lenya/cms/cocoon/generation/conf.properties";
+   public static final String DEFAULT_CONFIGURATION_KEY = "lenya.configuration";
+   public static final String OVERRIDE_DEFAULT_CONFIGURATION_KEY = "override.lenya.configuration";
+   public String trustStore = null;
+   public String trustStorePassword = null;
+   /**
+    * Creates a new Configuration object.
+    */
+   public Configuration() {
+      getProperties(load());
+   }
+   /**
+    * DOCUMENT ME!
+    * 
+    * @return DOCUMENT ME!
+    */
+   public static Properties load() {
+      String resourcePathRelativeToClasspath = System.getProperty(OVERRIDE_DEFAULT_CONFIGURATION_KEY);
+      if(resourcePathRelativeToClasspath == null){
+         resourcePathRelativeToClasspath = System.getProperty(DEFAULT_CONFIGURATION_KEY, DEFAULT_CONFIGURATION_FILE);
+         log.debug(DEFAULT_CONFIGURATION_KEY + "=" + resourcePathRelativeToClasspath);
+      }else{
+         log.debug(OVERRIDE_DEFAULT_CONFIGURATION_KEY + "=" + resourcePathRelativeToClasspath);
+      }
+      URL url = Configuration.class.getClassLoader().getResource(resourcePathRelativeToClasspath);
+      if(url == null){
+         log.error(".load(): Could not find resource on classpath: " + resourcePathRelativeToClasspath);
+      }
+      log.debug(url);
+      Properties properties = new Properties();
+      try{
+         properties.load(Configuration.class.getResourceAsStream("conf.properties"));
+      }catch(Exception e){
+         log.error(e);
+      }
+      return properties;
+   }
+   /**
+    * DOCUMENT ME!
+    * 
+    * @param properties
+    *           DOCUMENT ME!
+    */
+   public void getProperties(Properties properties) {
+      if(properties != null){
+         trustStore = getProperty(properties, "org.apache.lenya.cms.cocoon.generation.ProxyGenerator.trustStore");
+         trustStorePassword = getProperty(properties, "org.apache.lenya.cms.cocoon.generation.ProxyGenerator.trustStorePassword");
+      }
+   }
+   /**
+    * DOCUMENT ME!
+    * 
+    * @param properties
+    *           DOCUMENT ME!
+    * @param key
+    *           DOCUMENT ME!
+    * 
+    * @return DOCUMENT ME!
+    */
+   public String getProperty(Properties properties, String key) {
+      String value = properties.getProperty(key);
+      if(value != null){
+         log.debug(key + "=" + value);
+         return value;
+      }else{
+         log.error("No such property: " + key);
+      }
+      return null;
+   }
+   /**
+    * DOCUMENT ME!
+    */
+   public static void register() {
+   }
 }

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/generation/ProxyGenerator.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/generation/ProxyGenerator.java?rev=617035&r1=617034&r2=617035&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/generation/ProxyGenerator.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/generation/ProxyGenerator.java Wed Jan 30 23:44:03 2008
@@ -14,18 +14,14 @@
  * the License.
  *  
  */
-
 /* $Id$ */
-
 package org.apache.lenya.cms.cocoon.generation;
-
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.Enumeration;
-
 import org.apache.avalon.framework.component.Component;
 import org.apache.avalon.framework.parameters.ParameterException;
 import org.apache.avalon.framework.parameters.Parameterizable;
@@ -39,207 +35,157 @@
 import org.apache.commons.httpclient.HttpState;
 import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.excalibur.xml.sax.SAXParser;
-import org.apache.lenya.cms.cocoon.generation.Configuration;
-import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-public class ProxyGenerator extends org.apache.cocoon.generation.ServletGenerator implements
-        Parameterizable {
-    private static Category log = Category.getInstance(ProxyGenerator.class);
-    
-    private static String trustStore = null;
-    private static String trustStorePassword = null;    
-    
-    public ProxyGenerator() {
-        Configuration conf = new Configuration();
-        trustStore = conf.trustStore;
-        trustStorePassword = conf.trustStorePassword;
-        log.debug("loaded ProxyGenerator Config: " + "trustStore="+trustStore + " trustStorePassword=" + trustStorePassword);
-    }
-    
-    // The URI of the namespace of this generator
-    private String URI = "http://apache.org/cocoon/lenya/proxygenerator/1.0";
-
-    /**
-     * No parameters implemented.
-     * @see org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters)
-     */
-    public void parameterize(Parameters parameters) throws ParameterException {
-    }
-
-    /**
-     * @see org.apache.cocoon.generation.Generator#generate()
-     */
-    public void generate() throws SAXException {
-        Request request = (Request) objectModel.get(ObjectModelHelper.REQUEST_OBJECT);
-        
-        log.debug("\n----------------------------------------------------------------"
-                + "\n- Request: (" + request.getClass().getName() + ") at port "
-                + request.getServerPort()
-                + "\n----------------------------------------------------------------");
-
-        String submitMethod = request.getMethod();
-
-        SAXParser parser = null;
-
-        try {
-            // DEBUG
-            if (submitMethod.equals("POST")) {
-                // FIXME: Andreas
-                if (request instanceof HttpRequest) {
-                    java.io.InputStream is = intercept(((HttpRequest) request).getInputStream());
-                }
-            }
-
-            URL url = createURL(request);
-
-            // Forward "InputStream", Parameters, QueryString to Servlet
-            org.apache.commons.httpclient.HttpMethod httpMethod = null;
-
-            if (submitMethod.equals("POST")) {
-                httpMethod = new PostMethod();
-
-                Enumeration params = request.getParameterNames();
-
-                while (params.hasMoreElements()) {
-                    String paramName = (String) params.nextElement();
-                    String[] paramValues = request.getParameterValues(paramName);
-
-                    for (int i = 0; i < paramValues.length; i++) {
-                        ((PostMethod) httpMethod).setParameter(paramName, paramValues[i]);
-                    }
-                }
-            } else if (submitMethod.equals("GET")) {
-                httpMethod = new org.apache.commons.httpclient.methods.GetMethod();
-                httpMethod.setQueryString(request.getQueryString());
-            }
-
-            // Copy/clone Cookies
-            Cookie[] cookies = request.getCookies();
-            org.apache.commons.httpclient.Cookie[] transferedCookies = null;
-
-            if (cookies != null) {
-                transferedCookies = new org.apache.commons.httpclient.Cookie[cookies.length];
-
-                for (int i = 0; i < cookies.length; i++) {
-                    boolean secure = false; // http: false, https: true
-                    transferedCookies[i] = new org.apache.commons.httpclient.Cookie(url.getHost(),
-                            cookies[i].getName(), cookies[i].getValue(), url.getFile(), null,
-                            secure);
-                }
-            }
-
-            // Initialize HttpClient
-            HttpClient httpClient = new HttpClient();
-
-            // Set cookies
-            if ((transferedCookies != null) && (transferedCookies.length > 0)) {
-                HttpState httpState = new HttpState();
-                httpState.addCookies(transferedCookies);
-                httpClient.setState(httpState);
-            }
-
-            // DEBUG cookies
-            // Send request to servlet
-            httpMethod.setRequestHeader("Content-type", "text/plain");
-            httpMethod.setPath(url.getPath());
-
-            // FIXME
-            for (Enumeration e = request.getHeaderNames(); e.hasMoreElements();) {
-                String name = (String) e.nextElement();
-                httpMethod.addRequestHeader(name, request.getHeader(name));
-            }
-                        
-            HostConfiguration hostConfiguration = new HostConfiguration();
-            hostConfiguration.setHost(url.getHost(), url.getPort(), url.getProtocol());
-
-            log.debug("\n----------------------------------------------------------------"
-                    + "\n- Starting session at URI: " + url + "\n- Host:                    "
-                    + url.getHost() + "\n- Port:                    " + url.getPort()
-                    + "\n----------------------------------------------------------------");
-            
-            if (trustStore != null) {
-            	System.setProperty("javax.net.ssl.trustStore", trustStore);
-            }            
-            if (trustStorePassword != null) {
-            	System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);     
-            }
-            
-            int result = httpClient.executeMethod(hostConfiguration, httpMethod);
-
-            log.debug("\n----------------------------------------------------------------"
-                    + "\n- Result:                    " + result
-                    + "\n----------------------------------------------------------------");
-
-            byte[] sresponse = httpMethod.getResponseBody();
-
-            httpMethod.releaseConnection();
-
-            // Return XML
-            InputSource input = new InputSource(new ByteArrayInputStream(sresponse));
-            parser = (SAXParser) this.manager.lookup(SAXParser.ROLE);
-            parser.parse(input, this.xmlConsumer);
-        } catch (SAXException e) {
-            throw e;
-        } catch (Exception e) {
-            getLogger().error("Generation failed: ", e);
-            throw new SAXException(e);
-        } finally {
-            this.manager.release((Component) parser);
-        }
-    }
-
-    /**
-     * Log input stream for debugging
-     * 
-     * @param in an <code>InputStream</code> value
-     * 
-     * @return an <code>InputStream</code> value
-     * 
-     * @exception Exception if an error occurs
-     */
-    private InputStream intercept(InputStream in) throws Exception {
-        byte[] buffer = new byte[1024];
-        int bytes_read;
-        ByteArrayOutputStream bufferOut = new ByteArrayOutputStream();
-
-        while ((bytes_read = in.read(buffer)) != -1) {
-            bufferOut.write(buffer, 0, bytes_read);
-        }
-
-        return new ByteArrayInputStream(bufferOut.toByteArray());
-    }
-
-    private URL createURL(Request request) throws MalformedURLException {
-        URL url = null;
-
-        try {
-            url = new URL(this.source);
-            log.debug(".createURL(): " + url);
-        } catch (MalformedURLException e) {
-            url = new URL(request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + this.source);
-            log.debug(".createURL(): Add localhost and port: " + url);
-        }
-
-        return url;
-    }
-
-    private void attribute(AttributesImpl attr, String name, String value) {
-        attr.addAttribute("", name, name, "CDATA", value);
-    }
-
-    private void start(String name, AttributesImpl attr) throws SAXException {
-        super.contentHandler.startElement(URI, name, name, attr);
-        attr.clear();
-    }
-
-    private void end(String name) throws SAXException {
-        super.contentHandler.endElement(URI, name, name);
-    }
-
-    private void data(String data) throws SAXException {
-        super.contentHandler.characters(data.toCharArray(), 0, data.length());
-    }
+public class ProxyGenerator extends org.apache.cocoon.generation.ServletGenerator implements Parameterizable {
+   private static Logger log = Logger.getLogger(ProxyGenerator.class);
+   private static String trustStore = null;
+   private static String trustStorePassword = null;
+   public ProxyGenerator() {
+      Configuration conf = new Configuration();
+      trustStore = conf.trustStore;
+      trustStorePassword = conf.trustStorePassword;
+      log.debug("loaded ProxyGenerator Config: " + "trustStore=" + trustStore + " trustStorePassword=" + trustStorePassword);
+   }
+   // The URI of the namespace of this generator
+   // private String URI = "http://apache.org/cocoon/lenya/proxygenerator/1.0";
+   /**
+    * No parameters implemented.
+    * 
+    * @see org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters)
+    */
+   public void parameterize(Parameters parameters) throws ParameterException {
+   }
+   /**
+    * @see org.apache.cocoon.generation.Generator#generate()
+    */
+   public void generate() throws SAXException {
+      Request request = (Request) objectModel.get(ObjectModelHelper.REQUEST_OBJECT);
+      log.debug("\n----------------------------------------------------------------" + "\n- Request: (" + request.getClass().getName() + ") at port " + request.getServerPort() + "\n----------------------------------------------------------------");
+      String submitMethod = request.getMethod();
+      SAXParser parser = null;
+      try{
+         // DEBUG
+         if(submitMethod.equals("POST")){
+            // FIXME: Andreas
+            if(request instanceof HttpRequest){
+               // java.io.InputStream is =
+               intercept(((HttpRequest) request).getInputStream());
+            }
+         }
+         URL url = createURL(request);
+         // Forward "InputStream", Parameters, QueryString to Servlet
+         org.apache.commons.httpclient.HttpMethod httpMethod = null;
+         if(submitMethod.equals("POST")){
+            httpMethod = new PostMethod();
+            Enumeration params = request.getParameterNames();
+            while(params.hasMoreElements()){
+               String paramName = (String) params.nextElement();
+               String[] paramValues = request.getParameterValues(paramName);
+               for(int i = 0; i < paramValues.length; i++){
+                  ((PostMethod) httpMethod).setParameter(paramName, paramValues[i]);
+               }
+            }
+         }else if(submitMethod.equals("GET")){
+            httpMethod = new org.apache.commons.httpclient.methods.GetMethod();
+            httpMethod.setQueryString(request.getQueryString());
+         }
+         // Copy/clone Cookies
+         Cookie[] cookies = request.getCookies();
+         org.apache.commons.httpclient.Cookie[] transferedCookies = null;
+         if(cookies != null){
+            transferedCookies = new org.apache.commons.httpclient.Cookie[cookies.length];
+            for(int i = 0; i < cookies.length; i++){
+               boolean secure = false; // http: false, https: true
+               transferedCookies[i] = new org.apache.commons.httpclient.Cookie(url.getHost(), cookies[i].getName(), cookies[i].getValue(), url.getFile(), null, secure);
+            }
+         }
+         // Initialize HttpClient
+         HttpClient httpClient = new HttpClient();
+         // Set cookies
+         if((transferedCookies != null) && (transferedCookies.length > 0)){
+            HttpState httpState = new HttpState();
+            httpState.addCookies(transferedCookies);
+            httpClient.setState(httpState);
+         }
+         // DEBUG cookies
+         // Send request to servlet
+         httpMethod.setRequestHeader("Content-type", "text/plain");
+         httpMethod.setPath(url.getPath());
+         // FIXME
+         for(Enumeration e = request.getHeaderNames(); e.hasMoreElements();){
+            String name = (String) e.nextElement();
+            httpMethod.addRequestHeader(name, request.getHeader(name));
+         }
+         HostConfiguration hostConfiguration = new HostConfiguration();
+         hostConfiguration.setHost(url.getHost(), url.getPort(), url.getProtocol());
+         log.debug("\n----------------------------------------------------------------" + "\n- Starting session at URI: " + url + "\n- Host:                    " + url.getHost() + "\n- Port:                    " + url.getPort() + "\n----------------------------------------------------------------");
+         if(trustStore != null){
+            System.setProperty("javax.net.ssl.trustStore", trustStore);
+         }
+         if(trustStorePassword != null){
+            System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
+         }
+         int result = httpClient.executeMethod(hostConfiguration, httpMethod);
+         log.debug("\n----------------------------------------------------------------" + "\n- Result:                    " + result + "\n----------------------------------------------------------------");
+         byte[] sresponse = httpMethod.getResponseBody();
+         httpMethod.releaseConnection();
+         // Return XML
+         InputSource input = new InputSource(new ByteArrayInputStream(sresponse));
+         parser = (SAXParser) this.manager.lookup(SAXParser.ROLE);
+         parser.parse(input, this.xmlConsumer);
+      }catch(SAXException e){
+         throw e;
+      }catch(Exception e){
+         getLogger().error("Generation failed: ", e);
+         throw new SAXException(e);
+      }finally{
+         this.manager.release((Component) parser);
+      }
+   }
+   /**
+    * Log input stream for debugging
+    * 
+    * @param in
+    *           an <code>InputStream</code> value
+    * 
+    * @return an <code>InputStream</code> value
+    * 
+    * @exception Exception
+    *               if an error occurs
+    */
+   private InputStream intercept(InputStream in) throws Exception {
+      byte[] buffer = new byte[1024];
+      int bytes_read;
+      ByteArrayOutputStream bufferOut = new ByteArrayOutputStream();
+      while((bytes_read = in.read(buffer)) != -1){
+         bufferOut.write(buffer, 0, bytes_read);
+      }
+      return new ByteArrayInputStream(bufferOut.toByteArray());
+   }
+   private URL createURL(Request request) throws MalformedURLException {
+      URL url = null;
+      try{
+         url = new URL(this.source);
+         log.debug(".createURL(): " + url);
+      }catch(MalformedURLException e){
+         url = new URL(request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + this.source);
+         log.debug(".createURL(): Add localhost and port: " + url);
+      }
+      return url;
+   }
+   // private void attribute(AttributesImpl attr, String name, String value) {
+   // attr.addAttribute("", name, name, "CDATA", value);
+   // }
+   // private void start(String name, AttributesImpl attr) throws SAXException {
+   // super.contentHandler.startElement(URI, name, name, attr);
+   // attr.clear();
+   // }
+   // private void end(String name) throws SAXException {
+   // super.contentHandler.endElement(URI, name, name);
+   // }
+   // private void data(String data) throws SAXException {
+   // super.contentHandler.characters(data.toCharArray(), 0, data.length());
+   // }
 }

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/task/CocoonTaskWrapper.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/task/CocoonTaskWrapper.java?rev=617035&r1=617034&r2=617035&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/task/CocoonTaskWrapper.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/task/CocoonTaskWrapper.java Wed Jan 30 23:44:03 2008
@@ -14,14 +14,10 @@
  *  limitations under the License.
  *
  */
-
 /* $Id$  */
-
 package org.apache.lenya.cms.cocoon.task;
-
 import java.util.Iterator;
 import java.util.Map;
-
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.cocoon.environment.Request;
@@ -41,143 +37,127 @@
 import org.apache.lenya.cms.task.WorkflowInvoker;
 import org.apache.lenya.util.NamespaceMap;
 import org.apache.lenya.util.ServletHelper;
-import org.apache.log4j.Category;
-
+import org.apache.log4j.Logger;
 /**
  * Task wrapper to be used from Cocoon components.
  */
 public class CocoonTaskWrapper extends DefaultTaskWrapper {
-
-	private static Category log = Category.getInstance(CocoonTaskWrapper.class);
-
-	/**
-	 * Ctor to be called from a Cocoon component.
-	 * @param objectModel A Cocoon object model.
-	 * @param parameters A parameters object.
-	 * @throws ExecutionException when something went wrong.
-	 */
-	public CocoonTaskWrapper(Map objectModel, Parameters parameters) throws ExecutionException {
-
-		log.debug("Creating CocoonTaskWrapper");
-
-		Publication publication;
-		try {
-			publication = PublicationFactory.getPublication(objectModel);
-		} catch (PublicationException e) {
-			throw new ExecutionException(e);
-		}
-		Request request = ObjectModelHelper.getRequest(objectModel);
-
-        initialize(parameters, publication, request);
-	}
-    
-    /**
-     * Ctor.
-     */
-    protected CocoonTaskWrapper() {
-    }
-
-    /**
-     * Initializes this wrapper.
-     * @param parameters The task parameters.
-     * @param publication The publication.
-     * @param request The request.
-     * @throws ExecutionException when something went wrong.
-     */
-    protected void initialize(Parameters parameters, Publication publication, Request request)
-        throws ExecutionException {
-        setNotifying(request);
-        
-        Parameters taskParameters = extractTaskParameters(parameters, publication, request);
-        getTaskParameters().parameterize(taskParameters);
-        
-        String taskId = request.getParameter(TaskWrapperParameters.TASK_ID);
-        taskId = parameters.getParameter(TaskWrapperParameters.TASK_ID, taskId);
-        
-        String webappUrl = ServletHelper.getWebappURI(request);
-        initialize(taskId, publication, webappUrl, taskParameters);
-        
-        String eventName = request.getParameter(WorkflowInvoker.EVENT_REQUEST_PARAMETER);
-        if (eventName == null) {
-        	eventName = request.getParameter(WorkflowInvoker.LENYA_EVENT_REQUEST_PARAMETER);
-        }
-        if (eventName != null) {
-        	Session session = request.getSession(false);
-        	if (session == null) {
-        		log.debug("No session found - not enabling workflow handling.");
-        	} else {
-        		Identity identity = Identity.getIdentity(session);
-        		if (identity == null) {
-        			log.debug("No identity found - not enabling workflow handling.");
-        		} else {
-        			log.debug("Identity found - enabling workflow handling.");
-        			Role[] roles;
-        			try {
-        				roles = PolicyAuthorizer.getRoles(request);
-        			} catch (AccessControlException e) {
-        				throw new ExecutionException(e);
-        			}
-        			setWorkflowAware(eventName, identity, roles);
-        		}
-        	}
-        }
-        
-    }
-
-	/**
-	 * Enables notification if the corresponding request parameters exist.
-	 * @param request The request.
-	 */
-	protected void setNotifying(Request request) {
-
-		log.debug("Trying to initialize notification ...");
-
-		Map requestParameters = ServletHelper.getParameterMap(request);
-
-		log.debug("    Request parameters:");
-		for (Iterator i = requestParameters.keySet().iterator(); i.hasNext();) {
-			Object key = i.next();
-			log.debug("        [" + key + "] = [" + requestParameters.get(key) + "]");
-		}
-
-		NamespaceMap notificationMap = new NamespaceMap(requestParameters, Notifier.PREFIX);
-
-		log.debug("    Notification parameters:");
-		for (Iterator i = notificationMap.getMap().keySet().iterator(); i.hasNext();) {
-			Object key = i.next();
-			log.debug("        [" + key + "] = [" + notificationMap.getMap().get(key) + "]");
-		}
-
-		if (notificationMap.getMap().isEmpty()) {
-			log.debug("    No notification parameters found.");
-		} else {
-			log.debug("    Initializing notification");
-            
-            Identity identity = Identity.getIdentity(request.getSession());
-            User user = identity.getUser();
-            String eMail = user.getEmail();
-            notificationMap.put(Notifier.PARAMETER_FROM, eMail);
-            log.debug("    Setting from address [" + Notifier.PARAMETER_FROM + "] = [" + eMail + "]");
-
-			String toKey = NamespaceMap.getFullName(Notifier.PREFIX, Notifier.PARAMETER_TO);
-			String toString = "";
-			String[] toValues = request.getParameterValues(toKey);
-
-			if (toValues == null) {
-				throw new IllegalStateException("You must specify at least one [notification.tolist] request parameter!");
-			}
-
-			for (int i = 0; i < toValues.length; i++) {
-				if (i > 0 && !"".equals(toString)) {
-					toString += ",";
-				}
-				log.debug("    Adding notification address [" + toValues[i].trim() + "]");
-				toString += toValues[i].trim();
-			}
-
-			notificationMap.put(Notifier.PARAMETER_TO, toString);
-			setNotifying(notificationMap);
-		}
-	}
-
+   private static Logger log = Logger.getLogger(CocoonTaskWrapper.class);
+   /**
+    * Ctor to be called from a Cocoon component.
+    * 
+    * @param objectModel
+    *           A Cocoon object model.
+    * @param parameters
+    *           A parameters object.
+    * @throws ExecutionException
+    *            when something went wrong.
+    */
+   public CocoonTaskWrapper(Map objectModel, Parameters parameters) throws ExecutionException {
+      log.debug("Creating CocoonTaskWrapper");
+      Publication publication;
+      try{
+         publication = PublicationFactory.getPublication(objectModel);
+      }catch(PublicationException e){
+         throw new ExecutionException(e);
+      }
+      Request request = ObjectModelHelper.getRequest(objectModel);
+      initialize(parameters, publication, request);
+   }
+   /**
+    * Ctor.
+    */
+   protected CocoonTaskWrapper() {
+   }
+   /**
+    * Initializes this wrapper.
+    * 
+    * @param parameters
+    *           The task parameters.
+    * @param publication
+    *           The publication.
+    * @param request
+    *           The request.
+    * @throws ExecutionException
+    *            when something went wrong.
+    */
+   protected void initialize(Parameters parameters, Publication publication, Request request) throws ExecutionException {
+      setNotifying(request);
+      Parameters taskParameters = extractTaskParameters(parameters, publication, request);
+      getTaskParameters().parameterize(taskParameters);
+      String taskId = request.getParameter(TaskWrapperParameters.TASK_ID);
+      taskId = parameters.getParameter(TaskWrapperParameters.TASK_ID, taskId);
+      String webappUrl = ServletHelper.getWebappURI(request);
+      initialize(taskId, publication, webappUrl, taskParameters);
+      String eventName = request.getParameter(WorkflowInvoker.EVENT_REQUEST_PARAMETER);
+      if(eventName == null){
+         eventName = request.getParameter(WorkflowInvoker.LENYA_EVENT_REQUEST_PARAMETER);
+      }
+      if(eventName != null){
+         Session session = request.getSession(false);
+         if(session == null){
+            log.debug("No session found - not enabling workflow handling.");
+         }else{
+            Identity identity = Identity.getIdentity(session);
+            if(identity == null){
+               log.debug("No identity found - not enabling workflow handling.");
+            }else{
+               log.debug("Identity found - enabling workflow handling.");
+               Role[] roles;
+               try{
+                  roles = PolicyAuthorizer.getRoles(request);
+               }catch(AccessControlException e){
+                  throw new ExecutionException(e);
+               }
+               setWorkflowAware(eventName, identity, roles);
+            }
+         }
+      }
+   }
+   /**
+    * Enables notification if the corresponding request parameters exist.
+    * 
+    * @param request
+    *           The request.
+    */
+   protected void setNotifying(Request request) {
+      log.debug("Trying to initialize notification ...");
+      Map requestParameters = ServletHelper.getParameterMap(request);
+      log.debug("    Request parameters:");
+      for(Iterator i = requestParameters.keySet().iterator(); i.hasNext();){
+         Object key = i.next();
+         log.debug("        [" + key + "] = [" + requestParameters.get(key) + "]");
+      }
+      NamespaceMap notificationMap = new NamespaceMap(requestParameters, Notifier.PREFIX);
+      log.debug("    Notification parameters:");
+      for(Iterator i = notificationMap.getMap().keySet().iterator(); i.hasNext();){
+         Object key = i.next();
+         log.debug("        [" + key + "] = [" + notificationMap.getMap().get(key) + "]");
+      }
+      if(notificationMap.getMap().isEmpty()){
+         log.debug("    No notification parameters found.");
+      }else{
+         log.debug("    Initializing notification");
+         Identity identity = Identity.getIdentity(request.getSession());
+         User user = identity.getUser();
+         String eMail = user.getEmail();
+         notificationMap.put(Notifier.PARAMETER_FROM, eMail);
+         log.debug("    Setting from address [" + Notifier.PARAMETER_FROM + "] = [" + eMail + "]");
+         String toKey = NamespaceMap.getFullName(Notifier.PREFIX, Notifier.PARAMETER_TO);
+         String toString = "";
+         String[] toValues = request.getParameterValues(toKey);
+         if(toValues == null){
+            throw new IllegalStateException("You must specify at least one [notification.tolist] request parameter!");
+         }
+         for(int i = 0; i < toValues.length; i++){
+            if(i > 0 && !"".equals(toString)){
+               toString += ",";
+            }
+            log.debug("    Adding notification address [" + toValues[i].trim() + "]");
+            toString += toValues[i].trim();
+         }
+         notificationMap.put(Notifier.PARAMETER_TO, toString);
+         setNotifying(notificationMap);
+      }
+   }
 }

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/transformation/VirtualTransformer.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/transformation/VirtualTransformer.java?rev=617035&r1=617034&r2=617035&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/transformation/VirtualTransformer.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/transformation/VirtualTransformer.java Wed Jan 30 23:44:03 2008
@@ -1,5 +1,4 @@
 package org.apache.lenya.cms.cocoon.transformation;
-
 import org.apache.avalon.framework.component.ComponentManager;
 import org.apache.cocoon.components.CocoonComponentManager;
 import org.apache.cocoon.environment.ObjectModelHelper;
@@ -8,40 +7,38 @@
 import org.apache.excalibur.source.Source;
 import org.apache.lenya.cms.cocoon.components.source.impl.StringSource;
 import org.apache.lenya.cms.cocoon.components.source.impl.VirtualSourceFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
 /**
  * This transformer creates a new VirtualDocument with the specified key.
  * 
- * @author <a href="mailto:[email protected]">Paul Ercolino</a>
+ * @author solprovider
+ * @since 1.3
  */
-public class VirtualTransformer extends AbstractDOMTransformer{
-   private static final String SERIALIZER_NAME = "xml";
+public class VirtualTransformer extends AbstractDOMTransformer {
    public static final String CONTENT_PREFIX = "content";
-
-   protected org.w3c.dom.Document transform(org.w3c.dom.Document doc){
+   protected org.w3c.dom.Document transform(org.w3c.dom.Document doc) {
       Request request = ObjectModelHelper.getRequest(super.objectModel);
       createVirtual(request, this.source, doc);
       return doc;
    }
-   static public org.w3c.dom.Document transformDocument(Request request, String key, org.w3c.dom.Document doc){
+   static public org.w3c.dom.Document transformDocument(Request request, String key, org.w3c.dom.Document doc) {
       createVirtual(request, key, doc);
       return doc;
    }
    /**
-    *
-    * @param request The request
-    * @param doc The data to be inserted.
+    * 
+    * @param request
+    *           The request
+    * @param doc
+    *           The data to be inserted.
     */
-   static private void createVirtual(Request request, String key, org.w3c.dom.Document doc){
-      if (doc == null){
-System.out.println("Virtual: Document is required.");
-//         throw new ProcessingException("CreateRevision: document is required.");
+   static private void createVirtual(Request request, String key, org.w3c.dom.Document doc) {
+      if(doc == null){
+         System.out.println("Virtual: Document is required.");
+         // throw new ProcessingException("CreateRevision: document is required.");
       }
       ComponentManager manager = CocoonComponentManager.getSitemapComponentManager();
-//      Element root = doc.getDocumentElement();
-//      Source source = (Source) new StringSource(manager, root);
+      // Element root = doc.getDocumentElement();
+      // Source source = (Source) new StringSource(manager, root);
       Source source = (Source) new StringSource(manager, doc);
       VirtualSourceFactory.addSource(key, source);
    }

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/uriparameterizer/URIParameterizerException.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/uriparameterizer/URIParameterizerException.java?rev=617035&r1=617034&r2=617035&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/uriparameterizer/URIParameterizerException.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/uriparameterizer/URIParameterizerException.java Wed Jan 30 23:44:03 2008
@@ -14,43 +14,43 @@
  *  limitations under the License.
  *
  */
-
 /* $Id$  */
-
 package org.apache.lenya.cms.cocoon.uriparameterizer;
-
 public class URIParameterizerException extends Exception {
-
-    /**
-     * Ctor.
-     */
-    public URIParameterizerException() {
-        super();
-    }
-
-    /**
-     * Ctor.
-     * @param message The message.
-     */
-    public URIParameterizerException(String message) {
-        super(message);
-    }
-
-    /**
-     * Ctor.
-     * @param message The message.
-     * @param cause The cause.
-     */
-    public URIParameterizerException(String message, Throwable cause) {
-        super(message, cause);
-    }
-
-    /**
-     * Ctor.
-     * @param cause The cause.
-     */
-    public URIParameterizerException(Throwable cause) {
-        super(cause);
-    }
-
+   private static final long serialVersionUID = 1L;
+   /**
+    * Ctor.
+    */
+   public URIParameterizerException() {
+      super();
+   }
+   /**
+    * Ctor.
+    * 
+    * @param message
+    *           The message.
+    */
+   public URIParameterizerException(String message) {
+      super(message);
+   }
+   /**
+    * Ctor.
+    * 
+    * @param message
+    *           The message.
+    * @param cause
+    *           The cause.
+    */
+   public URIParameterizerException(String message, Throwable cause) {
+      super(message, cause);
+   }
+   /**
+    * Ctor.
+    * 
+    * @param cause
+    *           The cause.
+    */
+   public URIParameterizerException(Throwable cause) {
+      super(cause);
+   }
 }

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=617035&r1=617034&r2=617035&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 Wed Jan 30 23:44:03 2008
@@ -1,6 +1,10 @@
 package org.apache.lenya.cms.content;
 
-
+/**
+ * 
+ * @author solprovider
+ * @since 1.3
+ */
 public interface Content{
    public static final String TYPE_FLAT = "flat";
    public static final String TYPE_HIERARCHICAL = "hierarchical";

Modified: 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=617035&r1=617034&r2=617035&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/ContentInputModule.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/ContentInputModule.java Wed Jan 30 23:44:03 2008
@@ -1,102 +1,78 @@
 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
+ * 
+ * @author solprovider
+ * @since 1.3
  */
-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);
-    }
+public class ContentInputModule extends AbstractPageEnvelopeModule implements ThreadSafe {
+   // 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);
+   }
 }

Modified: 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=617035&r1=617034&r2=617035&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/ContentSourceFactory.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/ContentSourceFactory.java Wed Jan 30 23:44:03 2008
@@ -1,5 +1,4 @@
 package org.apache.lenya.cms.content;
-
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.util.Map;
@@ -19,13 +18,10 @@
 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>
@@ -35,185 +31,201 @@
  * <BR>== Content Impls == <BR>
  * ContentHierarchical (Lenya 1.2) <BR>
  * ContentFlat (Lenya 1.3)
+ * 
+ * @author solprovider
+ * @since 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){
+   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();
-            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");
+         }
+         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;
-        }
-        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;
-    // }
-    // }
+         }
+      }
+      // 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/Resource.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/Resource.java?rev=617035&r1=617034&r2=617035&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/Resource.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/Resource.java Wed Jan 30 23:44:03 2008
@@ -1,14 +1,14 @@
 package org.apache.lenya.cms.content;
-
-import org.apache.excalibur.source.Source;
-import org.apache.excalibur.source.SourceNotFoundException;
 import org.w3c.dom.Document;
-
-public interface Resource{
+/**
+ * 
+ * @author solprovider
+ * @since 1.3
+ */
+public interface Resource {
    public String getURI();
    public String getMetaURI();
    public String getNewURI();
-
    public String getUNID();
    public String getID();
    public String getType();
@@ -18,17 +18,16 @@
    public String[] getLanguages();
    public Document getInfoDocument();
    public Document update(Document document);
-
-/**
- * Get Navigation Title from live revision of current language.
- */
+   /**
+    * Get Navigation Title from live revision of current language.
+    */
    public String getTitle();
-/**
- * Get Navigation Title from live revision of specified language.
- */
+   /**
+    * Get Navigation Title from live revision of specified language.
+    */
    public String getTitle(String language);
-/**
- * Get Navigation Title from specified revision of specified language.
- */
+   /**
+    * Get Navigation Title from specified revision of specified language.
+    */
    public String getTitle(String language, String revision);
 }

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/ResourceTransformer.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/ResourceTransformer.java?rev=617035&r1=617034&r2=617035&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/ResourceTransformer.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/ResourceTransformer.java Wed Jan 30 23:44:03 2008
@@ -1,29 +1,29 @@
 package org.apache.lenya.cms.content;
-
 import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.transformation.AbstractDOMTransformer;
 import org.apache.lenya.cms.publication.PageEnvelope;
 import org.apache.lenya.cms.publication.Publication;
-
 /**
  * This transformer modifies the structural information of a Resource. It accepts a UNID as the src parameter. It can: - change the id and defaultlanguage of the Resource, - delete Translations and Revisions, - change the live and edit Revisions of Translations. <resource [id="newid"] [defaultlanguage="aa"]> <translation language="xx" [action="delete"] [live="1137958604000"] [edit="1137958604000"]> <revision revision="1137958604000" [action="delete"]/> </translation> </resource> action="delete" has top priority. Any settings not included will not be affected.
- * @author <a href="mailto:[email protected]">Paul Ercolino</a>
+ * 
+ * @author solprovider
+ * @since 1.3
  */
 public class ResourceTransformer extends AbstractDOMTransformer {
-    protected org.w3c.dom.Document transform(org.w3c.dom.Document doc) {
-        System.out.println("ResourceTransformer - BEGIN");
-        String unid = this.source;
-        Request request = ObjectModelHelper.getRequest(super.objectModel);
-        return transformDocument(request, unid, doc);
-    }
-    static public org.w3c.dom.Document transformDocument(Request request, String unid, org.w3c.dom.Document doc) {
-        PageEnvelope envelope = (PageEnvelope) request.getAttribute(PageEnvelope.class.getName());
-        Publication pub = envelope.getPublication();
-        Content content = pub.getContent();
-        Resource resource = content.getResource(unid);
-        resource.update(doc);
-        // System.out.println("ResourceTransformer - RETURN");
-        return doc;
-    }
+   protected org.w3c.dom.Document transform(org.w3c.dom.Document doc) {
+      System.out.println("ResourceTransformer - BEGIN");
+      String unid = this.source;
+      Request request = ObjectModelHelper.getRequest(super.objectModel);
+      return transformDocument(request, unid, doc);
+   }
+   static public org.w3c.dom.Document transformDocument(Request request, String unid, org.w3c.dom.Document doc) {
+      PageEnvelope envelope = (PageEnvelope) request.getAttribute(PageEnvelope.class.getName());
+      Publication pub = envelope.getPublication();
+      Content content = pub.getContent();
+      Resource resource = content.getResource(unid);
+      resource.update(doc);
+      // System.out.println("ResourceTransformer - RETURN");
+      return doc;
+   }
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.