You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lenya.apache.org by Andreas Hartmann <an...@apache.org> on 2006/09/26 21:35:58 UTC
Re: Copying of workflow meta data [was: svn commit: r447411 - in
/lenya/trunk/src: impl/java/org/apache/lenya/cms/metadata/ impl/test/org/apache/lenya/cms/metadata/
java/org/apache/lenya/cms/metadata/ modules-core/workflow-impl/config/cocoon-xconf/
modules/sourcerepository/java/src/org/apach...]
Hi Josias,
Josias Thöny wrote:
[...]
>> URL: http://svn.apache.org/viewvc?view=rev&rev=447411
>> Log:
>> Introduce onCopy action configuration for meta data, don't copy workflow meta data
>
> What exactly is the reason not to copy the workflow meta data?
the reason was that a new document which is a copy of an existing one
but has a different UUID/language should not start with the same
workflow history, but get a clean one.
> Now the workflow meta data gets lost when a document is moved to the
> trash/archive area.
Hmm, this is apparently an implementation bug. Moving a document
should not affect the meta data.
> As a consequence, the document cannot be restored
> anymore, because the workflow information is missing.
>
> Does anybody have an idea how this could be fixed?
Would you mind filing a bug?
Thanks for reporting!
-- Andreas
>
> thanks,
> josias
>
>> Modified:
>> lenya/trunk/src/impl/java/org/apache/lenya/cms/metadata/ConfigurableElementSet.java
>> lenya/trunk/src/impl/java/org/apache/lenya/cms/metadata/ElementImpl.java
>> lenya/trunk/src/impl/test/org/apache/lenya/cms/metadata/MetaDataTest.java
>> lenya/trunk/src/java/org/apache/lenya/cms/metadata/Element.java
>> lenya/trunk/src/modules-core/workflow-impl/config/cocoon-xconf/workflow-metadata.xconf
>> lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeMetaData.java
>>
>> Modified: lenya/trunk/src/impl/java/org/apache/lenya/cms/metadata/ConfigurableElementSet.java
>> URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/metadata/ConfigurableElementSet.java?view=diff&rev=447411&r1=447410&r2=447411
>> ==============================================================================
>> --- lenya/trunk/src/impl/java/org/apache/lenya/cms/metadata/ConfigurableElementSet.java (original)
>> +++ lenya/trunk/src/impl/java/org/apache/lenya/cms/metadata/ConfigurableElementSet.java Mon Sep 18 07:30:28 2006
>> @@ -48,7 +48,27 @@
>> String name = attributeConfigs[i].getAttribute("name");
>> boolean isMultiple = attributeConfigs[i].getAttributeAsBoolean("multiple", false);
>> boolean isEditable = attributeConfigs[i].getAttributeAsBoolean("editable", false);
>> - this.elements.put(name, new ElementImpl(name, isMultiple, isEditable));
>> + String actionOnCopy = attributeConfigs[i].getAttribute("onCopy", "copy");
>> + ElementImpl element = new ElementImpl(name, isMultiple, isEditable);
>> + int action;
>> + if (actionOnCopy.equalsIgnoreCase("copy")) {
>> + action = Element.ONCOPY_COPY;
>> + }
>> + else if (actionOnCopy.equalsIgnoreCase("ignore")) {
>> + action = Element.ONCOPY_IGNORE;
>> + }
>> + else if (actionOnCopy.equalsIgnoreCase("delete")) {
>> + action = Element.ONCOPY_DELETE;
>> + }
>> + else {
>> + throw new ConfigurationException("The action [" + actionOnCopy + "] is not supported.");
>> + }
>> + try {
>> + element.setActionOnCopy(action);
>> + } catch (MetaDataException e) {
>> + throw new RuntimeException(e);
>> + }
>> + this.elements.put(name, element);
>> }
>>
>> }
>>
>> Modified: lenya/trunk/src/impl/java/org/apache/lenya/cms/metadata/ElementImpl.java
>> URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/metadata/ElementImpl.java?view=diff&rev=447411&r1=447410&r2=447411
>> ==============================================================================
>> --- lenya/trunk/src/impl/java/org/apache/lenya/cms/metadata/ElementImpl.java (original)
>> +++ lenya/trunk/src/impl/java/org/apache/lenya/cms/metadata/ElementImpl.java Mon Sep 18 07:30:28 2006
>> @@ -42,11 +42,11 @@
>> * Ctor.
>> * @param name The name.
>> * @param isMultiple if the element can have multiple values.
>> + * @param isEditable if the element can be edited.
>> * @param description The description of the element.
>> */
>> - public ElementImpl(String name, boolean isMultiple, String description) {
>> - this.name = name;
>> - this.multiple = isMultiple;
>> + public ElementImpl(String name, boolean isMultiple, boolean isEditable, String description) {
>> + this(name, isMultiple, isEditable);
>> this.description = description;
>> }
>>
>> @@ -64,6 +64,20 @@
>>
>> public boolean isEditable() {
>> return this.editable;
>> + }
>> +
>> + private int actionOnCopy;
>> +
>> + public int getActionOnCopy() {
>> + return this.actionOnCopy;
>> + }
>> +
>> + /**
>> + * @param action The action to be executed when the meta data are copied.
>> + * @throws MetaDataException if the action is not supported.
>> + */
>> + public void setActionOnCopy(int action) throws MetaDataException {
>> + this.actionOnCopy = action;
>> }
>>
>> }
>>
>> Modified: lenya/trunk/src/impl/test/org/apache/lenya/cms/metadata/MetaDataTest.java
>> URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/test/org/apache/lenya/cms/metadata/MetaDataTest.java?view=diff&rev=447411&r1=447410&r2=447411
>> ==============================================================================
>> --- lenya/trunk/src/impl/test/org/apache/lenya/cms/metadata/MetaDataTest.java (original)
>> +++ lenya/trunk/src/impl/test/org/apache/lenya/cms/metadata/MetaDataTest.java Mon Sep 18 07:30:28 2006
>> @@ -16,9 +16,13 @@
>> */
>> package org.apache.lenya.cms.metadata;
>>
>> +import java.util.Map;
>> +
>> +import org.apache.avalon.framework.service.ServiceException;
>> import org.apache.lenya.ac.impl.AbstractAccessControlTest;
>> import org.apache.lenya.cms.metadata.dublincore.DublinCore;
>> 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;
>> @@ -52,12 +56,12 @@
>>
>> namespaceUri = DublinCore.DC_NAMESPACE;
>> MetaData dc = doc.getMetaData(namespaceUri);
>> -
>> +
>> doc.getRepositoryNode().lock();
>> -
>> +
>> checkSetTitle(dc);
>> checkRemoveAllValues(dc);
>> -
>> +
>> }
>>
>> protected void checkSetTitle(MetaData dc) throws MetaDataException {
>> @@ -69,7 +73,7 @@
>> }
>> assertNotNull(e);
>> dc.setValue("title", "This is the title");
>> -
>> +
>> e = null;
>> // addValue() should throw an exception because a value is already set
>> try {
>> @@ -78,12 +82,113 @@
>> e = e1;
>> }
>> assertNotNull(e);
>> +
>> + }
>> +
>> + String NAMESPACE = "http://apache.org/lenya/test/metadata";
>> +
>> + protected void checkOnCopy(Publication pub) throws Exception {
>> + MetaDataRegistry registry = null;
>> + try {
>> + registry = (MetaDataRegistry) getManager().lookup(MetaDataRegistry.ROLE);
>> + ElementSet set = new TestElementSet();
>> + registry.register(NAMESPACE, set);
>> + }
>> + finally {
>> + getManager().release(registry);
>> + }
>> +
>> + DocumentFactory factory = getFactory();
>> + Document source = factory.get(pub, Publication.AUTHORING_AREA, "/index", "en");
>> + Document target = factory.get(pub, Publication.AUTHORING_AREA, "/index", "en");
>> +
>> + MetaData sourceMeta = source.getMetaData(NAMESPACE);
>> + sourceMeta.setValue("copy", "sourceCopy");
>> + sourceMeta.setValue("ignore", "sourceIgnore");
>> + sourceMeta.setValue("delete", "sourceDelete");
>> +
>> + MetaData targetMeta = target.getMetaData(NAMESPACE);
>> + targetMeta.setValue("ignore", "targetIgnore");
>> + targetMeta.setValue("delete", "targetDelete");
>> +
>> + targetMeta.replaceBy(sourceMeta);
>> +
>> + assertTrue(targetMeta.getValues("copy").length == 1);
>> + assertEquals(sourceMeta.getValues("copy"), targetMeta.getValues("copy"));
>>
>> + assertTrue(targetMeta.getValues("ignore").length == 1);
>> + assertEquals(targetMeta.getFirstValue("ignore"), "targetIgnore");
>> +
>> + assertTrue(targetMeta.getValues("delete").length == 0);
>> }
>>
>> protected void checkRemoveAllValues(MetaData dc) throws MetaDataException {
>> dc.removeAllValues("title");
>> assertTrue(dc.getValues("title").length == 0);
>> }
>> -
>> +
>> + protected class TestElement implements Element {
>> +
>> + private String name;
>> + private int actionOnCopy;
>> +
>> + protected TestElement(String name, int actionOnCopy) {
>> + this.name = name;
>> + this.actionOnCopy = actionOnCopy;
>> + }
>> +
>> + public int getActionOnCopy() {
>> + return actionOnCopy;
>> + }
>> +
>> + public String getDescription() {
>> + return "";
>> + }
>> +
>> + public String getName() {
>> + return name;
>> + }
>> +
>> + public boolean isEditable() {
>> + return false;
>> + }
>> +
>> + public boolean isMultiple() {
>> + return false;
>> + }
>> +
>> + }
>> +
>> + protected class TestElementSet implements ElementSet {
>> +
>> + private Element[] elements = { new TestElement("copy", Element.ONCOPY_COPY),
>> + new TestElement("ignore", Element.ONCOPY_IGNORE),
>> + new TestElement("delete", Element.ONCOPY_DELETE) };
>> +
>> + private Map name2element;
>> +
>> + protected TestElementSet() {
>> + for (int i = 0; i < elements.length; i++) {
>> + this.name2element.put(elements[i].getName(), elements[i]);
>> + }
>> + }
>> +
>> + public boolean containsElement(String name) {
>> + return true;
>> + }
>> +
>> + public Element getElement(String name) throws MetaDataException {
>> + return (Element) this.name2element.get(name);
>> + }
>> +
>> + public Element[] getElements() {
>> + return elements;
>> + }
>> +
>> + public String getNamespaceUri() {
>> + return NAMESPACE;
>> + }
>> +
>> + }
>> +
>> }
>>
>> Modified: lenya/trunk/src/java/org/apache/lenya/cms/metadata/Element.java
>> URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/metadata/Element.java?view=diff&rev=447411&r1=447410&r2=447411
>> ==============================================================================
>> --- lenya/trunk/src/java/org/apache/lenya/cms/metadata/Element.java (original)
>> +++ lenya/trunk/src/java/org/apache/lenya/cms/metadata/Element.java Mon Sep 18 07:30:28 2006
>> @@ -20,25 +20,45 @@
>> * A meta data element.
>> */
>> public interface Element {
>> -
>> +
>> /**
>> * @return the name of the element.
>> */
>> String getName();
>> -
>> +
>> /**
>> * @return if the element can have multiple values.
>> */
>> boolean isMultiple();
>> -
>> +
>> /**
>> * @return the description of the element.
>> */
>> String getDescription();
>> -
>> +
>> /**
>> * @return if the element value can be edited.
>> */
>> boolean isEditable();
>> +
>> + /**
>> + * Copy all values if the meta data are copied.
>> + */
>> + int ONCOPY_COPY = 0;
>> +
>> + /**
>> + * Don't copy the values of this element if the meta data are copied.
>> + */
>> + int ONCOPY_IGNORE = 1;
>> +
>> + /**
>> + * Delete all values of this element if the meta data are copied.
>> + */
>> + int ONCOPY_DELETE = 2;
>> +
>> + /**
>> + * @return The action to be taken when meta data are copied from one owner to another.
>> + */
>> + int getActionOnCopy();
>>
>> }
>>
>> Modified: lenya/trunk/src/modules-core/workflow-impl/config/cocoon-xconf/workflow-metadata.xconf
>> URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/workflow-impl/config/cocoon-xconf/workflow-metadata.xconf?view=diff&rev=447411&r1=447410&r2=447411
>> ==============================================================================
>> --- lenya/trunk/src/modules-core/workflow-impl/config/cocoon-xconf/workflow-metadata.xconf (original)
>> +++ lenya/trunk/src/modules-core/workflow-impl/config/cocoon-xconf/workflow-metadata.xconf Mon Sep 18 07:30:28 2006
>> @@ -24,7 +24,7 @@
>> unless="/cocoon/meta-data/component-instance[@name = 'http://apache.org/lenya/metadata/workflow/1.0']">
>> <component-instance name="http://apache.org/lenya/metadata/workflow/1.0"
>> class="org.apache.lenya.cms.metadata.ConfigurableElementSet">
>> - <element name="workflowVersion" multiple="true"/>
>> + <element name="workflowVersion" multiple="true" onCopy="delete"/>
>> </component-instance>
>> </xconf>
>>
>>
>> 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=447411&r1=447410&r2=447411
>> ==============================================================================
>> --- 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 Mon Sep 18 07:30:28 2006
>> @@ -52,7 +52,8 @@
>> public ElementSet getElementSet() {
>> if (this.elementSet == null) {
>> try {
>> - MetaDataRegistry registry = (MetaDataRegistry) this.manager.lookup(MetaDataRegistry.ROLE);
>> + MetaDataRegistry registry = (MetaDataRegistry) this.manager
>> + .lookup(MetaDataRegistry.ROLE);
>> this.elementSet = registry.getElementSet(this.namespaceUri);
>> } catch (Exception e) {
>> throw new RuntimeException(e);
>> @@ -113,11 +114,17 @@
>> public void replaceBy(MetaData other) throws MetaDataException {
>> Element[] elements = getElementSet().getElements();
>> for (int i = 0; i < elements.length; i++) {
>> - String key = elements[i].getName();
>> - String[] values = other.getValues(key);
>> - removeAllValues(key);
>> - for (int j = 0; j < values.length; j++) {
>> - addValue(key, values[j]);
>> + if (elements[i].getActionOnCopy() == Element.ONCOPY_COPY) {
>> + String key = elements[i].getName();
>> + removeAllValues(key);
>> + String[] values = other.getValues(key);
>> + for (int j = 0; j < values.length; j++) {
>> + addValue(key, values[j]);
>> + }
>> + }
>> + else if (elements[i].getActionOnCopy() == Element.ONCOPY_DELETE) {
>> + String key = elements[i].getName();
>> + removeAllValues(key);
>> }
>> }
>> }
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
>> For additional commands, e-mail: commits-help@lenya.apache.org
>>
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org