mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merged BRANCHES/V3.2 to HEAD:
19177: (RECORD ONLY) Updated record-only entries for V3.1 branch 19321: (RECORD ONLY) Removed deep svn:mergeinfo 19331: (RECORD ONLY) Merged HEAD to BRANCHES/V3.2: 19324: Follow-up on ALF-765 by upgrading EHCache to 2.0.0Performing merge across the whole of the branch 19526: Moved ContentServicePolicy static QNames onto policy classes 19539: (RECORD ONLY) Merged HEAD to V3.2 19538: Build fix - fix build speed 19541: Added extraction of custom, mapped metadata from PDF documents 19543: (RECORD ONLY) Removed deep svn:mergeinfo 19598: (RECORD ONLY) Backported (merge not possible) HEAD rev 18790 for IndexInfo fixes 19626: Fix for ALF-732: Possible memory leak using the .getNodeRefs() method against a ResultSet ... 19629: (RECORD ONLY) Merged HEAD to V3.2 19625: Fix to allow Share logo to swapped out for a different one without having to modify the header CSS. 19628: Corrected Share header component height. 19649: ALF-885: Cannot retrieve cm:title from an AVM node in FreeMarker (if persisted with actual type set to MLText) 19694: (RECORD ONLY) Merged V3.2 to HEAD: r19310 bad back merge - record-only 19713: (RECORD ONLY) Removed svn:mergeinfo git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19719 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -32,9 +32,11 @@ import org.alfresco.service.namespace.QName;
|
|||||||
*/
|
*/
|
||||||
public interface ContentServicePolicies
|
public interface ContentServicePolicies
|
||||||
{
|
{
|
||||||
/** The QName's of the policies */
|
/** @deprecated Use {@link OnContentUpdatePolicy#QNAME} */
|
||||||
public static final QName ON_CONTENT_UPDATE = QName.createQName(NamespaceService.ALFRESCO_URI, "onContentUpdate");
|
public static final QName ON_CONTENT_UPDATE = QName.createQName(NamespaceService.ALFRESCO_URI, "onContentUpdate");
|
||||||
|
/** @deprecated Use {@link OnContentPropertyUpdatePolicy#QNAME} */
|
||||||
public static final QName ON_CONTENT_PROPERTY_UPDATE = QName.createQName(NamespaceService.ALFRESCO_URI, "onContentPropertyUpdate");
|
public static final QName ON_CONTENT_PROPERTY_UPDATE = QName.createQName(NamespaceService.ALFRESCO_URI, "onContentPropertyUpdate");
|
||||||
|
/** @deprecated Use {@link OnContentReadPolicy#QNAME} */
|
||||||
public static final QName ON_CONTENT_READ = QName.createQName(NamespaceService.ALFRESCO_URI, "onContentRead");
|
public static final QName ON_CONTENT_READ = QName.createQName(NamespaceService.ALFRESCO_URI, "onContentRead");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,6 +46,7 @@ public interface ContentServicePolicies
|
|||||||
*/
|
*/
|
||||||
public interface OnContentUpdatePolicy extends ClassPolicy
|
public interface OnContentUpdatePolicy extends ClassPolicy
|
||||||
{
|
{
|
||||||
|
public static final QName QNAME = QName.createQName(NamespaceService.ALFRESCO_URI, "onContentUpdate");
|
||||||
/**
|
/**
|
||||||
* @param nodeRef the node reference
|
* @param nodeRef the node reference
|
||||||
*/
|
*/
|
||||||
@@ -59,6 +62,7 @@ public interface ContentServicePolicies
|
|||||||
*/
|
*/
|
||||||
public interface OnContentPropertyUpdatePolicy extends ClassPolicy
|
public interface OnContentPropertyUpdatePolicy extends ClassPolicy
|
||||||
{
|
{
|
||||||
|
public static final QName QNAME = QName.createQName(NamespaceService.ALFRESCO_URI, "onContentPropertyUpdate");
|
||||||
/**
|
/**
|
||||||
* @param nodeRef the node reference
|
* @param nodeRef the node reference
|
||||||
* @param propertyQName the name of the property that changed
|
* @param propertyQName the name of the property that changed
|
||||||
@@ -86,6 +90,7 @@ public interface ContentServicePolicies
|
|||||||
*/
|
*/
|
||||||
public interface OnContentReadPolicy extends ClassPolicy
|
public interface OnContentReadPolicy extends ClassPolicy
|
||||||
{
|
{
|
||||||
|
public static final QName QNAME = QName.createQName(NamespaceService.ALFRESCO_URI, "onContentRead");
|
||||||
/**
|
/**
|
||||||
* @param nodeRef the node reference
|
* @param nodeRef the node reference
|
||||||
*/
|
*/
|
||||||
|
@@ -42,6 +42,7 @@ import org.apache.pdfbox.pdmodel.PDDocumentInformation;
|
|||||||
* <b>title:</b> -- cm:title
|
* <b>title:</b> -- cm:title
|
||||||
* <b>subject:</b> -- cm:description
|
* <b>subject:</b> -- cm:description
|
||||||
* <b>created:</b> -- cm:created
|
* <b>created:</b> -- cm:created
|
||||||
|
* <b>Any custom property:</b> -- [not mapped]
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* TIKA Note - all the fields (plus a few others) are present
|
* TIKA Note - all the fields (plus a few others) are present
|
||||||
@@ -124,7 +125,18 @@ public class PdfBoxMetadataExtracter extends AbstractMappingMetadataExtracter
|
|||||||
Date parsedDate = sdf.parse(dateWithoutLeadingDColon);
|
Date parsedDate = sdf.parse(dateWithoutLeadingDColon);
|
||||||
putRawValue(KEY_CREATED, parsedDate, rawProperties);
|
putRawValue(KEY_CREATED, parsedDate, rawProperties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Extract remaining custom properties
|
||||||
|
for (String customProp : super.getMapping().keySet())
|
||||||
|
{
|
||||||
|
if (rawProperties.keySet().contains(customProp))
|
||||||
|
{
|
||||||
|
// Ignore it
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String customValue = docInfo.getCustomMetadataValue(customProp);
|
||||||
|
putRawValue(customProp, customValue, rawProperties);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@@ -19,12 +19,12 @@
|
|||||||
package org.alfresco.repo.dictionary;
|
package org.alfresco.repo.dictionary;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.CopyOnWriteArraySet;
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
@@ -39,16 +39,16 @@ import org.alfresco.repo.tenant.TenantAdminService;
|
|||||||
import org.alfresco.repo.tenant.TenantService;
|
import org.alfresco.repo.tenant.TenantService;
|
||||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||||
import org.alfresco.repo.transaction.TransactionListenerAdapter;
|
import org.alfresco.repo.transaction.TransactionListenerAdapter;
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
import org.alfresco.repo.version.Version2Model;
|
import org.alfresco.repo.version.Version2Model;
|
||||||
import org.alfresco.repo.workflow.BPMEngineRegistry;
|
import org.alfresco.repo.workflow.BPMEngineRegistry;
|
||||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.ConstraintDefinition;
|
import org.alfresco.service.cmr.dictionary.ConstraintDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryException;
|
import org.alfresco.service.cmr.dictionary.DictionaryException;
|
||||||
import org.alfresco.service.cmr.dictionary.ModelDefinition;
|
import org.alfresco.service.cmr.dictionary.ModelDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.NamespaceDefinition;
|
import org.alfresco.service.cmr.dictionary.NamespaceDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.ContentReader;
|
import org.alfresco.service.cmr.repository.ContentReader;
|
||||||
@@ -63,7 +63,7 @@ import org.alfresco.service.cmr.workflow.WorkflowService;
|
|||||||
import org.alfresco.service.cmr.workflow.WorkflowTaskDefinition;
|
import org.alfresco.service.cmr.workflow.WorkflowTaskDefinition;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
@@ -122,8 +122,8 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda
|
|||||||
/** The tenant deployer service */
|
/** The tenant deployer service */
|
||||||
private TenantAdminService tenantAdminService;
|
private TenantAdminService tenantAdminService;
|
||||||
|
|
||||||
private TransactionService transactionService;
|
private TransactionService transactionService;
|
||||||
|
|
||||||
/** Transaction listener */
|
/** Transaction listener */
|
||||||
private DictionaryModelTypeTransactionListener transactionListener;
|
private DictionaryModelTypeTransactionListener transactionListener;
|
||||||
|
|
||||||
@@ -210,14 +210,14 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda
|
|||||||
this.tenantAdminService = tenantAdminService;
|
this.tenantAdminService = tenantAdminService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the transaction service
|
* Set the transaction service
|
||||||
*/
|
*/
|
||||||
public void setTransactionService(TransactionService transactionService)
|
public void setTransactionService(TransactionService transactionService)
|
||||||
{
|
{
|
||||||
this.transactionService = transactionService;
|
this.transactionService = transactionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStoreUrls(List<String> storeUrls)
|
public void setStoreUrls(List<String> storeUrls)
|
||||||
{
|
{
|
||||||
this.storeUrls = storeUrls;
|
this.storeUrls = storeUrls;
|
||||||
@@ -231,38 +231,38 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda
|
|||||||
{
|
{
|
||||||
// Register interest in the onContentUpdate policy for the dictionary model type
|
// Register interest in the onContentUpdate policy for the dictionary model type
|
||||||
policyComponent.bindClassBehaviour(
|
policyComponent.bindClassBehaviour(
|
||||||
ContentServicePolicies.ON_CONTENT_UPDATE,
|
ContentServicePolicies.OnContentUpdatePolicy.QNAME,
|
||||||
ContentModel.TYPE_DICTIONARY_MODEL,
|
ContentModel.TYPE_DICTIONARY_MODEL,
|
||||||
new JavaBehaviour(this, "onContentUpdate"));
|
new JavaBehaviour(this, "onContentUpdate"));
|
||||||
|
|
||||||
// Register interest in the onUpdateProperties policy for the dictionary model type
|
// Register interest in the onUpdateProperties policy for the dictionary model type
|
||||||
policyComponent.bindClassBehaviour(
|
policyComponent.bindClassBehaviour(
|
||||||
QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"),
|
QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"),
|
||||||
ContentModel.TYPE_DICTIONARY_MODEL,
|
ContentModel.TYPE_DICTIONARY_MODEL,
|
||||||
new JavaBehaviour(this, "onUpdateProperties"));
|
new JavaBehaviour(this, "onUpdateProperties"));
|
||||||
|
|
||||||
// Register interest in the beforeDeleteNode policy for the dictionary model type
|
// Register interest in the beforeDeleteNode policy for the dictionary model type
|
||||||
policyComponent.bindClassBehaviour(
|
policyComponent.bindClassBehaviour(
|
||||||
QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"),
|
QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"),
|
||||||
ContentModel.TYPE_DICTIONARY_MODEL,
|
ContentModel.TYPE_DICTIONARY_MODEL,
|
||||||
new JavaBehaviour(this, "beforeDeleteNode"));
|
new JavaBehaviour(this, "beforeDeleteNode"));
|
||||||
|
|
||||||
// Register interest in the onDeleteNode policy for the dictionary model type
|
// Register interest in the onDeleteNode policy for the dictionary model type
|
||||||
policyComponent.bindClassBehaviour(
|
policyComponent.bindClassBehaviour(
|
||||||
QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode"),
|
QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode"),
|
||||||
ContentModel.TYPE_DICTIONARY_MODEL,
|
ContentModel.TYPE_DICTIONARY_MODEL,
|
||||||
new JavaBehaviour(this, "onDeleteNode"));
|
new JavaBehaviour(this, "onDeleteNode"));
|
||||||
|
|
||||||
// Register interest in the onRemoveAspect policy
|
// Register interest in the onRemoveAspect policy
|
||||||
policyComponent.bindClassBehaviour(
|
policyComponent.bindClassBehaviour(
|
||||||
QName.createQName(NamespaceService.ALFRESCO_URI, "onRemoveAspect"),
|
QName.createQName(NamespaceService.ALFRESCO_URI, "onRemoveAspect"),
|
||||||
this,
|
this,
|
||||||
new JavaBehaviour(this, "onRemoveAspect"));
|
new JavaBehaviour(this, "onRemoveAspect"));
|
||||||
|
|
||||||
// Register interest in the onCreateNode policy
|
// Register interest in the onCreateNode policy
|
||||||
policyComponent.bindClassBehaviour(
|
policyComponent.bindClassBehaviour(
|
||||||
QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"),
|
QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"),
|
||||||
this,
|
this,
|
||||||
new JavaBehaviour(this, "onCreateNode"));
|
new JavaBehaviour(this, "onCreateNode"));
|
||||||
|
|
||||||
// Create the transaction listener
|
// Create the transaction listener
|
||||||
@@ -276,25 +276,25 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda
|
|||||||
*/
|
*/
|
||||||
public void onContentUpdate(NodeRef nodeRef, boolean newContent)
|
public void onContentUpdate(NodeRef nodeRef, boolean newContent)
|
||||||
{
|
{
|
||||||
if (logger.isTraceEnabled())
|
if (logger.isTraceEnabled())
|
||||||
{
|
{
|
||||||
logger.trace("onContentUpdate: nodeRef="+nodeRef+ " ["+AlfrescoTransactionSupport.getTransactionId()+"]");
|
logger.trace("onContentUpdate: nodeRef="+nodeRef+ " ["+AlfrescoTransactionSupport.getTransactionId()+"]");
|
||||||
}
|
}
|
||||||
|
|
||||||
queueModel(nodeRef);
|
queueModel(nodeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void queueModel(NodeRef nodeRef)
|
private void queueModel(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
Set<NodeRef> pendingModels = (Set<NodeRef>)AlfrescoTransactionSupport.getResource(KEY_PENDING_MODELS);
|
Set<NodeRef> pendingModels = (Set<NodeRef>)AlfrescoTransactionSupport.getResource(KEY_PENDING_MODELS);
|
||||||
if (pendingModels == null)
|
if (pendingModels == null)
|
||||||
{
|
{
|
||||||
//pendingModels = Collections.newSetFromMap(new ConcurrentHashMap()); // Java 6
|
//pendingModels = Collections.newSetFromMap(new ConcurrentHashMap()); // Java 6
|
||||||
pendingModels = new CopyOnWriteArraySet<NodeRef>();
|
pendingModels = new CopyOnWriteArraySet<NodeRef>();
|
||||||
AlfrescoTransactionSupport.bindResource(KEY_PENDING_MODELS, pendingModels);
|
AlfrescoTransactionSupport.bindResource(KEY_PENDING_MODELS, pendingModels);
|
||||||
}
|
}
|
||||||
pendingModels.add(tenantService.getName(nodeRef));
|
pendingModels.add(tenantService.getName(nodeRef));
|
||||||
|
|
||||||
AlfrescoTransactionSupport.bindListener(this.transactionListener);
|
AlfrescoTransactionSupport.bindListener(this.transactionListener);
|
||||||
}
|
}
|
||||||
@@ -311,11 +311,11 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda
|
|||||||
Map<QName, Serializable> before,
|
Map<QName, Serializable> before,
|
||||||
Map<QName, Serializable> after)
|
Map<QName, Serializable> after)
|
||||||
{
|
{
|
||||||
if (logger.isTraceEnabled())
|
if (logger.isTraceEnabled())
|
||||||
{
|
{
|
||||||
logger.trace("onUpdateProperties: nodeRef="+nodeRef+ " ["+AlfrescoTransactionSupport.getTransactionId()+"]");
|
logger.trace("onUpdateProperties: nodeRef="+nodeRef+ " ["+AlfrescoTransactionSupport.getTransactionId()+"]");
|
||||||
}
|
}
|
||||||
|
|
||||||
Boolean beforeValue = (Boolean)before.get(ContentModel.PROP_MODEL_ACTIVE);
|
Boolean beforeValue = (Boolean)before.get(ContentModel.PROP_MODEL_ACTIVE);
|
||||||
Boolean afterValue = (Boolean)after.get(ContentModel.PROP_MODEL_ACTIVE);
|
Boolean afterValue = (Boolean)after.get(ContentModel.PROP_MODEL_ACTIVE);
|
||||||
|
|
||||||
@@ -336,40 +336,40 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda
|
|||||||
|
|
||||||
public void onRemoveAspect(NodeRef nodeRef, QName aspect)
|
public void onRemoveAspect(NodeRef nodeRef, QName aspect)
|
||||||
{
|
{
|
||||||
if (logger.isTraceEnabled())
|
if (logger.isTraceEnabled())
|
||||||
{
|
{
|
||||||
logger.trace("onRemoveAspect: nodeRef="+nodeRef+ " ["+AlfrescoTransactionSupport.getTransactionId()+"]");
|
logger.trace("onRemoveAspect: nodeRef="+nodeRef+ " ["+AlfrescoTransactionSupport.getTransactionId()+"]");
|
||||||
}
|
}
|
||||||
|
|
||||||
// undo/cancel checkout removes the "workingcopy" aspect prior to deleting the node - hence need to track here
|
// undo/cancel checkout removes the "workingcopy" aspect prior to deleting the node - hence need to track here
|
||||||
if (aspect.equals(ContentModel.ASPECT_WORKING_COPY))
|
if (aspect.equals(ContentModel.ASPECT_WORKING_COPY))
|
||||||
{
|
{
|
||||||
AlfrescoTransactionSupport.bindResource(KEY_WORKING_COPY, nodeRef);
|
AlfrescoTransactionSupport.bindResource(KEY_WORKING_COPY, nodeRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void beforeDeleteNode(NodeRef nodeRef)
|
public void beforeDeleteNode(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
boolean workingCopy = nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY);
|
boolean workingCopy = nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY);
|
||||||
NodeRef wcNodeRef = (NodeRef)AlfrescoTransactionSupport.getResource(KEY_WORKING_COPY);
|
NodeRef wcNodeRef = (NodeRef)AlfrescoTransactionSupport.getResource(KEY_WORKING_COPY);
|
||||||
if ((wcNodeRef != null) && (wcNodeRef.equals(nodeRef)))
|
if ((wcNodeRef != null) && (wcNodeRef.equals(nodeRef)))
|
||||||
{
|
{
|
||||||
workingCopy = true;
|
workingCopy = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isVersionNode = nodeRef.getStoreRef().getIdentifier().equals(Version2Model.STORE_ID);
|
boolean isVersionNode = nodeRef.getStoreRef().getIdentifier().equals(Version2Model.STORE_ID);
|
||||||
|
|
||||||
// Ignore if the node is a working copy or version node
|
// Ignore if the node is a working copy or version node
|
||||||
if (! (workingCopy || isVersionNode))
|
if (! (workingCopy || isVersionNode))
|
||||||
{
|
{
|
||||||
QName modelName = (QName)this.nodeService.getProperty(nodeRef, ContentModel.PROP_MODEL_NAME);
|
QName modelName = (QName)this.nodeService.getProperty(nodeRef, ContentModel.PROP_MODEL_NAME);
|
||||||
|
|
||||||
if (logger.isTraceEnabled())
|
if (logger.isTraceEnabled())
|
||||||
{
|
{
|
||||||
logger.trace("beforeDeleteNode: nodeRef="+nodeRef+" validate model delete (modelName="+modelName+")");
|
logger.trace("beforeDeleteNode: nodeRef="+nodeRef+" validate model delete (modelName="+modelName+")");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modelName != null)
|
if (modelName != null)
|
||||||
{
|
{
|
||||||
// Validate model delete against usages - content and/or workflows
|
// Validate model delete against usages - content and/or workflows
|
||||||
@@ -378,8 +378,8 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda
|
|||||||
Set<NodeRef> pendingModelDeletes = (Set<NodeRef>)AlfrescoTransactionSupport.getResource(KEY_PENDING_DELETE_MODELS);
|
Set<NodeRef> pendingModelDeletes = (Set<NodeRef>)AlfrescoTransactionSupport.getResource(KEY_PENDING_DELETE_MODELS);
|
||||||
if (pendingModelDeletes == null)
|
if (pendingModelDeletes == null)
|
||||||
{
|
{
|
||||||
//pendingModelDeletes = Collections.newSetFromMap(new ConcurrentHashMap()); // Java 6
|
//pendingModelDeletes = Collections.newSetFromMap(new ConcurrentHashMap()); // Java 6
|
||||||
pendingModelDeletes = new CopyOnWriteArraySet<NodeRef>();
|
pendingModelDeletes = new CopyOnWriteArraySet<NodeRef>();
|
||||||
AlfrescoTransactionSupport.bindResource(KEY_PENDING_DELETE_MODELS, pendingModelDeletes);
|
AlfrescoTransactionSupport.bindResource(KEY_PENDING_DELETE_MODELS, pendingModelDeletes);
|
||||||
}
|
}
|
||||||
pendingModelDeletes.add(tenantService.getName(nodeRef));
|
pendingModelDeletes.add(tenantService.getName(nodeRef));
|
||||||
@@ -387,26 +387,26 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda
|
|||||||
AlfrescoTransactionSupport.bindListener(this.transactionListener);
|
AlfrescoTransactionSupport.bindListener(this.transactionListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (logger.isTraceEnabled())
|
if (logger.isTraceEnabled())
|
||||||
{
|
{
|
||||||
logger.trace("beforeDeleteNode: nodeRef="+nodeRef+ " ignored ("+(workingCopy ? " workingCopy " : "")+(isVersionNode ? " isVersionNode " : "")+") ["+AlfrescoTransactionSupport.getTransactionId()+"]");
|
logger.trace("beforeDeleteNode: nodeRef="+nodeRef+ " ignored ("+(workingCopy ? " workingCopy " : "")+(isVersionNode ? " isVersionNode " : "")+") ["+AlfrescoTransactionSupport.getTransactionId()+"]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//@SuppressWarnings("unchecked")
|
//@SuppressWarnings("unchecked")
|
||||||
public void onDeleteNode(ChildAssociationRef childAssocRef, boolean isNodeArchived)
|
public void onDeleteNode(ChildAssociationRef childAssocRef, boolean isNodeArchived)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
NodeRef nodeRef = childAssocRef.getChildRef();
|
NodeRef nodeRef = childAssocRef.getChildRef();
|
||||||
|
|
||||||
if (logger.isTraceEnabled())
|
if (logger.isTraceEnabled())
|
||||||
{
|
{
|
||||||
logger.trace("onDeleteNode: nodeRef="+nodeRef+ " ["+AlfrescoTransactionSupport.getTransactionId()+"]");
|
logger.trace("onDeleteNode: nodeRef="+nodeRef+ " ["+AlfrescoTransactionSupport.getTransactionId()+"]");
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<NodeRef> pendingDeleteModels = (Set<NodeRef>)AlfrescoTransactionSupport.getResource(KEY_PENDING_DELETE_MODELS);
|
Set<NodeRef> pendingDeleteModels = (Set<NodeRef>)AlfrescoTransactionSupport.getResource(KEY_PENDING_DELETE_MODELS);
|
||||||
|
|
||||||
if (pendingDeleteModels != null)
|
if (pendingDeleteModels != null)
|
||||||
@@ -426,32 +426,32 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}, tenantSystemUserName);
|
}, tenantSystemUserName);
|
||||||
|
|
||||||
if (logger.isTraceEnabled())
|
if (logger.isTraceEnabled())
|
||||||
{
|
{
|
||||||
logger.trace("onDeleteNode: Dictionary destroyed ["+AlfrescoTransactionSupport.getTransactionId()+"]");
|
logger.trace("onDeleteNode: Dictionary destroyed ["+AlfrescoTransactionSupport.getTransactionId()+"]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCreateNode(ChildAssociationRef childAssocRef)
|
public void onCreateNode(ChildAssociationRef childAssocRef)
|
||||||
{
|
{
|
||||||
NodeRef nodeRef = childAssocRef.getChildRef();
|
NodeRef nodeRef = childAssocRef.getChildRef();
|
||||||
|
|
||||||
if (logger.isTraceEnabled())
|
if (logger.isTraceEnabled())
|
||||||
{
|
{
|
||||||
logger.trace("onCreateNode: nodeRef="+nodeRef+ " ["+AlfrescoTransactionSupport.getTransactionId()+"]");
|
logger.trace("onCreateNode: nodeRef="+nodeRef+ " ["+AlfrescoTransactionSupport.getTransactionId()+"]");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodeService.getType(nodeRef).equals(ContentModel.TYPE_DICTIONARY_MODEL))
|
if (nodeService.getType(nodeRef).equals(ContentModel.TYPE_DICTIONARY_MODEL))
|
||||||
{
|
{
|
||||||
Boolean value = (Boolean)nodeService.getProperty(nodeRef, ContentModel.PROP_MODEL_ACTIVE);
|
Boolean value = (Boolean)nodeService.getProperty(nodeRef, ContentModel.PROP_MODEL_ACTIVE);
|
||||||
if ((value != null) && (value == true))
|
if ((value != null) && (value == true))
|
||||||
{
|
{
|
||||||
queueModel(nodeRef);
|
queueModel(nodeRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -474,81 +474,81 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda
|
|||||||
this.contentService = contentService;
|
this.contentService = contentService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public void afterCommit()
|
public void afterCommit()
|
||||||
{
|
{
|
||||||
Set<NodeRef> pendingModels = (Set<NodeRef>)AlfrescoTransactionSupport.getResource(KEY_PENDING_MODELS);
|
Set<NodeRef> pendingModels = (Set<NodeRef>)AlfrescoTransactionSupport.getResource(KEY_PENDING_MODELS);
|
||||||
Set<NodeRef> pendingDeleteModels = (Set<NodeRef>)AlfrescoTransactionSupport.getResource(KEY_PENDING_DELETE_MODELS);
|
Set<NodeRef> pendingDeleteModels = (Set<NodeRef>)AlfrescoTransactionSupport.getResource(KEY_PENDING_DELETE_MODELS);
|
||||||
|
|
||||||
if (logger.isTraceEnabled())
|
if (logger.isTraceEnabled())
|
||||||
{
|
{
|
||||||
logger.trace("afterCommit: pendingModelsCnt="+(pendingModels != null ? pendingModels.size() : "0")+
|
logger.trace("afterCommit: pendingModelsCnt="+(pendingModels != null ? pendingModels.size() : "0")+
|
||||||
", pendingDeleteModelsCnt="+(pendingDeleteModels != null ? pendingDeleteModels.size() : "0"));
|
", pendingDeleteModelsCnt="+(pendingDeleteModels != null ? pendingDeleteModels.size() : "0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<String> systemTenants = new HashSet<String>(10);
|
Set<String> systemTenants = new HashSet<String>(10);
|
||||||
|
|
||||||
if (pendingModels != null)
|
if (pendingModels != null)
|
||||||
{
|
{
|
||||||
// unbind the resource from the transaction
|
// unbind the resource from the transaction
|
||||||
AlfrescoTransactionSupport.unbindResource(KEY_PENDING_MODELS);
|
AlfrescoTransactionSupport.unbindResource(KEY_PENDING_MODELS);
|
||||||
|
|
||||||
for (NodeRef nodeRef : pendingModels)
|
for (NodeRef nodeRef : pendingModels)
|
||||||
{
|
{
|
||||||
String tenantDomain = tenantService.getDomain(nodeRef.getStoreRef().getIdentifier());
|
String tenantDomain = tenantService.getDomain(nodeRef.getStoreRef().getIdentifier());
|
||||||
String tenantSystemUserName = tenantService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantDomain);
|
String tenantSystemUserName = tenantService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantDomain);
|
||||||
systemTenants.add(tenantSystemUserName);
|
systemTenants.add(tenantSystemUserName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pendingDeleteModels != null)
|
if (pendingDeleteModels != null)
|
||||||
{
|
{
|
||||||
// unbind the resource from the transaction
|
// unbind the resource from the transaction
|
||||||
AlfrescoTransactionSupport.unbindResource(KEY_PENDING_DELETE_MODELS);
|
AlfrescoTransactionSupport.unbindResource(KEY_PENDING_DELETE_MODELS);
|
||||||
|
|
||||||
for (NodeRef nodeRef : pendingDeleteModels)
|
for (NodeRef nodeRef : pendingDeleteModels)
|
||||||
{
|
{
|
||||||
String tenantDomain = tenantService.getDomain(nodeRef.getStoreRef().getIdentifier());
|
String tenantDomain = tenantService.getDomain(nodeRef.getStoreRef().getIdentifier());
|
||||||
String tenantSystemUserName = tenantService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantDomain);
|
String tenantSystemUserName = tenantService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantDomain);
|
||||||
systemTenants.add(tenantSystemUserName);
|
systemTenants.add(tenantSystemUserName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (systemTenants.size() > 0)
|
if (systemTenants.size() > 0)
|
||||||
{
|
{
|
||||||
for (final String tenantSystemUserName : systemTenants)
|
for (final String tenantSystemUserName : systemTenants)
|
||||||
{
|
{
|
||||||
RetryingTransactionCallback<Void> work = new RetryingTransactionCallback<Void>()
|
RetryingTransactionCallback<Void> work = new RetryingTransactionCallback<Void>()
|
||||||
{
|
{
|
||||||
public Void execute() throws Throwable
|
public Void execute() throws Throwable
|
||||||
{
|
{
|
||||||
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
||||||
{
|
{
|
||||||
public Object doWork()
|
public Object doWork()
|
||||||
{
|
{
|
||||||
// invalidate - to force lazy re-init
|
// invalidate - to force lazy re-init
|
||||||
// note: since afterCommit - need to either clear shared cache or destroy in separate txn
|
// note: since afterCommit - need to either clear shared cache or destroy in separate txn
|
||||||
dictionaryDAO.destroy();
|
dictionaryDAO.destroy();
|
||||||
|
|
||||||
if (logger.isTraceEnabled())
|
if (logger.isTraceEnabled())
|
||||||
{
|
{
|
||||||
logger.trace("afterCommit: Dictionary destroyed ["+AlfrescoTransactionSupport.getTransactionId()+"]");
|
logger.trace("afterCommit: Dictionary destroyed ["+AlfrescoTransactionSupport.getTransactionId()+"]");
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}, tenantSystemUserName);
|
}, tenantSystemUserName);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
transactionService.getRetryingTransactionHelper().doInTransaction(work, true, true);
|
transactionService.getRetryingTransactionHelper().doInTransaction(work, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.repo.transaction.TransactionListener#beforeCommit(boolean)
|
* @see org.alfresco.repo.transaction.TransactionListener#beforeCommit(boolean)
|
||||||
*/
|
*/
|
||||||
@@ -560,9 +560,9 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda
|
|||||||
|
|
||||||
if (pendingModels != null)
|
if (pendingModels != null)
|
||||||
{
|
{
|
||||||
if (logger.isTraceEnabled())
|
if (logger.isTraceEnabled())
|
||||||
{
|
{
|
||||||
logger.trace("beforeCommit: pendingModelsCnt="+pendingModels.size());
|
logger.trace("beforeCommit: pendingModelsCnt="+pendingModels.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (NodeRef pendingNodeRef : pendingModels)
|
for (NodeRef pendingNodeRef : pendingModels)
|
||||||
@@ -576,12 +576,12 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda
|
|||||||
{
|
{
|
||||||
public Object doWork()
|
public Object doWork()
|
||||||
{
|
{
|
||||||
// Ignore if the node no longer exists
|
// Ignore if the node no longer exists
|
||||||
if (! nodeService.exists(nodeRef))
|
if (! nodeService.exists(nodeRef))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find out whether the model is active
|
// Find out whether the model is active
|
||||||
boolean isActive = false;
|
boolean isActive = false;
|
||||||
Boolean value = (Boolean)nodeService.getProperty(nodeRef, ContentModel.PROP_MODEL_ACTIVE);
|
Boolean value = (Boolean)nodeService.getProperty(nodeRef, ContentModel.PROP_MODEL_ACTIVE);
|
||||||
@@ -590,12 +590,12 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda
|
|||||||
isActive = value.booleanValue();
|
isActive = value.booleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore if the node is a working copy
|
// Ignore if the node is a working copy
|
||||||
if (! (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY)))
|
if (! (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY)))
|
||||||
{
|
{
|
||||||
if (isActive == true)
|
if (isActive == true)
|
||||||
{
|
{
|
||||||
// 1. Compile the model and update the details on the node
|
// 1. Compile the model and update the details on the node
|
||||||
// 2. Re-put the model
|
// 2. Re-put the model
|
||||||
|
|
||||||
ContentReader contentReader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT);
|
ContentReader contentReader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT);
|
||||||
@@ -605,8 +605,8 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda
|
|||||||
M2Model m2Model = M2Model.createModel(contentReader.getContentInputStream());
|
M2Model m2Model = M2Model.createModel(contentReader.getContentInputStream());
|
||||||
|
|
||||||
// Try and compile the model
|
// Try and compile the model
|
||||||
CompiledModel compiledModel= m2Model.compile(dictionaryDAO, namespaceDAO);
|
CompiledModel compiledModel= m2Model.compile(dictionaryDAO, namespaceDAO);
|
||||||
ModelDefinition modelDefinition = compiledModel.getModelDefinition();
|
ModelDefinition modelDefinition = compiledModel.getModelDefinition();
|
||||||
|
|
||||||
// Update the meta data for the model
|
// Update the meta data for the model
|
||||||
Map<QName, Serializable> props = nodeService.getProperties(nodeRef);
|
Map<QName, Serializable> props = nodeService.getProperties(nodeRef);
|
||||||
@@ -617,16 +617,16 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda
|
|||||||
props.put(ContentModel.PROP_MODEL_VERSION, modelDefinition.getVersion());
|
props.put(ContentModel.PROP_MODEL_VERSION, modelDefinition.getVersion());
|
||||||
nodeService.setProperties(nodeRef, props);
|
nodeService.setProperties(nodeRef, props);
|
||||||
|
|
||||||
// Validate model against dictionary - could be new, unchanged or updated
|
// Validate model against dictionary - could be new, unchanged or updated
|
||||||
validateModel(modelDefinition.getName(), m2Model, compiledModel);
|
validateModel(modelDefinition.getName(), m2Model, compiledModel);
|
||||||
|
|
||||||
// invalidate - to force lazy re-init
|
// invalidate - to force lazy re-init
|
||||||
//dictionaryDAO.destroy();
|
//dictionaryDAO.destroy();
|
||||||
|
|
||||||
if (logger.isTraceEnabled())
|
if (logger.isTraceEnabled())
|
||||||
{
|
{
|
||||||
logger.trace("beforeCommit: activating nodeRef="+nodeRef+" ("+modelDefinition.getName()+")");
|
logger.trace("beforeCommit: activating nodeRef="+nodeRef+" ("+modelDefinition.getName()+")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -638,12 +638,12 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda
|
|||||||
validateModelDelete(modelName);
|
validateModelDelete(modelName);
|
||||||
|
|
||||||
// invalidate - to force lazy re-init
|
// invalidate - to force lazy re-init
|
||||||
//dictionaryDAO.destroy();
|
//dictionaryDAO.destroy();
|
||||||
|
|
||||||
if (logger.isTraceEnabled())
|
if (logger.isTraceEnabled())
|
||||||
{
|
{
|
||||||
logger.trace("beforeCommit: deactivating nodeRef="+nodeRef+" ("+modelName+")");
|
logger.trace("beforeCommit: deactivating nodeRef="+nodeRef+" ("+modelName+")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -685,7 +685,7 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda
|
|||||||
private void validateModelDelete(final QName modelName)
|
private void validateModelDelete(final QName modelName)
|
||||||
{
|
{
|
||||||
// TODO add model locking during delete (would need to be tenant-aware & cluster-aware) to avoid potential
|
// TODO add model locking during delete (would need to be tenant-aware & cluster-aware) to avoid potential
|
||||||
// for concurrent addition of new content/workflow as model is being deleted
|
// for concurrent addition of new content/workflow as model is being deleted
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -693,11 +693,11 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda
|
|||||||
}
|
}
|
||||||
catch (DictionaryException e)
|
catch (DictionaryException e)
|
||||||
{
|
{
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
logger.debug("Dictionary model '" + modelName + "' does not exist ... skip delete validation : " + e);
|
logger.debug("Dictionary model '" + modelName + "' does not exist ... skip delete validation : " + e);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO - in case of MT we do not currently allow deletion of an overridden model (with usages) ... but could allow if (re-)inherited model is equivalent to an incremental update only ?
|
// TODO - in case of MT we do not currently allow deletion of an overridden model (with usages) ... but could allow if (re-)inherited model is equivalent to an incremental update only ?
|
||||||
@@ -803,162 +803,162 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* validate against dictionary
|
* validate against dictionary
|
||||||
*
|
*
|
||||||
* if new model
|
* if new model
|
||||||
* then nothing to validate
|
* then nothing to validate
|
||||||
*
|
*
|
||||||
* else if an existing model
|
* else if an existing model
|
||||||
* then could be updated (or unchanged) so validate to currently only allow incremental updates
|
* then could be updated (or unchanged) so validate to currently only allow incremental updates
|
||||||
* - addition of new types, aspects (except default aspects), properties, associations
|
* - addition of new types, aspects (except default aspects), properties, associations
|
||||||
* - no deletion of types, aspects or properties or associations
|
* - no deletion of types, aspects or properties or associations
|
||||||
* - no addition, update or deletion of default/mandatory aspects
|
* - no addition, update or deletion of default/mandatory aspects
|
||||||
*
|
*
|
||||||
* @paramn modelName
|
* @paramn modelName
|
||||||
* @param newOrUpdatedModel
|
* @param newOrUpdatedModel
|
||||||
*/
|
*/
|
||||||
private void validateModel(QName modelName, M2Model model, CompiledModel compiledModel)
|
private void validateModel(QName modelName, M2Model model, CompiledModel compiledModel)
|
||||||
{
|
{
|
||||||
List<M2ModelDiff> modelDiffs = dictionaryDAO.diffModel(model);
|
List<M2ModelDiff> modelDiffs = dictionaryDAO.diffModel(model);
|
||||||
|
|
||||||
for (M2ModelDiff modelDiff : modelDiffs)
|
for (M2ModelDiff modelDiff : modelDiffs)
|
||||||
{
|
{
|
||||||
if (modelDiff.getDiffType().equals(M2ModelDiff.DIFF_DELETED))
|
if (modelDiff.getDiffType().equals(M2ModelDiff.DIFF_DELETED))
|
||||||
{
|
{
|
||||||
// TODO - check tenants if model is shared / inherited
|
// TODO - check tenants if model is shared / inherited
|
||||||
if (modelDiff.getElementType().equals(M2ModelDiff.TYPE_PROPERTY))
|
if (modelDiff.getElementType().equals(M2ModelDiff.TYPE_PROPERTY))
|
||||||
{
|
{
|
||||||
validatePropertyDelete(modelName, modelDiff.getElementName(), false);
|
validatePropertyDelete(modelName, modelDiff.getElementName(), false);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (modelDiff.getElementType().equals(M2ModelDiff.TYPE_CONSTRAINT))
|
else if (modelDiff.getElementType().equals(M2ModelDiff.TYPE_CONSTRAINT))
|
||||||
{
|
{
|
||||||
validateConstraintDelete(compiledModel, modelDiff.getElementName(), false);
|
validateConstraintDelete(compiledModel, modelDiff.getElementName(), false);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Failed to validate model update - found deleted " + modelDiff.getElementType() + " '" + modelDiff.getElementName() + "'");
|
throw new AlfrescoRuntimeException("Failed to validate model update - found deleted " + modelDiff.getElementType() + " '" + modelDiff.getElementName() + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modelDiff.getDiffType().equals(M2ModelDiff.DIFF_UPDATED))
|
if (modelDiff.getDiffType().equals(M2ModelDiff.DIFF_UPDATED))
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Failed to validate model update - found non-incrementally updated " + modelDiff.getElementType() + " '" + modelDiff.getElementName() + "'");
|
throw new AlfrescoRuntimeException("Failed to validate model update - found non-incrementally updated " + modelDiff.getElementType() + " '" + modelDiff.getElementName() + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO validate that any deleted constraints are not being referenced - else currently will become anon - or push down into model compilation (check backwards compatibility ...)
|
// TODO validate that any deleted constraints are not being referenced - else currently will become anon - or push down into model compilation (check backwards compatibility ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validatePropertyDelete(QName modelName, QName propertyName, boolean sharedModel)
|
private void validatePropertyDelete(QName modelName, QName propertyName, boolean sharedModel)
|
||||||
{
|
{
|
||||||
String tenantDomain = TenantService.DEFAULT_DOMAIN;
|
String tenantDomain = TenantService.DEFAULT_DOMAIN;
|
||||||
if (sharedModel)
|
if (sharedModel)
|
||||||
{
|
{
|
||||||
tenantDomain = " for tenant [" + tenantService.getCurrentUserDomain() + "]";
|
tenantDomain = " for tenant [" + tenantService.getCurrentUserDomain() + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
|
|
||||||
// check for property usages
|
// check for property usages
|
||||||
for (PropertyDefinition prop : dictionaryDAO.getProperties(modelName, null))
|
for (PropertyDefinition prop : dictionaryDAO.getProperties(modelName, null))
|
||||||
{
|
{
|
||||||
// TODO ... match property
|
// TODO ... match property
|
||||||
if (prop.getName().equals(propertyName))
|
if (prop.getName().equals(propertyName))
|
||||||
{
|
{
|
||||||
// found
|
// found
|
||||||
found = true;
|
found = true;
|
||||||
validateIndexedProperty(tenantDomain, prop);
|
validateIndexedProperty(tenantDomain, prop);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! found)
|
if (! found)
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Failed to validate property delete" + tenantDomain + " - property definition '" + propertyName + "' not defined in model '" + modelName + "'");
|
throw new AlfrescoRuntimeException("Failed to validate property delete" + tenantDomain + " - property definition '" + propertyName + "' not defined in model '" + modelName + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateIndexedProperty(String tenantDomain, PropertyDefinition propDef)
|
private void validateIndexedProperty(String tenantDomain, PropertyDefinition propDef)
|
||||||
{
|
{
|
||||||
QName propName = propDef.getName();
|
QName propName = propDef.getName();
|
||||||
|
|
||||||
if (! propDef.isIndexed())
|
if (! propDef.isIndexed())
|
||||||
{
|
{
|
||||||
// TODO ... implement DB-level referential integrity
|
// TODO ... implement DB-level referential integrity
|
||||||
throw new AlfrescoRuntimeException("Failed to validate property delete" + tenantDomain + " - cannot delete unindexed property definition '" + propName);
|
throw new AlfrescoRuntimeException("Failed to validate property delete" + tenantDomain + " - cannot delete unindexed property definition '" + propName);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String storeUrl : this.storeUrls)
|
for (String storeUrl : this.storeUrls)
|
||||||
{
|
{
|
||||||
StoreRef store = new StoreRef(storeUrl);
|
StoreRef store = new StoreRef(storeUrl);
|
||||||
|
|
||||||
// search for indexed PROPERTY
|
// search for indexed PROPERTY
|
||||||
String escapePropName = propName.toPrefixString().replace(":", "\\:");
|
String escapePropName = propName.toPrefixString().replace(":", "\\:");
|
||||||
ResultSet rs = searchService.query(store, SearchService.LANGUAGE_LUCENE, "@"+escapePropName+":*");
|
ResultSet rs = searchService.query(store, SearchService.LANGUAGE_LUCENE, "@"+escapePropName+":*");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (rs.length() > 0)
|
if (rs.length() > 0)
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Failed to validate property delete" + tenantDomain + " - found " + rs.length() + " nodes in store " + store + " with PROPERTY '" + propName + "'" );
|
throw new AlfrescoRuntimeException("Failed to validate property delete" + tenantDomain + " - found " + rs.length() + " nodes in store " + store + " with PROPERTY '" + propName + "'" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
rs.close();
|
rs.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate delete of a referencable constraint def
|
// validate delete of a referencable constraint def
|
||||||
private void validateConstraintDelete(CompiledModel compiledModel, QName constraintName, boolean sharedModel)
|
private void validateConstraintDelete(CompiledModel compiledModel, QName constraintName, boolean sharedModel)
|
||||||
{
|
{
|
||||||
String tenantDomain = TenantService.DEFAULT_DOMAIN;
|
String tenantDomain = TenantService.DEFAULT_DOMAIN;
|
||||||
if (sharedModel)
|
if (sharedModel)
|
||||||
{
|
{
|
||||||
tenantDomain = " for tenant [" + tenantService.getCurrentUserDomain() + "]";
|
tenantDomain = " for tenant [" + tenantService.getCurrentUserDomain() + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<QName> referencedBy = new HashSet<QName>(0);
|
Set<QName> referencedBy = new HashSet<QName>(0);
|
||||||
|
|
||||||
// check for references to constraint definition
|
// check for references to constraint definition
|
||||||
// note: could be anon prop constraint (if no referenceable constraint)
|
// note: could be anon prop constraint (if no referenceable constraint)
|
||||||
Collection<QName> allModels = dictionaryDAO.getModels();
|
Collection<QName> allModels = dictionaryDAO.getModels();
|
||||||
for (QName model : allModels)
|
for (QName model : allModels)
|
||||||
{
|
{
|
||||||
Collection<PropertyDefinition> propDefs = null;
|
Collection<PropertyDefinition> propDefs = null;
|
||||||
if (compiledModel.getModelDefinition().getName().equals(model))
|
if (compiledModel.getModelDefinition().getName().equals(model))
|
||||||
{
|
{
|
||||||
// TODO deal with multiple pending model updates
|
// TODO deal with multiple pending model updates
|
||||||
propDefs = compiledModel.getProperties();
|
propDefs = compiledModel.getProperties();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
propDefs = dictionaryDAO.getProperties(model);
|
propDefs = dictionaryDAO.getProperties(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (PropertyDefinition propDef : propDefs)
|
for (PropertyDefinition propDef : propDefs)
|
||||||
{
|
{
|
||||||
for (ConstraintDefinition conDef : propDef.getConstraints())
|
for (ConstraintDefinition conDef : propDef.getConstraints())
|
||||||
{
|
{
|
||||||
if (constraintName.equals(conDef.getRef()))
|
if (constraintName.equals(conDef.getRef()))
|
||||||
{
|
{
|
||||||
referencedBy.add(conDef.getName());
|
referencedBy.add(conDef.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (referencedBy.size() == 1)
|
if (referencedBy.size() == 1)
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Failed to validate constraint delete" + tenantDomain + " - constraint definition '" + constraintName + "' is being referenced by '" + referencedBy.toArray()[0] + "' property constraint");
|
throw new AlfrescoRuntimeException("Failed to validate constraint delete" + tenantDomain + " - constraint definition '" + constraintName + "' is being referenced by '" + referencedBy.toArray()[0] + "' property constraint");
|
||||||
}
|
}
|
||||||
else if (referencedBy.size() > 1)
|
else if (referencedBy.size() > 1)
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Failed to validate constraint delete" + tenantDomain + " - constraint definition '" + constraintName + "' is being referenced by " + referencedBy.size() + " property constraints");
|
throw new AlfrescoRuntimeException("Failed to validate constraint delete" + tenantDomain + " - constraint definition '" + constraintName + "' is being referenced by " + referencedBy.size() + " property constraints");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -44,6 +44,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
|||||||
import org.alfresco.service.cmr.repository.Path;
|
import org.alfresco.service.cmr.repository.Path;
|
||||||
import org.alfresco.service.cmr.repository.Period;
|
import org.alfresco.service.cmr.repository.Period;
|
||||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||||
|
import org.alfresco.service.cmr.repository.datatype.TypeConverter.Converter;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.util.EqualsHelper;
|
import org.alfresco.util.EqualsHelper;
|
||||||
import org.alfresco.util.VersionNumber;
|
import org.alfresco.util.VersionNumber;
|
||||||
@@ -268,12 +269,36 @@ public class PropertyValue implements Cloneable, Serializable
|
|||||||
return ValueType.STRING;
|
return ValueType.STRING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (value instanceof String)
|
||||||
|
{
|
||||||
|
return ValueType.STRING;
|
||||||
|
}
|
||||||
return ValueType.DB_ATTRIBUTE;
|
return ValueType.DB_ATTRIBUTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
Serializable convert(Serializable value)
|
Serializable convert(Serializable value)
|
||||||
{
|
{
|
||||||
|
// NOTE: since 2.2.1, PropertyValue is only used by AVM (which does not natively support MLText, other than single/default string)
|
||||||
|
if (value != null)
|
||||||
|
{
|
||||||
|
if (value instanceof String)
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
else if (value instanceof MLText)
|
||||||
|
{
|
||||||
|
if (((MLText)value).size() <= 1)
|
||||||
|
{
|
||||||
|
return (String)((Converter<MLText, String>)DefaultTypeConverter.INSTANCE.getConverter(MLText.class, String.class)).convert((MLText)value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException("PropertyValue MLText is not supported for AVM");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return DefaultTypeConverter.INSTANCE.convert(MLText.class, value);
|
return DefaultTypeConverter.INSTANCE.convert(MLText.class, value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@@ -37,7 +37,6 @@ import org.springframework.context.ApplicationContext;
|
|||||||
*/
|
*/
|
||||||
public class PropertyValueTest extends TestCase
|
public class PropertyValueTest extends TestCase
|
||||||
{
|
{
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
||||||
|
|
||||||
public void testMLText()
|
public void testMLText()
|
||||||
@@ -54,11 +53,21 @@ public class PropertyValueTest extends TestCase
|
|||||||
PropertyValue propertyValue = new PropertyValue(DataTypeDefinition.MLTEXT, mlText);
|
PropertyValue propertyValue = new PropertyValue(DataTypeDefinition.MLTEXT, mlText);
|
||||||
assertNotNull("MLText not persisted as a string", propertyValue.getStringValue());
|
assertNotNull("MLText not persisted as a string", propertyValue.getStringValue());
|
||||||
|
|
||||||
// multiple languages
|
try
|
||||||
mlText = new MLText(Locale.GERMAN, "hallo");
|
{
|
||||||
mlText.addValue(Locale.ITALIAN, "ciao");
|
// multiple languages
|
||||||
propertyValue = new PropertyValue(DataTypeDefinition.MLTEXT, mlText);
|
mlText = new MLText(Locale.GERMAN, "hallo");
|
||||||
assertNotNull("MLText not persisted as an attribute", propertyValue.getAttributeValue());
|
mlText.addValue(Locale.ITALIAN, "ciao");
|
||||||
|
propertyValue = new PropertyValue(DataTypeDefinition.MLTEXT, mlText);
|
||||||
|
assertNotNull("MLText not persisted as an attribute", propertyValue.getAttributeValue());
|
||||||
|
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
catch (UnsupportedOperationException uoe)
|
||||||
|
{
|
||||||
|
// expected
|
||||||
|
// NOTE: since 2.2.1, PropertyValue is only used by AVM (which does not natively support MLText, other than single/default string)
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@@ -76,7 +76,7 @@ public class OnContentUpdateRuleTrigger extends RuleTriggerAbstractBase
|
|||||||
{
|
{
|
||||||
// Bind behaviour
|
// Bind behaviour
|
||||||
this.policyComponent.bindClassBehaviour(
|
this.policyComponent.bindClassBehaviour(
|
||||||
ContentServicePolicies.ON_CONTENT_UPDATE,
|
ContentServicePolicies.OnContentUpdatePolicy.QNAME,
|
||||||
this,
|
this,
|
||||||
new JavaBehaviour(this, "onContentUpdate"));
|
new JavaBehaviour(this, "onContentUpdate"));
|
||||||
}
|
}
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.security.permissions.impl.acegi;
|
package org.alfresco.repo.security.permissions.impl.acegi;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
@@ -120,26 +121,20 @@ public class FilteringResultSet extends ACLEntryAfterInvocationProvider implemen
|
|||||||
|
|
||||||
public List<NodeRef> getNodeRefs()
|
public List<NodeRef> getNodeRefs()
|
||||||
{
|
{
|
||||||
List<NodeRef> answer = unfiltered.getNodeRefs();
|
ArrayList<NodeRef> answer = new ArrayList<NodeRef>(length());
|
||||||
for (int i = unfiltered.length() - 1; i >= 0; i--)
|
for(ResultSetRow row : this)
|
||||||
{
|
{
|
||||||
if (!inclusionMask.get(i))
|
answer.add(row.getNodeRef());
|
||||||
{
|
|
||||||
answer.remove(i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return answer;
|
return answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ChildAssociationRef> getChildAssocRefs()
|
public List<ChildAssociationRef> getChildAssocRefs()
|
||||||
{
|
{
|
||||||
List<ChildAssociationRef> answer = unfiltered.getChildAssocRefs();
|
ArrayList<ChildAssociationRef> answer = new ArrayList<ChildAssociationRef>(length());
|
||||||
for (int i = unfiltered.length() - 1; i >= 0; i--)
|
for(ResultSetRow row : this)
|
||||||
{
|
{
|
||||||
if (!inclusionMask.get(i))
|
answer.add(row.getChildAssocRef());
|
||||||
{
|
|
||||||
answer.remove(i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return answer;
|
return answer;
|
||||||
}
|
}
|
||||||
|
@@ -81,6 +81,9 @@ public class FilteringResultSetTest extends TestCase
|
|||||||
filtering.setIncluded(i, true);
|
filtering.setIncluded(i, true);
|
||||||
assertEquals(1, filtering.length());
|
assertEquals(1, filtering.length());
|
||||||
assertEquals("n"+i, filtering.getNodeRef(0).getId());
|
assertEquals("n"+i, filtering.getNodeRef(0).getId());
|
||||||
|
assertEquals(1, filtering.getNodeRefs().size());
|
||||||
|
assertEquals(1, filtering.getChildAssocRefs().size());
|
||||||
|
assertEquals("n"+i, filtering.getNodeRefs().get(0).getId());
|
||||||
filtering.setIncluded(i, false);
|
filtering.setIncluded(i, false);
|
||||||
assertEquals(0, filtering.length());
|
assertEquals(0, filtering.length());
|
||||||
}
|
}
|
||||||
|
@@ -143,7 +143,7 @@ public class VersionableAspect implements ContentServicePolicies.OnContentUpdate
|
|||||||
new JavaBehaviour(this, "afterCreateVersion", Behaviour.NotificationFrequency.EVERY_EVENT));
|
new JavaBehaviour(this, "afterCreateVersion", Behaviour.NotificationFrequency.EVERY_EVENT));
|
||||||
|
|
||||||
this.policyComponent.bindClassBehaviour(
|
this.policyComponent.bindClassBehaviour(
|
||||||
ContentServicePolicies.ON_CONTENT_UPDATE,
|
ContentServicePolicies.OnContentUpdatePolicy.QNAME,
|
||||||
ContentModel.ASPECT_VERSIONABLE,
|
ContentModel.ASPECT_VERSIONABLE,
|
||||||
new JavaBehaviour(this, "onContentUpdate", Behaviour.NotificationFrequency.TRANSACTION_COMMIT));
|
new JavaBehaviour(this, "onContentUpdate", Behaviour.NotificationFrequency.TRANSACTION_COMMIT));
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This file is part of Alfresco
|
* This file is part of Alfresco
|
||||||
@@ -14,127 +14,127 @@
|
|||||||
* GNU Lesser General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.repo.workflow;
|
package org.alfresco.repo.workflow;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.repo.content.ContentServicePolicies;
|
import org.alfresco.repo.content.ContentServicePolicies;
|
||||||
import org.alfresco.repo.node.NodeServicePolicies;
|
import org.alfresco.repo.node.NodeServicePolicies;
|
||||||
import org.alfresco.repo.policy.JavaBehaviour;
|
import org.alfresco.repo.policy.JavaBehaviour;
|
||||||
import org.alfresco.repo.policy.PolicyComponent;
|
import org.alfresco.repo.policy.PolicyComponent;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Workflow Definition type behaviour.
|
* Workflow Definition type behaviour.
|
||||||
*
|
*
|
||||||
* @author JanV
|
* @author JanV
|
||||||
*/
|
*/
|
||||||
public class WorkflowDefinitionType implements ContentServicePolicies.OnContentUpdatePolicy,
|
public class WorkflowDefinitionType implements ContentServicePolicies.OnContentUpdatePolicy,
|
||||||
NodeServicePolicies.OnUpdatePropertiesPolicy,
|
NodeServicePolicies.OnUpdatePropertiesPolicy,
|
||||||
NodeServicePolicies.BeforeDeleteNodePolicy
|
NodeServicePolicies.BeforeDeleteNodePolicy
|
||||||
{
|
{
|
||||||
/** The policy component */
|
/** The policy component */
|
||||||
private PolicyComponent policyComponent;
|
private PolicyComponent policyComponent;
|
||||||
|
|
||||||
/** The workflow deployer / undeployer */
|
/** The workflow deployer / undeployer */
|
||||||
private WorkflowDeployer workflowDeployer;
|
private WorkflowDeployer workflowDeployer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the policy component
|
* Set the policy component
|
||||||
*
|
*
|
||||||
* @param policyComponent the policy component
|
* @param policyComponent the policy component
|
||||||
*/
|
*/
|
||||||
public void setPolicyComponent(PolicyComponent policyComponent)
|
public void setPolicyComponent(PolicyComponent policyComponent)
|
||||||
{
|
{
|
||||||
this.policyComponent = policyComponent;
|
this.policyComponent = policyComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the workflow deployer / undeployer
|
* Set the workflow deployer / undeployer
|
||||||
*
|
*
|
||||||
* @param workflowDeployer the workflow deployer / undeployer
|
* @param workflowDeployer the workflow deployer / undeployer
|
||||||
*/
|
*/
|
||||||
public void setWorkflowDeployer(WorkflowDeployer workflowDeployer)
|
public void setWorkflowDeployer(WorkflowDeployer workflowDeployer)
|
||||||
{
|
{
|
||||||
this.workflowDeployer = workflowDeployer;
|
this.workflowDeployer = workflowDeployer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The initialise method
|
* The initialise method
|
||||||
*/
|
*/
|
||||||
public void init()
|
public void init()
|
||||||
{
|
{
|
||||||
// Register interest in the onContentUpdate policy for the workflow definition type
|
// Register interest in the onContentUpdate policy for the workflow definition type
|
||||||
policyComponent.bindClassBehaviour(
|
policyComponent.bindClassBehaviour(
|
||||||
ContentServicePolicies.ON_CONTENT_UPDATE,
|
ContentServicePolicies.OnContentUpdatePolicy.QNAME,
|
||||||
WorkflowModel.TYPE_WORKFLOW_DEF,
|
WorkflowModel.TYPE_WORKFLOW_DEF,
|
||||||
new JavaBehaviour(this, "onContentUpdate"));
|
new JavaBehaviour(this, "onContentUpdate"));
|
||||||
|
|
||||||
// Register interest in the onPropertyUpdate policy for the workflow definition type
|
// Register interest in the onPropertyUpdate policy for the workflow definition type
|
||||||
policyComponent.bindClassBehaviour(
|
policyComponent.bindClassBehaviour(
|
||||||
QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"),
|
QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"),
|
||||||
WorkflowModel.TYPE_WORKFLOW_DEF,
|
WorkflowModel.TYPE_WORKFLOW_DEF,
|
||||||
new JavaBehaviour(this, "onUpdateProperties"));
|
new JavaBehaviour(this, "onUpdateProperties"));
|
||||||
|
|
||||||
// Register interest in the node delete policy
|
// Register interest in the node delete policy
|
||||||
policyComponent.bindClassBehaviour(
|
policyComponent.bindClassBehaviour(
|
||||||
QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"),
|
QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"),
|
||||||
WorkflowModel.TYPE_WORKFLOW_DEF,
|
WorkflowModel.TYPE_WORKFLOW_DEF,
|
||||||
new JavaBehaviour(this, "beforeDeleteNode"));
|
new JavaBehaviour(this, "beforeDeleteNode"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On content update behaviour implementation
|
* On content update behaviour implementation
|
||||||
*
|
*
|
||||||
* @param nodeRef the node reference whose content has been updated
|
* @param nodeRef the node reference whose content has been updated
|
||||||
*/
|
*/
|
||||||
public void onContentUpdate(NodeRef nodeRef, boolean newContent)
|
public void onContentUpdate(NodeRef nodeRef, boolean newContent)
|
||||||
{
|
{
|
||||||
workflowDeployer.deploy(nodeRef, true);
|
workflowDeployer.deploy(nodeRef, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On update properties behaviour implementation
|
* On update properties behaviour implementation
|
||||||
*
|
*
|
||||||
* @param nodeRef the node reference
|
* @param nodeRef the node reference
|
||||||
* @param before the values of the properties before update
|
* @param before the values of the properties before update
|
||||||
* @param after the values of the properties after the update
|
* @param after the values of the properties after the update
|
||||||
*/
|
*/
|
||||||
public void onUpdateProperties(
|
public void onUpdateProperties(
|
||||||
NodeRef nodeRef,
|
NodeRef nodeRef,
|
||||||
Map<QName, Serializable> before,
|
Map<QName, Serializable> before,
|
||||||
Map<QName, Serializable> after)
|
Map<QName, Serializable> after)
|
||||||
{
|
{
|
||||||
Boolean beforeValue = (Boolean)before.get(WorkflowModel.PROP_WORKFLOW_DEF_DEPLOYED);
|
Boolean beforeValue = (Boolean)before.get(WorkflowModel.PROP_WORKFLOW_DEF_DEPLOYED);
|
||||||
Boolean afterValue = (Boolean)after.get(WorkflowModel.PROP_WORKFLOW_DEF_DEPLOYED);
|
Boolean afterValue = (Boolean)after.get(WorkflowModel.PROP_WORKFLOW_DEF_DEPLOYED);
|
||||||
|
|
||||||
if (afterValue != null &&
|
if (afterValue != null &&
|
||||||
(beforeValue == null || (beforeValue != null && afterValue != null && beforeValue.equals(afterValue) == false)))
|
(beforeValue == null || (beforeValue != null && afterValue != null && beforeValue.equals(afterValue) == false)))
|
||||||
{
|
{
|
||||||
if (afterValue.booleanValue() == true)
|
if (afterValue.booleanValue() == true)
|
||||||
{
|
{
|
||||||
workflowDeployer.deploy(nodeRef, true);
|
workflowDeployer.deploy(nodeRef, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
workflowDeployer.undeploy(nodeRef);
|
workflowDeployer.undeploy(nodeRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (afterValue == null && beforeValue != null)
|
else if (afterValue == null && beforeValue != null)
|
||||||
{
|
{
|
||||||
// Undeploy the definition since the value has been cleared
|
// Undeploy the definition since the value has been cleared
|
||||||
workflowDeployer.undeploy(nodeRef);
|
workflowDeployer.undeploy(nodeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void beforeDeleteNode(NodeRef nodeRef)
|
public void beforeDeleteNode(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
workflowDeployer.undeploy(nodeRef);
|
workflowDeployer.undeploy(nodeRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user