mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge branch 'release/V2.5' into merge/Merge_RM-4997
Conflicts: rm-automation/src/test/java/org/alfresco/dataprep/RecordsManagementService.java rm-automation/src/test/java/org/alfresco/test/community/level2/filePlan/DestroyRecordFolderActions.java rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordsManagementContainerType.java rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java
This commit is contained in:
@@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
|
package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
|
||||||
|
|
||||||
|
import static org.alfresco.module.org_alfresco_module_rm.record.RecordUtils.appendIdentifierToName;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService;
|
import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
|
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
|
||||||
@@ -57,9 +59,9 @@ import org.alfresco.service.namespace.QName;
|
|||||||
public class RecordsManagementContainerType extends BaseBehaviourBean
|
public class RecordsManagementContainerType extends BaseBehaviourBean
|
||||||
implements NodeServicePolicies.OnCreateChildAssociationPolicy
|
implements NodeServicePolicies.OnCreateChildAssociationPolicy
|
||||||
{
|
{
|
||||||
/** behaviour name */
|
/** behaviour name */
|
||||||
private static final String BEHAVIOUR_NAME = "onCreateContainerType";
|
private static final String BEHAVIOUR_NAME = "onCreateContainerType";
|
||||||
|
|
||||||
/** identifier service */
|
/** identifier service */
|
||||||
protected IdentifierService identifierService;
|
protected IdentifierService identifierService;
|
||||||
|
|
||||||
@@ -95,25 +97,25 @@ public class RecordsManagementContainerType extends BaseBehaviourBean
|
|||||||
{
|
{
|
||||||
this.recordFolderService = recordFolderService;
|
this.recordFolderService = recordFolderService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disable the behaviours for this transaction
|
* Disable the behaviours for this transaction
|
||||||
*
|
*
|
||||||
* @since 2.3
|
* @since 2.3
|
||||||
*/
|
*/
|
||||||
public void disable()
|
public void disable()
|
||||||
{
|
{
|
||||||
getBehaviour(BEHAVIOUR_NAME).disable();
|
getBehaviour(BEHAVIOUR_NAME).disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable behaviours for this transaction
|
* Enable behaviours for this transaction
|
||||||
*
|
*
|
||||||
* @since 2.3
|
* @since 2.3
|
||||||
*/
|
*/
|
||||||
public void enable()
|
public void enable()
|
||||||
{
|
{
|
||||||
getBehaviour(BEHAVIOUR_NAME).enable();
|
getBehaviour(BEHAVIOUR_NAME).enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -122,7 +124,7 @@ public class RecordsManagementContainerType extends BaseBehaviourBean
|
|||||||
@Behaviour
|
@Behaviour
|
||||||
(
|
(
|
||||||
kind = BehaviourKind.ASSOCIATION,
|
kind = BehaviourKind.ASSOCIATION,
|
||||||
// Execute on first event to make all type conversions and set all the properties before transaction ends and response is returned
|
// 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,
|
notificationFrequency = NotificationFrequency.EVERY_EVENT,
|
||||||
name = BEHAVIOUR_NAME
|
name = BEHAVIOUR_NAME
|
||||||
)
|
)
|
||||||
@@ -171,6 +173,7 @@ public class RecordsManagementContainerType extends BaseBehaviourBean
|
|||||||
if (!nodeService.hasAspect(child, ASPECT_RECORD))
|
if (!nodeService.hasAspect(child, ASPECT_RECORD))
|
||||||
{
|
{
|
||||||
recordService.makeRecord(child);
|
recordService.makeRecord(child);
|
||||||
|
appendIdentifierToName(nodeService, child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -210,7 +213,7 @@ public class RecordsManagementContainerType extends BaseBehaviourBean
|
|||||||
* Converted the child node to a fileplan component
|
* Converted the child node to a fileplan component
|
||||||
* The conversion is needed here to be able to generate the identifier
|
* 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
|
* 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
|
* @param childAssocRef reference to the new association
|
||||||
* @return the new type of the child node
|
* @return the new type of the child node
|
||||||
*/
|
*/
|
||||||
|
@@ -27,11 +27,10 @@
|
|||||||
|
|
||||||
package org.alfresco.module.org_alfresco_module_rm.record;
|
package org.alfresco.module.org_alfresco_module_rm.record;
|
||||||
|
|
||||||
|
import static org.alfresco.module.org_alfresco_module_rm.record.RecordUtils.appendIdentifierToName;
|
||||||
import static org.alfresco.repo.policy.Behaviour.NotificationFrequency.FIRST_EVENT;
|
import static org.alfresco.repo.policy.Behaviour.NotificationFrequency.FIRST_EVENT;
|
||||||
import static org.alfresco.repo.policy.Behaviour.NotificationFrequency.TRANSACTION_COMMIT;
|
import static org.alfresco.repo.policy.Behaviour.NotificationFrequency.TRANSACTION_COMMIT;
|
||||||
import static org.alfresco.repo.policy.annotation.BehaviourKind.ASSOCIATION;
|
import static org.alfresco.repo.policy.annotation.BehaviourKind.ASSOCIATION;
|
||||||
import static org.apache.commons.lang.StringUtils.isNotBlank;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -429,7 +428,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
ContentData contentData = (ContentData) nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT);
|
ContentData contentData = (ContentData) nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT);
|
||||||
if (ContentData.hasContent(contentData) && contentData.getSize() > 0)
|
if (ContentData.hasContent(contentData) && contentData.getSize() > 0)
|
||||||
{
|
{
|
||||||
renameRecord(nodeRef);
|
appendIdentifierToName(nodeService, nodeRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -828,7 +827,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
|
|
||||||
// make the document a record
|
// make the document a record
|
||||||
makeRecord(nodeRef);
|
makeRecord(nodeRef);
|
||||||
renameRecord(nodeRef);
|
appendIdentifierToName(nodeService, nodeRef);
|
||||||
|
|
||||||
if (latestVersionRecord != null)
|
if (latestVersionRecord != null)
|
||||||
{
|
{
|
||||||
@@ -1037,7 +1036,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
|
|
||||||
// make record
|
// make record
|
||||||
makeRecord(record);
|
makeRecord(record);
|
||||||
renameRecord(record);
|
appendIdentifierToName(nodeService, record);
|
||||||
|
|
||||||
// remove added copy assocs
|
// remove added copy assocs
|
||||||
List<AssociationRef> recordAssocs = nodeService.getTargetAssocs(record, ContentModel.ASSOC_ORIGINAL);
|
List<AssociationRef> recordAssocs = nodeService.getTargetAssocs(record, ContentModel.ASSOC_ORIGINAL);
|
||||||
@@ -1172,7 +1171,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
{
|
{
|
||||||
// make record
|
// make record
|
||||||
makeRecord(record);
|
makeRecord(record);
|
||||||
renameRecord(record);
|
appendIdentifierToName(nodeService, record);
|
||||||
}
|
}
|
||||||
|
|
||||||
return record;
|
return record;
|
||||||
@@ -1223,7 +1222,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
|
|
||||||
if (TYPE_NON_ELECTRONIC_DOCUMENT.equals(nodeService.getType(document)))
|
if (TYPE_NON_ELECTRONIC_DOCUMENT.equals(nodeService.getType(document)))
|
||||||
{
|
{
|
||||||
renameRecord(document);
|
appendIdentifierToName(nodeService, document);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@@ -1792,34 +1791,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
{
|
{
|
||||||
if (!nodeService.hasAspect(nodeRef, ContentModel.ASPECT_HIDDEN) && !nodeService.hasAspect(nodeRef, ContentModel.ASPECT_LOCKABLE))
|
if (!nodeService.hasAspect(nodeRef, ContentModel.ASPECT_HIDDEN) && !nodeService.hasAspect(nodeRef, ContentModel.ASPECT_LOCKABLE))
|
||||||
{
|
{
|
||||||
renameRecord(nodeRef);
|
appendIdentifierToName(nodeService, nodeRef);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void renameRecord(NodeRef nodeRef)
|
|
||||||
{
|
|
||||||
// get the record id
|
|
||||||
String recordId = (String) nodeService.getProperty(nodeRef, PROP_IDENTIFIER);
|
|
||||||
|
|
||||||
if (isNotBlank(recordId))
|
|
||||||
{
|
|
||||||
// get the record name
|
|
||||||
String name = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
|
||||||
|
|
||||||
// rename the record
|
|
||||||
int dotIndex = name.lastIndexOf('.');
|
|
||||||
String prefix = name;
|
|
||||||
String postfix = "";
|
|
||||||
if (dotIndex > 0)
|
|
||||||
{
|
|
||||||
prefix = name.substring(0, dotIndex);
|
|
||||||
postfix = name.substring(dotIndex);
|
|
||||||
}
|
|
||||||
String recordName = prefix + " (" + recordId + ")" + postfix;
|
|
||||||
|
|
||||||
nodeService.setProperty(nodeRef, ContentModel.PROP_NAME, recordName);
|
|
||||||
|
|
||||||
LOGGER.debug("Rename " + name + " to " + recordName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* #%L
|
||||||
|
* Alfresco Records Management Module
|
||||||
|
* %%
|
||||||
|
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||||
|
* %%
|
||||||
|
* This file is part of the Alfresco software.
|
||||||
|
* -
|
||||||
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
|
* provided under the following open source license terms:
|
||||||
|
* -
|
||||||
|
* 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/>.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
|
package org.alfresco.module.org_alfresco_module_rm.record;
|
||||||
|
|
||||||
|
import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.PROP_IDENTIFIER;
|
||||||
|
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||||
|
import static org.apache.commons.lang.StringUtils.isNotBlank;
|
||||||
|
|
||||||
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Util class for records
|
||||||
|
*
|
||||||
|
* @author Tuna Aksoy
|
||||||
|
* @since 2.4
|
||||||
|
*/
|
||||||
|
public class RecordUtils
|
||||||
|
{
|
||||||
|
private RecordUtils()
|
||||||
|
{
|
||||||
|
// Will not be called
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends the record identifier to the name of the record
|
||||||
|
*
|
||||||
|
* @param nodeRef The node reference of the record.
|
||||||
|
*/
|
||||||
|
public static void appendIdentifierToName(NodeService nodeService, NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
mandatory("nodeService", nodeService);
|
||||||
|
mandatory("nodeRef", nodeRef);
|
||||||
|
|
||||||
|
// get the record id
|
||||||
|
String recordId = (String) nodeService.getProperty(nodeRef, PROP_IDENTIFIER);
|
||||||
|
|
||||||
|
if (isNotBlank(recordId))
|
||||||
|
{
|
||||||
|
// get the record name
|
||||||
|
String name = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||||
|
|
||||||
|
// rename the record
|
||||||
|
int dotIndex = name.lastIndexOf('.');
|
||||||
|
String prefix = name;
|
||||||
|
String postfix = "";
|
||||||
|
if (dotIndex > 0)
|
||||||
|
{
|
||||||
|
prefix = name.substring(0, dotIndex);
|
||||||
|
postfix = name.substring(dotIndex);
|
||||||
|
}
|
||||||
|
String recordName = prefix + " (" + recordId + ")" + postfix;
|
||||||
|
|
||||||
|
nodeService.setProperty(nodeRef, ContentModel.PROP_NAME, recordName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user