mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-1623 (Move In-Place Record)
* Created a new service for the inplace record actions git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@80914 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -22,7 +22,7 @@ import java.util.List;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.AuditableActionExecuterAbstractBase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.InplaceRecordService;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
@@ -51,8 +51,8 @@ public class HideRecordAction extends AuditableActionExecuterAbstractBase
|
||||
/** Node service */
|
||||
private NodeService nodeService;
|
||||
|
||||
/** Record service */
|
||||
private RecordService recordService;
|
||||
/** Inplace record service */
|
||||
private InplaceRecordService inplaceRecordService;
|
||||
|
||||
/**
|
||||
* @param nodeService node service
|
||||
@@ -63,11 +63,11 @@ public class HideRecordAction extends AuditableActionExecuterAbstractBase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param recordService record service
|
||||
* @param inplaceRecordService inplace record service
|
||||
*/
|
||||
public void setRecordService(RecordService recordService)
|
||||
public void setInplaceRecordService(InplaceRecordService inplaceRecordService)
|
||||
{
|
||||
this.recordService = recordService;
|
||||
this.inplaceRecordService = inplaceRecordService;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,7 +87,7 @@ public class HideRecordAction extends AuditableActionExecuterAbstractBase
|
||||
else
|
||||
{
|
||||
// hide the record from the collaboration site
|
||||
recordService.hideRecord(actionedUponNodeRef);
|
||||
inplaceRecordService.hideRecord(actionedUponNodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -23,7 +23,7 @@ import java.util.List;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.AuditableActionExecuterAbstractBase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.InplaceRecordService;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
@@ -53,8 +53,8 @@ public class MoveDmRecordAction extends AuditableActionExecuterAbstractBase impl
|
||||
/** Node service */
|
||||
private NodeService nodeService;
|
||||
|
||||
/** Record service */
|
||||
private RecordService recordService;
|
||||
/** Inplace record service */
|
||||
private InplaceRecordService inplaceRecordService;
|
||||
|
||||
/**
|
||||
* Gets the node service
|
||||
@@ -77,23 +77,23 @@ public class MoveDmRecordAction extends AuditableActionExecuterAbstractBase impl
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the record service
|
||||
* Gets the inplace record service
|
||||
*
|
||||
* @return Record service
|
||||
* @return Inplace record service
|
||||
*/
|
||||
protected RecordService getRecordService()
|
||||
protected InplaceRecordService getInplaceRecordService()
|
||||
{
|
||||
return this.recordService;
|
||||
return this.inplaceRecordService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the record service
|
||||
* Sets the inplace record service
|
||||
*
|
||||
* @param recordService Record service
|
||||
* @param InplaceRecordService Inplace record service
|
||||
*/
|
||||
public void setRecordService(RecordService recordService)
|
||||
public void setInplaceRecordService(InplaceRecordService inplaceRecordService)
|
||||
{
|
||||
this.recordService = recordService;
|
||||
this.inplaceRecordService = inplaceRecordService;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,7 +110,7 @@ public class MoveDmRecordAction extends AuditableActionExecuterAbstractBase impl
|
||||
else
|
||||
{
|
||||
// Move the record within the collaboration site
|
||||
getRecordService().moveRecord(actionedUponNodeRef, getTargetNodeRef(action));
|
||||
getInplaceRecordService().moveRecord(actionedUponNodeRef, getTargetNodeRef(action));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.record;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Inplace Record Service Interface.
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.3
|
||||
*/
|
||||
public interface InplaceRecordService
|
||||
{
|
||||
/**
|
||||
* Hides a record within a collaboration site
|
||||
*
|
||||
* @param nodeRef The record which should be hidden
|
||||
*/
|
||||
void hideRecord(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* Moves a record within a collaboration site
|
||||
*
|
||||
* @param nodeRef The record which should be moved
|
||||
* @param targetNodeRef The target node reference where it should be moved to
|
||||
*/
|
||||
void moveRecord(NodeRef nodeRef, NodeRef targetNodeRef);
|
||||
}
|
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.record;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.service.cmr.model.FileExistsException;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileNotFoundException;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.site.SiteInfo;
|
||||
import org.alfresco.service.cmr.site.SiteService;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
|
||||
/**
|
||||
* Inplace record service implementation.
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.3
|
||||
*/
|
||||
public class InplaceRecordServiceImpl implements InplaceRecordService, RecordsManagementModel
|
||||
{
|
||||
/** Site service */
|
||||
private SiteService siteService;
|
||||
|
||||
/** Node service */
|
||||
private NodeService nodeService;
|
||||
|
||||
/** Extended security service */
|
||||
private ExtendedSecurityService extendedSecurityService;
|
||||
|
||||
/** File folder service */
|
||||
private FileFolderService fileFolderService;
|
||||
|
||||
/**
|
||||
* @param siteService site service
|
||||
*/
|
||||
public void setSiteService(SiteService siteService)
|
||||
{
|
||||
this.siteService = siteService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeService node service
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param extendedSecurityService extended security service
|
||||
*/
|
||||
public void setExtendedSecurityService(
|
||||
ExtendedSecurityService extendedSecurityService)
|
||||
{
|
||||
this.extendedSecurityService = extendedSecurityService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fileFolderService file folder service
|
||||
*/
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.record.InplaceRecordService#hideRecord(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public void hideRecord(final NodeRef nodeRef)
|
||||
{
|
||||
ParameterCheck.mandatory("NodeRef", nodeRef);
|
||||
|
||||
// do the work of hiding the record as the system user
|
||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork()
|
||||
{
|
||||
// remove the child association
|
||||
NodeRef originatingLocation = (NodeRef) nodeService.getProperty(nodeRef, PROP_RECORD_ORIGINATING_LOCATION);
|
||||
List<ChildAssociationRef> parentAssocs = nodeService.getParentAssocs(nodeRef);
|
||||
for (ChildAssociationRef childAssociationRef : parentAssocs)
|
||||
{
|
||||
if (!childAssociationRef.isPrimary() && childAssociationRef.getParentRef().equals(originatingLocation))
|
||||
{
|
||||
nodeService.removeChildAssociation(childAssociationRef);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// remove the extended security from the node
|
||||
// this prevents the users from continuing to see the record in searchs and other linked locations
|
||||
extendedSecurityService.removeAllExtendedSecurity(nodeRef);
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.record.InplaceRecordService#moveRecord(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public void moveRecord(final NodeRef nodeRef, final NodeRef targetNodeRef)
|
||||
{
|
||||
ParameterCheck.mandatory("nodeRef", nodeRef);
|
||||
ParameterCheck.mandatory("targetNodeRef", targetNodeRef);
|
||||
|
||||
NodeRef sourceParentNodeRef = null;
|
||||
|
||||
NodeRef originatingLocation = (NodeRef) nodeService.getProperty(nodeRef, PROP_RECORD_ORIGINATING_LOCATION);
|
||||
for (ChildAssociationRef parentAssoc : nodeService.getParentAssocs(nodeRef))
|
||||
{
|
||||
if (!parentAssoc.isPrimary() && parentAssoc.getParentRef().equals(originatingLocation))
|
||||
{
|
||||
sourceParentNodeRef = parentAssoc.getParentRef();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sourceParentNodeRef == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Could not find source parent node reference.");
|
||||
}
|
||||
|
||||
SiteInfo sourceSite = siteService.getSite(sourceParentNodeRef);
|
||||
SiteInfo targetSite = siteService.getSite(targetNodeRef);
|
||||
|
||||
if (!sourceSite.equals(targetSite))
|
||||
{
|
||||
throw new AlfrescoRuntimeException("The record can only be moved within the same collaboration site.");
|
||||
}
|
||||
|
||||
if (!sourceSite.getSitePreset().equals("site-dashboard"))
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Only records within a collaboration site can be moved.");
|
||||
}
|
||||
|
||||
final NodeRef source = sourceParentNodeRef;
|
||||
|
||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Move the record
|
||||
fileFolderService.moveFrom(nodeRef, source, targetNodeRef, null);
|
||||
|
||||
// Update the originating location property
|
||||
nodeService.setProperty(nodeRef, PROP_RECORD_ORIGINATING_LOCATION, targetNodeRef);
|
||||
}
|
||||
catch (FileExistsException | FileNotFoundException ex)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Can't move node: " + ex);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@@ -169,13 +169,6 @@ public interface RecordService
|
||||
*/
|
||||
void file(NodeRef record);
|
||||
|
||||
/**
|
||||
* Hides a record within a collaboration site
|
||||
*
|
||||
* @param nodeRef The record which should be hidden
|
||||
*/
|
||||
void hideRecord(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* Rejects a record with the provided reason
|
||||
*
|
||||
@@ -231,12 +224,4 @@ public interface RecordService
|
||||
* @param folder The folder in which the link will be created
|
||||
*/
|
||||
void link(NodeRef nodeRef, NodeRef folder);
|
||||
|
||||
/**
|
||||
* Moves a record within a collaboration site
|
||||
*
|
||||
* @param nodeRef The record which should be moved
|
||||
* @param targetNodeRef The target node reference where it should be moved to
|
||||
*/
|
||||
void moveRecord(NodeRef nodeRef, NodeRef targetNodeRef);
|
||||
}
|
||||
|
@@ -80,8 +80,6 @@ import org.alfresco.service.cmr.security.AccessPermission;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.OwnableService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.cmr.site.SiteInfo;
|
||||
import org.alfresco.service.cmr.site.SiteService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
@@ -196,9 +194,6 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
/** Permission service */
|
||||
private PermissionService permissionService;
|
||||
|
||||
/** Site service */
|
||||
private SiteService siteService;
|
||||
|
||||
/** list of available record meta-data aspects and the file plan types the are applicable to */
|
||||
private Map<QName, Set<QName>> recordMetaDataAspects;
|
||||
|
||||
@@ -320,14 +315,6 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param siteService site service
|
||||
*/
|
||||
public void setSiteService(SiteService siteService)
|
||||
{
|
||||
this.siteService = siteService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*/
|
||||
@@ -1049,41 +1036,6 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#hideRecord(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public void hideRecord(final NodeRef nodeRef)
|
||||
{
|
||||
ParameterCheck.mandatory("NodeRef", nodeRef);
|
||||
|
||||
// do the work of hiding the record as the system user
|
||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork()
|
||||
{
|
||||
// remove the child association
|
||||
NodeRef originatingLocation = (NodeRef) nodeService.getProperty(nodeRef, PROP_RECORD_ORIGINATING_LOCATION);
|
||||
List<ChildAssociationRef> parentAssocs = nodeService.getParentAssocs(nodeRef);
|
||||
for (ChildAssociationRef childAssociationRef : parentAssocs)
|
||||
{
|
||||
if (!childAssociationRef.isPrimary() && childAssociationRef.getParentRef().equals(originatingLocation))
|
||||
{
|
||||
nodeService.removeChildAssociation(childAssociationRef);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// remove the extended security from the node
|
||||
// this prevents the users from continuing to see the record in searchs and other linked locations
|
||||
extendedSecurityService.removeAllExtendedSecurity(nodeRef);
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#rejectRecord(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
|
||||
*/
|
||||
@@ -1488,68 +1440,4 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
nodeService.addChild(folder, nodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, nodeService.getProperty(nodeRef, ContentModel.PROP_NAME).toString()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#moveRecord(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public void moveRecord(final NodeRef nodeRef, final NodeRef targetNodeRef)
|
||||
{
|
||||
ParameterCheck.mandatory("nodeRef", nodeRef);
|
||||
ParameterCheck.mandatory("targetNodeRef", targetNodeRef);
|
||||
|
||||
NodeRef sourceParentNodeRef = null;
|
||||
|
||||
NodeRef originatingLocation = (NodeRef) nodeService.getProperty(nodeRef, PROP_RECORD_ORIGINATING_LOCATION);
|
||||
for (ChildAssociationRef parentAssoc : nodeService.getParentAssocs(nodeRef))
|
||||
{
|
||||
if (!parentAssoc.isPrimary() && parentAssoc.getParentRef().equals(originatingLocation))
|
||||
{
|
||||
sourceParentNodeRef = parentAssoc.getParentRef();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sourceParentNodeRef == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Could not find source parent node reference.");
|
||||
}
|
||||
|
||||
SiteInfo sourceSite = siteService.getSite(sourceParentNodeRef);
|
||||
SiteInfo targetSite = siteService.getSite(targetNodeRef);
|
||||
|
||||
if (!sourceSite.equals(targetSite))
|
||||
{
|
||||
throw new AlfrescoRuntimeException("The record can only be moved within the same collaboration site.");
|
||||
}
|
||||
|
||||
if (!sourceSite.getSitePreset().equals("site-dashboard"))
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Only records within a collaboration site can be moved.");
|
||||
}
|
||||
|
||||
final NodeRef source = sourceParentNodeRef;
|
||||
|
||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Move the record
|
||||
fileFolderService.moveFrom(nodeRef, source, targetNodeRef, null);
|
||||
|
||||
// Update the originating location property
|
||||
nodeService.setProperty(nodeRef, PROP_RECORD_ORIGINATING_LOCATION, targetNodeRef);
|
||||
}
|
||||
catch (FileExistsException | FileNotFoundException ex)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Can't move node: " + ex);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user