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:
Tuna Aksoy
2017-04-10 22:59:27 +01:00
3 changed files with 103 additions and 46 deletions

View File

@@ -27,6 +27,8 @@
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.module.org_alfresco_module_rm.identifier.IdentifierService;
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
@@ -57,8 +59,8 @@ import org.alfresco.service.namespace.QName;
public class RecordsManagementContainerType extends BaseBehaviourBean
implements NodeServicePolicies.OnCreateChildAssociationPolicy
{
/** behaviour name */
private static final String BEHAVIOUR_NAME = "onCreateContainerType";
/** behaviour name */
private static final String BEHAVIOUR_NAME = "onCreateContainerType";
/** identifier service */
protected IdentifierService identifierService;
@@ -103,7 +105,7 @@ public class RecordsManagementContainerType extends BaseBehaviourBean
*/
public void disable()
{
getBehaviour(BEHAVIOUR_NAME).disable();
getBehaviour(BEHAVIOUR_NAME).disable();
}
/**
@@ -113,7 +115,7 @@ public class RecordsManagementContainerType extends BaseBehaviourBean
*/
public void enable()
{
getBehaviour(BEHAVIOUR_NAME).enable();
getBehaviour(BEHAVIOUR_NAME).enable();
}
/**
@@ -171,6 +173,7 @@ public class RecordsManagementContainerType extends BaseBehaviourBean
if (!nodeService.hasAspect(child, ASPECT_RECORD))
{
recordService.makeRecord(child);
appendIdentifierToName(nodeService, child);
}
}
}

View File

@@ -27,11 +27,10 @@
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.TRANSACTION_COMMIT;
import static org.alfresco.repo.policy.annotation.BehaviourKind.ASSOCIATION;
import static org.apache.commons.lang.StringUtils.isNotBlank;
import java.io.Serializable;
import java.util.ArrayList;
@@ -429,7 +428,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
ContentData contentData = (ContentData) nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT);
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
makeRecord(nodeRef);
renameRecord(nodeRef);
appendIdentifierToName(nodeService, nodeRef);
if (latestVersionRecord != null)
{
@@ -1037,7 +1036,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
// make record
makeRecord(record);
renameRecord(record);
appendIdentifierToName(nodeService, record);
// remove added copy assocs
List<AssociationRef> recordAssocs = nodeService.getTargetAssocs(record, ContentModel.ASSOC_ORIGINAL);
@@ -1172,7 +1171,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
{
// make record
makeRecord(record);
renameRecord(record);
appendIdentifierToName(nodeService, record);
}
return record;
@@ -1223,7 +1222,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
if (TYPE_NON_ELECTRONIC_DOCUMENT.equals(nodeService.getType(document)))
{
renameRecord(document);
appendIdentifierToName(nodeService, document);
}
}
finally
@@ -1792,34 +1791,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
{
if (!nodeService.hasAspect(nodeRef, ContentModel.ASPECT_HIDDEN) && !nodeService.hasAspect(nodeRef, ContentModel.ASPECT_LOCKABLE))
{
renameRecord(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);
appendIdentifierToName(nodeService, nodeRef);
}
}
}

View File

@@ -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);
}
}
}