mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge branch 'feature/RM-4619_createFolderThroughFTP' into 'master'
RM-4619 - convert the folder nodes before setting identifier See merge request !89
This commit is contained in:
@@ -234,6 +234,11 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
|
||||
TYPE_RECORD_FOLDER,
|
||||
new JavaBehaviour(this, "recordFolderCreate", NotificationFrequency.TRANSACTION_COMMIT));
|
||||
|
||||
this.policyComponent.bindClassBehaviour(
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "onSetNodeType"),
|
||||
TYPE_RECORD_FOLDER,
|
||||
new JavaBehaviour(this, "convertedToOrFromRecordFolder", NotificationFrequency.TRANSACTION_COMMIT));
|
||||
|
||||
// Vital Records Review Details Rollup
|
||||
this.policyComponent.bindClassBehaviour(
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"),
|
||||
@@ -428,6 +433,30 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* On update type to or from record folder behaviour implementation
|
||||
* @param nodeRef the updated node
|
||||
* @param oldType the type the node had before update
|
||||
* @param newType the type the node has after update
|
||||
*/
|
||||
public void convertedToOrFromRecordFolder(final NodeRef nodeRef, final QName oldType, final QName newType)
|
||||
{
|
||||
AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
// If the node has been updated to a record folder
|
||||
if (newType.equals(TYPE_RECORD_FOLDER) && nodeService.exists(nodeRef))
|
||||
{
|
||||
applySearchAspect(nodeRef);
|
||||
setupDispositionScheduleProperties(nodeRef);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Helper method to setup the disposition schedule properties
|
||||
*
|
||||
|
@@ -65,7 +65,7 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
||||
public class RecordComponentIdentifierAspect extends BaseBehaviourBean
|
||||
implements NodeServicePolicies.OnUpdatePropertiesPolicy,
|
||||
NodeServicePolicies.BeforeDeleteNodePolicy,
|
||||
NodeServicePolicies.OnCreateNodePolicy,
|
||||
NodeServicePolicies.OnAddAspectPolicy,
|
||||
CopyServicePolicies.OnCopyCompletePolicy
|
||||
{
|
||||
/** I18N */
|
||||
@@ -258,7 +258,7 @@ public class RecordComponentIdentifierAspect extends BaseBehaviourBean
|
||||
notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT
|
||||
)
|
||||
@Override
|
||||
public void onCreateNode(final ChildAssociationRef childAssocRef)
|
||||
public void onAddAspect(final NodeRef nodeRef, final QName aspectTypeQName)
|
||||
{
|
||||
AuthenticationUtil.runAsSystem(new RunAsWork<Object>()
|
||||
{
|
||||
@@ -268,10 +268,9 @@ public class RecordComponentIdentifierAspect extends BaseBehaviourBean
|
||||
* 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))
|
||||
if(nodeService.exists(nodeRef) && nodeService.hasAspect(nodeRef, aspectTypeQName))
|
||||
{
|
||||
nodeService.setProperty(newNode, RecordsManagementModel.PROP_ID_IS_TEMPORARILY_EDITABLE, false);
|
||||
nodeService.setProperty(nodeRef, RecordsManagementModel.PROP_ID_IS_TEMPORARILY_EDITABLE, false);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@@ -137,7 +137,7 @@ public class RecordsManagementContainerType extends BaseBehaviourBean
|
||||
final NodeRef child = childAssocRef.getChildRef();
|
||||
if (nodeService.exists(child))
|
||||
{
|
||||
QName childType = nodeService.getType(child);
|
||||
QName childType = convertNodeToFileplanComponent(childAssocRef);
|
||||
|
||||
// We only care about "folder" or sub-types that are not hidden.
|
||||
// Some modules use hidden files to store information (see RM-3283)
|
||||
@@ -205,4 +205,39 @@ public class RecordsManagementContainerType extends BaseBehaviourBean
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Converted the child node to a fileplan component
|
||||
* The conversion is needed here to be able to generate the identifier
|
||||
* If there is no conversion rule for the created type nothing happens and the current type is returned
|
||||
*
|
||||
* @param childAssocRef reference to the new association
|
||||
* @return the new type of the child node
|
||||
*/
|
||||
protected QName convertNodeToFileplanComponent(final ChildAssociationRef childAssocRef)
|
||||
{
|
||||
NodeRef child = childAssocRef.getChildRef();
|
||||
QName childType = nodeService.getType(child);
|
||||
QName parentType = nodeService.getType(childAssocRef.getParentRef());
|
||||
|
||||
if(childType.equals(ContentModel.TYPE_FOLDER))
|
||||
{
|
||||
if(parentType.equals(TYPE_FILE_PLAN))
|
||||
{
|
||||
nodeService.setType(child, TYPE_RECORD_CATEGORY);
|
||||
return TYPE_RECORD_CATEGORY;
|
||||
}
|
||||
if(parentType.equals(TYPE_RECORD_CATEGORY))
|
||||
{
|
||||
nodeService.setType(child, TYPE_RECORD_FOLDER);
|
||||
return TYPE_RECORD_FOLDER;
|
||||
}
|
||||
if(parentType.equals(TYPE_UNFILED_RECORD_CONTAINER) || parentType.equals(TYPE_UNFILED_RECORD_FOLDER))
|
||||
{
|
||||
nodeService.setType(child, TYPE_UNFILED_RECORD_FOLDER);
|
||||
return TYPE_UNFILED_RECORD_FOLDER;
|
||||
}
|
||||
}
|
||||
return childType;
|
||||
}
|
||||
}
|
||||
|
@@ -76,6 +76,15 @@ public class UnfiledRecordContainerType extends BaseBehaviourBean
|
||||
@Behaviour(kind = BehaviourKind.ASSOCIATION)
|
||||
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNewNode)
|
||||
{
|
||||
// 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 folder subtypes to store information (see RM-3283).
|
||||
QName childType = nodeService.getType(childAssocRef.getChildRef());
|
||||
if (childType.equals(ContentModel.TYPE_FOLDER))
|
||||
{
|
||||
nodeService.setType(childAssocRef.getChildRef(), TYPE_UNFILED_RECORD_FOLDER);
|
||||
}
|
||||
|
||||
// check the created child is of an accepted type
|
||||
validateNewChildAssociationSubTypesIncluded(childAssocRef.getChildRef(), ACCEPTED_NON_UNIQUE_CHILD_TYPES);
|
||||
}
|
||||
|
@@ -55,6 +55,15 @@ public class UnfiledRecordFolderType extends BaseBehaviourBean
|
||||
@Behaviour(kind = BehaviourKind.ASSOCIATION)
|
||||
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNewNode)
|
||||
{
|
||||
// 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 folder subtypes to store information (see RM-3283).
|
||||
QName childType = nodeService.getType(childAssocRef.getChildRef());
|
||||
if (childType.equals(ContentModel.TYPE_FOLDER))
|
||||
{
|
||||
nodeService.setType(childAssocRef.getChildRef(), TYPE_UNFILED_RECORD_FOLDER);
|
||||
}
|
||||
|
||||
// check the created child is of an accepted type
|
||||
validateNewChildAssociationSubTypesIncluded(childAssocRef.getChildRef(), ACCEPTED_NON_UNIQUE_CHILD_TYPES);
|
||||
}
|
||||
|
Reference in New Issue
Block a user