You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by jo...@apache.org on 2006/10/03 10:04:26 UTC
svn commit: r452337 - in /lenya/trunk/src:
impl/java/org/apache/lenya/cms/publication/
java/org/apache/lenya/cms/metadata/
modules-optional/jcrsource/java/src/org/apache/lenya/cms/jcr/metadata/
modules/repository/java/src/org/apache/lenya/cms/repo/adap...
Author: josias
Date: Tue Oct 3 01:04:26 2006
New Revision: 452337
URL: http://svn.apache.org/viewvc?view=rev&rev=452337
Log:
fixed meta data moving/copying: when a document is moved from one area to another, the metadata has to be moved completely, including workflow etc. fixes bug #40627
Modified:
lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java
lenya/trunk/src/java/org/apache/lenya/cms/metadata/MetaData.java
lenya/trunk/src/modules-optional/jcrsource/java/src/org/apache/lenya/cms/jcr/metadata/JCRMetaData.java
lenya/trunk/src/modules/repository/java/src/org/apache/lenya/cms/repo/adapter/RepoMetaData.java
lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeMetaData.java
Modified: lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java?view=diff&rev=452337&r1=452336&r2=452337
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java (original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java Tue Oct 3 01:04:26 2006
@@ -82,6 +82,12 @@
return document;
}
+ /**
+ * Copies meta data from one document to another.
+ * @param source
+ * @param destination
+ * @throws PublicationException
+ */
protected void copyMetaData(Document source, Document destination)
throws PublicationException {
try {
@@ -95,6 +101,26 @@
}
/**
+ * Copies meta data from one document to another, whereas both documents will have
+ * completely identical meta data afterwards (including workflow etc.). This is only
+ * useful if the source document will be deleted afterwards.
+ * @param source
+ * @param destination
+ * @throws PublicationException
+ */
+ protected void duplicateMetaData(Document source, Document destination)
+ throws PublicationException {
+ try {
+ String[] uris = source.getMetaDataNamespaceUris();
+ for (int i = 0; i < uris.length; i++) {
+ destination.getMetaData(uris[i]).forcedReplaceBy(source.getMetaData(uris[i]));
+ }
+ } catch (MetaDataException e) {
+ throw new PublicationException(e);
+ }
+ }
+
+ /**
* @see org.apache.lenya.cms.publication.DocumentManager#add(org.apache.lenya.cms.publication.DocumentFactory,
* org.apache.lenya.cms.publication.ResourceType, java.lang.String,
* org.apache.lenya.cms.publication.Publication, java.lang.String, java.lang.String,
@@ -403,7 +429,7 @@
targetDoc = sourceDoc;
}
else {
- targetDoc = addVersion(sourceDoc, targetArea.getName(), sourceDoc.getLanguage());
+ targetDoc = duplicateVersion(sourceDoc, targetArea.getName(), sourceDoc.getLanguage());
sourceDoc.delete();
}
@@ -787,6 +813,21 @@
sourceDocument.getSourceExtension());
copyMetaData(sourceDocument, document);
+ return document;
+ }
+
+ public Document duplicateVersion(Document sourceDocument, String area, String language)
+ throws DocumentBuildException, DocumentException, PublicationException {
+ Document document = add(sourceDocument.getFactory(),
+ sourceDocument.getResourceType(),
+ sourceDocument.getUUID(),
+ sourceDocument.getSourceURI(),
+ sourceDocument.getPublication(),
+ area,
+ language,
+ sourceDocument.getSourceExtension());
+ duplicateMetaData(sourceDocument, document);
+
return document;
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/metadata/MetaData.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/metadata/MetaData.java?view=diff&rev=452337&r1=452336&r2=452337
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/metadata/MetaData.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/metadata/MetaData.java Tue Oct 3 01:04:26 2006
@@ -69,6 +69,14 @@
void replaceBy(MetaData other) throws MetaDataException;
/**
+ * Replace the contents of the current meta data by the contents of other.
+ * All meta data is replaced, disregarding the rules given by element.getActionOnCopy().
+ * @param other The other meta data manager.
+ * @throws MetaDataException if an error occurs.
+ */
+ void forcedReplaceBy(MetaData other) throws MetaDataException;
+
+ /**
* @return All keys that can be used.
*/
String[] getPossibleKeys();
Modified: lenya/trunk/src/modules-optional/jcrsource/java/src/org/apache/lenya/cms/jcr/metadata/JCRMetaData.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-optional/jcrsource/java/src/org/apache/lenya/cms/jcr/metadata/JCRMetaData.java?view=diff&rev=452337&r1=452336&r2=452337
==============================================================================
--- lenya/trunk/src/modules-optional/jcrsource/java/src/org/apache/lenya/cms/jcr/metadata/JCRMetaData.java (original)
+++ lenya/trunk/src/modules-optional/jcrsource/java/src/org/apache/lenya/cms/jcr/metadata/JCRMetaData.java Tue Oct 3 01:04:26 2006
@@ -192,6 +192,10 @@
save();
}
+ public void forcedReplaceBy(MetaData other) throws MetaDataException {
+ replaceBy(other);
+ }
+
private String[] possibleKeys = new String[0];
/**
Modified: lenya/trunk/src/modules/repository/java/src/org/apache/lenya/cms/repo/adapter/RepoMetaData.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/repository/java/src/org/apache/lenya/cms/repo/adapter/RepoMetaData.java?view=diff&rev=452337&r1=452336&r2=452337
==============================================================================
--- lenya/trunk/src/modules/repository/java/src/org/apache/lenya/cms/repo/adapter/RepoMetaData.java (original)
+++ lenya/trunk/src/modules/repository/java/src/org/apache/lenya/cms/repo/adapter/RepoMetaData.java Tue Oct 3 01:04:26 2006
@@ -90,6 +90,10 @@
throw new RuntimeException("not implemented");
}
+ public void forcedReplaceBy(MetaData other) throws MetaDataException {
+ throw new RuntimeException("not implemented");
+ }
+
public String[] getPossibleKeys() {
Element[] elements;
try {
Modified: lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeMetaData.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeMetaData.java?view=diff&rev=452337&r1=452336&r2=452337
==============================================================================
--- lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeMetaData.java (original)
+++ lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeMetaData.java Tue Oct 3 01:04:26 2006
@@ -129,6 +129,18 @@
}
}
+ public void forcedReplaceBy(MetaData other) throws MetaDataException {
+ Element[] elements = getElementSet().getElements();
+ for (int i = 0; i < elements.length; i++) {
+ String key = elements[i].getName();
+ removeAllValues(key);
+ String[] values = other.getValues(key);
+ for (int j = 0; j < values.length; j++) {
+ addValue(key, values[j]);
+ }
+ }
+ }
+
public String[] getPossibleKeys() {
return getAvailableKeys();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org