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 [5/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.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Rollback.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Rollback.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/Rollback.java (original)
+++ lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/Rollback.java Fri Feb  6 17:55:28 2009
@@ -42,8 +42,7 @@
      */
     protected void doCheckPreconditions() throws Exception {
         super.doCheckPreconditions();
-        UsecaseWorkflowHelper.checkWorkflow(this.manager, this, getEvent(), getSourceDocument(),
-                getLogger());
+        UsecaseWorkflowHelper.checkWorkflow(this, getEvent(), getSourceDocument(), getLogger());
     }
 
     /**
@@ -58,7 +57,7 @@
         Node node = document.getRepositoryNode();
         node.rollback(revision);
 
-        WorkflowUtil.invoke(this.manager, getLogger(), getSourceDocument(), getEvent());
+        WorkflowUtil.invoke(getLogger(), getSourceDocument(), getEvent());
     }
 
     protected String getEvent() {

Modified: lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/SiteOverview.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/SiteOverview.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/SiteOverview.java (original)
+++ lenya/trunk/org.apache.lenya.core.sitemanagement/src/main/java/org/apache/lenya/cms/site/usecases/SiteOverview.java Fri Feb  6 17:55:28 2009
@@ -31,19 +31,15 @@
 import java.util.SortedSet;
 import java.util.TreeSet;
 
-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.DocumentException;
-import org.apache.lenya.cms.publication.DocumentFactory;
 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.URLInformation;
 import org.apache.lenya.cms.repository.Node;
 import org.apache.lenya.cms.repository.RepositoryException;
 import org.apache.lenya.cms.site.SiteException;
-import org.apache.lenya.cms.site.SiteManager;
 import org.apache.lenya.cms.usecase.AbstractUsecase;
 import org.apache.lenya.cms.workflow.WorkflowUtil;
 import org.apache.lenya.workflow.Version;
@@ -95,7 +91,7 @@
         super.prepareView();
         setDefaultParameter(SORT, KEY_PATH);
         setDefaultParameter(ORDER, ASC);
-        
+
         try {
             Document[] documents = getDocuments();
             List entries = new ArrayList();
@@ -104,7 +100,7 @@
             }
 
             prepareFilters(entries);
-            
+
             List filteredDocuments = filter(entries);
             sort(filteredDocuments);
             setParameter(DOCUMENTS, filteredDocuments);
@@ -115,7 +111,7 @@
             throw new RuntimeException(e);
         }
     }
-    
+
     protected void setDefaultParameter(String name, String value) {
         if (getParameter(name) == null) {
             setParameter(name, value);
@@ -140,16 +136,14 @@
         String lastModified = format.format(new Date(doc.getLastModified()));
         entry.setValue(KEY_LAST_MODIFIED, lastModified);
 
-        if (WorkflowUtil.hasWorkflow(this.manager, getLogger(), doc)) {
-            Workflowable workflowable = WorkflowUtil.getWorkflowable(this.manager,
-                    getLogger(), doc);
+        if (WorkflowUtil.hasWorkflow(getLogger(), doc)) {
+            Workflowable workflowable = WorkflowUtil.getWorkflowable(getLogger(), doc);
             Version latestVersion = workflowable.getLatestVersion();
             String state;
             if (latestVersion != null) {
                 state = latestVersion.getState();
             } else {
-                Workflow workflow = WorkflowUtil.getWorkflowSchema(this.manager,
-                        getLogger(), doc);
+                Workflow workflow = WorkflowUtil.getWorkflowSchema(getLogger(), doc);
                 state = workflow.getInitialState();
             }
             entry.setValue(KEY_WORKFLOW_STATE, state);
@@ -199,8 +193,8 @@
             String key = "key" + FILTERS[i].substring("filter".length());
             String filterValue = getParameterAsString(FILTERS[i]);
             if (!filterValue.equals(VALUE_ALL)) {
-                Entry[] allEntries = (Entry[]) filteredDocuments.toArray(new Entry[filteredDocuments
-                        .size()]);
+                Entry[] allEntries = (Entry[]) filteredDocuments
+                        .toArray(new Entry[filteredDocuments.size()]);
                 for (int entryIndex = 0; entryIndex < allEntries.length; entryIndex++) {
                     if (!allEntries[entryIndex].getValue(key).equals(filterValue)) {
                         filteredDocuments.remove(allEntries[entryIndex]);
@@ -217,38 +211,7 @@
      * @throws SiteException if an error occurs.
      */
     protected Document[] getDocuments() throws PublicationException, SiteException {
-        Publication publication = getPublication();
-        DocumentFactory identityMap = getDocumentFactory();
-        Document[] documents;
-
-        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.AUTHORING_AREA);
-        } catch (ServiceException e) {
-            throw new RuntimeException(e);
-        } finally {
-            if (selector != null) {
-                if (siteManager != null) {
-                    selector.release(siteManager);
-                }
-                this.manager.release(selector);
-            }
-        }
-
-        return documents;
-    }
-
-    /**
-     * @return The publication.
-     * @throws PublicationException if an error occurs.
-     */
-    protected Publication getPublication() throws PublicationException {
-        return PublicationUtil.getPublicationFromUrl(this.manager, getDocumentFactory(),
-                getSourceURL());
+        return getPublication().getArea(Publication.AUTHORING_AREA).getDocuments();
     }
 
     /**

Modified: lenya/trunk/org.apache.lenya.core.templating/src/main/java/org/apache/lenya/cms/publication/templating/PublicationTemplateManagerImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.templating/src/main/java/org/apache/lenya/cms/publication/templating/PublicationTemplateManagerImpl.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.templating/src/main/java/org/apache/lenya/cms/publication/templating/PublicationTemplateManagerImpl.java (original)
+++ lenya/trunk/org.apache.lenya.core.templating/src/main/java/org/apache/lenya/cms/publication/templating/PublicationTemplateManagerImpl.java Fri Feb  6 17:55:28 2009
@@ -22,41 +22,31 @@
 import java.util.Arrays;
 import java.util.List;
 
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.ServiceSelector;
-import org.apache.avalon.framework.service.Serviceable;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 import org.apache.cocoon.util.AbstractLogEnabled;
 import org.apache.commons.logging.Log;
 import org.apache.excalibur.source.SourceResolver;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.PublicationException;
+import org.springframework.web.context.WebApplicationContext;
 
 /**
  * Manager for publication templates.
  * 
- * @version $Id: PublicationTemplateManagerImpl.java 474729 2006-11-14 11:07:44Z
- *          andreas $
+ * @version $Id$
  */
 public class PublicationTemplateManagerImpl extends AbstractLogEnabled implements
-        PublicationTemplateManager, Serviceable {
+        PublicationTemplateManager {
 
-    /**
-     * Ctor.
-     */
-    public PublicationTemplateManagerImpl() {
-    }
+    private SourceResolver sourceResolver;
 
     /**
      * @see org.apache.lenya.cms.publication.templating.PublicationTemplateManager#visit(org.apache.lenya.cms.publication.Publication,
-     *      java.lang.String,
-     *      org.apache.lenya.cms.publication.templating.SourceVisitor)
+     *      java.lang.String, org.apache.lenya.cms.publication.templating.SourceVisitor)
      */
     public void visit(Publication publication, String path, SourceVisitor visitor) {
 
-        SourceResolver resolver = null;
         try {
-            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
 
             String[] baseUris = getBaseURIs(publication);
             for (int i = 0; i < baseUris.length; i++) {
@@ -66,32 +56,18 @@
                     getLogger().debug("Trying to resolve URI [" + uri + "]");
                 }
 
-                visitor.visit(resolver, uri);
+                visitor.visit(this.sourceResolver, uri);
             }
 
         } catch (Exception e) {
             throw new TemplatingException("Visiting path [" + path + "] failed: ", e);
-        } finally {
-            if (resolver != null) {
-                this.manager.release(resolver);
-            }
         }
 
     }
 
-    private ServiceManager manager;
-
-    /**
-     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
-     */
-    public void service(ServiceManager _manager) throws ServiceException {
-        this.manager = _manager;
-    }
-
     /**
      * Returns the publication.
-     * @return A publication. protected Publication getPublication1() { return
-     *         this.publication; }
+     * @return A publication. protected Publication getPublication1() { return this.publication; }
      */
 
     /**
@@ -128,10 +104,7 @@
      *      org.apache.lenya.cms.publication.templating.PublicationVisitor)
      */
     public void visit(Publication publication, PublicationVisitor visitor) {
-        SourceResolver resolver = null;
         try {
-            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
-
             Publication[] publications = getPublications(publication);
             for (int i = 0; i < publications.length; i++) {
                 if (getLogger().isDebugEnabled()) {
@@ -139,15 +112,9 @@
                 }
                 visitor.visit(publications[i]);
             }
-
         } catch (Exception e) {
             throw new TemplatingException("Visiting publications failed: ", e);
-        } finally {
-            if (resolver != null) {
-                this.manager.release(resolver);
-            }
         }
-
     }
 
     /**
@@ -162,7 +129,7 @@
         publications.add(publication);
 
         String templateId = publication.getTemplateId();
-        if(templateId != null) {
+        if (templateId != null) {
             try {
                 Publication template = publication.getFactory().getPublication(templateId);
                 Publication[] templateTemplates = getPublications(template);
@@ -175,17 +142,11 @@
         return (Publication[]) publications.toArray(new Publication[publications.size()]);
     }
 
-    /**
-     * @see org.apache.lenya.cms.publication.templating.PublicationTemplateManager#getSelectableHint(org.apache.lenya.cms.publication.Publication,
-     *      org.apache.avalon.framework.service.ServiceSelector,
-     *      java.lang.String)
-     */
-    public Object getSelectableHint(Publication publication, ServiceSelector selector,
-            final String originalHint) throws ServiceException {
+    public Object getSelectableHint(Publication publication, String role, final String originalHint) {
         Object selectableHint = null;
 
         try {
-            ExistingServiceVisitor resolver = new ExistingServiceVisitor(selector, originalHint,
+            ExistingServiceVisitor resolver = new ExistingServiceVisitor(role, originalHint,
                     getLogger());
             visit(publication, resolver);
             selectableHint = resolver.getSelectableHint();
@@ -197,10 +158,18 @@
             String message = "Resolving hint [" + originalHint + "] failed: ";
             getLogger().error(message, e);
             throw new RuntimeException(message, e);
-        } 
+        }
         return selectableHint;
     }
 
+    public void setSourceResolver(SourceResolver sourceResolver) {
+        this.sourceResolver = sourceResolver;
+    }
+
+    public SourceResolver getSourceResolver() {
+        return sourceResolver;
+    }
+
     /**
      * Searches for a declared service of the form "publicationId/service".
      */
@@ -212,16 +181,16 @@
          * @param hint The hint to check.
          * @param logger The logger.
          */
-        public ExistingServiceVisitor(ServiceSelector selector, Object hint, Log logger) {
-            this.selector = selector;
+        public ExistingServiceVisitor(String role, Object hint, Log logger) {
             this.hint = hint;
             this.logger = logger;
+            this.role = role;
         }
 
-        private ServiceSelector selector;
         private Object hint;
         private Object selectableHint = null;
         private Log logger;
+        private String role;
 
         /**
          * @see org.apache.lenya.cms.publication.templating.PublicationVisitor#visit(org.apache.lenya.cms.publication.Publication)
@@ -229,7 +198,8 @@
         public void visit(Publication publication) {
             String publicationHint = publication.getId() + "/" + this.hint;
             boolean success = false;
-            if (this.selector.isSelectable(publicationHint)) {
+            WebApplicationContext context = WebAppContextUtils.getCurrentWebApplicationContext();
+            if (context.containsBean(this.role + "/" + publicationHint)) {
                 this.selectableHint = publicationHint;
                 success = true;
             }
@@ -239,8 +209,8 @@
         }
 
         /**
-         * @return The publication hint that could be selected or
-         *         <code>null</code> if no hint could be selected.
+         * @return The publication hint that could be selected or <code>null</code> if no hint could
+         *         be selected.
          */
         public Object getSelectableHint() {
             return this.selectableHint;

Modified: lenya/trunk/org.apache.lenya.core.templating/src/main/java/org/apache/lenya/cms/publication/usecases/CreatePublicationFromTemplate.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.templating/src/main/java/org/apache/lenya/cms/publication/usecases/CreatePublicationFromTemplate.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.templating/src/main/java/org/apache/lenya/cms/publication/usecases/CreatePublicationFromTemplate.java (original)
+++ lenya/trunk/org.apache.lenya.core.templating/src/main/java/org/apache/lenya/cms/publication/usecases/CreatePublicationFromTemplate.java Fri Feb  6 17:55:28 2009
@@ -21,7 +21,7 @@
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.avalon.framework.service.ServiceSelector;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.PublicationUtil;
 import org.apache.lenya.cms.publication.templating.Instantiator;
@@ -86,36 +86,21 @@
 
         String templateId = getParameterAsString(TEMPLATE);
 
-        ServiceSelector selector = null;
         Instantiator instantiator = null;
 
-        try {
-
-            Publication template = getDocumentFactory().getPublication(templateId);
-            String name = getParameterAsString(PUBLICATION_NAME);
-
-            selector = (ServiceSelector) this.manager.lookup(Instantiator.ROLE + "Selector");
-            instantiator = (Instantiator) selector.select(template.getInstantiatorHint());
+        Publication template = getDocumentFactory().getPublication(templateId);
+        String name = getParameterAsString(PUBLICATION_NAME);
 
-            instantiator.instantiate(template, getParameterAsString(PUBLICATION_ID), name);
-            
-        } finally {
-            if (selector != null) {
-                if (instantiator != null) {
-                    selector.release(instantiator);
-                }
-                this.manager.release(selector);
-            }
-        }
+        instantiator = (Instantiator) WebAppContextUtils.getCurrentWebApplicationContext().getBean(
+                Instantiator.ROLE + "/" + template.getInstantiatorHint());
 
+        instantiator.instantiate(template, getParameterAsString(PUBLICATION_ID), name);
     }
-    /* TODO: enable once we can change configuration options in publication
-             via web interface
-    public String getTargetURL(boolean success) {
-        if (success) {
-            return "/" + getParameterAsString(PUBLICATION_ID) + "/introduction.html";
-        }
-        return super.getTargetURL(success);
-    }
-    */
+    
+    /*
+     * TODO: enable once we can change configuration options in publication via web interface public
+     * String getTargetURL(boolean success) { if (success) { return "/" +
+     * getParameterAsString(PUBLICATION_ID) + "/introduction.html"; } return
+     * super.getTargetURL(success); }
+     */
 }

Modified: lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/cocoon/transformation/UsecaseMenuTransformer.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/cocoon/transformation/UsecaseMenuTransformer.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/cocoon/transformation/UsecaseMenuTransformer.java (original)
+++ lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/cocoon/transformation/UsecaseMenuTransformer.java Fri Feb  6 17:55:28 2009
@@ -38,8 +38,13 @@
 import org.apache.lenya.ac.Role;
 import org.apache.lenya.cms.ac.PolicyUtil;
 import org.apache.lenya.cms.ac.usecase.UsecaseAuthorizer;
+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.PublicationUtil;
+import org.apache.lenya.cms.publication.URLInformation;
+import org.apache.lenya.cms.repository.RepositoryManager;
+import org.apache.lenya.cms.repository.RepositoryUtil;
+import org.apache.lenya.cms.repository.Session;
 import org.apache.lenya.cms.usecase.Usecase;
 import org.apache.lenya.cms.usecase.UsecaseMessage;
 import org.apache.lenya.cms.usecase.UsecaseResolver;
@@ -237,6 +242,7 @@
     private Publication publication;
     private AccessControllerResolver acResolver;
     private String sourceUrl;
+    private RepositoryManager repositoryManager;
 
     /**
      * @see org.apache.cocoon.sitemap.SitemapModelComponent#setup(org.apache.cocoon.environment.SourceResolver,
@@ -253,14 +259,17 @@
 
         try {
             this.roles = PolicyUtil.getRoles(this.request);
-            this.publication = PublicationUtil.getPublication(this.manager, _objectModel);
+            String webappUrl = ServletHelper.getWebappURI(this.request);
+            Session session = RepositoryUtil.getSession(getRepositoryManager(), this.request);
+            DocumentFactory factory = DocumentUtil.createDocumentFactory(session);
+            final String id = new URLInformation(webappUrl).getPublicationId();
+            this.publication = factory.getPublication(id);
 
             this.serviceSelector = (ServiceSelector) this.manager.lookup(AccessControllerResolver.ROLE
                     + "Selector");
             this.acResolver = (AccessControllerResolver) this.serviceSelector.select(AccessControllerResolver.DEFAULT_RESOLVER);
             getLogger().debug("Resolved AC resolver [" + this.acResolver + "]");
 
-            String webappUrl = ServletHelper.getWebappURI(this.request);
             AccessController accessController = this.acResolver.resolveAccessController(webappUrl);
 
             Authorizer[] authorizers = accessController.getAuthorizers();
@@ -300,4 +309,12 @@
         this.sourceUrl = null;
     }
 
+    public RepositoryManager getRepositoryManager() {
+        return repositoryManager;
+    }
+
+    public void setRepositoryManager(RepositoryManager repositoryManager) {
+        this.repositoryManager = repositoryManager;
+    }
+
 }

Modified: lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/AbstractUsecase.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/AbstractUsecase.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/AbstractUsecase.java (original)
+++ lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/AbstractUsecase.java Fri Feb  6 17:55:28 2009
@@ -23,26 +23,23 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 import java.util.Set;
 
-import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.configuration.Configurable;
-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.ContextException;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
-import org.apache.cocoon.components.ContextHelper;
-import org.apache.cocoon.environment.Request;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.cocoon.processing.ProcessInfoProvider;
 import org.apache.cocoon.servlet.multipart.Part;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 import org.apache.cocoon.util.AbstractLogEnabled;
 import org.apache.lenya.cms.publication.DocumentFactory;
-import org.apache.lenya.cms.publication.DocumentUtil;
+import org.apache.lenya.cms.publication.DocumentFactoryBuilder;
+import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.publication.PublicationException;
+import org.apache.lenya.cms.publication.URLInformation;
 import org.apache.lenya.cms.repository.Node;
 import org.apache.lenya.cms.repository.RepositoryException;
+import org.apache.lenya.cms.repository.RepositoryManager;
 import org.apache.lenya.cms.repository.RepositoryUtil;
 import org.apache.lenya.cms.repository.Session;
 import org.apache.lenya.transaction.ConcurrentModificationException;
@@ -54,8 +51,7 @@
  * 
  * @version $Id$
  */
-public class AbstractUsecase extends AbstractLogEnabled implements Usecase, Configurable,
-        Contextualizable, Serviceable, Initializable {
+public class AbstractUsecase extends AbstractLogEnabled implements Usecase {
 
     protected static final String EVENT_CHECK_POSTCONDITIONS = "checkPostconditions";
 
@@ -88,6 +84,10 @@
 
     protected static final String PARAMETERS_INITIALIZED = "private.parametersInitialized";
 
+    private DocumentFactoryBuilder documentFactoryBuilder;
+    private RepositoryManager repositoryManager;
+    private UsecaseView view;
+
     /**
      * Override to initialize parameters.
      */
@@ -125,14 +125,6 @@
     }
 
     /**
-     * Returns the context.
-     * @return A context.
-     */
-    protected Context getContext() {
-        return this.context;
-    }
-
-    /**
      * Determine if the usecase has error messages. Provides a way of checking for errors without
      * actually retrieving them.
      * @return true if the usecase resulted in error messages.
@@ -560,18 +552,20 @@
         DocumentFactory factory = (DocumentFactory) getParameter(PARAMETER_FACTORY);
         Session session = getSession();
         if (factory == null || factory.getSession() != session) {
-            factory = DocumentUtil.createDocumentFactory(this.manager, session);
+            factory = getDocumentFactoryBuilder().createDocumentFactory(session);
             setParameter(PARAMETER_FACTORY, factory);
         }
         return factory;
     }
 
     /**
-     * @see org.apache.avalon.framework.activity.Initializable#initialize()
+     * TODO: Add init-method to bean.
      */
-    public final void initialize() throws Exception {
-        Request request = ContextHelper.getRequest(this.context);
-        Session session = RepositoryUtil.getSession(this.manager, request);
+    public final void initialize() throws RepositoryException {
+        ProcessInfoProvider processInfo = (ProcessInfoProvider) WebAppContextUtils
+                .getCurrentWebApplicationContext().getBean(ProcessInfoProvider.ROLE);
+        HttpServletRequest request = processInfo.getRequest();
+        Session session = RepositoryUtil.getSession(getRepositoryManager(), request);
         setSession(session);
         setParameter(PARAMETER_STATE_MACHINE, new StateMachine(MODEL));
     }
@@ -636,8 +630,6 @@
         setParameter(SOURCE_URL, url);
     }
 
-    private UsecaseView view;
-
     /**
      * @see org.apache.lenya.cms.usecase.Usecase#getView()
      */
@@ -657,7 +649,7 @@
             }
         }
     }
-    
+
     /**
      * Override this method to prepare the view (add information messages etc.).
      * @throws Exception If an error occurs.
@@ -686,57 +678,6 @@
         return this.isOptimistic;
     }
 
-    /**
-     * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
-     */
-    public void configure(Configuration config) throws ConfigurationException {
-
-        Configuration[] parameterConfigs = config.getChildren(ELEMENT_PARAMETER);
-        for (int i = 0; i < parameterConfigs.length; i++) {
-            String name = parameterConfigs[i].getAttribute(ATTRIBUTE_NAME);
-            String value = parameterConfigs[i].getAttribute(ATTRIBUTE_VALUE);
-            setParameter(name, value);
-        }
-
-        Configuration viewConfig = config.getChild(ELEMENT_VIEW, false);
-        if (viewConfig != null) {
-            this.view = new UsecaseView();
-            try {
-                view.service(this.manager);
-            } catch (ServiceException e) {
-                throw new ConfigurationException("Couldn't service view: ", e);
-            }
-            view.configure(viewConfig);
-        }
-
-        Configuration transactionConfig = config.getChild(ELEMENT_TRANSACTION, false);
-        if (transactionConfig != null) {
-            String policy = transactionConfig.getAttribute(ATTRIBUTE_POLICY);
-            if (policy.equals(VALUE_PESSIMISTIC)) {
-                this.isOptimistic = false;
-            }
-        }
-
-        Configuration exitConfig = config.getChild(ELEMENT_EXIT, false);
-        if (exitConfig != null) {
-            this.exitUsecaseName = exitConfig.getAttribute(ATTRIBUTE_USECASE);
-            Configuration[] exitParameterConfigs = exitConfig.getChildren(ELEMENT_PARAMETER);
-            for (int i = 0; i < exitParameterConfigs.length; i++) {
-                String name = exitParameterConfigs[i].getAttribute(ATTRIBUTE_NAME);
-                String value = null;
-                String[] attributeNames = exitParameterConfigs[i].getAttributeNames();
-                for (int j = 0; j < attributeNames.length; j++) {
-                    if (attributeNames[j].equals(ATTRIBUTE_VALUE))
-                        value = exitParameterConfigs[i].getAttribute(ATTRIBUTE_VALUE);
-                }
-                setExitParameter(name, value);
-            }
-        }
-    }
-
-    /**
-     * @see org.apache.lenya.cms.usecase.Usecase#setView(org.apache.lenya.cms.usecase.UsecaseView)
-     */
     public void setView(UsecaseView view) {
         this.view = view;
     }
@@ -751,9 +692,9 @@
 
     /**
      * <p>
-     * This method starts the transaction and locks all involved objects immediately.
-     * This way, all changes to the objects in the session occur after the locking,
-     * avoiding overriding changes of other sessions.
+     * This method starts the transaction and locks all involved objects immediately. This way, all
+     * changes to the objects in the session occur after the locking, avoiding overriding changes of
+     * other sessions.
      * </p>
      * <p>
      * This method is locked via the class lock to avoid inter-usecase synchronization issues.
@@ -778,7 +719,7 @@
      */
     protected void startTransaction() throws RepositoryException {
         if (this.commitEnabled) {
-            setSession(RepositoryUtil.createSession(this.manager, getSession().getIdentity(), true));
+            setSession(getRepositoryManager().createSession(getSession().getIdentity(), true));
         }
     }
 
@@ -878,21 +819,6 @@
         return (Session) getParameter(PARAMETER_SESSION);
     }
 
-    protected Context context;
-
-    /**
-     * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
-     */
-    public void contextualize(Context context) throws ContextException {
-        this.context = context;
-    }
-
-    protected ServiceManager manager;
-
-    public void service(ServiceManager manager) throws ServiceException {
-        this.manager = manager;
-    }
-
     protected void setSession(org.apache.lenya.cms.repository.Session session) {
         setParameter(PARAMETER_SESSION, session);
     }
@@ -903,9 +829,73 @@
         this.commitEnabled = false;
         setSession(session);
     }
-    
+
     protected boolean checkoutRestrictedToSession() {
         return getParameterAsBoolean(PARAMETER_CHECKOUT_RESTRICTED_TO_SESSION, true);
     }
 
+    protected DocumentFactoryBuilder getDocumentFactoryBuilder() {
+        return documentFactoryBuilder;
+    }
+
+    public void setDocumentFactoryBuilder(DocumentFactoryBuilder documentFactoryBuilder) {
+        this.documentFactoryBuilder = documentFactoryBuilder;
+    }
+
+    protected RepositoryManager getRepositoryManager() {
+        return repositoryManager;
+    }
+
+    public void setRepositoryManager(RepositoryManager repositoryManager) {
+        this.repositoryManager = repositoryManager;
+    }
+
+    public void setParameters(Properties params) {
+        this.parameters = params;
+    }
+
+    public void setIsOptimistic(boolean optimistic) {
+        this.isOptimistic = optimistic;
+    }
+
+    protected String getExitUsecaseName() {
+        return exitUsecaseName;
+    }
+
+    public void setExitUsecaseName(String exitUsecaseName) {
+        this.exitUsecaseName = exitUsecaseName;
+    }
+
+    protected Map getExitUsecaseParameters() {
+        return exitUsecaseParameters;
+    }
+
+    public void setExitUsecaseParameters(Properties params) {
+        this.exitUsecaseParameters = params;
+    }
+
+    protected HttpServletRequest getRequest() {
+        ProcessInfoProvider process = (ProcessInfoProvider) WebAppContextUtils
+                .getCurrentWebApplicationContext().getBean(ProcessInfoProvider.ROLE);
+        HttpServletRequest request = process.getRequest();
+        return request;
+    }
+
+    private Publication pub;
+
+    /**
+     * @return the publication in which the use-case is being executed
+     */
+    protected Publication getPublication() {
+        if (this.pub == null) {
+            String pubId = new URLInformation(getSourceURL()).getPublicationId();
+            try {
+                this.pub = getDocumentFactory().getPublication(pubId);
+            } catch (PublicationException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        return this.pub;
+    }
+
 }

Modified: lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/Usecase.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/Usecase.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/Usecase.java (original)
+++ lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/Usecase.java Fri Feb  6 17:55:28 2009
@@ -201,11 +201,6 @@
     UsecaseView getView();
 
     /**
-     * @param view The view of the usecase.
-     */
-    void setView(UsecaseView view);
-
-    /**
      * @return The repository session.
      */
     Session getSession();
@@ -228,4 +223,10 @@
      * @throws UsecaseException if an error occurs.
      */
     void setupView() throws UsecaseException;
+
+    /**
+     * @param view The view
+     * @deprecated The UsecaseProxy concept will hopefully be abandoned soon.
+     */
+    void setView(UsecaseView view);
 }

Modified: lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/UsecaseView.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/UsecaseView.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/UsecaseView.java (original)
+++ lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/UsecaseView.java Fri Feb  6 17:55:28 2009
@@ -19,13 +19,8 @@
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Properties;
 
-import org.apache.avalon.framework.configuration.Configurable;
-import org.apache.avalon.framework.configuration.Configuration;
-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.lenya.cms.usecase.gui.GUIManager;
 import org.apache.lenya.cms.usecase.gui.Tab;
 
@@ -33,9 +28,8 @@
  * Information about a usecase view.
  * 
  * @version $Id$
- * <p>
- * Example configuration:
- * <code><pre>&lt;view uri="/modules/foo/usecases/foo-mogrify.jx"
+ *          <p>
+ *          Example configuration: <code><pre>&lt;view uri="/modules/foo/usecases/foo-mogrify.jx"
  *     customFlow="/modules/foo/flow/myflow.js"
  *     menu="false|true"
  *     createContinuation="false|true"
@@ -43,48 +37,52 @@
  *   &lt;tab group="foo" name="bar"/&gt;      // optional
  *   &lt;parameter name="foo" value="bar/&gt; // optional
  * &lt;/view&gt;</pre></code>
- * </p>
- * <p>
- * <code>uri</code> is the relative URL of the page to be sent back to the client. If the URI
- * starts with a slash, it is resolved starting at the root sitemap, otherwise it
- * is resolved relative to the current sitemap. The URI should not contain a
- * scheme (such as cocoon:).
- * </p>
- * <p>
- * <code>menu</code> is a boolean that governs whether the Lenya GUI menu is displayed while
- * the usecase is running. The displaying of the menu is handled by the usecase.xmap sitemap;
- * hence this option is only functional if <code>uri</code> does <em>not</em> start with a slash
- * (or if you implement it yourself based on the <code>showMenu()</code> method of this object).<br>
- * Default is <em>false</em>.
- * </p>
- * <p>
- * <code>customFlow</code> is a javascript file where you can provide custom methods that will override
- * those in the default usecase handler (<code>modules-core/usecase/usecases.js</code>).
- * Currently, it provides support for "customLoopFlow" and "customSubmitFlow". Refer to the default handler
- * for function prototypes and more information.
- * NB: the "menu" and "createContinuation" attributes will have no effect when you use custom flow code, unless
- * you check for them and implement the respective functions yourself.
- * </p>
- * <p>
- * <code>createContinuation</code> can be set to false, in which case the generic flowscript
- * uses "sendPage" instead of "sendPageAndWait" and terminates after the view has been sent.
- * When <code>createContinuation</code> is false, you must not specify <code>submitFlow</code> 
- * or <code>loopFlow</code>.<br>
- * Default is <em>true</em>.
- * </p>
- * <p>
- * For tabbed usecases, you can optionally specify a tab group and name. Additional custom
- * configuration can be passed via the generic "parameter" element. 
- * </p>
- * <p>
- * For backwards compatibility with existing usecases, the constructor looks for a <code>template</code>
- * attribute if no <code>uri</code> is present. It is mapped to the same field, viewUri, internally.
- * </p>
+ *          </p>
+ *          <p>
+ *          <code>uri</code> is the relative URL of the page to be sent back to the client. If the
+ *          URI starts with a slash, it is resolved starting at the root sitemap, otherwise it is
+ *          resolved relative to the current sitemap. The URI should not contain a scheme (such as
+ *          cocoon:).
+ *          </p>
+ *          <p>
+ *          <code>menu</code> is a boolean that governs whether the Lenya GUI menu is displayed
+ *          while the usecase is running. The displaying of the menu is handled by the usecase.xmap
+ *          sitemap; hence this option is only functional if <code>uri</code> does <em>not</em>
+ *          start with a slash (or if you implement it yourself based on the <code>showMenu()</code>
+ *          method of this object).<br>
+ *          Default is <em>false</em>.
+ *          </p>
+ *          <p>
+ *          <code>customFlow</code> is a javascript file where you can provide custom methods that
+ *          will override those in the default usecase handler (
+ *          <code>modules-core/usecase/usecases.js</code>). Currently, it provides support for
+ *          "customLoopFlow" and "customSubmitFlow". Refer to the default handler for function
+ *          prototypes and more information. NB: the "menu" and "createContinuation" attributes will
+ *          have no effect when you use custom flow code, unless you check for them and implement
+ *          the respective functions yourself.
+ *          </p>
+ *          <p>
+ *          <code>createContinuation</code> can be set to false, in which case the generic
+ *          flowscript uses "sendPage" instead of "sendPageAndWait" and terminates after the view
+ *          has been sent. When <code>createContinuation</code> is false, you must not specify
+ *          <code>submitFlow</code> or <code>loopFlow</code>.<br>
+ *          Default is <em>true</em>.
+ *          </p>
+ *          <p>
+ *          For tabbed usecases, you can optionally specify a tab group and name. Additional custom
+ *          configuration can be passed via the generic "parameter" element.
+ *          </p>
+ *          <p>
+ *          For backwards compatibility with existing usecases, the constructor looks for a
+ *          <code>template</code> attribute if no <code>uri</code> is present. It is mapped to the
+ *          same field, viewUri, internally.
+ *          </p>
  */
-public class UsecaseView implements Configurable, Serviceable {
+public class UsecaseView {
 
     protected static final String ATTRIBUTE_URI = "uri";
-    protected static final String ATTRIBUTE_TEMPLATE = "template"; // backwards compatibility, mapped to "uri"
+    protected static final String ATTRIBUTE_TEMPLATE = "template"; // backwards compatibility,
+    // mapped to "uri"
 
     protected static final String ATTRIBUTE_CUSTOM_FLOW = "customFlow";
     protected static final String ATTRIBUTE_SHOW_MENU = "menu";
@@ -96,66 +94,20 @@
     protected static final String ATTRIBUTE_VALUE = "value";
 
     // tabbed usecases:
-    protected static final String ATTRIBUTE_GROUP = "group"; 
+    protected static final String ATTRIBUTE_GROUP = "group";
     protected static final String ELEMENT_TAB = "tab";
 
-
     private Map parameters = new HashMap();
-    private ServiceManager manager;
 
     private String viewUri;
     private String customFlow;
-    
+
     private boolean showMenu;
     private boolean createContinuation;
     private Tab tab;
-
-
-    
-    /**
-     * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
-     */
-    public void configure(Configuration config) throws ConfigurationException {
-        // get <view> attributes:
-        this.viewUri = config.getAttribute(ATTRIBUTE_URI, "");
-        if (this.viewUri == "") {
-           // fall back to "template" attribute for backwards compatibility (rip out eventually).
-           this.viewUri = config.getAttribute(ATTRIBUTE_TEMPLATE, "");
-        }
-        this.showMenu = config.getAttributeAsBoolean(ATTRIBUTE_SHOW_MENU, false);
-        this.customFlow = config.getAttribute(ATTRIBUTE_CUSTOM_FLOW, "");
-        this.createContinuation = config.getAttributeAsBoolean(ATTRIBUTE_CREATE_CONT, true);
-
-
-        // get <tab/> configuration:
-        Configuration tabConfig = config.getChild(ELEMENT_TAB, false);
-        if (tabConfig != null) {
-            String tabName = tabConfig.getAttribute(ATTRIBUTE_NAME);
-            String tabGroup = tabConfig.getAttribute(ATTRIBUTE_GROUP);
-            GUIManager guiMgr = null;
-            try {
-                guiMgr = (GUIManager) this.manager.lookup(GUIManager.ROLE);
-                this.tab = guiMgr.getTab(tabGroup, tabName);
-            } catch (ServiceException e) {
-                throw new RuntimeException(e);
-            } finally {
-                if (guiMgr != null) {
-                    this.manager.release(guiMgr);
-                }
-            }
-        }
-
-        // get <parameter/> configuration
-        Configuration[] parameterConfigs = config.getChildren(ELEMENT_PARAMETER);
-        for (int i = 0; i < parameterConfigs.length; i++) {
-            String name = parameterConfigs[i].getAttribute(ATTRIBUTE_NAME);
-            String value = parameterConfigs[i].getAttribute(ATTRIBUTE_VALUE);
-            this.parameters.put(name, value);
-        }
-
-        checkConfig();
-
-    }
+    private GUIManager guiManager;
+    private String tabName;
+    private String tabGroup;
 
     /**
      * @return The URI of the JX template;
@@ -207,30 +159,58 @@
         if (getTab() == null) {
             return null;
         } else {
-            GUIManager guiMgr = null;
-            try {
-                guiMgr = (GUIManager) this.manager.lookup(GUIManager.ROLE);
-                return guiMgr.getActiveTabs(getTab().getGroup());
-            } catch (ServiceException e) {
-                throw new RuntimeException(e);
-            } finally {
-                if (guiMgr != null) {
-                    this.manager.release(guiMgr);
-                }
-            }
+            return getGuiManager().getActiveTabs(getTab().getGroup());
         }
     }
 
     /**
-     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
+     * TODO: Add init-method attribute to bean configuration.
      */
-    public void service(ServiceManager manager) throws ServiceException {
-        this.manager = manager;
-    }
-
-    private void checkConfig() throws ConfigurationException {
+    public void initialize() {
         if (this.tab != null && this.viewUri == "") {
-            throw new ConfigurationException("When you specify a <tab/>, you must specify a <view uri=\"..\"/> as well!");
+            throw new RuntimeException("When you specify a <tab/>, you must specify a <view uri=\"..\"/> as well!");
         }
+        this.tab = getGuiManager().getTab(tabGroup, tabName);
+    }
+
+    public GUIManager getGuiManager() {
+        return guiManager;
     }
+
+    public void setGuiManager(GUIManager guiManager) {
+        this.guiManager = guiManager;
+    }
+    
+    /**
+     * Bean setter.
+     * @param uri The view URI.
+     */
+    public void setUri(String uri) {
+        this.viewUri = uri;
+    }
+
+    public void setShowMenu(boolean showMenu) {
+        this.showMenu = showMenu;
+    }
+
+    public void setCreateContinuation(boolean createContinuation) {
+        this.createContinuation = createContinuation;
+    }
+
+    public void setTabName(String tabName) {
+        this.tabName = tabName;
+    }
+
+    public void setTabGroup(String tabGroup) {
+        this.tabGroup = tabGroup;
+    }
+    
+    public void setCustomFlow(String customFlow) {
+        this.customFlow = customFlow;
+    }
+    
+    public void setParameters(Properties params) {
+        this.parameters = params;
+    }
+
 }

Modified: lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/gui/impl/GUIManagerImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/gui/impl/GUIManagerImpl.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/gui/impl/GUIManagerImpl.java (original)
+++ lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/gui/impl/GUIManagerImpl.java Fri Feb  6 17:55:28 2009
@@ -22,18 +22,12 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.avalon.framework.configuration.Configurable;
+import javax.servlet.http.HttpServletRequest;
+
 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.ContextException;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.ServiceSelector;
-import org.apache.avalon.framework.service.Serviceable;
-import org.apache.cocoon.components.ContextHelper;
-import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.processing.ProcessInfoProvider;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 import org.apache.cocoon.util.AbstractLogEnabled;
 import org.apache.lenya.ac.AccessControlException;
 import org.apache.lenya.ac.AccessController;
@@ -42,11 +36,13 @@
 import org.apache.lenya.ac.Role;
 import org.apache.lenya.cms.ac.PolicyUtil;
 import org.apache.lenya.cms.ac.usecase.UsecaseAuthorizer;
-import org.apache.lenya.cms.cocoon.components.context.ContextUtility;
 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.PublicationUtil;
+import org.apache.lenya.cms.publication.URLInformation;
+import org.apache.lenya.cms.repository.RepositoryManager;
+import org.apache.lenya.cms.repository.RepositoryUtil;
+import org.apache.lenya.cms.repository.Session;
 import org.apache.lenya.cms.usecase.Usecase;
 import org.apache.lenya.cms.usecase.UsecaseMessage;
 import org.apache.lenya.cms.usecase.UsecaseResolver;
@@ -57,8 +53,7 @@
 /**
  * GUI manager implementation.
  */
-public class GUIManagerImpl extends AbstractLogEnabled implements GUIManager, Configurable,
-        Serviceable, Contextualizable {
+public class GUIManagerImpl extends AbstractLogEnabled implements GUIManager {
 
     protected static final String ELEMENT_PARAMETER = "parameter";
     protected static final String ELEMENT_TAB_GROUP = "tab-group";
@@ -70,6 +65,17 @@
 
     private Map name2group = new HashMap();
 
+    private UsecaseResolver usecaseResolver;
+    private RepositoryManager repositoryManager;
+
+    public RepositoryManager getRepositoryManager() {
+        return repositoryManager;
+    }
+
+    public void setRepositoryManager(RepositoryManager repositoryManager) {
+        this.repositoryManager = repositoryManager;
+    }
+
     /**
      * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
      */
@@ -137,24 +143,21 @@
     protected UsecaseMessage[] getErrorMessages(Tab tab) {
 
         UsecaseMessage[] messages;
-
-        ServiceSelector selector = null;
-        AccessControllerResolver acResolver = null;
-        AccessController accessController = null;
-        UsecaseResolver usecaseResolver = null;
         UsecaseAuthorizer authorizer = null;
-        
+
         String usecaseName = tab.getUsecase();
         if (usecaseName == null) {
-            throw new IllegalArgumentException("The usecase name of the tab [" + tab.getName() + "] is null.");
+            throw new IllegalArgumentException("The usecase name of the tab [" + tab.getName()
+                    + "] is null.");
         }
-        
+
         try {
 
-            selector = (ServiceSelector) this.manager.lookup(AccessControllerResolver.ROLE
-                    + "Selector");
-            acResolver = (AccessControllerResolver) selector.select(AccessControllerResolver.DEFAULT_RESOLVER);
-            accessController = acResolver.resolveAccessController(this.webappUrl);
+            AccessControllerResolver  acResolver = (AccessControllerResolver) WebAppContextUtils
+                    .getCurrentWebApplicationContext().getBean(
+                            AccessControllerResolver.ROLE + "/"
+                                    + AccessControllerResolver.DEFAULT_RESOLVER);
+            AccessController accessController = acResolver.resolveAccessController(this.webappUrl);
 
             Authorizer[] authorizers = accessController.getAuthorizers();
             for (int i = 0; i < authorizers.length; i++) {
@@ -163,30 +166,18 @@
                 }
             }
 
-            usecaseResolver = (UsecaseResolver) this.manager.lookup(UsecaseResolver.ROLE);
-
             // filter item if usecase not allowed
             if (tab.getUsecase() != null) {
                 if (getLogger().isDebugEnabled()) {
                     getLogger().debug("Found usecase [" + tab.getUsecase() + "]");
                 }
 
-                DocumentFactory factory;
-                ContextUtility util = null;
-                try {
-                    util = (ContextUtility) this.manager.lookup(ContextUtility.ROLE);
-                    Request request = util.getRequest();
-                    factory = DocumentUtil.getDocumentFactory(this.manager, request);
-                } finally {
-                    if (util != null) {
-                        this.manager.release(util);
-                    }
-                }
-
-                Publication pub = PublicationUtil.getPublicationFromUrl(this.manager,
-                        factory,
-                        this.webappUrl);
-                if (!authorizer.authorizeUsecase(usecaseName, this.roles, pub)) {
+                HttpServletRequest request = getRequest();
+                Session session = RepositoryUtil.getSession(getRepositoryManager(), request);
+                DocumentFactory factory = DocumentUtil.createDocumentFactory(session);
+                String pubId = new URLInformation(this.webappUrl).getPublicationId();
+                Publication pub = factory.getPublication(pubId);
+                if (!authorizer.authorizeUsecase(usecaseName, getRoles(), pub)) {
                     if (getLogger().isDebugEnabled()) {
                         getLogger().debug("Usecase not authorized");
                     }
@@ -224,51 +215,41 @@
             } else {
                 messages = new UsecaseMessage[1];
                 String[] params = {};
-                messages[0] = new UsecaseMessage("Usecase [" + usecaseName + "] is not registered!", params);
+                messages[0] = new UsecaseMessage(
+                        "Usecase [" + usecaseName + "] is not registered!", params);
             }
         } catch (final Exception e) {
             throw new RuntimeException(e);
-        } finally {
-            if (usecaseResolver != null) {
-                this.manager.release(usecaseResolver);
-            }
-            if (selector != null) {
-                if (acResolver != null) {
-                    if (accessController != null) {
-                        acResolver.release(accessController);
-                    }
-                    selector.release(acResolver);
-                }
-                this.manager.release(selector);
-            }
         }
 
         return messages;
     }
 
-    private ServiceManager manager;
-
-    /**
-     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
-     */
-    public void service(ServiceManager manager) throws ServiceException {
-        this.manager = manager;
+    protected HttpServletRequest getRequest() {
+        ProcessInfoProvider process = (ProcessInfoProvider) WebAppContextUtils
+                .getCurrentWebApplicationContext().getBean(ProcessInfoProvider.ROLE);
+        HttpServletRequest request = process.getRequest();
+        return request;
     }
 
     private String webappUrl;
     private Role[] roles;
 
-    /**
-     * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
-     */
-    public void contextualize(Context context) throws ContextException {
-        Request request = ContextHelper.getRequest(context);
-        try {
-            this.roles = PolicyUtil.getRoles(request);
-        } catch (AccessControlException e) {
-            throw new ContextException("Obtaining roles failed: ", e);
+    protected Role[] getRoles() throws AccessControlException {
+        if (this.roles == null) {
+            HttpServletRequest request = getRequest();
+            this.roles = PolicyUtil.getRoles(getRequest());
+            this.webappUrl = ServletHelper.getWebappURI(request);
         }
-        this.webappUrl = ServletHelper.getWebappURI(request);
+        return this.roles;
+    }
+
+    public void setUsecaseResolver(UsecaseResolver usecaseResolver) {
+        this.usecaseResolver = usecaseResolver;
+    }
+
+    public UsecaseResolver getUsecaseResolver() {
+        return usecaseResolver;
     }
 
 }

Modified: lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/impl/UsecaseInvokerImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/impl/UsecaseInvokerImpl.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/impl/UsecaseInvokerImpl.java (original)
+++ lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/impl/UsecaseInvokerImpl.java Fri Feb  6 17:55:28 2009
@@ -23,11 +23,10 @@
 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.avalon.framework.service.Serviceable;
-import org.apache.cocoon.environment.Request;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.cocoon.processing.ProcessInfoProvider;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 import org.apache.cocoon.util.AbstractLogEnabled;
 import org.apache.lenya.ac.AccessController;
 import org.apache.lenya.ac.AccessControllerResolver;
@@ -35,26 +34,30 @@
 import org.apache.lenya.ac.Role;
 import org.apache.lenya.cms.ac.PolicyUtil;
 import org.apache.lenya.cms.ac.usecase.UsecaseAuthorizer;
-import org.apache.lenya.cms.cocoon.components.context.ContextUtility;
 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.URLInformation;
+import org.apache.lenya.cms.repository.RepositoryManager;
+import org.apache.lenya.cms.repository.RepositoryUtil;
 import org.apache.lenya.cms.repository.Session;
 import org.apache.lenya.cms.usecase.Usecase;
 import org.apache.lenya.cms.usecase.UsecaseException;
 import org.apache.lenya.cms.usecase.UsecaseInvoker;
 import org.apache.lenya.cms.usecase.UsecaseMessage;
 import org.apache.lenya.cms.usecase.UsecaseResolver;
+import org.springframework.web.context.WebApplicationContext;
 
 /**
  * Usecase invoker implementation.
  * 
  * @version $Id$
  */
-public class UsecaseInvokerImpl extends AbstractLogEnabled implements UsecaseInvoker, Serviceable {
+public class UsecaseInvokerImpl extends AbstractLogEnabled implements UsecaseInvoker {
 
     private String targetUrl;
+    private RepositoryManager repositoryManager;
+    private UsecaseResolver usecaseResolver;
 
     /**
      * @return if the identity is authorized to invoke the usecase.
@@ -62,43 +65,27 @@
      */
     protected boolean isUsecaseAuthorized(String webappUrl, String usecaseName) throws Exception {
         boolean authorized = false;
-        ServiceSelector selector = null;
         AccessControllerResolver acResolver = null;
         AccessController accessController = null;
-        ContextUtility contextUtil = null;
-        try {
-            selector = (ServiceSelector) this.manager.lookup(AccessControllerResolver.ROLE
-                    + "Selector");
-            acResolver = (AccessControllerResolver) selector
-                    .select(AccessControllerResolver.DEFAULT_RESOLVER);
-            accessController = acResolver.resolveAccessController(webappUrl);
-
-            contextUtil = (ContextUtility) this.manager.lookup(ContextUtility.ROLE);
-            Request request = contextUtil.getRequest();
-            DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);
-            URLInformation info = new URLInformation(webappUrl);
-            Publication pub = factory.getPublication(info.getPublicationId());
-            Role[] roles = PolicyUtil.getRoles(request);
-
-            Authorizer[] authorizers = accessController.getAuthorizers();
-            for (int i = 0; i < authorizers.length; i++) {
-                if (authorizers[i] instanceof UsecaseAuthorizer) {
-                    UsecaseAuthorizer authorizer = (UsecaseAuthorizer) authorizers[i];
-                    authorized = authorizer.authorizeUsecase(usecaseName, roles, pub);
-                }
-            }
-        } finally {
-            if (selector != null) {
-                if (acResolver != null) {
-                    if (accessController != null) {
-                        acResolver.release(accessController);
-                    }
-                    selector.release(acResolver);
-                }
-                this.manager.release(selector);
-            }
-            if (contextUtil != null) {
-                this.manager.release(contextUtil);
+        WebApplicationContext context = WebAppContextUtils.getCurrentWebApplicationContext();
+        acResolver = (AccessControllerResolver) context.getBean(AccessControllerResolver.ROLE + "/"
+                + AccessControllerResolver.DEFAULT_RESOLVER);
+        accessController = acResolver.resolveAccessController(webappUrl);
+
+        ProcessInfoProvider process = (ProcessInfoProvider) context
+                .getBean(ProcessInfoProvider.ROLE);
+        HttpServletRequest request = process.getRequest();
+        Session session = RepositoryUtil.getSession(getRepositoryManager(), request);
+        DocumentFactory factory = DocumentUtil.createDocumentFactory(session);
+        URLInformation info = new URLInformation(webappUrl);
+        Publication pub = factory.getPublication(info.getPublicationId());
+        Role[] roles = PolicyUtil.getRoles(request);
+
+        Authorizer[] authorizers = accessController.getAuthorizers();
+        for (int i = 0; i < authorizers.length; i++) {
+            if (authorizers[i] instanceof UsecaseAuthorizer) {
+                UsecaseAuthorizer authorizer = (UsecaseAuthorizer) authorizers[i];
+                authorized = authorizer.authorizeUsecase(usecaseName, roles, pub);
             }
         }
         return authorized;
@@ -114,7 +101,6 @@
         this.errorMessages.clear();
         this.infoMessages.clear();
 
-        UsecaseResolver resolver = null;
         Usecase usecase = null;
         this.result = SUCCESS;
         try {
@@ -126,8 +112,7 @@
                 return;
             }
 
-            resolver = (UsecaseResolver) this.manager.lookup(UsecaseResolver.ROLE);
-            usecase = resolver.resolve(webappUrl, usecaseName);
+            usecase = getUsecaseResolver().resolve(webappUrl, usecaseName);
 
             Session testSession = getTestSession();
             if (testSession != null) {
@@ -158,17 +143,6 @@
 
         } catch (Exception e) {
             throw new RuntimeException(e);
-        } finally {
-            if (resolver != null) {
-                if (usecase != null) {
-                    try {
-                        resolver.release(usecase);
-                    } catch (ServiceException e) {
-                        throw new RuntimeException(e);
-                    }
-                }
-                this.manager.release(resolver);
-            }
         }
     }
 
@@ -231,15 +205,6 @@
         }
     }
 
-    private ServiceManager manager;
-
-    /**
-     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
-     */
-    public void service(ServiceManager manager) throws ServiceException {
-        this.manager = manager;
-    }
-
     private List errorMessages = new ArrayList();
     private List infoMessages = new ArrayList();
 
@@ -268,4 +233,20 @@
         this.testSession = session;
     }
 
+    public void setRepositoryManager(RepositoryManager repositoryManager) {
+        this.repositoryManager = repositoryManager;
+    }
+
+    public RepositoryManager getRepositoryManager() {
+        return repositoryManager;
+    }
+
+    public void setUsecaseResolver(UsecaseResolver usecaseResolver) {
+        this.usecaseResolver = usecaseResolver;
+    }
+
+    public UsecaseResolver getUsecaseResolver() {
+        return usecaseResolver;
+    }
+
 }

Modified: lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/impl/UsecaseResolverImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/impl/UsecaseResolverImpl.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/impl/UsecaseResolverImpl.java (original)
+++ lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/impl/UsecaseResolverImpl.java Fri Feb  6 17:55:28 2009
@@ -20,20 +20,20 @@
 import java.util.SortedSet;
 import java.util.TreeSet;
 
-import org.apache.avalon.framework.activity.Disposable;
+import javax.servlet.http.HttpServletRequest;
+
 import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.ServiceSelector;
-import org.apache.avalon.framework.service.Serviceable;
-import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.processing.ProcessInfoProvider;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 import org.apache.cocoon.util.AbstractLogEnabled;
-import org.apache.lenya.cms.cocoon.components.context.ContextUtility;
 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.URLInformation;
 import org.apache.lenya.cms.publication.templating.PublicationTemplateManager;
+import org.apache.lenya.cms.repository.RepositoryManager;
+import org.apache.lenya.cms.repository.RepositoryUtil;
+import org.apache.lenya.cms.repository.Session;
 import org.apache.lenya.cms.usecase.Usecase;
 import org.apache.lenya.cms.usecase.UsecaseResolver;
 
@@ -42,52 +42,15 @@
  * 
  * @version $Id$
  */
-public class UsecaseResolverImpl extends AbstractLogEnabled implements UsecaseResolver,
-        Serviceable, Disposable, ThreadSafe {
-
-    /**
-     * Ctor.
-     */
-    public UsecaseResolverImpl() {
-        // do nothing
-    }
-
-    private ServiceSelector selector;
-
-    private ServiceManager manager;
-
-    /**
-     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
-     */
-    public void service(ServiceManager _manager) throws ServiceException {
-        this.manager = _manager;
-    }
+public class UsecaseResolverImpl extends AbstractLogEnabled implements UsecaseResolver {
 
-    protected ServiceSelector getSelector() throws ServiceException {
-        if (this.selector == null) {
-            this.selector = (ServiceSelector) this.manager.lookup(Usecase.ROLE + "Selector");
-        }
-        return this.selector;
-    }
+    private PublicationTemplateManager templateManager;
+    private RepositoryManager repositoryManager;
 
     /**
      * @see org.apache.lenya.cms.usecase.UsecaseResolver#release(org.apache.lenya.cms.usecase.Usecase)
      */
     public void release(Usecase usecase) throws ServiceException {
-        if (usecase == null) {
-            throw new IllegalArgumentException("The usecase to release must not be null.");
-        }
-        getSelector().release(usecase);
-
-    }
-
-    /**
-     * @see org.apache.avalon.framework.activity.Disposable#dispose()
-     */
-    public void dispose() {
-        if (this.selector != null) {
-            this.manager.release(this.selector);
-        }
     }
 
     /**
@@ -102,17 +65,7 @@
 
         Publication publication = getPublication(webappUrl);
         if (publication != null) {
-            PublicationTemplateManager templateManager = null;
-            try {
-                templateManager = (PublicationTemplateManager) this.manager
-                        .lookup(PublicationTemplateManager.ROLE);
-                newName = (String) templateManager.getSelectableHint(publication, getSelector(),
-                        name);
-            } finally {
-                if (templateManager != null) {
-                    this.manager.release(templateManager);
-                }
-            }
+            newName = (String) this.templateManager.getSelectableHint(publication, Usecase.ROLE, name);
         } else {
             newName = name;
         }
@@ -126,13 +79,14 @@
      * @return A publication.
      */
     protected Publication getPublication(String webappUrl) {
+        ProcessInfoProvider process = (ProcessInfoProvider) WebAppContextUtils
+                .getCurrentWebApplicationContext().getBean(ProcessInfoProvider.ROLE);
+        HttpServletRequest request = process.getRequest();
         Publication publication = null;
-        ContextUtility util = null;
         try {
-            util = (ContextUtility) this.manager.lookup(ContextUtility.ROLE);
-            Request request = util.getRequest();
-            DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);
 
+            Session session = RepositoryUtil.getSession(getRepositoryManager(), request);
+            DocumentFactory factory = DocumentUtil.createDocumentFactory(session);
             URLInformation info = new URLInformation(webappUrl);
             String pubId = info.getPublicationId();
 
@@ -141,21 +95,17 @@
             }
         } catch (Exception e) {
             throw new RuntimeException(e);
-        } finally {
-            if (util != null) {
-                this.manager.release(util);
-            }
         }
         return publication;
     }
 
     /**
-     * @see org.apache.lenya.cms.usecase.UsecaseResolver#resolve(java.lang.String,
-     *      java.lang.String)
+     * @see org.apache.lenya.cms.usecase.UsecaseResolver#resolve(java.lang.String, java.lang.String)
      */
     public Usecase resolve(String webappUrl, String name) throws ServiceException {
         Object usecaseName = getUsecaseName(webappUrl, name);
-        Usecase usecase = (Usecase) getSelector().select(usecaseName);
+        Usecase usecase = (Usecase) WebAppContextUtils.getCurrentWebApplicationContext().getBean(
+                Usecase.ROLE + "/" + usecaseName);
         usecase.setName(name);
         usecase.setSourceURL(webappUrl);
         return usecase;
@@ -167,7 +117,8 @@
      */
     public boolean isRegistered(String webappUrl, String name) throws ServiceException {
         String usecaseName = getUsecaseName(webappUrl, name);
-        return getSelector().isSelectable(usecaseName);
+        return WebAppContextUtils.getCurrentWebApplicationContext().containsBean(
+                Usecase.ROLE + "/" + usecaseName);
     }
 
     /**
@@ -181,7 +132,7 @@
     }
 
     private SortedSet usecaseNames;
-    
+
     public void register(String usecaseName) {
         if (this.usecaseNames == null) {
             this.usecaseNames = new TreeSet();
@@ -189,4 +140,20 @@
         this.usecaseNames.add(usecaseName);
     }
 
+    public void setTemplateManager(PublicationTemplateManager templateManager) {
+        this.templateManager = templateManager;
+    }
+
+    public PublicationTemplateManager getTemplateManager() {
+        return templateManager;
+    }
+
+    public void setRepositoryManager(RepositoryManager repositoryManager) {
+        this.repositoryManager = repositoryManager;
+    }
+
+    public RepositoryManager getRepositoryManager() {
+        return repositoryManager;
+    }
+
 }
\ No newline at end of file

Modified: lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/scheduling/ManageJobs.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/scheduling/ManageJobs.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/scheduling/ManageJobs.java (original)
+++ lenya/trunk/org.apache.lenya.core.usecase/src/main/java/org/apache/lenya/cms/usecase/scheduling/ManageJobs.java Fri Feb  6 17:55:28 2009
@@ -19,7 +19,6 @@
 
 import java.util.Arrays;
 
-import org.apache.avalon.framework.service.ServiceException;
 import org.apache.cocoon.components.cron.JobSchedulerEntry;
 import org.apache.lenya.cms.usecase.DocumentUsecase;
 
@@ -32,23 +31,26 @@
 
     protected static final String JOBS = "jobs";
 
+    private UsecaseScheduler usecaseScheduler;
+
     /**
      * @see org.apache.lenya.cms.usecase.AbstractUsecase#initParameters()
      */
     protected void initParameters() {
         super.initParameters();
+        JobSchedulerEntry[] jobs = getUsecaseScheduler().getJobs();
+        setParameter(JOBS, Arrays.asList(jobs));
+    }
 
-        UsecaseScheduler scheduler = null;
-        try {
-            scheduler = (UsecaseScheduler) this.manager.lookup(UsecaseScheduler.ROLE);
-            JobSchedulerEntry[] jobs = scheduler.getJobs();
-            setParameter(JOBS, Arrays.asList(jobs));
-        } catch (ServiceException e) {
-            throw new RuntimeException(e);
-        } finally {
-            if (scheduler != null) {
-                this.manager.release(scheduler);
-            }
-        }
+    protected UsecaseScheduler getUsecaseScheduler() {
+        return usecaseScheduler;
     }
+
+    /**
+     * TODO: Bean wiring
+     */
+    public void setUsecaseScheduler(UsecaseScheduler usecaseScheduler) {
+        this.usecaseScheduler = usecaseScheduler;
+    }
+
 }
\ No newline at end of file

Modified: lenya/trunk/org.apache.lenya.core.workflow/src/main/java/org/apache/lenya/cms/cocoon/acting/WorkflowInvokerAction.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.workflow/src/main/java/org/apache/lenya/cms/cocoon/acting/WorkflowInvokerAction.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.workflow/src/main/java/org/apache/lenya/cms/cocoon/acting/WorkflowInvokerAction.java (original)
+++ lenya/trunk/org.apache.lenya.core.workflow/src/main/java/org/apache/lenya/cms/cocoon/acting/WorkflowInvokerAction.java Fri Feb  6 17:55:28 2009
@@ -29,15 +29,16 @@
 import org.apache.cocoon.environment.Redirector;
 import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.environment.SourceResolver;
-import org.apache.lenya.ac.AccessControlException;
 import org.apache.lenya.cms.publication.Document;
 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.PublicationUtil;
+import org.apache.lenya.cms.publication.URLInformation;
+import org.apache.lenya.cms.repository.RepositoryManager;
 import org.apache.lenya.cms.repository.RepositoryUtil;
 import org.apache.lenya.cms.repository.Session;
 import org.apache.lenya.cms.workflow.WorkflowUtil;
+import org.apache.lenya.util.ServletHelper;
 
 /**
  * Action to invoke a workflow transition independently from the request document URL. Parameters:
@@ -66,6 +67,8 @@
      * <code>EVENT</code> The event
      */
     public static final String EVENT = "event";
+    
+    private RepositoryManager repositoryManager;
 
     /**
      * @see org.apache.cocoon.acting.Action#act(org.apache.cocoon.environment.Redirector,
@@ -88,24 +91,27 @@
             getLogger().debug("    Event:       [" + eventName + "]");
         }
 
-        Publication pub;
         Request request = ObjectModelHelper.getRequest(objectModel);
-
-        try {
-            pub = PublicationUtil.getPublication(this.manager, request);
-        } catch (Exception e) {
-            throw new AccessControlException(e);
-        }
-        Session session = RepositoryUtil.getSession(this.manager, request);
-        DocumentFactory map = DocumentUtil.createDocumentFactory(this.manager, session);
-        Document document = map.get(pub, area, documentId, language);
+        Session session = RepositoryUtil.getSession(getRepositoryManager(), request);
+        DocumentFactory factory = DocumentUtil.createDocumentFactory(session);
+        String pubId = new URLInformation(ServletHelper.getWebappURI(request)).getPublicationId();
+        Publication pub = factory.getPublication(pubId);
+        Document document = pub.getArea(area).getDocument(documentId, language);
 
         if (getLogger().isDebugEnabled()) {
             getLogger().debug("    Invoking workflow event");
         }
-        WorkflowUtil.invoke(this.manager, getLogger(), document, eventName);
+        WorkflowUtil.invoke(getLogger(), document, eventName);
 
         return Collections.EMPTY_MAP;
     }
 
+    public void setRepositoryManager(RepositoryManager repositoryManager) {
+        this.repositoryManager = repositoryManager;
+    }
+
+    public RepositoryManager getRepositoryManager() {
+        return repositoryManager;
+    }
+
 }

Modified: lenya/trunk/org.apache.lenya.core.workflow/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/WorkflowModule.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.workflow/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/WorkflowModule.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.workflow/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/WorkflowModule.java (original)
+++ lenya/trunk/org.apache.lenya.core.workflow/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/WorkflowModule.java Fri Feb  6 17:55:28 2009
@@ -26,15 +26,11 @@
 
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.PageEnvelope;
-import org.apache.lenya.cms.repository.RepositoryUtil;
-import org.apache.lenya.cms.repository.Session;
 import org.apache.lenya.cms.workflow.WorkflowUtil;
 import org.apache.lenya.workflow.Version;
 import org.apache.lenya.workflow.Workflow;
-import org.apache.lenya.workflow.WorkflowManager;
 import org.apache.lenya.workflow.Workflowable;
 
 /**
@@ -76,32 +72,27 @@
             throws ConfigurationException {
 
         Object value = null;
-        WorkflowManager wfManager = null;
 
         try {
             PageEnvelope envelope = getEnvelope(objectModel, name);
             Document document = envelope.getDocument();
             if (document != null && document.exists()) {
-                wfManager = (WorkflowManager) this.manager.lookup(WorkflowManager.ROLE);
-                Session session = RepositoryUtil.getSession(this.manager,
-                        ObjectModelHelper.getRequest(objectModel));
-                Workflowable workflowable = WorkflowUtil.getWorkflowable(this.manager,
-                        getLogger(),
-                        document);
-                if (wfManager.hasWorkflow(workflowable)) {
+                Workflowable workflowable = WorkflowUtil.getWorkflowable(getLogger(), document);
+                if (WorkflowUtil.hasWorkflow(getLogger(), document)) {
 
                     Version latestVersion = workflowable.getLatestVersion();
 
                     if (name.equals(STATE)) {
                         if (latestVersion == null) {
-                            Workflow workflow = wfManager.getWorkflowSchema(workflowable);
+                            Workflow workflow = WorkflowUtil.getWorkflowSchema(getLogger(),
+                                    document);
                             value = workflow.getInitialState();
                         } else {
                             value = latestVersion.getState();
                         }
                     } else if (name.startsWith(VARIABLE_PREFIX)) {
                         String variableName = name.substring(VARIABLE_PREFIX.length());
-                        Workflow workflow = wfManager.getWorkflowSchema(workflowable);
+                        Workflow workflow = WorkflowUtil.getWorkflowSchema(getLogger(), document);
                         String[] variableNames = workflow.getVariableNames();
                         if (Arrays.asList(variableNames).contains(variableName)) {
                             if (latestVersion == null) {
@@ -120,7 +111,7 @@
                         String event = name.substring(LAST_DATE_PREFIX.length());
                         Version latestEventVersion = getLatestVersion(workflowable, event);
                         if (latestEventVersion != null) {
-                            synchronized(lock) {
+                            synchronized (lock) {
                                 value = this.DATE_FORMAT.format(latestEventVersion.getDate());
                             }
                         }
@@ -134,10 +125,6 @@
             throw e;
         } catch (Exception e) {
             throw new ConfigurationException("Resolving attribute failed: ", e);
-        } finally {
-            if (wfManager != null) {
-                this.manager.release(wfManager);
-            }
         }
         return value;
     }

Modified: lenya/trunk/org.apache.lenya.core.workflow/src/main/java/org/apache/lenya/cms/cocoon/transformation/WorkflowMenuTransformer.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.workflow/src/main/java/org/apache/lenya/cms/cocoon/transformation/WorkflowMenuTransformer.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.workflow/src/main/java/org/apache/lenya/cms/cocoon/transformation/WorkflowMenuTransformer.java (original)
+++ lenya/trunk/org.apache.lenya.core.workflow/src/main/java/org/apache/lenya/cms/cocoon/transformation/WorkflowMenuTransformer.java Fri Feb  6 17:55:28 2009
@@ -35,13 +35,12 @@
 import org.apache.lenya.cms.publication.DocumentFactory;
 import org.apache.lenya.cms.publication.DocumentUtil;
 import org.apache.lenya.cms.publication.ResourceType;
+import org.apache.lenya.cms.repository.RepositoryManager;
 import org.apache.lenya.cms.repository.RepositoryUtil;
 import org.apache.lenya.cms.repository.Session;
 import org.apache.lenya.cms.workflow.WorkflowUtil;
 import org.apache.lenya.util.ServletHelper;
 import org.apache.lenya.workflow.Workflow;
-import org.apache.lenya.workflow.WorkflowManager;
-import org.apache.lenya.workflow.Workflowable;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.AttributesImpl;
@@ -63,6 +62,8 @@
      * <code>EVENT_ATTRIBUTE</code> The event attribute
      */
     public static final String EVENT_ATTRIBUTE = "event";
+    
+    private RepositoryManager repositoryManager;
 
     /**
      * (non-Javadoc)
@@ -122,12 +123,10 @@
 
         super.setup(_resolver, _objectModel, src, _parameters);
 
-        WorkflowManager workflowManager = null;
-
         try {
             Request request = ObjectModelHelper.getRequest(_objectModel);
-            Session session = RepositoryUtil.getSession(this.manager, request);
-            DocumentFactory map = DocumentUtil.createDocumentFactory(this.manager, session);
+            Session session = RepositoryUtil.getSession(getRepositoryManager(), request);
+            DocumentFactory map = DocumentUtil.createDocumentFactory(session);
 
             String webappUrl = ServletHelper.getWebappURI(request);
             Document document = null;
@@ -136,7 +135,6 @@
                 ResourceType doctype = document.getResourceType();
                 if (document.getPublication().getWorkflowSchema(doctype) != null) {
                     setHasWorkflow(true);
-                    workflowManager = (WorkflowManager) this.manager.lookup(WorkflowManager.ROLE);
                 } else {
                     setHasWorkflow(false);
                 }
@@ -145,13 +143,10 @@
             }
 
             if (hasWorkflow()) {
-                Workflowable workflowable = WorkflowUtil.getWorkflowable(this.manager,
-                        getLogger(),
-                        document);
-                Workflow workflow = workflowManager.getWorkflowSchema(workflowable);
+                Workflow workflow = WorkflowUtil.getWorkflowSchema(getLogger(), document);
                 String[] events = workflow.getEvents();
                 for (int i = 0; i < events.length; i++) {
-                    if (workflowManager.canInvoke(workflowable, events[i])) {
+                    if (WorkflowUtil.canInvoke(getLogger(), document, events[i])) {
                         this.executableEvents.add(events[i]);
                     }
                 }
@@ -159,10 +154,6 @@
             }
         } catch (final Exception e) {
             throw new ProcessingException(e);
-        } finally {
-            if (workflowManager != null) {
-                this.manager.release(workflowManager);
-            }
         }
 
     }
@@ -187,4 +178,12 @@
         this.hasWorkflow = _hasWorkflow;
     }
 
+    public void setRepositoryManager(RepositoryManager repositoryManager) {
+        this.repositoryManager = repositoryManager;
+    }
+
+    public RepositoryManager getRepositoryManager() {
+        return repositoryManager;
+    }
+
 }
\ No newline at end of file

Modified: lenya/trunk/org.apache.lenya.core.workflow/src/main/java/org/apache/lenya/cms/workflow/usecases/CheckWorkflow.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.workflow/src/main/java/org/apache/lenya/cms/workflow/usecases/CheckWorkflow.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.workflow/src/main/java/org/apache/lenya/cms/workflow/usecases/CheckWorkflow.java (original)
+++ lenya/trunk/org.apache.lenya.core.workflow/src/main/java/org/apache/lenya/cms/workflow/usecases/CheckWorkflow.java Fri Feb  6 17:55:28 2009
@@ -17,9 +17,6 @@
  */
 package org.apache.lenya.cms.workflow.usecases;
 
-import org.apache.avalon.framework.configuration.Configurable;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.usecase.DocumentUsecase;
 import org.apache.lenya.cms.workflow.WorkflowUtil;
@@ -38,7 +35,7 @@
  * 
  * @version $Id: InvokeWorkflow.java 426254 2006-07-27 21:27:04Z andreas $
  */
-public class CheckWorkflow extends DocumentUsecase implements Configurable {
+public class CheckWorkflow extends DocumentUsecase {
 
     private String event;
 
@@ -60,7 +57,7 @@
         }
 
         Document doc = getSourceDocument();
-        if (!WorkflowUtil.canInvoke(this.manager, getLogger(), doc, getEvent())) {
+        if (!WorkflowUtil.canInvoke(getLogger(), doc, getEvent())) {
             UsecaseWorkflowHelper.addWorkflowError(this, getEvent(), doc);
         }
     }
@@ -68,12 +65,8 @@
     protected static final String ELEMENT_EVENT = "event";
     protected static final String ATTRIBUTE_ID = "id";
 
-    /**
-     * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
-     */
-    public void configure(Configuration config) throws ConfigurationException {
-        super.configure(config);
-        this.event = config.getChild(ELEMENT_EVENT).getAttribute(ATTRIBUTE_ID);
+    public void setEvent(String event) {
+        this.event = event;
     }
 
 }



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