mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge branch 'master' into feature/Update_Alfresco_Dependencies_5_2_d
Conflicts: pom.xml
This commit is contained in:
@@ -126,6 +126,7 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
|
||||
QName ASPECT_RECORD_COMPONENT_ID = QName.createQName(RM_URI, "recordComponentIdentifier");
|
||||
QName PROP_IDENTIFIER = QName.createQName(RM_URI, "identifier");
|
||||
QName PROP_DB_UNIQUENESS_ID = QName.createQName(RM_URI, "dbUniquenessId");
|
||||
QName PROP_ID_IS_TEMPORARILY_EDITABLE = QName.createQName(RM_URI, "idIsTemporarilyEditable");
|
||||
|
||||
// Vital record definition aspect
|
||||
QName ASPECT_VITAL_RECORD_DEFINITION = QName.createQName(RM_URI, "vitalRecordDefinition");
|
||||
|
@@ -47,6 +47,7 @@ import org.alfresco.repo.policy.annotation.BehaviourKind;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.service.cmr.attributes.AttributeService;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
@@ -64,6 +65,7 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
||||
public class RecordComponentIdentifierAspect extends BaseBehaviourBean
|
||||
implements NodeServicePolicies.OnUpdatePropertiesPolicy,
|
||||
NodeServicePolicies.BeforeDeleteNodePolicy,
|
||||
NodeServicePolicies.OnCreateNodePolicy,
|
||||
CopyServicePolicies.OnCopyCompletePolicy
|
||||
{
|
||||
/** I18N */
|
||||
@@ -127,7 +129,7 @@ public class RecordComponentIdentifierAspect extends BaseBehaviourBean
|
||||
if (newIdValue != null)
|
||||
{
|
||||
String oldIdValue = (String)before.get(PROP_IDENTIFIER);
|
||||
if (oldIdValue != null && !oldIdValue.equals(newIdValue))
|
||||
if (oldIdValue != null && !oldIdValue.equals(newIdValue) && !isRecordIdentifierEditable(nodeRef))
|
||||
{
|
||||
throw new IntegrityException(I18NUtil.getMessage(MSG_SET_ID, nodeRef.toString()), null);
|
||||
}
|
||||
@@ -140,6 +142,17 @@ public class RecordComponentIdentifierAspect extends BaseBehaviourBean
|
||||
}, AuthenticationUtil.getSystemUserName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method that checks if a record's identifier is temporarily editable
|
||||
* @param record the record to check
|
||||
* @return true if it is editable false otherwise
|
||||
*/
|
||||
private boolean isRecordIdentifierEditable(NodeRef record)
|
||||
{
|
||||
Boolean isEditableProperty = (Boolean)nodeService.getProperty(record, RecordsManagementModel.PROP_ID_IS_TEMPORARILY_EDITABLE);
|
||||
return isEditableProperty == null ? false : isEditableProperty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans up the {@link RecordsManagementModel#PROP_IDENTIFIER rma:identifier} property unique triplet.
|
||||
*
|
||||
@@ -230,7 +243,7 @@ public class RecordComponentIdentifierAspect extends BaseBehaviourBean
|
||||
// Do a blanket removal in case this is a contextual nodes
|
||||
attributeService.removeAttributes(CONTEXT_VALUE, nodeRef);
|
||||
}
|
||||
else
|
||||
else if(!beforeId.equals(afterId))
|
||||
{
|
||||
// This is a full update
|
||||
attributeService.updateOrCreateAttribute(
|
||||
@@ -238,4 +251,30 @@ public class RecordComponentIdentifierAspect extends BaseBehaviourBean
|
||||
CONTEXT_VALUE, contextNodeRef, afterId);
|
||||
}
|
||||
}
|
||||
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT
|
||||
)
|
||||
@Override
|
||||
public void onCreateNode(final ChildAssociationRef childAssocRef)
|
||||
{
|
||||
AuthenticationUtil.runAsSystem(new RunAsWork<Object>()
|
||||
{
|
||||
public Object doWork()
|
||||
{
|
||||
/*
|
||||
* When creating a new record the identifier is writable to allow the upload in multiple steps.
|
||||
* On transaction commit make the identifier read only (remove the editable aspect).
|
||||
*/
|
||||
NodeRef newNode = childAssocRef.getChildRef();
|
||||
if(nodeService.exists(newNode))
|
||||
{
|
||||
nodeService.setProperty(newNode, RecordsManagementModel.PROP_ID_IS_TEMPORARILY_EDITABLE, false);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@ package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
|
||||
@@ -213,6 +214,14 @@ public class FilePlanType extends BaseBehaviourBean
|
||||
@Override
|
||||
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew)
|
||||
{
|
||||
// We need to automatically cast the created folder to category if it is a plain folder
|
||||
// This occurs if the RM folder has been created via IMap, WebDav, etc. Don't check subtypes.
|
||||
// Some modules use hidden files to store information (see RM-3283)
|
||||
if (nodeService.getType(childAssocRef.getChildRef()).equals(ContentModel.TYPE_FOLDER))
|
||||
{
|
||||
nodeService.setType(childAssocRef.getChildRef(), TYPE_RECORD_CATEGORY);
|
||||
}
|
||||
|
||||
// check the created child is of an accepted type
|
||||
validateNewChildAssociation(childAssocRef.getParentRef(), childAssocRef.getChildRef(), ACCEPTED_UNIQUE_CHILD_TYPES, ACCEPTED_NON_UNIQUE_CHILD_TYPES);
|
||||
}
|
||||
|
@@ -31,6 +31,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
|
||||
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService;
|
||||
@@ -111,13 +112,22 @@ public class RecordCategoryType extends BaseBehaviourBean
|
||||
)
|
||||
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew)
|
||||
{
|
||||
NodeRef nodeRef = childAssocRef.getChildRef();
|
||||
NodeRef parentRef = childAssocRef.getParentRef();
|
||||
validateNewChildAssociation(parentRef, nodeRef, ACCEPTED_UNIQUE_CHILD_TYPES, ACCEPTED_NON_UNIQUE_CHILD_TYPES);
|
||||
QName childType = nodeService.getType(childAssocRef.getChildRef());
|
||||
|
||||
// We need to automatically cast the created folder to record folder if it is a plain folder
|
||||
// This occurs if the RM folder has been created via IMap, WebDav, etc. Don't check subtypes.
|
||||
// Some modules use hidden folders to store information (see RM-3283).
|
||||
if (childType.equals(ContentModel.TYPE_FOLDER))
|
||||
{
|
||||
nodeService.setType(childAssocRef.getChildRef(), TYPE_RECORD_FOLDER);
|
||||
}
|
||||
|
||||
validateNewChildAssociation(childAssocRef.getParentRef(), childAssocRef.getChildRef(), ACCEPTED_UNIQUE_CHILD_TYPES, ACCEPTED_NON_UNIQUE_CHILD_TYPES);
|
||||
|
||||
if (bNew)
|
||||
{
|
||||
// setup the record folder
|
||||
recordFolderService.setupRecordFolder(nodeRef);
|
||||
recordFolderService.setupRecordFolder(childAssocRef.getChildRef());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,9 +142,9 @@ public class RecordCategoryType extends BaseBehaviourBean
|
||||
policy = "alf:onCreateChildAssociation",
|
||||
notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT
|
||||
)
|
||||
public void onCreateChildAssociationOnCommit(ChildAssociationRef childAssocRef, boolean bNew)
|
||||
public void onCreateChildAssociationOnCommit(ChildAssociationRef childAssocRef, final boolean bNew)
|
||||
{
|
||||
final NodeRef recordCategory = childAssocRef.getChildRef();
|
||||
final NodeRef child = childAssocRef.getChildRef();
|
||||
|
||||
behaviourFilter.disableBehaviour();
|
||||
try
|
||||
@@ -145,7 +155,7 @@ public class RecordCategoryType extends BaseBehaviourBean
|
||||
public Void doWork()
|
||||
{
|
||||
// setup vital record definition
|
||||
vitalRecordService.setupVitalRecordDefinition(recordCategory);
|
||||
vitalRecordService.setupVitalRecordDefinition(child);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@@ -27,7 +27,6 @@
|
||||
|
||||
package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
|
||||
@@ -44,7 +43,6 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* rma:recordsManagementContainer behaviour bean.
|
||||
@@ -124,7 +122,8 @@ public class RecordsManagementContainerType extends BaseBehaviourBean
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.ASSOCIATION,
|
||||
notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT,
|
||||
// Execute on first event to make all type conversions and set all the properties before transaction ends and response is returned
|
||||
notificationFrequency = NotificationFrequency.EVERY_EVENT,
|
||||
name = BEHAVIOUR_NAME
|
||||
)
|
||||
public void onCreateChildAssociation(final ChildAssociationRef childAssocRef, boolean isNewNode)
|
||||
@@ -152,32 +151,6 @@ public class RecordsManagementContainerType extends BaseBehaviourBean
|
||||
}
|
||||
else
|
||||
{
|
||||
// We need to automatically cast the created folder to RM type if it is a plain folder
|
||||
// This occurs if the RM folder has been created via IMap, WebDav, etc
|
||||
if (!nodeService.hasAspect(child, ASPECT_FILE_PLAN_COMPONENT))
|
||||
{
|
||||
// Throw exception if the type is not cm:folder
|
||||
if (!ContentModel.TYPE_FOLDER.equals(childType))
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CANNOT_CAST_TO_RM_TYPE));
|
||||
}
|
||||
// check the type of the parent to determine what 'kind' of artifact to create
|
||||
NodeRef parent = childAssocRef.getParentRef();
|
||||
QName parentType = nodeService.getType(parent);
|
||||
|
||||
if (dictionaryService.isSubClass(parentType, TYPE_FILE_PLAN))
|
||||
{
|
||||
// create a rma:recordCategoty since we are in the root of the file plan
|
||||
nodeService.setType(child, TYPE_RECORD_CATEGORY);
|
||||
}
|
||||
else
|
||||
{
|
||||
// create a rma:recordFolder and initialise record folder
|
||||
nodeService.setType(child, TYPE_RECORD_FOLDER);
|
||||
recordFolderService.setupRecordFolder(child);
|
||||
}
|
||||
}
|
||||
|
||||
// Catch all to generate the rm id (assuming it doesn't already have one!)
|
||||
setIdenifierProperty(child);
|
||||
}
|
||||
@@ -223,8 +196,10 @@ public class RecordsManagementContainerType extends BaseBehaviourBean
|
||||
if (nodeService.hasAspect(nodeRef, ASPECT_FILE_PLAN_COMPONENT) &&
|
||||
nodeService.getProperty(nodeRef, PROP_IDENTIFIER) == null)
|
||||
{
|
||||
// Generate identifier and leave it editable until the transaction ends
|
||||
String id = identifierService.generateIdentifier(nodeRef);
|
||||
nodeService.setProperty(nodeRef, RecordsManagementModel.PROP_IDENTIFIER, id);
|
||||
nodeService.setProperty(nodeRef, RecordsManagementModel.PROP_ID_IS_TEMPORARILY_EDITABLE, true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@@ -44,6 +44,7 @@ import org.alfresco.query.PagingRequest;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.repo.security.authority.RMAuthority;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.AccessPermission;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
@@ -515,32 +516,40 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl
|
||||
private String createIPRGroup(String groupNamePrefix, Set<String> children, int index)
|
||||
{
|
||||
ParameterCheck.mandatory("groupNamePrefix", groupNamePrefix);
|
||||
|
||||
|
||||
// get the group name
|
||||
String groupShortName = getIPRGroupShortName(groupNamePrefix, children, index);
|
||||
|
||||
|
||||
// create group
|
||||
String group = authorityService.createAuthority(AuthorityType.GROUP, groupShortName, groupShortName, Collections.singleton(RMAuthority.ZONE_APP_RM));
|
||||
|
||||
// add root parent
|
||||
authorityService.addAuthority(getRootIRPGroup(), group);
|
||||
|
||||
// add children if provided
|
||||
if (children != null)
|
||||
String group;
|
||||
try
|
||||
{
|
||||
for (String child : children)
|
||||
group = authorityService.createAuthority(AuthorityType.GROUP, groupShortName, groupShortName, Collections.singleton(RMAuthority.ZONE_APP_RM));
|
||||
|
||||
// add root parent
|
||||
authorityService.addAuthority(getRootIRPGroup(), group);
|
||||
|
||||
// add children if provided
|
||||
if (children != null)
|
||||
{
|
||||
if (authorityService.authorityExists(child) &&
|
||||
!PermissionService.ALL_AUTHORITIES.equals(child))
|
||||
for (String child : children)
|
||||
{
|
||||
authorityService.addAuthority(group, child);
|
||||
if (authorityService.authorityExists(child) && !PermissionService.ALL_AUTHORITIES.equals(child))
|
||||
{
|
||||
authorityService.addAuthority(group, child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch(DuplicateChildNodeNameException ex)
|
||||
{
|
||||
// the group was concurrently created
|
||||
group = authorityService.getName(AuthorityType.GROUP, groupShortName);
|
||||
}
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Assign IPR groups to a node reference with the correct permissions.
|
||||
*
|
||||
|
Reference in New Issue
Block a user