-populate api
git-svn-id: https://svn.apache.org/repos/asf/lenya/trunk@1038618 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/org.apache.lenya.core.document.api/pom.xml b/org.apache.lenya.core.document.api/pom.xml
index 3e333da..73e9637 100644
--- a/org.apache.lenya.core.document.api/pom.xml
+++ b/org.apache.lenya.core.document.api/pom.xml
@@ -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>
diff --git a/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/Document.java b/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/Document.java
new file mode 100644
index 0000000..6093cb0
--- /dev/null
+++ b/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/Document.java
@@ -0,0 +1,323 @@
+/*
+ * 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.io.InputStream;
+import java.io.OutputStream;
+import java.util.Date;
+
+import org.apache.lenya.cms.metadata.MetaDataOwner;
+import org.apache.lenya.cms.publication.util.DocumentVisitor;
+//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.
+ */
+public interface Document extends Node, MetaDataOwner {
+
+ /**
+ * The document namespace URI.
+ */
+ String NAMESPACE = "http://apache.org/cocoon/lenya/document/1.0";
+
+ /**
+ * The default namespace prefix.
+ */
+ String DEFAULT_PREFIX = "lenya";
+
+ /**
+ * The transactionable type for document objects.
+ */
+ String TRANSACTIONABLE_TYPE = "document";
+
+ /**
+ * <code>DOCUMENT_META_SUFFIX</code> The suffix for document meta Uris
+ */
+ final String DOCUMENT_META_SUFFIX = ".meta";
+
+ /**
+ * Returns the date at which point the requested document is considered expired
+ * @return a string in RFC 1123 date format
+ * @throws DocumentException if an error occurs.
+ */
+ Date getExpires() throws DocumentException;
+
+ /**
+ * Returns the document name of this document.
+ * @return the document-name of this document.
+ */
+ String getName();
+
+ /**
+ * 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.
+ */
+ String getCanonicalWebappURL();
+
+ /**
+ * Returns the canonical document URL.
+ * @return A string.
+ */
+ String getCanonicalDocumentURL();
+
+ /**
+ * Returns the language of this document.
+ * Each document has one language associated to it.
+ * @return A string denoting the language.
+ */
+ String getLanguage();
+
+ /**
+ * Returns all the languages this document is available in.
+ * A document has one associated language (@see Document#getLanguage)
+ * but there are possibly a number of other languages for which a
+ * document with the same document-uuid is also available in.
+ *
+ * @return An array of strings denoting the languages.
+ */
+ String[] getLanguages();
+
+ /**
+ * Returns the date of the last modification of this document.
+ * @return A date denoting the date of the last modification.
+ * @throws DocumentException if an error occurs.
+ */
+ long getLastModified() throws DocumentException;
+
+ /**
+ * Returns the area this document belongs to.
+ * @return The area.
+ */
+ String getArea();
+
+ /**
+ * Returns the extension in the URL without the dot.
+ * @return A string.
+ */
+ String getExtension();
+
+ /**
+ * Returns the UUID.
+ * @return A string.
+ */
+ String getUUID();
+
+ /**
+ * Check if a document with the given document-uuid, language and in the given
+ * area actually exists.
+ *
+ * @return true if the document exists, false otherwise
+ */
+ boolean exists();
+
+ /**
+ * Check if a document exists with the given document-uuid and the given area
+ * independently of the given language.
+ *
+ * @return true if a document with the given document-uuid and area exists, false otherwise
+ */
+ boolean existsInAnyLanguage();
+
+ /**
+ * Returns the URI to resolve the document's source.
+ * The source can only be used for read-only access.
+ * For write access, use {@link #getOutputStream()}.
+ * @return A string.
+ */
+ String getSourceURI();
+
+ /**
+ * @return The output stream to write the document content to.
+ */
+ OutputStream getOutputStream();
+
+ /**
+ * Accepts a document visitor.
+ * @param visitor The visitor.
+ * @throws Exception if an error occurs.
+ */
+ void accept(DocumentVisitor visitor) throws Exception;
+
+ /**
+ * Deletes the document.
+ * @throws DocumentException if an error occurs.
+ */
+ void delete() throws DocumentException;
+
+ /**
+ * @return The resource type of this document (formerly known as doctype)
+ * @throws DocumentException if the resource type has not been set.
+ */
+ ResourceType getResourceType() throws DocumentException;
+
+ /**
+ * @param resourceType The resource type of this document.
+ */
+ void setResourceType(ResourceType resourceType);
+
+ /**
+ * @return The source extension used by this document, without the dot.
+ */
+ String getSourceExtension();
+
+ /**
+ * @param extension The source extension used by this document, without the dot.
+ */
+ void setSourceExtension(String extension);
+
+ /**
+ * Sets the mime type of this document.
+ * @param mimeType The mime type.
+ */
+ void setMimeType(String mimeType);
+
+ /**
+ * @return The mime type of this document.
+ * @throws DocumentException if the mime type has not been set.
+ */
+ String getMimeType() throws DocumentException;
+
+ /**
+ * @return The content length of the document.
+ */
+ long getContentLength();
+
+ /**
+ * @return The document identifier for this document.
+ */
+ DocumentIdentifier getIdentifier();
+
+ /**
+ * This is a shortcut to getLink().getNode().getPath().
+ * @return The path of this document in the site structure.
+ * @throws DocumentException if the document is not linked in the site structure.
+ */
+ String getPath() throws DocumentException;
+
+ /**
+ * Checks if a certain translation (language version) of this document exists.
+ * @param language The language.
+ * @return A boolean value.
+ */
+ boolean existsTranslation(String language);
+
+ /**
+ * Returns a certain translation (language version) of this document.
+ * @param language The language.
+ * @return A document.
+ * @throws ResourceNotFoundException if the language version doesn't exist.
+ */
+ Document getTranslation(String language) throws ResourceNotFoundException;
+
+ /**
+ * Checks if this document exists in a certain area.
+ * @param area The area.
+ * @return A boolean value.
+ */
+ boolean existsAreaVersion(String area);
+
+ /**
+ * Returns the document in a certain area.
+ * @param area The area.
+ * @return A document.
+ * @throws ResourceNotFoundException if the area version doesn't exist.
+ */
+ Document getAreaVersion(String area) throws ResourceNotFoundException;
+
+ /**
+ * Checks if a translation of this document exists in a certain area.
+ * @param area The area.
+ * @param language The language.
+ * @return A boolean value.
+ */
+ boolean existsVersion(String area, String language);
+
+ /**
+ * Returns a translation of this document in a certain area.
+ * @param area The area.
+ * @param language The language.
+ * @return A document.
+ * @throws ResourceNotFoundException if the area version doesn't exist.
+ */
+ Document getVersion(String area, String language) throws ResourceNotFoundException;
+
+ /**
+ * @return A document locator.
+ */
+ DocumentLocator getLocator();
+
+ /**
+ * @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.
+ */
+ boolean hasLink();
+
+ /**
+ * @return The input stream to obtain the document's content.
+ */
+ InputStream getInputStream();
+
+ /**
+ * @param i The revision number.
+ * @return A revision.
+ * @throws RepositoryException if the revision doesn't exist.
+ */
+ Document getRevision(int i) throws RepositoryException;
+
+ /**
+ * @return The revision number of this document.
+ */
+ int getRevisionNumber();
+
+ History getHistory();
+
+}
diff --git a/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentBuildException.java b/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentBuildException.java
new file mode 100644
index 0000000..b9031b9
--- /dev/null
+++ b/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentBuildException.java
@@ -0,0 +1,67 @@
+/*
+ * 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 org.apache.lenya.cms.repository.RepositoryException;
+
+/**
+ * Document build exception.
+ *
+ */
+//florent : change exceptions extension in order to repect dependencies
+//public class DocumentBuildException extends PublicationException {
+public class DocumentBuildException extends RepositoryException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Constructor.
+ */
+ public DocumentBuildException() {
+ super();
+ }
+
+ /**
+ * Constructor.
+ * @param message A message.
+ */
+ public DocumentBuildException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructor.
+ * @param cause The cause of the exception.
+ */
+ public DocumentBuildException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Constructor.
+ * @param message A message.
+ * @param cause The cause of the exception.
+ */
+ public DocumentBuildException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentDoesNotExistException.java b/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentDoesNotExistException.java
new file mode 100644
index 0000000..7f4f15c
--- /dev/null
+++ b/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentDoesNotExistException.java
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ *
+ */
+
+/* $Id$ */
+
+package org.apache.lenya.cms.publication;
+
+/**
+ * Document does not exist exception
+ */
+public class DocumentDoesNotExistException extends DocumentException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Creates a new DocumentDoesNotExistException
+ *
+ */
+ public DocumentDoesNotExistException() {
+ super();
+ }
+
+ /**
+ * Creates a new DocumentDoesNotExistException
+ * @param message the exception message
+ */
+ public DocumentDoesNotExistException(String message) {
+ super(message);
+ }
+
+ /**
+ * Creates a new DocumentDoesNotExistException
+ * @param message the exception message
+ * @param cause the cause of the exception
+ */
+ public DocumentDoesNotExistException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Creates a new DocumentDoesNotExistException
+ * @param cause the cause of the exception
+ */
+ public DocumentDoesNotExistException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentException.java b/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentException.java
new file mode 100644
index 0000000..3396739
--- /dev/null
+++ b/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentException.java
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ *
+ */
+
+/* $Id$ */
+
+package org.apache.lenya.cms.publication;
+
+import org.apache.lenya.cms.repository.RepositoryException;
+
+/**
+ * Document exception
+ */
+//florent : change exceptions extension in order to repect dependencies
+//public class DocumentException extends PublicationException {
+public class DocumentException extends RepositoryException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Creates a new DocumentException
+ *
+ */
+ public DocumentException() {
+ super();
+ }
+
+ /**
+ * Creates a new DocumentException
+ *
+ * @param message the exception message
+ */
+ public DocumentException(String message) {
+ super(message);
+ }
+
+ /**
+ * Creates a new DocumentException
+ *
+ * @param message the exception message
+ * @param cause the cause of the exception
+ */
+ public DocumentException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Creates a new DocumentException
+ *
+ * @param cause the cause of the exception
+ */
+ public DocumentException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentIdToPathMapper.java b/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentIdToPathMapper.java
new file mode 100644
index 0000000..43fee73
--- /dev/null
+++ b/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentIdToPathMapper.java
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ *
+ */
+
+/* $Id$ */
+
+package org.apache.lenya.cms.publication;
+
+/**
+ * Document Id to Path mapper interface
+ */
+public interface DocumentIdToPathMapper {
+
+ /**
+ * Compute the document-path for a given publication, area and document-uuid. The file separator
+ * is the slash (/).
+ *
+ * @param uuid the UUID of the document
+ * @param language the language of the document
+ *
+ * @return the path to the document, without publication ID and area
+ */
+ String getPath(String uuid, String language);
+
+}
diff --git a/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentIdentifier.java b/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentIdentifier.java
new file mode 100644
index 0000000..a0eaf3d
--- /dev/null
+++ b/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentIdentifier.java
@@ -0,0 +1,31 @@
+package org.apache.lenya.cms.publication;
+
+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
diff --git a/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentLocator.java b/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentLocator.java
new file mode 100644
index 0000000..7ba8914
--- /dev/null
+++ b/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/DocumentLocator.java
@@ -0,0 +1,83 @@
+package org.apache.lenya.cms.publication;
+
+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);
+
+}
\ No newline at end of file
diff --git a/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/ResourceType.java b/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/ResourceType.java
new file mode 100644
index 0000000..3fd79a6
--- /dev/null
+++ b/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/ResourceType.java
@@ -0,0 +1,147 @@
+/*
+ * 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.
+ *
+ */
+/*
+ * 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.Date;
+
+import org.apache.commons.lang.Validate;
+import org.apache.lenya.xml.Schema;
+
+/**
+ * @version $Id:$
+ */
+public interface ResourceType {
+
+ /**
+ * The Avalon service role.
+ */
+ String ROLE = ResourceType.class.getName();
+
+ /**
+ * Prefix for translating the resource type name, e.g.
+ * <i18n:text>resourceType-<jx:out
+ * value="${resourceType.getName()}"/></i18n:text>
+ */
+ String I18N_PREFIX = "resourceType-";
+
+ /**
+ * Returns the date at which point the requested resource is considered
+ * expired
+ * @return a string in RFC 1123 date format
+ */
+ Date getExpires();
+
+ /**
+ * Returns the name of this document type.
+ * @return A string value.
+ */
+ String getName();
+
+ /**
+ * @return The source URI of the RelaxNG schema.
+ */
+ Schema getSchema();
+
+ /**
+ * Returns an array of XPaths representing attributes to be rewritten when a
+ * document URL has changed.
+ * @return An array of strings.
+ */
+ String[] getLinkAttributeXPaths();
+
+ /**
+ * @return The names of all available samples. The first one is the default sample.
+ */
+ String[] getSampleNames();
+
+ /**
+ * @param name The name.
+ * @return The sample with the specified name.
+ */
+ Sample getSample(String name);
+
+ /**
+ * @return All supported formats.
+ */
+ String[] getFormats();
+
+ /**
+ * @param format The format.
+ * @return The URI to get the formatted content at.
+ */
+ String getFormatURI(String format);
+
+ /**
+ * A resource type sample.
+ */
+ public static class Sample {
+
+ protected Sample(String name, String mimeType, String uri) {
+ Validate.notNull(name);
+ Validate.notNull(mimeType);
+ Validate.notNull(uri);
+ this.name = name;
+ this.mimeType = mimeType;
+ this.uri = uri;
+ }
+
+ private String name;
+ private String mimeType;
+ private String uri;
+
+ /**
+ * @return The name of the sample.
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * @return The MIME type of the sample.
+ */
+ public String getMimeType() {
+ return this.mimeType;
+ }
+
+ /**
+ * @return The URI of the sample source.
+ */
+ public String getUri() {
+ return this.uri;
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/util/DocumentVisitor.java b/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/util/DocumentVisitor.java
new file mode 100644
index 0000000..909f8fa
--- /dev/null
+++ b/org.apache.lenya.core.document.api/src/main/java/org/apache/lenya/cms/publication/util/DocumentVisitor.java
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ *
+ */
+
+/* $Id$ */
+
+package org.apache.lenya.cms.publication.util;
+
+import org.apache.lenya.cms.publication.Document;
+
+/**
+ * Visitor for resources.
+ *
+ */
+public interface DocumentVisitor {
+
+ /**
+ * Visits a resource.
+ * @param document The resource.
+ * @throws Exception if an error occurs.
+ */
+ void visitDocument(Document document) throws Exception;
+
+}