You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2009/02/06 18:55:33 UTC

svn commit: r741654 [4/9] - in /lenya/trunk: org.apache.lenya.core.ac/src/main/java/org/apache/lenya/ac/impl/ org.apache.lenya.core.ac/src/main/java/org/apache/lenya/cms/ac/ org.apache.lenya.core.ac/src/main/java/org/apache/lenya/cms/cocoon/acting/ org...

Modified: lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/OutgoingLinkRewriter.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/OutgoingLinkRewriter.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/OutgoingLinkRewriter.java (original)
+++ lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/OutgoingLinkRewriter.java Fri Feb  6 17:55:28 2009
@@ -25,9 +25,8 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.ServiceSelector;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 import org.apache.lenya.ac.AccessController;
 import org.apache.lenya.ac.AccessControllerResolver;
 import org.apache.lenya.ac.AccreditableManager;
@@ -63,36 +62,32 @@
     private boolean considerSslPolicies;
 
     /**
-     * @param manager The service manager to use.
      * @param session The current session.
-     * @param requestUrl The requested web application URL (without servlet context path) where
-     *        the links should be rewritten.
+     * @param requestUrl The requested web application URL (without servlet context path) where the
+     *            links should be rewritten.
      * @param ssl If the current page is SSL-encrypted.
      * @param considerSslPolicies If the SSL protection of policies should be considered when
-     *        resolving the corresponding proxy. Setting this to <code>true</code> leads to a
-     *        substantial performance overhead.
+     *            resolving the corresponding proxy. Setting this to <code>true</code> leads to a
+     *            substantial performance overhead.
      * @param relativeUrls If relative URLs should be created.
      */
-    public OutgoingLinkRewriter(ServiceManager manager, Session session, String requestUrl,
-            boolean ssl, boolean considerSslPolicies, boolean relativeUrls) {
-
-        super(manager);
+    public OutgoingLinkRewriter(Session session, String requestUrl, boolean ssl,
+            boolean considerSslPolicies, boolean relativeUrls) {
         this.requestUrl = requestUrl;
         this.relativeUrls = relativeUrls;
         this.ssl = ssl;
         this.considerSslPolicies = considerSslPolicies;
 
         ServiceSelector serviceSelector = null;
-        AccessControllerResolver acResolver = null;
 
         try {
-            this.factory = DocumentUtil.createDocumentFactory(this.manager, session);
+            this.factory = DocumentUtil.createDocumentFactory(session);
 
             if (this.considerSslPolicies) {
-                serviceSelector = (ServiceSelector) this.manager
-                        .lookup(AccessControllerResolver.ROLE + "Selector");
-                acResolver = (AccessControllerResolver) serviceSelector
-                        .select(AccessControllerResolver.DEFAULT_RESOLVER);
+                AccessControllerResolver acResolver = (AccessControllerResolver) WebAppContextUtils
+                        .getCurrentWebApplicationContext().getBean(
+                                AccessControllerResolver.ROLE + "/"
+                                        + AccessControllerResolver.DEFAULT_RESOLVER);
                 AccessController accessController = acResolver.resolveAccessController(requestUrl);
                 if (accessController != null) {
                     this.accreditableManager = accessController.getAccreditableManager();
@@ -107,23 +102,13 @@
 
         } catch (final Exception e) {
             throw new RuntimeException(e);
-        } finally {
-            if (serviceSelector != null) {
-                if (acResolver != null) {
-                    serviceSelector.release(acResolver);
-                }
-                this.manager.release(serviceSelector);
-            }
         }
     }
 
     protected GlobalProxies getGlobalProxies() {
         if (this.globalProxies == null) {
-            try {
-                this.globalProxies = (GlobalProxies) this.manager.lookup(GlobalProxies.ROLE);
-            } catch (ServiceException e) {
-                throw new RuntimeException(e);
-            }
+            this.globalProxies = (GlobalProxies) WebAppContextUtils
+                    .getCurrentWebApplicationContext().getBean(GlobalProxies.ROLE);
         }
         return this.globalProxies;
     }
@@ -141,27 +126,25 @@
     public String rewrite(final String url) {
 
         String rewrittenUrl = "";
-        
+
         String path;
         String suffix;
-        
+
         int numIndex = url.indexOf('#');
         if (numIndex > -1) {
             path = url.substring(0, numIndex);
             suffix = url.substring(numIndex);
-        }
-        else {
+        } else {
             int qmIndex = url.indexOf('?');
             if (qmIndex > -1) {
                 path = url.substring(0, qmIndex);
                 suffix = url.substring(qmIndex);
-            }
-            else {
+            } else {
                 path = url;
                 suffix = "";
             }
         }
-        
+
         try {
             String normalizedUrl = normalizeUrl(path);
             if (this.relativeUrls) {
@@ -258,11 +241,10 @@
         String relativeUrl;
         if (this.requestUrl.equals(webappUrl)) {
             relativeUrl = getLastStep(webappUrl);
-        }
-        else {
+        } else {
             List sourceSteps = toList(this.requestUrl);
             List targetSteps = toList(webappUrl);
-            
+
             String lastEqualStep = null;
 
             while (!sourceSteps.isEmpty() && !targetSteps.isEmpty()
@@ -274,14 +256,11 @@
             String prefix = "";
             if (targetSteps.isEmpty()) {
                 prefix = generateUpDots(sourceSteps.size());
-            }
-            else if (sourceSteps.isEmpty()) {
+            } else if (sourceSteps.isEmpty()) {
                 prefix = getLastStep(this.requestUrl) + "/";
-            }
-            else if (sourceSteps.size() > 1) {
+            } else if (sourceSteps.size() > 1) {
                 prefix = generateUpDots(sourceSteps.size() - 1) + "/";
-            }
-            else if (sourceSteps.size() == 1 && targetSteps.get(0).equals("")) {
+            } else if (sourceSteps.size() == 1 && targetSteps.get(0).equals("")) {
                 prefix = generateUpDots(1) + "/" + lastEqualStep + "/";
             }
 

Modified: lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/ServletLinkRewriter.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/ServletLinkRewriter.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/ServletLinkRewriter.java (original)
+++ lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/ServletLinkRewriter.java Fri Feb  6 17:55:28 2009
@@ -17,40 +17,21 @@
  */
 package org.apache.lenya.cms.linking;
 
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.lenya.cms.cocoon.components.context.ContextUtility;
+import org.apache.cocoon.processing.ProcessInfoProvider;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 
 /**
  * Abstract base class for servlet-oriented link rewriters.
  */
 public abstract class ServletLinkRewriter implements LinkRewriter {
-    
-    protected ServiceManager manager;
-
-    /**
-     * @param manager The service manager.
-     */
-    public ServletLinkRewriter(ServiceManager manager) {
-        this.manager = manager;
-    }
 
     private String contextPath;
-    
+
     protected String getContextPath() {
         if (this.contextPath == null) {
-            ContextUtility context = null;
-            try {
-                context = (ContextUtility) this.manager.lookup(ContextUtility.ROLE);
-                this.contextPath = context.getRequest().getContextPath();
-            } catch (ServiceException e) {
-                throw new RuntimeException(e);
-            }
-            finally {
-                if (context != null) {
-                    this.manager.release(context);
-                }
-            }
+            ProcessInfoProvider process = (ProcessInfoProvider) WebAppContextUtils
+                    .getCurrentWebApplicationContext().getBean(ProcessInfoProvider.ROLE);
+            this.contextPath = process.getRequest().getContextPath();
         }
         return this.contextPath;
     }

Modified: lenya/trunk/org.apache.lenya.core.metadata/pom.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.metadata/pom.xml?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.metadata/pom.xml (original)
+++ lenya/trunk/org.apache.lenya.core.metadata/pom.xml Fri Feb  6 17:55:28 2009
@@ -16,6 +16,10 @@
   <name>Apache Lenya Core Metadata</name>
   <dependencies>
     <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>servlet-api</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.avalon.framework</groupId>
       <artifactId>avalon-framework-api</artifactId>
     </dependency>

Modified: lenya/trunk/org.apache.lenya.core.metadata/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/MetaDataModule.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.metadata/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/MetaDataModule.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.metadata/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/MetaDataModule.java (original)
+++ lenya/trunk/org.apache.lenya.core.metadata/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/MetaDataModule.java Fri Feb  6 17:55:28 2009
@@ -34,16 +34,20 @@
 
 /**
  * <p>
- * Input module to access meta data values. Use the name of the element as
- * input module parameter.
+ * Input module to access meta data values. Use the name of the element as input module parameter.
  * </p>
- * <p>Configuration:</p>
+ * <p>
+ * Configuration:
+ * </p>
+ * 
  * <pre>
- *  &lt;component-instance logger="sitemap.modules.input.dublincore" name="[...]"
- *    class="org.apache.lenya.cms.cocoon.components.modules.input.MetaDataModule"
- *    namespace="[namespace URI of the element set]"/&gt;
+ *  &lt;component-instance logger=&quot;sitemap.modules.input.dublincore&quot; name=&quot;[...]&quot;
+ *    class=&quot;org.apache.lenya.cms.cocoon.components.modules.input.MetaDataModule&quot;
+ *    namespace=&quot;[namespace URI of the element set]&quot;/&gt;
  * </pre>
- * <p>Usage examples:</p>
+ * <p>
+ * Usage examples:
+ * </p>
  * <ul>
  * <li><code>{dublincore:title}</code></li>
  * <li><code>{myMetData:myElementName}</code></li>
@@ -51,6 +55,8 @@
  */
 public class MetaDataModule extends AbstractPageEnvelopeModule {
 
+    private MetaDataRegistry metaDataRegistry;
+
     /**
      * @see org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String,
      *      org.apache.avalon.framework.configuration.Configuration, java.util.Map)
@@ -81,11 +87,9 @@
      */
     public Iterator getAttributeNames(Configuration modeConf, Map objectModel)
             throws ConfigurationException {
-
-        MetaDataRegistry registry = null;
         try {
-            registry = (MetaDataRegistry) this.manager.lookup(MetaDataRegistry.ROLE);
-            Element[] elements = registry.getElementSet(this.namespaceUri).getElements();
+            Element[] elements = getMetaDataRegistry().getElementSet(this.namespaceUri)
+                    .getElements();
             String[] keys = new String[elements.length];
             for (int i = 0; i < keys.length; i++) {
                 keys[i] = elements[i].getName();
@@ -94,9 +98,6 @@
         } catch (Exception e) {
             throw new ConfigurationException(e.getMessage(), e);
         }
-        finally {
-            this.manager.release(registry);
-        }
     }
 
     /**
@@ -132,19 +133,25 @@
         try {
             metaData = document.getMetaData(this.namespaceUri);
         } catch (MetaDataException e) {
-            throw new ConfigurationException("Obtaining custom meta data value for ["
-                    + document + "] failed: ", e);
+            throw new ConfigurationException("Obtaining custom meta data value for [" + document
+                    + "] failed: ", e);
         }
         return metaData;
     }
 
     private String namespaceUri;
-    
+
     public void configure(Configuration conf) throws ConfigurationException {
         super.configure(conf);
         this.namespaceUri = conf.getAttribute("namespace");
     }
-    
-    
-    
+
+    public MetaDataRegistry getMetaDataRegistry() {
+        return metaDataRegistry;
+    }
+
+    public void setMetaDataRegistry(MetaDataRegistry metaDataRegistry) {
+        this.metaDataRegistry = metaDataRegistry;
+    }
+
 }

Modified: lenya/trunk/org.apache.lenya.core.metadata/src/main/java/org/apache/lenya/modules/metadata/ChangeMetaData.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.metadata/src/main/java/org/apache/lenya/modules/metadata/ChangeMetaData.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.metadata/src/main/java/org/apache/lenya/modules/metadata/ChangeMetaData.java (original)
+++ lenya/trunk/org.apache.lenya.core.metadata/src/main/java/org/apache/lenya/modules/metadata/ChangeMetaData.java Fri Feb  6 17:55:28 2009
@@ -20,7 +20,6 @@
 import org.apache.lenya.cms.metadata.MetaData;
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.usecase.DocumentUsecase;
 import org.apache.lenya.cms.usecase.UsecaseInvoker;
 import org.apache.lenya.cms.workflow.usecases.InvokeWorkflow;
 import org.apache.lenya.util.Assert;
@@ -29,29 +28,22 @@
  * Save a meta data element.
  */
 public class ChangeMetaData extends InvokeWorkflow {
-    
+
     protected static final String PARAM_NAMESPACE = "namespace";
     protected static final String PARAM_ELEMENT = "element";
     protected static final String PARAM_VALUE = "value";
     protected static final String PARAM_OLD_VALUE = "oldValue";
-    
+
+    private UsecaseInvoker usecaseInvoker;
+
     protected void prepareView() throws Exception {
         super.prepareView();
-        UsecaseInvoker invoker = null;
-        try {
-            invoker = (UsecaseInvoker) this.manager.lookup(UsecaseInvoker.ROLE);
-            invoker.invoke(getSourceURL(), getName(), getParameters());
-        }
-        finally {
-            if (invoker != null) {
-                this.manager.release(invoker);
-            }
-        }
+        getUsecaseInvoker().invoke(getSourceURL(), getName(), getParameters());
     }
 
     protected void doCheckPreconditions() throws Exception {
         super.doCheckPreconditions();
-        
+
         Document doc = getSourceDocument();
         if (doc == null) {
             return;
@@ -69,23 +61,23 @@
         Assert.notNull("value", value);
         String oldValue = getParameterAsString(PARAM_OLD_VALUE);
         Assert.notNull("old value", oldValue);
-        
+
         MetaData meta = getSourceDocument().getMetaData(namespace);
-        
+
         String currentValue = meta.getFirstValue(element);
         if (currentValue == null) {
             currentValue = "";
         }
-        
+
         if (!oldValue.equals(currentValue)) {
             addErrorMessage("concurrent-change");
         }
     }
 
     protected void doExecute() throws Exception {
-        
+
         super.doExecute();
-        
+
         String namespace = getParameterAsString(PARAM_NAMESPACE);
         Assert.notNull("namespace", namespace);
         String element = getParameterAsString(PARAM_ELEMENT);
@@ -94,8 +86,20 @@
         Assert.notNull("value", value);
         String oldValue = getParameterAsString(PARAM_OLD_VALUE);
         Assert.notNull("old value", oldValue);
-        
+
         MetaData meta = getSourceDocument().getMetaData(namespace);
         meta.setValue(element, value);
     }
+
+    protected UsecaseInvoker getUsecaseInvoker() {
+        return usecaseInvoker;
+    }
+
+    /**
+     * TODO: Bean wiring
+     */
+    public void setUsecaseInvoker(UsecaseInvoker usecaseInvoker) {
+        this.usecaseInvoker = usecaseInvoker;
+    }
+
 }

Modified: lenya/trunk/org.apache.lenya.core.metadata/src/main/java/org/apache/lenya/modules/metadata/MetaDataTransformer.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.metadata/src/main/java/org/apache/lenya/modules/metadata/MetaDataTransformer.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.metadata/src/main/java/org/apache/lenya/modules/metadata/MetaDataTransformer.java (original)
+++ lenya/trunk/org.apache.lenya.core.metadata/src/main/java/org/apache/lenya/modules/metadata/MetaDataTransformer.java Fri Feb  6 17:55:28 2009
@@ -24,7 +24,6 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.cocoon.ProcessingException;
 import org.apache.cocoon.environment.ObjectModelHelper;
@@ -37,26 +36,35 @@
 import org.apache.lenya.cms.publication.DocumentFactory;
 import org.apache.lenya.cms.publication.DocumentUtil;
 import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.PublicationException;
+import org.apache.lenya.cms.repository.RepositoryManager;
+import org.apache.lenya.cms.repository.RepositoryUtil;
+import org.apache.lenya.cms.repository.Session;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.AttributesImpl;
 
 /**
- * <p>Meta data transformer.</p>
- * <p>Usage example:</p>
+ * <p>
+ * Meta data transformer.
+ * </p>
+ * <p>
+ * Usage example:
+ * </p>
+ * 
  * <pre>
- * &lt;meta:value xmlns:meta="http://apache.org/lenya/meta/1.0/"
- *   element="title"
- *   ns="http://purl.org/dc/elements/1.1/"
- *   uuid="{$uuid}"
- *   lang="{$language}"
- *   default="default-title"
- *   i18n:attr="default" /&gt;
+ * &lt;meta:value xmlns:meta=&quot;http://apache.org/lenya/meta/1.0/&quot;
+ *   element=&quot;title&quot;
+ *   ns=&quot;http://purl.org/dc/elements/1.1/&quot;
+ *   uuid=&quot;{$uuid}&quot;
+ *   lang=&quot;{$language}&quot;
+ *   default=&quot;default-title&quot;
+ *   i18n:attr=&quot;default&quot; /&gt;
  * </pre>
- * <p>The attribute <em>default</em> is optional.</p>
+ * <p>
+ * The attribute <em>default</em> is optional.
+ * </p>
  */
-public class MetaDataTransformer extends AbstractSAXTransformer implements Disposable {
+public class MetaDataTransformer extends AbstractSAXTransformer {
     /**
      * The namespace for the meta data is http://apache.org/lenya/meta/1.0
      */
@@ -105,6 +113,7 @@
     protected String uuid = null;
     protected Publication pub;
     private DocumentFactory factory;
+    protected RepositoryManager repositoryManager;
 
     /**
      * Setup the MetaDataTransformer.
@@ -124,10 +133,11 @@
                     "The area is not set! Please set like e.g. <map:parameter name='area' value='{request-param:area}'/>");
         }
         Request request = ObjectModelHelper.getRequest(objectModel);
-        factory = DocumentUtil.getDocumentFactory(this.manager, request);
         try {
+            Session session = RepositoryUtil.getSession(this.repositoryManager, request);
+            factory = DocumentUtil.createDocumentFactory(session);
             pub = factory.getPublication(this.publicationId);
-        } catch (PublicationException e) {
+        } catch (Exception e) {
             throw new ProcessingException("Error geting publication id / area from page envelope",
                     e);
         }
@@ -216,4 +226,8 @@
         this.factory = null;
     }
 
+    public void setRepositoryManager(RepositoryManager repositoryManager) {
+        this.repositoryManager = repositoryManager;
+    }
+
 }

Modified: lenya/trunk/org.apache.lenya.core.properties/pom.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.properties/pom.xml?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.properties/pom.xml (original)
+++ lenya/trunk/org.apache.lenya.core.properties/pom.xml Fri Feb  6 17:55:28 2009
@@ -16,6 +16,10 @@
   <name>Apache Lenya Core Properties</name>
   <dependencies>
     <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>servlet-api</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.avalon.framework</groupId>
       <artifactId>avalon-framework-api</artifactId>
     </dependency>

Modified: lenya/trunk/org.apache.lenya.core.properties/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/PropertiesModule.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.properties/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/PropertiesModule.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.properties/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/PropertiesModule.java (original)
+++ lenya/trunk/org.apache.lenya.core.properties/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/PropertiesModule.java Fri Feb  6 17:55:28 2009
@@ -28,12 +28,7 @@
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
-import org.apache.avalon.framework.activity.Initializable;
 import org.apache.avalon.framework.configuration.ConfigurationException;
-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.modules.input.DefaultsModule;
 import org.apache.cocoon.components.modules.input.InputModule;
 import org.apache.cocoon.environment.ObjectModelHelper;
@@ -43,9 +38,9 @@
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceResolver;
 import org.apache.lenya.cms.module.ModuleManager;
-import org.apache.lenya.cms.publication.DocumentFactory;
-import org.apache.lenya.cms.publication.DocumentUtil;
 import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.publication.Repository;
+import org.apache.lenya.cms.publication.Session;
 import org.apache.lenya.cms.publication.URLInformation;
 import org.apache.lenya.util.ServletHelper;
 import org.w3c.dom.Document;
@@ -58,27 +53,21 @@
  * are the locations of the <b>source </b> directories and of the <b>Lenya </b>
  * directories.
  */
-public class PropertiesModule extends DefaultsModule implements InputModule, Initializable,
-        ThreadSafe, Serviceable {
+public class PropertiesModule extends DefaultsModule implements InputModule {
 
     private Map pubId2roperties = new HashMap();
 
-	// FIXME Use commons-configuration
-    private Configuration globalProperties;
-
-    private SourceResolver m_resolver;
-
-    private ModuleManager moduleManager;
-
-    private ServiceManager serviceManager;
-
     private final static String LENYA_HOME = "context:/";
-
     private final static String DEFAULT_HOME_PROP = "lenya.home";
-
     private final static String PROPERTY_FILE_NAME = "lenya.properties.xml";
-
     private final static String PROPERTY_FILE_NAME_LOCAL = "local." + PROPERTY_FILE_NAME;
+    
+	// FIXME Use commons-configuration
+    private Configuration globalProperties;
+    private SourceResolver sourceResolver;
+    private ModuleManager moduleManager;
+
+    protected Repository repository;
 
     public Object getAttribute(String name, Configuration modeConf, Map objectModel)
             throws ConfigurationException {
@@ -117,10 +106,10 @@
         String webappUrl = ServletHelper.getWebappURI(request);
         URLInformation info = new URLInformation(webappUrl);
         String pubId = info.getPublicationId();
-        DocumentFactory factory = DocumentUtil.getDocumentFactory(this.serviceManager, request);
-        if (factory.existsPublication(pubId)) {
+        Session session = this.repository.getSession(request);
+        if (session.existsPublication(pubId)) {
             try {
-                Publication pub = factory.getPublication(pubId);
+                Publication pub = session.getPublication(pubId);
                 properties = getPublicationProperties(pub);
             }
             catch (Exception e) {
@@ -176,10 +165,10 @@
         merge(this.globalProperties, lenyaProperties);
         
         // get the values from all modules
-        String[] module2src = moduleManager.getModuleIds();
+        String[] module2src = this.moduleManager.getModuleIds();
         for (int i = 0; i < module2src.length; i++) {
             String moduleName = module2src[i];
-            String moduleBaseUri = moduleManager.getBaseURI(moduleName);
+            String moduleBaseUri = this.moduleManager.getBaseURI(moduleName);
             if (moduleBaseUri != null) {
                 String modulePropsUri = moduleBaseUri + "/" + PROPERTY_FILE_NAME;
                 Configuration moduleProperties = loadXMLPropertiesFromURI(modulePropsUri);
@@ -239,7 +228,7 @@
         Source source = null;
         try {
 
-            source = m_resolver.resolveURI(uri);
+            source = this.sourceResolver.resolveURI(uri);
 
             if (source.exists()) {
 
@@ -260,7 +249,7 @@
             }
         } finally {
             if (source != null) {
-                m_resolver.release(source);
+                this.sourceResolver.release(source);
             }
         }
         return properties;
@@ -299,12 +288,6 @@
         }
     }
 
-    public void service(ServiceManager manager) throws ServiceException {
-        this.serviceManager = manager;
-        m_resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
-        moduleManager = (ModuleManager) manager.lookup(ModuleManager.ROLE);
-    }
-
     /**
      * Rocket science
      */
@@ -321,4 +304,16 @@
         getLogger().debug(debugString);
     }
 
+    public void setRepository(Repository repository) {
+        this.repository = repository;
+    }
+
+    public void setSourceResolver(SourceResolver sourceResolver) {
+        this.sourceResolver = sourceResolver;
+    }
+
+    public void setModuleManager(ModuleManager moduleManager) {
+        this.moduleManager = moduleManager;
+    }
+
 }

Modified: lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/metadata/usecases/Metadata.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/metadata/usecases/Metadata.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/metadata/usecases/Metadata.java (original)
+++ lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/metadata/usecases/Metadata.java Fri Feb  6 17:55:28 2009
@@ -38,6 +38,8 @@
  * @version $Id$
  */
 public class Metadata extends SiteUsecase {
+    
+    private MetaDataRegistry metaDataRegistry;
 
     /**
      * @see org.apache.lenya.cms.usecase.AbstractUsecase#getNodesToLock()
@@ -106,21 +108,18 @@
         }
         
 
-        MetaDataRegistry registry = null;
         try {
-            boolean canChange = WorkflowUtil.canInvoke(this.manager, getLogger(), doc, "edit");
+            boolean canChange = WorkflowUtil.canInvoke(getLogger(), doc, "edit");
             
             if (!canChange) {
                 addInfoMessage("cannot-change-metadata");
             }
             
-            registry = (MetaDataRegistry) this.manager.lookup(MetaDataRegistry.ROLE);
-
             List numbers = new ArrayList();
             Map num2namespace = new HashMap();
             List keyList = new ArrayList();
 
-            String[] namespaces = registry.getNamespaceUris();
+            String[] namespaces = getMetaDataRegistry().getNamespaceUris();
 
             for (int nsIndex = 0; nsIndex < namespaces.length; nsIndex++) {
                 MetaData meta = doc.getMetaData(namespaces[nsIndex]);
@@ -145,11 +144,15 @@
         } catch (Exception e) {
             getLogger().error("Unable to load meta data.", e);
             addErrorMessage("Unable to load meta data: " + e.getMessage());
-        } finally {
-            if (registry != null) {
-                this.manager.release(registry);
-            }
         }
     }
 
+    protected MetaDataRegistry getMetaDataRegistry() {
+        return metaDataRegistry;
+    }
+
+    public void setMetaDataRegistry(MetaDataRegistry metaDataRegistry) {
+        this.metaDataRegistry = metaDataRegistry;
+    }
+    
 }

Modified: lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Assets.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Assets.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Assets.java (original)
+++ lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Assets.java Fri Feb  6 17:55:28 2009
@@ -47,7 +47,7 @@
                 throw new RuntimeException(e);
             }
             
-            if (!ServletHelper.isUploadEnabled(this.manager)) {
+            if (!ServletHelper.isUploadEnabled()) {
                 addErrorMessage(MESSAGE_UPLOAD_DISABLED);
                 setParameter(PARAMETER_UPLOAD_ENABLED, Boolean.FALSE);
             }

Modified: lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/ChangeLabel.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/ChangeLabel.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/ChangeLabel.java (original)
+++ lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/ChangeLabel.java Fri Feb  6 17:55:28 2009
@@ -58,8 +58,7 @@
             addErrorMessage("This usecase can only be invoked in the authoring area!");
         }
 
-        UsecaseWorkflowHelper.checkWorkflow(this.manager, this, getEvent(), doc,
-                getLogger());
+        UsecaseWorkflowHelper.checkWorkflow(this, getEvent(), doc, getLogger());
     }
 
     /**
@@ -67,10 +66,10 @@
      */
     protected Node[] getNodesToLock() throws UsecaseException {
         List nodes = new ArrayList();
-        if(getSourceDocument() != null) {
+        if (getSourceDocument() != null) {
             SiteStructure structure = getSourceDocument().area().getSite();
             nodes.add(structure.getRepositoryNode());
-        }    
+        }
 
         return (Node[]) nodes.toArray(new Node[nodes.size()]);
     }
@@ -101,7 +100,6 @@
         }
     }
 
-
     /**
      * @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
      */
@@ -112,7 +110,7 @@
         String label = getParameterAsString(LABEL).trim();
         document.getLink().setLabel(label);
 
-        WorkflowUtil.invoke(this.manager, getLogger(), document, getEvent());
+        WorkflowUtil.invoke(getLogger(), document, getEvent());
 
     }
 }

Modified: lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/ChangeNodeID.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/ChangeNodeID.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/ChangeNodeID.java (original)
+++ lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/ChangeNodeID.java Fri Feb  6 17:55:28 2009
@@ -46,6 +46,7 @@
 public class ChangeNodeID extends DocumentUsecase {
 
     protected static final String NODE_ID = "nodeId";
+    private DocumentManager documentManager;
 
     /**
      * @see org.apache.lenya.cms.usecase.AbstractUsecase#initParameters()
@@ -66,13 +67,13 @@
         List nodes = new ArrayList();
 
         try {
-            if(getSourceDocument() != null) {
+            if (getSourceDocument() != null) {
                 Node siteNode = getSourceDocument().area().getSite().getRepositoryNode();
                 nodes.add(siteNode);
 
                 Document sourceDocument = getSourceDocument();
-  
-                NodeSet subsite = SiteUtil.getSubSite(this.manager, sourceDocument.getLink().getNode());
+
+                NodeSet subsite = SiteUtil.getSubSite(sourceDocument.getLink().getNode());
                 for (NodeIterator i = subsite.iterator(); i.hasNext();) {
                     SiteNode node = i.next();
                     String[] languages = node.getLanguages();
@@ -156,17 +157,8 @@
         Document targetDoc;
         Document source = getSourceDocument();
         DocumentLocator target = getTargetLocator();
-        DocumentManager documentManager = null;
-        try {
-            documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
-            documentManager.moveAll(source.area(), source.getPath(), source.area(), target
-                    .getPath());
-            targetDoc = getDocumentFactory().get(target);
-        } finally {
-            if (documentManager != null) {
-                this.manager.release(documentManager);
-            }
-        }
+        getDocumentManager().moveAll(source.area(), source.getPath(), source.area(), target.getPath());
+        targetDoc = getDocumentFactory().get(target);
 
         setTargetDocument(targetDoc);
     }
@@ -190,4 +182,16 @@
 
         return newDocumentId;
     }
+
+    protected DocumentManager getDocumentManager() {
+        return documentManager;
+    }
+
+    /**
+     * TODO: Bean wiring
+     */
+    public void setDocumentManager(DocumentManager documentManager) {
+        this.documentManager = documentManager;
+    }
+
 }

Modified: lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/ChangeVisibility.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/ChangeVisibility.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/ChangeVisibility.java (original)
+++ lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/ChangeVisibility.java Fri Feb  6 17:55:28 2009
@@ -49,8 +49,7 @@
             } catch (DocumentException e) {
                 throw new RuntimeException(e);
             }
-        }
-        else {
+        } else {
             return super.getParameter(name);
         }
     }
@@ -72,8 +71,7 @@
         String[] languages = doc.getLanguages();
         for (int i = 0; i < languages.length; i++) {
             Document version = doc.getTranslation(languages[i]);
-            UsecaseWorkflowHelper.checkWorkflow(this.manager, this, getEvent(), version,
-                    getLogger());
+            UsecaseWorkflowHelper.checkWorkflow(this, getEvent(), version, getLogger());
         }
     }
 
@@ -86,7 +84,7 @@
         String[] languages = doc.getLanguages();
         for (int i = 0; i < languages.length; i++) {
             Document version = doc.getTranslation(languages[i]);
-            WorkflowUtil.invoke(this.manager, getLogger(), version, getEvent());
+            WorkflowUtil.invoke(getLogger(), version, getEvent());
         }
     }
 
@@ -95,7 +93,7 @@
      */
     protected Node[] getNodesToLock() throws UsecaseException {
         List nodes = new ArrayList();
-        if(getSourceDocument() != null) {
+        if (getSourceDocument() != null) {
             SiteStructure structure = getSourceDocument().area().getSite();
             nodes.add(structure.getRepositoryNode());
         }

Modified: lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/ClipboardHelper.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/ClipboardHelper.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/ClipboardHelper.java (original)
+++ lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/ClipboardHelper.java Fri Feb  6 17:55:28 2009
@@ -17,13 +17,8 @@
  */
 package org.apache.lenya.cms.site.usecases;
 
-import java.util.Map;
-
-import org.apache.avalon.framework.context.Context;
-import org.apache.cocoon.components.ContextHelper;
-import org.apache.cocoon.environment.ObjectModelHelper;
-import org.apache.cocoon.environment.Request;
-import org.apache.cocoon.environment.Session;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
 
 /**
  * Helper class for clipboard handling.
@@ -38,10 +33,9 @@
      * @return A clipboard or <code>null</code> if no clipboard is attached to
      *         the session.
      */
-    public Clipboard getClipboard(Context context) {
-        Session session = getSession(context);
-        Clipboard clipboard = (Clipboard) session.getAttribute(getSessionAttributeName());
-        return clipboard;
+    public Clipboard getClipboard(HttpServletRequest request) {
+        HttpSession session = request.getSession();
+        return (Clipboard) session.getAttribute(getSessionAttributeName());
     }
     
     /**
@@ -52,23 +46,12 @@
     }
 
     /**
-     * @param context The context.
-     * @return The session of the context.
-     */
-    protected Session getSession(Context context) {
-        Map objectModel = ContextHelper.getObjectModel(context);
-        Request request = ObjectModelHelper.getRequest(objectModel);
-        Session session = request.getCocoonSession(true);
-        return session;
-    }
-
-    /**
      * Saves the clipboard to the session.
      * @param context The context.
      * @param clipboard The clipboard.
      */
-    public void saveClipboard(Context context, Clipboard clipboard) {
-        Session session = getSession(context);
+    public void saveClipboard(HttpServletRequest request, Clipboard clipboard) {
+        HttpSession session = request.getSession();
         session.setAttribute(getSessionAttributeName(), clipboard);
     }
     
@@ -76,8 +59,8 @@
      * Removes the clipboard from the session.
      * @param context The context.
      */
-    public void removeClipboard(Context context) {
-        Session session = getSession(context);
+    public void removeClipboard(HttpServletRequest request) {
+        HttpSession session = request.getSession();
         session.removeAttribute(getSessionAttributeName());
     }
     

Modified: lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Copy.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Copy.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Copy.java (original)
+++ lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Copy.java Fri Feb  6 17:55:28 2009
@@ -17,6 +17,10 @@
  */
 package org.apache.lenya.cms.site.usecases;
 
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.cocoon.processing.ProcessInfoProvider;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.usecase.DocumentUsecase;
 
@@ -42,10 +46,16 @@
      */
     protected void doExecute() throws Exception {
         super.doExecute();
-        
+
         Clipboard clipboard = new Clipboard(getSourceDocument(), Clipboard.METHOD_COPY);
         ClipboardHelper helper = new ClipboardHelper();
-        helper.saveClipboard(getContext(), clipboard);
+        helper.saveClipboard(getRequest(), clipboard);
     }
-    
+
+    protected HttpServletRequest getRequest() {
+        ProcessInfoProvider process = (ProcessInfoProvider) WebAppContextUtils
+                .getCurrentWebApplicationContext().getBean(ProcessInfoProvider.ROLE);
+        return process.getRequest();
+    }
+
 }

Modified: lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Create.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Create.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Create.java (original)
+++ lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Create.java Fri Feb  6 17:55:28 2009
@@ -22,13 +22,12 @@
 import java.util.Collections;
 import java.util.GregorianCalendar;
 import java.util.List;
-import java.util.Map;
 
-import org.apache.avalon.framework.service.ServiceSelector;
-import org.apache.cocoon.components.ContextHelper;
-import org.apache.cocoon.environment.ObjectModelHelper;
-import org.apache.cocoon.environment.Request;
-import org.apache.cocoon.environment.Session;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.apache.cocoon.processing.ProcessInfoProvider;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 import org.apache.lenya.ac.Identity;
 import org.apache.lenya.ac.User;
 import org.apache.lenya.cms.metadata.MetaData;
@@ -37,9 +36,8 @@
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.DocumentManager;
 import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.PublicationException;
-import org.apache.lenya.cms.publication.PublicationUtil;
 import org.apache.lenya.cms.publication.ResourceType;
+import org.apache.lenya.cms.publication.ResourceTypeResolver;
 import org.apache.lenya.cms.publication.URLInformation;
 import org.apache.lenya.cms.repository.Node;
 import org.apache.lenya.cms.site.SiteStructure;
@@ -70,12 +68,8 @@
     protected static final String SAMPLE = "sample";
     protected static final String SAMPLES = "samples";
 
-    /**
-     * Ctor.
-     */
-    public Create() {
-        super();
-    }
+    private DocumentManager documentManager;
+    private ResourceTypeResolver resourceTypeResolver;
 
     /**
      * @see org.apache.lenya.cms.usecase.AbstractUsecase#doCheckPreconditions()
@@ -134,10 +128,9 @@
     }
 
     /**
-     * This method is used by {@link #doCheckExecutionConditions()} to check if
-     * the path entered by the user is valid. If not, checking the existence of
-     * the new document in the site structure is omitted because this operation
-     * could cause errors.
+     * This method is used by {@link #doCheckExecutionConditions()} to check if the path entered by
+     * the user is valid. If not, checking the existence of the new document in the site structure
+     * is omitted because this operation could cause errors.
      * @return A boolean value.
      */
     protected boolean isPathValid() {
@@ -151,57 +144,37 @@
         super.doExecute();
 
         // create new document
-        DocumentManager documentManager = null;
-        ServiceSelector selector = null;
         ResourceType resourceType = null;
-        try {
 
-            documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
+        String language = getParameterAsString(LANGUAGE);
+        Document initialDocument = getInitialDocument();
 
-            String language = getParameterAsString(LANGUAGE);
-            Document initialDocument = getInitialDocument();
-
-            Document document;
+        Document document;
 
-            String title = getDublinCoreParameter(DublinCore.ELEMENT_TITLE).trim();
+        String title = getDublinCoreParameter(DublinCore.ELEMENT_TITLE).trim();
 
-            if (createVersion()) {
-                document = documentManager.addVersion(initialDocument, getArea(), language, true);
-                document.getLink().setLabel(title);
+        if (createVersion()) {
+            document = documentManager.addVersion(initialDocument, getArea(), language, true);
+            document.getLink().setLabel(title);
+        } else {
+            if (initialDocument == null) {
+                resourceType = getResourceTypeResolver().getResourceType(getDocumentTypeName());
+                String sampleName = getParameterAsString(SAMPLE, resourceType.getSampleNames()[0]);
+                ResourceType.Sample sample = resourceType.getSample(sampleName);
+                document = documentManager.add(getDocumentFactory(), resourceType, sample.getUri(),
+                        getPublication(), getArea(), getNewDocumentPath(), language,
+                        getSourceExtension(), title, getVisibleInNav());
+                document.setMimeType(sample.getMimeType());
             } else {
-                if (initialDocument == null) {
-                    selector = (ServiceSelector) this.manager
-                            .lookup(ResourceType.ROLE + "Selector");
-                    resourceType = (ResourceType) selector.select(getDocumentTypeName());
-                    String sampleName = getParameterAsString(SAMPLE, resourceType.getSampleNames()[0]);
-                    ResourceType.Sample sample = resourceType.getSample(sampleName);
-                    document = documentManager.add(getDocumentFactory(), resourceType, sample.getUri(),
-                            getPublication(), getArea(), getNewDocumentPath(), language,
-                            getSourceExtension(), title, getVisibleInNav());
-                    document.setMimeType(sample.getMimeType());
-                } else {
-                    document = documentManager.add(initialDocument, getArea(),
-                            getNewDocumentPath(), language, getSourceExtension(), title,
-                            getVisibleInNav());
-                }
+                document = documentManager.add(initialDocument, getArea(), getNewDocumentPath(),
+                        language, getSourceExtension(), title, getVisibleInNav());
             }
+        }
 
-            setMetaData(document);
-
-            // the location to navigate to after completion of usecase
-            setDefaultTargetURL(document.getCanonicalWebappURL());
+        setMetaData(document);
 
-        } finally {
-            if (documentManager != null) {
-                this.manager.release(documentManager);
-            }
-            if (selector != null) {
-                if (resourceType != null) {
-                    selector.release(resourceType);
-                }
-                this.manager.release(selector);
-            }
-        }
+        // the location to navigate to after completion of usecase
+        setDefaultTargetURL(document.getCanonicalWebappURL());
     }
 
     protected String getDublinCoreParameter(String name) {
@@ -243,8 +216,8 @@
     protected abstract String getNewDocumentPath();
 
     /**
-     * If the document created in the usecase shall have initial contents copied
-     * from an existing document, construct that document in this method.
+     * If the document created in the usecase shall have initial contents copied from an existing
+     * document, construct that document in this method.
      * 
      * @return A document.
      */
@@ -288,9 +261,10 @@
     protected void initParameters() {
         super.initParameters();
 
-        Map objectModel = ContextHelper.getObjectModel(getContext());
-        Request request = ObjectModelHelper.getRequest(objectModel);
-        Session session = request.getCocoonSession(false);
+        ProcessInfoProvider process = (ProcessInfoProvider) WebAppContextUtils
+                .getCurrentWebApplicationContext().getBean(ProcessInfoProvider.ROLE);
+        HttpServletRequest request = process.getRequest();
+        HttpSession session = request.getSession(false);
         Identity identity = (Identity) session.getAttribute(Identity.class.getName());
         User user = identity.getUser();
         if (user != null) {
@@ -314,11 +288,9 @@
     }
 
     protected void initSampleParameters() {
-        ServiceSelector selector = null;
         ResourceType resourceType = null;
         try {
-            selector = (ServiceSelector) this.manager.lookup(ResourceType.ROLE + "Selector");
-            resourceType = (ResourceType) selector.select(getDocumentTypeName());
+            resourceType = getResourceTypeResolver().getResourceType(getDocumentTypeName());
             String[] samples = resourceType.getSampleNames();
             if (samples.length == 0) {
                 addErrorMessage("The resource type [" + resourceType.getName()
@@ -339,19 +311,12 @@
             }
         } catch (Exception e) {
             throw new RuntimeException(e);
-        } finally {
-            if (selector != null) {
-                if (resourceType != null) {
-                    selector.release(resourceType);
-                }
-                this.manager.release(selector);
-            }
         }
     }
 
     /**
-     * @return The source document or <code>null</code> if the usecase was not
-     *         invoked on a document.
+     * @return The source document or <code>null</code> if the usecase was not invoked on a
+     *         document.
      */
     protected Document getSourceDocument() {
         Document document = null;
@@ -389,25 +354,7 @@
     }
 
     /**
-     * Access to the current publication. Use this when the publication is not
-     * yet known in the usecase: e.g. when creating a global asset. When adding
-     * a resource or a child to a document, access the publication via that
-     * document's interface instead.
-     * 
-     * @return the publication in which the use-case is being executed
-     */
-    protected Publication getPublication() {
-        try {
-            return PublicationUtil.getPublicationFromUrl(this.manager, getDocumentFactory(),
-                    getSourceURL());
-        } catch (PublicationException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * @return the visibleInNav Attribute of the document being created in the
-     *         usecase
+     * @return the visibleInNav Attribute of the document being created in the usecase
      */
     protected boolean getVisibleInNav() {
         if (getParameterAsString(VISIBLEINNAV).equals("false")) {
@@ -416,4 +363,26 @@
         return true;
     }
 
+    protected DocumentManager getDocumentManager() {
+        return documentManager;
+    }
+
+    /**
+     * TODO: Bean wiring
+     */
+    public void setDocumentManager(DocumentManager documentManager) {
+        this.documentManager = documentManager;
+    }
+
+    protected ResourceTypeResolver getResourceTypeResolver() {
+        return resourceTypeResolver;
+    }
+
+    /**
+     * TODO: Bean wiring
+     */
+    public void setResourceTypeResolver(ResourceTypeResolver resourceTypeResolver) {
+        this.resourceTypeResolver = resourceTypeResolver;
+    }
+
 }

Modified: lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/CreateLanguage.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/CreateLanguage.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/CreateLanguage.java (original)
+++ lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/CreateLanguage.java Fri Feb  6 17:55:28 2009
@@ -20,13 +20,11 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.avalon.framework.service.ServiceSelector;
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.DocumentBuildException;
 import org.apache.lenya.cms.publication.DocumentException;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.ResourceType;
-import org.apache.lenya.cms.site.SiteManager;
 
 /**
  * Usecase to create a new language version of a resource.
@@ -144,27 +142,6 @@
         return this.documentTypeName;
     }
 
-    protected boolean getVisibleInNav() {
-        Document source = getSourceDocument();
-        ServiceSelector selector = null;
-        SiteManager siteManager = null;
-        try {
-            selector = (ServiceSelector) manager.lookup(SiteManager.ROLE + "Selector");
-            siteManager = (SiteManager) selector.select(source.getPublication()
-                    .getSiteManagerHint());
-            return siteManager.isVisibleInNav(source);
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        } finally {
-            if (selector != null) {
-                if (siteManager != null) {
-                    selector.release(siteManager);
-                }
-                manager.release(selector);
-            }
-        }
-    }
-
     protected String getSourceExtension() {
         return getSourceDocument().getSourceExtension();
     }

Modified: lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Cut.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Cut.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Cut.java (original)
+++ lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Cut.java Fri Feb  6 17:55:28 2009
@@ -17,6 +17,10 @@
  */
 package org.apache.lenya.cms.site.usecases;
 
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.cocoon.processing.ProcessInfoProvider;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.site.SiteStructure;
@@ -52,10 +56,16 @@
      */
     protected void doExecute() throws Exception {
         super.doExecute();
-        
+
         Clipboard clipboard = new Clipboard(getSourceDocument(), Clipboard.METHOD_CUT);
         ClipboardHelper helper = new ClipboardHelper();
-        helper.saveClipboard(getContext(), clipboard);
+        helper.saveClipboard(getRequest(), clipboard);
     }
-    
+
+    protected HttpServletRequest getRequest() {
+        ProcessInfoProvider process = (ProcessInfoProvider) WebAppContextUtils
+                .getCurrentWebApplicationContext().getBean(ProcessInfoProvider.ROLE);
+        return process.getRequest();
+    }
+
 }

Modified: lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/EmptyTrash.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/EmptyTrash.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/EmptyTrash.java (original)
+++ lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/EmptyTrash.java Fri Feb  6 17:55:28 2009
@@ -21,17 +21,14 @@
 import java.util.Arrays;
 import java.util.List;
 
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceSelector;
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.DocumentFactory;
 import org.apache.lenya.cms.publication.DocumentManager;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.PublicationException;
-import org.apache.lenya.cms.publication.PublicationUtil;
+import org.apache.lenya.cms.publication.URLInformation;
 import org.apache.lenya.cms.publication.util.DocumentSet;
 import org.apache.lenya.cms.site.SiteException;
-import org.apache.lenya.cms.site.SiteManager;
 import org.apache.lenya.cms.site.SiteStructure;
 import org.apache.lenya.cms.usecase.AbstractUsecase;
 import org.apache.lenya.cms.usecase.UsecaseException;
@@ -45,6 +42,8 @@
 
     protected static final String DOCUMENTS = "documents";
 
+    private DocumentManager documentManager;
+
     /**
      * @see org.apache.lenya.cms.usecase.AbstractUsecase#initParameters()
      */
@@ -70,36 +69,21 @@
      */
     protected org.apache.lenya.cms.repository.Node[] getNodesToLock() throws UsecaseException {
         List nodes = new ArrayList();
-        ServiceSelector selector = null;
-        SiteManager siteManager = null;
-
         try {
-            Publication publication = PublicationUtil.getPublicationFromUrl(this.manager,
-                    getDocumentFactory(),
-                    getSourceURL());
-            DocumentFactory identityMap = getDocumentFactory();
+            DocumentFactory factory = getDocumentFactory();
+            String pubId = new URLInformation(getSourceURL()).getPublicationId();
+            Publication publication = factory.getPublication(pubId);
             Document[] docs = getTrashDocuments();
             for (int i = 0; i < docs.length; i++) {
                 nodes.add(docs[i].getRepositoryNode());
             }
-
-            selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE + "Selector");
-            siteManager = (SiteManager) selector.select(publication.getSiteManagerHint());
-            SiteStructure structure = siteManager.getSiteStructure(identityMap,
-                    publication,
-                    Publication.TRASH_AREA);
+            SiteStructure structure = publication.getArea(Publication.TRASH_AREA).getSite();
             nodes.add(structure.getRepositoryNode());
         } catch (Exception e) {
             throw new UsecaseException(e);
-        } finally {
-            if (selector != null) {
-                if (siteManager != null) {
-                    selector.release(siteManager);
-                }
-                this.manager.release(selector);
-            }
         }
-        return (org.apache.lenya.cms.repository.Node[]) nodes.toArray(new org.apache.lenya.cms.repository.Node[nodes.size()]);
+        return (org.apache.lenya.cms.repository.Node[]) nodes
+                .toArray(new org.apache.lenya.cms.repository.Node[nodes.size()]);
     }
 
     /**
@@ -107,18 +91,9 @@
      */
     protected void doExecute() throws Exception {
         super.doExecute();
-
-        DocumentManager documentManager = null;
-        try {
-            documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
-            Document[] documents = getTrashDocuments();
-            DocumentSet set = new DocumentSet(documents);
-            documentManager.delete(set);
-        } finally {
-            if (documentManager != null) {
-                this.manager.release(documentManager);
-            }
-        }
+        Document[] documents = getTrashDocuments();
+        DocumentSet set = new DocumentSet(documents);
+        getDocumentManager().delete(set);
     }
 
     /**
@@ -127,29 +102,21 @@
      * @throws SiteException if an error occurs.
      */
     protected Document[] getTrashDocuments() throws PublicationException, SiteException {
-        Publication publication = PublicationUtil.getPublicationFromUrl(this.manager,
-                getDocumentFactory(),
-                getSourceURL());
-        DocumentFactory identityMap = getDocumentFactory();
-        Document[] documents;
+        String pubId = new URLInformation(getSourceURL()).getPublicationId();
+        DocumentFactory factory = getDocumentFactory();
+        Publication pub = factory.getPublication(pubId);
+        return pub.getArea(Publication.TRASH_AREA).getDocuments();
+    }
 
-        ServiceSelector selector = null;
-        SiteManager siteManager = null;
-        try {
-            selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE + "Selector");
-            siteManager = (SiteManager) selector.select(publication.getSiteManagerHint());
-            documents = siteManager.getDocuments(identityMap, publication, Publication.TRASH_AREA);
-        } catch (ServiceException e) {
-            throw new RuntimeException(e);
-        } finally {
-            if (selector != null) {
-                if (siteManager != null) {
-                    selector.release(siteManager);
-                }
-                this.manager.release(selector);
-            }
-        }
+    protected DocumentManager getDocumentManager() {
+        return documentManager;
+    }
 
-        return documents;
+    /**
+     * TODO: Bean wiring
+     */
+    public void setDocumentManager(DocumentManager documentManager) {
+        this.documentManager = documentManager;
     }
+
 }

Modified: lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/ForceLiveCheckIn.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/ForceLiveCheckIn.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/ForceLiveCheckIn.java (original)
+++ lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/ForceLiveCheckIn.java Fri Feb  6 17:55:28 2009
@@ -19,7 +19,6 @@
 
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.PublicationException;
-import org.apache.lenya.cms.publication.PublicationUtil;
 import org.apache.lenya.cms.repository.Node;
 import org.apache.lenya.cms.usecase.AbstractUsecase;
 
@@ -58,8 +57,4 @@
     private Node getNode() throws PublicationException {
         return getPublication().getArea(Publication.LIVE_AREA).getSite().getRepositoryNode();
     }
- 
-    private Publication getPublication() throws PublicationException {
-        return PublicationUtil.getPublicationFromUrl(this.manager, getDocumentFactory(),getSourceURL());
-    }
 }

Modified: lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/MoveSubsite.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/MoveSubsite.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/MoveSubsite.java (original)
+++ lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/MoveSubsite.java Fri Feb  6 17:55:28 2009
@@ -59,6 +59,8 @@
      */
     protected abstract String getTargetArea();
 
+    private DocumentManager documentManager;
+
     /**
      * @see org.apache.lenya.cms.usecase.AbstractUsecase#doCheckPreconditions()
      */
@@ -75,15 +77,14 @@
 
             Document document = getSourceDocument();
 
-            NodeSet subsite = SiteUtil.getSubSite(this.manager, document.getLink().getNode());
+            NodeSet subsite = SiteUtil.getSubSite(document.getLink().getNode());
             Document[] docs = subsite.getDocuments();
             for (int i = 0; i < docs.length; i++) {
                 if (docs[i].existsAreaVersion(Publication.LIVE_AREA)) {
                     Document liveVersion = docs[i].getAreaVersion(Publication.LIVE_AREA);
                     addErrorMessage("delete-doc-live", new String[] { liveVersion.toString() });
                 }
-                UsecaseWorkflowHelper.checkWorkflow(this.manager, this, getEvent(), docs[i],
-                        getLogger());
+                UsecaseWorkflowHelper.checkWorkflow(this, getEvent(), docs[i], getLogger());
             }
         }
     }
@@ -94,24 +95,24 @@
     protected abstract String getEvent();
 
     /**
-     * Lock all source documents and the site structure repository nodes because
-     * changes to the site structure would compromise the operation.
+     * Lock all source documents and the site structure repository nodes because changes to the site
+     * structure would compromise the operation.
      */
     protected Node[] getNodesToLock() throws UsecaseException {
         Set nodes = new HashSet();
-  
-        if(getSourceDocument() != null) {
+
+        if (getSourceDocument() != null) {
             try {
 
                 SiteStructure sourceSite = getSourceDocument().area().getSite();
-                SiteStructure targetSite = getSourceDocument().getPublication()
-                        .getArea(getTargetArea()).getSite();
+                SiteStructure targetSite = getSourceDocument().getPublication().getArea(
+                        getTargetArea()).getSite();
 
                 nodes.add(sourceSite.getRepositoryNode());
                 nodes.add(targetSite.getRepositoryNode());
 
-                Document[] docs = SiteUtil.getSubSite(this.manager,
-                        getSourceDocument().getLink().getNode()).getDocuments();
+                Document[] docs = SiteUtil.getSubSite(getSourceDocument().getLink().getNode())
+                        .getDocuments();
                 for (int i = 0; i < docs.length; i++) {
                     nodes.add(docs[i].getRepositoryNode());
                 }
@@ -120,7 +121,7 @@
                 throw new UsecaseException(e);
             }
         }
- 
+
         return (Node[]) nodes.toArray(new Node[nodes.size()]);
     }
 
@@ -131,39 +132,27 @@
 
         String targetAreaName = getTargetArea();
         Document doc = getSourceDocument();
-        Document[] sources = SiteUtil.getSubSite(this.manager, doc.getLink().getNode())
-                .getDocuments();
+        Document[] sources = SiteUtil.getSubSite(doc.getLink().getNode()).getDocuments();
         Area targetArea = doc.getPublication().getArea(targetAreaName);
 
         DocumentLocator targetLoc = doc.getLocator().getAreaVersion(targetAreaName);
-        targetLoc = SiteUtil.getAvailableLocator(this.manager, getDocumentFactory(), targetLoc);
+        targetLoc = SiteUtil.getAvailableLocator(getDocumentFactory(), targetLoc);
 
         for (int i = 0; i < sources.length; i++) {
-            WorkflowUtil.invoke(this.manager, getLogger(), sources[i], getEvent(),
-                    true);
-            
+            WorkflowUtil.invoke(getLogger(), sources[i], getEvent(), true);
+
             if (this.getClass().getName().equals(Restore.class.getName())) {
-                Workflowable workflowable = WorkflowUtil.getWorkflowable(this.manager,
-                        getLogger(), sources[i]);
+                Workflowable workflowable = WorkflowUtil.getWorkflowable(getLogger(), sources[i]);
                 String state = workflowable.getLatestVersion().getState();
                 if (!state.equals("authoring")) {
                     addErrorMessage("The state is [" + state + "] instead of [authoring]!");
                 }
             }
-            
-        }
-
-        DocumentManager docManager = null;
-        try {
-            docManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
-            docManager.moveAll(doc.area(), doc.getPath(), targetArea, targetLoc.getPath());
 
-        } finally {
-            if (docManager != null) {
-                this.manager.release(docManager);
-            }
         }
 
+        getDocumentManager().moveAll(doc.area(), doc.getPath(), targetArea, targetLoc.getPath());
+
         setTargetDocument(doc.getAreaVersion(targetAreaName));
 
     }
@@ -179,7 +168,8 @@
         } else {
             try {
                 Document document = getTargetDocument(success);
-                SiteStructure site = document.getPublication().getArea(Publication.AUTHORING_AREA).getSite();
+                SiteStructure site = document.getPublication().getArea(Publication.AUTHORING_AREA)
+                        .getSite();
                 return getTargetUrl(site, document.getPath()) + getExitQueryString();
             } catch (Exception e) {
                 throw new RuntimeException(e);
@@ -198,13 +188,11 @@
                 String defaultLanguage = site.getPublication().getDefaultLanguage();
                 if (node.hasLink(defaultLanguage)) {
                     link = node.getLink(defaultLanguage);
-                }
-                else {
+                } else {
                     link = node.getLink(node.getLanguages()[0]);
                 }
                 return link.getDocument().getCanonicalWebappURL();
-            }
-            else {
+            } else {
                 return getTargetUrl(site, getParentPath(path));
             }
         } else {
@@ -218,4 +206,15 @@
         return path.substring(0, path.lastIndexOf("/"));
     }
 
+    protected DocumentManager getDocumentManager() {
+        return documentManager;
+    }
+
+    /**
+     * TODO: Bean wiring
+     */
+    public void setDocumentManager(DocumentManager documentManager) {
+        this.documentManager = documentManager;
+    }
+
 }

Modified: lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Overview.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Overview.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Overview.java (original)
+++ lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Overview.java Fri Feb  6 17:55:28 2009
@@ -49,13 +49,8 @@
     protected static final String WORKFLOW_VARIABLE_ISLIVE = "is_live";
     protected static final String PARAM_NUMBER_OF_DOCUMENTS = "numberOfDocuments";
     protected static final String PARAM_NUMBER_OF_SITE_NODES = "numberOfSiteNodes";
-
-    /**
-     * Ctor.
-     */
-    public Overview() {
-        super();
-    }
+    
+    private WorkflowManager workflowManager;
 
     /**
      * @see org.apache.lenya.cms.usecase.AbstractUsecase#initParameters()
@@ -63,7 +58,6 @@
     protected void initParameters() {
         super.initParameters();
 
-        WorkflowManager resolver = null;
         try {
             Document doc = getSourceDocument();
             if (doc == null) {
@@ -89,11 +83,9 @@
                 boolean visible = doc.getLink().getNode().isVisible();
                 setParameter(VISIBLE_IN_NAVIGATION, Boolean.valueOf(visible));
 
-                Workflowable workflowable = WorkflowUtil.getWorkflowable(this.manager,
-                        getLogger(), doc);
-                resolver = (WorkflowManager) this.manager.lookup(WorkflowManager.ROLE);
-                if (resolver.hasWorkflow(workflowable)) {
-                    Workflow workflow = resolver.getWorkflowSchema(workflowable);
+                Workflowable workflowable = WorkflowUtil.getWorkflowable(getLogger(), doc);
+                if (getWorkflowManager().hasWorkflow(workflowable)) {
+                    Workflow workflow = getWorkflowManager().getWorkflowSchema(workflowable);
                     String[] variableNames = workflow.getVariableNames();
                     Version latestVersion = workflowable.getLatestVersion();
                     Boolean isLive = null;
@@ -119,10 +111,6 @@
         } catch (final Exception e) {
             addErrorMessage("Could not read a value. See log files for details.");
             getLogger().error("Could not read value for Overview usecase. ", e);
-        } finally {
-            if (resolver != null) {
-                this.manager.release(resolver);
-            }
         }
     }
 
@@ -133,4 +121,15 @@
         // don't complain if document is null
     }
 
+    protected WorkflowManager getWorkflowManager() {
+        return workflowManager;
+    }
+
+    /**
+     * TODO: Bean wiring
+     */
+    public void setWorkflowManager(WorkflowManager workflowManager) {
+        this.workflowManager = workflowManager;
+    }
+
 }
\ No newline at end of file

Modified: lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Paste.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Paste.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Paste.java (original)
+++ lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Paste.java Fri Feb  6 17:55:28 2009
@@ -20,7 +20,11 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.servlet.http.HttpServletRequest;
+
 import org.apache.avalon.framework.service.ServiceException;
+import org.apache.cocoon.processing.ProcessInfoProvider;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 import org.apache.lenya.cms.publication.Area;
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.DocumentBuildException;
@@ -48,6 +52,8 @@
 
     protected static final String CLIPBOARD_LABEL = "clipboardLabel";
 
+    private DocumentManager documentManager;
+
     /**
      * @see org.apache.lenya.cms.usecase.AbstractUsecase#doCheckPreconditions()
      */
@@ -57,19 +63,19 @@
         if (hasErrors()) {
             return;
         }
-        
+
         if (!getArea().getName().equals(Publication.AUTHORING_AREA)) {
             addErrorMessage("only-in-authoring-area");
         }
 
-        Clipboard clipboard = new ClipboardHelper().getClipboard(getContext());
+        Clipboard clipboard = new ClipboardHelper().getClipboard(getRequest());
         if (clipboard == null) {
             addErrorMessage("clipboard-empty");
-        }
-        else {
+        } else {
             Document doc = getSourceDocument();
-            if(doc != null) {
-                Document clippedDoc = clipboard.getDocument(getDocumentFactory(), doc.getPublication());
+            if (doc != null) {
+                Document clippedDoc = clipboard.getDocument(getDocumentFactory(), doc
+                        .getPublication());
                 String uuid = clippedDoc.getUUID();
                 SiteNode node = doc.getLink().getNode();
                 if (clipboard.getMethod() == Clipboard.METHOD_CUT) {
@@ -112,7 +118,7 @@
     protected void initParameters() {
         super.initParameters();
 
-        Clipboard clipboard = new ClipboardHelper().getClipboard(getContext());
+        Clipboard clipboard = new ClipboardHelper().getClipboard(getRequest());
         if (clipboard != null) {
             String label;
             try {
@@ -143,20 +149,19 @@
 
         try {
 
-            Clipboard clipboard = new ClipboardHelper().getClipboard(getContext());
+            Clipboard clipboard = new ClipboardHelper().getClipboard(getRequest());
             if (clipboard != null) {
-                
+
                 Node siteNode = getArea().getSite().getRepositoryNode();
                 nodes.add(siteNode);
 
                 DocumentFactory map = getDocumentFactory();
                 Publication pub = getPublication();
                 Document clippedDocument = clipboard.getDocument(map, pub);
-    
-                NodeSet subsite = SiteUtil
-                        .getSubSite(this.manager, clippedDocument.getLink().getNode());
+
+                NodeSet subsite = SiteUtil.getSubSite(clippedDocument.getLink().getNode());
                 Document[] subsiteDocs = subsite.getDocuments();
-    
+
                 for (int i = 0; i < subsiteDocs.length; i++) {
                     if (clipboard.getMethod() == Clipboard.METHOD_CUT) {
                         nodes.add(subsiteDocs[i].getRepositoryNode());
@@ -190,36 +195,28 @@
         DocumentFactory identityMap = getDocumentFactory();
         ClipboardHelper helper = new ClipboardHelper();
 
-        Clipboard clipboard = helper.getClipboard(getContext());
+        HttpServletRequest request = getRequest();
+        Clipboard clipboard = helper.getClipboard(request);
         Publication pub = getPublication();
         Document clippedDocument = clipboard.getDocument(identityMap, pub);
 
         final String targetPath = getTargetPath();
         final Area area = clippedDocument.area();
-        DocumentManager documentManager = null;
-        try {
-            documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
-
-            if (clipboard.getMethod() == Clipboard.METHOD_COPY) {
-                documentManager.copyAll(area, clippedDocument.getPath(), area, targetPath);
-            } else if (clipboard.getMethod() == Clipboard.METHOD_CUT) {
-                documentManager.moveAll(area, clippedDocument.getPath(), area, targetPath);
-            } else {
-                throw new RuntimeException("This clipboard method is not supported!");
-            }
-        } finally {
-            if (documentManager != null) {
-                this.manager.release(documentManager);
-            }
+        if (clipboard.getMethod() == Clipboard.METHOD_COPY) {
+            getDocumentManager().copyAll(area, clippedDocument.getPath(), area, targetPath);
+        } else if (clipboard.getMethod() == Clipboard.METHOD_CUT) {
+            getDocumentManager().moveAll(area, clippedDocument.getPath(), area, targetPath);
+        } else {
+            throw new RuntimeException("This clipboard method is not supported!");
         }
 
-        helper.removeClipboard(getContext());
+        helper.removeClipboard(request);
     }
 
     protected String getTargetPath() throws SiteException, DocumentBuildException,
             ServiceException, DocumentException {
         DocumentFactory identityMap = getDocumentFactory();
-        Clipboard clipboard = new ClipboardHelper().getClipboard(getContext());
+        Clipboard clipboard = new ClipboardHelper().getClipboard(getRequest());
         Publication pub = getPublication();
         Document clippedDocument = clipboard.getDocument(identityMap, pub);
 
@@ -234,7 +231,24 @@
 
         DocumentLocator potentialLoc = DocumentLocator.getLocator(getPublication().getId(),
                 targetArea, potentialPath, language);
-        return SiteUtil.getAvailableLocator(this.manager, getDocumentFactory(), potentialLoc)
-                .getPath();
+        return SiteUtil.getAvailableLocator(getDocumentFactory(), potentialLoc).getPath();
+    }
+
+    protected HttpServletRequest getRequest() {
+        ProcessInfoProvider process = (ProcessInfoProvider) WebAppContextUtils
+                .getCurrentWebApplicationContext().getBean(ProcessInfoProvider.ROLE);
+        return process.getRequest();
+    }
+
+    protected DocumentManager getDocumentManager() {
+        return documentManager;
     }
+
+    /**
+     * TODO: Bean wiring
+     */
+    public void setDocumentManager(DocumentManager documentManager) {
+        this.documentManager = documentManager;
+    }
+
 }

Modified: lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Restore.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Restore.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Restore.java (original)
+++ lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Restore.java Fri Feb  6 17:55:28 2009
@@ -56,28 +56,27 @@
     protected void doCheckPreconditions() throws Exception {
         super.doCheckPreconditions();
 
-        String targetAreaName = getTargetArea(); 
+        String targetAreaName = getTargetArea();
         Document doc = getSourceDocument();
-        if(doc == null) {
+        if (doc == null) {
             return;
         }
         // Check to see if parent node exists in target to prevent ghost nodes
         Area targetArea = doc.getPublication().getArea(targetAreaName);
         DocumentLocator targetLoc = doc.getLocator().getAreaVersion(targetAreaName);
-        targetLoc = SiteUtil.getAvailableLocator(this.manager, getDocumentFactory(), targetLoc);
+        targetLoc = SiteUtil.getAvailableLocator(getDocumentFactory(), targetLoc);
         String targetPath = targetLoc.getPath();
-        targetPath = targetPath.substring(0,targetPath.lastIndexOf('/'));
-        if(!targetArea.getSite().contains(targetPath)) {
+        targetPath = targetPath.substring(0, targetPath.lastIndexOf('/'));
+        if (!targetArea.getSite().contains(targetPath)) {
             addErrorMessage("The authoring path [" + targetPath + "] does not exist.");
         }
     }
-  
+
     protected void doCheckPostconditions() throws Exception {
         super.doCheckPostconditions();
 
         Document doc = getTargetDocument(true);
-        Workflowable workflowable = WorkflowUtil.getWorkflowable(this.manager,
-                getLogger(), doc);
+        Workflowable workflowable = WorkflowUtil.getWorkflowable(getLogger(), doc);
         String state = workflowable.getLatestVersion().getState();
         if (!state.equals("authoring")) {
             addErrorMessage("The state is [" + state + "] instead of [authoring]!");

Modified: lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Revisions.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Revisions.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Revisions.java (original)
+++ lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Revisions.java Fri Feb  6 17:55:28 2009
@@ -33,8 +33,8 @@
 public class Revisions extends SiteUsecase {
 
     /**
-     * @see org.apache.lenya.cms.usecase.AbstractUsecase#initParameters() TODO
-     *      filter out checkin entries
+     * @see org.apache.lenya.cms.usecase.AbstractUsecase#initParameters() TODO filter out checkin
+     *      entries
      */
     protected void initParameters() {
         super.initParameters();
@@ -50,20 +50,19 @@
                 }
                 setParameter("revisions", revisions);
 
-                Boolean canRollback = Boolean.valueOf(WorkflowUtil.canInvoke(this.manager,
-                        getLogger(), sourceDoc, getEvent()));
+                Boolean canRollback = Boolean.valueOf(WorkflowUtil.canInvoke(getLogger(),
+                        sourceDoc, getEvent()));
                 setParameter("canRollback", canRollback);
 
-                if (WorkflowUtil.hasWorkflow(this.manager, getLogger(), sourceDoc)) {
-                    Workflowable workflowable = WorkflowUtil.getWorkflowable(this.manager,
-                            getLogger(), sourceDoc);
+                if (WorkflowUtil.hasWorkflow(getLogger(), sourceDoc)) {
+                    Workflowable workflowable = WorkflowUtil
+                            .getWorkflowable(getLogger(), sourceDoc);
                     Version latestVersion = workflowable.getLatestVersion();
                     String state;
                     if (latestVersion != null) {
                         state = latestVersion.getState();
                     } else {
-                        Workflow workflow = WorkflowUtil.getWorkflowSchema(this.manager,
-                                getLogger(), sourceDoc);
+                        Workflow workflow = WorkflowUtil.getWorkflowSchema(getLogger(), sourceDoc);
                         state = workflow.getInitialState();
                     }
                     setParameter("workflowState", state);
@@ -73,22 +72,19 @@
             }
 
             /*
-             * // since we need both state and canInvoke, we could deal with the
-             * avalon // component ourselves rather than using WorkflowUtil -
-             * saves one // service manager lookup. // problem is that
-             * DocumentWorkflowable is not public and Workflowable is abstract :(
+             * // since we need both state and canInvoke, we could deal with the avalon // component
+             * ourselves rather than using WorkflowUtil - saves one // service manager lookup. //
+             * problem is that DocumentWorkflowable is not public and Workflowable is abstract :(
              * 
-             * WorkflowManager wfManager = null; String workflowState; Boolean
-             * canRollback; try { wfManager = (WorkflowManager)
-             * this.manager.lookup(WorkflowManager.ROLE); Workflowable
+             * WorkflowManager wfManager = null; String workflowState; Boolean canRollback; try {
+             * wfManager = (WorkflowManager) this.manager.lookup(WorkflowManager.ROLE); Workflowable
              * workflowable = new DocumentWorkflowable( this.manager,
-             * getDocumentFactory().getSession(), sourceDoc, getLogger() );
-             * workflowState = workflowable.getLatestVersion().getState();
-             * canRollback = new Boolean(wfManager.canInvoke(workflowable,
-             * WORKFLOW_EVENT_EDIT)); } catch (ServiceException e) { throw new
-             * RuntimeException(e); } finally { if (wfManager != null) {
-             * manager.release(wfManager); } } setParameter("workflowState",
-             * workflowState); setParameter("canRollback", canRollback);
+             * getDocumentFactory().getSession(), sourceDoc, getLogger() ); workflowState =
+             * workflowable.getLatestVersion().getState(); canRollback = new
+             * Boolean(wfManager.canInvoke(workflowable, WORKFLOW_EVENT_EDIT)); } catch
+             * (ServiceException e) { throw new RuntimeException(e); } finally { if (wfManager !=
+             * null) { manager.release(wfManager); } } setParameter("workflowState", workflowState);
+             * setParameter("canRollback", canRollback);
              */
 
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org