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 2005/03/13 00:11:11 UTC

svn commit: r157295 [3/3] - in lenya/trunk/src/java/org/apache/lenya/cms: ac/ ac/cocoon/ ac/workflow/ ant/ cocoon/acting/ cocoon/components/modules/input/ cocoon/flow/ cocoon/generation/ cocoon/scheduler/ cocoon/source/ cocoon/transformation/ metadata/dublincore/ publication/ publication/task/ publication/util/ scheduler/ site/ site/topicmap/ site/tree/ site/usecases/ task/ usecase/

Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/tree/TreeSiteManager.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/TreeSiteManager.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/tree/TreeSiteManager.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/tree/TreeSiteManager.java Sat Mar 12 15:10:56 2005
@@ -24,6 +24,7 @@
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.DocumentBuildException;
 import org.apache.lenya.cms.publication.DocumentIdentityMap;
+import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.PublicationException;
 import org.apache.lenya.cms.site.AbstractSiteManager;
 import org.apache.lenya.cms.site.Label;
@@ -47,20 +48,26 @@
      * Returns the sitetree for a specific area of this publication. Sitetrees
      * are created on demand and are cached.
      * @param map The document identity map.
+     * @param publication The publication.
      * @param area The area.
      * @return A site tree.
      * @throws SiteException if an error occurs.
      */
-    public SiteTree getTree(DocumentIdentityMap map, String area) throws SiteException {
-        DefaultSiteTree sitetree = (DefaultSiteTree) map.getSiteStructure(map.getPublication(), area);
+    public SiteTree getTree(DocumentIdentityMap map, Publication publication, String area)
+            throws SiteException {
+        DefaultSiteTree sitetree = (DefaultSiteTree) map.getSiteStructure(publication, area);
         if (sitetree == null) {
-            sitetree = new DefaultSiteTree(map.getPublication().getDirectory(), area);
+            sitetree = new DefaultSiteTree(publication.getDirectory(), area);
             ContainerUtil.enableLogging(sitetree, getLogger());
-            map.putSiteStructure(map.getPublication(), area, sitetree);
+            map.putSiteStructure(publication, area, sitetree);
         }
         return sitetree;
     }
 
+    protected SiteTree getTree(Document document) throws SiteException {
+        return getTree(document.getIdentityMap(), document.getPublication(), document.getArea());
+    }
+
     /**
      * Returns the ancestors of a resource, beginning with the parent.
      * @param resource The resource.
@@ -108,7 +115,7 @@
             getLogger().debug("Obtaining requiring resources of [" + resource + "]");
         }
 
-        SiteTree tree = getTree(resource.getIdentityMap(), resource.getArea());
+        SiteTree tree = getTree(resource);
 
         SiteTreeNode node = tree.getNode(resource.getId());
         List preOrder = node.preOrder();
@@ -121,8 +128,10 @@
         try {
             for (int i = 0; i < resources.length; i++) {
                 SiteTreeNode descendant = (SiteTreeNode) preOrder.get(i);
-                resources[i] = resource.getIdentityMap().getFactory().get(resource.getArea(),
-                        descendant.getAbsoluteId());
+                resources[i] = resource.getIdentityMap().getFactory()
+                        .get(resource.getPublication(),
+                                resource.getArea(),
+                                descendant.getAbsoluteId());
                 if (getLogger().isDebugEnabled()) {
                     getLogger().debug("    Descendant: [" + resources[i] + "]");
                 }
@@ -142,7 +151,7 @@
      * @see org.apache.lenya.cms.site.SiteManager#contains(org.apache.lenya.cms.publication.Document)
      */
     public boolean contains(Document resource) throws SiteException {
-        SiteTree tree = getTree(resource.getIdentityMap(), resource.getArea());
+        SiteTree tree = getTree(resource);
         SiteTreeNode node = tree.getNode(resource.getId());
         return node != null && node.getLabel(resource.getLanguage()) != null;
     }
@@ -151,7 +160,7 @@
      * @see org.apache.lenya.cms.site.SiteManager#containsInAnyLanguage(org.apache.lenya.cms.publication.Document)
      */
     public boolean containsInAnyLanguage(Document resource) throws SiteException {
-        SiteTree tree = getTree(resource.getIdentityMap(), resource.getArea());
+        SiteTree tree = getTree(resource);
         SiteTreeNode node = tree.getNode(resource.getId());
         return node != null;
     }
@@ -161,9 +170,8 @@
      *      org.apache.lenya.cms.publication.Document)
      */
     public void copy(Document sourceDocument, Document destinationDocument) throws SiteException {
-        SiteTree sourceTree = getTree(sourceDocument.getIdentityMap(), sourceDocument.getArea());
-        SiteTree destinationTree = getTree(destinationDocument.getIdentityMap(),
-                destinationDocument.getArea());
+        SiteTree sourceTree = getTree(sourceDocument);
+        SiteTree destinationTree = getTree(destinationDocument);
 
         SiteTreeNode sourceNode = sourceTree.getNode(sourceDocument.getId());
         if (sourceNode == null) {
@@ -232,7 +240,8 @@
      * @see org.apache.lenya.cms.site.SiteManager#delete(org.apache.lenya.cms.publication.Document)
      */
     public void delete(Document document) throws SiteException {
-        SiteTree tree = getTree(document.getIdentityMap(), document.getArea());
+        SiteTree tree = getTree(document.getIdentityMap(), document.getPublication(), document
+                .getArea());
 
         SiteTreeNode node = tree.getNode(document.getId());
 
@@ -277,7 +286,7 @@
         Label labelObject = getLabelObject(document);
         labelObject.setLabel(label);
 
-        SiteTree tree = getTree(document.getIdentityMap(), document.getArea());
+        SiteTree tree = getTree(document);
         tree.setLabel(document.getId(), labelObject);
         tree.save();
     }
@@ -290,7 +299,7 @@
      */
     protected Label getLabelObject(Document document) throws SiteException {
         Label label = null;
-        SiteTree siteTree = getTree(document.getIdentityMap(), document.getArea());
+        SiteTree siteTree = getTree(document);
         if (siteTree != null) {
             SiteTreeNode node = siteTree.getNode(document.getId());
             if (node == null) {
@@ -308,16 +317,17 @@
 
     /**
      * @see org.apache.lenya.cms.site.SiteManager#getDocuments(org.apache.lenya.cms.publication.DocumentIdentityMap,
-     *      java.lang.String)
+     *      org.apache.lenya.cms.publication.Publication, java.lang.String)
      */
-    public Document[] getDocuments(DocumentIdentityMap map, String area) throws SiteException {
+    public Document[] getDocuments(DocumentIdentityMap map, Publication publication, String area)
+            throws SiteException {
         try {
-            List allNodes = getTree(map, area).getNode("/").preOrder();
+            List allNodes = getTree(map, publication, area).getNode("/").preOrder();
             Document[] documents = new Document[allNodes.size() - 1];
 
             for (int i = 1; i < allNodes.size(); i++) {
                 SiteTreeNode node = (SiteTreeNode) allNodes.get(i);
-                documents[i - 1] = map.getFactory().get(area, node.getAbsoluteId());
+                documents[i - 1] = map.getFactory().get(publication, area, node.getAbsoluteId());
             }
             return documents;
         } catch (DocumentBuildException e) {
@@ -333,7 +343,7 @@
         if (contains(document)) {
             throw new SiteException("The document [" + document + "] is already contained!");
         }
-        SiteTree tree = getTree(document.getIdentityMap(), document.getArea());
+        SiteTree tree = getTree(document);
         Label label = new Label("", document.getLanguage());
 
         SiteTreeNode node = tree.getNode(document.getId());

Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/ChangeNodeID.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/ChangeNodeID.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/ChangeNodeID.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/ChangeNodeID.java Sat Mar 12 15:10:56 2005
@@ -125,11 +125,13 @@
         String[] availableLanguages = document.getLanguages();
 
         for (int i = 0; i < availableLanguages.length; i++) {
-            Document languageVersion = identityMap.getFactory().get(document.getArea(),
+            Document languageVersion = identityMap.getFactory().get(document.getPublication(),
+                    document.getArea(),
                     document.getId(),
                     availableLanguages[i]);
 
-            Document newLanguageVersion = identityMap.getFactory().get(document.getArea(),
+            Document newLanguageVersion = identityMap.getFactory().get(document.getPublication(),
+                    document.getArea(),
                     newDocumentId,
                     availableLanguages[i]);
 

Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Clipboard.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Clipboard.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Clipboard.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Clipboard.java Sat Mar 12 15:10:56 2005
@@ -16,24 +16,29 @@
  */
 package org.apache.lenya.cms.site.usecases;
 
+import org.apache.avalon.framework.logger.ConsoleLogger;
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.DocumentBuildException;
 import org.apache.lenya.cms.publication.DocumentIdentityMap;
+import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.publication.PublicationException;
+import org.apache.lenya.cms.publication.PublicationFactory;
 
 /**
- * Clipboard for cut/copy/paste of documents.
- * The clipping method is either {@link #METHOD_CUT} or {@link #METHOD_COPY}.
+ * Clipboard for cut/copy/paste of documents. The clipping method is either
+ * {@link #METHOD_CUT}or {@link #METHOD_COPY}.
  * 
  * @version $Id:$
  */
 public class Clipboard {
 
     private String publicationId;
+    private String servletContextPath;
     private String area;
     private String documentId;
     private String language;
     private int method;
-    
+
     protected static final int METHOD_CUT = 0;
     protected static final int METHOD_COPY = 1;
 
@@ -44,6 +49,7 @@
      */
     public Clipboard(Document document, int method) {
         this.publicationId = document.getPublication().getId();
+        this.servletContextPath = document.getPublication().getServletContext().getAbsolutePath();
         this.area = document.getArea();
         this.documentId = document.getId();
         this.language = document.getLanguage();
@@ -57,11 +63,19 @@
      * @throws DocumentBuildException if the document could not be built.
      */
     public Document getDocument(DocumentIdentityMap identityMap) throws DocumentBuildException {
-        if (!identityMap.getPublication().getId().equals(this.publicationId)) {
-            throw new RuntimeException("A document cannot be pasted in another publication!");
-        }
 
-        Document document = identityMap.getFactory().get(this.area, this.documentId, this.language);
+        PublicationFactory factory = PublicationFactory.getInstance(new ConsoleLogger());
+        Publication publication;
+        try {
+            publication = factory.getPublication(this.publicationId,
+                    this.servletContextPath);
+        } catch (PublicationException e) {
+            throw new RuntimeException(e);
+        }
+        Document document = identityMap.getFactory().get(publication,
+                this.area,
+                this.documentId,
+                this.language);
         return document;
     }
 

Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java Sat Mar 12 15:10:56 2005
@@ -31,6 +31,8 @@
 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.PublicationFactory;
 import org.apache.lenya.cms.publication.URLInformation;
 import org.apache.lenya.cms.site.SiteManager;
 import org.apache.lenya.cms.usecase.AbstractUsecase;
@@ -58,7 +60,7 @@
      */
     protected void doCheckPreconditions() throws Exception {
         super.doCheckPreconditions();
-        
+
         if (!getArea().equals(Publication.AUTHORING_AREA)) {
             addErrorMessage("This usecase can only be invoked in the authoring area!");
         }
@@ -139,8 +141,7 @@
         User user = identity.getUser();
         if (user != null) {
             setParameter(DublinCore.ELEMENT_CREATOR, user.getId());
-        }
-        else {
+        } else {
             setParameter(DublinCore.ELEMENT_CREATOR, "");
         }
 
@@ -148,7 +149,7 @@
         setParameter(DublinCore.ELEMENT_DATE, format.format(new GregorianCalendar().getTime()));
 
     }
-    
+
     /**
      * @return The source document or <code>null</code> if the usecase was not
      *         invoked on a document.
@@ -158,8 +159,8 @@
         String url = getSourceURL();
         DocumentFactory factory = getUnitOfWork().getIdentityMap().getFactory();
         try {
-            if (factory.isDocument(url)) {
-                document = factory.getFromURL(url);
+            if (factory.isDocument(getPublication(), url)) {
+                document = factory.getFromURL(getPublication(), url);
             }
         } catch (Exception e) {
             throw new RuntimeException(e);
@@ -173,5 +174,19 @@
     public String getArea() {
         URLInformation info = new URLInformation(getSourceURL());
         return info.getArea();
+    }
+
+    private Publication publication;
+
+    protected Publication getPublication() {
+        if (this.publication == null) {
+            PublicationFactory factory = PublicationFactory.getInstance(getLogger());
+            try {
+                this.publication = factory.getPublication(this.manager, getSourceURL());
+            } catch (PublicationException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        return this.publication;
     }
 }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateDocument.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateDocument.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateDocument.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateDocument.java Sat Mar 12 15:10:56 2005
@@ -49,7 +49,7 @@
             setParameter(PARENT_ID, "");
         }
 
-        String[] languages = getUnitOfWork().getIdentityMap().getPublication().getLanguages();
+        String[] languages = getPublication().getLanguages();
         setParameter(LANGUAGES, languages);
     }
 
@@ -92,7 +92,10 @@
 
         Publication publication = parent.getPublication();
         String area = parent.getArea();
-        Document document = parent.getIdentityMap().getFactory().get(area, documentId, language);
+        Document document = parent.getIdentityMap().getFactory().get(getPublication(),
+                area,
+                documentId,
+                language);
 
         DocumentType documentType = DocumentTypeBuilder.buildDocumentType(documentTypeName,
                 publication);

Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateLanguage.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateLanguage.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateLanguage.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateLanguage.java Sat Mar 12 15:10:56 2005
@@ -46,7 +46,7 @@
      */
     protected void doCheckPreconditions() throws Exception {
         super.doCheckPreconditions();
-        
+
         if (getSourceDocument() == null) {
             addErrorMessage("This operation must be invoked on a document.");
             return;
@@ -74,7 +74,8 @@
         String[] languages = source.getPublication().getLanguages();
         DocumentFactory factory = source.getIdentityMap().getFactory();
         for (int i = 0; i < languages.length; i++) {
-            Document version = factory.get(source.getArea(), source.getId(), languages[i]);
+            Document version = factory.get(source.getPublication(), source.getArea(), source
+                    .getId(), languages[i]);
             if (!version.exists()) {
                 nonExistingLanguages.add(languages[i]);
             }
@@ -98,8 +99,8 @@
                 this.documentTypeName = type.getName();
 
                 List nonExistingLanguages = getNonExistingLanguages();
-                setParameter(LANGUAGES, nonExistingLanguages.toArray(new String[nonExistingLanguages
-                        .size()]));
+                setParameter(LANGUAGES, nonExistingLanguages
+                        .toArray(new String[nonExistingLanguages.size()]));
 
             } catch (Exception e) {
                 throw new RuntimeException(e);
@@ -130,7 +131,7 @@
         Publication publication = source.getPublication();
         String area = source.getArea();
         DocumentFactory factory = source.getIdentityMap().getFactory();
-        Document document = factory.get(area, source.getId(), language);
+        Document document = factory.get(publication, area, source.getId(), language);
 
         DocumentType documentType = DocumentTypeBuilder.buildDocumentType(documentTypeName,
                 publication);
@@ -140,7 +141,7 @@
         if (parent != null) {
             parentId = factory.getParent(document).getId().substring(1);
         }
-        
+
         String childId = document.getName();
 
         File doctypesDirectory = new File(publication.getDirectory(),

Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Delete.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Delete.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Delete.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Delete.java Sat Mar 12 15:10:56 2005
@@ -74,7 +74,9 @@
         String availableId = helper.computeUniqueDocumentId(source.getPublication(),
                 Publication.TRASH_AREA,
                 desiredId);
-        Document target = identityMap.getFactory().get(Publication.TRASH_AREA, availableId);
+        Document target = identityMap.getFactory().get(source.getPublication(),
+                Publication.TRASH_AREA,
+                availableId);
         getDocumentManager().moveAll(source, target);
 
         setTargetDocument(target);

Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/LinkRewriterImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/LinkRewriterImpl.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/LinkRewriterImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/LinkRewriterImpl.java Sat Mar 12 15:10:56 2005
@@ -74,10 +74,10 @@
         DocumentIdentityMap identityMap = originalTargetDocument.getIdentityMap();
 
         SiteManager siteManager;
-        Document[] documents; 
+        Document[] documents;
         try {
             siteManager = publication.getSiteManager();
-            documents = siteManager.getDocuments(identityMap, area);
+            documents = siteManager.getDocuments(identityMap, publication, area);
         } catch (SiteException e) {
             throw new RuntimeException(e);
         }
@@ -131,8 +131,9 @@
                                 if (url.startsWith(contextPath + "/" + publication.getId())) {
                                     final String webappUrl = url.substring(contextPath.length());
 
-                                    if (docFactory.isDocument(webappUrl)) {
-                                        Document targetDocument = docFactory.getFromURL(webappUrl);
+                                    if (docFactory.isDocument(publication, webappUrl)) {
+                                        Document targetDocument = docFactory
+                                                .getFromURL(publication, webappUrl);
 
                                         if (matches(targetDocument, originalTargetDocument)) {
                                             String newTargetUrl = getNewTargetURL(targetDocument,

Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Nudge.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Nudge.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Nudge.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Nudge.java Sat Mar 12 15:10:56 2005
@@ -16,7 +16,6 @@
  */
 package org.apache.lenya.cms.site.usecases;
 
-import org.apache.lenya.cms.publication.DocumentIdentityMap;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.site.SiteManager;
 import org.apache.lenya.cms.site.tree.SiteTree;
@@ -52,13 +51,13 @@
             return;
         }
 
-        DocumentIdentityMap identityMap = getUnitOfWork().getIdentityMap();
-        Publication publication = identityMap.getPublication();
+        Publication publication = getSourceDocument().getPublication();
         SiteManager manager = publication.getSiteManager();
         if (manager instanceof TreeSiteManager) {
 
             TreeSiteManager treeManager = (TreeSiteManager) manager;
             SiteTree tree = treeManager.getTree(getSourceDocument().getIdentityMap(),
+                    publication,
                     getSourceDocument().getArea());
             SiteTreeNode node = tree.getNode(getSourceDocument().getId());
             SiteTreeNode[] siblings = null;
@@ -86,13 +85,13 @@
     protected void doExecute() throws Exception {
         super.doExecute();
 
-        DocumentIdentityMap identityMap = getUnitOfWork().getIdentityMap();
-        Publication publication = identityMap.getPublication();
+        Publication publication = getSourceDocument().getPublication();
         SiteManager manager = publication.getSiteManager();
         if (manager instanceof TreeSiteManager) {
 
             TreeSiteManager treeManager = (TreeSiteManager) manager;
             SiteTree tree = treeManager.getTree(getSourceDocument().getIdentityMap(),
+                    publication,
                     getSourceDocument().getArea());
 
             String direction = getParameterAsString(DIRECTION);

Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Paste.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Paste.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Paste.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Paste.java Sat Mar 12 15:10:56 2005
@@ -27,7 +27,7 @@
  * @version $Id:$
  */
 public class Paste extends DocumentUsecase {
-    
+
     protected static final String CLIPBOARD_DOCUMENT_ID = "clipboardDocumentId";
 
     /**
@@ -35,20 +35,20 @@
      */
     protected void doCheckPreconditions() throws Exception {
         super.doCheckPreconditions();
-        
+
         if (!getErrorMessages().isEmpty()) {
             return;
         }
-        
+
         Clipboard clipboard = new ClipboardHelper().getClipboard(getContext());
         if (clipboard == null) {
             addErrorMessage("Cannot paste - the clipboard is empty.");
         }
     }
-    
+
     protected void initParameters() {
         super.initParameters();
-        
+
         Clipboard clipboard = new ClipboardHelper().getClipboard(getContext());
         if (clipboard != null) {
             String id;
@@ -60,34 +60,36 @@
             setParameter(CLIPBOARD_DOCUMENT_ID, id);
         }
     }
-    
+
     /**
      * @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
      */
     protected void doExecute() throws Exception {
         super.doExecute();
-        
+
         DocumentIdentityMap identityMap = getUnitOfWork().getIdentityMap();
         String targetArea = getSourceDocument().getArea();
-        
+
         Clipboard clipboard = new ClipboardHelper().getClipboard(getContext());
         Document clippedDocument = clipboard.getDocument(identityMap);
-        
+
         String language = clippedDocument.getLanguage();
         String nodeId = clippedDocument.getName();
         String potentialDocumentId = getSourceDocument().getId() + "/" + nodeId;
-        
-        Document potentialDocument = identityMap.getFactory().get(targetArea, potentialDocumentId, language);
+
+        Document potentialDocument = identityMap.getFactory().get(getSourceDocument()
+                .getPublication(),
+                targetArea,
+                potentialDocumentId,
+                language);
         Document availableDocument = getDocumentManager().getAvailableDocument(potentialDocument);
-        
+
         if (clipboard.getMethod() == Clipboard.METHOD_COPY) {
             getDocumentManager().copyAll(clippedDocument, availableDocument);
-        }
-        else if (clipboard.getMethod() == Clipboard.METHOD_CUT) {
+        } else if (clipboard.getMethod() == Clipboard.METHOD_CUT) {
             getDocumentManager().moveAll(clippedDocument, availableDocument);
-        }
-        else {
+        } else {
             throw new RuntimeException("This clipboard method is not supported!");
         }
     }
-}
+}
\ No newline at end of file

Modified: lenya/trunk/src/java/org/apache/lenya/cms/task/WorkflowInvoker.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/task/WorkflowInvoker.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/task/WorkflowInvoker.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/task/WorkflowInvoker.java Sat Mar 12 15:10:56 2005
@@ -194,8 +194,8 @@
             // check for workflow instance first (task can initialize the workflow history)
             WorkflowFactory factory = WorkflowFactory.newInstance();
             try {
-                DocumentIdentityMap map = new DocumentIdentityMap(publication);
-                this.document = map.getFactory().getFromURL(webappUrl);
+                DocumentIdentityMap map = new DocumentIdentityMap();
+                this.document = map.getFactory().getFromURL(publication, webappUrl);
             } catch (DocumentBuildException e) {
                 throw new ExecutionException(e);
             }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/usecase/AbstractUsecase.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/usecase/AbstractUsecase.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/usecase/AbstractUsecase.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/usecase/AbstractUsecase.java Sat Mar 12 15:10:56 2005
@@ -28,14 +28,10 @@
 import org.apache.avalon.framework.context.ContextException;
 import org.apache.avalon.framework.context.Contextualizable;
 import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.cocoon.components.ContextHelper;
 import org.apache.cocoon.components.cron.CronJob;
 import org.apache.cocoon.components.cron.JobScheduler;
-import org.apache.cocoon.environment.ObjectModelHelper;
-import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.servlet.multipart.Part;
 import org.apache.lenya.cms.publication.DocumentManager;
-import org.apache.lenya.util.ServletHelper;
 
 /**
  * Abstract usecase implementation.
@@ -388,15 +384,6 @@
      * Does the actual initialization. Template method.
      */
     protected void doInitialize() {
-        Map objectModel = ContextHelper.getObjectModel(this.context);
-        Request request = ObjectModelHelper.getRequest(objectModel);
-        String webappUri = ServletHelper.getWebappURI(request);
-
-        this.sourceUrl = webappUri;
-
-        if (getLogger().isDebugEnabled()) {
-            getLogger().debug("Invoking usecase on URL: [" + this.sourceUrl + "]");
-        }
     }
 
     /**
@@ -473,6 +460,13 @@
     public String[] getParameterNames() {
         Set keys = this.parameters.keySet();
         return (String[]) keys.toArray(new String[keys.size()]);
+    }
+
+    /**
+     * @see org.apache.lenya.cms.usecase.Usecase#setSourceURL(java.lang.String)
+     */
+    public void setSourceURL(String url) {
+        this.sourceUrl = url;
     }
 
 }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/usecase/DocumentUsecase.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/usecase/DocumentUsecase.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/usecase/DocumentUsecase.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/usecase/DocumentUsecase.java Sat Mar 12 15:10:56 2005
@@ -25,6 +25,8 @@
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.DocumentBuildException;
 import org.apache.lenya.cms.publication.DocumentFactory;
+import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.publication.PublicationFactory;
 import org.apache.lenya.cms.publication.URLInformation;
 import org.apache.lenya.util.ServletHelper;
 
@@ -60,25 +62,28 @@
             addErrorMessage("This usecase can only be invoked on documents!");
         }
     }
-    
+
     /**
      * @see org.apache.lenya.cms.usecase.AbstractUsecase#doInitialize()
      */
     protected void doInitialize() {
         super.doInitialize();
         try {
-            DocumentFactory factory = getUnitOfWork().getIdentityMap().getFactory();
-            if (factory.isDocument(getSourceURL())) {
-                this.sourceDocument = factory.getFromURL(getSourceURL());
-            }
-            
             Map objectModel = ContextHelper.getObjectModel(getContext());
             Request request = ObjectModelHelper.getRequest(objectModel);
             String webappUri = ServletHelper.getWebappURI(request);
-            
+
+            DocumentFactory factory = getUnitOfWork().getIdentityMap().getFactory();
+            PublicationFactory pubFactory = PublicationFactory.getInstance(getLogger());
+            Publication publication = pubFactory.getPublication(this.manager, webappUri);
+
+            if (factory.isDocument(publication, getSourceURL())) {
+                this.sourceDocument = factory.getFromURL(publication, getSourceURL());
+            }
+
             URLInformation info = new URLInformation(webappUri);
             this.completeArea = info.getCompleteArea();
-        } catch (DocumentBuildException e) {
+        } catch (Exception e) {
             throw new RuntimeException(e);
         }
     }
@@ -128,7 +133,8 @@
     public String getTargetURL(boolean success) {
         Document document = getTargetDocument(success);
         String documentUrl = document.getCanonicalDocumentURL();
-        String url = "/" + document.getPublication().getId() + "/" + this.completeArea + documentUrl;
+        String url = "/" + document.getPublication().getId() + "/" + this.completeArea
+                + documentUrl;
         return url;
     }
 
@@ -147,7 +153,8 @@
      */
     protected void setTargetURL(String url) {
         try {
-            this.sourceDocument = getUnitOfWork().getIdentityMap().getFactory().getFromURL(url);
+            this.targetDocument = getUnitOfWork().getIdentityMap().getFactory()
+                    .getFromURL(getSourceDocument().getPublication(), url);
         } catch (DocumentBuildException e) {
             throw new RuntimeException(e);
         }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/usecase/UnitOfWorkImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/usecase/UnitOfWorkImpl.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/usecase/UnitOfWorkImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/usecase/UnitOfWorkImpl.java Sat Mar 12 15:10:56 2005
@@ -16,24 +16,15 @@
  */
 package org.apache.lenya.cms.usecase;
 
-import java.util.Map;
-
-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.logger.AbstractLogEnabled;
-import org.apache.cocoon.components.ContextHelper;
 import org.apache.lenya.cms.publication.DocumentIdentityMap;
-import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.PublicationException;
-import org.apache.lenya.cms.publication.PublicationFactory;
 
 /**
  * Abstract base class for operations on documents.
  * 
  * @version $Id$
  */
-public class UnitOfWorkImpl extends AbstractLogEnabled implements UnitOfWork, Contextualizable {
+public class UnitOfWorkImpl extends AbstractLogEnabled implements UnitOfWork {
 
     /**
      * Ctor.
@@ -49,35 +40,11 @@
      * @return A document identity map.
      */
     public DocumentIdentityMap getIdentityMap() {
-        
         if (this.identityMap == null) {
-            Map objectModel = ContextHelper.getObjectModel(this.context);
-            Publication publication;
-            try {
-                PublicationFactory factory = PublicationFactory.getInstance(getLogger());
-                publication = factory.getPublication(objectModel);
-            } catch (PublicationException e) {
-                throw new RuntimeException(e);
-            }
-            if (getLogger().isDebugEnabled()) {
-                getLogger().debug("Initializing unit of work for publication [" + publication.getId() + "]");
-            }
-            
-            this.identityMap = new DocumentIdentityMap(publication);
+            this.identityMap = new DocumentIdentityMap();
         }
-        
         return this.identityMap;
     }
 
-    /**
-     * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
-     */
-    public void contextualize(Context _context)
-            throws ContextException {
-        this.context = _context;
-    }
-
-    /** The environment context */
-    private Context context;
 
 }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/usecase/Usecase.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/usecase/Usecase.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/usecase/Usecase.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/usecase/Usecase.java Sat Mar 12 15:10:56 2005
@@ -31,6 +31,11 @@
      * The <code>Usecase</code> role.
      */
     String ROLE = Usecase.class.getName();
+    
+    /**
+     * @param url The URL the usecase is invoked on.
+     */
+    void setSourceURL(String url);
 
     /**
      * Sets a parameter from the form.

Modified: lenya/trunk/src/java/org/apache/lenya/cms/usecase/UsecaseCronJob.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/usecase/UsecaseCronJob.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/usecase/UsecaseCronJob.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/usecase/UsecaseCronJob.java Sat Mar 12 15:10:56 2005
@@ -16,17 +16,16 @@
  */
 package org.apache.lenya.cms.usecase;
 
-import java.io.InputStream;
-import java.io.InputStreamReader;
+import java.util.Collections;
 import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 
-import org.apache.avalon.framework.CascadingRuntimeException;
 import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.framework.service.ServiceException;
 import org.apache.cocoon.components.cron.ConfigurableCronJob;
 import org.apache.cocoon.components.cron.ServiceableCronJob;
-import org.apache.excalibur.source.Source;
-import org.apache.excalibur.source.SourceResolver;
 
 /**
  * Job to schedule usecase execution.
@@ -36,88 +35,116 @@
 public class UsecaseCronJob extends ServiceableCronJob implements ConfigurableCronJob {
 
     /**
-     * @see org.apache.cocoon.components.cron.CronJob#execute(java.lang.String)
+     * Initializes the job.
+     * @param usecase The usecase.
      */
-    public void execute(String jobname) {
-        if (getLogger().isDebugEnabled()) {
-            getLogger().debug("UsecaseCronJob: " + jobname);
-            getLogger().debug("URI: " + getRequestURI());
+    public void setup(Usecase usecase) {
+        this.usecaseName = usecase.getName();
+        String[] keys = usecase.getParameterNames();
+        for (int i = 0; i < keys.length; i++) {
+            this.parameters.put(keys[i], usecase.getParameter(keys[i]));
         }
+    }
+
+    private String usecaseName;
+    private String sourceUrl;
+
+    private Map parameters = new HashMap();
+
+    protected static final String USECASE_NAME = "usecaseName";
+
+    protected static final String SOURCE_URL = "sourceUrl";
+
+    protected String getUsecaseName() {
+        return this.usecaseName;
+    }
+    
+    protected String getSourceURL() {
+        return this.sourceUrl;
+    }
+
+    protected Map getParameters() {
+        return Collections.unmodifiableMap(this.parameters);
+    }
 
-        SourceResolver resolver = null;
-        Source source = null;
+    /**
+     * @see org.apache.cocoon.components.cron.CronJob#execute(java.lang.String)
+     */
+    public void execute(String jobname) {
+        UsecaseResolver resolver = null;
+        Usecase usecase = null;
         try {
-            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
-            final String url = "cocoon:/" + getRequestURI();
-            source = resolver.resolveURI(url, url, this.requestParameters);
-
-            InputStream is = source.getInputStream();
-            InputStreamReader reader = new InputStreamReader(is);
-            StringBuffer sb = new StringBuffer();
-            char[] b = new char[8192];
-            int n;
-            while ((n = reader.read(b)) > 0) {
-                sb.append(b, 0, n);
+            resolver = (UsecaseResolver) this.manager.lookup(UsecaseResolver.ROLE);
+            usecase = resolver.resolve(getSourceURL(), getUsecaseName());
+            usecase.setName(getUsecaseName());
+
+            passParameters(usecase);
+
+            usecase.checkPreconditions();
+            List errorMessages = usecase.getErrorMessages();
+            if (!errorMessages.isEmpty()) {
+                logErrorMessages("Pre condition messages:", errorMessages);
+            } else {
+                usecase.checkExecutionConditions();
+                errorMessages = usecase.getErrorMessages();
+                if (!errorMessages.isEmpty()) {
+                    logErrorMessages("Execution condition messages:", errorMessages);
+                } else {
+                    usecase.execute();
+                    logErrorMessages("Execution messages:", usecase.getErrorMessages());
+                    usecase.checkPostconditions();
+                    logErrorMessages("Post condition messages:", usecase.getErrorMessages());
+                }
             }
-            reader.close();
+
         } catch (Exception e) {
-            throw new CascadingRuntimeException("UsecaseCronJob: " + jobname
-                    + ", raised an exception: ", e);
+            throw new RuntimeException(e);
         } finally {
             if (resolver != null) {
-                resolver.release(source);
+                if (usecase != null) {
+                    try {
+                        resolver.release(usecase);
+                    } catch (ServiceException e) {
+                        throw new RuntimeException(e);
+                    }
+                }
                 this.manager.release(resolver);
-                resolver = null;
-                source = null;
             }
         }
+
     }
 
-    private String requestUri;
-    private Map requestParameters;
+    /**
+     * @param headline The headline of the messages.
+     * @param errorMessages The messages to log.
+     */
+    protected void logErrorMessages(String headline, List errorMessages) {
+        getLogger().error("Usecase [" + getUsecaseName() + "] - " + headline);
+        for (Iterator i = errorMessages.iterator(); i.hasNext();) {
+            getLogger().error((String) i.next());
+        }
+    }
 
     /**
-     * @return The request URI.
+     * @param usecase The usecase to pass the parameters to.
      */
-    protected String getRequestURI() {
-        return requestUri;
+    protected void passParameters(Usecase usecase) {
+        Map parameters = getParameters();
+        for (Iterator i = parameters.keySet().iterator(); i.hasNext();) {
+            String key = (String) i.next();
+            Object value = parameters.get(key);
+            usecase.setParameter(key, value);
+        }
     }
-    
-    protected static final String SOURCE_URL = "sourceUrl";
-    protected static final String USECASE_NAME = "usecaseName";
 
     /**
      * @see org.apache.cocoon.components.cron.ConfigurableCronJob#setup(org.apache.avalon.framework.parameters.Parameters,
      *      java.util.Map)
      */
-    public void setup(Parameters params, Map objects) {
-
-        try {
-            final String sourceUri = (String) objects.get(SOURCE_URL);
-            if (sourceUri == null) {
-                throw new RuntimeException("Source URI not set!");
-            }
-            
-            final String usecaseName = (String) objects.get(USECASE_NAME);
-            if (usecaseName == null) {
-                throw new RuntimeException("Usecase name not set!");
-            }
-
-            this.requestParameters = new HashMap(Parameters.toProperties(params));
-            this.requestParameters.put("lenya.usecase", usecaseName);
-            this.requestParameters.put("lenya.schedule", "true");
-
-//            String requestUri = sourceUri + "?lenya.usecase=" + usecaseName + "&lenya.schedule=true";
-
-            String[] names = params.getNames();
-            for (int i = 0; i < names.length; i++) {
-                requestUri += "&" + names[i] + "=" + params.getParameter(names[i]);
-            }
-            this.requestUri = sourceUri;
-        } catch (RuntimeException e) {
-            throw e;
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
+    public void setup(Parameters parameters, Map objects) {
+        this.parameters.putAll(Parameters.toProperties(parameters));
+        this.usecaseName = (String) objects.get(USECASE_NAME);
+        this.sourceUrl = (String) objects.get(SOURCE_URL);
     }
+
 }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/usecase/UsecaseResolver.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/usecase/UsecaseResolver.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/usecase/UsecaseResolver.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/usecase/UsecaseResolver.java Sat Mar 12 15:10:56 2005
@@ -39,12 +39,30 @@
     Usecase resolve(String name) throws ServiceException;
     
     /**
+     * Resolves a usecase object.
+     * @param webappUrl The web application URL.
+     * @param name The name of the usecase.
+     * @return A usecase object.
+     * @throws ServiceException if the object could not be created.
+     */
+    Usecase resolve(String webappUrl, String name) throws ServiceException;
+    
+    /**
      * Checks if a certain usecase is registered.
      * @param name The usecase name.
      * @return A boolean value.
      * @throws ServiceException if an error occurs.
      */
     boolean isRegistered(String name) throws ServiceException;
+    
+    /**
+     * Checks if a certain usecase is registered.
+     * @param webappUrl The web application URL.
+     * @param name The usecase name.
+     * @return A boolean value.
+     * @throws ServiceException if an error occurs.
+     */
+    boolean isRegistered(String webappUrl, String name) throws ServiceException;
     
     /**
      * Releases a usecase object.

Modified: lenya/trunk/src/java/org/apache/lenya/cms/usecase/UsecaseResolverImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/usecase/UsecaseResolverImpl.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/usecase/UsecaseResolverImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/usecase/UsecaseResolverImpl.java Sat Mar 12 15:10:56 2005
@@ -16,8 +16,6 @@
  */
 package org.apache.lenya.cms.usecase;
 
-import java.util.Map;
-
 import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.context.Context;
 import org.apache.avalon.framework.context.ContextException;
@@ -28,8 +26,11 @@
 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.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.excalibur.source.SourceUtil;
 import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.PublicationException;
 import org.apache.lenya.cms.publication.PublicationFactory;
 
 /**
@@ -53,16 +54,7 @@
      * @see org.apache.lenya.cms.usecase.UsecaseResolver#resolve(java.lang.String)
      */
     public Usecase resolve(String name) throws ServiceException {
-        Usecase usecase = null;
-        String publicationUsecaseName = getPublicationUsecaseName(name);
-        if (this.selector.isSelectable(publicationUsecaseName)) {
-            usecase = (Usecase) this.selector.select(publicationUsecaseName);
-        }
-        else {
-            usecase = (Usecase) this.selector.select(name);
-            
-        }
-        return usecase;
+        return this.resolve(getWebappURL(), name);
     }
 
     private ServiceManager manager;
@@ -99,17 +91,24 @@
      * @see org.apache.lenya.cms.usecase.UsecaseResolver#isRegistered(java.lang.String)
      */
     public boolean isRegistered(String name) throws ServiceException {
-        return this.selector.isSelectable(getPublicationUsecaseName(name))
-                || this.selector.isSelectable(name);
+        return this.isRegistered(getWebappURL(), name);
+    }
+
+    protected String getWebappURL() {
+        Request request = ContextHelper.getRequest(getContext());
+        String context = request.getContextPath();
+        String webappUrl = request.getRequestURI().substring(context.length());
+        return webappUrl;
     }
 
     /**
      * Returns the name of the publication-overridden usecase to be resolved.
+     * @param webappUrl The web application URL.
      * @param name The plain usecase name.
      * @return A string.
      */
-    protected String getPublicationUsecaseName(String name) {
-        return getPublication().getId() + "/" + name;
+    protected String getPublicationUsecaseName(String webappUrl, String name) {
+        return getPublication(webappUrl).getId() + "/" + name;
     }
 
     private Context context;
@@ -131,18 +130,56 @@
 
     /**
      * Returns the publication the usecase was invoked in.
+     * @param webappUrl The web application URL.
      * @return A publication.
      */
-    protected Publication getPublication() {
-        Map objectModel = ContextHelper.getObjectModel(getContext());
+    protected Publication getPublication(String webappUrl) {
+
+        SourceResolver resolver = null;
+        Source source = null;
         Publication publication;
         try {
+            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
+            source = resolver.resolveURI("context://");
+
             PublicationFactory factory = PublicationFactory.getInstance(getLogger());
-            publication = factory.getPublication(objectModel);
-        } catch (PublicationException e) {
+            publication = factory.getPublication(webappUrl, SourceUtil.getFile(source));
+        } catch (Exception e) {
             throw new RuntimeException(e);
+        } finally {
+            if (resolver != null) {
+                if (source != null) {
+                    resolver.release(source);
+                }
+                this.manager.release(resolver);
+            }
         }
         return publication;
+    }
+
+    /**
+     * @see org.apache.lenya.cms.usecase.UsecaseResolver#resolve(java.lang.String,
+     *      java.lang.String)
+     */
+    public Usecase resolve(String webappUrl, String name) throws ServiceException {
+        Usecase usecase = null;
+        String publicationUsecaseName = getPublicationUsecaseName(webappUrl, name);
+        if (this.selector.isSelectable(publicationUsecaseName)) {
+            usecase = (Usecase) this.selector.select(publicationUsecaseName);
+        } else {
+            usecase = (Usecase) this.selector.select(name);
+
+        }
+        return usecase;
+    }
+
+    /**
+     * @see org.apache.lenya.cms.usecase.UsecaseResolver#isRegistered(java.lang.String,
+     *      java.lang.String)
+     */
+    public boolean isRegistered(String webappUrl, String name) throws ServiceException {
+        return this.selector.isSelectable(getPublicationUsecaseName(webappUrl, name))
+                || this.selector.isSelectable(name);
     }
 
 }



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