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/08/25 15:45:21 UTC
svn commit: r436789 - in /lenya/trunk/src:
java/org/apache/lenya/cms/cocoon/components/modules/input/
modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/
modules-core/sitemanagement/usecases/site/
pubs/default/lenya/xslt/exception/...
Author: andreas
Date: Fri Aug 25 06:45:20 2006
New Revision: 436789
URL: http://svn.apache.org/viewvc?rev=436789&view=rev
Log:
Changed Create parameter documentId to path and clarified some other parameters, set language param even when no source document exists, allow PageEnvelopeModule to return paths for non-existing documents.
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PageEnvelopeModule.java
lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/Create.java
lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/CreateDocument.java
lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/CreateLanguage.java
lenya/trunk/src/modules-core/sitemanagement/usecases/site/create.jx
lenya/trunk/src/pubs/default/lenya/xslt/exception/document-does-not-exist.xsl
lenya/trunk/src/webapp/lenya/config/sitemap/pipelines.xmap
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?rev=436789&r1=436788&r2=436789&view=diff
==============================================================================
--- 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 Aug 25 06:45:20 2006
@@ -27,15 +27,21 @@
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
import org.apache.commons.lang.StringUtils;
import org.apache.lenya.cms.publication.Document;
-import org.apache.lenya.cms.publication.DocumentException;
+import org.apache.lenya.cms.publication.DocumentLocator;
import org.apache.lenya.cms.publication.PageEnvelope;
+import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.ResourceType;
+import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.cms.site.SiteUtil;
+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.
@@ -46,12 +52,11 @@
/**
* @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 {
-
+
final String name = getAttributeName(attributeName);
if (!Arrays.asList(PageEnvelope.PARAMETER_NAMES).contains(name)) {
@@ -76,6 +81,8 @@
value = envelope.getPublication().getDefaultLanguage();
} else if (name.equals(PageEnvelope.BREADCRUMB_PREFIX)) {
value = envelope.getPublication().getBreadcrumbPrefix();
+ } else if (name.equals(PageEnvelope.DOCUMENT_PATH)) {
+ value = getPath(envelope, objectModel);
}
Document document = envelope.getDocument();
@@ -83,6 +90,9 @@
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();
@@ -94,8 +104,6 @@
value = document.getCanonicalDocumentURL();
} else if (name.equals(PageEnvelope.DOCUMENT_URL_WITHOUT_LANGUAGE)) {
value = document.getCanonicalWebappURL();
- } else if (name.equals(PageEnvelope.DOCUMENT_PATH)) {
- value = document.getLocator().getPath();
} else if (name.equals(PageEnvelope.DOCUMENT_FILE)) {
value = document.getFile();
} else if (name.equals(PageEnvelope.DOCUMENT_EXTENSION)) {
@@ -117,13 +125,12 @@
ResourceType resourceType = document.getResourceType();
if (resourceType == null) {
value = null;
- }
- else {
+ } else {
value = resourceType.getName();
}
}
}
- } catch (final DocumentException e) {
+ } catch (final Exception e) {
throw new ConfigurationException("Getting attribute for name [" + name + "] failed: ",
e);
}
@@ -135,6 +142,21 @@
return value;
}
+ protected String getPath(PageEnvelope envelope, Map objectModel) throws SiteException {
+ String path;
+ Document doc = envelope.getDocument();
+ if (doc == null) {
+ Publication pub = envelope.getPublication();
+ Request request = ObjectModelHelper.getRequest(objectModel);
+ String url = ServletHelper.getWebappURI(request);
+ DocumentLocator loc = SiteUtil.getLocator(this.manager, pub.getFactory(), url);
+ path = loc.getPath();
+ } else {
+ path = doc.getLocator().getPath();
+ }
+ return path;
+ }
+
/**
* <code>DATE_FORMAT</code> The date format
*/
@@ -151,8 +173,7 @@
/**
* @see org.apache.cocoon.components.modules.input.InputModule#getAttributeValues(java.lang.String,
- * org.apache.avalon.framework.configuration.Configuration,
- * java.util.Map)
+ * org.apache.avalon.framework.configuration.Configuration, java.util.Map)
*/
public Object[] getAttributeValues(String name, Configuration modeConf, Map objectModel)
throws ConfigurationException {
Modified: lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/Create.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/Create.java?rev=436789&r1=436788&r2=436789&view=diff
==============================================================================
--- lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/Create.java (original)
+++ lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/Create.java Fri Aug 25 06:45:20 2006
@@ -48,24 +48,23 @@
import org.apache.lenya.cms.usecase.UsecaseException;
/**
- * Abstract superclass for usecases to create a document.
+ * <p>Abstract superclass for usecases to create a document.</p>
+ * <p>You can pass the following parameters into the usecase:</p>
+ * <ul>
+ * <li><strong>path</strong> - the path of the document to create (optional)</li>
+ * </ul>
*
* @version $Id$
*/
public abstract class Create extends AbstractUsecase {
protected static final String RESOURCE_TYPES = "resourceTypes";
-
protected static final String LANGUAGE = "language";
-
protected static final String LANGUAGES = "languages";
-
- protected static final String DOCUMENT_ID = "documentId";
-
+ protected static final String PATH = "path";
+ protected static final String NODE_NAME = "nodeName";
protected static final String VISIBLEINNAV = "visibleInNav";
-
protected static final String SAMPLE = "sample";
-
protected static final String SAMPLES = "samples";
/**
@@ -91,10 +90,10 @@
*/
protected Node[] getNodesToLock() throws UsecaseException {
try {
- SiteStructure structure = SiteUtil.getSiteStructure(this.manager, getSourceDocument());
+ SiteStructure structure = getPublication().getArea(getArea()).getSite();
Node[] nodes = { structure.getRepositoryNode() };
return nodes;
- } catch (SiteException e) {
+ } catch (Exception e) {
throw new UsecaseException(e);
}
}
Modified: lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/CreateDocument.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/CreateDocument.java?rev=436789&r1=436788&r2=436789&view=diff
==============================================================================
--- lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/CreateDocument.java (original)
+++ lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/CreateDocument.java Fri Aug 25 06:45:20 2006
@@ -32,7 +32,7 @@
*/
public class CreateDocument extends Create {
- protected static final String PARENT_PATH = "parentId";
+ protected static final String PARENT_PATH = "parentPath";
protected static final String DOCUMENT_TYPE = "doctype";
@@ -41,7 +41,7 @@
protected static final String RELATION_CHILD = "child";
protected static final String RELATION_BEFORE = "sibling before";
protected static final String RELATION_AFTER = "sibling after";
- protected static final String DOCUMENT_ID_PROVIDED = "documentIdProvided";
+ protected static final String PATH_PROVIDED = "pathProvided";
/**
* @see org.apache.lenya.cms.usecase.AbstractUsecase#initParameters()
@@ -58,17 +58,21 @@
} catch (DocumentException e) {
throw new RuntimeException(e);
}
- String[] languages = parent.getPublication().getLanguages();
- setParameter(LANGUAGES, languages);
}
+ String[] languages = getPublication().getLanguages();
+ if (languages.length == 0){
+ addErrorMessage("The publication doesn't contain any languages!");
+ }
+ setParameter(LANGUAGES, languages);
+
String[] relations = { RELATION_CHILD, RELATION_AFTER };
setParameter(RELATIONS, relations);
setParameter(RELATION, RELATION_CHILD);
- String documentId = getParameterAsString(DOCUMENT_ID);
- boolean provided = documentId != null && !documentId.equals("");
- setParameter(DOCUMENT_ID_PROVIDED, Boolean.valueOf(provided));
+ String path = getParameterAsString(PATH);
+ boolean provided = path != null && !path.equals("");
+ setParameter(PATH_PROVIDED, Boolean.valueOf(provided));
}
/**
@@ -85,33 +89,29 @@
protected void doCheckExecutionConditions() throws Exception {
super.doCheckExecutionConditions();
- String documentName = getParameterAsString(DOCUMENT_ID);
- String language = getParameterAsString(LANGUAGE);
+ String nodeName = getParameterAsString(NODE_NAME);
String relation = getParameterAsString(RELATION);
if (!Arrays.asList(getSupportedRelations()).contains(relation)) {
addErrorMessage("The relation '" + relation + "' is not supported.");
}
+
+ Publication pub = getPublication();
ServiceSelector selector = null;
DocumentBuilder builder = null;
try {
selector = (ServiceSelector) this.manager.lookup(DocumentBuilder.ROLE + "Selector");
- String hint = getSourceDocument().getPublication().getDocumentBuilderHint();
+ String hint = pub.getDocumentBuilderHint();
builder = (DocumentBuilder) selector.select(hint);
- boolean provided = getParameterAsBoolean(DOCUMENT_ID_PROVIDED, false);
- if (!provided && !builder.isValidDocumentName(documentName)) {
+ boolean provided = getParameterAsBoolean(PATH_PROVIDED, false);
+ if (!provided && !builder.isValidDocumentName(nodeName)) {
addErrorMessage("The document ID may not contain any special characters.");
} else {
- Publication publication = getSourceDocument().getPublication();
- String newDocumentId = getNewDocumentPath();
- Document document = getSourceDocument().getFactory().get(publication,
- getSourceDocument().getArea(),
- newDocumentId,
- language);
- if (document.exists()) {
- addErrorMessage("The document with ID " + newDocumentId + " already exists.");
+ String newPath = getNewDocumentPath();
+ if (pub.getArea(getArea()).getSite().contains(newPath)) {
+ addErrorMessage("The document with path " + newPath + " already exists.");
}
}
} finally {
@@ -128,14 +128,14 @@
* @see Create#getNewDocumentName()
*/
protected String getNewDocumentName() {
- final String documentId = getParameterAsString(DOCUMENT_ID);
- String documentName;
- if (getParameterAsBoolean(DOCUMENT_ID_PROVIDED, false)) {
- documentName = documentId.substring(documentId.lastIndexOf("/") + 1);
+ String nodeName;
+ if (getParameterAsBoolean(PATH_PROVIDED, false)) {
+ final String path = getParameterAsString(PATH);
+ nodeName = path.substring(path.lastIndexOf("/") + 1);
} else {
- documentName = documentId;
+ nodeName = getParameterAsString(NODE_NAME);
}
- return documentName;
+ return nodeName;
}
/**
@@ -149,8 +149,8 @@
* @see Create#getNewDocumentPath()
*/
protected String getNewDocumentPath() {
- if (getParameterAsBoolean(DOCUMENT_ID_PROVIDED, false)) {
- return getParameterAsString(DOCUMENT_ID);
+ if (getParameterAsBoolean(PATH_PROVIDED, false)) {
+ return getParameterAsString(PATH);
} else {
String relation = getRelation();
DocumentLocator sourceLoc = getSourceDocument().getLocator();
@@ -170,7 +170,7 @@
protected String getDocumentTypeName() {
return getParameterAsString(DOCUMENT_TYPE);
}
-
+
protected String getSourceExtension() {
return "xml";
}
Modified: lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/CreateLanguage.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/CreateLanguage.java?rev=436789&r1=436788&r2=436789&view=diff
==============================================================================
--- lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/CreateLanguage.java (original)
+++ lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/CreateLanguage.java Fri Aug 25 06:45:20 2006
@@ -84,8 +84,8 @@
Document source = getSourceDocument();
if (source != null) {
- setParameter(DOCUMENT_ID, source.getUUID());
try {
+ setParameter(PATH, source.getPath());
List nonExistingLanguages = getNonExistingLanguages();
setParameter(LANGUAGES, nonExistingLanguages
.toArray(new String[nonExistingLanguages.size()]));
Modified: lenya/trunk/src/modules-core/sitemanagement/usecases/site/create.jx
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/sitemanagement/usecases/site/create.jx?rev=436789&r1=436788&r2=436789&view=diff
==============================================================================
--- lenya/trunk/src/modules-core/sitemanagement/usecases/site/create.jx (original)
+++ lenya/trunk/src/modules-core/sitemanagement/usecases/site/create.jx Fri Aug 25 06:45:20 2006
@@ -36,30 +36,37 @@
<input type="hidden" name="lenya.continuation" value="${continuation.id}"/>
<input type="hidden" name="lenya.usecase" value="${request.getParameter('lenya.usecase')}"/>
<table class="lenya-table-noborder">
- <jx:if test="${!usecase.getParameter('documentIdProvided')}">
- <tr>
- <td class="lenya-entry-caption">
- <i18n:text>Parent ID</i18n:text>:</td>
- <td>
- <jx:out value="${usecase.getParameter('parentId')}"/>
- </td>
- </tr>
- </jx:if>
- <tr>
- <td class="lenya-entry-caption">
- <label for="documentId"><i18n:text>Document ID</i18n:text>*: </label></td>
- <td>
- <jx:choose>
- <jx:when test="${usecase.getParameter('documentIdProvided')}">
- <jx:out value="${usecase.getParameter('documentId')}"/>
- </jx:when>
- <jx:otherwise>
- <input class="lenya-form-element" type="text" name="documentId" value="${usecase.getParameter('documentId')}"/>
+ <jx:choose>
+ <jx:when test="${usecase.getParameter('pathProvided')}">
+ <tr>
+ <td class="lenya-entry-caption">
+ <label for="nodeName"><i18n:text>Path</i18n:text>: </label>
+ </td>
+ <td>
+ <jx:out value="${usecase.getParameter('path')}"/>
+ </td>
+ </tr>
+ </jx:when>
+ <jx:otherwise>
+ <tr>
+ <td class="lenya-entry-caption">
+ <label for="nodeName"><i18n:text>Parent Path</i18n:text>: </label>
+ </td>
+ <td>
+ <jx:out value="${usecase.getParameter('parentPath')}"/>
+ </td>
+ </tr>
+ <tr>
+ <td class="lenya-entry-caption">
+ <label for="nodeName"><i18n:text>Node Name</i18n:text>*: </label>
+ </td>
+ <td>
+ <input class="lenya-form-element" type="text" name="nodeName" value="${usecase.getParameter('nodeName')}"/>
<br/> (<i18n:text>No whitespace, no special characters</i18n:text>)
- </jx:otherwise>
- </jx:choose>
- </td>
- </tr>
+ </td>
+ </tr>
+ </jx:otherwise>
+ </jx:choose>
<tr>
<td class="lenya-entry-caption">
<label for="title"><i18n:text>Navigation Title</i18n:text>*: </label></td>
@@ -89,7 +96,7 @@
</select>
</td>
</tr>
- <jx:if test="${!usecase.getParameter('documentIdProvided')}">
+ <jx:if test="${!usecase.getParameter('pathProvided')}">
<tr>
<td class="lenya-entry-caption">
<label for="relation"><i18n:text>Relation</i18n:text>*: </label>
Modified: lenya/trunk/src/pubs/default/lenya/xslt/exception/document-does-not-exist.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/lenya/xslt/exception/document-does-not-exist.xsl?rev=436789&r1=436788&r2=436789&view=diff
==============================================================================
--- lenya/trunk/src/pubs/default/lenya/xslt/exception/document-does-not-exist.xsl (original)
+++ lenya/trunk/src/pubs/default/lenya/xslt/exception/document-does-not-exist.xsl Fri Aug 25 06:45:20 2006
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!--
Copyright 1999-2004 The Apache Software Foundation
-
+
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,7 +23,7 @@
xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
>
- <xsl:param name="documentid"/>
+ <xsl:param name="path"/>
<xsl:param name="documenturl"/>
<xsl:param name="area"/>
@@ -39,16 +39,17 @@
<i18n:translate>
<i18n:text i18n:key="error-document-existance" />
<i18n:param>'<xsl:value-of select="$documenturl"/>'</i18n:param>
- <i18n:param>'<xsl:value-of select="$documentid"/>'</i18n:param>
+ <i18n:param>'<xsl:value-of select="$path"/>'</i18n:param>
</i18n:translate>
</p>
<xsl:if test="$area = 'authoring'">
<p>
- <a href="?lenya.usecase=site.create&documentId={$documentid}"><i18n:text>create-document</i18n:text></a>
+ <a href="?lenya.usecase=site.create&path={$path}"><i18n:text>create-document</i18n:text></a>
+ </p>
+ <p>
+ <strong>NOTE:</strong> Please make sure that your content repository
+ is configured correctly within (local.)publication.xconf.
</p>
-<p>
-<b>NOTE:</b> Please make sure that your content repository is configured correctly within (local.)publication.xconf
-</p>
</xsl:if>
</div>
</div>
Modified: lenya/trunk/src/webapp/lenya/config/sitemap/pipelines.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/lenya/config/sitemap/pipelines.xmap?rev=436789&r1=436788&r2=436789&view=diff
==============================================================================
--- lenya/trunk/src/webapp/lenya/config/sitemap/pipelines.xmap (original)
+++ lenya/trunk/src/webapp/lenya/config/sitemap/pipelines.xmap Fri Aug 25 06:45:20 2006
@@ -108,7 +108,7 @@
<map:when test="document-does-not-exist">
<map:generate src="lenya/content/util/empty.xml"/>
<map:transform src="fallback://lenya/xslt/exception/document-does-not-exist.xsl">
- <map:parameter name="documentid" value="{page-envelope:document-id}"/>
+ <map:parameter name="path" value="{page-envelope:document-path}"/>
<map:parameter name="documenturl" value="{page-envelope:document-url}"/>
<map:parameter name="area" value="{page-envelope:area}"/>
</map:transform>
@@ -118,7 +118,7 @@
<map:when test="not-found">
<map:generate src="lenya/content/util/empty.xml" />
<map:transform src="fallback://lenya/xslt/exception/document-does-not-exist.xsl">
- <map:parameter name="documentid" value="{page-envelope:document-id}"/>
+ <map:parameter name="path" value="{page-envelope:document-path}"/>
<map:parameter name="documenturl" value="{page-envelope:document-url}"/>
<map:parameter name="area" value="{page-envelope:area}"/>
</map:transform>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org