Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/ac/PolicyUtil.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/ac/PolicyUtil.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/ac/PolicyUtil.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/ac/PolicyUtil.java Fri Feb 6 17:55:28 2009
@@ -23,10 +23,9 @@
import java.util.Enumeration;
import java.util.List;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.ServiceSelector;
-import org.apache.cocoon.environment.Request;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
import org.apache.commons.logging.Log;
import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.ac.AccessController;
@@ -45,120 +44,83 @@
/**
* Fetches the stored roles from the request.
- * @param request The request.
+ * @param httpServletRequest The request.
* @return A role array.
- * @throws AccessControlException If the request does not contain the roles
- * list.
+ * @throws AccessControlException If the request does not contain the roles list.
*/
- public static final Role[] getRoles(Request request) throws AccessControlException {
- List roleList = (List) request.getAttribute(Role.class.getName());
+ public static final Role[] getRoles(HttpServletRequest httpServletRequest) throws AccessControlException {
+ List roleList = (List) httpServletRequest.getAttribute(Role.class.getName());
if (roleList == null) {
StringBuffer buf = new StringBuffer();
- buf.append(" URI: [" + request.getRequestURI() + "]\n");
- for (Enumeration e = request.getParameterNames(); e.hasMoreElements();) {
+ buf.append(" URI: [" + httpServletRequest.getRequestURI() + "]\n");
+ for (Enumeration e = httpServletRequest.getParameterNames(); e.hasMoreElements();) {
String key = (String) e.nextElement();
- buf.append(" Parameter: [" + key + "] = [" + request.getParameter(key) + "]\n");
+ buf.append(" Parameter: [" + key + "] = [" + httpServletRequest.getParameter(key) + "]\n");
}
- throw new AccessControlException("Request [" + request + "] does not contain roles: \n"
+ throw new AccessControlException("Request [" + httpServletRequest + "] does not contain roles: \n"
+ buf.toString());
}
Role[] roles = (Role[]) roleList.toArray(new Role[roleList.size()]);
return roles;
}
-
+
/**
- * @param manager The service manager.
* @param webappUrl The web application URL.
* @param userId The user ID.
* @param logger The logger.
* @return A user.
* @throws AccessControlException if an error occurs.
*/
- public static final User getUser(ServiceManager manager, String webappUrl,
- String userId, Log logger) throws AccessControlException {
- ServiceSelector selector = null;
- AccessControllerResolver resolver = null;
- AccessController controller = null;
- try {
- selector = (ServiceSelector) manager.lookup(AccessControllerResolver.ROLE + "Selector");
- resolver = (AccessControllerResolver) selector
- .select(AccessControllerResolver.DEFAULT_RESOLVER);
- controller = resolver.resolveAccessController(webappUrl);
-
- AccreditableManager accreditableManager = controller.getAccreditableManager();
- UserManager userManager = accreditableManager.getUserManager();
-
- return userManager.getUser(userId);
- } catch (ServiceException e) {
- throw new AccessControlException(e);
- } finally {
- if (selector != null) {
- if (resolver != null) {
- if (controller != null) {
- resolver.release(controller);
- }
- selector.release(resolver);
- }
- manager.release(selector);
- }
- }
+ public static final User getUser(String webappUrl, String userId, Log logger)
+ throws AccessControlException {
+ AccessController controller = getAccessController(webappUrl);
+ AccreditableManager accreditableManager = controller.getAccreditableManager();
+ UserManager userManager = accreditableManager.getUserManager();
+ return userManager.getUser(userId);
+ }
+
+ protected static AccessController getAccessController(String webappUrl)
+ throws AccessControlException {
+ AccessControllerResolver resolver = (AccessControllerResolver) WebAppContextUtils
+ .getCurrentWebApplicationContext().getBean(
+ AccessControllerResolver.ROLE + "/"
+ + AccessControllerResolver.DEFAULT_RESOLVER);
+ AccessController controller = resolver.resolveAccessController(webappUrl);
+ return controller;
}
/**
- * @param manager The service manager.
* @param webappUrl The web application URL.
* @param role The ID of the role.
* @param logger The logger to use.
* @return All users which have the role on this URL.
* @throws AccessControlException if an error occurs.
*/
- public static final User[] getUsersWithRole(ServiceManager manager, String webappUrl,
- String role, Log logger) throws AccessControlException {
- ServiceSelector selector = null;
- AccessControllerResolver resolver = null;
- AccessController controller = null;
- try {
- selector = (ServiceSelector) manager.lookup(AccessControllerResolver.ROLE + "Selector");
- resolver = (AccessControllerResolver) selector
- .select(AccessControllerResolver.DEFAULT_RESOLVER);
- controller = resolver.resolveAccessController(webappUrl);
-
- AccreditableManager accreditableManager = controller.getAccreditableManager();
- UserManager userManager = accreditableManager.getUserManager();
- User[] users = userManager.getUsers();
- List usersWithRole = new ArrayList();
- PolicyManager policyManager = controller.getPolicyManager();
-
- Role roleObject = accreditableManager.getRoleManager().getRole(role);
-
- for (int i = 0; i < users.length; i++) {
- Identity identity = new Identity(logger);
- identity.addIdentifiable(users[i]);
- Role[] roles = policyManager.getGrantedRoles(accreditableManager, identity,
- webappUrl);
- if (Arrays.asList(roles).contains(roleObject)) {
- usersWithRole.add(users[i]);
- }
- }
-
- return (User[]) usersWithRole.toArray(new User[usersWithRole.size()]);
- } catch (ServiceException e) {
- throw new AccessControlException(e);
- } finally {
- if (selector != null) {
- if (resolver != null) {
- if (controller != null) {
- resolver.release(controller);
- }
- selector.release(resolver);
- }
- manager.release(selector);
+ public static final User[] getUsersWithRole(String webappUrl, String role, Log logger)
+ throws AccessControlException {
+ AccessController controller = getAccessController(webappUrl);
+ AccreditableManager accreditableManager = controller.getAccreditableManager();
+ UserManager userManager = accreditableManager.getUserManager();
+ User[] users = userManager.getUsers();
+ List usersWithRole = new ArrayList();
+ PolicyManager policyManager = controller.getPolicyManager();
+
+ Role roleObject = accreditableManager.getRoleManager().getRole(role);
+
+ for (int i = 0; i < users.length; i++) {
+ Identity identity = new Identity(logger);
+ identity.addIdentifiable(users[i]);
+ Role[] roles = policyManager.getGrantedRoles(accreditableManager, identity, webappUrl);
+ if (Arrays.asList(roles).contains(roleObject)) {
+ usersWithRole.add(users[i]);
}
}
+
+ return (User[]) usersWithRole.toArray(new User[usersWithRole.size()]);
}
}
Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/acting/LanguageExistsAction.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/acting/LanguageExistsAction.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/acting/LanguageExistsAction.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/acting/LanguageExistsAction.java Fri Feb 6 17:55:28 2009
@@ -31,12 +31,17 @@
import org.apache.cocoon.environment.SourceResolver;
import org.apache.lenya.cms.publication.DocumentFactory;
import org.apache.lenya.cms.publication.DocumentUtil;
+import org.apache.lenya.cms.repository.RepositoryManager;
+import org.apache.lenya.cms.repository.RepositoryUtil;
+import org.apache.lenya.cms.repository.Session;
import org.apache.lenya.util.ServletHelper;
/**
* Action that checks if the current URL represents an existing document.
*/
public class LanguageExistsAction extends ServiceableAction {
+
+ private RepositoryManager repositoryManager;
/**
* Check if the current URL represents an existing document.
@@ -48,7 +53,8 @@
Parameters parameters) throws Exception {
Request request = ObjectModelHelper.getRequest(objectModel);
- DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);
+ Session session = RepositoryUtil.getSession(getRepositoryManager(), request);
+ DocumentFactory factory = DocumentUtil.createDocumentFactory(session);
String url = ServletHelper.getWebappURI(request);
if (factory.isDocument(url)) {
@@ -58,4 +64,12 @@
return null;
}
}
+
+ public void setRepositoryManager(RepositoryManager repositoryManager) {
+ this.repositoryManager = repositoryManager;
+ }
+
+ public RepositoryManager getRepositoryManager() {
+ return repositoryManager;
+ }
}
\ No newline at end of file
Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/acting/ReservedCheckinAction.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/acting/ReservedCheckinAction.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/acting/ReservedCheckinAction.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/acting/ReservedCheckinAction.java Fri Feb 6 17:55:28 2009
@@ -33,7 +33,7 @@
import org.apache.lenya.cms.publication.DocumentUtil;
import org.apache.lenya.cms.repository.Node;
import org.apache.lenya.cms.repository.RepositoryException;
-import org.apache.lenya.cms.repository.RepositoryUtil;
+import org.apache.lenya.cms.repository.RepositoryManager;
import org.apache.lenya.cms.repository.Session;
import org.apache.lenya.util.ServletHelper;
@@ -41,6 +41,9 @@
* Checkin document
*/
public class ReservedCheckinAction extends RevisionControllerAction {
+
+ private RepositoryManager repositoryManager;
+
/**
* Checkin document
* @return HashMap with checkin parameters
@@ -55,9 +58,9 @@
try {
Request request = ObjectModelHelper.getRequest(objectModel);
Identity identity = (Identity) request.getSession().getAttribute(Identity.class.getName());
- Session session = RepositoryUtil.createSession(this.manager, identity, true);
+ Session session = getRepositoryManager().createSession(identity, true);
- DocumentFactory factory = DocumentUtil.createDocumentFactory(this.manager, session);
+ DocumentFactory factory = DocumentUtil.createDocumentFactory(session);
String url = ServletHelper.getWebappURI(request);
if (factory.isDocument(url)) {
Node node = factory.getFromURL(url).getRepositoryNode();
@@ -80,4 +83,12 @@
return null;
}
+
+ public void setRepositoryManager(RepositoryManager repositoryManager) {
+ this.repositoryManager = repositoryManager;
+ }
+
+ public RepositoryManager getRepositoryManager() {
+ return repositoryManager;
+ }
}
\ No newline at end of file
Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/acting/RevisionControllerAction.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/acting/RevisionControllerAction.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/acting/RevisionControllerAction.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/acting/RevisionControllerAction.java Fri Feb 6 17:55:28 2009
@@ -21,14 +21,14 @@
import java.io.File;
import java.util.Map;
+import javax.servlet.http.HttpSession;
+
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.acting.ServiceableAction;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.Request;
-import org.apache.cocoon.environment.Session;
import org.apache.cocoon.environment.SourceResolver;
-import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.ac.Identity;
import org.apache.lenya.ac.User;
import org.apache.lenya.cms.publication.Document;
@@ -37,16 +37,17 @@
import org.apache.lenya.cms.publication.PageEnvelope;
import org.apache.lenya.cms.publication.PageEnvelopeFactory;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.PublicationUtil;
+import org.apache.lenya.cms.publication.URLInformation;
import org.apache.lenya.cms.rc.RCEnvironment;
import org.apache.lenya.cms.repository.Node;
+import org.apache.lenya.cms.repository.RepositoryManager;
import org.apache.lenya.cms.repository.RepositoryUtil;
+import org.apache.lenya.util.ServletHelper;
/**
* Revision controller action.
*
- * @version $Id: RevisionControllerAction.java 487290 2006-12-14 18:18:35Z
- * andreas $
+ * @version $Id$
*/
public class RevisionControllerAction extends ServiceableAction {
@@ -54,11 +55,12 @@
private String backupDirectory = null;
private String username = null;
private Node node = null;
+ private RepositoryManager repositoryManager;
/**
* @see org.apache.cocoon.acting.Action#act(org.apache.cocoon.environment.Redirector,
- * org.apache.cocoon.environment.SourceResolver, java.util.Map,
- * java.lang.String, org.apache.avalon.framework.parameters.Parameters)
+ * org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String,
+ * org.apache.avalon.framework.parameters.Parameters)
*/
public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String src,
Parameters parameters) throws Exception {
@@ -71,22 +73,17 @@
return null;
}
- PageEnvelope envelope = null;
- Publication publication;
-
- try {
- publication = PublicationUtil.getPublication(this.manager, request);
- } catch (Exception e) {
- throw new AccessControlException(e);
- }
org.apache.lenya.cms.repository.Session repoSession = RepositoryUtil.getSession(
- this.manager, request);
+ getRepositoryManager(), request);
+ DocumentFactory factory = DocumentUtil.createDocumentFactory(repoSession);
+
+ PageEnvelope envelope = null;
+ String id = new URLInformation(ServletHelper.getWebappURI(request)).getPublicationId();
+ Publication publication = factory.getPublication(id);
- DocumentFactory factory = DocumentUtil.createDocumentFactory(this.manager, repoSession);
Document document = null;
try {
- publication = PublicationUtil.getPublication(this.manager, objectModel);
envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(factory, objectModel,
publication);
document = envelope.getDocument();
@@ -105,7 +102,7 @@
this.backupDirectory = publicationPath + File.separator + this.backupDirectory;
// Get session
- Session session = request.getCocoonSession(false);
+ HttpSession session = request.getSession(false);
if (session == null) {
getLogger().error(".act(): No session object");
@@ -180,4 +177,12 @@
return this.username;
}
+ public void setRepositoryManager(RepositoryManager repositoryManager) {
+ this.repositoryManager = repositoryManager;
+ }
+
+ public RepositoryManager getRepositoryManager() {
+ return repositoryManager;
+ }
+
}
\ No newline at end of file
Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/components/context/ContextUtility.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/components/context/ContextUtility.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/components/context/ContextUtility.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/components/context/ContextUtility.java Fri Feb 6 17:55:28 2009
@@ -30,6 +30,7 @@
/**
* Utility class for getting the context, request, response and
* object model of the current request.
+ * @deprecated
*/
public class ContextUtility extends AbstractLogEnabled implements
Component, Contextualizable {
Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/DocumentInfoModule.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/DocumentInfoModule.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/DocumentInfoModule.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/DocumentInfoModule.java Fri Feb 6 17:55:28 2009
@@ -26,9 +26,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.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;
@@ -37,6 +34,7 @@
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.repository.RepositoryManager;
import org.apache.lenya.cms.repository.RepositoryUtil;
import org.apache.lenya.cms.repository.Session;
@@ -60,10 +58,8 @@
* an empty string if the document is not referenced in the site structure.</li>
* </ul>
*/
-public class DocumentInfoModule extends AbstractInputModule implements Serviceable {
-
- protected ServiceManager manager;
-
+public class DocumentInfoModule extends AbstractInputModule {
+
// Input module parameters:
protected final static String PARAM_PUBLICATION_ID = "publication-id";
protected final static String PARAM_AREA = "area";
@@ -95,6 +91,8 @@
protected SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
+ private RepositoryManager repositoryManager;
+
/**
* Parse the parameters and return a document.
* @param publicationId The publication ID.
@@ -113,8 +111,8 @@
Request request = ObjectModelHelper.getRequest(objectModel);
try {
- Session session = RepositoryUtil.getSession(this.manager, request);
- DocumentFactory docFactory = DocumentUtil.createDocumentFactory(this.manager, session);
+ Session session = RepositoryUtil.getSession(getRepositoryManager(), request);
+ DocumentFactory docFactory = DocumentUtil.createDocumentFactory(session);
Publication pub = docFactory.getPublication(publicationId);
document = docFactory.get(pub, area, uuid, language, revision);
} catch (Exception e) {
@@ -203,7 +201,11 @@
}
- public void service(ServiceManager manager) throws ServiceException {
- this.manager = manager;
+ public void setRepositoryManager(RepositoryManager repositoryManager) {
+ this.repositoryManager = repositoryManager;
+ }
+
+ public RepositoryManager getRepositoryManager() {
+ return repositoryManager;
}
}
Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/DocumentURLModule.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/DocumentURLModule.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/DocumentURLModule.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/DocumentURLModule.java Fri Feb 6 17:55:28 2009
@@ -60,7 +60,7 @@
final String language = attributes[2];
try {
- DocumentHelper helper = new DocumentHelper(this.manager, objectModel);
+ DocumentHelper helper = new DocumentHelper(objectModel);
url = helper.getDocumentUrl(uuid, area, language);
} catch (Exception e) {
throw new ConfigurationException("Resolving attribute [" + name + "] failed: ", e);
Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/OperationModule.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/OperationModule.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/OperationModule.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/OperationModule.java Fri Feb 6 17:55:28 2009
@@ -17,19 +17,15 @@
*/
package org.apache.lenya.cms.cocoon.components.modules.input;
-import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
-import org.apache.cocoon.components.ContextHelper;
+import javax.servlet.http.HttpServletRequest;
+
import org.apache.cocoon.components.modules.input.AbstractInputModule;
-import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.processing.ProcessInfoProvider;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
import org.apache.lenya.cms.publication.DocumentFactory;
-import org.apache.lenya.cms.publication.DocumentUtil;
+import org.apache.lenya.cms.publication.DocumentFactoryBuilder;
import org.apache.lenya.cms.repository.RepositoryException;
+import org.apache.lenya.cms.repository.RepositoryManager;
import org.apache.lenya.cms.repository.RepositoryUtil;
import org.apache.lenya.cms.repository.Session;
@@ -38,50 +34,42 @@
*
* @version $Id$
*/
-public class OperationModule extends AbstractInputModule implements Serviceable,
- Initializable, Contextualizable {
-
- /**
- * Ctor.
- */
- public OperationModule() {
- super();
- }
+public class OperationModule extends AbstractInputModule {
- private DocumentFactory documentIdentityMap;
-
- private Request request;
+ private RepositoryManager repositoryManager;
+ private DocumentFactory documentFactory;
+ private DocumentFactoryBuilder documentFactoryBuilder;
protected DocumentFactory getDocumentFactory() {
- if (this.documentIdentityMap == null) {
+ ProcessInfoProvider processInfo = (ProcessInfoProvider) WebAppContextUtils
+ .getCurrentWebApplicationContext().getBean(ProcessInfoProvider.ROLE);
+ if (this.documentFactory == null) {
+ HttpServletRequest request = processInfo.getRequest();
try {
- Session session = RepositoryUtil.getSession(this.manager, this.request);
- this.documentIdentityMap = DocumentUtil.createDocumentFactory(this.manager, session);
+ Session session = RepositoryUtil.getSession(getRepositoryManager(), request);
+ this.documentFactory = getDocumentFactoryBuilder().createDocumentFactory(
+ session);
} catch (RepositoryException e) {
throw new RuntimeException(e);
}
}
- return this.documentIdentityMap;
+ return this.documentFactory;
}
- protected ServiceManager manager;
+ public RepositoryManager getRepositoryManager() {
+ return repositoryManager;
+ }
- /**
- * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
- */
- public void service(ServiceManager _manager) throws ServiceException {
- this.manager = _manager;
+ public void setRepositoryManager(RepositoryManager repositoryManager) {
+ this.repositoryManager = repositoryManager;
}
- /**
- * @see org.apache.avalon.framework.activity.Initializable#initialize()
- */
- public void initialize() throws Exception {
- // do nothing
+ public DocumentFactoryBuilder getDocumentFactoryBuilder() {
+ return documentFactoryBuilder;
}
- public void contextualize(Context context) throws ContextException {
- this.request = ContextHelper.getRequest(context);
+ public void setDocumentFactoryBuilder(DocumentFactoryBuilder documentFactoryBuilder) {
+ this.documentFactoryBuilder = documentFactoryBuilder;
}
}
Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/ResourceTypeModule.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/ResourceTypeModule.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/ResourceTypeModule.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/ResourceTypeModule.java Fri Feb 6 17:55:28 2009
@@ -17,26 +17,24 @@
*/
package org.apache.lenya.cms.cocoon.components.modules.input;
+import java.text.SimpleDateFormat;
import java.util.Arrays;
-import java.util.Map;
import java.util.Date;
-import java.text.SimpleDateFormat;
+import java.util.Map;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.ServiceSelector;
-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.commons.lang.StringUtils;
-import org.apache.lenya.cms.publication.DocumentUtil;
-import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentFactory;
+import org.apache.lenya.cms.publication.DocumentUtil;
+import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.ResourceType;
+import org.apache.lenya.cms.publication.ResourceTypeResolver;
+import org.apache.lenya.cms.repository.RepositoryManager;
import org.apache.lenya.cms.repository.RepositoryUtil;
import org.apache.lenya.cms.repository.Session;
import org.apache.lenya.util.ServletHelper;
@@ -46,10 +44,10 @@
* Resource type module.
* </p>
* <p>
- * The syntax is either <code>{resource-type:<attribute>}</code> (which uses the resource
- * type of the currenlty requested document) or
- * <code>{resource-type:<name>:<attribute>}</code> (which allows to access an
- * arbitrary resource type).
+ * The syntax is either <code>{resource-type:<attribute>}</code> (which uses the resource type
+ * of the currenlty requested document) or
+ * <code>{resource-type:<name>:<attribute>}</code> (which allows to access an arbitrary
+ * resource type).
* </p>
* <p>
* Attributes:
@@ -57,27 +55,30 @@
* <ul>
* <li><strong><code>expires</code></strong> - the expiration date in RFC 822/1123 format, see
* {@link org.apache.lenya.cms.publication.ResourceType#getExpires()}</li>
- * <li><strong><code>schemaUri</code></strong> - see
- * {@link org.apache.lenya.xml.Schema#getURI()}</li>
- * <li><strong><code>httpSchemaUri</code></strong> - the URI to request the schema over HTTP, without Proxy and context (use {proxy:} around it).</li>
- * <li><strong><code>supportsFormat:{format}</code></strong> - true if the resource type
- * supports this format, false otherwise</li>
+ * <li><strong><code>schemaUri</code></strong> - see {@link org.apache.lenya.xml.Schema#getURI()}</li>
+ * <li><strong><code>httpSchemaUri</code></strong> - the URI to request the schema over HTTP,
+ * without Proxy and context (use {proxy:} around it).</li>
+ * <li><strong><code>supportsFormat:{format}</code></strong> - true if the resource type supports
+ * this format, false otherwise</li>
* </ul>
*/
-public class ResourceTypeModule extends AbstractInputModule implements Serviceable {
+public class ResourceTypeModule extends AbstractInputModule {
protected static final String SCHEMA_URI = "schemaUri";
protected static final String HTTP_SCHEMA_URI = "httpSchemaUri";
protected static final String EXPIRES = "expires";
protected static final String SUPPORTS_FORMAT = "supportsFormat";
+ private RepositoryManager repositoryManager;
+ private ResourceTypeResolver resourceTypeResolver;
+
public Object getAttribute(String name, Configuration modeConf, Map objectModel)
throws ConfigurationException {
Object value = null;
try {
Request request = ObjectModelHelper.getRequest(objectModel);
- Session session = RepositoryUtil.getSession(this.manager, request);
+ Session session = RepositoryUtil.getSession(getRepositoryManager(), request);
ResourceType resourceType;
Publication pub = null;
@@ -85,8 +86,7 @@
String[] steps = name.split(":");
if (steps.length == 1) {
- DocumentFactory docFactory = DocumentUtil.createDocumentFactory(this.manager,
- session);
+ DocumentFactory docFactory = DocumentUtil.createDocumentFactory(session);
String webappUrl = ServletHelper.getWebappURI(request);
Document document = docFactory.getFromURL(webappUrl);
pub = document.getPublication();
@@ -96,15 +96,7 @@
} else {
attribute = steps[1];
String resourceTypeName = steps[0];
-
- ServiceSelector selector = null;
- try {
- selector = (ServiceSelector) this.manager
- .lookup(ResourceType.ROLE + "Selector");
- resourceType = (ResourceType) selector.select(resourceTypeName);
- } finally {
- this.manager.release(selector);
- }
+ resourceType = getResourceTypeResolver().getResourceType(resourceTypeName);
}
if (attribute.startsWith("format-")) {
@@ -163,10 +155,20 @@
}
}
- protected ServiceManager manager;
+ public void setRepositoryManager(RepositoryManager repositoryManager) {
+ this.repositoryManager = repositoryManager;
+ }
+
+ public RepositoryManager getRepositoryManager() {
+ return repositoryManager;
+ }
+
+ public void setResourceTypeResolver(ResourceTypeResolver resourceTypeResolver) {
+ this.resourceTypeResolver = resourceTypeResolver;
+ }
- public void service(ServiceManager manager) throws ServiceException {
- this.manager = manager;
+ public ResourceTypeResolver getResourceTypeResolver() {
+ return resourceTypeResolver;
}
}
Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/flow/FlowHelper.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/flow/FlowHelper.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/flow/FlowHelper.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/flow/FlowHelper.java Fri Feb 6 17:55:28 2009
@@ -19,6 +19,8 @@
import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+
import org.apache.cocoon.components.flow.javascript.fom.FOM_Cocoon;
import org.apache.cocoon.environment.Request;
import org.apache.lenya.ac.AccessControlException;
@@ -59,7 +61,7 @@
* @param cocoon The FOM_Cocoon object.
* @return A request object.
*/
- Request getRequest(FOM_Cocoon cocoon);
+ HttpServletRequest getRequest(FOM_Cocoon cocoon);
/**
* Returns the Cocoon Object Model
Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/flow/FlowHelperImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/flow/FlowHelperImpl.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/flow/FlowHelperImpl.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/flow/FlowHelperImpl.java Fri Feb 6 17:55:28 2009
@@ -23,52 +23,66 @@
import java.util.Enumeration;
import java.util.Map;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
+import javax.servlet.http.HttpServletRequest;
+
import org.apache.cocoon.components.flow.javascript.fom.FOM_Cocoon;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.util.AbstractLogEnabled;
import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentFactory;
-import org.apache.lenya.cms.publication.DocumentUtil;
+import org.apache.lenya.cms.publication.DocumentFactoryBuilder;
import org.apache.lenya.cms.publication.PageEnvelope;
import org.apache.lenya.cms.publication.PageEnvelopeException;
import org.apache.lenya.cms.publication.PageEnvelopeFactory;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.PublicationUtil;
+import org.apache.lenya.cms.publication.URLInformation;
import org.apache.lenya.cms.publication.util.DocumentHelper;
import org.apache.lenya.cms.rc.FileReservedCheckInException;
import org.apache.lenya.cms.repository.Node;
+import org.apache.lenya.cms.repository.RepositoryManager;
import org.apache.lenya.cms.repository.RepositoryUtil;
import org.apache.lenya.cms.repository.Session;
import org.apache.lenya.cms.workflow.WorkflowUtil;
+import org.apache.lenya.util.ServletHelper;
import org.apache.lenya.workflow.WorkflowException;
/**
* Flowscript utility class. The FOM_Cocoon object is not passed in the constructor to avoid errors.
* This way, not the initial, but the current FOM_Cocoon object is used by the methods.
*/
-public class FlowHelperImpl extends AbstractLogEnabled implements FlowHelper, Serviceable {
+public class FlowHelperImpl extends AbstractLogEnabled implements FlowHelper {
+
+ private RepositoryManager repositoryManager;
+ private DocumentFactoryBuilder documentFactoryBuilder;
- /**
- * Ctor.
- */
- public FlowHelperImpl() {
- // do nothing
+ public RepositoryManager getRepositoryManager() {
+ return repositoryManager;
+ }
+
+ public void setRepositoryManager(RepositoryManager repositoryManager) {
+ this.repositoryManager = repositoryManager;
+ }
+
+ public DocumentFactoryBuilder getDocumentFactoryBuilder() {
+ return documentFactoryBuilder;
+ }
+
+ public void setDocumentFactoryBuilder(DocumentFactoryBuilder documentFactoryBuilder) {
+ this.documentFactoryBuilder = documentFactoryBuilder;
}
/**
* @see org.apache.lenya.cms.cocoon.flow.FlowHelper#getPageEnvelope(org.apache.cocoon.components.flow.javascript.fom.FOM_Cocoon)
*/
public PageEnvelope getPageEnvelope(FOM_Cocoon cocoon) throws PageEnvelopeException {
- Request request = getRequest(cocoon);
+ HttpServletRequest request = getRequest(cocoon);
try {
- Session session = RepositoryUtil.getSession(this.manager, request);
- DocumentFactory map = DocumentUtil.createDocumentFactory(this.manager, session);
+ Session session = RepositoryUtil.getSession(getRepositoryManager(), request);
+ DocumentFactory map = getDocumentFactoryBuilder().createDocumentFactory(session);
PageEnvelopeFactory factory = PageEnvelopeFactory.getInstance();
- Publication publication = PublicationUtil.getPublication(this.manager, request);
+ URLInformation info = new URLInformation(ServletHelper.getWebappURI(request));
+ Publication publication = map.getPublication(info.getPublicationId());
return factory.getPageEnvelope(map, cocoon.getObjectModel(), publication);
} catch (Exception e) {
throw new PageEnvelopeException(e);
@@ -85,7 +99,7 @@
/**
* @see org.apache.lenya.cms.cocoon.flow.FlowHelper#getRequest(org.apache.cocoon.components.flow.javascript.fom.FOM_Cocoon)
*/
- public Request getRequest(FOM_Cocoon cocoon) {
+ public HttpServletRequest getRequest(FOM_Cocoon cocoon) {
return cocoon.getRequest();
}
@@ -100,7 +114,7 @@
* @see org.apache.lenya.cms.cocoon.flow.FlowHelper#getDocumentHelper(org.apache.cocoon.components.flow.javascript.fom.FOM_Cocoon)
*/
public DocumentHelper getDocumentHelper(FOM_Cocoon cocoon) {
- return new DocumentHelper(this.manager, cocoon.getObjectModel());
+ return new DocumentHelper(cocoon.getObjectModel());
}
/**
@@ -142,7 +156,7 @@
public void triggerWorkflow(FOM_Cocoon cocoon, String event) throws WorkflowException,
PageEnvelopeException, AccessControlException {
Document document = getPageEnvelope(cocoon).getDocument();
- WorkflowUtil.invoke(this.manager, getLogger(), document, event);
+ WorkflowUtil.invoke(getLogger(), document, event);
}
/**
@@ -156,12 +170,4 @@
node.checkin();
}
- 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;
- }
}
\ No newline at end of file
Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/LenyaSourceFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/LenyaSourceFactory.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/LenyaSourceFactory.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/LenyaSourceFactory.java Fri Feb 6 17:55:28 2009
@@ -20,27 +20,23 @@
import java.net.MalformedURLException;
import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.DefaultConfiguration;
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
-import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.cocoon.components.ContextHelper;
import org.apache.cocoon.components.flow.FlowHelper;
import org.apache.cocoon.components.modules.input.JXPathHelper;
import org.apache.cocoon.components.modules.input.JXPathHelperConfiguration;
-import org.apache.cocoon.environment.ObjectModelHelper;
-import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.processing.ProcessInfoProvider;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
import org.apache.cocoon.util.AbstractLogEnabled;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
import org.apache.excalibur.source.SourceFactory;
import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.repository.NodeFactory;
import org.apache.lenya.cms.repository.RepositoryException;
+import org.apache.lenya.cms.repository.RepositoryManager;
import org.apache.lenya.cms.repository.RepositoryUtil;
import org.apache.lenya.cms.repository.Session;
import org.apache.lenya.util.Query;
@@ -52,8 +48,7 @@
*
* @version $Id$
*/
-public class LenyaSourceFactory extends AbstractLogEnabled implements SourceFactory, ThreadSafe,
- Contextualizable, Serviceable {
+public class LenyaSourceFactory extends AbstractLogEnabled implements SourceFactory {
protected static final String SCHEME = "lenya:";
@@ -61,24 +56,9 @@
protected static final String DEFAULT_DELEGATION_SCHEME = "context:";
protected static final String DEFAULT_DELEGATION_PREFIX = "/"
+ Publication.PUBLICATION_PREFIX_URI;
-
- private Context context;
- private ServiceManager manager;
-
- /**
- * Used for resolving the object model.
- * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
- */
- public void contextualize(Context _context) throws ContextException {
- this.context = _context;
- }
-
- /**
- * @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 NodeFactory nodeFactory;
+ private RepositoryManager repositoryManager;
/**
* @see org.apache.excalibur.source.SourceFactory#getSource(java.lang.String, java.util.Map)
@@ -87,7 +67,7 @@
throws MalformedURLException, IOException, SourceException {
String sessionName = null;
-
+
String[] uriAndQuery = location.split("\\?");
if (uriAndQuery.length > 1) {
Query query = new Query(uriAndQuery[1]);
@@ -105,18 +85,19 @@
getLogger().debug("Creating repository source for URI [" + location + "]");
}
- return new RepositorySource(this.manager, location, session, getLogger());
+ return new RepositorySource(getNodeFactory(), location, session, getLogger());
}
protected Session getSession(String sessionName) throws RepositoryException {
- Map objectModel = ContextHelper.getObjectModel(this.context);
Session session;
+ ProcessInfoProvider process = (ProcessInfoProvider) WebAppContextUtils
+ .getCurrentWebApplicationContext().getBean(ProcessInfoProvider.ROLE);
if (sessionName == null) {
- Request request = ObjectModelHelper.getRequest(objectModel);
- session = RepositoryUtil.getSession(this.manager, request);
+ HttpServletRequest request = process.getRequest();
+ session = RepositoryUtil.getSession(getRepositoryManager(), request);
} else if (sessionName.equals("usecase")) {
- session = getUsecaseSession(objectModel);
+ session = getUsecaseSession(process.getObjectModel());
} else {
throw new RepositoryException("Invalid session: [" + sessionName + "]");
}
@@ -143,4 +124,20 @@
public void release(Source source) {
// do nothing
}
+
+ public void setNodeFactory(NodeFactory nodeFactory) {
+ this.nodeFactory = nodeFactory;
+ }
+
+ public NodeFactory getNodeFactory() {
+ return nodeFactory;
+ }
+
+ public void setRepositoryManager(RepositoryManager repositoryManager) {
+ this.repositoryManager = repositoryManager;
+ }
+
+ public RepositoryManager getRepositoryManager() {
+ return repositoryManager;
+ }
}
\ No newline at end of file
Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/RepositorySource.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/RepositorySource.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/RepositorySource.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/RepositorySource.java Fri Feb 6 17:55:28 2009
@@ -25,14 +25,15 @@
import java.net.MalformedURLException;
import java.util.Collection;
+import javax.servlet.http.HttpServletRequest;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.processing.ProcessInfoProvider;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
import org.apache.commons.logging.Log;
import org.apache.excalibur.source.ModifiableTraversableSource;
import org.apache.excalibur.source.Source;
@@ -40,10 +41,11 @@
import org.apache.excalibur.source.SourceNotFoundException;
import org.apache.excalibur.source.SourceValidity;
import org.apache.excalibur.source.impl.AbstractSource;
-import org.apache.lenya.cms.cocoon.components.context.ContextUtility;
import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentFactory;
+import org.apache.lenya.cms.publication.DocumentUtil;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.PublicationUtil;
+import org.apache.lenya.cms.publication.URLInformation;
import org.apache.lenya.cms.repository.ContentHolder;
import org.apache.lenya.cms.repository.Node;
import org.apache.lenya.cms.repository.NodeFactory;
@@ -59,24 +61,25 @@
*/
public class RepositorySource extends AbstractSource implements ModifiableTraversableSource {
- private ServiceManager manager;
private ContentHolder content;
private Session session;
private Log logger;
protected static final String SCHEME = "lenya";
+ private NodeFactory nodeFactory;
+
/**
- * @param manager The service manager.
+ * @param nodeFactory The node factory.
* @param uri The source URI.
* @param session The repository session.
* @param logger The logger.
* @throws SourceException if an error occurs.
* @throws MalformedURLException if an error occurs.
*/
- public RepositorySource(ServiceManager manager, String uri, Session session, Log logger)
+ public RepositorySource(NodeFactory nodeFactory, String uri, Session session, Log logger)
throws SourceException, MalformedURLException {
- this.manager = manager;
this.logger = logger;
+ this.nodeFactory = nodeFactory;
if (getLogger().isDebugEnabled())
getLogger().debug("Init RepositorySource: " + uri);
@@ -96,8 +99,8 @@
int start = 0;
int end = uri.indexOf(':');
if (end == -1)
- throw new MalformedURLException("Malformed uri for xmodule source (cannot find scheme) : "
- + uri);
+ throw new MalformedURLException(
+ "Malformed uri for xmodule source (cannot find scheme) : " + uri);
String scheme = uri.substring(start, end);
if (!SCHEME.equals(scheme))
@@ -105,57 +108,42 @@
setScheme(scheme);
- NodeFactory factory = null;
try {
- factory = (NodeFactory) this.manager.lookup(NodeFactory.ROLE);
-
+
String sourceUri;
int revisionNumber = -1;
-
+
int questionMarkIndex = uri.indexOf("?");
if (questionMarkIndex > -1) {
sourceUri = uri.substring(0, questionMarkIndex);
Query query = new Query(uri.substring(questionMarkIndex + 1));
String revisionString = query.getValue("rev", null);
if (revisionString != null) {
-
- ContextUtility util = null;
- try {
- util = (ContextUtility) this.manager.lookup(ContextUtility.ROLE);
- Request request = util.getRequest();
- String webappUrl = ServletHelper.getWebappURI(request);
-
- Publication pub = PublicationUtil.getPublication(this.manager, request);
- Document currentDoc = pub.getFactory().getFromURL(webappUrl);
- if (currentDoc.getSourceURI().equals(sourceUri)) {
- revisionNumber = Integer.valueOf(revisionString).intValue();
- }
- }
- finally {
- if (util != null) {
- this.manager.release(util);
- }
+ ProcessInfoProvider process = (ProcessInfoProvider) WebAppContextUtils
+ .getCurrentWebApplicationContext().getBean(ProcessInfoProvider.ROLE);
+ HttpServletRequest request = process.getRequest();
+ String webappUrl = ServletHelper.getWebappURI(request);
+ String pubId = new URLInformation(webappUrl).getPublicationId();
+ DocumentFactory factory = DocumentUtil.createDocumentFactory(session);
+ Publication pub = factory.getPublication(pubId);
+ Document currentDoc = pub.getFactory().getFromURL(webappUrl);
+ if (currentDoc.getSourceURI().equals(sourceUri)) {
+ revisionNumber = Integer.valueOf(revisionString).intValue();
}
}
- }
- else {
+ } else {
sourceUri = uri;
}
-
+
if (revisionNumber == -1) {
- this.content = (ContentHolder) session.getRepositoryItem(factory, sourceUri);
- }
- else {
- Node node = (Node) session.getRepositoryItem(factory, sourceUri);
+ this.content = (ContentHolder) session.getRepositoryItem(nodeFactory, sourceUri);
+ } else {
+ Node node = (Node) session.getRepositoryItem(nodeFactory, sourceUri);
this.content = node.getHistory().getRevision(revisionNumber);
}
-
+
} catch (Exception e) {
throw new SourceException("Creating repository node failed: ", e);
- } finally {
- if (factory != null) {
- this.manager.release(factory);
- }
}
}
@@ -163,11 +151,12 @@
* @return The repository node which is accessed by this source.
*/
public Node getNode() {
-
+
if (!(this.content instanceof Node)) {
- throw new RuntimeException("This operation can only be invoked on nodes, not on revisions.");
+ throw new RuntimeException(
+ "This operation can only be invoked on nodes, not on revisions.");
}
-
+
return (Node) this.content;
}
@@ -254,8 +243,8 @@
try {
transform(doc, pos);
} catch (TransformerException e) {
- throw new RuntimeException("Failed to tranform org.w3c.dom.Document to PipedOutputStream",
- e);
+ throw new RuntimeException(
+ "Failed to tranform org.w3c.dom.Document to PipedOutputStream", e);
} finally {
try {
pos.close();
@@ -264,8 +253,7 @@
}
}
}
- },
- getClass().getName() + ".convert(org.w3c.dom.Document edoc)")).start();
+ }, getClass().getName() + ".convert(org.w3c.dom.Document edoc)")).start();
return pis;
}
@@ -281,7 +269,7 @@
transformer.transform(new DOMSource(edoc), new StreamResult(pos));
}
-
+
/**
* @return The content of this source.
*/
@@ -373,10 +361,8 @@
java.util.Vector newChildren = new java.util.Vector();
while (iterator.hasNext()) {
Node child = (Node) iterator.next();
- newChildren.add(new RepositorySource(this.manager,
- child.getSourceURI(),
- this.session,
- getLogger()));
+ newChildren.add(new RepositorySource(getNodeFactory(), child.getSourceURI(),
+ this.session, getLogger()));
}
return newChildren;
} catch (Exception e) {
@@ -394,7 +380,7 @@
throw new RuntimeException(e);
}
}
-
+
private SourceValidity validity;
public SourceValidity getValidity() {
@@ -403,6 +389,9 @@
}
return this.validity;
}
-
-
+
+ public NodeFactory getNodeFactory() {
+ return nodeFactory;
+ }
+
}
Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/SiteSourceFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/SiteSourceFactory.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/SiteSourceFactory.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/SiteSourceFactory.java Fri Feb 6 17:55:28 2009
@@ -22,16 +22,10 @@
import java.util.Map;
import java.util.StringTokenizer;
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
-import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.cocoon.components.ContextHelper;
-import org.apache.cocoon.environment.ObjectModelHelper;
-import org.apache.cocoon.environment.Request;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.cocoon.processing.ProcessInfoProvider;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
import org.apache.cocoon.util.AbstractLogEnabled;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
@@ -43,6 +37,9 @@
import org.apache.lenya.cms.publication.DocumentUtil;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.URLInformation;
+import org.apache.lenya.cms.repository.RepositoryManager;
+import org.apache.lenya.cms.repository.RepositoryUtil;
+import org.apache.lenya.cms.repository.Session;
import org.apache.lenya.cms.site.SiteStructure;
import org.apache.lenya.util.ServletHelper;
@@ -68,35 +65,19 @@
* <li><code>site:/en/news/today</code></li>
* </ul>
*/
-public class SiteSourceFactory extends AbstractLogEnabled implements SourceFactory, ThreadSafe,
- Contextualizable, Serviceable {
-
- private Context context;
- private ServiceManager manager;
- private SourceResolver resolver;
+public class SiteSourceFactory extends AbstractLogEnabled implements SourceFactory {
- /**
- * Used for resolving the object model.
- * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
- */
- public void contextualize(Context context) throws ContextException {
- this.context = context;
- }
-
- /**
- * @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 SourceResolver sourceResolver;
+ private RepositoryManager repositoryManager;
/**
* @see org.apache.excalibur.source.SourceFactory#getSource(java.lang.String, java.util.Map)
*/
public Source getSource(String location, Map parameters) throws MalformedURLException,
IOException, SourceException {
- Map objectModel = ContextHelper.getObjectModel(this.context);
- Request request = ObjectModelHelper.getRequest(objectModel);
+ ProcessInfoProvider process = (ProcessInfoProvider) WebAppContextUtils
+ .getCurrentWebApplicationContext().getBean(ProcessInfoProvider.ROLE);
+ HttpServletRequest request = process.getRequest();
String areaName = null;
String pubId;
@@ -106,7 +87,6 @@
String relativePath;
try {
- this.resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
String scheme = completePath.substring(0, completePath.indexOf(":") + 1);
final String absolutePath = completePath.substring(scheme.length());
@@ -128,7 +108,8 @@
+ "] must start with at least one slash.");
}
- DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);
+ Session session = RepositoryUtil.getSession(getRepositoryManager(), request);
+ DocumentFactory factory = DocumentUtil.createDocumentFactory(session);
Publication pub = factory.getPublication(pubId);
SiteStructure site = pub.getArea(areaName).getSite();
@@ -147,7 +128,7 @@
String queryString = locationSteps.nextToken();
docUri = docUri + "?" + queryString;
}
- return this.resolver.resolveURI(docUri);
+ return this.sourceResolver.resolveURI(docUri);
} else {
throw new SourceNotFoundException("The source [" + location + "] doesn't exist.");
}
@@ -161,7 +142,23 @@
* @see org.apache.excalibur.source.SourceFactory#release(org.apache.excalibur.source.Source)
*/
public void release(Source source) {
- this.resolver.release(source);
+ this.sourceResolver.release(source);
+ }
+
+ public void setRepositoryManager(RepositoryManager repositoryManager) {
+ this.repositoryManager = repositoryManager;
+ }
+
+ public RepositoryManager getRepositoryManager() {
+ return repositoryManager;
+ }
+
+ public SourceResolver getSourceResolver() {
+ return sourceResolver;
+ }
+
+ public void setSourceResolver(SourceResolver sourceResolver) {
+ this.sourceResolver = sourceResolver;
}
}
Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/SourceUtil.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/SourceUtil.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/SourceUtil.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/SourceUtil.java Fri Feb 6 17:55:28 2009
@@ -200,15 +200,13 @@
* @param sourceUri The source URI.
* @param manager The service manager.
* @return A document or <code>null</code> if the source does not exist.
- * @throws ServiceException if an error occurs.
* @throws SourceNotFoundException if an error occurs.
* @throws ParserConfigurationException if an error occurs.
* @throws SAXException if an error occurs.
* @throws IOException if an error occurs.
*/
public static Document readDOM(String sourceUri, SourceResolver resolver)
- throws ServiceException, SourceNotFoundException, ParserConfigurationException,
- SAXException, IOException {
+ throws SourceNotFoundException, ParserConfigurationException, SAXException, IOException {
Source source = null;
Document document = null;
try {
Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/metadata/MetaDataRegistry.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/metadata/MetaDataRegistry.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/metadata/MetaDataRegistry.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/metadata/MetaDataRegistry.java Fri Feb 6 17:55:28 2009
@@ -21,6 +21,11 @@
* Meta data registry.
*/
public interface MetaDataRegistry {
+
+ /**
+ * The service role.
+ */
+ String ROLE = MetaDataRegistry.class.getName();
/**
* @param namespaceUri The namespace URI of the element set.
Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/DefaultDocumentBuilder.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/DefaultDocumentBuilder.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/DefaultDocumentBuilder.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/DefaultDocumentBuilder.java Fri Feb 6 17:55:28 2009
@@ -189,7 +189,7 @@
Publication publication;
try {
- publication = PublicationUtil.getPublicationFromUrl(this.manager, factory, webappUrl);
+ publication = factory.getPublication(info.getPublicationId());
} catch (PublicationException e) {
throw new DocumentBuildException(e);
}
Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/DocumentUtil.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/DocumentUtil.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/DocumentUtil.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/DocumentUtil.java Fri Feb 6 17:55:28 2009
@@ -17,69 +17,23 @@
*/
package org.apache.lenya.cms.publication;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.cocoon.environment.Request;
import org.apache.cocoon.spring.configurator.WebAppContextUtils;
-import org.apache.lenya.cms.repository.RepositoryException;
-import org.apache.lenya.cms.repository.RepositoryUtil;
import org.apache.lenya.cms.repository.Session;
-import org.apache.lenya.util.ServletHelper;
/**
* Document utility class.
*/
public final class DocumentUtil {
- private static DocumentFactoryBuilder builder;
-
/**
* Creates a document factory.
- * @param manager The service manager.
* @param session The session.
* @return a document factory.
*/
- public static final DocumentFactory createDocumentFactory(ServiceManager manager,
- Session session) {
+ public static final DocumentFactory createDocumentFactory(Session session) {
DocumentFactoryBuilder builder = (DocumentFactoryBuilder) WebAppContextUtils
.getCurrentWebApplicationContext().getBean(DocumentFactoryBuilder.class.getName());
return builder.createDocumentFactory(session);
}
- /**
- * Returns a document factory for the session which is attached to the request. If no session
- * exists, it is created.
- * @param manager The service manager.
- * @param request The request.
- * @return A document factory.
- */
- public static DocumentFactory getDocumentFactory(ServiceManager manager, Request request) {
- Session session;
- try {
- session = RepositoryUtil.getSession(manager, request);
- } catch (RepositoryException e) {
- throw new RuntimeException(e);
- }
- return createDocumentFactory(manager, session);
- }
-
- /**
- * Returns the currently requested document or <code>null</code> if no document is requested.
- * @param manager The service manager.
- * @param request The request.
- * @return A document.
- * @throws RepositoryException if an error occurs.
- * @throws DocumentBuildException if an error occurs.
- */
- public static Document getCurrentDocument(ServiceManager manager, Request request)
- throws RepositoryException, DocumentBuildException {
- Session session = RepositoryUtil.getSession(manager, request);
- DocumentFactory factory = DocumentUtil.createDocumentFactory(manager, session);
- String url = ServletHelper.getWebappURI(request);
- Document doc = null;
- if (factory.isDocument(url)) {
- doc = factory.getFromURL(url);
- }
- return doc;
- }
-
}
Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/PublicationUtil.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/PublicationUtil.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/PublicationUtil.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/PublicationUtil.java Fri Feb 6 17:55:28 2009
@@ -18,16 +18,6 @@
package org.apache.lenya.cms.publication;
import java.util.Arrays;
-import java.util.Map;
-
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.cocoon.environment.ObjectModelHelper;
-import org.apache.cocoon.environment.Request;
-import org.apache.lenya.cms.repository.RepositoryException;
-import org.apache.lenya.cms.repository.RepositoryUtil;
-import org.apache.lenya.cms.repository.Session;
-import org.apache.lenya.util.ServletHelper;
/**
* Publication utility.
@@ -35,77 +25,6 @@
public class PublicationUtil {
/**
- * Creates a new publication. The publication ID is resolved from the request URI. The servlet
- * context path is resolved from the context object.
- * @param manager The service manager.
- * @param objectModel The object model of the Cocoon component.
- * @return a <code>Publication</code>
- * @throws PublicationException if there was a problem creating the publication.
- */
- public static Publication getPublication(ServiceManager manager, Map objectModel)
- throws PublicationException {
- return getPublication(manager, ObjectModelHelper.getRequest(objectModel));
- }
-
- /**
- * Creates a new publication based on a request.
- * @param manager The service manager.
- * @param request A request.
- * @return A publication.
- * @throws PublicationException if there was a problem creating the publication.
- */
- public static Publication getPublication(ServiceManager manager, Request request)
- throws PublicationException {
- Session session;
- try {
- session = RepositoryUtil.getSession(manager, request);
- } catch (RepositoryException e) {
- throw new PublicationException(e);
- }
- DocumentFactory factory = DocumentUtil.createDocumentFactory(manager, session);
- String webappUrl = ServletHelper.getWebappURI(request);
- return getPublicationFromUrl(manager, factory, webappUrl);
- }
-
- /**
- * Creates a publication from a webapp URL and a servlet context directory.
- * @param manager The service manager.
- * @param factory The factory.
- * @param webappUrl The URL within the web application (without context prefix)
- * @return A publication
- * @throws PublicationException when something went wrong
- * @deprecated
- */
- public static Publication getPublicationFromUrl(ServiceManager manager,
- DocumentFactory factory, String webappUrl) throws PublicationException {
- URLInformation info = new URLInformation(webappUrl);
- String pubId = info.getPublicationId();
- return factory.getPublication(pubId);
- }
-
- /**
- * Returns a list of all available publications.
- * @param manager The service manager.
- * @param factory The document factory.
- * @return An array of publications.
- * @throws PublicationException if an error occurs.
- */
- public static Publication[] getPublications(ServiceManager manager, DocumentFactory factory)
- throws PublicationException {
- PublicationManager pubManager = null;
- try {
- pubManager = (PublicationManager) manager.lookup(PublicationManager.ROLE);
- return pubManager.getPublications(factory);
- } catch (ServiceException e) {
- throw new PublicationException(e);
- } finally {
- if (pubManager != null) {
- manager.release(pubManager);
- }
- }
- }
-
- /**
* Checks if a publication id is valid.
* @param id
* @return true if the id contains only lowercase letters and/or numbers, and is not an empty
Added: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/Repository.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/Repository.java?rev=741654&view=auto
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/Repository.java (added)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/Repository.java Fri Feb 6 17:55:28 2009
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.publication;
+
+import javax.servlet.http.HttpServletRequest;
+
+public interface Repository {
+
+ Session getSession(HttpServletRequest request);
+
+}
Added: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/ResourceTypeResolver.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/ResourceTypeResolver.java?rev=741654&view=auto
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/ResourceTypeResolver.java (added)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/ResourceTypeResolver.java Fri Feb 6 17:55:28 2009
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.publication;
+
+public interface ResourceTypeResolver {
+
+ boolean existsResourceType(String name);
+
+ ResourceType getResourceType(String name);
+
+}
Added: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/Session.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/Session.java?rev=741654&view=auto
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/Session.java (added)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/Session.java Fri Feb 6 17:55:28 2009
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.publication;
+
+public interface Session {
+
+ Repository getRepository();
+
+ Publication getPublication(String id);
+
+ boolean existsPublication(String id);
+
+ DocumentFactory getDocumentFactory();
+
+}
Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/templating/PublicationTemplateManager.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/templating/PublicationTemplateManager.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/templating/PublicationTemplateManager.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/templating/PublicationTemplateManager.java Fri Feb 6 17:55:28 2009
@@ -17,8 +17,6 @@
*/
package org.apache.lenya.cms.publication.templating;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceSelector;
import org.apache.lenya.cms.publication.Publication;
/**
@@ -63,12 +61,10 @@
/**
* Returns the hint for the publiation which declares a service.
* @param publication The original publication.
- * @param selector The service selector.
+ * @param role The service role.
* @param originalHint The original hint.
* @return An object.
- * @throws ServiceException if an error occurs.
*/
- Object getSelectableHint(Publication publication, ServiceSelector selector, String originalHint)
- throws ServiceException;
+ Object getSelectableHint(Publication publication, String role, String originalHint);
}
\ No newline at end of file
Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/util/DocumentHelper.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/util/DocumentHelper.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/util/DocumentHelper.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/util/DocumentHelper.java Fri Feb 6 17:55:28 2009
@@ -24,24 +24,25 @@
import java.util.List;
import java.util.Map;
-import org.apache.avalon.framework.service.ServiceManager;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentBuildException;
import org.apache.lenya.cms.publication.DocumentException;
import org.apache.lenya.cms.publication.DocumentFactory;
+import org.apache.lenya.cms.publication.DocumentFactoryBuilder;
import org.apache.lenya.cms.publication.DocumentLocator;
-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.PublicationUtil;
import org.apache.lenya.cms.publication.URLInformation;
import org.apache.lenya.cms.repository.RepositoryException;
+import org.apache.lenya.cms.repository.RepositoryManager;
import org.apache.lenya.cms.repository.RepositoryUtil;
import org.apache.lenya.cms.repository.Session;
import org.apache.lenya.util.ServletHelper;
+import org.springframework.web.context.WebApplicationContext;
/**
* Helper class to handle documents from XSP.
@@ -49,7 +50,7 @@
public class DocumentHelper {
private Map objectModel;
- private DocumentFactory identityMap;
+ private DocumentFactory documentFactory;
private Publication publication;
/**
@@ -57,27 +58,35 @@
* @param manager The service manager.
* @param _objectModel The Cocoon object model.
*/
- public DocumentHelper(ServiceManager manager, Map _objectModel) {
- this.objectModel = _objectModel;
- try {
- this.publication = PublicationUtil.getPublication(manager, _objectModel);
- } catch (PublicationException e) {
- throw new RuntimeException(e);
- }
+ public DocumentHelper(Map _objectModel) {
+ WebApplicationContext context = WebAppContextUtils.getCurrentWebApplicationContext();
+ RepositoryManager repoMgr = (RepositoryManager) context.getBean(RepositoryManager.ROLE);
+ DocumentFactoryBuilder builder = (DocumentFactoryBuilder) context
+ .getBean(DocumentFactoryBuilder.class.getName());
+
Request request = ObjectModelHelper.getRequest(_objectModel);
Session session;
try {
- session = RepositoryUtil.getSession(manager, request);
+ session = RepositoryUtil.getSession(repoMgr, request);
} catch (RepositoryException e) {
throw new RuntimeException(e);
}
- this.identityMap = DocumentUtil.createDocumentFactory(manager, session);
+
+ this.documentFactory = builder.createDocumentFactory(session);
+ this.objectModel = _objectModel;
+ try {
+ URLInformation info = new URLInformation(ServletHelper.getWebappURI(request));
+ this.publication = this.documentFactory.getPublication(info.getPublicationId());
+ } catch (PublicationException e) {
+ throw new RuntimeException(e);
+ }
}
/**
- * Creates a document URL. <br/>If the document ID is null, the current document ID is used.
- * <br/>If the document area is null, the current area is used. <br/>If the language is null,
- * the current language is used.
+ * Creates a document URL. <br/>
+ * If the document ID is null, the current document ID is used. <br/>
+ * If the document area is null, the current area is used. <br/>
+ * If the language is null, the current language is used.
* @param uuid The target document UUID.
* @param documentArea The target area.
* @param language The target language.
@@ -92,7 +101,7 @@
try {
Request request = ObjectModelHelper.getRequest(this.objectModel);
String webappUrl = ServletHelper.getWebappURI(request);
- Document envDocument = this.identityMap.getFromURL(webappUrl);
+ Document envDocument = this.documentFactory.getFromURL(webappUrl);
if (uuid == null) {
uuid = envDocument.getUUID();
}
@@ -107,7 +116,8 @@
language = envDocument.getLanguage();
}
- Document document = this.identityMap.get(this.publication, documentArea, uuid, language);
+ Document document = this.documentFactory
+ .get(this.publication, documentArea, uuid, language);
url = document.getCanonicalWebappURL();
String contextPath = request.getContextPath();
@@ -138,12 +148,12 @@
try {
Request request = ObjectModelHelper.getRequest(this.objectModel);
String webappUrl = ServletHelper.getWebappURI(request);
- Document document = this.identityMap.getFromURL(webappUrl);
+ Document document = this.documentFactory.getFromURL(webappUrl);
contextPath = request.getContextPath();
DocumentLocator parentLocator = document.getLocator().getParent("/index");
- Document parent = this.identityMap.get(parentLocator);
+ Document parent = this.documentFactory.get(parentLocator);
parentUrl = parent.getCanonicalWebappURL();
} catch (final DocumentBuildException e) {
throw new ProcessingException(e);
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.