svn commit: r741654 [8/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...

[email protected]
Newsgroups gmane.comp.cms.lenya.cvs
Message-ID <[email protected]>
Modified: lenya/trunk/org.apache.lenya.module.simplesite/src/main/java/org/apache/lenya/cms/site/simple/SimpleSiteManager.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.simplesite/src/main/java/org/apache/lenya/cms/site/simple/SimpleSiteManager.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.simplesite/src/main/java/org/apache/lenya/cms/site/simple/SimpleSiteManager.java (original)
+++ lenya/trunk/org.apache.lenya.module.simplesite/src/main/java/org/apache/lenya/cms/site/simple/SimpleSiteManager.java Fri Feb  6 17:55:28 2009
@@ -17,16 +17,13 @@
  */
 package org.apache.lenya.cms.site.simple;
 
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
+import org.apache.excalibur.source.SourceResolver;
 import org.apache.lenya.cms.cocoon.source.SourceUtil;
 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.DocumentLocator;
 import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.repository.RepositoryItemFactory;
 import org.apache.lenya.cms.site.AbstractSiteManager;
 import org.apache.lenya.cms.site.SiteException;
 import org.apache.lenya.cms.site.SiteNode;
@@ -39,16 +36,10 @@
  * 
  * @version $Id$
  */
-public class SimpleSiteManager extends AbstractSiteManager implements Serviceable {
+public class SimpleSiteManager extends AbstractSiteManager {
 
-    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 DocumentStoreFactory documentStoreFactory;
+    private SourceResolver sourceResolver;
 
     /**
      * @see org.apache.lenya.cms.site.SiteManager#requires(org.apache.lenya.cms.publication.DocumentFactory,
@@ -95,9 +86,9 @@
             throws SiteException {
         String key = getKey(publication, area);
         DocumentStore store;
-        RepositoryItemFactory factory = new DocumentStoreFactory(this.manager, getLogger());
         try {
-            store = (DocumentStore) map.getSession().getRepositoryItem(factory, key);
+            store = (DocumentStore) map.getSession().getRepositoryItem(getDocumentStoreFactory(),
+                    key);
         } catch (Exception e) {
             throw new SiteException(e);
         }
@@ -108,12 +99,13 @@
     protected String getCollectionUuid(Publication pub) {
         String sourceUri = pub.getContentURI(Publication.AUTHORING_AREA) + DOCUMENT_PATH;
         try {
-            
-            if (!SourceUtil.exists(sourceUri, manager)) {
-                throw new RuntimeException("The site configuration [" + sourceUri + "] does not exist!");
+
+            if (!SourceUtil.exists(sourceUri, getSourceResolver())) {
+                throw new RuntimeException("The site configuration [" + sourceUri
+                        + "] does not exist!");
             }
-            
-            org.w3c.dom.Document xml = SourceUtil.readDOM(sourceUri, manager);
+
+            org.w3c.dom.Document xml = SourceUtil.readDOM(sourceUri, getSourceResolver());
             if (!xml.getDocumentElement().hasAttribute("uuid")) {
                 throw new RuntimeException("The document element of [" + sourceUri
                         + "] doesn't contain a uuid attribute!");
@@ -239,4 +231,26 @@
         return new DocumentLocator[0];
     }
 
+    /**
+     * TODO: Bean wiring
+     */
+    public void setDocumentStoreFactory(DocumentStoreFactory documentStoreFactory) {
+        this.documentStoreFactory = documentStoreFactory;
+    }
+
+    public DocumentStoreFactory getDocumentStoreFactory() {
+        return documentStoreFactory;
+    }
+
+    /**
+     * TODO: Bean wiring
+     */
+    public void setSourceResolver(SourceResolver sourceResolver) {
+        this.sourceResolver = sourceResolver;
+    }
+
+    public SourceResolver getSourceResolver() {
+        return sourceResolver;
+    }
+
 }

Modified: lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/SitetreeModule.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/SitetreeModule.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/SitetreeModule.java (original)
+++ lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/SitetreeModule.java Fri Feb  6 17:55:28 2009
@@ -24,18 +24,9 @@
 
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.service.ServiceSelector;
-import org.apache.cocoon.environment.ObjectModelHelper;
-import org.apache.cocoon.environment.Request;
-import org.apache.lenya.cms.publication.DocumentFactory;
-import org.apache.lenya.cms.publication.DocumentUtil;
 import org.apache.lenya.cms.publication.PageEnvelope;
 import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.repository.RepositoryUtil;
-import org.apache.lenya.cms.repository.Session;
-import org.apache.lenya.cms.site.SiteManager;
-import org.apache.lenya.cms.site.tree.SiteTree;
-import org.apache.lenya.cms.site.tree.TreeSiteManager;
+import org.apache.lenya.cms.site.SiteStructure;
 
 /**
  * Module for sitetree access.
@@ -66,59 +57,40 @@
 
     /**
      * @see org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String,
-     *      org.apache.avalon.framework.configuration.Configuration,
-     *      java.util.Map)
+     *      org.apache.avalon.framework.configuration.Configuration, java.util.Map)
      */
     public Object getAttribute(String name, Configuration modeConf, Map objectModel)
             throws ConfigurationException {
 
         Object value = null;
-        ServiceSelector selector = null;
-        TreeSiteManager _manager = null;
 
         try {
             PageEnvelope envelope = getEnvelope(objectModel, name);
-            Publication publication = envelope.getPublication();
-            
-            selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE + "Selector");
-            _manager = (TreeSiteManager) selector.select(publication.getSiteManagerHint());
-            
-            Request request = ObjectModelHelper.getRequest(objectModel);
-            Session session = RepositoryUtil.getSession(this.manager, request);
-            DocumentFactory map = DocumentUtil.createDocumentFactory(this.manager, session);
+            Publication pub = envelope.getPublication();
 
+            SiteStructure site = null;
             if (name.equals(AUTHORING_NODE)) {
-                SiteTree authoringTree = _manager.getTree(map,
-                        publication,
-                        Publication.AUTHORING_AREA);
-                value = authoringTree.getNode(envelope.getDocument().getPath());
+                site = pub.getArea(Publication.AUTHORING_AREA).getSite();
             }
 
             if (name.equals(LIVE_NODE)) {
-                SiteTree liveTree = _manager.getTree(map, publication, Publication.LIVE_AREA);
-                value = liveTree.getNode(envelope.getDocument().getPath());
+                site = pub.getArea(Publication.LIVE_AREA).getSite();;
             }
 
             if (name.equals(TRASH_NODE)) {
-                SiteTree trashTree = _manager.getTree(map, publication, Publication.TRASH_AREA);
-                value = trashTree.getNode(envelope.getDocument().getPath());
+                site = pub.getArea(Publication.TRASH_AREA).getSite();;
             }
 
             if (name.equals(ARCHIVE_NODE)) {
-                SiteTree archiveTree = _manager.getTree(map, publication, Publication.ARCHIVE_AREA);
-                value = archiveTree.getNode(envelope.getDocument().getPath());
+                site = pub.getArea(Publication.ARCHIVE_AREA).getSite();;
+            }
+            if (site != null) {
+                value = site.getNode(envelope.getDocument().getPath());
             }
+
         } catch (Exception e) {
             throw new ConfigurationException("Obtaining value for [" + name + "] failed: ", e);
         }
-        finally {
-            if (selector != null) {
-                if (_manager != null) {
-                    selector.release(_manager);
-                }
-                this.manager.release(selector);
-            }
-        }
 
         return value;
     }
@@ -134,8 +106,7 @@
 
     /**
      * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeValues(java.lang.String,
-     *      org.apache.avalon.framework.configuration.Configuration,
-     *      java.util.Map)
+     *      org.apache.avalon.framework.configuration.Configuration, java.util.Map)
      */
     public Object[] getAttributeValues(String name, Configuration modeConf, Map objectModel)
             throws ConfigurationException {

Modified: lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/cocoon/generation/SitetreeFragmentGenerator.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/cocoon/generation/SitetreeFragmentGenerator.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/cocoon/generation/SitetreeFragmentGenerator.java (original)
+++ lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/cocoon/generation/SitetreeFragmentGenerator.java Fri Feb  6 17:55:28 2009
@@ -31,15 +31,12 @@
 import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.generation.ServiceableGenerator;
 import org.apache.excalibur.source.Source;
-import org.apache.excalibur.source.SourceResolver;
 import org.apache.excalibur.source.SourceValidity;
-import org.apache.lenya.cms.publication.DocumentFactory;
-import org.apache.lenya.cms.publication.DocumentUtil;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.PublicationException;
+import org.apache.lenya.cms.publication.Repository;
+import org.apache.lenya.cms.publication.Session;
 import org.apache.lenya.cms.publication.URLInformation;
-import org.apache.lenya.cms.repository.RepositoryUtil;
-import org.apache.lenya.cms.repository.Session;
 import org.apache.lenya.cms.site.Link;
 import org.apache.lenya.cms.site.SiteException;
 import org.apache.lenya.cms.site.SiteNode;
@@ -82,6 +79,8 @@
 
     private String cacheKey;
     private SourceValidity validity;
+    
+    private Repository repository;
 
     protected static final String PARAM_PUB = "pub";
     protected static final String PARAM_AREA = "area";
@@ -172,8 +171,7 @@
 
         Source source = null;
         try {
-            Session session = RepositoryUtil.getSession(this.manager, request);
-            DocumentFactory factory = DocumentUtil.createDocumentFactory(this.manager, session);
+            Session session = this.repository.getSession(request);
             String pubId = null;
             if (par.isParameter(PARAM_PUB)) {
                 pubId = par.getParameter(PARAM_PUB);
@@ -182,7 +180,7 @@
                 URLInformation info = new URLInformation(webappUrl);
                 pubId = info.getPublicationId();
             }
-            Publication pub = factory.getPublication(pubId);
+            Publication pub = session.getPublication(pubId);
             this.site = pub.getArea(area).getSite();
 
             if (this.path == null) {
@@ -547,4 +545,8 @@
         return this.validity;
     }
 
+    public void setRepository(Repository repository) {
+        this.repository = repository;
+    }
+
 }

Modified: lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/cocoon/transformation/IconUrlTransformer.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/cocoon/transformation/IconUrlTransformer.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/cocoon/transformation/IconUrlTransformer.java (original)
+++ lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/cocoon/transformation/IconUrlTransformer.java Fri Feb  6 17:55:28 2009
@@ -22,8 +22,6 @@
 import java.util.Arrays;
 import java.util.Map;
 
-import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.activity.Initializable;
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.cocoon.ProcessingException;
@@ -35,11 +33,10 @@
 import org.apache.lenya.cms.linking.LinkRewriter;
 import org.apache.lenya.cms.linking.LinkTarget;
 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.Repository;
 import org.apache.lenya.cms.publication.ResourceType;
+import org.apache.lenya.cms.publication.Session;
 import org.apache.lenya.cms.publication.URLInformation;
-import org.apache.lenya.util.ServletHelper;
 import org.xml.sax.SAXException;
 
 /**
@@ -50,9 +47,10 @@
 
     private LinkResolver linkResolver;
     private IconLinkRewriter rewriter = null;
-    private DocumentFactory factory;
     private String pubId;
     private String area;
+    private Repository repository;
+    private Session session;
 
     protected LinkRewriter getLinkRewriter() {
         if (this.rewriter == null) {
@@ -79,7 +77,7 @@
                 try {
                     Link link = getLink(linkUri, pubId, area);
                     LinkTarget target = IconUrlTransformer.this.linkResolver.resolve(
-                            IconUrlTransformer.this.factory, link.getUri());
+                            IconUrlTransformer.this.session.getDocumentFactory(), link.getUri());
                     if (target.exists()) {
                         Document doc = target.getDocument();
                         ResourceType type = doc.getResourceType();
@@ -113,7 +111,7 @@
         super.setup(resolver, objectModel, src, params);
         try {
             Request request = ObjectModelHelper.getRequest(objectModel);
-            this.factory = DocumentUtil.getDocumentFactory(this.manager, request);
+            this.session = this.repository.getSession(request);
             this.linkResolver = (LinkResolver) this.manager.lookup(LinkResolver.ROLE);
 
             String webappUrl = getWebappUrl(params, objectModel);
@@ -135,10 +133,14 @@
 
     public void recycle() {
         super.recycle();
-        this.factory = null;
+        this.session = null;
         this.pubId = null;
         this.area = null;
         this.linkResolver = null;
     }
 
+    public void setRepository(Repository repository) {
+        this.repository = repository;
+    }
+
 }

Modified: lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree/DefaultSiteTree.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree/DefaultSiteTree.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree/DefaultSiteTree.java (original)
+++ lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree/DefaultSiteTree.java Fri Feb  6 17:55:28 2009
@@ -25,7 +25,7 @@
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.TransformerException;
 
-import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 import org.apache.cocoon.util.AbstractLogEnabled;
 import org.apache.commons.logging.Log;
 import org.apache.lenya.cms.publication.DocumentFactory;
@@ -68,7 +68,6 @@
     // exception.
     private String area = "";
     private Publication pub;
-    protected ServiceManager manager;
     private Document document;
     private DocumentFactory factory;
 
@@ -81,12 +80,11 @@
      * @param factory The document factory.
      * @param publication The publication.
      * @param _area The area.
-     * @param manager The service manager.
      * @param logger The logger.
      * @throws SiteException if an error occurs.
      */
     protected DefaultSiteTree(DocumentFactory factory, Publication publication, String _area,
-            ServiceManager manager, Log logger) throws SiteException {
+            Log logger) throws SiteException {
         setLogger(logger);
 
         this.factory = factory;
@@ -94,12 +92,10 @@
         this.sourceUri = publication.getSourceURI() + "/content/" + _area + "/"
                 + SITE_TREE_FILENAME;
         this.area = _area;
-        this.manager = manager;
         try {
             if (getRepositoryNode().exists()) {
                 this.document = DocumentHelper.readDocument(getRepositoryNode().getInputStream());
-            }
-            else {
+            } else {
                 getLogger().info("Empty sitetree will be created/initialized!");
                 this.document = createDocument();
             }
@@ -117,17 +113,16 @@
     }
 
     /**
-     * Checks if the tree file has been modified externally and reloads the site
-     * tree. protected synchronized void checkModified() { if
-     * (this.area.equals(Publication.LIVE_AREA) && this.treefile.lastModified() >
-     * this.lastModified) {
+     * Checks if the tree file has been modified externally and reloads the site tree. protected
+     * synchronized void checkModified() { if (this.area.equals(Publication.LIVE_AREA) &&
+     * this.treefile.lastModified() > this.lastModified) {
      * 
-     * if (getLogger().isDebugEnabled()) { getLogger().debug("Sitetree [" +
-     * this.treefile + "] has changed: reloading."); }
+     * if (getLogger().isDebugEnabled()) { getLogger().debug("Sitetree [" + this.treefile +
+     * "] has changed: reloading."); }
      * 
-     * try { this.document = DocumentHelper.readDocument(this.treefile); } catch
-     * (Exception e) { throw new IllegalStateException(e.getMessage()); }
-     * this.lastModified = this.treefile.lastModified(); } }
+     * try { this.document = DocumentHelper.readDocument(this.treefile); } catch (Exception e) {
+     * throw new IllegalStateException(e.getMessage()); } this.lastModified =
+     * this.treefile.lastModified(); } }
      */
 
     /**
@@ -148,8 +143,8 @@
     }
 
     /**
-     * Find a node in a subtree. The search is started at the given node. The
-     * list of ids contains the document-id split by "/".
+     * Find a node in a subtree. The search is started at the given node. The list of ids contains
+     * the document-id split by "/".
      * @param node where to start the search
      * @param ids list of node ids
      * @return the node that matches the path given in the list of ids
@@ -190,8 +185,8 @@
         }
     }
 
-    protected synchronized void addNode(String parentid, String id, String uuid, boolean visibleInNav)
-            throws SiteException {
+    protected synchronized void addNode(String parentid, String id, String uuid,
+            boolean visibleInNav) throws SiteException {
         addNode(parentid, id, uuid, visibleInNav, null, null, false);
     }
 
@@ -362,8 +357,7 @@
      * 
      * @param path the document-id of the Node that we're trying to get
      * 
-     * @return the Node if there is a Node for the given document-id, null
-     *         otherwise
+     * @return the Node if there is a Node for the given document-id, null otherwise
      * @throws SiteException
      */
     private synchronized Node getNodeInternal(String path) throws SiteException {
@@ -482,17 +476,13 @@
     public org.apache.lenya.cms.repository.Node getRepositoryNode() {
         if (this.repositoryNode == null) {
             Session session = this.getPublication().getFactory().getSession();
-            NodeFactory factory = null;
             try {
-                factory = (NodeFactory) manager.lookup(NodeFactory.ROLE);
-                this.repositoryNode = (org.apache.lenya.cms.repository.Node)
-                    session.getRepositoryItem(factory, this.sourceUri);
+                NodeFactory factory = (NodeFactory) WebAppContextUtils
+                        .getCurrentWebApplicationContext().getBean(NodeFactory.ROLE);
+                this.repositoryNode = (org.apache.lenya.cms.repository.Node) session
+                        .getRepositoryItem(factory, this.sourceUri);
             } catch (Exception e) {
                 throw new RuntimeException("Creating repository node failed: ", e);
-            } finally {
-                if (factory != null) {
-                    manager.release(factory);
-                }
             }
         }
         return this.repositoryNode;

Modified: lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree/SiteTreeFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree/SiteTreeFactory.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree/SiteTreeFactory.java (original)
+++ lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree/SiteTreeFactory.java Fri Feb  6 17:55:28 2009
@@ -17,7 +17,6 @@
  */
 package org.apache.lenya.cms.site.tree;
 
-import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.cocoon.util.AbstractLogEnabled;
 import org.apache.commons.logging.Log;
 import org.apache.lenya.cms.publication.DocumentFactory;
@@ -35,15 +34,11 @@
  */
 public class SiteTreeFactory extends AbstractLogEnabled implements RepositoryItemFactory {
 
-    protected ServiceManager manager;
-
     /**
      * Ctor.
-     * @param manager The service manager.
      * @param logger The logger.
      */
-    public SiteTreeFactory(ServiceManager manager, Log logger) {
-        this.manager = manager;
+    public SiteTreeFactory(Log logger) {
         setLogger(logger);
     }
 
@@ -53,9 +48,9 @@
         String area = snippets[1];
         DefaultSiteTree tree;
         try {
-            DocumentFactory factory = DocumentUtil.createDocumentFactory(this.manager, session);
+            DocumentFactory factory = DocumentUtil.createDocumentFactory(session);
             Publication publication = factory.getPublication(publicationId);
-            tree = new DefaultSiteTree(factory, publication, area, this.manager, getLogger());
+            tree = new DefaultSiteTree(factory, publication, area, getLogger());
         } catch (Exception e) {
             throw new RepositoryException(e);
         }

Modified: lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree/TreeSiteManager.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree/TreeSiteManager.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree/TreeSiteManager.java (original)
+++ lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree/TreeSiteManager.java Fri Feb  6 17:55:28 2009
@@ -21,7 +21,6 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.avalon.framework.service.Serviceable;
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.DocumentException;
 import org.apache.lenya.cms.publication.DocumentFactory;
@@ -41,7 +40,7 @@
  * 
  * @version $Id: TreeSiteManager.java 208766 2005-07-01 16:05:00Z andreas $
  */
-public class TreeSiteManager extends AbstractSiteManager implements Serviceable {
+public class TreeSiteManager extends AbstractSiteManager {
 
     /**
      * Ctor.
@@ -65,7 +64,7 @@
 
         String key = getKey(publication, area);
         DefaultSiteTree sitetree;
-        RepositoryItemFactory factory = new SiteTreeFactory(this.manager, getLogger());
+        RepositoryItemFactory factory = new SiteTreeFactory(getLogger());
         try {
             sitetree = (DefaultSiteTree) map.getSession().getRepositoryItem(factory, key);
         } catch (Exception e) {
@@ -134,7 +133,7 @@
             getLogger().debug("Obtaining requiring resources of [" + resource + "]");
         }
 
-        NodeSet nodes = new NodeSet(this.manager);
+        NodeSet nodes = new NodeSet();
         Publication pub = resource.getStructure().getPublication();
         String area = resource.getStructure().getArea();
         SiteTree tree = getTree(map, pub, area);

Modified: lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree2/DelegatingSiteTree.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree2/DelegatingSiteTree.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree2/DelegatingSiteTree.java (original)
+++ lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree2/DelegatingSiteTree.java Fri Feb  6 17:55:28 2009
@@ -22,8 +22,7 @@
 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.cocoon.spring.configurator.WebAppContextUtils;
 import org.apache.lenya.cms.publication.Area;
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.Publication;
@@ -38,13 +37,11 @@
 import org.apache.lenya.cms.site.tree.SiteTree;
 
 /**
- * Site tree implementation which delegates all operations to a shared site
- * tree.
+ * Site tree implementation which delegates all operations to a shared site tree.
  */
 public class DelegatingSiteTree implements SiteStructure, SiteTree {
 
     private Area area;
-    private ServiceManager manager;
     private Map links = new HashMap();
     private Map nodes = new HashMap();
     private List nodeList;
@@ -56,16 +53,13 @@
     private SiteTreeFactory factory;
 
     /**
-     * @param manager The service manager.
      * @param area The area which this tree belongs to.
      * @param factory The site tree factory.
      * @param store The shared item store.
      * @param key The key to build the sitetree.
      */
-    public DelegatingSiteTree(ServiceManager manager, Area area, SiteTreeFactory factory, Session session,
-            String key) {
+    public DelegatingSiteTree(Area area, SiteTreeFactory factory, Session session, String key) {
         this.area = area;
-        this.manager = manager;
         this.key = key;
         this.factory = factory;
         this.sharedItemStoreSession = session;
@@ -164,11 +158,8 @@
 
     protected NodeFactory getNodeFactory() {
         if (this.nodeFactory == null) {
-            try {
-                this.nodeFactory = (NodeFactory) this.manager.lookup(NodeFactory.ROLE);
-            } catch (ServiceException e) {
-                throw new RuntimeException("Creating repository node failed: ", e);
-            }
+            this.nodeFactory = (NodeFactory) WebAppContextUtils.getCurrentWebApplicationContext()
+                    .getBean(NodeFactory.ROLE);
         }
         return this.nodeFactory;
     }

Modified: lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree2/SiteTreeFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree2/SiteTreeFactory.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree2/SiteTreeFactory.java (original)
+++ lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree2/SiteTreeFactory.java Fri Feb  6 17:55:28 2009
@@ -17,7 +17,6 @@
  */
 package org.apache.lenya.cms.site.tree2;
 
-import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.cocoon.util.AbstractLogEnabled;
 import org.apache.commons.logging.Log;
 import org.apache.lenya.cms.publication.Area;
@@ -37,16 +36,14 @@
  * @version $Id: SiteTreeFactory.java 179568 2005-06-02 09:27:26Z jwkaltz $
  */
 public class SiteTreeFactory extends AbstractLogEnabled implements RepositoryItemFactory {
-
-    protected ServiceManager manager;
+    
+    private SharedItemStore sharedItemStore;
 
     /**
      * Ctor.
-     * @param manager The service manager.
      * @param logger The logger.
      */
-    public SiteTreeFactory(ServiceManager manager, Log logger) {
-        this.manager = manager;
+    public SiteTreeFactory(Log logger) {
         setLogger(logger);
     }
 
@@ -55,25 +52,19 @@
         String publicationId = snippets[0];
         String areaName = snippets[1];
         SiteTree tree;
-        SharedItemStore store = null;
         try {
-            DocumentFactory factory = DocumentUtil.createDocumentFactory(this.manager, session);
+            DocumentFactory factory = DocumentUtil.createDocumentFactory(session);
             Publication publication = factory.getPublication(publicationId);
             Area area = publication.getArea(areaName);
-            store = (SharedItemStore) this.manager.lookup(SharedItemStore.ROLE);
 
-            Session storeSession = store.getSession();
+            Session storeSession = getSharedItemStore().getSession();
             if (session.isModifiable() || session == storeSession) {
-                tree = new SiteTreeImpl(this.manager, area, getLogger());
+                tree = new SiteTreeImpl(area, getLogger());
             } else {
-                tree = new DelegatingSiteTree(this.manager, area, this, storeSession, key);
+                tree = new DelegatingSiteTree(area, this, storeSession, key);
             }
         } catch (Exception e) {
             throw new RepositoryException(e);
-        } finally {
-            if (store != null) {
-                this.manager.release(store);
-            }
         }
         return tree;
     }
@@ -82,4 +73,15 @@
         return SiteTree.IDENTIFIABLE_TYPE;
     }
 
+    /**
+     * TODO: Bean wiring
+     */
+    public void setSharedItemStore(SharedItemStore sharedItemStore) {
+        this.sharedItemStore = sharedItemStore;
+    }
+
+    public SharedItemStore getSharedItemStore() {
+        return sharedItemStore;
+    }
+
 }
\ No newline at end of file

Modified: lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java (original)
+++ lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java Fri Feb  6 17:55:28 2009
@@ -21,8 +21,7 @@
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 import org.apache.cocoon.util.AbstractLogEnabled;
 import org.apache.commons.logging.Log;
 import org.apache.lenya.cms.publication.Area;
@@ -43,22 +42,20 @@
 /**
  * Simple site tree implementation.
  */
-public class SiteTreeImpl extends AbstractLogEnabled implements SiteStructure, SiteTree, Persistable {
+public class SiteTreeImpl extends AbstractLogEnabled implements SiteStructure, SiteTree,
+        Persistable {
 
     private Area area;
-    protected ServiceManager manager;
     private RootNode root;
     private int revision;
 
     /**
-     * @param manager The service manager.
      * @param area The area.
      * @param logger The logger.
      */
-    public SiteTreeImpl(ServiceManager manager, Area area, Log logger) {
+    public SiteTreeImpl(Area area, Log logger) {
         setLogger(logger);
         this.area = area;
-        this.manager = manager;
         initRoot();
     }
 
@@ -95,20 +92,19 @@
 
         try {
             repoNode.setPersistable(this);
-            
+
             if (repoNode.exists()) {
                 TreeBuilder builder = null;
                 try {
                     this.loading = true;
-                    builder = (TreeBuilder) this.manager.lookup(TreeBuilder.ROLE);
+                    builder = (TreeBuilder) WebAppContextUtils.getCurrentWebApplicationContext()
+                            .getBean(TreeBuilder.ROLE);
                     reset();
                     builder.buildTree(this);
-                    Assert.isTrue("Latest revision loaded", getRevision() == getRevision(getRepositoryNode()));
+                    Assert.isTrue("Latest revision loaded",
+                            getRevision() == getRevision(getRepositoryNode()));
                 } finally {
                     this.loading = false;
-                    if (builder != null) {
-                        this.manager.release(builder);
-                    }
                 }
             }
             this.loaded = true;
@@ -137,17 +133,13 @@
         }
         TreeWriter writer = null;
         try {
-            writer = (TreeWriter) this.manager.lookup(TreeWriter.ROLE);
+            writer = (TreeWriter) WebAppContextUtils.getCurrentWebApplicationContext().getBean(TreeWriter.ROLE);
             int revision = getRevision(getRepositoryNode()) + 1;
             writer.writeTree(this);
         } catch (RuntimeException e) {
             throw e;
         } catch (Exception e) {
             throw new RepositoryException(e);
-        } finally {
-            if (writer != null) {
-                this.manager.release(writer);
-            }
         }
 
     }
@@ -321,17 +313,14 @@
     public Session getSession() {
         return this.area.getPublication().getFactory().getSession();
     }
-    
+
     private NodeFactory nodeFactory;
     private boolean changed = false;
-    
+
     protected NodeFactory getNodeFactory() {
         if (this.nodeFactory == null) {
-            try {
-                this.nodeFactory = (NodeFactory) manager.lookup(NodeFactory.ROLE);
-            } catch (ServiceException e) {
-                throw new RuntimeException("Creating repository node failed: ", e);
-            }
+            this.nodeFactory = (NodeFactory) WebAppContextUtils.getCurrentWebApplicationContext()
+                    .getBean(NodeFactory.ROLE);
         }
         return this.nodeFactory;
     }
@@ -421,7 +410,7 @@
     protected int getRevision() {
         return this.revision;
     }
-    
+
     protected void setRevision(int revision) {
         this.revision = revision;
     }

Modified: lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree2/TreeSiteManager.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree2/TreeSiteManager.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree2/TreeSiteManager.java (original)
+++ lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree2/TreeSiteManager.java Fri Feb  6 17:55:28 2009
@@ -54,7 +54,7 @@
 
         String key = getKey(area);
         SiteTree sitetree;
-        RepositoryItemFactory factory = new SiteTreeFactory(this.manager, getLogger());
+        RepositoryItemFactory factory = new SiteTreeFactory(getLogger());
         try {
             sitetree = (SiteTree) area.getPublication().getFactory().getSession()
                     .getRepositoryItem(factory, key);
@@ -230,7 +230,7 @@
 
     public SiteNode[] getRequiringResources(DocumentFactory map, SiteNode resource)
             throws SiteException {
-        NodeSet nodes = new NodeSet(this.manager);
+        NodeSet nodes = new NodeSet();
         SiteTree tree = (SiteTree) resource.getStructure();
 
         TreeNode node = (TreeNode) tree.getNode(resource.getPath());

Modified: lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/usecases/Nudge.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/usecases/Nudge.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/usecases/Nudge.java (original)
+++ lenya/trunk/org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/usecases/Nudge.java Fri Feb  6 17:55:28 2009
@@ -17,11 +17,9 @@
  */
 package org.apache.lenya.cms.site.usecases;
 
-import org.apache.avalon.framework.service.ServiceSelector;
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.repository.Node;
-import org.apache.lenya.cms.site.SiteManager;
 import org.apache.lenya.cms.site.SiteStructure;
 import org.apache.lenya.cms.site.tree.SiteTree;
 import org.apache.lenya.cms.site.tree.SiteTreeNode;
@@ -60,14 +58,8 @@
         }
 
         Publication publication = doc.getPublication();
-
-        ServiceSelector selector = null;
-        SiteManager siteManager = null;
         try {
-            selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE + "Selector");
-            siteManager = (SiteManager) selector.select(publication.getSiteManagerHint());
-            SiteStructure structure = siteManager.getSiteStructure(doc.getFactory(), publication,
-                    doc.getArea());
+            SiteStructure structure = publication.getArea(doc.getArea()).getSite();
             if (structure instanceof SiteTree) {
 
                 SiteTreeNode node = (SiteTreeNode) doc.getLink().getNode();
@@ -90,13 +82,6 @@
             }
         } catch (Exception e) {
             throw new RuntimeException(e);
-        } finally {
-            if (selector != null) {
-                if (siteManager != null) {
-                    selector.release(siteManager);
-                }
-                this.manager.release(selector);
-            }
         }
     }
 
@@ -105,7 +90,7 @@
      */
     protected Node[] getNodesToLock() throws UsecaseException {
         Node[] nodes = new Node[0];
-        if(getSourceDocument() != null) {
+        if (getSourceDocument() != null) {
             Node node = getSourceDocument().area().getSite().getRepositoryNode();
             nodes = new Node[] { node };
         }
@@ -119,13 +104,8 @@
         super.doExecute();
 
         Publication publication = getSourceDocument().getPublication();
-        ServiceSelector selector = null;
-        SiteManager siteManager = null;
         try {
-            selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE + "Selector");
-            siteManager = (SiteManager) selector.select(publication.getSiteManagerHint());
-            SiteStructure structure = siteManager.getSiteStructure(
-                    getSourceDocument().getFactory(), publication, getSourceDocument().getArea());
+            SiteStructure structure = publication.getArea(getSourceDocument().getArea()).getSite();
             if (structure instanceof SiteTree) {
 
                 SiteTree tree = (SiteTree) structure;
@@ -143,13 +123,6 @@
             }
         } catch (Exception e) {
             throw new RuntimeException(e);
-        } finally {
-            if (selector != null) {
-                if (siteManager != null) {
-                    selector.release(siteManager);
-                }
-                this.manager.release(selector);
-            }
         }
 
     }

Modified: lenya/trunk/org.apache.lenya.module.tinymce/src/main/java/org/apache/lenya/cms/editors/tinymce/TinyMce.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.tinymce/src/main/java/org/apache/lenya/cms/editors/tinymce/TinyMce.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.tinymce/src/main/java/org/apache/lenya/cms/editors/tinymce/TinyMce.java (original)
+++ lenya/trunk/org.apache.lenya.module.tinymce/src/main/java/org/apache/lenya/cms/editors/tinymce/TinyMce.java Fri Feb  6 17:55:28 2009
@@ -15,7 +15,6 @@
  limitations under the License.
  */
 
-
 package org.apache.lenya.cms.editors.tinymce;
 
 import java.io.FileNotFoundException;
@@ -24,10 +23,9 @@
 import java.io.UnsupportedEncodingException;
 import java.io.Writer;
 
+import javax.servlet.http.HttpServletRequest;
 import javax.xml.parsers.ParserConfigurationException;
 
-import org.apache.cocoon.components.ContextHelper;
-import org.apache.cocoon.environment.Request;
 import org.apache.lenya.cms.cocoon.source.SourceUtil;
 import org.apache.lenya.cms.linking.LinkConverter;
 import org.apache.lenya.cms.publication.ResourceType;
@@ -45,8 +43,8 @@
 /**
  * TinyMce Usecase
  * 
- * since there is no really tinymce-specific code in here, most methods should
- * eventually be moved into DocumentUsecase and shared across all editor usecases.
+ * since there is no really tinymce-specific code in here, most methods should eventually be moved
+ * into DocumentUsecase and shared across all editor usecases.
  */
 
 public class TinyMce extends DocumentUsecase {
@@ -65,7 +63,7 @@
     protected void initParameters() {
         super.initParameters();
 
-        Request request = ContextHelper.getRequest(this.context);
+        HttpServletRequest request = getRequest();
         setParameter("host", "http://" + request.getServerName() + ":" + request.getServerPort());
         setParameter("requesturi", request.getRequestURI());
     }
@@ -75,8 +73,7 @@
      */
     protected void doCheckPreconditions() throws Exception {
         super.doCheckPreconditions();
-        UsecaseWorkflowHelper.checkWorkflow(this.manager, this, getEvent(), getSourceDocument(),
-                getLogger());
+        UsecaseWorkflowHelper.checkWorkflow(this, getEvent(), getSourceDocument(), getLogger());
     }
 
     /**
@@ -95,9 +92,7 @@
     }
 
     protected String getEncoding() {
-        Request request = ContextHelper.getRequest(this.context);
-        String encoding = request.getCharacterEncoding();
-        return encoding;
+        return getRequest().getCharacterEncoding();
     }
 
     protected String getXmlString(String encoding) {
@@ -114,7 +109,6 @@
         return content;
     }
 
-
     public void advance() throws UsecaseException {
         clearErrorMessages();
         try {
@@ -146,7 +140,7 @@
     protected void validate(Document xml) throws Exception {
         ResourceType resourceType = getSourceDocument().getResourceType();
         Schema schema = resourceType.getSchema();
-        ValidationUtil.validate(this.manager, xml, schema, new UsecaseErrorHandler(this));
+        ValidationUtil.validate(xml, schema, new UsecaseErrorHandler(this));
     }
 
     protected Document getXml() throws ParserConfigurationException, IOException {
@@ -162,11 +156,10 @@
         return xml;
     }
 
-   /**
-     * Save the content to the document source. After saving, the XML is
-     * validated. If validation errors occur, the usecase transaction is rolled
-     * back, so the changes are not persistent. If the validation succeeded, the
-     * workflow event is invoked.
+    /**
+     * Save the content to the document source. After saving, the XML is validated. If validation
+     * errors occur, the usecase transaction is rolled back, so the changes are not persistent. If
+     * the validation succeeded, the workflow event is invoked.
      * @param encoding The encoding to use.
      * @param content The content to save.
      * @throws Exception if an error occurs.
@@ -174,10 +167,10 @@
     protected void saveDocument(String encoding, String content) throws Exception {
         org.apache.lenya.cms.publication.Document doc = getSourceDocument();
         saveXMLFile(encoding, content, doc);
-        LinkConverter converter = new LinkConverter(this.manager, getLogger());
+        LinkConverter converter = new LinkConverter(getLogger());
         converter.convertUrlsToUuids(doc, false);
 
-        WorkflowUtil.invoke(this.manager, getLogger(), doc, getEvent());
+        WorkflowUtil.invoke(getLogger(), doc, getEvent());
     }
 
     /**
@@ -190,8 +183,8 @@
      * @throws IOException if an IO error occurs
      */
     private void saveXMLFile(String encoding, String content,
-            org.apache.lenya.cms.publication.Document document)
-            throws FileNotFoundException, UnsupportedEncodingException, IOException {
+            org.apache.lenya.cms.publication.Document document) throws FileNotFoundException,
+            UnsupportedEncodingException, IOException {
         Writer writer = null;
 
         try {
@@ -237,11 +230,11 @@
      * @param content The content to add them to
      * @return The content with the added namespaces
      */
-/*    private String addNamespaces(String namespaces, String content) {
-        int i = content.indexOf(">");
-        return content.substring(0, i) + " " + namespaces + content.substring(i);
-    }
-*/
+    /*
+     * private String addNamespaces(String namespaces, String content) { int i =
+     * content.indexOf(">"); return content.substring(0, i) + " " + namespaces +
+     * content.substring(i); }
+     */
 
     protected String getEvent() {
         return "edit";

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

Modified: lenya/trunk/org.apache.lenya.module.usecasedocument/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/UsecaseDocumentModule.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.usecasedocument/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/UsecaseDocumentModule.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.usecasedocument/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/UsecaseDocumentModule.java (original)
+++ lenya/trunk/org.apache.lenya.module.usecasedocument/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/UsecaseDocumentModule.java Fri Feb  6 17:55:28 2009
@@ -23,21 +23,24 @@
 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.cocoon.components.modules.input.AbstractInputModule;
 import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.cocoon.environment.Request;
 import org.apache.lenya.cms.publication.Document;
-import org.apache.lenya.cms.publication.DocumentUtil;
+import org.apache.lenya.cms.publication.Repository;
+import org.apache.lenya.cms.publication.Session;
 import org.apache.lenya.cms.site.usecases.CreateUsecaseDocument;
+import org.apache.lenya.util.ServletHelper;
 import org.apache.lenya.xml.DocumentHelper;
 
 /**
  * Module to retrieve information from a usecase resource type document.
  */
-public class UsecaseDocumentModule extends AbstractInputModule implements Serviceable {
+public class UsecaseDocumentModule extends AbstractInputModule {
 
     protected static final String USECASE = "usecase";
+    
+    private Repository repository;
 
     public Object getAttribute(String name, Configuration modeConf, Map objectModel)
             throws ConfigurationException {
@@ -46,7 +49,9 @@
         try {
             if (name.equals(USECASE)) {
                 Request request = ObjectModelHelper.getRequest(objectModel);
-                Document doc = DocumentUtil.getCurrentDocument(this.manager, request);
+                Session session = this.repository.getSession(request);
+                String webappUrl = ServletHelper.getWebappURI(request);
+                Document doc = session.getDocumentFactory().getFromURL(webappUrl);
                 org.w3c.dom.Document xmlDoc = DocumentHelper.readDocument(doc.getInputStream());
                 String usecaseName = xmlDoc.getDocumentElement().getAttribute(CreateUsecaseDocument.ATTRIBUTE_NAME);
                 value = usecaseName;
@@ -63,4 +68,8 @@
         this.manager = manager;
     }
 
+    public void setRepository(Repository repository) {
+        this.repository = repository;
+    }
+
 }

Modified: lenya/trunk/org.apache.lenya.module.usecasedocument/src/main/java/org/apache/lenya/cms/site/usecases/CreateUsecaseDocument.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.usecasedocument/src/main/java/org/apache/lenya/cms/site/usecases/CreateUsecaseDocument.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.usecasedocument/src/main/java/org/apache/lenya/cms/site/usecases/CreateUsecaseDocument.java (original)
+++ lenya/trunk/org.apache.lenya.module.usecasedocument/src/main/java/org/apache/lenya/cms/site/usecases/CreateUsecaseDocument.java Fri Feb  6 17:55:28 2009
@@ -37,6 +37,7 @@
 
     protected static final String USECASE = "usecase";
     protected static final String RESOURCE_TYPE_USECASE = "usecase";
+    private UsecaseResolver usecaseResolver;
 
     /**
      * The namespace for usecase document content.
@@ -52,7 +53,7 @@
      * The local name of the name attribute.
      */
     public static final String ATTRIBUTE_NAME = "name";
-    
+
     protected void initParameters() {
         super.initParameters();
         setParameter(DOCUMENT_TYPE, RESOURCE_TYPE_USECASE);
@@ -66,16 +67,8 @@
         if (usecaseName.equals("")) {
             addErrorMessage("Please enter a usecase name.");
         } else {
-            UsecaseResolver resolver = null;
-            try {
-                resolver = (UsecaseResolver) this.manager.lookup(UsecaseResolver.ROLE);
-                if (!resolver.isRegistered(getSourceURL(), usecaseName)) {
-                    addErrorMessage("The usecase '" + usecaseName + "' is not registered.");
-                }
-            } finally {
-                if (resolver != null) {
-                    this.manager.release(resolver);
-                }
+            if (!getUsecaseResolver().isRegistered(getSourceURL(), usecaseName)) {
+                addErrorMessage("The usecase '" + usecaseName + "' is not registered.");
             }
         }
     }
@@ -90,4 +83,15 @@
 
     }
 
+    /**
+     * TODO: Bean wiring
+     */
+    public void setUsecaseResolver(UsecaseResolver usecaseResolver) {
+        this.usecaseResolver = usecaseResolver;
+    }
+
+    public UsecaseResolver getUsecaseResolver() {
+        return usecaseResolver;
+    }
+
 }

Modified: lenya/trunk/org.apache.lenya.module.webdav/src/main/java/org/apache/lenya/cms/usecases/webdav/FilePropfind.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.webdav/src/main/java/org/apache/lenya/cms/usecases/webdav/FilePropfind.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.webdav/src/main/java/org/apache/lenya/cms/usecases/webdav/FilePropfind.java (original)
+++ lenya/trunk/org.apache.lenya.module.webdav/src/main/java/org/apache/lenya/cms/usecases/webdav/FilePropfind.java Fri Feb  6 17:55:28 2009
@@ -21,9 +21,6 @@
 import java.util.Vector;
 
 import org.apache.lenya.cms.publication.Document;
-import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.PublicationException;
-import org.apache.lenya.cms.publication.PublicationUtil;
 import org.apache.lenya.cms.publication.URLInformation;
 import org.apache.lenya.cms.repository.Node;
 import org.apache.lenya.cms.site.usecases.SiteUsecase;
@@ -97,27 +94,4 @@
         }
         return document;
     }
-
-    private Publication publication;
-
-    /**
-     * Access to the current publication. Use this when the publication is not yet known in the
-     * usecase: e.g. when creating a global asset. When adding a resource or a child to a document,
-     * access the publication via that document's interface instead.
-     * 
-     * @return the publication in which the use-case is being executed
-     */
-    protected Publication getPublication() {
-        if (this.publication == null) {
-            try {
-                this.publication = PublicationUtil.getPublicationFromUrl(this.manager,
-                        getDocumentFactory(),
-                        getSourceURL());
-            } catch (PublicationException e) {
-                throw new RuntimeException(e);
-            }
-        }
-        return this.publication;
-    }
-
 }

Modified: lenya/trunk/org.apache.lenya.module.webdav/src/main/java/org/apache/lenya/cms/usecases/webdav/Mkcol.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.webdav/src/main/java/org/apache/lenya/cms/usecases/webdav/Mkcol.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.webdav/src/main/java/org/apache/lenya/cms/usecases/webdav/Mkcol.java (original)
+++ lenya/trunk/org.apache.lenya.module.webdav/src/main/java/org/apache/lenya/cms/usecases/webdav/Mkcol.java Fri Feb  6 17:55:28 2009
@@ -19,7 +19,6 @@
 
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.service.ServiceSelector;
 import org.apache.excalibur.source.SourceResolver;
 import org.apache.lenya.cms.metadata.MetaData;
 import org.apache.lenya.cms.metadata.MetaDataException;
@@ -28,6 +27,7 @@
 import org.apache.lenya.cms.publication.DocumentFactory;
 import org.apache.lenya.cms.publication.DocumentManager;
 import org.apache.lenya.cms.publication.ResourceType;
+import org.apache.lenya.cms.publication.ResourceTypeResolver;
 import org.apache.lenya.cms.site.usecases.Create;
 
 /**
@@ -41,8 +41,14 @@
     protected static final String ATTRIBUTE_TYPE = "resource-type";
     protected static final String ELEMENT_EXTENSION = "extension";
 
+    private SourceResolver sourceResolver;
+    private DocumentManager documentManager;
+    private ResourceTypeResolver resourceTypeResolver;
+
+    /**
+     * TODO: Spring bean config
+     */
     public void configure(Configuration config) throws ConfigurationException {
-        super.configure(config);
         Configuration typeConfig = config.getChild(ELEMENT_EXTENSION, false);
         if (typeConfig != null) {
             this.EXTENSION = typeConfig.getValue();
@@ -55,53 +61,26 @@
      */
     protected void doExecute() throws Exception {
         // super.doExecute();
-        SourceResolver resolver = null;
+        SourceResolver resolver = getSourceResolver();
         ResourceType resourceType = null;
 
-        try {
-            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
+        Document doc = getSourceDocument();
+        // sanity check
+        if (doc == null)
+            throw new IllegalArgumentException("illegal usage, source document may not be null");
+
+        if (!doc.exists()) {
+
+            DocumentFactory map = getDocumentFactory();
+            String path = doc.getPath();
+
+            resourceType = getResourceTypeResolver().getResourceType(TYPE);
+            ResourceType.Sample sample = resourceType.getSample(resourceType.getSampleNames()[0]);
+            doc = getDocumentManager().add(map, resourceType, sample.getUri(), getPublication(),
+                    doc.getArea(), path, doc.getLanguage(), EXTENSION, doc.getName(), true);
+            doc.setMimeType(sample.getMimeType());
 
-            Document doc = getSourceDocument();
-            // sanity check
-            if (doc == null)
-                throw new IllegalArgumentException("illegal usage, source document may not be null");
-
-            if (!doc.exists()) {
-                DocumentManager documentManager = null;
-                ServiceSelector selector = null;
-                try {
-                    selector = (ServiceSelector) this.manager
-                            .lookup(ResourceType.ROLE + "Selector");
-
-                    documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
-
-                    DocumentFactory map = getDocumentFactory();
-                    String path = doc.getPath();
-
-                    resourceType = (ResourceType) selector.select(TYPE);
-                    ResourceType.Sample sample = resourceType.getSample(resourceType.getSampleNames()[0]);
-                    doc = documentManager.add(map, resourceType, sample.getUri(), getPublication(), doc
-                            .getArea(), path, doc.getLanguage(), EXTENSION, doc.getName(), true);
-                    doc.setMimeType(sample.getMimeType());
-
-                    setMetaData(doc);
-                } finally {
-                    if (documentManager != null) {
-                        this.manager.release(documentManager);
-                    }
-                    if (selector != null) {
-                        if (resourceType != null) {
-                            selector.release(resourceType);
-                        }
-                        this.manager.release(selector);
-                    }
-                }
-            }
-
-        } finally {
-            if (resolver != null) {
-                this.manager.release(resolver);
-            }
+            setMetaData(doc);
         }
     }
 
@@ -149,4 +128,37 @@
         return false;
     }
 
+    /**
+     * TODO: Bean wiring
+     */
+    public void setSourceResolver(SourceResolver sourceResolver) {
+        this.sourceResolver = sourceResolver;
+    }
+
+    public SourceResolver getSourceResolver() {
+        return sourceResolver;
+    }
+
+    public DocumentManager getDocumentManager() {
+        return documentManager;
+    }
+
+    /**
+     * TODO: Bean wiring
+     */
+    public void setDocumentManager(DocumentManager documentManager) {
+        this.documentManager = documentManager;
+    }
+
+    public ResourceTypeResolver getResourceTypeResolver() {
+        return resourceTypeResolver;
+    }
+
+    /**
+     * TODO: Bean wiring
+     */
+    public void setResourceTypeResolver(ResourceTypeResolver resourceTypeResolver) {
+        this.resourceTypeResolver = resourceTypeResolver;
+    }
+
 }

Modified: lenya/trunk/org.apache.lenya.module.webdav/src/main/java/org/apache/lenya/cms/usecases/webdav/Propfind.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.webdav/src/main/java/org/apache/lenya/cms/usecases/webdav/Propfind.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.webdav/src/main/java/org/apache/lenya/cms/usecases/webdav/Propfind.java (original)
+++ lenya/trunk/org.apache.lenya.module.webdav/src/main/java/org/apache/lenya/cms/usecases/webdav/Propfind.java Fri Feb  6 17:55:28 2009
@@ -21,13 +21,9 @@
 import java.util.Date;
 import java.util.Vector;
 
-import org.apache.avalon.framework.service.ServiceSelector;
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.PublicationException;
-import org.apache.lenya.cms.publication.PublicationUtil;
 import org.apache.lenya.cms.repository.Node;
-import org.apache.lenya.cms.site.SiteManager;
 import org.apache.lenya.cms.site.usecases.SiteUsecase;
 
 /**
@@ -55,10 +51,8 @@
     protected void initParameters() {
         super.initParameters();
 
-        Publication _publication = this.getPublication();
+        Publication pub = this.getPublication();
 
-        ServiceSelector siteManagerSelector = null;
-        SiteManager siteManager = null;
         Vector docs = new Vector();
         Vector checkedOut = new Vector();
 
@@ -72,12 +66,7 @@
         }
         try {
 
-            siteManagerSelector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE
-                    + "Selector");
-            siteManager = (SiteManager) siteManagerSelector.select(_publication.getSiteManagerHint());
-            Document[] documents = siteManager.getDocuments(getDocumentFactory(),
-                    _publication,
-                    Publication.AUTHORING_AREA);
+            Document[] documents = pub.getArea(Publication.AUTHORING_AREA).getDocuments();
 
             for (int i = 0; i < documents.length; i++) {
                 String test = documents[i].getCanonicalWebappURL().replaceFirst("/[^/]*.html", "");
@@ -103,18 +92,11 @@
             setParameter(DATEFORMAT, format);
             Date rootModDate = new Date();
             setParameter("rootModDate", rootModDate);
-            String defaultLang = _publication.getDefaultLanguage();
+            String defaultLang = pub.getDefaultLanguage();
             setParameter("defaultLang", defaultLang);
 
         } catch (Exception e) {
             throw new RuntimeException(e);
-        } finally {
-            if (siteManagerSelector != null) {
-                if (siteManager != null) {
-                    siteManagerSelector.release(siteManager);
-                }
-                this.manager.release(siteManagerSelector);
-            }
         }
     }
 
@@ -125,26 +107,4 @@
         return Publication.AUTHORING_AREA;
     }
 
-    private Publication publication;
-
-    /**
-     * Access to the current publication. Use this when the publication is not yet known in the
-     * usecase: e.g. when creating a global asset. When adding a resource or a child to a document,
-     * access the publication via that document's interface instead.
-     * 
-     * @return the publication in which the use-case is being executed
-     */
-    protected Publication getPublication() {
-        if (this.publication == null) {
-            try {
-                this.publication = PublicationUtil.getPublicationFromUrl(this.manager,
-                        getDocumentFactory(),
-                        getSourceURL());
-            } catch (PublicationException e) {
-                throw new RuntimeException(e);
-            }
-        }
-        return this.publication;
-    }
-
 }

Modified: lenya/trunk/org.apache.lenya.module.webdav/src/main/java/org/apache/lenya/cms/usecases/webdav/Put.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.webdav/src/main/java/org/apache/lenya/cms/usecases/webdav/Put.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.webdav/src/main/java/org/apache/lenya/cms/usecases/webdav/Put.java (original)
+++ lenya/trunk/org.apache.lenya.module.webdav/src/main/java/org/apache/lenya/cms/usecases/webdav/Put.java Fri Feb  6 17:55:28 2009
@@ -23,8 +23,6 @@
 
 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.ServiceSelector;
 import org.apache.excalibur.source.SourceResolver;
 import org.apache.lenya.cms.cocoon.source.SourceUtil;
 import org.apache.lenya.cms.metadata.MetaData;
@@ -33,10 +31,8 @@
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.DocumentFactory;
 import org.apache.lenya.cms.publication.DocumentManager;
-import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.PublicationException;
-import org.apache.lenya.cms.publication.PublicationUtil;
 import org.apache.lenya.cms.publication.ResourceType;
+import org.apache.lenya.cms.publication.ResourceTypeResolver;
 import org.apache.lenya.cms.repository.Node;
 import org.apache.lenya.cms.site.NodeSet;
 import org.apache.lenya.cms.site.SiteStructure;
@@ -55,7 +51,7 @@
  * @version $Id: $
  */
 public class Put extends CreateDocument {
-    
+
     // registeredExtensions contain all known extension matching to a certain resource-type.
     private HashMap registeredExtensions = new HashMap();
     // default is xhtml and xml but you can override it with the config
@@ -65,11 +61,16 @@
     protected static final String ELEMENT_ROOT = "extensions";
     protected static final String ELEMENT_EXTENSION = "extension";
     protected static final String EVENT = "lenya.event";
-    
+
     private boolean fallback = false;
+    private SourceResolver sourceResolver;
+    private ResourceTypeResolver resourceTypeResolver;
+    private DocumentManager documentManager;
 
+    /**
+     * TODO: Spring bean configuration
+     */
     public void configure(Configuration config) throws ConfigurationException {
-        super.configure(config);
         Configuration extensionsConfig = config.getChild(ELEMENT_ROOT, false);
         if (extensionsConfig != null) {
             Configuration[] extensions = extensionsConfig.getChildren(ELEMENT_EXTENSION);
@@ -89,8 +90,7 @@
         String event = getParameterAsString(EVENT);
         if (event != null) {
             Document doc = getSourceDocument();
-            UsecaseWorkflowHelper.checkWorkflow(this.manager, this, event, doc,
-                    getLogger());
+            UsecaseWorkflowHelper.checkWorkflow(this, event, doc, getLogger());
         }
     }
 
@@ -98,92 +98,63 @@
      * @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
      */
     protected void doExecute() throws Exception {
-        SourceResolver resolver = null;
+        SourceResolver resolver = getSourceResolver();
 
-        try {
-            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
-
-            Document doc = getSourceDocument();
-            String extension = getSourceExtension();
-            // sanity check
-            if (doc == null)
-                throw new IllegalArgumentException("illegal usage, source document may not be null");
-
-            // create new doc from PUT input
-            if (!doc.exists()) {
-                DocumentManager documentManager = null;
-                ServiceSelector selector = null;
-                ResourceType resourceType = null;
-                try {
-                    selector = (ServiceSelector) this.manager
-                            .lookup(ResourceType.ROLE + "Selector");
-
-                    documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
-
-                    DocumentFactory map = getDocumentFactory();
-                    String path = doc.getPath();
-                    // lookupResourceType(extension)
-                    resourceType = lookUpExtension(extension, selector);
-                    ResourceType.Sample sample = resourceType.getSample(resourceType.getSampleNames()[0]);
-                    doc = documentManager.add(map, resourceType, sample.getUri(), getPublication(), doc
-                            .getArea(), path, doc.getLanguage(), extension, doc.getName(), true);
-                    doc.setMimeType(sample.getMimeType());
-                    setMetaData(doc);
-                } finally {
-                    if (documentManager != null) {
-                        this.manager.release(documentManager);
-                    }
-                    if (selector != null) {
-                        if (resourceType != null) {
-                            selector.release(resourceType);
-                        }
-                        this.manager.release(selector);
-                    }
-                }
-            }
-
-            String sourceUri = "cocoon:/request/PUT/" + extension;
-            org.w3c.dom.Document xmlDoc = SourceUtil.readDOM(sourceUri, manager);
-
-            // validate if a schema is provided and we are not using any fallback
-            if (doc.getResourceType().getSchema() != null & fallback == false) {
-                validateDoc(resolver, xmlDoc, doc);
-            }
-
-            if (!hasErrors()) {
-                try {
-                    DocumentHelper.writeDocument(xmlDoc, doc.getOutputStream());
-                } catch (Exception e) {
-                    addErrorMessage("invalid source xml. Full exception: " + e);
-                }
-            }
+        Document doc = getSourceDocument();
+        String extension = getSourceExtension();
+        // sanity check
+        if (doc == null)
+            throw new IllegalArgumentException("illegal usage, source document may not be null");
+
+        // create new doc from PUT input
+        if (!doc.exists()) {
+            DocumentFactory map = getDocumentFactory();
+            String path = doc.getPath();
+            ResourceType resourceType = lookUpExtension(extension);
+            ResourceType.Sample sample = resourceType.getSample(resourceType.getSampleNames()[0]);
+            doc = getDocumentManager().add(map, resourceType, sample.getUri(), getPublication(),
+                    doc.getArea(), path, doc.getLanguage(), extension, doc.getName(), true);
+            doc.setMimeType(sample.getMimeType());
+            setMetaData(doc);
+        }
+
+        String sourceUri = "cocoon:/request/PUT/" + extension;
+        org.w3c.dom.Document xmlDoc = SourceUtil.readDOM(sourceUri, getSourceResolver());
+
+        // validate if a schema is provided and we are not using any fallback
+        if (doc.getResourceType().getSchema() != null & fallback == false) {
+            validateDoc(resolver, xmlDoc, doc);
+        }
 
-            String event = getParameterAsString(EVENT);
-            if (event != null) {
-                WorkflowUtil.invoke(this.manager, getLogger(), doc, event);
+        if (!hasErrors()) {
+            try {
+                DocumentHelper.writeDocument(xmlDoc, doc.getOutputStream());
+            } catch (Exception e) {
+                addErrorMessage("invalid source xml. Full exception: " + e);
             }
+        }
 
-        } finally {
-            if (resolver != null) {
-                this.manager.release(resolver);
-            }
+        String event = getParameterAsString(EVENT);
+        if (event != null) {
+            WorkflowUtil.invoke(getLogger(), doc, event);
         }
+
     }
 
-    private ResourceType lookUpExtension(String extension, ServiceSelector selector)
-            throws ServiceException {
+    private ResourceType lookUpExtension(String extension) {
         ResourceType resourceType;
         String resourceTypeName = (String) registeredExtensions.get(extension);
         if (resourceTypeName == null || resourceTypeName.equals("")) {
             resourceTypeName = (String) registeredExtensions.get(this.EXTENSION);
             this.fallback = true;
         }
-        if (selector.isSelectable(resourceTypeName)) {
-            resourceType = (ResourceType) selector.select(resourceTypeName);
+        ResourceTypeResolver resolver = getResourceTypeResolver();
+        if (resolver.existsResourceType(resourceTypeName)) {
+            resourceType = (ResourceType) resolver.getResourceType(resourceTypeName);
         } else {
             // using a fallback resource type
             // FIXME this resource tye should be a more generic one like "media-assets" or "bin"
-            resourceType = (ResourceType) selector.select(this.TYPE);
+            resourceType = (ResourceType) resolver.getResourceType(this.TYPE);
             this.fallback = true;
         }
         return resourceType;
@@ -193,7 +164,7 @@
             throws Exception {
         ResourceType resourceType = doc.getResourceType();
         Schema schema = resourceType.getSchema();
-        ValidationUtil.validate(this.manager, xmlDoc, schema, new UsecaseErrorHandler(this));
+        ValidationUtil.validate(xmlDoc, schema, new UsecaseErrorHandler(this));
     }
 
     /**
@@ -204,7 +175,7 @@
             Document doc = getSourceDocument();
             List nodes = new ArrayList();
 
-            NodeSet set = SiteUtil.getSubSite(this.manager, doc.getLink().getNode());
+            NodeSet set = SiteUtil.getSubSite(doc.getLink().getNode());
             Document[] documents = set.getDocuments();
             for (int i = 0; i < documents.length; i++) {
                 nodes.add(documents[i].getRepositoryNode());
@@ -240,27 +211,6 @@
         dcMetaData.setValue(DublinCore.ELEMENT_LANGUAGE, document.getLanguage());
     }
 
-    private Publication publication;
-
-    /**
-     * Access to the current publication. Use this when the publication is not yet known in the
-     * usecase: e.g. when creating a global asset. When adding a resource or a child to a document,
-     * access the publication via that document's interface instead.
-     * 
-     * @return the publication in which the use-case is being executed
-     */
-    protected Publication getPublication() {
-        if (this.publication == null) {
-            try {
-                this.publication = PublicationUtil.getPublicationFromUrl(this.manager,
-                        getDocumentFactory(), getSourceURL());
-            } catch (PublicationException e) {
-                throw new RuntimeException(e);
-            }
-        }
-        return this.publication;
-    }
-
     protected String getSourceExtension() {
         String destinationUri = getParameterAsString(SOURCE_URL);
         String extension = null;
@@ -288,21 +238,40 @@
     }
 
     protected String getDocumentTypeName() {
-        ResourceType resourceType = null;
-        ServiceSelector selector = null;
-        String docType = "";
-        try {
-            selector = (ServiceSelector) this.manager.lookup(ResourceType.ROLE + "Selector");
-            resourceType = lookUpExtension(getSourceExtension(), selector);
-            docType = resourceType.getName();
-        } catch (ServiceException e) {
-            throw new RuntimeException(e);
-        } finally {
-            if (selector != null) {
-                this.manager.release(selector);
-            }
-        }
-        return docType;
+        return lookUpExtension(getSourceExtension()).getName();
+    }
+
+    /**
+     * TODO: Bean wiring
+     */
+    public void setSourceResolver(SourceResolver sourceResolver) {
+        this.sourceResolver = sourceResolver;
+    }
+
+    public SourceResolver getSourceResolver() {
+        return sourceResolver;
+    }
+
+    public ResourceTypeResolver getResourceTypeResolver() {
+        return resourceTypeResolver;
+    }
+
+    /**
+     * TODO: Bean wiring
+     */
+    public void setResourceTypeResolver(ResourceTypeResolver resourceTypeResolver) {
+        this.resourceTypeResolver = resourceTypeResolver;
+    }
+
+    public DocumentManager getDocumentManager() {
+        return documentManager;
+    }
+
+    /**
+     * TODO: Bean wiring
+     */
+    public void setDocumentManager(DocumentManager documentManager) {
+        this.documentManager = documentManager;
     }
 
 }

Modified: lenya/trunk/org.apache.lenya.optional.jcrsource/src/main/java/org/apache/lenya/cms/jcr/JCRNodeFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.optional.jcrsource/src/main/java/org/apache/lenya/cms/jcr/JCRNodeFactory.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.optional.jcrsource/src/main/java/org/apache/lenya/cms/jcr/JCRNodeFactory.java (original)
+++ lenya/trunk/org.apache.lenya.optional.jcrsource/src/main/java/org/apache/lenya/cms/jcr/JCRNodeFactory.java Fri Feb  6 17:55:28 2009
@@ -17,10 +17,8 @@
  */
 package org.apache.lenya.cms.jcr;
 
-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.util.AbstractLogEnabled;
+import org.apache.excalibur.source.SourceResolver;
 import org.apache.lenya.cms.repository.Node;
 import org.apache.lenya.cms.repository.NodeFactory;
 import org.apache.lenya.cms.repository.RepositoryException;
@@ -30,21 +28,17 @@
 /**
  * JCR node factory.
  */
-public class JCRNodeFactory extends AbstractLogEnabled implements NodeFactory, Serviceable {
+public class JCRNodeFactory extends AbstractLogEnabled implements NodeFactory {
+    
+    private SourceResolver sourceResolver;
 
     public RepositoryItem buildItem(Session session, String key) throws RepositoryException {
-        return new JCRSourceNode(this.session, key, this.manager, getLogger());
+        return new JCRSourceNode(this.session, key, getSourceResolver(), getLogger());
     }
 
     public String getItemType() {
         return Node.IDENTIFIABLE_TYPE;
     }
-
-    private ServiceManager manager;
-
-    public void service(ServiceManager manager) throws ServiceException {
-        this.manager = manager;
-    }
     
     private Session session;
 
@@ -56,4 +50,12 @@
         return false;
     }
 
+    public void setSourceResolver(SourceResolver sourceResolver) {
+        this.sourceResolver = sourceResolver;
+    }
+
+    public SourceResolver getSourceResolver() {
+        return sourceResolver;
+    }
+
 }
\ No newline at end of file

Modified: lenya/trunk/org.apache.lenya.optional.jcrsource/src/main/java/org/apache/lenya/cms/jcr/JCRSourceNode.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.optional.jcrsource/src/main/java/org/apache/lenya/cms/jcr/JCRSourceNode.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.optional.jcrsource/src/main/java/org/apache/lenya/cms/jcr/JCRSourceNode.java (original)
+++ lenya/trunk/org.apache.lenya.optional.jcrsource/src/main/java/org/apache/lenya/cms/jcr/JCRSourceNode.java Fri Feb  6 17:55:28 2009
@@ -17,8 +17,8 @@
  */
 package org.apache.lenya.cms.jcr;
 
-import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.commons.logging.Log;
+import org.apache.excalibur.source.SourceResolver;
 import org.apache.lenya.cms.repository.RepositoryException;
 import org.apache.lenya.cms.repository.Session;
 import org.apache.lenya.cms.repository.SourceNode;
@@ -34,11 +34,10 @@
      * Ctor.
      * @param session The session.
      * @param sourceURI The source URI.
-     * @param manager The service manager.
      * @param logger The logger.
      */
-    public JCRSourceNode(Session session, String sourceURI, ServiceManager manager, Log logger) {
-        super(session, sourceURI, manager, logger);
+    public JCRSourceNode(Session session, String sourceURI, SourceResolver resolver, Log logger) {
+        super(session, sourceURI, resolver, logger);
         this.sourceUri = sourceURI;
     }
 

Modified: lenya/trunk/org.apache.lenya.optional.jcrsource/src/main/java/org/apache/lenya/cms/jcr/usecases/Import.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.optional.jcrsource/src/main/java/org/apache/lenya/cms/jcr/usecases/Import.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.optional.jcrsource/src/main/java/org/apache/lenya/cms/jcr/usecases/Import.java (original)
+++ lenya/trunk/org.apache.lenya.optional.jcrsource/src/main/java/org/apache/lenya/cms/jcr/usecases/Import.java Fri Feb  6 17:55:28 2009
@@ -19,19 +19,16 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 
-import org.apache.avalon.framework.service.ServiceSelector;
 import org.apache.excalibur.source.SourceResolver;
 import org.apache.lenya.cms.cocoon.source.SourceUtil;
+import org.apache.lenya.cms.publication.Area;
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.DocumentFactory;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.repository.Node;
-import org.apache.lenya.cms.site.SiteManager;
 import org.apache.lenya.cms.usecase.AbstractUsecase;
 
 /**
@@ -42,6 +39,8 @@
     protected static final String PUBLICATIONS = "publications";
     protected static final String PUBLICATION = "publication";
 
+    private SourceResolver sourceResolver;
+
     protected void initParameters() {
         super.initParameters();
         Publication[] pubs = getDocumentFactory().getPublications();
@@ -53,65 +52,54 @@
         super.doExecute();
         String pubId = getParameterAsString(PUBLICATION);
         DocumentFactory factory = getDocumentFactory();
-        ServiceSelector selector = null;
-        SiteManager siteManager = null;
-        SourceResolver resolver = null;
-        try {
-            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
-            Publication pub = factory.getPublication(pubId);
-            selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE + "Selector");
-            siteManager = (SiteManager) selector.select(pub.getSiteManagerHint());
-
-            List nodes = new ArrayList();
-            Map uri2meta = new HashMap();
-
-            String[] areas = { Publication.AUTHORING_AREA, Publication.LIVE_AREA,
-                    Publication.TRASH_AREA, Publication.ARCHIVE_AREA };
-            for (int i = 0; i < areas.length; i++) {
-                Document[] docs = siteManager.getDocuments(factory, pub, areas[i]);
-                for (int j = 0; j < docs.length; j++) {
-                    nodes.add(docs[j].getRepositoryNode());
-                    /*
-                    final String lenyaUri = docs[j].getSourceURI();
-                    final String sourcePath = lenyaUri.substring("lenya://".length());
-                    final String contextUri = "context://" + sourcePath + ".meta";
-                     * MetaDataManager meta = new MetaDataManager(contextUri, this.manager,
-                     * getLogger()); uri2meta.put(docs[j].getSourceURI(), meta);
-                     */
-                }
-                nodes.add(siteManager.getSiteStructure(factory, pub, areas[i]).getRepositoryNode());
-            }
+        Publication pub = factory.getPublication(pubId);
 
-            for (Iterator i = nodes.iterator(); i.hasNext();) {
-                Node node = (Node) i.next();
-                final String lenyaUri = node.getSourceURI();
-                final String sourcePath = lenyaUri.substring("lenya://".length());
-                final String contextUri = "context://" + sourcePath;
-                final String jcrUri = "jcr://" + sourcePath;
-                if (SourceUtil.exists(contextUri, this.manager)) {
-                    SourceUtil.copy(resolver, contextUri, jcrUri);
-                    /*
-                     * MetaDataManager sourceMgr = (MetaDataManager) uri2meta.get(lenyaUri); if
-                     * (sourceMgr != null) { MetaDataManager jcrMgr = new JCRMetaDataManager(jcrUri,
-                     * this.manager, getLogger()); jcrMgr.replaceMetaData(sourceMgr); }
-                     */
-                } else {
-                    addInfoMessage("The source [" + contextUri + "] does not exist.");
-                }
-            }
+        List nodes = new ArrayList();
 
-        } finally {
-            if (selector != null) {
-                if (siteManager != null) {
-                    selector.release(siteManager);
-                }
-                this.manager.release(selector);
+        String[] areas = { Publication.AUTHORING_AREA, Publication.LIVE_AREA,
+                Publication.TRASH_AREA, Publication.ARCHIVE_AREA };
+        for (int i = 0; i < areas.length; i++) {
+            Area area = pub.getArea(areas[i]);
+            Document[] docs = area.getDocuments();
+            for (int j = 0; j < docs.length; j++) {
+                nodes.add(docs[j].getRepositoryNode());
+                /*
+                 * final String lenyaUri = docs[j].getSourceURI(); final String sourcePath =
+                 * lenyaUri.substring("lenya://".length()); final String contextUri = "context://" +
+                 * sourcePath + ".meta"; MetaDataManager meta = new MetaDataManager(contextUri,
+                 * this.manager, getLogger()); uri2meta.put(docs[j].getSourceURI(), meta);
+                 */
             }
-            if (resolver != null) {
-                this.manager.release(resolver);
+            nodes.add(area.getSite().getRepositoryNode());
+        }
+
+        for (Iterator i = nodes.iterator(); i.hasNext();) {
+            Node node = (Node) i.next();
+            final String lenyaUri = node.getSourceURI();
+            final String sourcePath = lenyaUri.substring("lenya://".length());
+            final String contextUri = "context://" + sourcePath;
+            final String jcrUri = "jcr://" + sourcePath;
+            SourceResolver resolver = getSourceResolver();
+            if (SourceUtil.exists(contextUri, resolver)) {
+                SourceUtil.copy(resolver, contextUri, jcrUri);
+                /*
+                 * MetaDataManager sourceMgr = (MetaDataManager) uri2meta.get(lenyaUri); if
+                 * (sourceMgr != null) { MetaDataManager jcrMgr = new JCRMetaDataManager(jcrUri,
+                 * this.manager, getLogger()); jcrMgr.replaceMetaData(sourceMgr); }
+                 */
+            } else {
+                addInfoMessage("The source [" + contextUri + "] does not exist.");
             }
         }
 
     }
 
+    public void setSourceResolver(SourceResolver sourceResolver) {
+        this.sourceResolver = sourceResolver;
+    }
+
+    public SourceResolver getSourceResolver() {
+        return sourceResolver;
+    }
+
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.