Author: andreas
Date: Fri Aug 24 03:47:38 2007
New Revision: 569341
URL: http://svn.apache.org/viewvc?rev=569341&view=rev
Log:
Add revision number to Document interface, added revision handling to LenyaMetaDataTransformer and DocumentInfoModule. This fixes bug 42932.
Modified:
lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/AreaImpl.java
lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java
lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/DocumentInfoModule.java
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/generation/LenyaMetaDataGenerator.java
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/RepositorySource.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentFactory.java
lenya/trunk/src/java/org/apache/lenya/cms/workflow/DocumentWorkflowable.java
lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/linking/LinkResolverImpl.java
lenya/trunk/src/modules/resource/sitemap.xmap
lenya/trunk/src/modules/resource/xslt/common/mimetype.xsl
lenya/trunk/src/modules/resource/xslt/resource2xhtml.xsl
lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeMetaDataHandler.java
lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceWrapper.java
lenya/trunk/src/pubs/default/sitemap.xmap
Modified: lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/AreaImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/AreaImpl.java?rev=569341&r1=569340&r2=569341&view=diff
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/AreaImpl.java (original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/AreaImpl.java Fri Aug 24 03:47:38 2007
@@ -56,15 +56,21 @@
}
public boolean contains(String uuid, String language) {
- String sourceUri = DocumentImpl.getSourceURI(pub, name, uuid, language);
- try {
- Node node = (Node) getPublication().getSession().getRepositoryItem(getNodeFactory(), sourceUri);
- return node.exists();
- } catch (RepositoryException e) {
- throw new RuntimeException(e);
+ // check site structure first (performance)
+ if (getSite().containsByUuid(uuid, language)) {
+ return true;
+ } else {
+ String sourceUri = DocumentImpl.getSourceURI(pub, name, uuid, language);
+ try {
+ Node node = (Node) getPublication().getSession().getRepositoryItem(
+ getNodeFactory(), sourceUri);
+ return node.exists();
+ } catch (RepositoryException e) {
+ throw new RuntimeException(e);
+ }
}
}
-
+
protected NodeFactory getNodeFactory() {
if (this.nodeFactory == null) {
try {
@@ -75,7 +81,6 @@
}
return this.nodeFactory;
}
-
public Document getDocument(String uuid, String language) throws PublicationException {
return this.factory.get(getPublication(), getName(), uuid, language);
Modified: lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java?rev=569341&r1=569340&r2=569341&view=diff
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java (original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java Fri Aug 24 03:47:38 2007
@@ -70,14 +70,18 @@
*/
public Document get(Publication publication, String area, String uuid, String language)
throws DocumentBuildException {
+ return get(publication, area, uuid, language, -1);
+ }
+ public Document get(Publication publication, String area, String uuid, String language,
+ int revision) throws DocumentBuildException {
if (getLogger().isDebugEnabled())
getLogger().debug(
"DocumentIdentityMap::get() called on publication [" + publication.getId()
+ "], area [" + area + "], UUID [" + uuid + "], language [" + language
+ "]");
- String key = getKey(publication, area, uuid, language);
+ String key = getKey(publication, area, uuid, language, revision);
if (getLogger().isDebugEnabled())
getLogger().debug(
@@ -197,10 +201,11 @@
* @param area The area.
* @param uuid The document UUID.
* @param language The language.
+ * @param revision
* @return A key.
*/
- public String getKey(Publication publication, String area, String uuid, String language) {
- return publication.getId() + ":" + area + ":" + uuid + ":" + language;
+ public String getKey(Publication publication, String area, String uuid, String language, int revision) {
+ return publication.getId() + ":" + area + ":" + uuid + ":" + language + ":" + revision;
}
/**
@@ -217,7 +222,7 @@
Publication publication = getPublication(locator.getPublicationId());
String area = locator.getArea();
String uuid = publication.getArea(area).getSite().getNode(locator.getPath()).getUuid();
- return getKey(publication, area, uuid, locator.getLanguage());
+ return getKey(publication, area, uuid, locator.getLanguage(), -1);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -250,6 +255,8 @@
String area = tokenizer.nextToken();
String uuid = tokenizer.nextToken();
String language = tokenizer.nextToken();
+ String revisionString = tokenizer.nextToken();
+ int revision = Integer.valueOf(revisionString).intValue();
Document document;
try {
@@ -257,7 +264,7 @@
DocumentBuilder builder = publication.getDocumentBuilder();
DocumentIdentifier identifier = new DocumentIdentifier(publication, area, uuid,
language);
- document = buildDocument(this, identifier, builder);
+ document = buildDocument(this, identifier, revision, builder);
} catch (Exception e) {
throw new RepositoryException(e);
}
@@ -268,9 +275,9 @@
}
protected Document buildDocument(DocumentFactory map, DocumentIdentifier identifier,
- DocumentBuilder builder) throws DocumentBuildException {
+ int revision, DocumentBuilder builder) throws DocumentBuildException {
- DocumentImpl document = createDocument(map, identifier, builder);
+ DocumentImpl document = createDocument(map, identifier, revision, builder);
ContainerUtil.enableLogging(document, getLogger());
return document;
}
@@ -280,13 +287,14 @@
* e.g., for different document IDs.
* @param map The identity map.
* @param identifier The identifier.
+ * @param revision The revision or -1 for the latest revision.
* @param builder The document builder.
* @return A document.
* @throws DocumentBuildException when something went wrong.
*/
protected DocumentImpl createDocument(DocumentFactory map, DocumentIdentifier identifier,
- DocumentBuilder builder) throws DocumentBuildException {
- return new DocumentImpl(this.manager, map, identifier, getLogger());
+ int revision, DocumentBuilder builder) throws DocumentBuildException {
+ return new DocumentImpl(this.manager, map, identifier, revision, getLogger());
}
public Document get(DocumentIdentifier identifier) throws DocumentBuildException {
Modified: lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java?rev=569341&r1=569340&r2=569341&view=diff
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java (original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java Fri Aug 24 03:47:38 2007
@@ -34,6 +34,7 @@
import org.apache.lenya.cms.metadata.MetaData;
import org.apache.lenya.cms.metadata.MetaDataException;
import org.apache.lenya.cms.publication.util.DocumentVisitor;
+import org.apache.lenya.cms.repository.ContentHolder;
import org.apache.lenya.cms.repository.Node;
import org.apache.lenya.cms.repository.NodeFactory;
import org.apache.lenya.cms.repository.RepositoryException;
@@ -52,6 +53,7 @@
private DocumentIdentifier identifier;
private DocumentFactory factory;
protected ServiceManager manager;
+ private int revision = -1;
/**
* The meta data namespace.
@@ -93,10 +95,11 @@
* @param manager The service manager.
* @param map The identity map the document belongs to.
* @param identifier The identifier.
+ * @param revision The revision number or -1 if the latest revision should be used.
* @param _logger a logger
*/
protected DocumentImpl(ServiceManager manager, DocumentFactory map,
- DocumentIdentifier identifier, Logger _logger) {
+ DocumentIdentifier identifier, int revision, Logger _logger) {
ContainerUtil.enableLogging(this, _logger);
if (getLogger().isDebugEnabled()) {
@@ -112,6 +115,7 @@
}
this.factory = map;
+ this.revision = revision;
if (getLogger().isDebugEnabled()) {
getLogger().debug(
@@ -274,6 +278,7 @@
* @param _extension A string.
*/
protected void setExtension(String _extension) {
+ checkWritability();
assert _extension != null;
Assert.isTrue("Extension doesn't start with a dot", !_extension.startsWith("."));
this.extension = _extension;
@@ -434,11 +439,11 @@
}
public MetaData getMetaData(String namespaceUri) throws MetaDataException {
- return getRepositoryNode().getMetaData(namespaceUri);
+ return getContentHolder().getMetaData(namespaceUri);
}
public String[] getMetaDataNamespaceUris() throws MetaDataException {
- return getRepositoryNode().getMetaDataNamespaceUris();
+ return getContentHolder().getMetaDataNamespaceUris();
}
public String getMimeType() throws DocumentException {
@@ -455,13 +460,14 @@
public long getContentLength() throws DocumentException {
try {
- return getRepositoryNode().getContentLength();
+ return getContentHolder().getContentLength();
} catch (RepositoryException e) {
throw new DocumentException(e);
}
}
public void setMimeType(String mimeType) throws DocumentException {
+ checkWritability();
try {
getMetaData(METADATA_NAMESPACE).setValue(METADATA_MIME_TYPE, mimeType);
} catch (MetaDataException e) {
@@ -527,6 +533,20 @@
}
return this.repositoryNode;
}
+
+ protected ContentHolder getContentHolder() {
+ Node node = getRepositoryNode();
+ if (this.revision == -1) {
+ return node;
+ }
+ else {
+ try {
+ return node.getHistory().getRevision(revision);
+ } catch (RepositoryException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
protected static Node getRepositoryNode(ServiceManager manager, DocumentFactory docFactory,
String sourceUri) {
@@ -591,16 +611,16 @@
return area().getSite().containsByUuid(getUUID(), getLanguage());
}
- private Area area;
-
public Area area() {
- if (this.area == null) {
- this.area = new AreaImpl(this.manager, getFactory(), getPublication(), getArea());
+ try {
+ return getPublication().getArea(getArea());
+ } catch (PublicationException e) {
+ throw new RuntimeException(e);
}
- return this.area;
}
public void setResourceType(ResourceType resourceType) {
+ checkWritability();
Assert.notNull("resource type", resourceType);
try {
MetaData meta = getMetaData(DocumentImpl.METADATA_NAMESPACE);
@@ -611,6 +631,7 @@
}
public void setSourceExtension(String extension) {
+ checkWritability();
Assert.notNull("extension", extension);
Assert.isTrue("extension doesn't start with a dot", !extension.startsWith("."));
try {
@@ -622,6 +643,7 @@
}
public OutputStream getOutputStream() {
+ checkWritability();
try {
return getRepositoryNode().getOutputStream();
} catch (RepositoryException e) {
@@ -629,6 +651,12 @@
}
}
+ protected void checkWritability() {
+ if (this.revision == -1) {
+ throw new UnsupportedOperationException();
+ }
+ }
+
public InputStream getInputStream() {
try {
return getRepositoryNode().getInputStream();
@@ -639,6 +667,15 @@
public Session getSession() {
return getFactory().getSession();
+ }
+
+ public int getRevisionNumber() {
+ if (this.revision == -1) {
+ return getRepositoryNode().getHistory().getLatestRevision().getNumber();
+ }
+ else {
+ return this.revision;
+ }
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/DocumentInfoModule.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/DocumentInfoModule.java?rev=569341&r1=569340&r2=569341&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/DocumentInfoModule.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/DocumentInfoModule.java Fri Aug 24 03:47:38 2007
@@ -70,6 +70,7 @@
protected final static String PARAM_UUID = "uuid";
protected final static String PARAM_DOCUMENT_LANGUAGE = "document-language";
protected final static String PARAM_PROPERTY = "property";
+ protected final static String PARAM_REVISION = "revision";
protected final static int MIN_MANDATORY_PARAMS = 5;
protected final static String UUID = "uuid";
@@ -87,7 +88,7 @@
protected final static String VISIBLE_IN_NAVIGATION = "visibleInNav";
protected final static String[] PARAMS = { PARAM_PUBLICATION_ID, PARAM_AREA, PARAM_UUID,
- PARAM_DOCUMENT_LANGUAGE, PARAM_PROPERTY };
+ PARAM_DOCUMENT_LANGUAGE, PARAM_PROPERTY, PARAM_REVISION };
protected final static String META_RESOURCE_TYPE = "resourceType";
protected final static String META_EXPIRES = "expires";
@@ -100,12 +101,13 @@
* @param area The area.
* @param uuid The document UUID.
* @param language The document language.
+ * @param revision The revision.
* @param objectModel The object model.
* @return The document object created.
* @throws ConfigurationException
*/
protected Document getDocument(String publicationId, String area, String uuid, String language,
- Map objectModel) throws ConfigurationException {
+ int revision, Map objectModel) throws ConfigurationException {
Document document = null;
Request request = ObjectModelHelper.getRequest(objectModel);
@@ -114,7 +116,7 @@
Session session = RepositoryUtil.getSession(this.manager, request);
DocumentFactory docFactory = DocumentUtil.createDocumentFactory(this.manager, session);
Publication pub = docFactory.getPublication(publicationId);
- document = pub.getArea(area).getDocument(uuid, language);
+ document = docFactory.get(pub, area, uuid, language, revision);
} catch (Exception e) {
throw new ConfigurationException("Error getting document [" + publicationId + ":"
+ area + ":" + uuid + ":" + language + "]: " + e.getMessage(), e);
@@ -131,11 +133,20 @@
Object value = null;
InputModuleParameters params = new InputModuleParameters(name, PARAMS, MIN_MANDATORY_PARAMS);
-
+
try {
+ int rev = -1;
+ if (params.isParameter(PARAM_REVISION)) {
+ String revision = params.getParameter(PARAM_REVISION);
+ if (!revision.equals("")) {
+ rev = Integer.valueOf(revision).intValue();
+ }
+ }
+
Document document = getDocument(params.getParameter(PARAM_PUBLICATION_ID), params
.getParameter(PARAM_AREA), params.getParameter(PARAM_UUID), params
- .getParameter(PARAM_DOCUMENT_LANGUAGE), objectModel);
+ .getParameter(PARAM_DOCUMENT_LANGUAGE), rev, objectModel);
+
String attribute = params.getParameter(PARAM_PROPERTY);
if (attribute.equals(RESOURCE_TYPE)) {
Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/generation/LenyaMetaDataGenerator.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/generation/LenyaMetaDataGenerator.java?rev=569341&r1=569340&r2=569341&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/generation/LenyaMetaDataGenerator.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/generation/LenyaMetaDataGenerator.java Fri Aug 24 03:47:38 2007
@@ -25,55 +25,46 @@
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.caching.CacheableProcessingComponent;
-import org.apache.cocoon.environment.ObjectModelHelper;
-import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.generation.ServiceableGenerator;
import org.apache.excalibur.source.SourceValidity;
import org.apache.excalibur.source.impl.validity.TimeStampValidity;
import org.apache.excalibur.xml.dom.DOMParser;
+import org.apache.lenya.cms.cocoon.source.RepositorySource;
import org.apache.lenya.cms.metadata.MetaData;
import org.apache.lenya.cms.metadata.MetaDataException;
-import org.apache.lenya.cms.publication.Document;
-import org.apache.lenya.cms.publication.DocumentBuildException;
-import org.apache.lenya.cms.publication.DocumentFactory;
-import org.apache.lenya.cms.publication.DocumentUtil;
-import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.repository.ContentHolder;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
/**
- * <p>Generates the meta data of a document.</p>
- * <p>Parameters to specify the document:</p>
- * <ul>
- * <li><strong>pubid</strong> - mandatory</li>
- * <li><strong>area</strong> - mandatory</li>
- * <li><strong>uuid</strong> - mandatory</li>
- * <li><strong>lang</strong> - mandatory</li>
- * </ul>
- * <p>Example output:</p>
+ * <p>
+ * Generates the meta data of a document. The <code>src</code> attribute must be
+ * a {@link RepositorySource} URI (e.g., <code>lenya-document:...</code>).
+ * </p>
+ * <p>
+ * Example output:
+ * </p>
+ *
* <pre>
-<lenya:metadata xmlns:lenya="http://apache.org/cocoon/lenya/metadata/1.0">
- <elements xmlns="http://purl.org/dc/elements/1.1/">
- <title>Search</title>
- <date>2006-06-12 13:43:14</date>
- <language>en</language>
- <creator>lenya</creator>
- </elements>
- <elements xmlns="http://apache.org/lenya/metadata/document/1.0">
- <extension>xml</extension>
- <resourceType>usecase</resourceType>
- <contentType>xml</contentType>
- </elements>
-</lenya:metadata>
-</pre>
+ * <lenya:metadata xmlns:lenya="http://apache.org/cocoon/lenya/metadata/1.0">
+ * <elements xmlns="http://purl.org/dc/elements/1.1/">
+ * <title>Search</title>
+ * <date>2006-06-12 13:43:14</date>
+ * <language>en</language>
+ * <creator>lenya</creator>
+ * </elements>
+ * <elements xmlns="http://apache.org/lenya/metadata/document/1.0">
+ * <extension>xml</extension>
+ * <resourceType>usecase</resourceType>
+ * <contentType>xml</contentType>
+ * </elements>
+ * </lenya:metadata>
+ * </pre>
*/
public class LenyaMetaDataGenerator extends ServiceableGenerator implements
CacheableProcessingComponent {
- /** The corresponding lenya document */
- protected Document document;
-
/** Node and attribute names */
protected AttributesImpl attributes;
@@ -86,50 +77,24 @@
/** The namespace prefix for this namespace */
protected static final String PREFIX_META = "lenya";
- /** Custom metadata */
- protected static final String ROOT_CUSTOM_META_NODE_NAME = "custom";
-
- /** Internal metadata */
- protected static final String ROOT_INTERNAL_META_NODE_NAME = "internal";
-
- /** Dublin Core metadata */
- protected static final String ROOT_DC_META_NODE_NAME = "dc";
-
- /** Namespace prefix for the dublin core */
- protected static final String PREFIX_META_DC = "dc";
-
- /** The URI of the namespace of the dublin core metadata */
- protected static final String URI_META_DC = "http://purl.org/dc/elements/1.1/";
-
/** The parser for the XML snippets to be included. */
protected DOMParser parser = null;
-
- /** The document that should be parsed and (partly) included. */
- protected org.w3c.dom.Document doc = null;
-
- /** Helper for lenya document retrival */
- protected String publicationId = null;
-
- protected String area = null;
-
- protected String language = null;
-
- protected String uuid = null;
+
+ private String src;
+
+ /** The repository content holder to generate the meta data for */
+ private ContentHolder content;
/**
* Recycle this component. All instance variables are set to <code>null</code>.
*/
public void recycle() {
- this.document = null;
- this.uuid = null;
- this.language = null;
- this.area = null;
- this.publicationId = null;
- this.doc = null;
+ this.content = null;
+ this.src = null;
this.parser = null;
super.recycle();
}
-
+
/**
* Serviceable
*
@@ -148,50 +113,22 @@
*/
public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
throws ProcessingException, SAXException, IOException {
-
+
super.setup(resolver, objectModel, src, par);
-
- this.publicationId = par.getParameter("pubid", null);
- if (this.publicationId == null) {
- throw new ProcessingException("The pubid is not set! Please set like e.g. <map:parameter name='pubid' value='{request-param:pubid}'/>");
- }
-
- this.area = par.getParameter("area", null);
- if (this.area == null) {
- throw new ProcessingException("The area is not set! Please set like e.g. <map:parameter name='area' value='{request-param:area}'/>");
- }
-
- uuid = par.getParameter("uuid", null);
- if (this.uuid == null) {
- throw new ProcessingException("The uuid is not set! Please set like e.g. <map:parameter name='uuid' value='{request-param:uuid}'/>");
- }
-
- language = par.getParameter("lang", null);
- if (language == null)
- throw new ProcessingException("The 'lang' parameter is not set.");
-
- try {
- prepareLenyaDoc(objectModel);
- } catch (DocumentBuildException e) {
- throw new ProcessingException(src + " threw DocumentBuildException: " + e);
- }
-
- }
-
- protected void prepareLenyaDoc(Map objectModel) throws DocumentBuildException,
- ProcessingException {
-
- Request request = ObjectModelHelper.getRequest(objectModel);
- Publication pub;
+ this.src = src;
+
+ RepositorySource source = null;
try {
- DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);
- pub = factory.getPublication(this.publicationId);
- this.document = pub.getArea(area).getDocument(uuid, language);
+ source = (RepositorySource) resolver.resolveURI(src);
+ this.content = source.getContent();
} catch (Exception e) {
- throw new ProcessingException("Error geting publication id / area from page envelope",
- e);
+ throw new RuntimeException(e);
+ }
+ finally {
+ if (source != null) {
+ resolver.release(source);
+ }
}
-
}
/**
@@ -200,7 +137,7 @@
* @return The generated key hashes the src
*/
public Serializable getKey() {
- return language + "$$" + uuid;
+ return this.src;
}
/**
@@ -212,7 +149,7 @@
public SourceValidity getValidity() {
long lastModified;
try {
- lastModified = document.getLastModified();
+ lastModified = this.content.getLastModified();
} catch (Exception e) {
getLogger().error("Error determining last modification date", e);
return null;
@@ -230,9 +167,9 @@
}
private void performIncludesMeta() throws SAXException, ProcessingException {
-
+
try {
- String[] namespaces = this.document.getMetaDataNamespaceUris();
+ String[] namespaces = this.content.getMetaDataNamespaceUris();
for (int i = 0; i < namespaces.length; i++) {
this.contentHandler.startPrefixMapping("", namespaces[i]);
startNodeMeta(namespaces[i]);
@@ -243,7 +180,7 @@
} catch (MetaDataException e) {
throw new ProcessingException(e);
}
-
+
}
private void parseMetaData(String namespace) throws ProcessingException, SAXException {
@@ -257,7 +194,8 @@
throw new ProcessingException(e);
}
for (int j = 0; j < values.length; j++) {
- this.contentHandler.startElement(namespace, names[i], names[i], new AttributesImpl());
+ this.contentHandler.startElement(namespace, names[i], names[i],
+ new AttributesImpl());
char[] valueChars = values[j].toCharArray();
this.contentHandler.characters(valueChars, 0, valueChars.length);
this.contentHandler.endElement(namespace, names[i], names[i]);
@@ -274,17 +212,12 @@
private void startNodeRoot() throws SAXException {
this.contentHandler.startDocument();
this.contentHandler.startPrefixMapping(PREFIX_META, URI_META);
- this.contentHandler.startElement(URI_META,
- "metadata",
- PREFIX_META + ":metadata",
+ this.contentHandler.startElement(URI_META, "metadata", PREFIX_META + ":metadata",
attributes);
}
private void startNodeMeta(String namespace) throws SAXException {
- this.contentHandler.startElement(namespace,
- "elements",
- "elements",
- attributes);
+ this.contentHandler.startElement(namespace, "elements", "elements", attributes);
}
private void endNodeMeta(String namespace) throws SAXException {
@@ -292,13 +225,11 @@
}
protected MetaData getMetaData(String namespaceUri) throws ProcessingException {
- MetaData metaData = null;
try {
- metaData = this.document.getMetaData(namespaceUri);
+ return this.content.getMetaData(namespaceUri);
} catch (Exception e1) {
- throw new ProcessingException("Obtaining custom meta data value for ["
- + document + "] failed: ", e1);
+ throw new ProcessingException("Obtaining meta data value for [" + this.content
+ + "] failed: ", e1);
}
- return metaData;
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/RepositorySource.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/RepositorySource.java?rev=569341&r1=569340&r2=569341&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/RepositorySource.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/RepositorySource.java Fri Aug 24 03:47:38 2007
@@ -282,7 +282,10 @@
}
- protected ContentHolder getContent() {
+ /**
+ * @return The content of this source.
+ */
+ public ContentHolder getContent() {
return this.content;
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java?rev=569341&r1=569340&r2=569341&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java Fri Aug 24 03:47:38 2007
@@ -319,4 +319,8 @@
*/
InputStream getInputStream();
+ /**
+ * @return The revision number of this document.
+ */
+ int getRevisionNumber();
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentFactory.java?rev=569341&r1=569340&r2=569341&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentFactory.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentFactory.java Fri Aug 24 03:47:38 2007
@@ -48,6 +48,19 @@
throws DocumentBuildException;
/**
+ * Returns a revision of a document.
+ * @param publication The publication.
+ * @param area The area.
+ * @param uuid The document ID.
+ * @param language The language.
+ * @param revision The revision..
+ * @return A document.
+ * @throws DocumentBuildException if the document does not exist.
+ */
+ Document get(Publication publication, String area, String uuid, String language, int revision)
+ throws DocumentBuildException;
+
+ /**
* Returns the document identified by a certain web application URL.
* @param webappUrl The web application URL.
* @return A document.
Modified: lenya/trunk/src/java/org/apache/lenya/cms/workflow/DocumentWorkflowable.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/workflow/DocumentWorkflowable.java?rev=569341&r1=569340&r2=569341&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/workflow/DocumentWorkflowable.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/workflow/DocumentWorkflowable.java Fri Aug 24 03:47:38 2007
@@ -32,6 +32,7 @@
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.lenya.ac.Identity;
+import org.apache.lenya.ac.User;
import org.apache.lenya.cms.metadata.MetaData;
import org.apache.lenya.cms.observation.RepositoryEvent;
import org.apache.lenya.cms.observation.RepositoryEventFactory;
@@ -203,7 +204,10 @@
string += " state:" + version.getState();
Identity identity = getSession().getIdentity();
- string += " user:" + identity.getUser().getId();
+ User user = identity.getUser();
+ if (user != null) {
+ string += " user:" + identity.getUser().getId();
+ }
string += " machine:" + identity.getMachine().getIp();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
Modified: lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/linking/LinkResolverImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/linking/LinkResolverImpl.java?rev=569341&r1=569340&r2=569341&view=diff
==============================================================================
--- lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/linking/LinkResolverImpl.java (original)
+++ lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/linking/LinkResolverImpl.java Fri Aug 24 03:47:38 2007
@@ -126,7 +126,7 @@
doc = null;
} else if (this.fallbackMode == MODE_DEFAULT_LANGUAGE) {
if (areaObj.contains(uuid, pub.getDefaultLanguage())) {
- doc = areaObj.getDocument(uuid, pub.getDefaultLanguage());
+ doc = factory.get(pub, area, uuid, pub.getDefaultLanguage(), revision);
} else {
doc = null;
}
Modified: lenya/trunk/src/modules/resource/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/sitemap.xmap?rev=569341&r1=569340&r2=569341&view=diff
==============================================================================
--- lenya/trunk/src/modules/resource/sitemap.xmap (original)
+++ lenya/trunk/src/modules/resource/sitemap.xmap Fri Aug 24 03:47:38 2007
@@ -33,19 +33,16 @@
<map:pipelines>
<!-- Generates the lenya metadata to be aggregated for each page -->
<map:pipeline>
- <map:match pattern="lenyametadata.xml/*/*/*/*">
- <map:generate type="lenyaMetaData">
- <map:parameter name="pubid" value="{1}"/>
- <map:parameter name="area" value="{2}"/>
- <map:parameter name="uuid" value="{3}"/>
- <map:parameter name="lang" value="{4}"/>
- </map:generate>
+ <map:match pattern="lenyametadata.xml/*/*/*/*/*">
+ <map:generate type="lenyaMetaData" src="lenya-document:{3},pub={1},area={2},lang={4},rev={5}"/>
<map:serialize type="xml"/>
</map:match>
</map:pipeline>
+
<map:pipeline>
<!-- View Revision? -->
+ <!--
<map:match pattern="*.xml">
<map:match type="step" pattern="view-revision">
<map:generate type="serverpages"
@@ -67,6 +64,7 @@
<map:serialize type="xml"/>
</map:match>
</map:match>
+ -->
<!-- pattern="{format}.xml" -->
<map:match pattern="*.xml">
@@ -76,10 +74,10 @@
<!-- {format}.xml/{pubId}/{area}/{uuid}/{language} -->
<map:match pattern="downloadLink.xml/*/*/*/*">
- <map:generate src="cocoon:/lenyametadata.xml/{1}/{2}/{3}/{4}"/>
+ <map:generate src="cocoon:/lenyametadata.xml/{1}/{2}/{3}/{4}/"/>
<map:transform src="fallback://lenya/modules/resource/xslt/downloadLink.xsl">
- <map:parameter name="contentLength" value="{doc-info:{1}:{2}:{3}:{4}:contentLength}"/>
- <map:parameter name="mimeType" value="{doc-info:{1}:{2}:{3}:{4}:mimeType}"/>
+ <map:parameter name="contentLength" value="{doc-info:{1}:{2}:{3}:{4}}"/>
+ <map:parameter name="mimeType" value="{doc-info:{1}:{2}:{3}:{4}}"/>
<map:parameter name="uuid" value="{3}"/>
<map:parameter name="language" value="{4}"/>
<map:parameter name="imageprefix" value="{proxy:/{1}/modules/resource}"/>
@@ -90,19 +88,20 @@
<!-- {format}.xml/{pubId}/{area}/{uuid}/{language} -->
<!-- FIXME: page envelope calls have to be removed -->
<map:match pattern="xhtml.xml/*/*/*/*">
- <map:generate src="cocoon:/lenyametadata.xml/{1}/{2}/{3}/{4}"/>
+ <map:generate src="cocoon:/lenyametadata.xml/{1}/{2}/{3}/{4}/{request-param:lenya.revision}"/>
<map:transform src="fallback://lenya/modules/resource/xslt/resource2xhtml.xsl">
- <map:parameter name="document-type" value="{doc-info:{1}:{2}:{3}:{4}:resourceType}"/>
+ <map:parameter name="document-type" value="{doc-info:{1}:{2}:{3}:{4}:resourceType:{request-param:lenya.revision}}"/>
<map:parameter name="nodeId" value="{doc-info:{1}:{2}:{3}:{4}:nodeName}"/>
<map:parameter name="path" value="{doc-info:{1}:{2}:{3}:{4}:path}"/>
<map:parameter name="language" value="{4}"/>
<map:parameter name="root" value="{proxy:/{1}/{2}}"/>
- <map:parameter name="mimeType" value="{doc-info:{1}:{2}:{3}:{4}:mimeType}"/>
- <map:parameter name="contentLength" value="{doc-info:{1}:{2}:{3}:{4}:contentLength}"/>
+ <map:parameter name="mimeType" value="{doc-info:{1}:{2}:{3}:{4}:mimeType:{request-param:lenya.revision}}"/>
+ <map:parameter name="contentLength" value="{doc-info:{1}:{2}:{3}:{4}:contentLength:{request-param:lenya.revision}}"/>
<map:parameter name="documentUrl" value="{doc-info:{1}:{2}:{3}:{4}:documentUrl}"/>
- <map:parameter name="sourceExtension" value="{doc-info:{1}:{2}:{3}:{4}:sourceExtension}"/>
+ <map:parameter name="sourceExtension" value="{doc-info:{1}:{2}:{3}:{4}:sourceExtension:{request-param:lenya.revision}}"/>
<map:parameter name="pubid" value="{1}"/>
<map:parameter name="imageprefix" value="{proxy:/{1}/modules/resource}"/>
+ <map:parameter name="revision" value="{request-param:lenya.revision}"/>
</map:transform>
<map:transform type="i18n"/>
<map:serialize type="xml"/>
Modified: lenya/trunk/src/modules/resource/xslt/common/mimetype.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/xslt/common/mimetype.xsl?rev=569341&r1=569340&r2=569341&view=diff
==============================================================================
--- lenya/trunk/src/modules/resource/xslt/common/mimetype.xsl (original)
+++ lenya/trunk/src/modules/resource/xslt/common/mimetype.xsl Fri Aug 24 03:47:38 2007
@@ -165,10 +165,20 @@
<xsl:param name="width"/>
<xsl:param name="height"/>
- <xsl:variable name="previewWidth">400</xsl:variable>
+ <xsl:variable name="maxPreviewWidth">400</xsl:variable>
+ <xsl:variable name="previewWidth">
+ <xsl:choose>
+ <xsl:when test="$width > $maxPreviewWidth"><xsl:value-of select="$maxPreviewWidth"/></xsl:when>
+ <xsl:otherwise><xsl:value-of select="$width"/></xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
<xsl:variable name="svgSuffix">
- <xsl:text>?lenya.module=svg&height=</xsl:text>
+ <xsl:choose>
+ <xsl:when test="contains($mediaURI, '?')">&</xsl:when>
+ <xsl:otherwise>?</xsl:otherwise>
+ </xsl:choose>
+ <xsl:text>lenya.module=svg&height=</xsl:text>
<xsl:value-of select="$previewWidth * ($height div $width)"/>
<xsl:text>&width=</xsl:text>
<xsl:value-of select="$previewWidth"/>
Modified: lenya/trunk/src/modules/resource/xslt/resource2xhtml.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/xslt/resource2xhtml.xsl?rev=569341&r1=569340&r2=569341&view=diff
==============================================================================
--- lenya/trunk/src/modules/resource/xslt/resource2xhtml.xsl (original)
+++ lenya/trunk/src/modules/resource/xslt/resource2xhtml.xsl Fri Aug 24 03:47:38 2007
@@ -42,8 +42,15 @@
<xsl:param name="documentUrl"/>
<xsl:param name="sourceExtension"/>
<xsl:param name="imageprefix"/>
+ <xsl:param name="revision"/>
- <xsl:variable name="mediaUrl" select="concat(substring-before($documentUrl, '.html'), '.', $sourceExtension)"/>
+ <xsl:variable name="revisionSuffix">
+ <xsl:if test="$revision != ''">
+ <xsl:text>?lenya.revision=</xsl:text><xsl:value-of select="$revision"/>
+ </xsl:if>
+ </xsl:variable>
+
+ <xsl:variable name="mediaUrl" select="concat(substring-before($documentUrl, '.html'), '.', $sourceExtension, $revisionSuffix)"/>
<xsl:template match="/">
<xhtml:div id="body">
Modified: lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeMetaDataHandler.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeMetaDataHandler.java?rev=569341&r1=569340&r2=569341&view=diff
==============================================================================
--- lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeMetaDataHandler.java (original)
+++ lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeMetaDataHandler.java Fri Aug 24 03:47:38 2007
@@ -58,23 +58,24 @@
public MetaData getMetaData(String namespaceUri) throws MetaDataException {
- MetaDataRegistry registry = null;
- try {
- registry = (MetaDataRegistry) this.manager.lookup(MetaDataRegistry.ROLE);
- if (!registry.isRegistered(namespaceUri)) {
- throw new MetaDataException("The namespace [" + namespaceUri
- + "] is not registered!");
- }
- } catch (ServiceException e) {
- throw new MetaDataException(e);
- } finally {
- if (registry != null) {
- this.manager.release(registry);
- }
- }
-
MetaData meta = (MetaData) this.namespace2metadata.get(namespaceUri);
if (meta == null) {
+
+ MetaDataRegistry registry = null;
+ try {
+ registry = (MetaDataRegistry) this.manager.lookup(MetaDataRegistry.ROLE);
+ if (!registry.isRegistered(namespaceUri)) {
+ throw new MetaDataException("The namespace [" + namespaceUri
+ + "] is not registered!");
+ }
+ } catch (ServiceException e) {
+ throw new MetaDataException(e);
+ } finally {
+ if (registry != null) {
+ this.manager.release(registry);
+ }
+ }
+
synchronized (this) {
meta = new SourceNodeMetaData(namespaceUri, this, this.manager);
this.namespace2metadata.put(namespaceUri, meta);
Modified: lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceWrapper.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceWrapper.java?rev=569341&r1=569340&r2=569341&view=diff
==============================================================================
--- lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceWrapper.java (original)
+++ lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceWrapper.java Fri Aug 24 03:47:38 2007
@@ -102,7 +102,8 @@
try {
String pubBase = Node.LENYA_PROTOCOL + Publication.PUBLICATION_PREFIX_URI + "/";
String publicationsPath = sourceUri.substring(pubBase.length());
- publicationId = publicationsPath.split("/")[0];
+ int firstSlashIndex = publicationsPath.indexOf("/");
+ publicationId = publicationsPath.substring(0, firstSlashIndex);
DocumentFactory factory = DocumentUtil.createDocumentFactory(manager, session);
Publication pub = factory.getPublication(publicationId);
contentDir = pub.getContentDir();
@@ -129,22 +130,21 @@
uriSuffix = "/" + fileSuffix;
}
- try {
- if (!SourceUtil.exists(contentBaseUri, manager)) {
- logger.info("The content directory [" + contentBaseUri + "] does not exist. "
- + "It will be created as soon as documents are added.");
- }
- } catch (ServiceException e) {
- throw new RuntimeException(e);
- } catch (MalformedURLException e) {
- throw new RuntimeException(e);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
-
String realSourceUri = contentBaseUri + uriSuffix;
if (logger.isDebugEnabled()) {
+ try {
+ if (!SourceUtil.exists(contentBaseUri, manager)) {
+ logger.debug("The content directory [" + contentBaseUri + "] does not exist. "
+ + "It will be created as soon as documents are added.");
+ }
+ } catch (ServiceException e) {
+ throw new RuntimeException(e);
+ } catch (MalformedURLException e) {
+ throw new RuntimeException(e);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
logger.debug("Real Source URI: " + realSourceUri);
}
@@ -177,7 +177,8 @@
* @see org.apache.lenya.cms.repository.Node#getInputStream()
*/
public synchronized InputStream getInputStream() throws RepositoryException {
- if (!exists()) {
+ loadData();
+ if (this.data == null) {
throw new RuntimeException(this + " does not exist!");
}
return new ByteArrayInputStream(this.data);
@@ -189,12 +190,21 @@
* @see org.apache.lenya.cms.repository.Node#exists()
*/
public boolean exists() throws RepositoryException {
- loadData();
- return this.data != null;
+ if (this.deleted == true) {
+ return false;
+ } else if (this.data != null) {
+ return true;
+ } else {
+ try {
+ return SourceUtil.exists(getRealSourceUri(), this.manager);
+ } catch (Exception e) {
+ throw new RepositoryException(e);
+ }
+ }
}
-
+
private boolean deleted;
-
+
protected void delete() {
this.deleted = true;
}
@@ -252,12 +262,12 @@
}
}
}
-
+
/**
* Store the source URLs which are currently written.
*/
private static Map lockedUris = new WeakHashMap();
-
+
/**
* @throws RepositoryException if an error occurs.
* @see org.apache.lenya.transaction.Transactionable#saveTransactionable()
@@ -268,15 +278,15 @@
}
if (this.data != null) {
-
+
String realSourceUri = getRealSourceUri();
Object lock = lockedUris.get(realSourceUri);
if (lock == null) {
lock = this;
lockedUris.put(realSourceUri, lock);
}
-
- synchronized(lock) {
+
+ synchronized (lock) {
saveTransactionable(realSourceUri);
}
}
@@ -287,17 +297,17 @@
ModifiableSource source = null;
InputStream in = null;
OutputStream out = null;
-
+
try {
resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
source = (ModifiableSource) resolver.resolveURI(realSourceUri);
-
+
out = source.getOutputStream();
-
+
byte[] buf = new byte[4096];
in = new ByteArrayInputStream(this.data);
int read = in.read(buf);
-
+
while (read > 0) {
out.write(buf, 0, read);
read = in.read(buf);
@@ -305,7 +315,7 @@
} catch (Exception e) {
throw new RepositoryException(e);
} finally {
-
+
try {
if (in != null) {
in.close();
@@ -317,7 +327,7 @@
} catch (Throwable t) {
throw new RuntimeException("Could not close streams: ", t);
}
-
+
if (resolver != null) {
if (source != null) {
resolver.release(source);
@@ -374,7 +384,7 @@
}
return this.lastModified;
}
-
+
private String mimeType;
/**
Modified: lenya/trunk/src/pubs/default/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/sitemap.xmap?rev=569341&r1=569340&r2=569341&view=diff
==============================================================================
--- lenya/trunk/src/pubs/default/sitemap.xmap (original)
+++ lenya/trunk/src/pubs/default/sitemap.xmap Fri Aug 24 03:47:38 2007
@@ -350,12 +350,12 @@
<map:match pattern="*/**.*">
<!-- TODO: http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=112496255207733&w=2 -->
<map:match type="regexp" pattern="(.*\.)(pdf|PDF|Pdf)$">
- <map:read src="lenyadoc:/{page-envelope:document-language}/{page-envelope:document-uuid}" mime-type="application/pdf">
+ <map:read src="lenya-document:{page-envelope:document-uuid},lang={page-envelope:document-language}{link:rev}" mime-type="application/pdf">
<map:parameter name="byte-ranges" value="false"/>
</map:read>
</map:match>
<map:act type="language-exists">
- <map:read src="lenyadoc:/{page-envelope:document-language}/{page-envelope:document-uuid}"/>
+ <map:read src="lenya-document:{page-envelope:document-uuid},lang={page-envelope:document-language}{link:rev}"/>
</map:act>
<map:generate type="serverpages" src="fallback://lenya/content/exception/document-does-not-exist.xsp"/>
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.