You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2005/03/13 00:11:10 UTC
svn commit: r157295 [2/3] - in lenya/trunk/src/java/org/apache/lenya/cms:
ac/ ac/cocoon/ ac/workflow/ ant/ cocoon/acting/
cocoon/components/modules/input/ cocoon/flow/ cocoon/generation/
cocoon/scheduler/ cocoon/source/ cocoon/transformation/
metadata/dublincore/ publication/ publication/task/ publication/util/
scheduler/ site/ site/topicmap/ site/tree/ site/usecases/ task/ usecase/
Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/LinkRewritingTransformer.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/LinkRewritingTransformer.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/LinkRewritingTransformer.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/LinkRewritingTransformer.java Sat Mar 12 15:10:56 2005
@@ -45,8 +45,6 @@
import org.apache.lenya.cms.publication.PageEnvelopeFactory;
import org.apache.lenya.cms.publication.Proxy;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.PublicationException;
-import org.apache.lenya.cms.publication.PublicationFactory;
import org.apache.lenya.util.ServletHelper;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
@@ -68,10 +66,12 @@
* These links are rewritten using the following rules:
* </p>
* <ul>
- * <li>The area is replaced by the current area (obtained from the page envelope).</li>
- * <li>A URL prefix is added depending on the proxy configuration of the publication.</li>
- * <li>If the target document does not exist, the <code><a/></code> element is removed to
- * disable the link.</li>
+ * <li>The area is replaced by the current area (obtained from the page
+ * envelope).</li>
+ * <li>A URL prefix is added depending on the proxy configuration of the
+ * publication.</li>
+ * <li>If the target document does not exist, the <code><a/></code>
+ * element is removed to disable the link.</li>
* </ul>
*
* $Id: LinkRewritingTransformer.java,v 1.7 2004/03/16 11:12:16 gregor
@@ -90,26 +90,22 @@
/**
* @see org.apache.cocoon.sitemap.SitemapModelComponent#setup(org.apache.cocoon.environment.SourceResolver,
- * java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
+ * java.util.Map, java.lang.String,
+ * org.apache.avalon.framework.parameters.Parameters)
*/
- public void setup(SourceResolver _resolver, Map _objectModel, String _source, Parameters _parameters)
- throws ProcessingException, SAXException, IOException {
+ public void setup(SourceResolver _resolver, Map _objectModel, String _source,
+ Parameters _parameters) throws ProcessingException, SAXException, IOException {
super.setup(_resolver, _objectModel, _source, _parameters);
try {
- PublicationFactory factory = PublicationFactory.getInstance(getLogger());
- Publication pub = factory.getPublication(_objectModel);
- this.identityMap = new DocumentIdentityMap(pub);
- PageEnvelope envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(
- this.identityMap, _objectModel);
+ this.identityMap = new DocumentIdentityMap();
+ PageEnvelope envelope = PageEnvelopeFactory.getInstance()
+ .getPageEnvelope(this.identityMap, _objectModel);
this.currentDocument = envelope.getDocument();
- } catch (final PublicationException e1) {
- throw new ProcessingException(e1);
} catch (final PageEnvelopeException e1) {
throw new ProcessingException(e1);
}
-
if (getLogger().isDebugEnabled()) {
getLogger().debug("Setting up transformer");
getLogger().debug(" Processed version: [" + getCurrentDocument() + "]");
@@ -169,15 +165,15 @@
private String indent = "";
/**
- * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String,
- * java.lang.String, org.xml.sax.Attributes)
+ * @see org.xml.sax.ContentHandler#startElement(java.lang.String,
+ * java.lang.String, java.lang.String, org.xml.sax.Attributes)
*/
public void startElement(String uri, String name, String qname, Attributes attrs)
throws SAXException {
if (getLogger().isDebugEnabled()) {
- getLogger().debug(
- this.indent + "<" + qname + "> (ignoreAElement = " + this.ignoreAElement + ")");
+ getLogger().debug(this.indent + "<" + qname + "> (ignoreAElement = "
+ + this.ignoreAElement + ")");
this.indent += " ";
}
@@ -219,19 +215,19 @@
getLogger().debug(this.indent + "webapp URL: [" + webappUrl + "]");
getLogger().debug(this.indent + "anchor: [" + anchor + "]");
}
- if (this.identityMap.getFactory().isDocument(webappUrl)) {
+ if (this.identityMap.getFactory().isDocument(publication, webappUrl)) {
- Document targetDocument = this.identityMap.getFactory().getFromURL(
- webappUrl);
+ Document targetDocument = this.identityMap.getFactory()
+ .getFromURL(publication, webappUrl);
if (getLogger().isDebugEnabled()) {
- getLogger().debug(
- this.indent + "Resolved target document: ["
- + targetDocument + "]");
+ getLogger().debug(this.indent + "Resolved target document: ["
+ + targetDocument + "]");
}
- targetDocument = this.identityMap.getFactory().get(
- getCurrentDocument().getArea(), targetDocument.getId(),
+ targetDocument = this.identityMap.getFactory().get(publication,
+ getCurrentDocument().getArea(),
+ targetDocument.getId(),
targetDocument.getLanguage());
if (targetDocument.exists()) {
@@ -312,7 +308,8 @@
*
* @param attr The attributes.
* @param value The value.
- * @throws IllegalArgumentException if the href attribute is not contained in this attributes.
+ * @throws IllegalArgumentException if the href attribute is not contained
+ * in this attributes.
*/
protected void setHrefAttribute(AttributesImpl attr, String value) {
int position = attr.getIndex(ATTRIBUTE_HREF);
@@ -323,8 +320,8 @@
}
/**
- * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String,
- * java.lang.String)
+ * @see org.xml.sax.ContentHandler#endElement(java.lang.String,
+ * java.lang.String, java.lang.String)
*/
public void endElement(String uri, String name, String qname) throws SAXException {
if (getLogger().isDebugEnabled()) {
Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/WorkflowMenuTransformer.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/WorkflowMenuTransformer.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/WorkflowMenuTransformer.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/WorkflowMenuTransformer.java Sat Mar 12 15:10:56 2005
@@ -32,8 +32,6 @@
import org.apache.lenya.cms.publication.DocumentIdentityMap;
import org.apache.lenya.cms.publication.PageEnvelope;
import org.apache.lenya.cms.publication.PageEnvelopeFactory;
-import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.PublicationFactory;
import org.apache.lenya.cms.workflow.WorkflowResolver;
import org.apache.lenya.workflow.Situation;
import org.apache.lenya.workflow.Workflow;
@@ -123,9 +121,7 @@
WorkflowResolver workflowResolver = null;
try {
- PublicationFactory factory = PublicationFactory.getInstance(getLogger());
- Publication pub = factory.getPublication(_objectModel);
- DocumentIdentityMap map = new DocumentIdentityMap(pub);
+ DocumentIdentityMap map = new DocumentIdentityMap();
envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(map, _objectModel);
Document document = envelope.getDocument();
Modified: lenya/trunk/src/java/org/apache/lenya/cms/metadata/dublincore/DublinCoreHelper.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/metadata/dublincore/DublinCoreHelper.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/metadata/dublincore/DublinCoreHelper.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/metadata/dublincore/DublinCoreHelper.java Sat Mar 12 15:10:56 2005
@@ -32,10 +32,10 @@
public final class DublinCoreHelper {
/**
- * Constructor
+ * Constructor
*/
private DublinCoreHelper() {
- // do nothing
+ // do nothing
}
private static Logger log = Logger.getLogger(DublinCoreHelper.class);
@@ -51,19 +51,22 @@
*/
public static String getDCIdentifier(Publication publication, String area, String documentId)
throws DocumentException {
-
+
String identifier = null;
try {
identifier = null;
-
- DocumentIdentityMap map = new DocumentIdentityMap(publication);
- Document baseDocument = map.getFactory().get(area, documentId);
+
+ DocumentIdentityMap map = new DocumentIdentityMap();
+ Document baseDocument = map.getFactory().get(publication, area, documentId);
String[] languages = baseDocument.getLanguages();
-
+
int i = 0;
if (languages.length > 0) {
while (identifier == null && i < languages.length) {
- Document document = map.getFactory().get(area, documentId, languages[i]);
+ Document document = map.getFactory().get(publication,
+ area,
+ documentId,
+ languages[i]);
log.debug("document file : " + document.getFile().getAbsolutePath());
DublinCore dublincore = document.getDublinCore();
log.debug("dublincore title : "
@@ -77,10 +80,10 @@
identifier = dublincore.getFirstValue(DublinCore.ELEMENT_IDENTIFIER);
}
} catch (final DocumentBuildException e) {
- log.error("" +e.toString());
+ log.error("" + e.toString());
throw new DocumentException(e);
} catch (final DocumentException e) {
- log.error("" +e.toString());
+ log.error("" + e.toString());
throw new DocumentException(e);
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java Sat Mar 12 15:10:56 2005
@@ -53,10 +53,12 @@
* Creates a new instance of DefaultDocument. The language of the document
* is the default language of the publication.
* @param map The identity map the document belongs to.
+ * @param publication The publication.
* @param _id The document ID (starting with a slash).
* @param _area The area.
*/
- protected DefaultDocument(DocumentIdentityMap map, String _id, String _area) {
+ protected DefaultDocument(DocumentIdentityMap map, Publication publication, String _id,
+ String _area) {
if (_id == null) {
throw new IllegalArgumentException("The document ID must not be null!");
}
@@ -64,11 +66,12 @@
throw new IllegalArgumentException("The document ID must start with a slash!");
}
this.id = _id;
+ this.publication = publication;
this.identityMap = map;
setArea(_area);
- setLanguage(this.identityMap.getPublication().getDefaultLanguage());
+ setLanguage(getPublication().getDefaultLanguage());
this.dublincore = new DublinCoreProxy(this);
}
@@ -77,11 +80,13 @@
* Creates a new instance of DefaultDocument.
*
* @param map The identity map the document belongs to.
+ * @param publication The publication.
* @param _id The document ID (starting with a slash).
* @param _area The area.
* @param _language the language
*/
- protected DefaultDocument(DocumentIdentityMap map, String _id, String _area, String _language) {
+ protected DefaultDocument(DocumentIdentityMap map, Publication publication, String _id,
+ String _area, String _language) {
if (_id == null) {
throw new IllegalArgumentException("The document ID must not be null!");
}
@@ -89,6 +94,7 @@
throw new IllegalArgumentException("The document ID must start with a slash!");
}
this.id = _id;
+ this.publication = publication;
this.identityMap = map;
this.language = _language;
@@ -114,11 +120,13 @@
return nodeId;
}
+ private Publication publication;
+
/**
* @see org.apache.lenya.cms.publication.Document#getPublication()
*/
public Publication getPublication() {
- return getIdentityMap().getPublication();
+ return this.publication;
}
/**
@@ -378,9 +386,9 @@
public void accept(DocumentVisitor visitor) throws PublicationException {
visitor.visitDocument(this);
}
-
+
private History history;
-
+
/**
* @return The workflow history.
*/
@@ -432,7 +440,7 @@
path = path.replace('/', File.separatorChar);
return new File(getPublication().getDirectory(), path);
}
-
+
/**
* @return The source URI of the history file.
*/
@@ -441,7 +449,9 @@
}
/**
- * @see org.apache.lenya.workflow.Workflowable#newVersion(org.apache.lenya.workflow.Workflow, org.apache.lenya.workflow.Version, org.apache.lenya.workflow.Situation)
+ * @see org.apache.lenya.workflow.Workflowable#newVersion(org.apache.lenya.workflow.Workflow,
+ * org.apache.lenya.workflow.Version,
+ * org.apache.lenya.workflow.Situation)
*/
public void newVersion(Workflow workflow, Version version, Situation situation) {
getHistory().newVersion(workflow, version, situation);
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocumentBuilder.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocumentBuilder.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocumentBuilder.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocumentBuilder.java Sat Mar 12 15:10:56 2005
@@ -35,9 +35,9 @@
/**
* @see org.apache.lenya.cms.publication.DocumentBuilder#buildDocument(org.apache.lenya.cms.publication.DocumentIdentityMap,
- * java.lang.String)
+ * org.apache.lenya.cms.publication.Publication, java.lang.String)
*/
- public Document buildDocument(DocumentIdentityMap map, String url)
+ public Document buildDocument(DocumentIdentityMap map, Publication publication, String url)
throws DocumentBuildException {
URLInformation info = new URLInformation(url);
@@ -53,7 +53,7 @@
documentURL = documentURL.substring(0, documentURL.length() - fullLanguage.length());
if ("".equals(language)) {
- language = map.getPublication().getDefaultLanguage();
+ language = publication.getDefaultLanguage();
}
String documentId = documentURL;
@@ -63,7 +63,11 @@
+ "] does not start with '/'!");
}
- DefaultDocument document = createDocument(map, info.getArea(), documentId, language);
+ DefaultDocument document = createDocument(map,
+ publication,
+ info.getArea(),
+ documentId,
+ language);
ContainerUtil.enableLogging(document, getLogger());
document.setExtension(extension);
document.setDocumentURL(originalURL);
@@ -75,15 +79,16 @@
* Creates a new document object. Override this method to create specific
* document objects, e.g., for different document IDs.
* @param map The identity map.
+ * @param publication The publication.
* @param area The area.
* @param documentId The document ID.
* @param language The language.
* @return A document.
* @throws DocumentBuildException when something went wrong.
*/
- protected DefaultDocument createDocument(DocumentIdentityMap map, String area,
- String documentId, String language) throws DocumentBuildException {
- DefaultDocument document = new DefaultDocument(map, documentId, area, language);
+ protected DefaultDocument createDocument(DocumentIdentityMap map, Publication publication,
+ String area, String documentId, String language) throws DocumentBuildException {
+ DefaultDocument document = new DefaultDocument(map, publication, documentId, area, language);
return document;
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentBuilder.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentBuilder.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentBuilder.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentBuilder.java Sat Mar 12 15:10:56 2005
@@ -28,11 +28,12 @@
/**
* Builds a document.
* @param map The identity map the document belongs to.
+ * @param publication The publication.
* @param url The URL of the form /{publication-id}/{area}/{document-id}{language-suffix}.{extension}.
* @return A document.
* @throws DocumentBuildException when something went wrong.
*/
- Document buildDocument(DocumentIdentityMap map, String url)
+ Document buildDocument(DocumentIdentityMap map, Publication publication, String url)
throws DocumentBuildException;
/**
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentFactory.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentFactory.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentFactory.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentFactory.java Sat Mar 12 15:10:56 2005
@@ -17,7 +17,7 @@
package org.apache.lenya.cms.publication;
/**
- *
+ *
*/
public class DocumentFactory {
@@ -41,48 +41,53 @@
/**
* Checks if a webapp URL represents a document.
+ * @param publication The publication.
* @param webappUrl A web application URL.
* @return A boolean value.
* @throws DocumentBuildException if an error occurs.
*/
- public boolean isDocument(String webappUrl) throws DocumentBuildException {
- Publication pub = getIdentityMap().getPublication();
- return pub.getDocumentBuilder().isDocument(pub, webappUrl);
+ public boolean isDocument(Publication publication, String webappUrl)
+ throws DocumentBuildException {
+ return publication.getDocumentBuilder().isDocument(publication, webappUrl);
}
/**
* Builds a document in the default language.
+ * @param publication The publication.
* @param area The area.
* @param documentId The document ID.
* @return A document.
* @throws DocumentBuildException if an error occurs.
*/
- public Document get(String area, String documentId) throws DocumentBuildException {
- return getIdentityMap().get(area, documentId,
- getIdentityMap().getPublication().getDefaultLanguage());
+ public Document get(Publication publication, String area, String documentId)
+ throws DocumentBuildException {
+ return get(publication, area, documentId, publication.getDefaultLanguage());
}
/**
* Builds a document.
+ * @param publication The publication.
* @param area The area.
* @param documentId The document ID.
* @param language The language.
* @return A document.
* @throws DocumentBuildException if an error occurs.
*/
- public Document get(String area, String documentId, String language)
+ public Document get(Publication publication, String area, String documentId, String language)
throws DocumentBuildException {
- return getIdentityMap().get(area, documentId, language);
+ return getIdentityMap().get(publication, area, documentId, language);
}
/**
* Builds a document from a URL.
+ * @param publication The publication.
* @param webappUrl The web application URL.
* @return A document.
* @throws DocumentBuildException if an error occurs.
*/
- public Document getFromURL(String webappUrl) throws DocumentBuildException {
- return getIdentityMap().getFromURL(webappUrl);
+ public Document getFromURL(Publication publication, String webappUrl)
+ throws DocumentBuildException {
+ return getIdentityMap().getFromURL(publication, webappUrl);
}
/**
@@ -94,7 +99,7 @@
*/
public Document getLanguageVersion(Document document, String language)
throws DocumentBuildException {
- return get(document.getArea(), document.getId(), language);
+ return get(document.getPublication(), document.getArea(), document.getId(), language);
}
/**
@@ -105,7 +110,7 @@
* @throws DocumentBuildException if an error occurs.
*/
public Document getAreaVersion(Document document, String area) throws DocumentBuildException {
- return get(area, document.getId(), document.getLanguage());
+ return get(document.getPublication(), area, document.getId(), document.getLanguage());
}
/**
@@ -119,7 +124,8 @@
int lastSlashIndex = document.getId().lastIndexOf("/");
if (lastSlashIndex > 0) {
String parentId = document.getId().substring(0, lastSlashIndex);
- parent = get(document.getArea(), parentId, document.getLanguage());
+ parent = get(document.getPublication(), document.getArea(), parentId, document
+ .getLanguage());
}
return parent;
}
@@ -127,7 +133,8 @@
/**
* Returns the parent of a document.
* @param document A document.
- * @param defaultDocumentId The document ID to use if the document has no parent.
+ * @param defaultDocumentId The document ID to use if the document has no
+ * parent.
* @return A document.
* @throws DocumentBuildException if an error occurs.
*/
@@ -135,34 +142,35 @@
throws DocumentBuildException {
Document parent = getParent(document);
if (parent == null) {
- parent = get(document.getArea(), defaultDocumentId, document.getLanguage());
+ parent = get(document.getPublication(), document.getArea(), defaultDocumentId, document
+ .getLanguage());
}
return parent;
}
-
+
/**
* Checks if a string represents a valid document ID.
* @param id The string.
* @return A boolean value.
*/
public boolean isValidDocumentId(String id) {
-
+
if (!id.startsWith("/")) {
return false;
}
-
+
String[] snippets = id.split("/");
-
+
if (snippets.length < 2) {
return false;
}
-
+
for (int i = 1; i < snippets.length; i++) {
if (!snippets[i].matches("[a-zA-Z0-9\\-]+")) {
return false;
}
}
-
+
return true;
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdentityMap.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdentityMap.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdentityMap.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdentityMap.java Sat Mar 12 15:10:56 2005
@@ -31,7 +31,6 @@
*/
public class DocumentIdentityMap {
- private Publication publication;
private Map key2document = new HashMap();
private DocumentFactory factory;
@@ -39,10 +38,8 @@
/**
* Ctor.
- * @param _publication The publication to use.
*/
- public DocumentIdentityMap(Publication _publication) {
- this.publication = _publication;
+ public DocumentIdentityMap() {
}
/**
@@ -57,14 +54,6 @@
}
/**
- * Returns the publication.
- * @return A publication.
- */
- public Publication getPublication() {
- return this.publication;
- }
-
- /**
* Returns a site structure object.
* @param publication The publication.
* @param area The area.
@@ -92,20 +81,21 @@
/**
* Returns a document.
+ * @param publication The publication.
* @param area The area.
* @param documentId The document ID.
* @param language The language.
* @return A document.
* @throws DocumentBuildException if an error occurs.
*/
- protected Document get(String area, String documentId, String language)
+ protected Document get(Publication publication, String area, String documentId, String language)
throws DocumentBuildException {
String key = getKey(area, documentId, language);
Document document = (Document) this.key2document.get(key);
if (document == null) {
- DocumentBuilder builder = getPublication().getDocumentBuilder();
- String url = builder.buildCanonicalUrl(getPublication(), area, documentId, language);
- document = builder.buildDocument(this, url);
+ DocumentBuilder builder = publication.getDocumentBuilder();
+ String url = builder.buildCanonicalUrl(publication, area, documentId, language);
+ document = builder.buildDocument(this, publication, url);
this.key2document.put(key, document);
}
return document;
@@ -113,18 +103,19 @@
/**
* Returns the document identified by a certain web application URL.
+ * @param publication The publication to use.
* @param webappUrl The web application URL.
* @return A document.
* @throws DocumentBuildException if an error occurs.
*/
- protected Document getFromURL(String webappUrl) throws DocumentBuildException {
- DocumentBuilder builder = getPublication().getDocumentBuilder();
- if (!builder.isDocument(getPublication(), webappUrl)) {
+ protected Document getFromURL(Publication publication, String webappUrl) throws DocumentBuildException {
+ DocumentBuilder builder = publication.getDocumentBuilder();
+ if (!builder.isDocument(publication, webappUrl)) {
throw new DocumentBuildException("The webapp URL [" + webappUrl
+ "] does not identify a valid document");
}
- Document document = builder.buildDocument(this, webappUrl);
+ Document document = builder.buildDocument(this, publication, webappUrl);
String key = getKey(document.getArea(), document.getId(), document.getLanguage());
Document resultDocument;
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java Sat Mar 12 15:10:56 2005
@@ -103,7 +103,7 @@
ResourcesManager resourcesManager = document.getResourcesManager();
resourcesManager.deleteResources();
-
+
WorkflowManager workflowManager = null;
try {
workflowManager = (WorkflowManager) this.manager.lookup(WorkflowManager.ROLE);
@@ -213,7 +213,10 @@
} else if (nodeId.indexOf("/") > -1) {
errorMessages.add("The document ID may not contain a slash ('/').");
} else if (identityMap.getFactory().isValidDocumentId(newDocumentId)) {
- Document newDocument = identityMap.getFactory().get(area, newDocumentId, language);
+ Document newDocument = identityMap.getFactory().get(parent.getPublication(),
+ area,
+ newDocumentId,
+ language);
if (newDocument.exists()) {
errorMessages.add("A document with this ID already exists.");
@@ -233,8 +236,10 @@
String availableDocumentId = uniqueDocumentId.computeUniqueDocumentId(document
.getPublication(), document.getArea(), document.getId());
DocumentFactory factory = document.getIdentityMap().getFactory();
- Document availableDocument = factory.get(document.getArea(), availableDocumentId, document
- .getLanguage());
+ Document availableDocument = factory.get(document.getPublication(),
+ document.getArea(),
+ availableDocumentId,
+ document.getLanguage());
return availableDocument;
}
@@ -262,8 +267,7 @@
* org.apache.lenya.cms.publication.Document)
*/
public void copyAll(Document source, Document target) throws PublicationException {
- DocumentIdentityMap identityMap = source.getIdentityMap();
- SiteManager manager = identityMap.getPublication().getSiteManager();
+ SiteManager manager = source.getPublication().getSiteManager();
Document[] descendantsArray = manager.getRequiringResources(source);
OrderedDocumentSet descendants = new OrderedDocumentSet(descendantsArray);
descendants.add(source);
@@ -284,7 +288,8 @@
Document sourceVersion = identityMap.getFactory().getLanguageVersion(source,
languages[i]);
- Document targetVersion = identityMap.getFactory().get(target.getArea(),
+ Document targetVersion = identityMap.getFactory().get(target.getPublication(),
+ target.getArea(),
target.getId(),
languages[i]);
copyDocument(sourceVersion, targetVersion);
@@ -396,7 +401,10 @@
String childId = source.getId().substring(rootSourceId.length());
String targetId = rootTargetId + childId;
DocumentFactory factory = getRootTarget().getIdentityMap().getFactory();
- return factory.get(getRootTarget().getArea(), targetId, source.getLanguage());
+ return factory.get(getRootTarget().getPublication(),
+ getRootTarget().getArea(),
+ targetId,
+ source.getLanguage());
}
}
@@ -429,8 +437,7 @@
* @see org.apache.lenya.cms.publication.DocumentManager#deleteAll(org.apache.lenya.cms.publication.Document)
*/
public void deleteAll(Document document) throws PublicationException {
- DocumentIdentityMap identityMap = document.getIdentityMap();
- SiteManager manager = identityMap.getPublication().getSiteManager();
+ SiteManager manager = document.getPublication().getSiteManager();
Document[] descendantsArray = manager.getRequiringResources(document);
OrderedDocumentSet descendants = new OrderedDocumentSet(descendantsArray);
descendants.add(document);
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java Sat Mar 12 15:10:56 2005
@@ -21,6 +21,7 @@
import java.util.Map;
+import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.lenya.cms.rc.RCEnvironment;
@@ -149,7 +150,8 @@
private String context;
private String area;
-
+ private Publication publication;
+
/**
* Constructor.
*/
@@ -179,8 +181,11 @@
URLInformation info = new URLInformation(webappURI);
this.area = info.getArea();
- if (map.getFactory().isDocument(webappURI)) {
- Document _document = map.getFactory().getFromURL(webappURI);
+ this.publication = PublicationFactory.getInstance(new ConsoleLogger())
+ .getPublication(objectModel);
+
+ if (map.getFactory().isDocument(publication, webappURI)) {
+ Document _document = map.getFactory().getFromURL(publication, webappURI);
setDocument(_document);
}
@@ -216,7 +221,7 @@
* @return a <code>Publication</code> value
*/
public Publication getPublication() {
- return getIdentityMap().getPublication();
+ return this.publication;
}
/**
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/PublicationFactory.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/PublicationFactory.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/PublicationFactory.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/PublicationFactory.java Sat Mar 12 15:10:56 2005
@@ -27,6 +27,8 @@
import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.service.ServiceException;
+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;
@@ -47,9 +49,9 @@
private PublicationFactory(Logger logger) {
ContainerUtil.enableLogging(this, logger);
}
-
+
private static PublicationFactory instance;
-
+
/**
* Returns the publication factory instance.
* @param logger The logger to use.
@@ -65,12 +67,13 @@
private static Map keyToPublication = new HashMap();
/**
- * Creates a new publication.
- * The publication ID is resolved from the request URI.
- * The servlet context path is resolved from the context object.
+ * Creates a new publication. The publication ID is resolved from the
+ * request URI. The servlet context path is resolved from the context
+ * object.
* @param objectModel The object model of the Cocoon component.
* @return a <code>Publication</code>
- * @throws PublicationException if there was a problem creating the publication.
+ * @throws PublicationException if there was a problem creating the
+ * publication.
*/
public Publication getPublication(Map objectModel) throws PublicationException {
@@ -81,15 +84,17 @@
}
/**
- * Create a new publication with the given publication-id and servlet context path.
- * These publications are cached and reused for similar requests.
+ * Create a new publication with the given publication-id and servlet
+ * context path. These publications are cached and reused for similar
+ * requests.
* @param id the publication id
* @param servletContextPath the servlet context path of the publication
* @return a <code>Publication</code>
- * @throws PublicationException if there was a problem creating the publication.
+ * @throws PublicationException if there was a problem creating the
+ * publication.
*/
public Publication getPublication(String id, String servletContextPath)
- throws PublicationException {
+ throws PublicationException {
assert id != null;
assert servletContextPath != null;
@@ -108,22 +113,22 @@
}
if (publication == null) {
- throw new PublicationException("The publication for ID [" + id + "] could not be created.");
+ throw new PublicationException("The publication for ID [" + id
+ + "] could not be created.");
}
return publication;
}
/**
- * Generates a key to cache a publication.
- * The cache key is constructed using the canonical servlet context path
- * and the publication ID.
+ * Generates a key to cache a publication. The cache key is constructed
+ * using the canonical servlet context path and the publication ID.
* @param publicationId The publication ID.
* @param servletContextPath The servlet context path.
* @return A cache key.
* @throws PublicationException when the servlet context does not exist.
*/
protected static String generateKey(String publicationId, String servletContextPath)
- throws PublicationException {
+ throws PublicationException {
String key;
File servletContext = new File(servletContextPath);
String canonicalPath;
@@ -141,10 +146,10 @@
* @param request A request.
* @param context A context.
* @return A publication.
- * @throws PublicationException if there was a problem creating the publication.
+ * @throws PublicationException if there was a problem creating the
+ * publication.
*/
- public Publication getPublication(Request request, Context context)
- throws PublicationException {
+ public Publication getPublication(Request request, Context context) throws PublicationException {
getLogger().debug("Creating publication from Cocoon object model");
String webappUrl = ServletHelper.getWebappURI(request);
@@ -154,13 +159,14 @@
/**
* Creates a publication from a webapp URL and a servlet context directory.
- * @param webappUrl The URL within the web application (without context prefix)
+ * @param webappUrl The URL within the web application (without context
+ * prefix)
* @param servletContext The Lenya servlet context directory
* @return A publication
* @throws PublicationException when something went wrong
*/
public Publication getPublication(String webappUrl, File servletContext)
- throws PublicationException {
+ throws PublicationException {
getLogger().debug("Creating publication from webapp URL and servlet context");
getLogger().debug(" Webapp URL: [" + webappUrl + "]");
@@ -173,7 +179,8 @@
* Checks if a publication with a certain ID exists in a certain context.
* @param id The publication ID.
* @param servletContextPath The webapp context path.
- * @return <code>true</code> if the publication exists, <code>false</code> otherwise.
+ * @return <code>true</code> if the publication exists, <code>false</code>
+ * otherwise.
*/
public static boolean existsPublication(String id, String servletContextPath) {
@@ -181,13 +188,8 @@
servletContextPath = servletContextPath.substring(0, servletContextPath.length() - 1);
}
- File publicationDirectory =
- new File(
- servletContextPath
- + File.separator
- + Publication.PUBLICATION_PREFIX
- + File.separator
- + id);
+ File publicationDirectory = new File(servletContextPath + File.separator
+ + Publication.PUBLICATION_PREFIX + File.separator + id);
boolean exists = true;
exists = exists && publicationDirectory.isDirectory();
@@ -204,15 +206,26 @@
* @throws PublicationException when something went wrong.
*/
public Publication getPublication(SourceResolver resolver, Request request)
- throws PublicationException {
+ throws PublicationException {
getLogger().debug("Creating publication from resolver and request");
+ String webappUrl = ServletHelper.getWebappURI(request);
+ return getPublication(resolver, webappUrl);
+ }
+
+ /**
+ * @param resolver A source resolver.
+ * @param webappUrl A webapp URL.
+ * @return A publication.
+ * @throws PublicationException if an error occurs.
+ */
+ public Publication getPublication(SourceResolver resolver, String webappUrl)
+ throws PublicationException {
Publication publication;
- String webappUri = ServletHelper.getWebappURI(request);
Source source = null;
try {
source = resolver.resolveURI("context:///");
File servletContext = SourceUtil.getFile(source);
- publication = getPublication(webappUri, servletContext);
+ publication = getPublication(webappUrl, servletContext);
} catch (Exception e) {
throw new PublicationException(e);
} finally {
@@ -222,5 +235,28 @@
}
return publication;
}
-
-}
+
+ /**
+ * @param manager A service manager.
+ * @param webappUrl A webapp URL.
+ * @return A publication.
+ * @throws PublicationException if an error occurs.
+ */
+ public Publication getPublication(ServiceManager manager, String webappUrl)
+ throws PublicationException {
+ Publication publication = null;
+ SourceResolver resolver = null;
+ try {
+ resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
+ publication = getPublication(resolver, webappUrl);
+ } catch (ServiceException e) {
+ throw new PublicationException(e);
+ } finally {
+ if (resolver != null) {
+ manager.release(resolver);
+ }
+ }
+ return publication;
+ }
+
+}
\ No newline at end of file
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/PublicationImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/PublicationImpl.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/PublicationImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/PublicationImpl.java Sat Mar 12 15:10:56 2005
@@ -65,8 +65,7 @@
* @throws PublicationException if there was a problem reading the config
* file
*/
- protected PublicationImpl(String _id, String servletContextPath)
- throws PublicationException {
+ protected PublicationImpl(String _id, String servletContextPath) throws PublicationException {
assert _id != null;
this.id = _id;
@@ -292,7 +291,8 @@
DocumentBuilder builder = getDocumentBuilder();
String url = builder
.buildCanonicalUrl(this, area, document.getId(), document.getLanguage());
- Document destinationDocument = builder.buildDocument(document.getIdentityMap(), url);
+ Document destinationDocument = builder.buildDocument(document.getIdentityMap(), document
+ .getPublication(), url);
return destinationDocument;
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/task/DocumentTask.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/task/DocumentTask.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/task/DocumentTask.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/task/DocumentTask.java Sat Mar 12 15:10:56 2005
@@ -37,7 +37,8 @@
*/
public static final String PARAMETER_DOCUMENT_AREA = "document-area";
/**
- * <code>PARAMETER_DOCUMENT_LANGUAGE</code> The document language parameter
+ * <code>PARAMETER_DOCUMENT_LANGUAGE</code> The document language
+ * parameter
*/
public static final String PARAMETER_DOCUMENT_LANGUAGE = "document-language";
@@ -72,7 +73,7 @@
protected Document getDocument(String documentId, String area, String language)
throws ExecutionException {
try {
- return getIdentityMap().getFactory().get(area, documentId, language);
+ return getIdentityMap().getFactory().get(getPublication(), area, documentId, language);
} catch (DocumentBuildException e) {
throw new ExecutionException(e);
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java Sat Mar 12 15:10:56 2005
@@ -54,6 +54,7 @@
private static final Logger log = Logger.getLogger(PublicationTask.class);
private DocumentIdentityMap map;
+ private Publication publication;
/**
* Returns the publication used by this task.
@@ -61,7 +62,18 @@
* @throws ExecutionException when an error occurs.
*/
protected Publication getPublication() throws ExecutionException {
- return getIdentityMap().getPublication();
+ if (this.publication == null) {
+ try {
+ String publicationId = getParameters().getParameter(Task.PARAMETER_PUBLICATION_ID);
+ String servletContextPath = getParameters()
+ .getParameter(Task.PARAMETER_SERVLET_CONTEXT);
+ PublicationFactory factory = PublicationFactory.getInstance(new ConsoleLogger());
+ this.publication = factory.getPublication(publicationId, servletContextPath);
+ } catch (Exception e) {
+ throw new ExecutionException(e);
+ }
+ }
+ return this.publication;
}
/**
@@ -71,16 +83,7 @@
*/
protected DocumentIdentityMap getIdentityMap() throws ExecutionException {
if (this.map == null) {
- try {
- String publicationId = getParameters().getParameter(Task.PARAMETER_PUBLICATION_ID);
- String servletContextPath = getParameters()
- .getParameter(Task.PARAMETER_SERVLET_CONTEXT);
- PublicationFactory factory = PublicationFactory.getInstance(new ConsoleLogger());
- Publication publication = factory.getPublication(publicationId, servletContextPath);
- this.map = new DocumentIdentityMap(publication);
- } catch (Exception e) {
- throw new ExecutionException(e);
- }
+ this.map = new DocumentIdentityMap();
}
return this.map;
}
@@ -138,7 +141,8 @@
*/
public static final String PARAMETER_ROLE_IDS = "role-ids";
/**
- * <code>ROLE_SEPARATOR_REGEXP</code> The role separator regular expression
+ * <code>ROLE_SEPARATOR_REGEXP</code> The role separator regular
+ * expression
*/
public static final String ROLE_SEPARATOR_REGEXP = ",";
@@ -199,11 +203,11 @@
WorkflowFactory factory = WorkflowFactory.newInstance();
if (factory.hasWorkflow(document)) {
-
+
try {
String userId = getParameters().getParameter(PARAMETER_USER_ID);
String machineIp = getParameters().getParameter(PARAMETER_IP_ADDRESS);
-
+
Workflow workflow = factory.getWorkflow(document);
Situation situation = factory.buildSituation(getRoleIDs(), userId, machineIp);
WorkflowEngine engine = new WorkflowEngineImpl();
@@ -249,7 +253,7 @@
if (!(manager instanceof TreeSiteManager)) {
throw new RuntimeException("Only supported for site trees.");
}
- tree = ((TreeSiteManager) manager).getTree(getIdentityMap(), area);
+ tree = ((TreeSiteManager) manager).getTree(getIdentityMap(), getPublication(), area);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/util/CollectionImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/util/CollectionImpl.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/util/CollectionImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/util/CollectionImpl.java Sat Mar 12 15:10:56 2005
@@ -31,6 +31,7 @@
import org.apache.lenya.cms.publication.DocumentBuildException;
import org.apache.lenya.cms.publication.DocumentException;
import org.apache.lenya.cms.publication.DocumentIdentityMap;
+import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.xml.DocumentHelper;
import org.apache.lenya.xml.NamespaceHelper;
import org.apache.xpath.XPathAPI;
@@ -48,31 +49,35 @@
/**
* Ctor.
* @param map A document identity map.
+ * @param publication The publication.
* @param id The document ID.
* @param area The area the document belongs to.
* @throws DocumentException when something went wrong.
*/
- public CollectionImpl(DocumentIdentityMap map, String id, String area) throws DocumentException {
- super(map, id, area);
+ public CollectionImpl(DocumentIdentityMap map, Publication publication, String id, String area)
+ throws DocumentException {
+ super(map, publication, id, area);
}
/**
* Ctor.
* @param map A document identity map.
+ * @param publication The publication.
* @param id The document ID.
* @param area The area the document belongs to.
* @param language The language of the document.
* @throws DocumentException when something went wrong.
*/
- public CollectionImpl(DocumentIdentityMap map, String id, String area, String language)
- throws DocumentException {
- super(map, id, area, language);
+ public CollectionImpl(DocumentIdentityMap map, Publication publication, String id, String area,
+ String language) throws DocumentException {
+ super(map, publication, id, area, language);
}
private List documentsList = new ArrayList();
/**
- * Returns the list that holds the documents. Use this method to invoke lazy loading.
+ * Returns the list that holds the documents. Use this method to invoke lazy
+ * loading.
* @return A list.
* @throws DocumentException when something went wrong.
*/
@@ -156,7 +161,10 @@
*/
protected Document loadDocument(Element documentElement) throws DocumentBuildException {
String documentId = documentElement.getAttribute(ATTRIBUTE_ID);
- Document document = getIdentityMap().getFactory().get(getArea(), documentId, getLanguage());
+ Document document = getIdentityMap().getFactory().get(getPublication(),
+ getArea(),
+ documentId,
+ getLanguage());
return document;
}
@@ -215,7 +223,7 @@
documentElement.setAttributeNS(null, ATTRIBUTE_ID, document.getId());
return documentElement;
} catch (final DOMException e) {
- throw new DocumentException(e);
+ throw new DocumentException(e);
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentHelper.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentHelper.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentHelper.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentHelper.java Sat Mar 12 15:10:56 2005
@@ -47,6 +47,7 @@
private Map objectModel;
private DocumentIdentityMap identityMap;
+ private Publication publication;
/**
* Ctor.
@@ -55,20 +56,19 @@
*/
public DocumentHelper(Map _objectModel) {
this.objectModel = _objectModel;
- Publication publication;
try {
PublicationFactory factory = PublicationFactory.getInstance(new ConsoleLogger());
- publication = factory.getPublication(_objectModel);
+ this.publication = factory.getPublication(_objectModel);
} catch (PublicationException e) {
throw new RuntimeException(e);
}
- this.identityMap = new DocumentIdentityMap(publication);
+ this.identityMap = new DocumentIdentityMap();
}
/**
- * Creates a document URL. <br/>If the document ID is null, the current document ID is used.
- * <br/>If the document area is null, the current area is used. <br/>If the language is null,
- * the current language is used.
+ * Creates a document URL. <br/>If the document ID is null, the current
+ * document ID is used. <br/>If the document area is null, the current area
+ * is used. <br/>If the language is null, the current language is used.
* @param documentId The target document ID.
* @param documentArea The target area.
* @param language The target language.
@@ -81,8 +81,8 @@
String url = null;
try {
- PageEnvelope envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(
- this.identityMap, this.objectModel);
+ PageEnvelope envelope = PageEnvelopeFactory.getInstance()
+ .getPageEnvelope(this.identityMap, this.objectModel);
if (documentId == null) {
documentId = envelope.getDocument().getId();
@@ -101,7 +101,9 @@
language = envelope.getDocument().getLanguage();
}
- Document document = this.identityMap.getFactory().get(documentArea, documentId,
+ Document document = this.identityMap.getFactory().get(this.publication,
+ documentArea,
+ documentId,
language);
url = document.getCanonicalWebappURL();
@@ -122,9 +124,9 @@
}
/**
- * Returns the complete URL of the parent document. If the document is a top-level document, the
- * /index document is chosen. If the parent does not exist in the appropriate language, the
- * default language is chosen.
+ * Returns the complete URL of the parent document. If the document is a
+ * top-level document, the /index document is chosen. If the parent does not
+ * exist in the appropriate language, the default language is chosen.
* @return A string.
* @throws ProcessingException when something went wrong.
*/
@@ -133,8 +135,8 @@
String parentUrl;
String contextPath;
try {
- PageEnvelope envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(
- this.identityMap, this.objectModel);
+ PageEnvelope envelope = PageEnvelopeFactory.getInstance()
+ .getPageEnvelope(this.identityMap, this.objectModel);
Document document = envelope.getDocument();
Request request = ObjectModelHelper.getRequest(this.objectModel);
@@ -156,9 +158,10 @@
}
/**
- * Returns an existing language version of a document. If the document exists in the default
- * language, the default language version is returned. Otherwise, a random language version is
- * returned. If no language version exists, a DocumentException is thrown.
+ * Returns an existing language version of a document. If the document
+ * exists in the default language, the default language version is returned.
+ * Otherwise, a random language version is returned. If no language version
+ * exists, a DocumentException is thrown.
*
* @param document The document.
* @return A document.
@@ -169,10 +172,11 @@
}
/**
- * Returns an existing language version of a document. If the document exists in the preferred
- * language, this version is returned. Otherwise, if the document exists in the default
- * language, the default language version is returned. Otherwise, a random language version is
- * returned. If no language version exists, a DocumentException is thrown.
+ * Returns an existing language version of a document. If the document
+ * exists in the preferred language, this version is returned. Otherwise, if
+ * the document exists in the default language, the default language version
+ * is returned. Otherwise, a random language version is returned. If no
+ * language version exists, a DocumentException is thrown.
*
* @param document The document.
* @param preferredLanguage The preferred language.
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentReferencesHelper.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentReferencesHelper.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentReferencesHelper.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentReferencesHelper.java Sat Mar 12 15:10:56 2005
@@ -68,22 +68,25 @@
}
/**
- * Construct a search string for the search of references, i.e. links from other documents to
- * the current document. This is done using the assumption that internal links look as if they
- * were copied directly from the browser, e.g. /lenya/default/authoring/doctypes/2columns.html
+ * Construct a search string for the search of references, i.e. links from
+ * other documents to the current document. This is done using the
+ * assumption that internal links look as if they were copied directly from
+ * the browser, e.g. /lenya/default/authoring/doctypes/2columns.html
*
* @return the search string
*/
protected String getReferencesSearchString() {
return "href\\s*=\\s*\"" + this.pageEnvelope.getContext() + "/"
+ this.pageEnvelope.getPublication().getId() + "/"
- + this.pageEnvelope.getDocument().getArea() + this.pageEnvelope.getDocument().getId();
+ + this.pageEnvelope.getDocument().getArea()
+ + this.pageEnvelope.getDocument().getId();
}
/**
- * Construct a search string for the search of internal references, i.e from the current
- * document to others. This is done using the assumption that internal links look as if they
- * were copied directly from the browser, e.g. /lenya/default/authoring/doctypes/2columns.html
+ * Construct a search string for the search of internal references, i.e from
+ * the current document to others. This is done using the assumption that
+ * internal links look as if they were copied directly from the browser,
+ * e.g. /lenya/default/authoring/doctypes/2columns.html
*
* @return the search string
*/
@@ -103,19 +106,19 @@
// DocumentToPathMapper and will probably fail if the URL
// looks different.
- return Pattern
- .compile("href\\s*=\\s*\"" + this.pageEnvelope.getContext() + "/"
- + this.pageEnvelope.getPublication().getId() + "/"
- + this.pageEnvelope.getDocument().getArea()
- + "(/[-a-zA-Z0-9_/]+?)(_[a-z][a-z])?\\.html");
+ return Pattern.compile("href\\s*=\\s*\"" + this.pageEnvelope.getContext() + "/"
+ + this.pageEnvelope.getPublication().getId() + "/"
+ + this.pageEnvelope.getDocument().getArea()
+ + "(/[-a-zA-Z0-9_/]+?)(_[a-z][a-z])?\\.html");
}
/**
- * Find a list of document-ids which have references to the current document.
+ * Find a list of document-ids which have references to the current
+ * document.
* @param area The area.
*
- * @return an <code>array</code> of documents if there are references, an empty
- * <code>array</code> otherwise
+ * @return an <code>array</code> of documents if there are references, an
+ * empty <code>array</code> otherwise
*
* @throws ProcessingException if the search for references failed.
*/
@@ -133,12 +136,18 @@
inconsistentFiles = Grep.find(publication.getContentDirectory(area),
getReferencesSearchString());
for (int i = 0; i < inconsistentFiles.length; i++) {
- // for performance reasons the getReferencesSearchString() is
- // constructed in a way such that it will catch all files which
- // have a link to any language version of the current document.
- // That's why we need to do some additional tests for each hit.
- String languageOfCurrentDocument = this.pageEnvelope.getDocument().getLanguage();
- String defaultLanguage = this.pageEnvelope.getPublication().getDefaultLanguage();
+ // for performance reasons the getReferencesSearchString()
+ // is
+ // constructed in a way such that it will catch all files
+ // which
+ // have a link to any language version of the current
+ // document.
+ // That's why we need to do some additional tests for each
+ // hit.
+ String languageOfCurrentDocument = this.pageEnvelope.getDocument()
+ .getLanguage();
+ String defaultLanguage = this.pageEnvelope.getPublication()
+ .getDefaultLanguage();
Pattern referencesSearchStringWithLanguage = Pattern
.compile(getReferencesSearchString() + "_" + languageOfCurrentDocument);
Pattern referencesSearchStringWithOutLanguage = Pattern
@@ -149,22 +158,27 @@
+ referencesSearchStringWithOutLanguage.pattern());
log.debug("referencesSearchStringWithLanguage: "
+ referencesSearchStringWithLanguage.pattern());
- // a link is indeed to the current document if the following conditions
+ // a link is indeed to the current document if the following
+ // conditions
// are met:
// 1. the link is to foo_xx and the language of the current
// document is xx.
- // 2. or the link is to foo.html and the language of the current
+ // 2. or the link is to foo.html and the language of the
+ // current
// document is the default language.
- // Now negate the expression because we continue if above (1) and (2) are
+ // Now negate the expression because we continue if above
+ // (1) and (2) are
// false, and you'll get the following if statement
if (!Grep.containsPattern(inconsistentFiles[i],
referencesSearchStringWithLanguage)
&& !(Grep.containsPattern(inconsistentFiles[i],
referencesSearchStringWithOutLanguage) && languageOfCurrentDocument
.equals(defaultLanguage))) {
- // the reference foo_xx is neither to the language of the current
+ // the reference foo_xx is neither to the language of
+ // the current
// document.
- // nor is the reference foo.html and the current document is in the
+ // nor is the reference foo.html and the current
+ // document is in the
// default language.
// So the reference is of no importance to us, skip
continue;
@@ -179,7 +193,10 @@
}
log.debug("language: " + language);
- documents.add(this.identityMap.getFactory().get(area, documentId, language));
+ documents.add(this.identityMap.getFactory().get(publication,
+ area,
+ documentId,
+ language));
}
} catch (IOException e) {
throw new ProcessingException(e);
@@ -193,11 +210,12 @@
}
/**
- * Find all internal references in the current document to documents which have not been
- * published yet.
+ * Find all internal references in the current document to documents which
+ * have not been published yet.
*
- * @return an <code>array</code> of <code>Document</code> of references from the current
- * document to documents which have not been published yet.
+ * @return an <code>array</code> of <code>Document</code> of references
+ * from the current document to documents which have not been
+ * published yet.
*
* @throws ProcessingException if the current document cannot be opened.
*/
@@ -207,9 +225,10 @@
Publication publication = this.pageEnvelope.getPublication();
try {
String[] internalLinks = Grep.findPattern(this.pageEnvelope.getDocument().getFile(),
- internalLinkPattern, 1);
- String[] internalLinksLanguages = Grep.findPattern(
- this.pageEnvelope.getDocument().getFile(), internalLinkPattern, 2);
+ internalLinkPattern,
+ 1);
+ String[] internalLinksLanguages = Grep.findPattern(this.pageEnvelope.getDocument()
+ .getFile(), internalLinkPattern, 2);
for (int i = 0; i < internalLinks.length; i++) {
String docId = internalLinks[i];
@@ -226,7 +245,9 @@
}
log.debug("language: " + language);
- Document liveDocument = this.identityMap.getFactory().get(Publication.LIVE_AREA, docId,
+ Document liveDocument = this.identityMap.getFactory().get(publication,
+ Publication.LIVE_AREA,
+ docId,
language);
if (!liveDocument.exists()) {
// the docId has not been published for the given language
@@ -234,8 +255,8 @@
if (liveLanguage == null) {
liveLanguage = publication.getDefaultLanguage();
}
- unpublishedReferences.add(this.identityMap.getFactory().getLanguageVersion(
- liveDocument, liveLanguage));
+ unpublishedReferences.add(this.identityMap.getFactory()
+ .getLanguageVersion(liveDocument, liveLanguage));
}
}
} catch (final DocumentBuildException e) {
@@ -247,6 +268,6 @@
}
return (Document[]) unpublishedReferences
- .toArray(new Document[unpublishedReferences.size()]);
+ .toArray(new Document[unpublishedReferences.size()]);
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/util/PublicationHelper.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/util/PublicationHelper.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/util/PublicationHelper.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/util/PublicationHelper.java Sat Mar 12 15:10:56 2005
@@ -55,14 +55,18 @@
public Document[] getAllDocuments(DocumentIdentityMap map, String area, String language)
throws DocumentException {
try {
- Document[] allDocuments = getPublication().getSiteManager().getDocuments(map, area);
+ Document[] allDocuments = getPublication().getSiteManager().getDocuments(map,
+ this.publication,
+ area);
List documents = new ArrayList();
for (int i = 0; i < allDocuments.length; i++) {
Document doc = allDocuments[i];
- Document languageDoc = doc.getIdentityMap().getFactory().get(doc.getArea(),
- doc.getId(), language);
+ Document languageDoc = doc.getIdentityMap().getFactory().get(getPublication(),
+ doc.getArea(),
+ doc.getId(),
+ language);
documents.add(languageDoc);
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/util/UniqueDocumentId.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/util/UniqueDocumentId.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/util/UniqueDocumentId.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/util/UniqueDocumentId.java Sat Mar 12 15:10:56 2005
@@ -28,8 +28,9 @@
import org.apache.lenya.cms.site.tree.TreeSiteManager;
/**
- * class to compute an unique document id for a document, if there is already a node in the sitetree
- * for a document with this id. It will documentid_"number of version"
+ * class to compute an unique document id for a document, if there is already a
+ * node in the sitetree for a document with this id. It will documentid_"number
+ * of version"
*/
public class UniqueDocumentId {
@@ -42,14 +43,14 @@
*/
public String computeUniqueDocumentId(Publication publication, String area, String documentid) {
try {
-
+
SiteManager manager = publication.getSiteManager();
-
+
if (!(manager instanceof TreeSiteManager)) {
throw new RuntimeException("Only supported for site trees!");
}
- DocumentIdentityMap map = new DocumentIdentityMap(publication);
- SiteTree tree = ((TreeSiteManager) manager).getTree(map, area);
+ DocumentIdentityMap map = new DocumentIdentityMap();
+ SiteTree tree = ((TreeSiteManager) manager).getTree(map, publication, area);
SiteTreeNode node = tree.getNode(documentid);
String suffix = null;
int version = 0;
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/util/XlinkCollection.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/util/XlinkCollection.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/util/XlinkCollection.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/util/XlinkCollection.java Sat Mar 12 15:10:56 2005
@@ -24,6 +24,7 @@
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentException;
import org.apache.lenya.cms.publication.DocumentIdentityMap;
+import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.xml.NamespaceHelper;
import org.apache.lenya.xml.XLink;
import org.w3c.dom.Element;
@@ -38,26 +39,28 @@
/**
* Ctor.
* @param map A document identity map.
+ * @param publication The publication.
* @param id The document ID.
* @param area The area the document belongs to.
* @throws DocumentException when something went wrong.
*/
- public XlinkCollection(DocumentIdentityMap map, String id, String area)
+ public XlinkCollection(DocumentIdentityMap map, Publication publication, String id, String area)
throws DocumentException {
- super(map, id, area);
+ super(map, publication, id, area);
}
/**
* Ctor.
* @param map A document identity map.
+ * @param publication The publication.
* @param id The document ID.
* @param area The area the document belongs to.
* @param language The language of the document.
* @throws DocumentException when something went wrong.
*/
- public XlinkCollection(DocumentIdentityMap map, String id, String area, String language)
- throws DocumentException {
- super(map, id, area, language);
+ public XlinkCollection(DocumentIdentityMap map, Publication publication, String id,
+ String area, String language) throws DocumentException {
+ super(map, publication, id, area, language);
}
/**
@@ -100,10 +103,11 @@
NamespaceHelper helper = super.getNamespaceHelper();
if (!exists()) {
Element collectionElement = helper.getDocument().getDocumentElement();
- String namespaceDeclaration = collectionElement.getAttributeNS(
- "http://www.w3.org/2000/xmlns/", "xlink");
+ String namespaceDeclaration = collectionElement
+ .getAttributeNS("http://www.w3.org/2000/xmlns/", "xlink");
if (namespaceDeclaration == null || !namespaceDeclaration.equals(XLink.XLINK_NAMESPACE)) {
- collectionElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:xlink",
+ collectionElement.setAttributeNS("http://www.w3.org/2000/xmlns/",
+ "xmlns:xlink",
XLink.XLINK_NAMESPACE);
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/scheduler/LoadQuartzServlet.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/scheduler/LoadQuartzServlet.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/scheduler/LoadQuartzServlet.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/scheduler/LoadQuartzServlet.java Sat Mar 12 15:10:56 2005
@@ -98,7 +98,6 @@
*/
public static final String SERVLET_URL = "/servlet/QuartzSchedulerServlet";
-
/**
* Returns the scheduler wrapper.
* @return A scheduler wrapper.
@@ -275,9 +274,9 @@
getServletContextDirectory().getAbsolutePath());
String documentUrl = (String) schedulerParameters.get(PARAMETER_DOCUMENT_URL);
- DocumentIdentityMap map = new DocumentIdentityMap(publication);
+ DocumentIdentityMap map = new DocumentIdentityMap();
org.apache.lenya.cms.publication.Document document = map.getFactory()
- .getFromURL(documentUrl);
+ .getFromURL(publication, documentUrl);
deleteDocumentJobs(document);
}
@@ -396,7 +395,8 @@
File publicationsDirectory = new File(getServletContextDirectory(),
PublishingEnvironment.PUBLICATION_PREFIX);
- File[] publicationDirectories = publicationsDirectory.listFiles(new IsDirectoryFileFilter());
+ File[] publicationDirectories = publicationsDirectory
+ .listFiles(new IsDirectoryFileFilter());
log.debug("=========================================");
log.debug(" Restoring jobs.");
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java Sat Mar 12 15:10:56 2005
@@ -19,6 +19,7 @@
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentIdentityMap;
+import org.apache.lenya.cms.publication.Publication;
/**
* <p>
@@ -26,19 +27,21 @@
* </p>
*
* <p>
- * Dependence on a set of resources must be a strict partial order <strong>< </strong>:
+ * Dependence on a set of resources must be a strict partial order <strong><
+ * </strong>:
* </p>
* <ul>
- * <li><em>irreflexive:</em> d <strong>< </strong>d does not hold for any resource d</li>
- * <li><em>antisymmetric:</em> d <strong>< </strong>e and e <strong>< </strong>d implies
- * d=e</li>
- * <li><em>transitive:</em> d <strong>< </strong>e and e <strong>< </strong>f implies d
- * <strong>< </strong>f</li>
+ * <li><em>irreflexive:</em> d <strong>< </strong>d does not hold for any
+ * resource d</li>
+ * <li><em>antisymmetric:</em> d <strong>< </strong>e and e <strong><
+ * </strong>d implies d=e</li>
+ * <li><em>transitive:</em> d <strong>< </strong>e and e <strong><
+ * </strong>f implies d <strong>< </strong>f</li>
* </ul>*
* @version $Id$
*/
public interface SiteManager {
-
+
/**
* The Avalon role.
*/
@@ -68,7 +71,7 @@
* @throws SiteException if an error occurs.
*/
Document[] getRequiringResources(Document resource) throws SiteException;
-
+
/**
* Adds a document to the site structure.
* @param document The document to add.
@@ -77,7 +80,8 @@
void add(Document document) throws SiteException;
/**
- * Checks if the site structure contains a certain resource in a certain area.
+ * Checks if the site structure contains a certain resource in a certain
+ * area.
* @param resource The resource.
* @return A boolean value.
* @throws SiteException if an error occurs.
@@ -85,8 +89,8 @@
boolean contains(Document resource) throws SiteException;
/**
- * Checks if the site structure contains any language version of a certain resource in a certain
- * area.
+ * Checks if the site structure contains any language version of a certain
+ * resource in a certain area.
* @param resource The resource.
* @return A boolean value.
* @throws SiteException if an error occurs.
@@ -115,7 +119,7 @@
* @throws SiteException if an error occurs.
*/
String getLabel(Document document) throws SiteException;
-
+
/**
* Sets the label of a certain document.
* @param document The document.
@@ -127,10 +131,12 @@
/**
* Returns all documents in a certain area.
* @param identityMap The identityMap to use.
+ * @param publication The publication.
* @param area The area.
* @return An array of documents.
* @throws SiteException if an error occurs.
*/
- Document[] getDocuments(DocumentIdentityMap identityMap, String area) throws SiteException;
-
+ Document[] getDocuments(DocumentIdentityMap identityMap, Publication publication, String area)
+ throws SiteException;
+
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/topicmap/TopicMapSiteManager.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/topicmap/TopicMapSiteManager.java?view=diff&r1=157294&r2=157295
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/topicmap/TopicMapSiteManager.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/topicmap/TopicMapSiteManager.java Sat Mar 12 15:10:56 2005
@@ -18,6 +18,7 @@
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentIdentityMap;
+import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.site.SiteException;
import org.apache.lenya.cms.site.SiteManager;
@@ -112,9 +113,10 @@
/**
* @see org.apache.lenya.cms.site.SiteManager#getDocuments(org.apache.lenya.cms.publication.DocumentIdentityMap,
- * java.lang.String)
+ * org.apache.lenya.cms.publication.Publication, java.lang.String)
*/
- public Document[] getDocuments(DocumentIdentityMap map, String area) throws SiteException {
+ public Document[] getDocuments(DocumentIdentityMap map, Publication publication, String area)
+ throws SiteException {
// TODO Auto-generated method stub
return null;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org