You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2006/12/15 18:01:16 UTC
svn commit: r487598 - in /lenya/trunk/src:
impl/java/org/apache/lenya/cms/publication/
impl/test/org/apache/lenya/cms/publication/
java/org/apache/lenya/cms/cocoon/acting/
java/org/apache/lenya/cms/cocoon/components/modules/input/
java/org/apache/lenya...
Author: andreas
Date: Fri Dec 15 09:01:14 2006
New Revision: 487598
URL: http://svn.apache.org/viewvc?view=rev&rev=487598
Log:
Allow to use extensions instead of regexps in BypassableAccessController, various refactorings to improve performance, e.g. avoid duplicate source resolving
Added:
lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/VisitingSourceResolver.java
- copied, changed from r482993, lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/URIResolver.java
Removed:
lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/URIResolver.java
Modified:
lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java
lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/TestPageEnvelope.java
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/RevisionControllerAction.java
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/AbstractPageEnvelopeModule.java
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PageEnvelopeModule.java
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/flow/FlowHelperImpl.java
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/FallbackSourceFactory.java
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/TemplateFallbackSourceFactory.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelopeFactory.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/URLInformation.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/AllExistingSourceResolver.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingAncestorSourceResolver.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingSourceResolver.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/SourceVisitor.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentLanguagesHelper.java
lenya/trunk/src/java/org/apache/lenya/cms/site/SiteStructure.java
lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java
lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStore.java
lenya/trunk/src/modules-core/ac-impl/config/cocoon-xconf/bypassable-access-controller.xconf
lenya/trunk/src/modules-core/ac-impl/java/src/org/apache/lenya/ac/impl/BypassableAccessController.java
lenya/trunk/src/modules-core/ac-impl/java/src/org/apache/lenya/cms/ac/DocumentPolicyManagerWrapper.java
lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/LinkRewritingTransformer.java
lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/ChangeNodeID.java
lenya/trunk/src/modules-core/templating-impl/java/src/org/apache/lenya/cms/publication/templating/PublicationTemplateManagerImpl.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/DefaultSiteTree.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java
lenya/trunk/src/targets/webapp-build.xml
Modified: lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java (original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java Fri Dec 15 09:01:14 2006
@@ -17,6 +17,8 @@
*/
package org.apache.lenya.cms.publication;
+import java.util.StringTokenizer;
+
import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.Logger;
@@ -181,7 +183,11 @@
DocumentBuilder builder = publication.getDocumentBuilder();
if (builder.isDocument(webappUrl)) {
DocumentLocator locator = builder.getLocator(this, webappUrl);
- return SiteUtil.contains(this.manager, this, locator);
+ String area = locator.getArea();
+ String path = locator.getPath();
+ String language = locator.getLanguage();
+ SiteStructure site = publication.getArea(area).getSite();
+ return site.contains(path, language);
} else {
return false;
}
@@ -216,7 +222,7 @@
String uuid = null;
try {
Publication publication = getPublication(locator.getPublicationId());
- if (SiteUtil.isDocument(this.manager, this, webappUrl)) {
+ if (SiteUtil.isDocument(this, webappUrl)) {
uuid = publication.getArea(area).getSite().getNode(locator.getPath()).getUuid();
} else {
UUIDGenerator generator = (UUIDGenerator) this.manager.lookup(UUIDGenerator.ROLE);
@@ -250,11 +256,11 @@
if (getLogger().isDebugEnabled())
getLogger().debug("DocumentFactory::build() called with key [" + key + "]");
- String[] snippets = key.split(":");
- String publicationId = snippets[0];
- String area = snippets[1];
- String uuid = snippets[2];
- String language = snippets[3];
+ StringTokenizer tokenizer = new StringTokenizer(key, ":");
+ String publicationId = tokenizer.nextToken();
+ String area = tokenizer.nextToken();
+ String uuid = tokenizer.nextToken();
+ String language = tokenizer.nextToken();
Document document;
try {
Modified: lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/TestPageEnvelope.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/TestPageEnvelope.java?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/TestPageEnvelope.java (original)
+++ lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/TestPageEnvelope.java Fri Dec 15 09:01:14 2006
@@ -38,7 +38,7 @@
*/
public TestPageEnvelope(Publication publication, String url, ServiceManager manager,
Logger logger) throws PageEnvelopeException {
- super(manager);
+ super();
setContext("");
try {
Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/RevisionControllerAction.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/RevisionControllerAction.java?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/RevisionControllerAction.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/RevisionControllerAction.java Fri Dec 15 09:01:14 2006
@@ -33,7 +33,6 @@
import org.apache.lenya.ac.User;
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.DocumentUtil;
import org.apache.lenya.cms.publication.PageEnvelope;
import org.apache.lenya.cms.publication.PageEnvelopeFactory;
@@ -47,7 +46,8 @@
/**
* Revision controller action.
*
- * @version $Id$
+ * @version $Id: RevisionControllerAction.java 487290 2006-12-14 18:18:35Z
+ * andreas $
*/
public class RevisionControllerAction extends ServiceableAction {
@@ -59,8 +59,8 @@
/**
* @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 {
@@ -81,17 +81,15 @@
} catch (Exception e) {
throw new AccessControlException(e);
}
- org.apache.lenya.cms.repository.Session repoSession = RepositoryUtil.getSession(this.manager,
- request);
+ org.apache.lenya.cms.repository.Session repoSession = RepositoryUtil.getSession(
+ this.manager, request);
DocumentFactory factory = DocumentUtil.createDocumentFactory(this.manager, repoSession);
Document document = null;
try {
publication = PublicationUtil.getPublication(this.manager, objectModel);
- envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(this.manager,
- factory,
- objectModel,
+ envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(factory, objectModel,
publication);
document = envelope.getDocument();
} catch (Exception e) {
Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/AbstractPageEnvelopeModule.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/AbstractPageEnvelopeModule.java?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/AbstractPageEnvelopeModule.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/AbstractPageEnvelopeModule.java Fri Dec 15 09:01:14 2006
@@ -74,7 +74,7 @@
try {
DocumentFactory factory = getDocumentFactory();
Publication pub = PublicationUtil.getPublicationFromUrl(this.manager, factory, webappUrl);
- envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(this.manager,
+ envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(
factory,
contextPath,
webappUrl,
Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PageEnvelopeModule.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PageEnvelopeModule.java?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PageEnvelopeModule.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PageEnvelopeModule.java Fri Dec 15 09:01:14 2006
@@ -41,8 +41,8 @@
import org.apache.lenya.util.ServletHelper;
/**
- * Input module wrapping the page envelope. This module provides publication related information
- * such as document-id, area, publication-id.
+ * Input module wrapping the page envelope. This module provides publication
+ * related information such as document-id, area, publication-id.
*
* @see org.apache.lenya.cms.publication.PageEnvelope
* @deprecated use DocumentInfoModule instead.
@@ -53,7 +53,8 @@
/**
* @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(final String attributeName, Configuration modeConf, Map objectModel)
throws ConfigurationException {
@@ -84,50 +85,50 @@
value = envelope.getPublication().getBreadcrumbPrefix();
} else if (name.equals(PageEnvelope.DOCUMENT_PATH)) {
value = getPath(envelope, objectModel);
- }
-
- Document document = envelope.getDocument();
- if (document != null) {
- if (name.equals(PageEnvelope.DOCUMENT)) {
- value = document;
- } else if (name.equals(PageEnvelope.DOCUMENT_ID)) {
- getLogger().warn(
- "This attribute is deprecated."
- + " Use document-path or document-uuid instead!");
- value = document.getId();
- } else if (name.equals(PageEnvelope.DOCUMENT_PARENT)) {
- value = document.getLocator().getParent().getPath();
- } else if (name.equals(PageEnvelope.DOCUMENT_NAME)) {
- value = document.getName();
- } else if (name.equals(PageEnvelope.DOCUMENT_LABEL)) {
- value = document.getLink().getLabel();
- } else if (name.equals(PageEnvelope.DOCUMENT_URL)) {
- value = document.getCanonicalDocumentURL();
- } else if (name.equals(PageEnvelope.DOCUMENT_URL_WITHOUT_LANGUAGE)) {
- value = document.getCanonicalWebappURL();
- } else if (name.equals(PageEnvelope.DOCUMENT_FILE)) {
- value = document.getFile();
- } else if (name.equals(PageEnvelope.DOCUMENT_EXTENSION)) {
- value = document.getExtension();
- } else if (name.equals(PageEnvelope.DOCUMENT_SOURCE_EXTENSION)) {
- value = document.getSourceExtension();
- } else if (name.equals(PageEnvelope.DOCUMENT_UUID)) {
- value = document.getUUID();
- } else if (name.equals(PageEnvelope.DOCUMENT_LANGUAGE)) {
- value = document.getLanguage();
- } else if (name.equals(PageEnvelope.DOCUMENT_LANGUAGES)) {
- value = document.getLanguages();
- } else if (name.equals(PageEnvelope.DOCUMENT_LANGUAGES_CSV)) {
- value = StringUtils.join(document.getLanguages(), ',');
- } else if (name.equals(PageEnvelope.DOCUMENT_LASTMODIFIED)) {
- Date date = new Date(document.getLastModified());
- value = new SimpleDateFormat(DATE_FORMAT).format(date);
- } else if (name.equals(PageEnvelope.DOCUMENT_TYPE)) {
- ResourceType resourceType = document.getResourceType();
- if (resourceType == null) {
- value = null;
- } else {
- value = resourceType.getName();
+ } else {
+ Document document = envelope.getDocument();
+ if (document != null) {
+ if (name.equals(PageEnvelope.DOCUMENT)) {
+ value = document;
+ } else if (name.equals(PageEnvelope.DOCUMENT_ID)) {
+ getLogger().warn(
+ "This attribute is deprecated."
+ + " Use document-path or document-uuid instead!");
+ value = document.getId();
+ } else if (name.equals(PageEnvelope.DOCUMENT_PARENT)) {
+ value = document.getLocator().getParent().getPath();
+ } else if (name.equals(PageEnvelope.DOCUMENT_NAME)) {
+ value = document.getName();
+ } else if (name.equals(PageEnvelope.DOCUMENT_LABEL)) {
+ value = document.getLink().getLabel();
+ } else if (name.equals(PageEnvelope.DOCUMENT_URL)) {
+ value = document.getCanonicalDocumentURL();
+ } else if (name.equals(PageEnvelope.DOCUMENT_URL_WITHOUT_LANGUAGE)) {
+ value = document.getCanonicalWebappURL();
+ } else if (name.equals(PageEnvelope.DOCUMENT_FILE)) {
+ value = document.getFile();
+ } else if (name.equals(PageEnvelope.DOCUMENT_EXTENSION)) {
+ value = document.getExtension();
+ } else if (name.equals(PageEnvelope.DOCUMENT_SOURCE_EXTENSION)) {
+ value = document.getSourceExtension();
+ } else if (name.equals(PageEnvelope.DOCUMENT_UUID)) {
+ value = document.getUUID();
+ } else if (name.equals(PageEnvelope.DOCUMENT_LANGUAGE)) {
+ value = document.getLanguage();
+ } else if (name.equals(PageEnvelope.DOCUMENT_LANGUAGES)) {
+ value = document.getLanguages();
+ } else if (name.equals(PageEnvelope.DOCUMENT_LANGUAGES_CSV)) {
+ value = StringUtils.join(document.getLanguages(), ',');
+ } else if (name.equals(PageEnvelope.DOCUMENT_LASTMODIFIED)) {
+ Date date = new Date(document.getLastModified());
+ value = new SimpleDateFormat(DATE_FORMAT).format(date);
+ } else if (name.equals(PageEnvelope.DOCUMENT_TYPE)) {
+ ResourceType resourceType = document.getResourceType();
+ if (resourceType == null) {
+ value = null;
+ } else {
+ value = resourceType.getName();
+ }
}
}
}
@@ -174,7 +175,8 @@
/**
* @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/src/java/org/apache/lenya/cms/cocoon/flow/FlowHelperImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/flow/FlowHelperImpl.java?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/flow/FlowHelperImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/flow/FlowHelperImpl.java Fri Dec 15 09:01:14 2006
@@ -73,7 +73,7 @@
DocumentFactory map = DocumentUtil.createDocumentFactory(this.manager, session);
PageEnvelopeFactory factory = PageEnvelopeFactory.getInstance();
Publication publication = PublicationUtil.getPublication(this.manager, request);
- return factory.getPageEnvelope(this.manager, map, cocoon.getObjectModel(), publication);
+ return factory.getPageEnvelope(map, cocoon.getObjectModel(), publication);
} catch (Exception e) {
throw new PageEnvelopeException(e);
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/FallbackSourceFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/FallbackSourceFactory.java?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/FallbackSourceFactory.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/FallbackSourceFactory.java Fri Dec 15 09:01:14 2006
@@ -45,7 +45,7 @@
import org.apache.lenya.cms.publication.URLInformation;
import org.apache.lenya.cms.publication.templating.ExistingSourceResolver;
import org.apache.lenya.cms.publication.templating.PublicationTemplateManager;
-import org.apache.lenya.cms.publication.templating.URIResolver;
+import org.apache.lenya.cms.publication.templating.VisitingSourceResolver;
/**
* Source factory following the fallback principle.
@@ -68,8 +68,6 @@
public Source getSource(final String location, Map parameters) throws IOException,
MalformedURLException {
- String resolvedUri = null;
-
long startTime = new GregorianCalendar().getTimeInMillis();
// Remove the protocol and the first '//'
@@ -103,7 +101,7 @@
PublicationManager pubMgr = null;
PublicationTemplateManager templateManager = null;
SourceResolver sourceResolver = null;
- Source source;
+ Source source = null;
try {
sourceResolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
@@ -123,16 +121,16 @@
DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);
Publication pub = pubMgr.getPublication(factory, publicationId);
if (pub.exists()) {
- URIResolver resolver = getSourceVisitor();
+ VisitingSourceResolver resolver = getSourceVisitor();
templateManager.visit(pub, path, resolver);
- resolvedUri = resolver.getURI();
+ source = resolver.getSource();
}
if (getLogger().isDebugEnabled()) {
- getLogger().debug("Resolved URI: [" + resolvedUri + "]");
+ getLogger().debug("Resolved URI: [" + source.getURI() + "]");
}
- if (resolvedUri == null) {
+ if (source == null) {
if (path.startsWith("lenya/modules/")) {
ModuleManager moduleMgr = null;
try {
@@ -140,7 +138,7 @@
final String moduleShortcut = path.split("/")[2];
String baseUri = moduleMgr.getBaseURI(moduleShortcut);
final String modulePath = path.substring(("lenya/modules/" + moduleShortcut).length());
- resolvedUri = baseUri + modulePath;
+ source = sourceResolver.resolveURI(baseUri + modulePath);
} finally {
if (moduleMgr != null) {
this.manager.release(moduleMgr);
@@ -148,12 +146,10 @@
}
} else {
String contextUri = "context://" + path;
- resolvedUri = contextUri;
+ source = sourceResolver.resolveURI(contextUri);
}
}
- source = sourceResolver.resolveURI(resolvedUri);
-
} catch (Exception e) {
throw new RuntimeException("Resolving path [" + location + "] failed: ", e);
} finally {
@@ -178,7 +174,7 @@
return source;
}
- protected URIResolver getSourceVisitor() {
+ protected VisitingSourceResolver getSourceVisitor() {
return new ExistingSourceResolver();
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/TemplateFallbackSourceFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/TemplateFallbackSourceFactory.java?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/TemplateFallbackSourceFactory.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/TemplateFallbackSourceFactory.java Fri Dec 15 09:01:14 2006
@@ -18,7 +18,7 @@
package org.apache.lenya.cms.cocoon.source;
import org.apache.lenya.cms.publication.templating.ExistingAncestorSourceResolver;
-import org.apache.lenya.cms.publication.templating.URIResolver;
+import org.apache.lenya.cms.publication.templating.VisitingSourceResolver;
/**
* Source factory following the fallback principle, resolving the existing ancestor of the existing resource.
@@ -34,7 +34,7 @@
super();
}
- protected URIResolver getSourceVisitor() {
+ protected VisitingSourceResolver getSourceVisitor() {
return new ExistingAncestorSourceResolver();
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java Fri Dec 15 09:01:14 2006
@@ -22,7 +22,6 @@
import java.io.File;
-import org.apache.avalon.framework.service.ServiceManager;
import org.apache.cocoon.environment.Request;
import org.apache.lenya.cms.rc.RCEnvironment;
import org.apache.lenya.cms.site.SiteUtil;
@@ -163,19 +162,15 @@
private String area;
private Publication publication;
- private ServiceManager manager;
-
/**
* Constructor.
* @param manager The service manager.
*/
- protected PageEnvelope(ServiceManager manager) {
- this.manager = manager;
+ protected PageEnvelope() {
}
/**
* Creates a page envelope from an object model.
- * @param manager The service manager.
* @param map The identity map to use.
* @param contextPath The servlet context prefix.
* @param webappUrl The web application URL.
@@ -183,14 +178,13 @@
* @param publication The publication.
* @throws PageEnvelopeException when something went wrong.
*/
- public PageEnvelope(ServiceManager manager, DocumentFactory map, String contextPath,
+ public PageEnvelope(DocumentFactory map, String contextPath,
String webappUrl, File servletContext, Publication publication)
throws PageEnvelopeException {
this.factory = map;
this.context = contextPath;
this.webappUrl = webappUrl;
this.publication = publication;
- this.manager = manager;
}
private String webappUrl;
@@ -289,7 +283,7 @@
if (!documentChecked) {
try {
documentChecked = true;
- if (SiteUtil.isDocument(this.manager, getDocumentFactory(), this.webappUrl)) {
+ if (SiteUtil.isDocument(getDocumentFactory(), this.webappUrl)) {
this.document = getDocumentFactory().getFromURL(this.webappUrl);
}
} catch (final Exception e) {
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelopeFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelopeFactory.java?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelopeFactory.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelopeFactory.java Fri Dec 15 09:01:14 2006
@@ -23,7 +23,6 @@
import java.io.File;
import java.util.Map;
-import org.apache.avalon.framework.service.ServiceManager;
import org.apache.cocoon.environment.Context;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
@@ -55,31 +54,24 @@
/**
* Returns the page envelope for the object model of a Cocoon component.
- * @param manager The service manager.
* @param map The document identity map to use.
* @param objectModel The object model.
* @param pub The publication.
* @return A page envelope.
* @throws PageEnvelopeException if something went wrong.
*/
- public PageEnvelope getPageEnvelope(ServiceManager manager, DocumentFactory map,
- Map objectModel, Publication pub) throws PageEnvelopeException {
+ public PageEnvelope getPageEnvelope(DocumentFactory map, Map objectModel, Publication pub)
+ throws PageEnvelopeException {
Request request = ObjectModelHelper.getRequest(objectModel);
String contextPath = request.getContextPath();
Context context = ObjectModelHelper.getContext(objectModel);
String webappUrl = ServletHelper.getWebappURI(request);
String servletContextPath = context.getRealPath("");
- return getPageEnvelope(manager,
- map,
- contextPath,
- webappUrl,
- new File(servletContextPath),
- pub);
+ return getPageEnvelope(map, contextPath, webappUrl, new File(servletContextPath), pub);
}
/**
* Creates a page envelope.
- * @param manager The service manager.
* @param map The document identity map to use.
* @param contextPath The servlet context prefix.
* @param webappUrl The web application URL.
@@ -88,15 +80,9 @@
* @return A page envelope.
* @throws PageEnvelopeException if something went wrong.
*/
- public PageEnvelope getPageEnvelope(ServiceManager manager, DocumentFactory map,
- String contextPath, String webappUrl, File servletContext, Publication pub)
- throws PageEnvelopeException {
- PageEnvelope envelope = new PageEnvelope(manager,
- map,
- contextPath,
- webappUrl,
- servletContext,
- pub);
+ public PageEnvelope getPageEnvelope(DocumentFactory map, String contextPath, String webappUrl,
+ File servletContext, Publication pub) throws PageEnvelopeException {
+ PageEnvelope envelope = new PageEnvelope(map, contextPath, webappUrl, servletContext, pub);
return envelope;
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/URLInformation.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/URLInformation.java?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/URLInformation.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/URLInformation.java Fri Dec 15 09:01:14 2006
@@ -30,11 +30,21 @@
private String completeArea = null;
private String documentUrl = null;
+ private String url;
+
/**
* Returns the area (without the "webdav" prefix).
* @return A string.
*/
public String getArea() {
+ if (this.area == null) {
+ String completeArea = getCompleteArea();
+ if (completeArea.equals(Publication.DAV_AREA)) {
+ this.area = Publication.AUTHORING_AREA;
+ } else {
+ this.area = completeArea;
+ }
+ }
return this.area;
}
@@ -43,6 +53,14 @@
* @return A string.
*/
public String getCompleteArea() {
+ if (this.completeArea == null) {
+ String pubUrl = this.url.substring(getPublicationId().length());
+ if (pubUrl.startsWith("/")) {
+ this.completeArea = extractBeforeSlash(pubUrl.substring(1));
+ } else {
+ this.completeArea = null;
+ }
+ }
return this.completeArea;
}
@@ -51,6 +69,14 @@
* @return A string.
*/
public String getDocumentUrl() {
+ if (this.documentUrl == null) {
+ String pubId = getPublicationId();
+ String area = getArea();
+ if (pubId != null && area != null) {
+ String prefix = pubId + "/" + area;
+ this.documentUrl = this.url.substring(prefix.length());
+ }
+ }
return this.documentUrl;
}
@@ -59,41 +85,38 @@
* @return A string.
*/
public String getPublicationId() {
+ if (this.publicationId == null) {
+ this.publicationId = extractBeforeSlash(this.url);
+ }
return this.publicationId;
}
+ protected String extractBeforeSlash(String remaining) {
+
+ if (remaining.length() == 0) {
+ return null;
+ }
+
+ String step;
+ int slashIndex = remaining.indexOf('/');
+ if (slashIndex == -1) {
+ step = remaining;
+ } else {
+ step = remaining.substring(0, slashIndex);
+ }
+ return step;
+ }
+
/**
* Ctor.
* @param webappUrl A webapp URL (without context prefix).
*/
public URLInformation(String webappUrl) {
-
+
if (!webappUrl.startsWith("/")) {
throw new RuntimeException("The URL [" + webappUrl + "] doesn't start with a slash!");
}
- String url = webappUrl.substring(1);
-
- String[] fragments = url.split("/");
- if (fragments.length > 0) {
- this.publicationId = fragments[0];
-
- if (fragments.length > 1) {
- this.completeArea = fragments[1];
-
- if (url.length() > (this.publicationId + "/" + this.completeArea).length()) {
- this.documentUrl = url.substring((this.publicationId + "/" + this.completeArea).length());
- } else {
- this.documentUrl = "";
- }
-
- if (this.completeArea.equals(Publication.DAV_AREA)) {
- this.area = Publication.AUTHORING_AREA;
- } else {
- this.area = this.completeArea;
- }
- }
- }
+ this.url = webappUrl.substring(1);
}
-
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/AllExistingSourceResolver.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/AllExistingSourceResolver.java?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/AllExistingSourceResolver.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/AllExistingSourceResolver.java Fri Dec 15 09:01:14 2006
@@ -21,20 +21,31 @@
import java.util.List;
import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
/**
* Source visitor to obtain all existing sources.
*/
public class AllExistingSourceResolver implements SourceVisitor {
- public void visit(Source source) {
- if (source.exists()) {
- this.uris.add(source.getURI());
+ public void visit(SourceResolver resolver, String sourceUri) {
+ Source source = null;
+ try {
+ source = resolver.resolveURI(sourceUri);
+ if (source.exists()) {
+ this.uris.add(sourceUri);
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (source != null) {
+ resolver.release(source);
+ }
}
}
-
+
private List uris = new ArrayList();
-
+
/**
* @return All existing source URIs.
*/
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingAncestorSourceResolver.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingAncestorSourceResolver.java?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingAncestorSourceResolver.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingAncestorSourceResolver.java Fri Dec 15 09:01:14 2006
@@ -19,15 +19,16 @@
package org.apache.lenya.cms.publication.templating;
import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
/**
* Source visitor to obtain the first existing source.
*
* @version $Id: ExistingSourceResolver.java 179568 2005-06-02 09:27:26Z jwkaltz $
*/
-public class ExistingAncestorSourceResolver implements URIResolver {
-
- private String uri;
+public class ExistingAncestorSourceResolver implements VisitingSourceResolver {
+
+ private Source source;
/**
* Ctor.
@@ -35,25 +36,31 @@
public ExistingAncestorSourceResolver() {
super();
}
-
+
/**
- * Returns the URI of the first existing source.
- * @return The URI
+ * @return the ancestor of the first existing source.
*/
- public String getURI() {
- return this.uri;
+ public Source getSource() {
+ return this.source;
}
private int matches = 0;
- /**
- * @see org.apache.lenya.cms.publication.templating.SourceVisitor#visit(org.apache.excalibur.source.Source)
- */
- public void visit(Source source) {
- if (source.exists()) {
- matches++;
- if (matches == 2) {
- this.uri = source.getURI();
+ public void visit(SourceResolver resolver, String sourceUri) {
+ Source source = null;
+ try {
+ source = resolver.resolveURI(sourceUri);
+ if (source.exists()) {
+ matches++;
+ if (matches == 2) {
+ this.source = source;
+ }
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (source != null) {
+ resolver.release(source);
}
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingSourceResolver.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingSourceResolver.java?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingSourceResolver.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingSourceResolver.java Fri Dec 15 09:01:14 2006
@@ -19,15 +19,16 @@
package org.apache.lenya.cms.publication.templating;
import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
/**
* Source visitor to obtain the first existing source.
*
* @version $Id$
*/
-public class ExistingSourceResolver implements URIResolver {
-
- private String uri;
+public class ExistingSourceResolver implements VisitingSourceResolver {
+
+ private Source source;
/**
* Ctor.
@@ -35,21 +36,29 @@
public ExistingSourceResolver() {
super();
}
-
+
/**
- * Returns the URI of the first existing source.
- * @return The URI
+ * @return the first existing source.
*/
- public String getURI() {
- return this.uri;
+ public Source getSource() {
+ return this.source;
}
-
- /**
- * @see org.apache.lenya.cms.publication.templating.SourceVisitor#visit(org.apache.excalibur.source.Source)
- */
- public void visit(Source source) {
- if (this.uri == null && source.exists()) {
- this.uri = source.getURI();
+
+ public void visit(SourceResolver resolver, String sourceUri) {
+ if (this.source == null) {
+ Source source = null;
+ try {
+ source = resolver.resolveURI(sourceUri);
+ if (source.exists()) {
+ this.source = source;
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (source != null) {
+ resolver.release(source);
+ }
+ }
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/SourceVisitor.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/SourceVisitor.java?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/SourceVisitor.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/SourceVisitor.java Fri Dec 15 09:01:14 2006
@@ -17,7 +17,7 @@
*/
package org.apache.lenya.cms.publication.templating;
-import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
/**
* @version $Id$
@@ -25,9 +25,12 @@
public interface SourceVisitor {
/**
- * Visits a source.
- * @param source The source.
+ * Visits a source. We pass the resolver and the URI so that the visitor can
+ * decide if it wants to resolve the source (mainly for performance
+ * reasons).
+ * @param resolver The resolver.
+ * @param sourceUri The source URI.
*/
- void visit(Source source);
+ void visit(SourceResolver resolver, String sourceUri);
}
Copied: lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/VisitingSourceResolver.java (from r482993, lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/URIResolver.java)
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/VisitingSourceResolver.java?view=diff&rev=487598&p1=lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/URIResolver.java&r1=482993&p2=lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/VisitingSourceResolver.java&r2=487598
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/URIResolver.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/VisitingSourceResolver.java Fri Dec 15 09:01:14 2006
@@ -17,14 +17,16 @@
*/
package org.apache.lenya.cms.publication.templating;
+import org.apache.excalibur.source.Source;
+
/**
* URI resolver.
*/
-public interface URIResolver extends SourceVisitor {
+public interface VisitingSourceResolver extends SourceVisitor {
/**
- * @return The resolved URI.
+ * @return The resolved source.
*/
- String getURI();
+ Source getSource();
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentLanguagesHelper.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentLanguagesHelper.java?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentLanguagesHelper.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentLanguagesHelper.java Fri Dec 15 09:01:14 2006
@@ -103,7 +103,8 @@
String[] languages = pub.getLanguages();
for (int i = 0; i < languages.length; i++) {
DocumentLocator version = locator.getLanguageVersion(languages[i]);
- if (SiteUtil.contains(this.manager, factory, version)) {
+ Publication pub = factory.getPublication(locator.getPublicationId());
+ if (pub.getArea(version.getArea()).getSite().contains(version.getPath(), version.getLanguage())) {
availableLanguages.add(languages[i]);
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/SiteStructure.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/site/SiteStructure.java?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/SiteStructure.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/SiteStructure.java Fri Dec 15 09:01:14 2006
@@ -64,6 +64,14 @@
boolean contains(String path);
/**
+ * Checks if a link is contained for a certain path and language.
+ * @param path The path.
+ * @param language The language.
+ * @return A boolean value.
+ */
+ boolean contains(String path, String language);
+
+ /**
* Checks if the structure contains a link with a certain UUID and language.
* @param uuid The UUID.
* @param language The language.
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java Fri Dec 15 09:01:14 2006
@@ -24,7 +24,6 @@
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.ServiceSelector;
import org.apache.lenya.cms.publication.Document;
-import org.apache.lenya.cms.publication.DocumentBuildException;
import org.apache.lenya.cms.publication.DocumentBuilder;
import org.apache.lenya.cms.publication.DocumentFactory;
import org.apache.lenya.cms.publication.DocumentLocator;
@@ -112,46 +111,15 @@
}
}
- public static boolean contains(ServiceManager manager, DocumentFactory factory,
- DocumentLocator locator) throws SiteException {
- SiteManager siteManager = null;
- ServiceSelector selector = null;
-
- try {
- selector = (ServiceSelector) manager.lookup(SiteManager.ROLE + "Selector");
- Publication pub = factory.getPublication(locator.getPublicationId());
- String siteManagerHint = pub.getSiteManagerHint();
- siteManager = (SiteManager) selector.select(siteManagerHint);
- SiteStructure site = siteManager.getSiteStructure(factory, pub, locator.getArea());
- String path = locator.getPath();
- String language = locator.getLanguage();
- return site.contains(path) && site.getNode(path).hasLink(language);
- } catch (SiteException e) {
- throw e;
- } catch (Exception e) {
- throw new SiteException(e);
- } finally {
- if (selector != null) {
- if (siteManager != null) {
- selector.release(siteManager);
- }
- manager.release(selector);
- }
- }
- }
-
- public static boolean isDocument(ServiceManager manager, DocumentFactory factory,
- String webappUrl) throws SiteException {
+ public static boolean isDocument(DocumentFactory factory, String webappUrl)
+ throws SiteException {
URLInformation info = new URLInformation(webappUrl);
try {
Publication pub = factory.getPublication(info.getPublicationId());
if (pub.exists()) {
DocumentBuilder builder = pub.getDocumentBuilder();
- if (builder.isDocument(webappUrl)) {
- DocumentLocator locator = builder.getLocator(factory, webappUrl);
- return contains(manager, factory, locator);
- }
+ return builder.isDocument(webappUrl);
}
return false;
} catch (SiteException e) {
@@ -164,15 +132,18 @@
public static Document getDocument(ServiceManager manager, DocumentFactory factory,
String webappUrl) throws SiteException {
- DocumentLocator locator = getLocator(manager, factory, webappUrl);
- if (contains(manager, factory, locator)) {
- try {
+ try {
+ DocumentLocator locator = getLocator(manager, factory, webappUrl);
+ Publication pub = factory.getPublication(locator.getPublicationId());
+ String path = locator.getPath();
+ String lang = locator.getLanguage();
+ if (pub.getArea(locator.getArea()).getSite().contains(path, lang)) {
return factory.get(locator);
- } catch (DocumentBuildException e) {
- throw new SiteException(e);
+ } else {
+ throw new SiteException("No document for webapp URL [" + webappUrl + "]");
}
- } else {
- throw new SiteException("No document for webapp URL [" + webappUrl + "]");
+ } catch (Exception e) {
+ throw new SiteException(e);
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStore.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStore.java?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStore.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStore.java Fri Dec 15 09:01:14 2006
@@ -302,4 +302,16 @@
return (SiteNode[]) topLevelNodes.toArray(new SiteNode[topLevelNodes.size()]);
}
+ public boolean contains(String path, String language) {
+ if (contains(path)) {
+ SiteNode node;
+ try {
+ node = getNode(path);
+ } catch (SiteException e) {
+ throw new RuntimeException(e);
+ }
+ return node.hasLink(language);
+ }
+ return false;
+ }
}
Modified: lenya/trunk/src/modules-core/ac-impl/config/cocoon-xconf/bypassable-access-controller.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/ac-impl/config/cocoon-xconf/bypassable-access-controller.xconf?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/modules-core/ac-impl/config/cocoon-xconf/bypassable-access-controller.xconf (original)
+++ lenya/trunk/src/modules-core/ac-impl/config/cocoon-xconf/bypassable-access-controller.xconf Fri Dec 15 09:01:14 2006
@@ -24,7 +24,13 @@
<xconf xpath="/cocoon" unless="/cocoon/component[@role = 'org.apache.lenya.ac.AccessController/bypassable']">
<component logger="lenya.ac.accesscontroller.bypassable"
class="org.apache.lenya.ac.impl.BypassableAccessController"
- role="org.apache.lenya.ac.AccessController/bypassable">
- <public>.*[.]css|.*[.]jpg|.*[.]gif|.*[.]png|.*[.]rng|.*[.]xsl</public>
+ role="org.apache.lenya.ac.AccessController/bypassable">
+
+ <public-extensions>css,jpg,gif,png,rng,xsl</public-extensions>
+
+ <!-- bad performance, use only for complex patterns
+ <public>.*[.]css|.*[.]jpg|.*[.]gif|.*[.]png|.*[.]rng|.*[.]xsl</public>
+ -->
+
</component>
</xconf>
Modified: lenya/trunk/src/modules-core/ac-impl/java/src/org/apache/lenya/ac/impl/BypassableAccessController.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/ac-impl/java/src/org/apache/lenya/ac/impl/BypassableAccessController.java?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/modules-core/ac-impl/java/src/org/apache/lenya/ac/impl/BypassableAccessController.java (original)
+++ lenya/trunk/src/modules-core/ac-impl/java/src/org/apache/lenya/ac/impl/BypassableAccessController.java Fri Dec 15 09:01:14 2006
@@ -46,6 +46,7 @@
}
private List publicMatchers = new ArrayList();
+ private List publicExtensions = new ArrayList();
/**
* @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
@@ -70,6 +71,19 @@
getLogger().debug("CONFIGURATION: public: " + publicHref);
}
}
+
+ Configuration[] extensionConfigs = conf.getChildren("public-extensions");
+ for (int i = 0; i < extensionConfigs.length; i++) {
+ String extensionString = extensionConfigs[i].getValue();
+ String[] extensions = extensionString.split(",");
+ for (int e = 0; e < extensions.length; e++) {
+ String ext = extensions[e].trim();
+ if (!ext.startsWith(".")) {
+ ext = "." + ext;
+ }
+ this.publicExtensions.add(ext);
+ }
+ }
}
@@ -149,6 +163,13 @@
}
authorized = true;
}
+ i++;
+ }
+
+ i = 0;
+ while (!authorized && i < this.publicExtensions.size()) {
+ String ext = (String) this.publicExtensions.get(i);
+ authorized = uri.endsWith(ext);
i++;
}
Modified: lenya/trunk/src/modules-core/ac-impl/java/src/org/apache/lenya/cms/ac/DocumentPolicyManagerWrapper.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/ac-impl/java/src/org/apache/lenya/cms/ac/DocumentPolicyManagerWrapper.java?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/modules-core/ac-impl/java/src/org/apache/lenya/cms/ac/DocumentPolicyManagerWrapper.java (original)
+++ lenya/trunk/src/modules-core/ac-impl/java/src/org/apache/lenya/cms/ac/DocumentPolicyManagerWrapper.java Fri Dec 15 09:01:14 2006
@@ -71,11 +71,13 @@
/**
* Returns the URI which is used to obtain the policy for a webapp URL.
+ * @param controller The accreditable manager.
* @param webappUrl The webapp URL.
* @return A string.
* @throws AccessControlException when something went wrong.
*/
- protected String getPolicyURL(String webappUrl) throws AccessControlException {
+ protected String getPolicyURL(String webappUrl)
+ throws AccessControlException {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Resolving policy for webapp URL [" + webappUrl + "]");
@@ -130,6 +132,20 @@
getLogger().debug(" Using URL: [" + url + "]");
}
return url;
+ }
+
+ protected String getPolicyUrlFast(String webappUrl)
+ throws AccessControlException {
+ String strippedUrl = strip(strip(webappUrl, '.'), '_');
+ return strippedUrl;
+ }
+
+ protected String strip(String strippedUrl, char delimiter) {
+ int lastDotIndex = strippedUrl.lastIndexOf(delimiter);
+ if (lastDotIndex != -1) {
+ strippedUrl = strippedUrl.substring(0, lastDotIndex);
+ }
+ return strippedUrl;
}
/**
Modified: lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/LinkRewritingTransformer.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/LinkRewritingTransformer.java?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/LinkRewritingTransformer.java (original)
+++ lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/LinkRewritingTransformer.java Fri Dec 15 09:01:14 2006
@@ -36,6 +36,7 @@
import org.apache.lenya.ac.Policy;
import org.apache.lenya.ac.PolicyManager;
import org.apache.lenya.cms.linking.LinkResolver;
+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;
@@ -56,7 +57,7 @@
* <p>
* This transformer is applied to an XHMTL document. It processes all links
* following the {@link LinkResolver} syntax which are denoted by
- * {@link ResourceType#getLinkAttributeXPaths()}.
+ * {@link org.apache.lenya.cms.publication.ResourceType#getLinkAttributeXPaths()}.
* </p>
* <p>
* These links are resolved using the following rules:
@@ -209,8 +210,9 @@
if (linkUriAndQuery.length > 1) {
queryString = linkUriAndQuery[1];
}
- Document targetDocument = this.linkResolver.resolve(doc, linkUri).getDocument();
- if (targetDocument != null) {
+ LinkTarget target = this.linkResolver.resolve(doc, linkUri);
+ if (target.exists()) {
+ Document targetDocument = target.getDocument();
String extension = targetDocument.getExtension();
if (extension.length() > 0) {
extension = "." + extension;
Modified: lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/ChangeNodeID.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/ChangeNodeID.java?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/ChangeNodeID.java (original)
+++ lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/ChangeNodeID.java Fri Dec 15 09:01:14 2006
@@ -32,6 +32,7 @@
import org.apache.lenya.cms.site.NodeSet;
import org.apache.lenya.cms.site.SiteException;
import org.apache.lenya.cms.site.SiteNode;
+import org.apache.lenya.cms.site.SiteStructure;
import org.apache.lenya.cms.site.SiteUtil;
import org.apache.lenya.cms.usecase.DocumentUsecase;
import org.apache.lenya.cms.usecase.UsecaseException;
@@ -127,7 +128,9 @@
addErrorMessage("The document ID is not valid.");
} else {
DocumentLocator target = getTargetLocator();
- if (SiteUtil.contains(this.manager, getDocumentFactory(), target)) {
+ Publication pub = getDocumentFactory().getPublication(target.getPublicationId());
+ SiteStructure site = pub.getArea(target.getArea()).getSite();
+ if (site.contains(target.getPath(), target.getLanguage())) {
addErrorMessage("The document does already exist.");
}
}
Modified: lenya/trunk/src/modules-core/templating-impl/java/src/org/apache/lenya/cms/publication/templating/PublicationTemplateManagerImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/templating-impl/java/src/org/apache/lenya/cms/publication/templating/PublicationTemplateManagerImpl.java?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/modules-core/templating-impl/java/src/org/apache/lenya/cms/publication/templating/PublicationTemplateManagerImpl.java (original)
+++ lenya/trunk/src/modules-core/templating-impl/java/src/org/apache/lenya/cms/publication/templating/PublicationTemplateManagerImpl.java Fri Dec 15 09:01:14 2006
@@ -28,7 +28,6 @@
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.ServiceSelector;
import org.apache.avalon.framework.service.Serviceable;
-import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceResolver;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.PublicationException;
@@ -36,7 +35,8 @@
/**
* Manager for publication templates.
*
- * @version $Id$
+ * @version $Id: PublicationTemplateManagerImpl.java 474729 2006-11-14 11:07:44Z
+ * andreas $
*/
public class PublicationTemplateManagerImpl extends AbstractLogEnabled implements
PublicationTemplateManager, Serviceable {
@@ -49,7 +49,8 @@
/**
* @see org.apache.lenya.cms.publication.templating.PublicationTemplateManager#visit(org.apache.lenya.cms.publication.Publication,
- * java.lang.String, org.apache.lenya.cms.publication.templating.SourceVisitor)
+ * java.lang.String,
+ * org.apache.lenya.cms.publication.templating.SourceVisitor)
*/
public void visit(Publication publication, String path, SourceVisitor visitor) {
@@ -65,18 +66,7 @@
getLogger().debug("Trying to resolve URI [" + uri + "]");
}
- Source source = null;
- try {
- source = resolver.resolveURI(uri);
- visitor.visit(source);
- } catch (Exception e) {
- getLogger().error("Could not resolve URI [" + uri + "]: ", e);
- throw e;
- } finally {
- if (source != null) {
- resolver.release(source);
- }
- }
+ visitor.visit(resolver, uri);
}
} catch (Exception e) {
@@ -100,7 +90,8 @@
/**
* Returns the publication.
- * @return A publication. protected Publication getPublication1() { return this.publication; }
+ * @return A publication. protected Publication getPublication1() { return
+ * this.publication; }
*/
/**
@@ -188,7 +179,8 @@
/**
* @see org.apache.lenya.cms.publication.templating.PublicationTemplateManager#getSelectableHint(org.apache.lenya.cms.publication.Publication,
- * org.apache.avalon.framework.service.ServiceSelector, java.lang.String)
+ * org.apache.avalon.framework.service.ServiceSelector,
+ * java.lang.String)
*/
public Object getSelectableHint(Publication publication, ServiceSelector selector,
final String originalHint) throws ServiceException {
@@ -254,8 +246,8 @@
}
/**
- * @return The publication hint that could be selected or <code>null</code> if no hint
- * could be selected.
+ * @return The publication hint that could be selected or
+ * <code>null</code> if no hint could be selected.
*/
public Object getSelectableHint() {
return this.selectableHint;
Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/DefaultSiteTree.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/DefaultSiteTree.java?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/DefaultSiteTree.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/DefaultSiteTree.java Fri Dec 15 09:01:14 2006
@@ -624,4 +624,17 @@
return root;
}
+ public boolean contains(String path, String language) {
+ if (contains(path)) {
+ SiteNode node;
+ try {
+ node = getNode(path);
+ } catch (SiteException e) {
+ throw new RuntimeException(e);
+ }
+ return node.hasLink(language);
+ }
+ return false;
+ }
+
}
Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java Fri Dec 15 09:01:14 2006
@@ -382,4 +382,16 @@
parent.moveUp(node.getName());
}
+ public boolean contains(String path, String language) {
+ if (contains(path)) {
+ SiteNode node;
+ try {
+ node = getNode(path);
+ } catch (SiteException e) {
+ throw new RuntimeException(e);
+ }
+ return node.hasLink(language);
+ }
+ return false;
+ }
}
Modified: lenya/trunk/src/targets/webapp-build.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/targets/webapp-build.xml?view=diff&rev=487598&r1=487597&r2=487598
==============================================================================
--- lenya/trunk/src/targets/webapp-build.xml (original)
+++ lenya/trunk/src/targets/webapp-build.xml Fri Dec 15 09:01:14 2006
@@ -33,6 +33,19 @@
</antcall>
</target>
+ <target name="compile-impl" description="compile and deploy core implementation">
+ <path id="classpath.impl">
+ <path refid="classpath"/>
+ <fileset dir="${build.webapp}/WEB-INF/lib" includes="lenya-*-api.jar"/>
+ </path>
+ <antcall target="compile-src">
+ <param name="compile.src.dir" value="${src.java.impl.dir}"/>
+ <param name="compile.dest.dir" value="${build.dir}/impl"/>
+ <param name="compile.classpath" value="classpath.impl"/>
+ <param name="jar.name" value="impl"/>
+ </antcall>
+ </target>
+
<!--
This target creates a webapp directory which exactly mirrors how
the war file will look. It is used to create the war file for
@@ -128,19 +141,7 @@
</delete>
<antcall target="compile-api"/>
-
- <path id="classpath.impl">
- <path refid="classpath"/>
- <fileset dir="${build.webapp}/WEB-INF/lib" includes="lenya-*-api.jar"/>
- </path>
-
- <!-- compile core implementation -->
- <antcall target="compile-src">
- <param name="compile.src.dir" value="${src.java.impl.dir}"/>
- <param name="compile.dest.dir" value="${build.dir}/impl"/>
- <param name="compile.classpath" value="classpath.impl"/>
- <param name="jar.name" value="impl"/>
- </antcall>
+ <antcall target="compile-impl"/>
<!--
<antcall target="deploy-modules"/>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org
Re: svn commit: r487598 - in /lenya/trunk/src: impl/java/org/apache/lenya/cms/publication/
impl/test/org/apache/lenya/cms/publication/ java/org/apache/lenya/cms/cocoon/acting/
java/org/apache/lenya/cms/cocoon/components/modules/input/ java/org/apache/lenya...
Posted by Richard Frovarp <Ri...@sendit.nodak.edu>.
This broke something. Clean build of Lenya plus Cocoon results in:
Message: Failed to process pipeline at <map:serialize> -
file:/home/rfrovarp/lenya-1.4.x/build/lenya/webapp/sitemap.xmap:663:41
at <map:transform> -
file:/home/rfrovarp/lenya-1.4.x/build/lenya/webapp/sitemap.xmap:548:76
at <map:transform> -
file:/home/rfrovarp/lenya-1.4.x/build/lenya/webapp/sitemap.xmap:545:70
at <map:transform type="i18n"> -
file:/home/rfrovarp/lenya-1.4.x/build/lenya/webapp/sitemap.xmap:542:34
at <map:transform> -
file:/home/rfrovarp/lenya-1.4.x/build/lenya/webapp/sitemap.xmap:657:72
at <map:generate type="notifying"> -
file:/home/rfrovarp/lenya-1.4.x/build/lenya/webapp/sitemap.xmap:656:39
Sender: org.apache.cocoon.servlet.CocoonServlet
Source: Cocoon Servlet
Request URI
index.html
cause
java.lang.NullPointerException
request-uri
/index.html
stacktrace
java.lang.NullPointerException
at org.apache.lenya.cms.cocoon.source.FallbackSourceFactory.getSource(FallbackSourceFactory.java:130)
at org.apache.excalibur.source.impl.SourceResolverImpl.resolveURI(SourceResolverImpl.java:208)
at org.apache.cocoon.components.CocoonComponentManager.resolveURI(CocoonComponentManager.java:558)
at org.apache.cocoon.environment.AbstractEnvironment.resolveURI(AbstractEnvironment.java:553)
at org.apache.cocoon.environment.AbstractEnvironment.resolveURI(AbstractEnvironment.java:540)
at org.apache.cocoon.transformation.TraxTransformer.setup(TraxTransformer.java:310)
at org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.setupPipeline(AbstractProcessingPipeline.java:398)
at org.apache.cocoon.components.pipeline.impl.AbstractCachingProcessingPipeline.setupPipeline(AbstractCachingProcessingPipeline.java:717)
at org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.preparePipeline(AbstractProcessingPipeline.java:501)
at org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.process(AbstractProcessingPipeline.java:453)
at org.apache.cocoon.components.treeprocessor.sitemap.SerializeNode.invoke(SerializeNode.java:121)
at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:69)
at org.apache.cocoon.components.treeprocessor.sitemap.HandleErrorsNode.invoke(HandleErrorsNode.java:89)
at org.apache.cocoon.components.treeprocessor.sitemap.ErrorHandlerHelper.prepareErrorHandler(ErrorHandlerHelper.java:182)
at org.apache.cocoon.components.treeprocessor.sitemap.ErrorHandlerHelper.prepareErrorHandler(ErrorHandlerHelper.java:135)
at org.apache.cocoon.components.treeprocessor.sitemap.ErrorHandlerHelper.invokeErrorHandler(ErrorHandlerHelper.java:108)
at org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:100)
at org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process(ConcreteTreeProcessor.java:235)
at org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process(ConcreteTreeProcessor.java:177)
at org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:253)
at org.apache.cocoon.Cocoon.process(Cocoon.java:699)
at org.apache.cocoon.servlet.CocoonServlet.service(CocoonServlet.java:1154)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:427)
at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:475)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:567)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1565)
at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:635)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1517)
at org.mortbay.jetty.plus.PlusWebAppContext.handle(PlusWebAppContext.java:158)
at org.mortbay.http.HttpServer.service(HttpServer.java:954)
at org.mortbay.http.HttpConnection.service(HttpConnection.java:814)
at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:981)
at org.mortbay.http.HttpConnection.handle(HttpConnection.java:831)
at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:244)
at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
andreas@apache.org wrote:
> Author: andreas
> Date: Fri Dec 15 09:01:14 2006
> New Revision: 487598
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=487598
> Log:
> Allow to use extensions instead of regexps in BypassableAccessController, various refactorings to improve performance, e.g. avoid duplicate source resolving
>
> Added:
> lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/VisitingSourceResolver.java
> - copied, changed from r482993, lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/URIResolver.java
> Removed:
> lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/URIResolver.java
> Modified:
> lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java
> lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/TestPageEnvelope.java
> lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/RevisionControllerAction.java
> lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/AbstractPageEnvelopeModule.java
> lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PageEnvelopeModule.java
> lenya/trunk/src/java/org/apache/lenya/cms/cocoon/flow/FlowHelperImpl.java
> lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/FallbackSourceFactory.java
> lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/TemplateFallbackSourceFactory.java
> lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java
> lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelopeFactory.java
> lenya/trunk/src/java/org/apache/lenya/cms/publication/URLInformation.java
> lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/AllExistingSourceResolver.java
> lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingAncestorSourceResolver.java
> lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingSourceResolver.java
> lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/SourceVisitor.java
> lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentLanguagesHelper.java
> lenya/trunk/src/java/org/apache/lenya/cms/site/SiteStructure.java
> lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java
> lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStore.java
> lenya/trunk/src/modules-core/ac-impl/config/cocoon-xconf/bypassable-access-controller.xconf
> lenya/trunk/src/modules-core/ac-impl/java/src/org/apache/lenya/ac/impl/BypassableAccessController.java
> lenya/trunk/src/modules-core/ac-impl/java/src/org/apache/lenya/cms/ac/DocumentPolicyManagerWrapper.java
> lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/LinkRewritingTransformer.java
> lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/ChangeNodeID.java
> lenya/trunk/src/modules-core/templating-impl/java/src/org/apache/lenya/cms/publication/templating/PublicationTemplateManagerImpl.java
> lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/DefaultSiteTree.java
> lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java
> lenya/trunk/src/targets/webapp-build.xml
>
> Modified: lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java (original)
> +++ lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java Fri Dec 15 09:01:14 2006
> @@ -17,6 +17,8 @@
> */
> package org.apache.lenya.cms.publication;
>
> +import java.util.StringTokenizer;
> +
> import org.apache.avalon.framework.container.ContainerUtil;
> import org.apache.avalon.framework.logger.AbstractLogEnabled;
> import org.apache.avalon.framework.logger.Logger;
> @@ -181,7 +183,11 @@
> DocumentBuilder builder = publication.getDocumentBuilder();
> if (builder.isDocument(webappUrl)) {
> DocumentLocator locator = builder.getLocator(this, webappUrl);
> - return SiteUtil.contains(this.manager, this, locator);
> + String area = locator.getArea();
> + String path = locator.getPath();
> + String language = locator.getLanguage();
> + SiteStructure site = publication.getArea(area).getSite();
> + return site.contains(path, language);
> } else {
> return false;
> }
> @@ -216,7 +222,7 @@
> String uuid = null;
> try {
> Publication publication = getPublication(locator.getPublicationId());
> - if (SiteUtil.isDocument(this.manager, this, webappUrl)) {
> + if (SiteUtil.isDocument(this, webappUrl)) {
> uuid = publication.getArea(area).getSite().getNode(locator.getPath()).getUuid();
> } else {
> UUIDGenerator generator = (UUIDGenerator) this.manager.lookup(UUIDGenerator.ROLE);
> @@ -250,11 +256,11 @@
> if (getLogger().isDebugEnabled())
> getLogger().debug("DocumentFactory::build() called with key [" + key + "]");
>
> - String[] snippets = key.split(":");
> - String publicationId = snippets[0];
> - String area = snippets[1];
> - String uuid = snippets[2];
> - String language = snippets[3];
> + StringTokenizer tokenizer = new StringTokenizer(key, ":");
> + String publicationId = tokenizer.nextToken();
> + String area = tokenizer.nextToken();
> + String uuid = tokenizer.nextToken();
> + String language = tokenizer.nextToken();
>
> Document document;
> try {
>
> Modified: lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/TestPageEnvelope.java
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/TestPageEnvelope.java?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/TestPageEnvelope.java (original)
> +++ lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/TestPageEnvelope.java Fri Dec 15 09:01:14 2006
> @@ -38,7 +38,7 @@
> */
> public TestPageEnvelope(Publication publication, String url, ServiceManager manager,
> Logger logger) throws PageEnvelopeException {
> - super(manager);
> + super();
> setContext("");
>
> try {
>
> Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/RevisionControllerAction.java
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/RevisionControllerAction.java?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/RevisionControllerAction.java (original)
> +++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/RevisionControllerAction.java Fri Dec 15 09:01:14 2006
> @@ -33,7 +33,6 @@
> import org.apache.lenya.ac.User;
> 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.DocumentUtil;
> import org.apache.lenya.cms.publication.PageEnvelope;
> import org.apache.lenya.cms.publication.PageEnvelopeFactory;
> @@ -47,7 +46,8 @@
> /**
> * Revision controller action.
> *
> - * @version $Id$
> + * @version $Id: RevisionControllerAction.java 487290 2006-12-14 18:18:35Z
> + * andreas $
> */
> public class RevisionControllerAction extends ServiceableAction {
>
> @@ -59,8 +59,8 @@
>
> /**
> * @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 {
> @@ -81,17 +81,15 @@
> } catch (Exception e) {
> throw new AccessControlException(e);
> }
> - org.apache.lenya.cms.repository.Session repoSession = RepositoryUtil.getSession(this.manager,
> - request);
> + org.apache.lenya.cms.repository.Session repoSession = RepositoryUtil.getSession(
> + this.manager, request);
>
> DocumentFactory factory = DocumentUtil.createDocumentFactory(this.manager, repoSession);
> Document document = null;
>
> try {
> publication = PublicationUtil.getPublication(this.manager, objectModel);
> - envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(this.manager,
> - factory,
> - objectModel,
> + envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(factory, objectModel,
> publication);
> document = envelope.getDocument();
> } catch (Exception e) {
>
> Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/AbstractPageEnvelopeModule.java
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/AbstractPageEnvelopeModule.java?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/AbstractPageEnvelopeModule.java (original)
> +++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/AbstractPageEnvelopeModule.java Fri Dec 15 09:01:14 2006
> @@ -74,7 +74,7 @@
> try {
> DocumentFactory factory = getDocumentFactory();
> Publication pub = PublicationUtil.getPublicationFromUrl(this.manager, factory, webappUrl);
> - envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(this.manager,
> + envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(
> factory,
> contextPath,
> webappUrl,
>
> Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PageEnvelopeModule.java
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PageEnvelopeModule.java?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PageEnvelopeModule.java (original)
> +++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PageEnvelopeModule.java Fri Dec 15 09:01:14 2006
> @@ -41,8 +41,8 @@
> import org.apache.lenya.util.ServletHelper;
>
> /**
> - * Input module wrapping the page envelope. This module provides publication related information
> - * such as document-id, area, publication-id.
> + * Input module wrapping the page envelope. This module provides publication
> + * related information such as document-id, area, publication-id.
> *
> * @see org.apache.lenya.cms.publication.PageEnvelope
> * @deprecated use DocumentInfoModule instead.
> @@ -53,7 +53,8 @@
>
> /**
> * @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(final String attributeName, Configuration modeConf, Map objectModel)
> throws ConfigurationException {
> @@ -84,50 +85,50 @@
> value = envelope.getPublication().getBreadcrumbPrefix();
> } else if (name.equals(PageEnvelope.DOCUMENT_PATH)) {
> value = getPath(envelope, objectModel);
> - }
> -
> - Document document = envelope.getDocument();
> - if (document != null) {
> - if (name.equals(PageEnvelope.DOCUMENT)) {
> - value = document;
> - } else if (name.equals(PageEnvelope.DOCUMENT_ID)) {
> - getLogger().warn(
> - "This attribute is deprecated."
> - + " Use document-path or document-uuid instead!");
> - value = document.getId();
> - } else if (name.equals(PageEnvelope.DOCUMENT_PARENT)) {
> - value = document.getLocator().getParent().getPath();
> - } else if (name.equals(PageEnvelope.DOCUMENT_NAME)) {
> - value = document.getName();
> - } else if (name.equals(PageEnvelope.DOCUMENT_LABEL)) {
> - value = document.getLink().getLabel();
> - } else if (name.equals(PageEnvelope.DOCUMENT_URL)) {
> - value = document.getCanonicalDocumentURL();
> - } else if (name.equals(PageEnvelope.DOCUMENT_URL_WITHOUT_LANGUAGE)) {
> - value = document.getCanonicalWebappURL();
> - } else if (name.equals(PageEnvelope.DOCUMENT_FILE)) {
> - value = document.getFile();
> - } else if (name.equals(PageEnvelope.DOCUMENT_EXTENSION)) {
> - value = document.getExtension();
> - } else if (name.equals(PageEnvelope.DOCUMENT_SOURCE_EXTENSION)) {
> - value = document.getSourceExtension();
> - } else if (name.equals(PageEnvelope.DOCUMENT_UUID)) {
> - value = document.getUUID();
> - } else if (name.equals(PageEnvelope.DOCUMENT_LANGUAGE)) {
> - value = document.getLanguage();
> - } else if (name.equals(PageEnvelope.DOCUMENT_LANGUAGES)) {
> - value = document.getLanguages();
> - } else if (name.equals(PageEnvelope.DOCUMENT_LANGUAGES_CSV)) {
> - value = StringUtils.join(document.getLanguages(), ',');
> - } else if (name.equals(PageEnvelope.DOCUMENT_LASTMODIFIED)) {
> - Date date = new Date(document.getLastModified());
> - value = new SimpleDateFormat(DATE_FORMAT).format(date);
> - } else if (name.equals(PageEnvelope.DOCUMENT_TYPE)) {
> - ResourceType resourceType = document.getResourceType();
> - if (resourceType == null) {
> - value = null;
> - } else {
> - value = resourceType.getName();
> + } else {
> + Document document = envelope.getDocument();
> + if (document != null) {
> + if (name.equals(PageEnvelope.DOCUMENT)) {
> + value = document;
> + } else if (name.equals(PageEnvelope.DOCUMENT_ID)) {
> + getLogger().warn(
> + "This attribute is deprecated."
> + + " Use document-path or document-uuid instead!");
> + value = document.getId();
> + } else if (name.equals(PageEnvelope.DOCUMENT_PARENT)) {
> + value = document.getLocator().getParent().getPath();
> + } else if (name.equals(PageEnvelope.DOCUMENT_NAME)) {
> + value = document.getName();
> + } else if (name.equals(PageEnvelope.DOCUMENT_LABEL)) {
> + value = document.getLink().getLabel();
> + } else if (name.equals(PageEnvelope.DOCUMENT_URL)) {
> + value = document.getCanonicalDocumentURL();
> + } else if (name.equals(PageEnvelope.DOCUMENT_URL_WITHOUT_LANGUAGE)) {
> + value = document.getCanonicalWebappURL();
> + } else if (name.equals(PageEnvelope.DOCUMENT_FILE)) {
> + value = document.getFile();
> + } else if (name.equals(PageEnvelope.DOCUMENT_EXTENSION)) {
> + value = document.getExtension();
> + } else if (name.equals(PageEnvelope.DOCUMENT_SOURCE_EXTENSION)) {
> + value = document.getSourceExtension();
> + } else if (name.equals(PageEnvelope.DOCUMENT_UUID)) {
> + value = document.getUUID();
> + } else if (name.equals(PageEnvelope.DOCUMENT_LANGUAGE)) {
> + value = document.getLanguage();
> + } else if (name.equals(PageEnvelope.DOCUMENT_LANGUAGES)) {
> + value = document.getLanguages();
> + } else if (name.equals(PageEnvelope.DOCUMENT_LANGUAGES_CSV)) {
> + value = StringUtils.join(document.getLanguages(), ',');
> + } else if (name.equals(PageEnvelope.DOCUMENT_LASTMODIFIED)) {
> + Date date = new Date(document.getLastModified());
> + value = new SimpleDateFormat(DATE_FORMAT).format(date);
> + } else if (name.equals(PageEnvelope.DOCUMENT_TYPE)) {
> + ResourceType resourceType = document.getResourceType();
> + if (resourceType == null) {
> + value = null;
> + } else {
> + value = resourceType.getName();
> + }
> }
> }
> }
> @@ -174,7 +175,8 @@
>
> /**
> * @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/src/java/org/apache/lenya/cms/cocoon/flow/FlowHelperImpl.java
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/flow/FlowHelperImpl.java?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/flow/FlowHelperImpl.java (original)
> +++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/flow/FlowHelperImpl.java Fri Dec 15 09:01:14 2006
> @@ -73,7 +73,7 @@
> DocumentFactory map = DocumentUtil.createDocumentFactory(this.manager, session);
> PageEnvelopeFactory factory = PageEnvelopeFactory.getInstance();
> Publication publication = PublicationUtil.getPublication(this.manager, request);
> - return factory.getPageEnvelope(this.manager, map, cocoon.getObjectModel(), publication);
> + return factory.getPageEnvelope(map, cocoon.getObjectModel(), publication);
> } catch (Exception e) {
> throw new PageEnvelopeException(e);
> }
>
> Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/FallbackSourceFactory.java
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/FallbackSourceFactory.java?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/FallbackSourceFactory.java (original)
> +++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/FallbackSourceFactory.java Fri Dec 15 09:01:14 2006
> @@ -45,7 +45,7 @@
> import org.apache.lenya.cms.publication.URLInformation;
> import org.apache.lenya.cms.publication.templating.ExistingSourceResolver;
> import org.apache.lenya.cms.publication.templating.PublicationTemplateManager;
> -import org.apache.lenya.cms.publication.templating.URIResolver;
> +import org.apache.lenya.cms.publication.templating.VisitingSourceResolver;
>
> /**
> * Source factory following the fallback principle.
> @@ -68,8 +68,6 @@
> public Source getSource(final String location, Map parameters) throws IOException,
> MalformedURLException {
>
> - String resolvedUri = null;
> -
> long startTime = new GregorianCalendar().getTimeInMillis();
>
> // Remove the protocol and the first '//'
> @@ -103,7 +101,7 @@
> PublicationManager pubMgr = null;
> PublicationTemplateManager templateManager = null;
> SourceResolver sourceResolver = null;
> - Source source;
> + Source source = null;
> try {
> sourceResolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
>
> @@ -123,16 +121,16 @@
> DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);
> Publication pub = pubMgr.getPublication(factory, publicationId);
> if (pub.exists()) {
> - URIResolver resolver = getSourceVisitor();
> + VisitingSourceResolver resolver = getSourceVisitor();
> templateManager.visit(pub, path, resolver);
> - resolvedUri = resolver.getURI();
> + source = resolver.getSource();
> }
>
> if (getLogger().isDebugEnabled()) {
> - getLogger().debug("Resolved URI: [" + resolvedUri + "]");
> + getLogger().debug("Resolved URI: [" + source.getURI() + "]");
> }
>
> - if (resolvedUri == null) {
> + if (source == null) {
> if (path.startsWith("lenya/modules/")) {
> ModuleManager moduleMgr = null;
> try {
> @@ -140,7 +138,7 @@
> final String moduleShortcut = path.split("/")[2];
> String baseUri = moduleMgr.getBaseURI(moduleShortcut);
> final String modulePath = path.substring(("lenya/modules/" + moduleShortcut).length());
> - resolvedUri = baseUri + modulePath;
> + source = sourceResolver.resolveURI(baseUri + modulePath);
> } finally {
> if (moduleMgr != null) {
> this.manager.release(moduleMgr);
> @@ -148,12 +146,10 @@
> }
> } else {
> String contextUri = "context://" + path;
> - resolvedUri = contextUri;
> + source = sourceResolver.resolveURI(contextUri);
> }
> }
>
> - source = sourceResolver.resolveURI(resolvedUri);
> -
> } catch (Exception e) {
> throw new RuntimeException("Resolving path [" + location + "] failed: ", e);
> } finally {
> @@ -178,7 +174,7 @@
> return source;
> }
>
> - protected URIResolver getSourceVisitor() {
> + protected VisitingSourceResolver getSourceVisitor() {
> return new ExistingSourceResolver();
> }
>
>
> Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/TemplateFallbackSourceFactory.java
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/TemplateFallbackSourceFactory.java?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/TemplateFallbackSourceFactory.java (original)
> +++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/TemplateFallbackSourceFactory.java Fri Dec 15 09:01:14 2006
> @@ -18,7 +18,7 @@
> package org.apache.lenya.cms.cocoon.source;
>
> import org.apache.lenya.cms.publication.templating.ExistingAncestorSourceResolver;
> -import org.apache.lenya.cms.publication.templating.URIResolver;
> +import org.apache.lenya.cms.publication.templating.VisitingSourceResolver;
>
> /**
> * Source factory following the fallback principle, resolving the existing ancestor of the existing resource.
> @@ -34,7 +34,7 @@
> super();
> }
>
> - protected URIResolver getSourceVisitor() {
> + protected VisitingSourceResolver getSourceVisitor() {
> return new ExistingAncestorSourceResolver();
> }
>
>
> Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java (original)
> +++ lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java Fri Dec 15 09:01:14 2006
> @@ -22,7 +22,6 @@
>
> import java.io.File;
>
> -import org.apache.avalon.framework.service.ServiceManager;
> import org.apache.cocoon.environment.Request;
> import org.apache.lenya.cms.rc.RCEnvironment;
> import org.apache.lenya.cms.site.SiteUtil;
> @@ -163,19 +162,15 @@
> private String area;
> private Publication publication;
>
> - private ServiceManager manager;
> -
> /**
> * Constructor.
> * @param manager The service manager.
> */
> - protected PageEnvelope(ServiceManager manager) {
> - this.manager = manager;
> + protected PageEnvelope() {
> }
>
> /**
> * Creates a page envelope from an object model.
> - * @param manager The service manager.
> * @param map The identity map to use.
> * @param contextPath The servlet context prefix.
> * @param webappUrl The web application URL.
> @@ -183,14 +178,13 @@
> * @param publication The publication.
> * @throws PageEnvelopeException when something went wrong.
> */
> - public PageEnvelope(ServiceManager manager, DocumentFactory map, String contextPath,
> + public PageEnvelope(DocumentFactory map, String contextPath,
> String webappUrl, File servletContext, Publication publication)
> throws PageEnvelopeException {
> this.factory = map;
> this.context = contextPath;
> this.webappUrl = webappUrl;
> this.publication = publication;
> - this.manager = manager;
> }
>
> private String webappUrl;
> @@ -289,7 +283,7 @@
> if (!documentChecked) {
> try {
> documentChecked = true;
> - if (SiteUtil.isDocument(this.manager, getDocumentFactory(), this.webappUrl)) {
> + if (SiteUtil.isDocument(getDocumentFactory(), this.webappUrl)) {
> this.document = getDocumentFactory().getFromURL(this.webappUrl);
> }
> } catch (final Exception e) {
>
> Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelopeFactory.java
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelopeFactory.java?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelopeFactory.java (original)
> +++ lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelopeFactory.java Fri Dec 15 09:01:14 2006
> @@ -23,7 +23,6 @@
> import java.io.File;
> import java.util.Map;
>
> -import org.apache.avalon.framework.service.ServiceManager;
> import org.apache.cocoon.environment.Context;
> import org.apache.cocoon.environment.ObjectModelHelper;
> import org.apache.cocoon.environment.Request;
> @@ -55,31 +54,24 @@
>
> /**
> * Returns the page envelope for the object model of a Cocoon component.
> - * @param manager The service manager.
> * @param map The document identity map to use.
> * @param objectModel The object model.
> * @param pub The publication.
> * @return A page envelope.
> * @throws PageEnvelopeException if something went wrong.
> */
> - public PageEnvelope getPageEnvelope(ServiceManager manager, DocumentFactory map,
> - Map objectModel, Publication pub) throws PageEnvelopeException {
> + public PageEnvelope getPageEnvelope(DocumentFactory map, Map objectModel, Publication pub)
> + throws PageEnvelopeException {
> Request request = ObjectModelHelper.getRequest(objectModel);
> String contextPath = request.getContextPath();
> Context context = ObjectModelHelper.getContext(objectModel);
> String webappUrl = ServletHelper.getWebappURI(request);
> String servletContextPath = context.getRealPath("");
> - return getPageEnvelope(manager,
> - map,
> - contextPath,
> - webappUrl,
> - new File(servletContextPath),
> - pub);
> + return getPageEnvelope(map, contextPath, webappUrl, new File(servletContextPath), pub);
> }
>
> /**
> * Creates a page envelope.
> - * @param manager The service manager.
> * @param map The document identity map to use.
> * @param contextPath The servlet context prefix.
> * @param webappUrl The web application URL.
> @@ -88,15 +80,9 @@
> * @return A page envelope.
> * @throws PageEnvelopeException if something went wrong.
> */
> - public PageEnvelope getPageEnvelope(ServiceManager manager, DocumentFactory map,
> - String contextPath, String webappUrl, File servletContext, Publication pub)
> - throws PageEnvelopeException {
> - PageEnvelope envelope = new PageEnvelope(manager,
> - map,
> - contextPath,
> - webappUrl,
> - servletContext,
> - pub);
> + public PageEnvelope getPageEnvelope(DocumentFactory map, String contextPath, String webappUrl,
> + File servletContext, Publication pub) throws PageEnvelopeException {
> + PageEnvelope envelope = new PageEnvelope(map, contextPath, webappUrl, servletContext, pub);
> return envelope;
> }
>
>
> Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/URLInformation.java
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/URLInformation.java?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/java/org/apache/lenya/cms/publication/URLInformation.java (original)
> +++ lenya/trunk/src/java/org/apache/lenya/cms/publication/URLInformation.java Fri Dec 15 09:01:14 2006
> @@ -30,11 +30,21 @@
> private String completeArea = null;
> private String documentUrl = null;
>
> + private String url;
> +
> /**
> * Returns the area (without the "webdav" prefix).
> * @return A string.
> */
> public String getArea() {
> + if (this.area == null) {
> + String completeArea = getCompleteArea();
> + if (completeArea.equals(Publication.DAV_AREA)) {
> + this.area = Publication.AUTHORING_AREA;
> + } else {
> + this.area = completeArea;
> + }
> + }
> return this.area;
> }
>
> @@ -43,6 +53,14 @@
> * @return A string.
> */
> public String getCompleteArea() {
> + if (this.completeArea == null) {
> + String pubUrl = this.url.substring(getPublicationId().length());
> + if (pubUrl.startsWith("/")) {
> + this.completeArea = extractBeforeSlash(pubUrl.substring(1));
> + } else {
> + this.completeArea = null;
> + }
> + }
> return this.completeArea;
> }
>
> @@ -51,6 +69,14 @@
> * @return A string.
> */
> public String getDocumentUrl() {
> + if (this.documentUrl == null) {
> + String pubId = getPublicationId();
> + String area = getArea();
> + if (pubId != null && area != null) {
> + String prefix = pubId + "/" + area;
> + this.documentUrl = this.url.substring(prefix.length());
> + }
> + }
> return this.documentUrl;
> }
>
> @@ -59,41 +85,38 @@
> * @return A string.
> */
> public String getPublicationId() {
> + if (this.publicationId == null) {
> + this.publicationId = extractBeforeSlash(this.url);
> + }
> return this.publicationId;
> }
>
> + protected String extractBeforeSlash(String remaining) {
> +
> + if (remaining.length() == 0) {
> + return null;
> + }
> +
> + String step;
> + int slashIndex = remaining.indexOf('/');
> + if (slashIndex == -1) {
> + step = remaining;
> + } else {
> + step = remaining.substring(0, slashIndex);
> + }
> + return step;
> + }
> +
> /**
> * Ctor.
> * @param webappUrl A webapp URL (without context prefix).
> */
> public URLInformation(String webappUrl) {
> -
> +
> if (!webappUrl.startsWith("/")) {
> throw new RuntimeException("The URL [" + webappUrl + "] doesn't start with a slash!");
> }
>
> - String url = webappUrl.substring(1);
> -
> - String[] fragments = url.split("/");
> - if (fragments.length > 0) {
> - this.publicationId = fragments[0];
> -
> - if (fragments.length > 1) {
> - this.completeArea = fragments[1];
> -
> - if (url.length() > (this.publicationId + "/" + this.completeArea).length()) {
> - this.documentUrl = url.substring((this.publicationId + "/" + this.completeArea).length());
> - } else {
> - this.documentUrl = "";
> - }
> -
> - if (this.completeArea.equals(Publication.DAV_AREA)) {
> - this.area = Publication.AUTHORING_AREA;
> - } else {
> - this.area = this.completeArea;
> - }
> - }
> - }
> + this.url = webappUrl.substring(1);
> }
> -
> }
>
> Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/AllExistingSourceResolver.java
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/AllExistingSourceResolver.java?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/AllExistingSourceResolver.java (original)
> +++ lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/AllExistingSourceResolver.java Fri Dec 15 09:01:14 2006
> @@ -21,20 +21,31 @@
> import java.util.List;
>
> import org.apache.excalibur.source.Source;
> +import org.apache.excalibur.source.SourceResolver;
>
> /**
> * Source visitor to obtain all existing sources.
> */
> public class AllExistingSourceResolver implements SourceVisitor {
>
> - public void visit(Source source) {
> - if (source.exists()) {
> - this.uris.add(source.getURI());
> + public void visit(SourceResolver resolver, String sourceUri) {
> + Source source = null;
> + try {
> + source = resolver.resolveURI(sourceUri);
> + if (source.exists()) {
> + this.uris.add(sourceUri);
> + }
> + } catch (Exception e) {
> + throw new RuntimeException(e);
> + } finally {
> + if (source != null) {
> + resolver.release(source);
> + }
> }
> }
> -
> +
> private List uris = new ArrayList();
> -
> +
> /**
> * @return All existing source URIs.
> */
>
> Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingAncestorSourceResolver.java
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingAncestorSourceResolver.java?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingAncestorSourceResolver.java (original)
> +++ lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingAncestorSourceResolver.java Fri Dec 15 09:01:14 2006
> @@ -19,15 +19,16 @@
> package org.apache.lenya.cms.publication.templating;
>
> import org.apache.excalibur.source.Source;
> +import org.apache.excalibur.source.SourceResolver;
>
> /**
> * Source visitor to obtain the first existing source.
> *
> * @version $Id: ExistingSourceResolver.java 179568 2005-06-02 09:27:26Z jwkaltz $
> */
> -public class ExistingAncestorSourceResolver implements URIResolver {
> -
> - private String uri;
> +public class ExistingAncestorSourceResolver implements VisitingSourceResolver {
> +
> + private Source source;
>
> /**
> * Ctor.
> @@ -35,25 +36,31 @@
> public ExistingAncestorSourceResolver() {
> super();
> }
> -
> +
> /**
> - * Returns the URI of the first existing source.
> - * @return The URI
> + * @return the ancestor of the first existing source.
> */
> - public String getURI() {
> - return this.uri;
> + public Source getSource() {
> + return this.source;
> }
>
> private int matches = 0;
>
> - /**
> - * @see org.apache.lenya.cms.publication.templating.SourceVisitor#visit(org.apache.excalibur.source.Source)
> - */
> - public void visit(Source source) {
> - if (source.exists()) {
> - matches++;
> - if (matches == 2) {
> - this.uri = source.getURI();
> + public void visit(SourceResolver resolver, String sourceUri) {
> + Source source = null;
> + try {
> + source = resolver.resolveURI(sourceUri);
> + if (source.exists()) {
> + matches++;
> + if (matches == 2) {
> + this.source = source;
> + }
> + }
> + } catch (Exception e) {
> + throw new RuntimeException(e);
> + } finally {
> + if (source != null) {
> + resolver.release(source);
> }
> }
> }
>
> Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingSourceResolver.java
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingSourceResolver.java?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingSourceResolver.java (original)
> +++ lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingSourceResolver.java Fri Dec 15 09:01:14 2006
> @@ -19,15 +19,16 @@
> package org.apache.lenya.cms.publication.templating;
>
> import org.apache.excalibur.source.Source;
> +import org.apache.excalibur.source.SourceResolver;
>
> /**
> * Source visitor to obtain the first existing source.
> *
> * @version $Id$
> */
> -public class ExistingSourceResolver implements URIResolver {
> -
> - private String uri;
> +public class ExistingSourceResolver implements VisitingSourceResolver {
> +
> + private Source source;
>
> /**
> * Ctor.
> @@ -35,21 +36,29 @@
> public ExistingSourceResolver() {
> super();
> }
> -
> +
> /**
> - * Returns the URI of the first existing source.
> - * @return The URI
> + * @return the first existing source.
> */
> - public String getURI() {
> - return this.uri;
> + public Source getSource() {
> + return this.source;
> }
> -
> - /**
> - * @see org.apache.lenya.cms.publication.templating.SourceVisitor#visit(org.apache.excalibur.source.Source)
> - */
> - public void visit(Source source) {
> - if (this.uri == null && source.exists()) {
> - this.uri = source.getURI();
> +
> + public void visit(SourceResolver resolver, String sourceUri) {
> + if (this.source == null) {
> + Source source = null;
> + try {
> + source = resolver.resolveURI(sourceUri);
> + if (source.exists()) {
> + this.source = source;
> + }
> + } catch (Exception e) {
> + throw new RuntimeException(e);
> + } finally {
> + if (source != null) {
> + resolver.release(source);
> + }
> + }
> }
> }
>
>
> Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/SourceVisitor.java
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/SourceVisitor.java?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/SourceVisitor.java (original)
> +++ lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/SourceVisitor.java Fri Dec 15 09:01:14 2006
> @@ -17,7 +17,7 @@
> */
> package org.apache.lenya.cms.publication.templating;
>
> -import org.apache.excalibur.source.Source;
> +import org.apache.excalibur.source.SourceResolver;
>
> /**
> * @version $Id$
> @@ -25,9 +25,12 @@
> public interface SourceVisitor {
>
> /**
> - * Visits a source.
> - * @param source The source.
> + * Visits a source. We pass the resolver and the URI so that the visitor can
> + * decide if it wants to resolve the source (mainly for performance
> + * reasons).
> + * @param resolver The resolver.
> + * @param sourceUri The source URI.
> */
> - void visit(Source source);
> + void visit(SourceResolver resolver, String sourceUri);
>
> }
>
> Copied: lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/VisitingSourceResolver.java (from r482993, lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/URIResolver.java)
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/VisitingSourceResolver.java?view=diff&rev=487598&p1=lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/URIResolver.java&r1=482993&p2=lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/VisitingSourceResolver.java&r2=487598
> ==============================================================================
> --- lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/URIResolver.java (original)
> +++ lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/VisitingSourceResolver.java Fri Dec 15 09:01:14 2006
> @@ -17,14 +17,16 @@
> */
> package org.apache.lenya.cms.publication.templating;
>
> +import org.apache.excalibur.source.Source;
> +
> /**
> * URI resolver.
> */
> -public interface URIResolver extends SourceVisitor {
> +public interface VisitingSourceResolver extends SourceVisitor {
>
> /**
> - * @return The resolved URI.
> + * @return The resolved source.
> */
> - String getURI();
> + Source getSource();
>
> }
>
> Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentLanguagesHelper.java
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentLanguagesHelper.java?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentLanguagesHelper.java (original)
> +++ lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentLanguagesHelper.java Fri Dec 15 09:01:14 2006
> @@ -103,7 +103,8 @@
> String[] languages = pub.getLanguages();
> for (int i = 0; i < languages.length; i++) {
> DocumentLocator version = locator.getLanguageVersion(languages[i]);
> - if (SiteUtil.contains(this.manager, factory, version)) {
> + Publication pub = factory.getPublication(locator.getPublicationId());
> + if (pub.getArea(version.getArea()).getSite().contains(version.getPath(), version.getLanguage())) {
> availableLanguages.add(languages[i]);
> }
> }
>
> Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/SiteStructure.java
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/site/SiteStructure.java?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/java/org/apache/lenya/cms/site/SiteStructure.java (original)
> +++ lenya/trunk/src/java/org/apache/lenya/cms/site/SiteStructure.java Fri Dec 15 09:01:14 2006
> @@ -64,6 +64,14 @@
> boolean contains(String path);
>
> /**
> + * Checks if a link is contained for a certain path and language.
> + * @param path The path.
> + * @param language The language.
> + * @return A boolean value.
> + */
> + boolean contains(String path, String language);
> +
> + /**
> * Checks if the structure contains a link with a certain UUID and language.
> * @param uuid The UUID.
> * @param language The language.
>
> Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java (original)
> +++ lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java Fri Dec 15 09:01:14 2006
> @@ -24,7 +24,6 @@
> import org.apache.avalon.framework.service.ServiceManager;
> import org.apache.avalon.framework.service.ServiceSelector;
> import org.apache.lenya.cms.publication.Document;
> -import org.apache.lenya.cms.publication.DocumentBuildException;
> import org.apache.lenya.cms.publication.DocumentBuilder;
> import org.apache.lenya.cms.publication.DocumentFactory;
> import org.apache.lenya.cms.publication.DocumentLocator;
> @@ -112,46 +111,15 @@
> }
> }
>
> - public static boolean contains(ServiceManager manager, DocumentFactory factory,
> - DocumentLocator locator) throws SiteException {
> - SiteManager siteManager = null;
> - ServiceSelector selector = null;
> -
> - try {
> - selector = (ServiceSelector) manager.lookup(SiteManager.ROLE + "Selector");
> - Publication pub = factory.getPublication(locator.getPublicationId());
> - String siteManagerHint = pub.getSiteManagerHint();
> - siteManager = (SiteManager) selector.select(siteManagerHint);
> - SiteStructure site = siteManager.getSiteStructure(factory, pub, locator.getArea());
> - String path = locator.getPath();
> - String language = locator.getLanguage();
> - return site.contains(path) && site.getNode(path).hasLink(language);
> - } catch (SiteException e) {
> - throw e;
> - } catch (Exception e) {
> - throw new SiteException(e);
> - } finally {
> - if (selector != null) {
> - if (siteManager != null) {
> - selector.release(siteManager);
> - }
> - manager.release(selector);
> - }
> - }
> - }
> -
> - public static boolean isDocument(ServiceManager manager, DocumentFactory factory,
> - String webappUrl) throws SiteException {
> + public static boolean isDocument(DocumentFactory factory, String webappUrl)
> + throws SiteException {
>
> URLInformation info = new URLInformation(webappUrl);
> try {
> Publication pub = factory.getPublication(info.getPublicationId());
> if (pub.exists()) {
> DocumentBuilder builder = pub.getDocumentBuilder();
> - if (builder.isDocument(webappUrl)) {
> - DocumentLocator locator = builder.getLocator(factory, webappUrl);
> - return contains(manager, factory, locator);
> - }
> + return builder.isDocument(webappUrl);
> }
> return false;
> } catch (SiteException e) {
> @@ -164,15 +132,18 @@
> public static Document getDocument(ServiceManager manager, DocumentFactory factory,
> String webappUrl) throws SiteException {
>
> - DocumentLocator locator = getLocator(manager, factory, webappUrl);
> - if (contains(manager, factory, locator)) {
> - try {
> + try {
> + DocumentLocator locator = getLocator(manager, factory, webappUrl);
> + Publication pub = factory.getPublication(locator.getPublicationId());
> + String path = locator.getPath();
> + String lang = locator.getLanguage();
> + if (pub.getArea(locator.getArea()).getSite().contains(path, lang)) {
> return factory.get(locator);
> - } catch (DocumentBuildException e) {
> - throw new SiteException(e);
> + } else {
> + throw new SiteException("No document for webapp URL [" + webappUrl + "]");
> }
> - } else {
> - throw new SiteException("No document for webapp URL [" + webappUrl + "]");
> + } catch (Exception e) {
> + throw new SiteException(e);
> }
> }
>
>
> Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStore.java
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStore.java?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStore.java (original)
> +++ lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStore.java Fri Dec 15 09:01:14 2006
> @@ -302,4 +302,16 @@
> return (SiteNode[]) topLevelNodes.toArray(new SiteNode[topLevelNodes.size()]);
> }
>
> + public boolean contains(String path, String language) {
> + if (contains(path)) {
> + SiteNode node;
> + try {
> + node = getNode(path);
> + } catch (SiteException e) {
> + throw new RuntimeException(e);
> + }
> + return node.hasLink(language);
> + }
> + return false;
> + }
> }
>
> Modified: lenya/trunk/src/modules-core/ac-impl/config/cocoon-xconf/bypassable-access-controller.xconf
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/ac-impl/config/cocoon-xconf/bypassable-access-controller.xconf?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/modules-core/ac-impl/config/cocoon-xconf/bypassable-access-controller.xconf (original)
> +++ lenya/trunk/src/modules-core/ac-impl/config/cocoon-xconf/bypassable-access-controller.xconf Fri Dec 15 09:01:14 2006
> @@ -24,7 +24,13 @@
> <xconf xpath="/cocoon" unless="/cocoon/component[@role = 'org.apache.lenya.ac.AccessController/bypassable']">
> <component logger="lenya.ac.accesscontroller.bypassable"
> class="org.apache.lenya.ac.impl.BypassableAccessController"
> - role="org.apache.lenya.ac.AccessController/bypassable">
> - <public>.*[.]css|.*[.]jpg|.*[.]gif|.*[.]png|.*[.]rng|.*[.]xsl</public>
> + role="org.apache.lenya.ac.AccessController/bypassable">
> +
> + <public-extensions>css,jpg,gif,png,rng,xsl</public-extensions>
> +
> + <!-- bad performance, use only for complex patterns
> + <public>.*[.]css|.*[.]jpg|.*[.]gif|.*[.]png|.*[.]rng|.*[.]xsl</public>
> + -->
> +
> </component>
> </xconf>
>
> Modified: lenya/trunk/src/modules-core/ac-impl/java/src/org/apache/lenya/ac/impl/BypassableAccessController.java
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/ac-impl/java/src/org/apache/lenya/ac/impl/BypassableAccessController.java?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/modules-core/ac-impl/java/src/org/apache/lenya/ac/impl/BypassableAccessController.java (original)
> +++ lenya/trunk/src/modules-core/ac-impl/java/src/org/apache/lenya/ac/impl/BypassableAccessController.java Fri Dec 15 09:01:14 2006
> @@ -46,6 +46,7 @@
> }
>
> private List publicMatchers = new ArrayList();
> + private List publicExtensions = new ArrayList();
>
> /**
> * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
> @@ -70,6 +71,19 @@
> getLogger().debug("CONFIGURATION: public: " + publicHref);
> }
> }
> +
> + Configuration[] extensionConfigs = conf.getChildren("public-extensions");
> + for (int i = 0; i < extensionConfigs.length; i++) {
> + String extensionString = extensionConfigs[i].getValue();
> + String[] extensions = extensionString.split(",");
> + for (int e = 0; e < extensions.length; e++) {
> + String ext = extensions[e].trim();
> + if (!ext.startsWith(".")) {
> + ext = "." + ext;
> + }
> + this.publicExtensions.add(ext);
> + }
> + }
>
> }
>
> @@ -149,6 +163,13 @@
> }
> authorized = true;
> }
> + i++;
> + }
> +
> + i = 0;
> + while (!authorized && i < this.publicExtensions.size()) {
> + String ext = (String) this.publicExtensions.get(i);
> + authorized = uri.endsWith(ext);
> i++;
> }
>
>
> Modified: lenya/trunk/src/modules-core/ac-impl/java/src/org/apache/lenya/cms/ac/DocumentPolicyManagerWrapper.java
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/ac-impl/java/src/org/apache/lenya/cms/ac/DocumentPolicyManagerWrapper.java?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/modules-core/ac-impl/java/src/org/apache/lenya/cms/ac/DocumentPolicyManagerWrapper.java (original)
> +++ lenya/trunk/src/modules-core/ac-impl/java/src/org/apache/lenya/cms/ac/DocumentPolicyManagerWrapper.java Fri Dec 15 09:01:14 2006
> @@ -71,11 +71,13 @@
>
> /**
> * Returns the URI which is used to obtain the policy for a webapp URL.
> + * @param controller The accreditable manager.
> * @param webappUrl The webapp URL.
> * @return A string.
> * @throws AccessControlException when something went wrong.
> */
> - protected String getPolicyURL(String webappUrl) throws AccessControlException {
> + protected String getPolicyURL(String webappUrl)
> + throws AccessControlException {
>
> if (getLogger().isDebugEnabled()) {
> getLogger().debug("Resolving policy for webapp URL [" + webappUrl + "]");
> @@ -130,6 +132,20 @@
> getLogger().debug(" Using URL: [" + url + "]");
> }
> return url;
> + }
> +
> + protected String getPolicyUrlFast(String webappUrl)
> + throws AccessControlException {
> + String strippedUrl = strip(strip(webappUrl, '.'), '_');
> + return strippedUrl;
> + }
> +
> + protected String strip(String strippedUrl, char delimiter) {
> + int lastDotIndex = strippedUrl.lastIndexOf(delimiter);
> + if (lastDotIndex != -1) {
> + strippedUrl = strippedUrl.substring(0, lastDotIndex);
> + }
> + return strippedUrl;
> }
>
> /**
>
> Modified: lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/LinkRewritingTransformer.java
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/LinkRewritingTransformer.java?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/LinkRewritingTransformer.java (original)
> +++ lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/LinkRewritingTransformer.java Fri Dec 15 09:01:14 2006
> @@ -36,6 +36,7 @@
> import org.apache.lenya.ac.Policy;
> import org.apache.lenya.ac.PolicyManager;
> import org.apache.lenya.cms.linking.LinkResolver;
> +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;
> @@ -56,7 +57,7 @@
> * <p>
> * This transformer is applied to an XHMTL document. It processes all links
> * following the {@link LinkResolver} syntax which are denoted by
> - * {@link ResourceType#getLinkAttributeXPaths()}.
> + * {@link org.apache.lenya.cms.publication.ResourceType#getLinkAttributeXPaths()}.
> * </p>
> * <p>
> * These links are resolved using the following rules:
> @@ -209,8 +210,9 @@
> if (linkUriAndQuery.length > 1) {
> queryString = linkUriAndQuery[1];
> }
> - Document targetDocument = this.linkResolver.resolve(doc, linkUri).getDocument();
> - if (targetDocument != null) {
> + LinkTarget target = this.linkResolver.resolve(doc, linkUri);
> + if (target.exists()) {
> + Document targetDocument = target.getDocument();
> String extension = targetDocument.getExtension();
> if (extension.length() > 0) {
> extension = "." + extension;
>
> Modified: lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/ChangeNodeID.java
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/ChangeNodeID.java?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/ChangeNodeID.java (original)
> +++ lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/ChangeNodeID.java Fri Dec 15 09:01:14 2006
> @@ -32,6 +32,7 @@
> import org.apache.lenya.cms.site.NodeSet;
> import org.apache.lenya.cms.site.SiteException;
> import org.apache.lenya.cms.site.SiteNode;
> +import org.apache.lenya.cms.site.SiteStructure;
> import org.apache.lenya.cms.site.SiteUtil;
> import org.apache.lenya.cms.usecase.DocumentUsecase;
> import org.apache.lenya.cms.usecase.UsecaseException;
> @@ -127,7 +128,9 @@
> addErrorMessage("The document ID is not valid.");
> } else {
> DocumentLocator target = getTargetLocator();
> - if (SiteUtil.contains(this.manager, getDocumentFactory(), target)) {
> + Publication pub = getDocumentFactory().getPublication(target.getPublicationId());
> + SiteStructure site = pub.getArea(target.getArea()).getSite();
> + if (site.contains(target.getPath(), target.getLanguage())) {
> addErrorMessage("The document does already exist.");
> }
> }
>
> Modified: lenya/trunk/src/modules-core/templating-impl/java/src/org/apache/lenya/cms/publication/templating/PublicationTemplateManagerImpl.java
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/templating-impl/java/src/org/apache/lenya/cms/publication/templating/PublicationTemplateManagerImpl.java?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/modules-core/templating-impl/java/src/org/apache/lenya/cms/publication/templating/PublicationTemplateManagerImpl.java (original)
> +++ lenya/trunk/src/modules-core/templating-impl/java/src/org/apache/lenya/cms/publication/templating/PublicationTemplateManagerImpl.java Fri Dec 15 09:01:14 2006
> @@ -28,7 +28,6 @@
> import org.apache.avalon.framework.service.ServiceManager;
> import org.apache.avalon.framework.service.ServiceSelector;
> import org.apache.avalon.framework.service.Serviceable;
> -import org.apache.excalibur.source.Source;
> import org.apache.excalibur.source.SourceResolver;
> import org.apache.lenya.cms.publication.Publication;
> import org.apache.lenya.cms.publication.PublicationException;
> @@ -36,7 +35,8 @@
> /**
> * Manager for publication templates.
> *
> - * @version $Id$
> + * @version $Id: PublicationTemplateManagerImpl.java 474729 2006-11-14 11:07:44Z
> + * andreas $
> */
> public class PublicationTemplateManagerImpl extends AbstractLogEnabled implements
> PublicationTemplateManager, Serviceable {
> @@ -49,7 +49,8 @@
>
> /**
> * @see org.apache.lenya.cms.publication.templating.PublicationTemplateManager#visit(org.apache.lenya.cms.publication.Publication,
> - * java.lang.String, org.apache.lenya.cms.publication.templating.SourceVisitor)
> + * java.lang.String,
> + * org.apache.lenya.cms.publication.templating.SourceVisitor)
> */
> public void visit(Publication publication, String path, SourceVisitor visitor) {
>
> @@ -65,18 +66,7 @@
> getLogger().debug("Trying to resolve URI [" + uri + "]");
> }
>
> - Source source = null;
> - try {
> - source = resolver.resolveURI(uri);
> - visitor.visit(source);
> - } catch (Exception e) {
> - getLogger().error("Could not resolve URI [" + uri + "]: ", e);
> - throw e;
> - } finally {
> - if (source != null) {
> - resolver.release(source);
> - }
> - }
> + visitor.visit(resolver, uri);
> }
>
> } catch (Exception e) {
> @@ -100,7 +90,8 @@
>
> /**
> * Returns the publication.
> - * @return A publication. protected Publication getPublication1() { return this.publication; }
> + * @return A publication. protected Publication getPublication1() { return
> + * this.publication; }
> */
>
> /**
> @@ -188,7 +179,8 @@
>
> /**
> * @see org.apache.lenya.cms.publication.templating.PublicationTemplateManager#getSelectableHint(org.apache.lenya.cms.publication.Publication,
> - * org.apache.avalon.framework.service.ServiceSelector, java.lang.String)
> + * org.apache.avalon.framework.service.ServiceSelector,
> + * java.lang.String)
> */
> public Object getSelectableHint(Publication publication, ServiceSelector selector,
> final String originalHint) throws ServiceException {
> @@ -254,8 +246,8 @@
> }
>
> /**
> - * @return The publication hint that could be selected or <code>null</code> if no hint
> - * could be selected.
> + * @return The publication hint that could be selected or
> + * <code>null</code> if no hint could be selected.
> */
> public Object getSelectableHint() {
> return this.selectableHint;
>
> Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/DefaultSiteTree.java
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/DefaultSiteTree.java?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/DefaultSiteTree.java (original)
> +++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/DefaultSiteTree.java Fri Dec 15 09:01:14 2006
> @@ -624,4 +624,17 @@
> return root;
> }
>
> + public boolean contains(String path, String language) {
> + if (contains(path)) {
> + SiteNode node;
> + try {
> + node = getNode(path);
> + } catch (SiteException e) {
> + throw new RuntimeException(e);
> + }
> + return node.hasLink(language);
> + }
> + return false;
> + }
> +
> }
>
> Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java (original)
> +++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java Fri Dec 15 09:01:14 2006
> @@ -382,4 +382,16 @@
> parent.moveUp(node.getName());
> }
>
> + public boolean contains(String path, String language) {
> + if (contains(path)) {
> + SiteNode node;
> + try {
> + node = getNode(path);
> + } catch (SiteException e) {
> + throw new RuntimeException(e);
> + }
> + return node.hasLink(language);
> + }
> + return false;
> + }
> }
>
> Modified: lenya/trunk/src/targets/webapp-build.xml
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/targets/webapp-build.xml?view=diff&rev=487598&r1=487597&r2=487598
> ==============================================================================
> --- lenya/trunk/src/targets/webapp-build.xml (original)
> +++ lenya/trunk/src/targets/webapp-build.xml Fri Dec 15 09:01:14 2006
> @@ -33,6 +33,19 @@
> </antcall>
> </target>
>
> + <target name="compile-impl" description="compile and deploy core implementation">
> + <path id="classpath.impl">
> + <path refid="classpath"/>
> + <fileset dir="${build.webapp}/WEB-INF/lib" includes="lenya-*-api.jar"/>
> + </path>
> + <antcall target="compile-src">
> + <param name="compile.src.dir" value="${src.java.impl.dir}"/>
> + <param name="compile.dest.dir" value="${build.dir}/impl"/>
> + <param name="compile.classpath" value="classpath.impl"/>
> + <param name="jar.name" value="impl"/>
> + </antcall>
> + </target>
> +
> <!--
> This target creates a webapp directory which exactly mirrors how
> the war file will look. It is used to create the war file for
> @@ -128,19 +141,7 @@
> </delete>
>
> <antcall target="compile-api"/>
> -
> - <path id="classpath.impl">
> - <path refid="classpath"/>
> - <fileset dir="${build.webapp}/WEB-INF/lib" includes="lenya-*-api.jar"/>
> - </path>
> -
> - <!-- compile core implementation -->
> - <antcall target="compile-src">
> - <param name="compile.src.dir" value="${src.java.impl.dir}"/>
> - <param name="compile.dest.dir" value="${build.dir}/impl"/>
> - <param name="compile.classpath" value="classpath.impl"/>
> - <param name="jar.name" value="impl"/>
> - </antcall>
> + <antcall target="compile-impl"/>
>
> <!--
> <antcall target="deploy-modules"/>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
> For additional commands, e-mail: commits-help@lenya.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org