mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge branch 'feature-2.4/RM-4997' into release/V2.4
This commit is contained in:
@@ -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.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService;
|
||||
@@ -198,6 +200,7 @@ public class RecordsManagementContainerType extends BaseBehaviourBean
|
||||
if (!nodeService.hasAspect(child, ASPECT_RECORD))
|
||||
{
|
||||
recordService.makeRecord(child);
|
||||
appendIdentifierToName(nodeService, child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -27,10 +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;
|
||||
@@ -422,7 +422,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -831,7 +831,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
|
||||
// make the document a record
|
||||
makeRecord(nodeRef);
|
||||
renameRecord(nodeRef);
|
||||
appendIdentifierToName(nodeService, nodeRef);
|
||||
|
||||
if (latestVersionRecord != null)
|
||||
{
|
||||
@@ -927,7 +927,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);
|
||||
@@ -1062,7 +1062,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
{
|
||||
// make record
|
||||
makeRecord(record);
|
||||
renameRecord(record);
|
||||
appendIdentifierToName(nodeService, record);
|
||||
}
|
||||
|
||||
return record;
|
||||
@@ -1113,7 +1113,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
|
||||
if (TYPE_NON_ELECTRONIC_DOCUMENT.equals(nodeService.getType(document)))
|
||||
{
|
||||
renameRecord(document);
|
||||
appendIdentifierToName(nodeService, document);
|
||||
}
|
||||
}
|
||||
finally
|
||||
@@ -1714,42 +1714,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
{
|
||||
if (!nodeService.hasAspect(nodeRef, ContentModel.ASPECT_HIDDEN) && !nodeService.hasAspect(nodeRef, ContentModel.ASPECT_LOCKABLE))
|
||||
{
|
||||
renameRecord(nodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the record identifier to the name of the record
|
||||
*
|
||||
* @param nodeRef The node reference of the record.
|
||||
*/
|
||||
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);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Rename " + name + " to " + recordName);
|
||||
}
|
||||
appendIdentifierToName(nodeService, nodeRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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