You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2006/03/24 17:55:45 UTC
svn commit: r388579 - in /lenya/trunk/src/java/org/apache/lenya/cms:
publication/DefaultDocument.java publication/Document.java
publication/DocumentManagerImpl.java repository/SourceNode.java
Author: andreas
Date: Fri Mar 24 08:55:43 2006
New Revision: 388579
URL: http://svn.apache.org/viewcvs?rev=388579&view=rev
Log:
Allow different extensions for actual source and meta data source
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java
lenya/trunk/src/java/org/apache/lenya/cms/repository/SourceNode.java
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java?rev=388579&r1=388578&r2=388579&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java Fri Mar 24 08:55:43 2006
@@ -43,7 +43,6 @@
public class DefaultDocument extends AbstractLogEnabled implements Document {
private DocumentIdentifier identifier;
- private String sourceURI;
private DocumentIdentityMap identityMap;
protected ServiceManager manager;
private MetaDataManager metaDataManager;
@@ -221,7 +220,8 @@
uuid = siteManager.getUUID(this);
if (uuid == null) {
uuid = getCanonicalDocumentURL();
- getLogger().warn("No UUID found for document [" + this + "]. Use canonical document URL: " + uuid);
+ getLogger().warn("No UUID found for document [" + this
+ + "]. Use canonical document URL: " + uuid);
}
return uuid;
} catch (Exception e) {
@@ -252,7 +252,8 @@
throw new RuntimeException(e);
}
if (sourceExtension == null) {
- getLogger().warn("No source extension for document [" + this + "]. The extension \"" + defaultSourceExtension + "\" will be used as default!");
+ getLogger().warn("No source extension for document [" + this + "]. The extension \""
+ + defaultSourceExtension + "\" will be used as default!");
sourceExtension = defaultSourceExtension;
}
return sourceExtension;
@@ -315,8 +316,6 @@
* @see org.apache.lenya.cms.publication.Document#existsInAnyLanguage()
*/
public boolean existsInAnyLanguage() throws DocumentException {
- boolean exists = false;
-
String[] languages = getLanguages();
if (languages.length > 0) {
@@ -326,7 +325,8 @@
}
String[] allLanguages = getPublication().getLanguages();
if (languages.length == allLanguages.length)
- // TODO: This is not entirely true, because the publication could assume the languages EN and DE, but the document could exist for the languages DE and FR!
+ // TODO: This is not entirely true, because the publication could assume the
+ // languages EN and DE, but the document could exist for the languages DE and FR!
if (getLogger().isDebugEnabled()) {
getLogger().debug("Document (" + this
+ ") exists even in all languages of this publication");
@@ -457,32 +457,13 @@
}
/**
- * When source URI has not been set by whoever created the document, provides a default
- * mechanism for constructing the document's URI.
- * @return A URI.
+ * @see org.apache.lenya.cms.publication.Document#getSourceURI()
*/
- private String getDefaultSourceURI() {
+ public String getSourceURI() {
String path = getPublication().getPathMapper().getPath(getId(),
getLanguage(),
getSourceExtension());
return getPublication().getSourceURI() + "/content/" + getArea() + "/" + path;
-
- }
-
- /**
- * @see org.apache.lenya.cms.publication.Document#getSourceURI()
- */
- public String getSourceURI() {
- if (sourceURI == null)
- sourceURI = getDefaultSourceURI();
- return sourceURI;
- }
-
- /**
- * @see org.apache.lenya.cms.publication.Document#setSourceURI(String)
- */
- public void setSourceURI(String _uri) {
- sourceURI = _uri;
}
/**
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java?rev=388579&r1=388578&r2=388579&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 Mar 24 08:55:43 2006
@@ -174,12 +174,6 @@
String getSourceURI();
/**
- * Setter for the URI to resolve the document's source.
- * @param uri URI
- */
- void setSourceURI(String uri);
-
- /**
* Accepts a document visitor.
* @param visitor The visitor.
* @throws PublicationException if an error occurs.
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java?rev=388579&r1=388578&r2=388579&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java Fri Mar 24 08:55:43 2006
@@ -106,6 +106,19 @@
try {
+ // This locks the meta data node, using the default source URI with the extension ".xml".
+ // Note that the actual source URI with the correct extension is not yet determined,
+ // that's why the node has to be locked again later on.
+ Node node = document.getRepositoryNode();
+ node.lock();
+
+ // Write Lenya-internal meta-data
+ Map lenyaMetaData = new HashMap();
+ lenyaMetaData.put(LenyaMetaData.ELEMENT_RESOURCE_TYPE, documentType.getName());
+ lenyaMetaData.put(LenyaMetaData.ELEMENT_CONTENT_TYPE, "xml");
+ lenyaMetaData.put(LenyaMetaData.ELEMENT_EXTENSION, extension);
+ document.getMetaDataManager().setLenyaMetaData(lenyaMetaData);
+
if (getLogger().isDebugEnabled()) {
getLogger().debug("Create");
getLogger().debug(" document: [" + document + "]");
@@ -113,25 +126,15 @@
getLogger().debug(" contents URI: [" + initialContentsURI + "]");
}
+ // Now that the correcet source is determined, lock the document node again.
+ document.getRepositoryNode().lock();
+
// look up creator for documents of this type
NodeCreatorInterface creator = documentType.getCreator();
-
- // now that the source is determined, lock involved nodes
- Node node = document.getRepositoryNode();
- node.lock();
-
- //
creator.create(initialContentsURI, document, parameters);
} catch (Exception e) {
throw new DocumentBuildException("call to creator for new document failed", e);
}
-
- // Write Lenya-internal meta-data
- Map lenyaMetaData = new HashMap(2);
- lenyaMetaData.put(LenyaMetaData.ELEMENT_RESOURCE_TYPE, documentType.getName());
- lenyaMetaData.put(LenyaMetaData.ELEMENT_CONTENT_TYPE, "xml");
- lenyaMetaData.put(LenyaMetaData.ELEMENT_EXTENSION, extension);
- document.getMetaDataManager().setLenyaMetaData(lenyaMetaData);
// Notify site manager about new document
addToSiteManager(document, navigationTitle, visibleInNav);
Modified: lenya/trunk/src/java/org/apache/lenya/cms/repository/SourceNode.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/repository/SourceNode.java?rev=388579&r1=388578&r2=388579&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/repository/SourceNode.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/repository/SourceNode.java Fri Mar 24 08:55:43 2006
@@ -639,8 +639,19 @@
return sourceURI;
}
+ /**
+ * @return The source URI of the meta data node.
+ * TODO: This is a hack and can be removed when UUIDs are used.
+ */
protected String getMetaSourceURI() {
- return getSourceURI() + "." + LENYA_META_SUFFIX;
+ String sourceUri = getSourceURI();
+ if (!sourceUri.endsWith(".xml")) {
+ int lastDotIndex = sourceUri.lastIndexOf(".");
+ if (lastDotIndex > -1) {
+ sourceUri = sourceUri.substring(0, lastDotIndex) + ".xml";
+ }
+ }
+ return sourceUri + "." + LENYA_META_SUFFIX;
}
private MetaDataManager metaDataManager;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org