mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Add active content to hold through rest api
This commit is contained in:
@@ -41,6 +41,7 @@ import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
@@ -108,6 +109,9 @@ public class HoldServiceImpl extends ServiceBaseImpl
|
||||
/** records management audit service */
|
||||
private RecordsManagementAuditService recordsManagementAuditService;
|
||||
|
||||
/** Capability service */
|
||||
private CapabilityService capabilityService;
|
||||
|
||||
/**
|
||||
* Set the file plan service
|
||||
*
|
||||
@@ -166,6 +170,14 @@ public class HoldServiceImpl extends ServiceBaseImpl
|
||||
this.recordsManagementAuditService = recordsManagementAuditService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param capabilityService capability service
|
||||
*/
|
||||
public void setCapabilityService(CapabilityService capabilityService)
|
||||
{
|
||||
this.capabilityService = capabilityService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise hold service
|
||||
*/
|
||||
@@ -563,7 +575,9 @@ public class HoldServiceImpl extends ServiceBaseImpl
|
||||
throw new IntegrityException(I18NUtil.getMessage("rm.hold.not-hold", holdName), null);
|
||||
}
|
||||
|
||||
if (permissionService.hasPermission(hold, RMPermissionModel.FILING) == AccessStatus.DENIED)
|
||||
if (permissionService.hasPermission(hold, RMPermissionModel.FILING) == AccessStatus.DENIED ||
|
||||
!AccessStatus.ALLOWED.equals(
|
||||
capabilityService.getCapabilityAccessState(hold, RMPermissionModel.ADD_TO_HOLD)))
|
||||
{
|
||||
throw new AccessDeniedException(I18NUtil.getMessage(MSG_ERR_ACCESS_DENIED));
|
||||
}
|
||||
|
@@ -33,9 +33,11 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.hold.HoldService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.json.JSONArray;
|
||||
@@ -68,6 +70,9 @@ public abstract class BaseHold extends DeclarativeWebScript
|
||||
/** node service */
|
||||
private NodeService nodeService;
|
||||
|
||||
/** Dictionary service */
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
/**
|
||||
* Set the hold service
|
||||
*
|
||||
@@ -95,13 +100,21 @@ public abstract class BaseHold extends DeclarativeWebScript
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeService node service
|
||||
* @param nodeService node service
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dictionaryService dictionary service
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hold service
|
||||
*
|
||||
@@ -130,7 +143,8 @@ public abstract class BaseHold extends DeclarativeWebScript
|
||||
* It will either add the item(s) to the hold(s) or remove it/them from the hold(s)
|
||||
*
|
||||
* @param holds List of hold {@link NodeRef}(s)
|
||||
* @param nodeRefs List of item {@link NodeRef}(s) (record(s) / record folder(s)) which will be either added to the hold(s) or removed from the hold(s)
|
||||
* @param nodeRefs List of item {@link NodeRef}(s) (record(s) / record folder(s) / active content(s)) which will be
|
||||
* either added to the hold(s) or removed from the hold(s)
|
||||
*/
|
||||
abstract void doAction(List<NodeRef> holds, List<NodeRef> nodeRefs);
|
||||
|
||||
@@ -163,7 +177,8 @@ public abstract class BaseHold extends DeclarativeWebScript
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to get the {@link NodeRef}s for the items(s) (record(s) / record folder(s)) which will be added to the hold(s)
|
||||
* Helper method to get the {@link NodeRef}s for the items(s) (record(s) / record folder(s) / active content(s))
|
||||
* which will be added to the hold(s)
|
||||
*
|
||||
* @param json The request content as JSON object
|
||||
* @return List of item {@link NodeRef}s which will be added to the hold(s)
|
||||
@@ -193,7 +208,7 @@ public abstract class BaseHold extends DeclarativeWebScript
|
||||
/**
|
||||
* Helper method for checking the node reference for an item
|
||||
*
|
||||
* @param nodeRef The {@link NodeRef} of an item (record / record folder)
|
||||
* @param nodeRef The {@link NodeRef} of an item (record / record folder / active content)
|
||||
*/
|
||||
private void checkItemNodeRef(NodeRef nodeRef)
|
||||
{
|
||||
@@ -203,15 +218,16 @@ public abstract class BaseHold extends DeclarativeWebScript
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Item being added to hold does not exist.");
|
||||
}
|
||||
|
||||
// ensure that the node we are adding to the hold is a record or record folder
|
||||
if (!recordService.isRecord(nodeRef) && !recordFolderService.isRecordFolder(nodeRef))
|
||||
// ensure that the node we are adding to the hold is a record or record folder or active content
|
||||
if (!recordService.isRecord(nodeRef) && !recordFolderService.isRecordFolder(nodeRef) &&
|
||||
!dictionaryService.isSubClass(nodeService.getType(nodeRef), ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Items added to a hold must be either a record or record folder.");
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Items added to a hold must be either a record, a record folder or active content.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to get the list of {@link NodeRef}(s) for the hold(s) which will contain the item (record / record folder)
|
||||
* Helper method to get the list of {@link NodeRef}(s) for the hold(s) which will contain the item (record / record folder / active content)
|
||||
*
|
||||
* @param json The request content as JSON object
|
||||
* @return List of {@link NodeRef}(s) of the hold(s)
|
||||
|
@@ -134,7 +134,7 @@ public class HoldsGet extends DeclarativeWebScript
|
||||
List<Hold> holdObjects = new ArrayList<>(holds.size());
|
||||
for (NodeRef nodeRef : holds)
|
||||
{
|
||||
// only add if user has filling permisson on the hold
|
||||
// only add if user has filling permission on the hold
|
||||
if (!fileOnly || permissionService.hasPermission(nodeRef, RMPermissionModel.FILING) == AccessStatus.ALLOWED)
|
||||
{
|
||||
String name = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||
@@ -215,7 +215,7 @@ public class HoldsGet extends DeclarativeWebScript
|
||||
String includedInHold = req.getParameter("includedInHold");
|
||||
if (StringUtils.isNotBlank(includedInHold))
|
||||
{
|
||||
result = Boolean.valueOf(includedInHold).booleanValue();
|
||||
result = Boolean.parseBoolean(includedInHold);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -226,7 +226,7 @@ public class HoldsGet extends DeclarativeWebScript
|
||||
String fillingOnly = req.getParameter("fileOnly");
|
||||
if (StringUtils.isNotBlank(fillingOnly))
|
||||
{
|
||||
result = Boolean.valueOf(fillingOnly).booleanValue();
|
||||
result = Boolean.parseBoolean(fillingOnly);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user