You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by fl...@apache.org on 2010/11/24 15:20:28 UTC
svn commit: r1038618 - in /lenya/trunk/org.apache.lenya.core.document.api:
./ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/lenya/ src/main/java/org/apache/lenya/cms/
src/main/java/org/apache/lenya/cms/publication/ src/main/java...
Author: florent
Date: Wed Nov 24 14:20:28 2010
New Revision: 1038618
URL: http://svn.apache.org/viewvc?rev=1038618&view=rev
Log:
-populate api
Added:
lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/
lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/
lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/
lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/
lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/
lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/Document.java
- copied, changed from r1035056, lenya/trunk/org.apache.lenya.core.document.impl/src/main/java/org/apache/lenya/cms/publication/Document.java
lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentBuildException.java
- copied, changed from r1035056, lenya/trunk/org.apache.lenya.core.document.impl/src/main/java/org/apache/lenya/cms/publication/DocumentBuildException.java
lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentDoesNotExistException.java
- copied unchanged from r1035056, lenya/trunk/org.apache.lenya.core.document.impl/src/main/java/org/apache/lenya/cms/publication/DocumentDoesNotExistException.java
lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentException.java
- copied, changed from r1035056, lenya/trunk/org.apache.lenya.core.document.impl/src/main/java/org/apache/lenya/cms/publication/DocumentException.java
lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentIdToPathMapper.java
- copied unchanged from r1035056, lenya/trunk/org.apache.lenya.core.document.impl/src/main/java/org/apache/lenya/cms/publication/DocumentIdToPathMapper.java
lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentIdentifier.java
- copied, changed from r1035056, lenya/trunk/org.apache.lenya.core.document.impl/src/main/java/org/apache/lenya/cms/publication/DocumentIdentifier.java
lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentLocator.java
- copied, changed from r1035056, lenya/trunk/org.apache.lenya.core.document.impl/src/main/java/org/apache/lenya/cms/publication/DocumentLocator.java
lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/ResourceType.java
- copied unchanged from r1034526, lenya/trunk/org.apache.lenya.core.publication.impl/src/main/java/org/apache/lenya/cms/publication/ResourceType.java
lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/util/
lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/util/DocumentVisitor.java
- copied unchanged from r1034526, lenya/trunk/org.apache.lenya.core.publication.impl/src/main/java/org/apache/lenya/cms/publication/util/DocumentVisitor.java
Modified:
lenya/trunk/org.apache.lenya.core.document.api/pom.xml
Modified: lenya/trunk/org.apache.lenya.core.document.api/pom.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.document.api/pom.xml?rev=1038618&r1=1038617&r2=1038618&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.document.api/pom.xml (original)
+++ lenya/trunk/org.apache.lenya.core.document.api/pom.xml Wed Nov 24 14:20:28 2010
@@ -16,7 +16,22 @@
<description>API for Lenya Document</description>
<dependencies>
-
+ <dependency>
+ <groupId>org.apache.lenya</groupId>
+ <artifactId>lenya-core-repository-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lenya</groupId>
+ <artifactId>lenya-core-transaction-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lenya</groupId>
+ <artifactId>lenya-core-metadata-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lenya</groupId>
+ <artifactId>lenya-core-api</artifactId>
+ </dependency>
<!-- TODO : see if all theses dependencies are required -->
<dependency>
<groupId>org.apache.cocoon</groupId>
Copied: lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/Document.java (from r1035056, lenya/trunk/org.apache.lenya.core.document.impl/src/main/java/org/apache/lenya/cms/publication/Document.java)
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/Document.java?p2=lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/Document.java&p1=lenya/trunk/org.apache.lenya.core.document.impl/src/main/java/org/apache/lenya/cms/publication/Document.java&r1=1035056&r2=1038618&rev=1038618&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.document.impl/src/main/java/org/apache/lenya/cms/publication/Document.java (original)
+++ lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/Document.java Wed Nov 24 14:20:28 2010
@@ -24,7 +24,13 @@ import java.util.Date;
import org.apache.lenya.cms.metadata.MetaDataOwner;
import org.apache.lenya.cms.publication.util.DocumentVisitor;
-import org.apache.lenya.cms.site.Link;
+//florent : removed import as they create cyclic dependencies
+/*import org.apache.lenya.cms.site.Link;
+import org.apache.lenya.cms.publication.Node;*/
+import org.apache.lenya.cms.repository.Node;
+import org.apache.lenya.cms.repository.History;
+import org.apache.lenya.cms.repository.RepositoryException;
+import org.apache.cocoon.ResourceNotFoundException;
/**
* A CMS document.
@@ -68,9 +74,16 @@ public interface Document extends Node,
* Returns the publication this document belongs to.
* @return A publication object.
*/
+ //florent : seems never use, imply cyclic dependencies
+ /*
Publication getPublication();
+ */
/**
+ * returns the publication id that hold the documents
+ */
+ public String getPublicationId();
+ /**
* Returns the canonical web application URL.
* @return A string.
*/
@@ -272,13 +285,17 @@ public interface Document extends Node,
* @return The link to this document in the site structure.
* @throws DocumentException if the document is not referenced in the site structure.
*/
+ //florent : imply cyclic dependencies with publication
+ /*
Link getLink() throws DocumentException;
-
+ */
/**
* @return The area the document belongs to.
*/
+ //florent : imply cyclic dependencies with publication
+ /*
Area area();
-
+*/
/**
* @return if the document is linked in the site structure.
*/
Copied: lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentBuildException.java (from r1035056, lenya/trunk/org.apache.lenya.core.document.impl/src/main/java/org/apache/lenya/cms/publication/DocumentBuildException.java)
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentBuildException.java?p2=lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentBuildException.java&p1=lenya/trunk/org.apache.lenya.core.document.impl/src/main/java/org/apache/lenya/cms/publication/DocumentBuildException.java&r1=1035056&r2=1038618&rev=1038618&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.document.impl/src/main/java/org/apache/lenya/cms/publication/DocumentBuildException.java (original)
+++ lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentBuildException.java Wed Nov 24 14:20:28 2010
@@ -18,12 +18,16 @@
package org.apache.lenya.cms.publication;
+import org.apache.lenya.cms.repository.RepositoryException;
+
/**
* Document build exception.
*
- * @version $Id$
*/
-public class DocumentBuildException extends PublicationException {
+//florent : change exceptions extension in order to repect dependencies
+//public class DocumentBuildException extends PublicationException {
+public class DocumentBuildException extends RepositoryException {
+
/**
*
*/
Copied: lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentException.java (from r1035056, lenya/trunk/org.apache.lenya.core.document.impl/src/main/java/org/apache/lenya/cms/publication/DocumentException.java)
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentException.java?p2=lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentException.java&p1=lenya/trunk/org.apache.lenya.core.document.impl/src/main/java/org/apache/lenya/cms/publication/DocumentException.java&r1=1035056&r2=1038618&rev=1038618&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.document.impl/src/main/java/org/apache/lenya/cms/publication/DocumentException.java (original)
+++ lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentException.java Wed Nov 24 14:20:28 2010
@@ -20,10 +20,14 @@
package org.apache.lenya.cms.publication;
+import org.apache.lenya.cms.repository.RepositoryException;
+
/**
* Document exception
*/
-public class DocumentException extends PublicationException {
+//florent : change exceptions extension in order to repect dependencies
+//public class DocumentException extends PublicationException {
+public class DocumentException extends RepositoryException {
/**
*
Copied: lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentIdentifier.java (from r1035056, lenya/trunk/org.apache.lenya.core.document.impl/src/main/java/org/apache/lenya/cms/publication/DocumentIdentifier.java)
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentIdentifier.java?p2=lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentIdentifier.java&p1=lenya/trunk/org.apache.lenya.core.document.impl/src/main/java/org/apache/lenya/cms/publication/DocumentIdentifier.java&r1=1035056&r2=1038618&rev=1038618&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.document.impl/src/main/java/org/apache/lenya/cms/publication/DocumentIdentifier.java (original)
+++ lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentIdentifier.java Wed Nov 24 14:20:28 2010
@@ -1,97 +1,31 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
package org.apache.lenya.cms.publication;
-/**
- * Value object to identify documents.
- */
-public class DocumentIdentifier {
-
- private String publicationId;
- private String area;
- private String language;
- private String uuid;
-
- /**
- * Ctor.
- * @param pubId The publication ID.
- * @param area The area.
- * @param uuid The document UUID.
- * @param language The language.
- */
- public DocumentIdentifier(String pubId, String area, String uuid, String language) {
-
- if (uuid.startsWith("/") && uuid.split("-").length == 4) {
- throw new IllegalArgumentException("The UUID [" + uuid + "] must not begin with a '/'!");
- }
- if (uuid.indexOf("/") > 0) {
- throw new IllegalArgumentException("The UUID [" + uuid
- + "] must not contain a '/' after the first position!");
- }
-
- this.publicationId = pubId;
- this.area = area;
- this.language = language;
- this.uuid = uuid;
- }
-
- /**
- * @return The UUID.
- */
- public String getUUID() {
- return this.uuid;
- }
-
- /**
- * @return The area.
- */
- public String getArea() {
- return area;
- }
-
- /**
- * @return The language.
- */
- public String getLanguage() {
- return language;
- }
-
- /**
- * @return The publication ID.
- */
- public String getPublicationId() {
- return publicationId;
- }
-
- public boolean equals(Object obj) {
- return (obj instanceof DocumentIdentifier) && obj.hashCode() == hashCode();
- }
-
- public int hashCode() {
- return getKey().hashCode();
- }
-
- protected String getKey() {
- return this.publicationId + ":" + this.area + ":" + this.uuid + ":" + this.language;
- }
-
- public String toString() {
- return getKey();
- }
+public interface DocumentIdentifier {
-}
+ /**
+ * @return The UUID.
+ */
+ public abstract String getUUID();
+
+ /**
+ * @return The area.
+ */
+ public abstract String getArea();
+
+ /**
+ * @return The language.
+ */
+ public abstract String getLanguage();
+
+ /**
+ * @return The publication ID.
+ */
+ public abstract String getPublicationId();
+
+ public abstract boolean equals(Object obj);
+
+ public abstract int hashCode();
+
+ public abstract String toString();
+
+}
\ No newline at end of file
Copied: lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentLocator.java (from r1035056, lenya/trunk/org.apache.lenya.core.document.impl/src/main/java/org/apache/lenya/cms/publication/DocumentLocator.java)
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentLocator.java?p2=lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentLocator.java&p1=lenya/trunk/org.apache.lenya.core.document.impl/src/main/java/org/apache/lenya/cms/publication/DocumentLocator.java&r1=1035056&r2=1038618&rev=1038618&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.document.impl/src/main/java/org/apache/lenya/cms/publication/DocumentLocator.java (original)
+++ lenya/trunk/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentLocator.java Wed Nov 24 14:20:28 2010
@@ -1,210 +1,83 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
package org.apache.lenya.cms.publication;
-import java.util.Map;
-import java.util.WeakHashMap;
+public interface DocumentLocator {
+ /**
+ * @return The area of the document.
+ */
+ public abstract String getArea();
+
+ /**
+ * @return The language of the document.
+ */
+ public abstract String getLanguage();
+
+ /**
+ * @return The path of the document in the site structure.
+ */
+ public abstract String getPath();
+
+ /**
+ * @return The publication ID.
+ */
+ public abstract String getPublicationId();
+
+ /**
+ * Returns a locator with the same publication ID, area, and language, but a different path in
+ * the site structure.
+ * @param path The path.
+ * @return A document locator.
+ */
+ public abstract DocumentLocator getPathVersion(String path);
+
+ /**
+ * Returns a descendant of this locator.
+ * @param relativePath The relative path which must not begin with a slash and must not be
+ * empty.
+ * @return A document locator.
+ */
+ public abstract DocumentLocator getDescendant(String relativePath);
+
+ /**
+ * Returns a child of this locator.
+ * @param step The relative path to the child, it must not contain a slash.
+ * @return A document locator.
+ */
+ public abstract DocumentLocator getChild(String step);
+
+ /**
+ * Returns the parent of this locator.
+ * @return A document locator or <code>null</code> if this is the root locator.
+ */
+ public abstract DocumentLocator getParent();
+
+ /**
+ * Returns the parent of this locator.
+ * @param defaultPath The path of the locator to return if this is the root locator.
+ * @return A document locator.
+ */
+ public abstract DocumentLocator getParent(String defaultPath);
+
+ /**
+ * Returns a locator with the same publication ID, area, and path, but with a different
+ * language.
+ * @param language The language.
+ * @return A document locator.
+ */
+ public abstract DocumentLocator getLanguageVersion(String language);
+
+ public abstract boolean equals(Object obj);
+
+ public abstract int hashCode();
+
+ public abstract String toString();
+
+ /**
+ * Returns a locator with the same publication ID, path, and language, but with a different
+ * area.
+ * @param area The area.
+ * @return A document locator.
+ */
+ public abstract DocumentLocator getAreaVersion(String area);
-/**
- * A DocumentLocator describes a document based on its path in the site structure. The actual
- * document doesn't have to exist.
- */
-public class DocumentLocator {
-
- private static Map locators = new WeakHashMap();
-
- /**
- * Returns a specific document locator.
- * @param pubId The publication ID.
- * @param area The area of the document.
- * @param path The path of the document in the site structure.
- * @param language The language of the document.
- * @return A document locator.
- */
- public static DocumentLocator getLocator(String pubId, String area, String path, String language) {
- String key = DocumentLocator.getKey(pubId, area, path, language);
- DocumentLocator locator = (DocumentLocator) locators.get(key);
- if (locator == null) {
- locator = new DocumentLocator(pubId, area, path, language);
- locators.put(key, locator);
- }
- return locator;
- }
-
- protected static final String getKey(String pubId, String area, String path, String language) {
- return pubId + ":" + area + ":" + path + ":" + language;
- }
-
- private String pubId;
- private String area;
- private String path;
- private String language;
-
- protected DocumentLocator(String pubId, String area, String path, String language) {
- this.path = path;
- this.pubId = pubId;
- this.area = area;
- this.language = language;
- }
-
- /**
- * @return The area of the document.
- */
- public String getArea() {
- return area;
- }
-
- /**
- * @return The language of the document.
- */
- public String getLanguage() {
- return language;
- }
-
- /**
- * @return The path of the document in the site structure.
- */
- public String getPath() {
- return path;
- }
-
- /**
- * @return The publication ID.
- */
- public String getPublicationId() {
- return pubId;
- }
-
- /**
- * Returns a locator with the same publication ID, area, and language, but a different path in
- * the site structure.
- * @param path The path.
- * @return A document locator.
- */
- public DocumentLocator getPathVersion(String path) {
- return DocumentLocator.getLocator(getPublicationId(), getArea(), path, getLanguage());
- }
-
- /**
- * Returns a descendant of this locator.
- * @param relativePath The relative path which must not begin with a slash and must not be
- * empty.
- * @return A document locator.
- */
- public DocumentLocator getDescendant(String relativePath) {
- if (relativePath.length() == 0) {
- throw new IllegalArgumentException("The relative path must not be empty!");
- }
- if (relativePath.startsWith("/")) {
- throw new IllegalArgumentException("The relative path must not start with a slash!");
- }
- return getPathVersion(getPath() + "/" + relativePath);
- }
-
- /**
- * Returns a child of this locator.
- * @param step The relative path to the child, it must not contain a slash.
- * @return A document locator.
- */
- public DocumentLocator getChild(String step) {
- if (step.indexOf("/") > -1) {
- throw new IllegalArgumentException("The step [" + step + "] must not contain a slash!");
- }
- return getDescendant(step);
- }
-
- /**
- * Returns the parent of this locator.
- * @return A document locator or <code>null</code> if this is the root locator.
- */
- public DocumentLocator getParent() {
- int lastSlashIndex = getPath().lastIndexOf("/");
- if (lastSlashIndex > -1) {
- String parentPath = getPath().substring(0, lastSlashIndex);
- return getPathVersion(parentPath);
- } else {
- return null;
- }
- }
-
- /**
- * Returns the parent of this locator.
- * @param defaultPath The path of the locator to return if this is the root locator.
- * @return A document locator.
- */
- public DocumentLocator getParent(String defaultPath) {
- DocumentLocator parent = getParent();
- if (parent != null) {
- return parent;
- } else {
- return getPathVersion(defaultPath);
- }
- }
-
- /**
- * Returns a locator with the same publication ID, area, and path, but with a different
- * language.
- * @param language The language.
- * @return A document locator.
- */
- public DocumentLocator getLanguageVersion(String language) {
- return DocumentLocator.getLocator(getPublicationId(), getArea(), getPath(), language);
- }
-
- protected String getKey() {
- return DocumentLocator.getKey(getPublicationId(), getArea(), getPath(), getLanguage());
- }
-
- public boolean equals(Object obj) {
- if (!(obj instanceof DocumentLocator)) {
- return false;
- }
- DocumentLocator locator = (DocumentLocator) obj;
- return locator.getKey().equals(getKey());
- }
-
- public int hashCode() {
- return getKey().hashCode();
- }
-
- public String toString() {
- return getKey();
- }
-
- /**
- * Returns a locator with the same publication ID, path, and language, but with a different
- * area.
- * @param area The area.
- * @return A document locator.
- */
- public DocumentLocator getAreaVersion(String area) {
- return DocumentLocator.getLocator(getPublicationId(), area, getPath(), getLanguage());
- }
-
- public Document getDocument(Session session) throws ResourceNotFoundException {
- try {
- Publication pub = session.getPublication(getPublicationId());
- return pub.getArea(getArea()).getSite().getNode(getPath()).getLink(getLanguage())
- .getDocument();
- } catch (PublicationException e) {
- throw new ResourceNotFoundException(e);
- }
- }
-
-}
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org