mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-3974 Cleaned up various classes after the Form Processor refactor. Added @since tags to all new classes. Moved TaskUpdater, WorkflowBuilder and PackageManager into org.alfresco.repo.workflow.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21431 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -25,6 +25,13 @@ import org.apache.commons.logging.Log;
|
||||
|
||||
import com.sun.star.lang.IllegalArgumentException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
* @param <Data>
|
||||
*/
|
||||
public abstract class AbstractFieldProcessor<Data> implements FieldProcessor
|
||||
{
|
||||
/* (non-Javadoc)
|
||||
|
@@ -21,6 +21,12 @@ package org.alfresco.repo.forms.processor;
|
||||
|
||||
import org.alfresco.repo.forms.Field;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
public interface FieldProcessor
|
||||
{
|
||||
Field generateField(String fieldName, FormCreationData data);
|
||||
|
@@ -24,6 +24,11 @@ import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.forms.Field;
|
||||
|
||||
/**
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
public class FieldProcessorRegistry
|
||||
{
|
||||
private final Map<String, FieldProcessor> processors = new HashMap<String, FieldProcessor>();
|
||||
|
@@ -30,6 +30,7 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* Simple DTO containing various objects needed to generate Forms.
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*/
|
||||
public class FormCreationData
|
||||
|
@@ -20,7 +20,11 @@
|
||||
package org.alfresco.repo.forms.processor;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
* @param <PersistType>
|
||||
*/
|
||||
public interface FormPersister<PersistType>
|
||||
{
|
||||
|
@@ -19,6 +19,12 @@ import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
public class AssociationFieldProcessor extends QNameFieldProcessor<AssociationDefinition>
|
||||
{
|
||||
private static final Log logger = LogFactory.getLog(AssociationFieldProcessor.class);
|
||||
@@ -50,7 +56,7 @@ public class AssociationFieldProcessor extends QNameFieldProcessor<AssociationDe
|
||||
public Field makeField(AssociationDefinition assocDef, Object value, FieldGroup group)
|
||||
{
|
||||
AssociationFieldDefinition fieldDef = makeAssociationFieldDefinition(assocDef, group);
|
||||
return new ContentField(assocDef, fieldDef, value);
|
||||
return new ContentModelField(assocDef, fieldDef, value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -30,14 +30,15 @@ import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* @author Nick Smith
|
||||
* @since 3.4
|
||||
*/
|
||||
public class ContentField implements Field
|
||||
public class ContentModelField implements Field
|
||||
{
|
||||
private final FieldDefinition fieldDefinition;
|
||||
private final ClassAttributeDefinition classDefinition;
|
||||
private final Object value;
|
||||
|
||||
public ContentField(PropertyDefinition propertyDefinition,
|
||||
public ContentModelField(PropertyDefinition propertyDefinition,
|
||||
PropertyFieldDefinition fieldDef, Object value)
|
||||
{
|
||||
this.classDefinition = propertyDefinition;
|
||||
@@ -45,7 +46,7 @@ public class ContentField implements Field
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public ContentField(AssociationDefinition assocDefinition,
|
||||
public ContentModelField(AssociationDefinition assocDefinition,
|
||||
AssociationFieldDefinition fieldDef, Object value)
|
||||
{
|
||||
this.classDefinition = assocDefinition;
|
||||
@@ -57,7 +58,7 @@ public class ContentField implements Field
|
||||
* This constructor should only be used to create FieldInfo for transient properties such as encoding, mimetype or size.
|
||||
* @param fieldDef The PropertyFieldDefinition for the transient property.
|
||||
*/
|
||||
public ContentField(FieldDefinition fieldDef, Object value)
|
||||
public ContentModelField(FieldDefinition fieldDef, Object value)
|
||||
{
|
||||
this.classDefinition = null;
|
||||
this.fieldDefinition = fieldDef;
|
@@ -22,6 +22,8 @@ package org.alfresco.repo.forms.processor.node;
|
||||
import org.alfresco.repo.forms.processor.FieldProcessorRegistry;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
|
@@ -18,6 +18,13 @@
|
||||
*/
|
||||
package org.alfresco.repo.forms.processor.node;
|
||||
|
||||
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.ASSOC_DATA_ADDED_SUFFIX;
|
||||
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.ASSOC_DATA_PREFIX;
|
||||
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.ASSOC_DATA_REMOVED_SUFFIX;
|
||||
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.ON;
|
||||
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.PROP_DATA_PREFIX;
|
||||
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.DEFAULT_CONTENT_MIMETYPE;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -37,7 +44,6 @@ import org.alfresco.repo.forms.FormException;
|
||||
import org.alfresco.repo.forms.FormData.FieldData;
|
||||
import org.alfresco.repo.forms.processor.FilteredFormProcessor;
|
||||
import org.alfresco.repo.forms.processor.FormCreationData;
|
||||
import org.alfresco.repo.forms.processor.workflow.DataKeyMatcher;
|
||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.ChildAssociationDefinition;
|
||||
@@ -70,48 +76,11 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
||||
* form processors that deal with Alfresco content models i.e. types and nodes.
|
||||
*
|
||||
* @author Gavin Cornwell
|
||||
* @author Nick Smith
|
||||
*/
|
||||
public abstract class ContentModelFormProcessor<ItemType, PersistType> extends
|
||||
FilteredFormProcessor<ItemType, PersistType>
|
||||
{
|
||||
/** Public constants */
|
||||
public static final String ON = "on";
|
||||
|
||||
public static final String PROP = "prop";
|
||||
|
||||
public static final String ASSOC = "assoc";
|
||||
|
||||
public static final String DATA_KEY_SEPARATOR = "_";
|
||||
|
||||
public static final String PROP_DATA_PREFIX = PROP + DATA_KEY_SEPARATOR;
|
||||
|
||||
public static final String ASSOC_DATA_PREFIX = ASSOC + DATA_KEY_SEPARATOR;
|
||||
|
||||
public static final String ASSOC_DATA_ADDED_SUFFIX = DATA_KEY_SEPARATOR + "added";
|
||||
|
||||
public static final String ASSOC_DATA_REMOVED_SUFFIX = DATA_KEY_SEPARATOR + "removed";
|
||||
|
||||
public static final String TRANSIENT_MIMETYPE = "mimetype";
|
||||
|
||||
public static final String TRANSIENT_SIZE = "size";
|
||||
|
||||
public static final String TRANSIENT_ENCODING = "encoding";
|
||||
|
||||
/** Protected constants */
|
||||
protected static final String DEFAULT_CONTENT_MIMETYPE = "text/plain";
|
||||
|
||||
protected static final String MSG_MIMETYPE_LABEL = "form_service.mimetype.label";
|
||||
|
||||
protected static final String MSG_MIMETYPE_DESC = "form_service.mimetype.description";
|
||||
|
||||
protected static final String MSG_ENCODING_LABEL = "form_service.encoding.label";
|
||||
|
||||
protected static final String MSG_ENCODING_DESC = "form_service.encoding.description";
|
||||
|
||||
protected static final String MSG_SIZE_LABEL = "form_service.size.label";
|
||||
|
||||
protected static final String MSG_SIZE_DESC = "form_service.size.description";
|
||||
|
||||
/** Services */
|
||||
protected NodeService nodeService;
|
||||
|
||||
@@ -145,8 +114,6 @@ public abstract class ContentModelFormProcessor<ItemType, PersistType> extends
|
||||
*/
|
||||
protected Pattern associationNamePattern = Pattern.compile(ASSOC_DATA_PREFIX + "([a-zA-Z0-9]+)_(.*)(_[a-zA-Z]+)");
|
||||
|
||||
private DataKeyMatcher keyMatcher;
|
||||
|
||||
/**
|
||||
* Sets the node service
|
||||
*
|
||||
@@ -185,7 +152,6 @@ public abstract class ContentModelFormProcessor<ItemType, PersistType> extends
|
||||
public void setNamespaceService(NamespaceService namespaceService)
|
||||
{
|
||||
this.namespaceService = namespaceService;
|
||||
this.keyMatcher = new DataKeyMatcher(namespaceService);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -509,15 +475,15 @@ public abstract class ContentModelFormProcessor<ItemType, PersistType> extends
|
||||
{
|
||||
String fieldName = tppm.group(1);
|
||||
|
||||
if (fieldName.equals(TRANSIENT_MIMETYPE))
|
||||
if (fieldName.equals(MimetypeFieldProcessor.KEY))
|
||||
{
|
||||
processMimetypePropertyPersist(nodeRef, fieldData, propsToPersist);
|
||||
}
|
||||
else if (fieldName.equals(TRANSIENT_ENCODING))
|
||||
else if (fieldName.equals(EncodingFieldProcessor.KEY))
|
||||
{
|
||||
processEncodingPropertyPersist(nodeRef, fieldData, propsToPersist);
|
||||
}
|
||||
else if (fieldName.equals(TRANSIENT_SIZE))
|
||||
else if (fieldName.equals(SizeFieldProcessor.KEY))
|
||||
{
|
||||
// the size property is well known but should never be
|
||||
// persisted
|
||||
@@ -814,7 +780,7 @@ public abstract class ContentModelFormProcessor<ItemType, PersistType> extends
|
||||
|
||||
if (data != null)
|
||||
{
|
||||
FieldData mimetypeField = data.getFieldData(PROP + DATA_KEY_SEPARATOR + TRANSIENT_MIMETYPE);
|
||||
FieldData mimetypeField = data.getFieldData(PROP_DATA_PREFIX + MimetypeFieldProcessor.KEY);
|
||||
if (mimetypeField != null)
|
||||
{
|
||||
String mimetypeFieldValue = (String)mimetypeField.getValue();
|
||||
|
@@ -32,7 +32,10 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
public class DefaultFieldBuilder
|
||||
{
|
||||
|
@@ -28,6 +28,12 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
public class DefaultFieldProcessor extends QNameFieldProcessor<ClassAttributeDefinition> implements InitializingBean
|
||||
{
|
||||
private static final Log logger = LogFactory.getLog(DefaultFieldProcessor.class);
|
||||
|
@@ -20,7 +20,6 @@
|
||||
package org.alfresco.repo.forms.processor.node;
|
||||
|
||||
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.PROP_DATA_PREFIX;
|
||||
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.TRANSIENT_ENCODING;
|
||||
|
||||
import org.alfresco.repo.forms.FieldDefinition;
|
||||
import org.alfresco.repo.forms.PropertyFieldDefinition;
|
||||
@@ -29,10 +28,18 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
public class TransientEncodingFieldProcessor extends TransientFieldProcessor
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
public class EncodingFieldProcessor extends TransientFieldProcessor
|
||||
{
|
||||
private static final Log logger = LogFactory.getLog(TransientEncodingFieldProcessor.class);
|
||||
private static final Log logger = LogFactory.getLog(EncodingFieldProcessor.class);
|
||||
|
||||
public static final String KEY = "encoding";
|
||||
|
||||
private static final String MSG_ENCODING_LABEL = "form_service.encoding.label";
|
||||
private static final String MSG_ENCODING_DESC = "form_service.encoding.description";
|
||||
|
||||
@@ -45,8 +52,8 @@ public class TransientEncodingFieldProcessor extends TransientFieldProcessor
|
||||
@Override
|
||||
protected FieldDefinition makeTransientFieldDefinition()
|
||||
{
|
||||
String dataKeyName = PROP_DATA_PREFIX + TRANSIENT_ENCODING;
|
||||
PropertyFieldDefinition encodingField = new PropertyFieldDefinition(TRANSIENT_ENCODING,
|
||||
String dataKeyName = PROP_DATA_PREFIX + KEY;
|
||||
PropertyFieldDefinition encodingField = new PropertyFieldDefinition(KEY,
|
||||
DataTypeDefinition.TEXT.getLocalName());
|
||||
encodingField.setLabel(I18NUtil.getMessage(MSG_ENCODING_LABEL));
|
||||
encodingField.setDescription(I18NUtil.getMessage(MSG_ENCODING_DESC));
|
||||
@@ -57,6 +64,6 @@ public class TransientEncodingFieldProcessor extends TransientFieldProcessor
|
||||
@Override
|
||||
protected String getRegistryKey()
|
||||
{
|
||||
return FormFieldConstants.TRANSIENT_ENCODING;
|
||||
return KEY;
|
||||
}
|
||||
}
|
@@ -40,7 +40,10 @@ import org.alfresco.service.namespace.NamespaceServiceMemoryImpl;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
public class FieldProcessorTest extends TestCase
|
||||
{
|
||||
|
@@ -35,6 +35,7 @@ import org.alfresco.service.namespace.NamespaceService;
|
||||
* {@link PropertyDefinition PropertyDefinitions} and
|
||||
* {@link AssociationDefinition AssociationDefinitions}
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
|
@@ -20,6 +20,7 @@
|
||||
package org.alfresco.repo.forms.processor.node;
|
||||
|
||||
/**
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*/
|
||||
public interface FormFieldConstants
|
||||
@@ -43,13 +44,11 @@ public interface FormFieldConstants
|
||||
|
||||
public static final String ASSOC_DATA_REMOVED_SUFFIX = DATA_KEY_SEPARATOR + "removed";
|
||||
|
||||
public static final String TRANSIENT_MIMETYPE = "mimetype";
|
||||
|
||||
public static final String TRANSIENT_SIZE = "size";
|
||||
|
||||
public static final String TRANSIENT_ENCODING = "encoding";
|
||||
|
||||
public static final String ADDED = "added";
|
||||
|
||||
public static final String REMOVED = "removed";
|
||||
|
||||
/** Protected constants */
|
||||
public static final String DEFAULT_CONTENT_MIMETYPE = "text/plain";
|
||||
|
||||
}
|
||||
|
@@ -38,6 +38,7 @@ import org.alfresco.service.namespace.QName;
|
||||
* Simple data transfer object used by the ContentModelFormProcessor and its
|
||||
* descendants.
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*/
|
||||
public class ItemData<ItemType> implements TransientValueGetter
|
||||
|
@@ -20,7 +20,6 @@
|
||||
package org.alfresco.repo.forms.processor.node;
|
||||
|
||||
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.PROP_DATA_PREFIX;
|
||||
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.TRANSIENT_MIMETYPE;
|
||||
|
||||
import org.alfresco.repo.forms.FieldDefinition;
|
||||
import org.alfresco.repo.forms.PropertyFieldDefinition;
|
||||
@@ -29,10 +28,19 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
public class TransientMimetypeFieldProcessor extends TransientFieldProcessor
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
public class MimetypeFieldProcessor extends TransientFieldProcessor
|
||||
{
|
||||
private static final Log logger = LogFactory.getLog(TransientMimetypeFieldProcessor.class);
|
||||
private static final String MSG_MIMETYPE_LABEL = "form_service.mimetype.label";
|
||||
private static final Log logger = LogFactory.getLog(MimetypeFieldProcessor.class);
|
||||
|
||||
public static final String KEY = "mimetype";
|
||||
|
||||
private static final String MSG_MIMETYPE_LABEL = "form_service.mimetype.label";
|
||||
private static final String MSG_MIMETYPE_DESC = "form_service.mimetype.description";
|
||||
|
||||
@Override
|
||||
@@ -42,8 +50,8 @@ public class TransientMimetypeFieldProcessor extends TransientFieldProcessor
|
||||
|
||||
@Override
|
||||
protected FieldDefinition makeTransientFieldDefinition() {
|
||||
String dataKeyName = PROP_DATA_PREFIX + TRANSIENT_MIMETYPE;
|
||||
PropertyFieldDefinition mimetypeField = new PropertyFieldDefinition(TRANSIENT_MIMETYPE, DataTypeDefinition.TEXT
|
||||
String dataKeyName = PROP_DATA_PREFIX + KEY;
|
||||
PropertyFieldDefinition mimetypeField = new PropertyFieldDefinition(KEY, DataTypeDefinition.TEXT
|
||||
.getLocalName());
|
||||
mimetypeField.setLabel(I18NUtil.getMessage(MSG_MIMETYPE_LABEL));
|
||||
mimetypeField.setDescription(I18NUtil.getMessage(MSG_MIMETYPE_DESC));
|
||||
@@ -54,6 +62,6 @@ public class TransientMimetypeFieldProcessor extends TransientFieldProcessor
|
||||
@Override
|
||||
protected String getRegistryKey()
|
||||
{
|
||||
return FormFieldConstants.TRANSIENT_MIMETYPE;
|
||||
return KEY;
|
||||
}
|
||||
}
|
@@ -40,7 +40,10 @@ import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
public class MockClassAttributeDefinition implements PropertyDefinition, AssociationDefinition
|
||||
{
|
||||
|
@@ -1,10 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
|
||||
package org.alfresco.repo.forms.processor.node;
|
||||
|
||||
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.ASSOC;
|
||||
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.PROP;
|
||||
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.TRANSIENT_ENCODING;
|
||||
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.TRANSIENT_MIMETYPE;
|
||||
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.TRANSIENT_SIZE;
|
||||
|
||||
import org.alfresco.repo.forms.processor.FieldProcessor;
|
||||
import org.alfresco.repo.forms.processor.workflow.PackageItemsFieldProcessor;
|
||||
@@ -12,15 +34,21 @@ import org.alfresco.repo.forms.processor.workflow.TransitionFieldProcessor;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
public class MockFieldProcessorRegistry extends ContentModelFieldProcessorRegistry
|
||||
{
|
||||
public MockFieldProcessorRegistry(NamespaceService namespaceService, DictionaryService dictionaryService)
|
||||
{
|
||||
register(PROP, makePropertyFieldProcessor(namespaceService, dictionaryService));
|
||||
register(ASSOC, makeAssociationFieldProcessor(namespaceService, dictionaryService));
|
||||
register(TRANSIENT_ENCODING, makeEncodingFieldProcessor());
|
||||
register(TRANSIENT_MIMETYPE, makeMimetypeFieldProcessor());
|
||||
register(TRANSIENT_SIZE, makeSizeFieldProcessor());
|
||||
register(EncodingFieldProcessor.KEY, makeEncodingFieldProcessor());
|
||||
register(MimetypeFieldProcessor.KEY, makeMimetypeFieldProcessor());
|
||||
register(SizeFieldProcessor.KEY, makeSizeFieldProcessor());
|
||||
register(TransitionFieldProcessor.KEY, makeTransitionFieldProcessor());
|
||||
register(PackageItemsFieldProcessor.KEY, makePackageItemFieldProcessor());
|
||||
setDefaultProcessor(makeDefaultFieldProcessor(namespaceService, dictionaryService));
|
||||
@@ -60,19 +88,19 @@ public class MockFieldProcessorRegistry extends ContentModelFieldProcessorRegist
|
||||
return processor;
|
||||
}
|
||||
|
||||
private TransientEncodingFieldProcessor makeEncodingFieldProcessor()
|
||||
private EncodingFieldProcessor makeEncodingFieldProcessor()
|
||||
{
|
||||
return new TransientEncodingFieldProcessor();
|
||||
return new EncodingFieldProcessor();
|
||||
}
|
||||
|
||||
private TransientMimetypeFieldProcessor makeMimetypeFieldProcessor()
|
||||
private MimetypeFieldProcessor makeMimetypeFieldProcessor()
|
||||
{
|
||||
return new TransientMimetypeFieldProcessor();
|
||||
return new MimetypeFieldProcessor();
|
||||
}
|
||||
|
||||
private TransientSizeFieldProcessor makeSizeFieldProcessor()
|
||||
private SizeFieldProcessor makeSizeFieldProcessor()
|
||||
{
|
||||
return new TransientSizeFieldProcessor();
|
||||
return new SizeFieldProcessor();
|
||||
}
|
||||
|
||||
private PropertyFieldProcessor makePropertyFieldProcessor(NamespaceService namespaceService,
|
||||
|
@@ -48,6 +48,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
* repository nodes.
|
||||
*
|
||||
* @author Gavin Cornwell
|
||||
* @author Nick Smith
|
||||
*/
|
||||
public class NodeFormProcessor extends ContentModelFormProcessor<NodeRef, NodeRef>
|
||||
{
|
||||
@@ -193,9 +194,9 @@ public class NodeFormProcessor extends ContentModelFormProcessor<NodeRef, NodeRe
|
||||
ContentData contentData = getContentData(item);
|
||||
if(contentData!=null)
|
||||
{
|
||||
values.put(TRANSIENT_ENCODING, contentData.getEncoding());
|
||||
values.put(TRANSIENT_MIMETYPE, contentData.getMimetype());
|
||||
values.put(TRANSIENT_SIZE, contentData.getSize());
|
||||
values.put(EncodingFieldProcessor.KEY, contentData.getEncoding());
|
||||
values.put(MimetypeFieldProcessor.KEY, contentData.getMimetype());
|
||||
values.put(SizeFieldProcessor.KEY, contentData.getSize());
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
@@ -45,6 +45,12 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
public class PropertyFieldProcessor extends QNameFieldProcessor<PropertyDefinition>
|
||||
{
|
||||
private static final Log logger = LogFactory.getLog(PropertyFieldProcessor.class);
|
||||
@@ -83,7 +89,7 @@ public class PropertyFieldProcessor extends QNameFieldProcessor<PropertyDefiniti
|
||||
public Field makeField(PropertyDefinition propDef, Object value, FieldGroup group)
|
||||
{
|
||||
PropertyFieldDefinition fieldDef = makePropertyFieldDefinition(propDef, group);
|
||||
return new ContentField(propDef, fieldDef, value);
|
||||
return new ContentModelField(propDef, fieldDef, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -30,6 +30,13 @@ import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
* @param <Type>
|
||||
*/
|
||||
public abstract class QNameFieldProcessor<Type extends ClassAttributeDefinition> extends AbstractFieldProcessor<ItemData<?>>
|
||||
{
|
||||
protected NamespaceService namespaceService;
|
||||
|
@@ -20,7 +20,6 @@
|
||||
package org.alfresco.repo.forms.processor.node;
|
||||
|
||||
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.PROP_DATA_PREFIX;
|
||||
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.TRANSIENT_SIZE;
|
||||
|
||||
import org.alfresco.repo.forms.FieldDefinition;
|
||||
import org.alfresco.repo.forms.PropertyFieldDefinition;
|
||||
@@ -29,9 +28,19 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
public class TransientSizeFieldProcessor extends TransientFieldProcessor
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
public class SizeFieldProcessor extends TransientFieldProcessor
|
||||
{
|
||||
private static final Log logger = LogFactory.getLog(TransientSizeFieldProcessor.class);
|
||||
private static final Log logger = LogFactory.getLog(SizeFieldProcessor.class);
|
||||
|
||||
|
||||
public static final String KEY = "size";
|
||||
|
||||
private static final String MSG_SIZE_LABEL = "form_service.size.label";
|
||||
private static final String MSG_SIZE_DESC = "form_service.size.description";
|
||||
|
||||
@@ -44,8 +53,8 @@ public class TransientSizeFieldProcessor extends TransientFieldProcessor
|
||||
@Override
|
||||
protected FieldDefinition makeTransientFieldDefinition()
|
||||
{
|
||||
String dataKeyName = PROP_DATA_PREFIX + TRANSIENT_SIZE;
|
||||
PropertyFieldDefinition sizeField = new PropertyFieldDefinition(TRANSIENT_SIZE,
|
||||
String dataKeyName = PROP_DATA_PREFIX + KEY;
|
||||
PropertyFieldDefinition sizeField = new PropertyFieldDefinition(KEY,
|
||||
DataTypeDefinition.LONG.getLocalName());
|
||||
sizeField.setLabel(I18NUtil.getMessage(MSG_SIZE_LABEL));
|
||||
sizeField.setDescription(I18NUtil.getMessage(MSG_SIZE_DESC));
|
||||
@@ -57,6 +66,6 @@ public class TransientSizeFieldProcessor extends TransientFieldProcessor
|
||||
@Override
|
||||
protected String getRegistryKey()
|
||||
{
|
||||
return FormFieldConstants.TRANSIENT_SIZE;
|
||||
return KEY;
|
||||
}
|
||||
}
|
@@ -24,6 +24,12 @@ import org.alfresco.repo.forms.FieldDefinition;
|
||||
import org.alfresco.repo.forms.processor.AbstractFieldProcessor;
|
||||
import org.alfresco.repo.forms.processor.FormCreationData;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
public abstract class TransientFieldProcessor extends AbstractFieldProcessor<TransientValueGetter>
|
||||
{
|
||||
/* (non-Javadoc)
|
||||
@@ -37,7 +43,7 @@ public abstract class TransientFieldProcessor extends AbstractFieldProcessor<Tra
|
||||
Object value = getValue(fieldName, typedData);
|
||||
if (transientPropDef != null)
|
||||
{
|
||||
fieldInfo = new ContentField(transientPropDef, value);
|
||||
fieldInfo = new ContentModelField(transientPropDef, value);
|
||||
}
|
||||
return fieldInfo;
|
||||
}
|
||||
|
@@ -20,6 +20,8 @@
|
||||
package org.alfresco.repo.forms.processor.node;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
|
@@ -39,11 +39,14 @@ import org.alfresco.util.GUID;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.*;
|
||||
|
||||
/**
|
||||
* FormProcessor implementation that can generate and persist Form objects for
|
||||
* types in the Alfresco content model.
|
||||
*
|
||||
* @author Gavin Cornwell
|
||||
* @author 3.4
|
||||
*/
|
||||
public class TypeFormProcessor extends ContentModelFormProcessor<TypeDefinition, NodeRef>
|
||||
{
|
||||
|
@@ -35,7 +35,12 @@ import org.alfresco.service.cmr.workflow.WorkflowService;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
* @param <ItemType>
|
||||
* @param <PersistType>
|
||||
*/
|
||||
public abstract class AbstractWorkflowFormProcessor<ItemType, PersistType> extends ContentModelFormProcessor<ItemType, PersistType>
|
||||
{
|
||||
|
@@ -34,8 +34,11 @@ import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public abstract class ContentModelFormPersister<T> implements FormPersister<T>
|
||||
{
|
||||
|
@@ -22,6 +22,8 @@ package org.alfresco.repo.forms.processor.workflow;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
@@ -93,24 +95,4 @@ public class DataKeyInfo
|
||||
return isAdd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements the visitor pattern. Takes a DataKeyInfoVisitor and calls the
|
||||
* appropriate visit method based on the fieldType.
|
||||
*
|
||||
* @param <T>
|
||||
* @param visitor
|
||||
* @return
|
||||
*/
|
||||
public <T> T visit(DataKeyInfoVisitor<T> visitor)
|
||||
{
|
||||
switch(fieldType)
|
||||
{
|
||||
case ASSOCIATION: return visitor.visitAssociation(this);
|
||||
case PROPERTY: return visitor.visitProperty(this);
|
||||
case TRANSIENT_ASSOCIATION: return visitor.visitTransientAssociation(this);
|
||||
case TRANSIENT_PROPERTY: return visitor.visitTransientProperty(this);
|
||||
default: return null; //Should never be reached.
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.alfresco.repo.forms.processor.workflow;
|
||||
|
||||
/**
|
||||
* Visitor interface used to enable the visitor pattern on {@link DataKeyInfo}
|
||||
* instances. Implementations of this interface can call
|
||||
* <code>DataKeyInfo.visit(DataKeyInfoVisitor)</code> to have the appropriate
|
||||
* visit method called on the visitor, based on the fieldType of the
|
||||
* {@link DataKeyInfo} instance.
|
||||
*
|
||||
* @author Nick Smith
|
||||
*/
|
||||
public interface DataKeyInfoVisitor<T>
|
||||
{
|
||||
/**
|
||||
* Called for {@link DataKeyInfo} instances with a field type of ASSOCIATION.
|
||||
* @param info
|
||||
* @return
|
||||
*/
|
||||
T visitAssociation(DataKeyInfo info);
|
||||
|
||||
/**
|
||||
* Called for {@link DataKeyInfo} instances with a field type of PROPERTY.
|
||||
* @param info
|
||||
* @return
|
||||
*/
|
||||
T visitProperty(DataKeyInfo info);
|
||||
|
||||
/**
|
||||
* Called for {@link DataKeyInfo} instances with a field type of TRANSIENT_ASSOCIATION.
|
||||
* @param info
|
||||
* @return
|
||||
*/
|
||||
T visitTransientAssociation(DataKeyInfo info);
|
||||
|
||||
/**
|
||||
* Called for {@link DataKeyInfo} instances with a field type of TRANSIENT_PROPERTY.
|
||||
* @param info
|
||||
* @return
|
||||
*/
|
||||
T visitTransientProperty(DataKeyInfo info);
|
||||
}
|
@@ -28,6 +28,8 @@ import org.alfresco.service.namespace.QName;
|
||||
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
|
@@ -20,6 +20,8 @@
|
||||
package org.alfresco.repo.forms.processor.workflow;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
|
@@ -21,10 +21,12 @@ package org.alfresco.repo.forms.processor.workflow;
|
||||
|
||||
import org.alfresco.repo.forms.FormData.FieldData;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public interface FormPersister<T>
|
||||
{
|
||||
|
@@ -32,6 +32,8 @@ import static org.alfresco.repo.forms.processor.node.FormFieldConstants.ASSOC_DA
|
||||
|
||||
/**
|
||||
* {@link FieldProcessor} for handling package contents when displaying Workflow and Task Forms.
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*/
|
||||
public class PackageItemsFieldProcessor extends TransientFieldProcessor
|
||||
|
@@ -24,6 +24,7 @@ import java.util.List;
|
||||
|
||||
import org.alfresco.repo.forms.FormData.FieldData;
|
||||
import org.alfresco.repo.forms.processor.node.ItemData;
|
||||
import org.alfresco.repo.workflow.TaskUpdater;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
@@ -34,6 +35,8 @@ import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
|
@@ -47,7 +47,10 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
public class TaskFormProcessor extends AbstractWorkflowFormProcessor<WorkflowTask, WorkflowTask>
|
||||
{
|
||||
|
@@ -79,7 +79,10 @@ import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
public class TaskFormProcessorTest extends TestCase
|
||||
{
|
||||
|
@@ -29,6 +29,8 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
|
@@ -38,7 +38,10 @@ import org.json.JSONException;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
public class TypedPropertyValueGetter
|
||||
{
|
||||
|
@@ -23,6 +23,7 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.forms.processor.node.ItemData;
|
||||
import org.alfresco.repo.workflow.WorkflowBuilder;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
@@ -34,6 +35,8 @@ import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
|
@@ -35,6 +35,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
* Temporary FormProcessor implementation that can generate and persist
|
||||
* Form objects for workflow definitions.
|
||||
*
|
||||
*@since 3.4
|
||||
* @author Nick Smith
|
||||
*/
|
||||
public class WorkflowFormProcessor extends AbstractWorkflowFormProcessor<WorkflowDefinition, WorkflowInstance>
|
||||
|
@@ -22,7 +22,10 @@ package org.alfresco.repo.forms.processor.workflow;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
public class WorkflowFormProcessorTest extends TestCase
|
||||
{
|
||||
|
@@ -17,7 +17,7 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.alfresco.repo.forms.processor.workflow;
|
||||
package org.alfresco.repo.workflow;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -28,7 +28,6 @@ import java.util.Set;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.workflow.WorkflowModel;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
@@ -42,7 +41,14 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* This helper class is used to manage a workflow package. The manager is a
|
||||
* stateful object which accumulates all the changes to be made to the package
|
||||
* (such as adding and removing package items). These changes are then applied
|
||||
* to the package when either the create() or update() method is called.
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
public class PackageManager
|
||||
{
|
@@ -23,7 +23,7 @@
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
|
||||
package org.alfresco.repo.forms.processor.workflow;
|
||||
package org.alfresco.repo.workflow;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
@@ -39,9 +39,10 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* A utility class for updating workflow tasks. This is a stateful object that
|
||||
* accumulates a set of updates to a task and then commits all the updates when
|
||||
* the update() method is called.
|
||||
* A helper class for updating and transitioning {@link WorkflowTask
|
||||
* WorkflowTasks}. This is a stateful object that accumulates a set of updates
|
||||
* to a task and then commits all the updates when either the update() or
|
||||
* transition() method is called.
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
@@ -17,14 +17,13 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.alfresco.repo.forms.processor.workflow;
|
||||
package org.alfresco.repo.workflow;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.workflow.WorkflowModel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
|
||||
@@ -36,10 +35,11 @@ import org.alfresco.service.cmr.workflow.WorkflowTask;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* A helper class used to start workflows. The builder accumuates all the
|
||||
* changes to be made to the list of parameters and package items, then starts a
|
||||
* new workflow once the build() method is called.
|
||||
* A helper class used to start workflows. The builder is a stateful object that
|
||||
* accumulates the various parameters and package items used to start the
|
||||
* workflow. The workflow is started when the build() method is called.
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Nick Smith
|
||||
*/
|
||||
public class WorkflowBuilder
|
Reference in New Issue
Block a user