mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-562 (Add 'Manage Permission' action to unfiled records toolbar)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@43974 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -311,6 +311,7 @@
|
|||||||
<value>FILE_PLAN</value>
|
<value>FILE_PLAN</value>
|
||||||
<value>RECORD_CATEGORY</value>
|
<value>RECORD_CATEGORY</value>
|
||||||
<value>RECORD_FOLDER</value>
|
<value>RECORD_FOLDER</value>
|
||||||
|
<value>UNFILED_RECORD_CONTAINER</value>
|
||||||
</set>
|
</set>
|
||||||
</property>
|
</property>
|
||||||
<property name="capability" value ="ManageAccessRights"/>
|
<property name="capability" value ="ManageAccessRights"/>
|
||||||
|
@@ -29,6 +29,7 @@ import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
|||||||
import org.alfresco.service.cmr.model.FileInfo;
|
import org.alfresco.service.cmr.model.FileInfo;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.security.AccessStatus;
|
import org.alfresco.service.cmr.security.AccessStatus;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.json.simple.JSONArray;
|
import org.json.simple.JSONArray;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
@@ -39,226 +40,230 @@ import org.json.simple.JSONObject;
|
|||||||
*/
|
*/
|
||||||
public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONConversionComponent
|
public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONConversionComponent
|
||||||
{
|
{
|
||||||
/** Records management service */
|
/** Records management service */
|
||||||
private RecordsManagementService recordsManagementService;
|
private RecordsManagementService recordsManagementService;
|
||||||
|
|
||||||
/** Record service */
|
/** Record service */
|
||||||
private RecordService recordService;
|
private RecordService recordService;
|
||||||
|
|
||||||
/** Capability service */
|
/** Capability service */
|
||||||
private CapabilityService capabilityService;
|
private CapabilityService capabilityService;
|
||||||
|
|
||||||
/** Indicators */
|
/** Indicators */
|
||||||
private List<BaseEvaluator> indicators = new ArrayList<BaseEvaluator>();
|
private List<BaseEvaluator> indicators = new ArrayList<BaseEvaluator>();
|
||||||
|
|
||||||
/** Actions */
|
/** Actions */
|
||||||
private List<BaseEvaluator> actions = new ArrayList<BaseEvaluator>();
|
private List<BaseEvaluator> actions = new ArrayList<BaseEvaluator>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param recordsManagementService records management service
|
* @param recordsManagementService records management service
|
||||||
*/
|
*/
|
||||||
public void setRecordsManagementService(RecordsManagementService recordsManagementService)
|
public void setRecordsManagementService(RecordsManagementService recordsManagementService)
|
||||||
{
|
{
|
||||||
this.recordsManagementService = recordsManagementService;
|
this.recordsManagementService = recordsManagementService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param recordService record service
|
* @param recordService record service
|
||||||
*/
|
*/
|
||||||
public void setRecordService(RecordService recordService)
|
public void setRecordService(RecordService recordService)
|
||||||
{
|
{
|
||||||
this.recordService = recordService;
|
this.recordService = recordService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param capabilityService capability service
|
* @param capabilityService capability service
|
||||||
*/
|
*/
|
||||||
public void setCapabilityService(CapabilityService capabilityService)
|
public void setCapabilityService(CapabilityService capabilityService)
|
||||||
{
|
{
|
||||||
this.capabilityService = capabilityService;
|
this.capabilityService = capabilityService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param indicator registered indicator
|
* @param indicator registered indicator
|
||||||
*/
|
*/
|
||||||
public void registerIndicator(BaseEvaluator indicator)
|
public void registerIndicator(BaseEvaluator indicator)
|
||||||
{
|
{
|
||||||
indicators.add(indicator);
|
indicators.add(indicator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param action registered action
|
* @param action registered action
|
||||||
*/
|
*/
|
||||||
public void registerAction(BaseEvaluator action)
|
public void registerAction(BaseEvaluator action)
|
||||||
{
|
{
|
||||||
actions.add(action);
|
actions.add(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.repo.jscript.app.JSONConversionComponent#setRootValues(org.alfresco.service.cmr.model.FileInfo, org.json.simple.JSONObject, boolean)
|
* @see org.alfresco.repo.jscript.app.JSONConversionComponent#setRootValues(org.alfresco.service.cmr.model.FileInfo, org.json.simple.JSONObject, boolean)
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
protected void setRootValues(FileInfo nodeInfo, JSONObject rootJSONObject, boolean useShortQNames)
|
protected void setRootValues(FileInfo nodeInfo, JSONObject rootJSONObject, boolean useShortQNames)
|
||||||
{
|
{
|
||||||
// Set the base root values
|
// Set the base root values
|
||||||
super.setRootValues(nodeInfo, rootJSONObject, useShortQNames);
|
super.setRootValues(nodeInfo, rootJSONObject, useShortQNames);
|
||||||
|
|
||||||
// Get the node reference for convenience
|
// Get the node reference for convenience
|
||||||
NodeRef nodeRef = nodeInfo.getNodeRef();
|
NodeRef nodeRef = nodeInfo.getNodeRef();
|
||||||
|
|
||||||
if (AccessStatus.ALLOWED.equals(capabilityService.getCapabilityAccessState(nodeRef, RMPermissionModel.VIEW_RECORDS)) == true)
|
if (AccessStatus.ALLOWED.equals(capabilityService.getCapabilityAccessState(nodeRef, RMPermissionModel.VIEW_RECORDS)) == true)
|
||||||
{
|
{
|
||||||
// Indicate whether the node is a RM object or not
|
// Indicate whether the node is a RM object or not
|
||||||
boolean isFilePlanComponent = recordsManagementService.isFilePlanComponent(nodeInfo.getNodeRef());
|
boolean isFilePlanComponent = recordsManagementService.isFilePlanComponent(nodeInfo.getNodeRef());
|
||||||
rootJSONObject.put("isRmNode", isFilePlanComponent);
|
rootJSONObject.put("isRmNode", isFilePlanComponent);
|
||||||
|
|
||||||
if (isFilePlanComponent == true)
|
if (isFilePlanComponent == true)
|
||||||
|
{
|
||||||
|
rootJSONObject.put("rmNode", setRmNodeValues(nodeRef, rootJSONObject, useShortQNames));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param nodeRef
|
||||||
|
* @param rootJSONObject
|
||||||
|
* @param useShortQName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private JSONObject setRmNodeValues(NodeRef nodeRef, JSONObject rootJSONObject, boolean useShortQName)
|
||||||
|
{
|
||||||
|
JSONObject rmNodeValues = new JSONObject();
|
||||||
|
|
||||||
|
// UI convenience type
|
||||||
|
rmNodeValues.put("uiType", getUIType(nodeRef));
|
||||||
|
|
||||||
|
// Get the 'kind' of the file plan component
|
||||||
|
FilePlanComponentKind kind = recordsManagementService.getFilePlanComponentKind(nodeRef);
|
||||||
|
rmNodeValues.put("kind", kind.toString());
|
||||||
|
|
||||||
|
// File plan node reference
|
||||||
|
NodeRef filePlan = recordsManagementService.getFilePlan(nodeRef);
|
||||||
|
rmNodeValues.put("filePlan", filePlan.toString());
|
||||||
|
|
||||||
|
// Unfiled container node reference
|
||||||
|
NodeRef unfiledRecordContainer = recordService.getUnfiledRecordContainer(filePlan);
|
||||||
|
rmNodeValues.put("unfiledRecordContainer", unfiledRecordContainer.toString());
|
||||||
|
rmNodeValues.put("properties", propertiesToJSON(unfiledRecordContainer, useShortQName));
|
||||||
|
QName type = fileFolderService.getFileInfo(unfiledRecordContainer).getType();
|
||||||
|
rmNodeValues.put("type", useShortQName ? type.toPrefixString(namespaceService) : type.toString());
|
||||||
|
|
||||||
|
// Set the indicators array
|
||||||
|
setIndicators(rmNodeValues, nodeRef);
|
||||||
|
|
||||||
|
// Set the actions array
|
||||||
|
setActions(rmNodeValues, nodeRef);
|
||||||
|
|
||||||
|
return rmNodeValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private void setIndicators(JSONObject rmNodeValues, NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
if (indicators != null && indicators.isEmpty() == false)
|
||||||
|
{
|
||||||
|
JSONArray jsonIndicators = new JSONArray();
|
||||||
|
|
||||||
|
for (BaseEvaluator indicator : indicators)
|
||||||
|
{
|
||||||
|
if (indicator.evaluate(nodeRef) == true)
|
||||||
{
|
{
|
||||||
rootJSONObject.put("rmNode", setRmNodeValues(nodeRef, rootJSONObject, useShortQNames));
|
jsonIndicators.add(indicator.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
rmNodeValues.put("indicators", jsonIndicators);
|
||||||
*
|
}
|
||||||
* @param nodeRef
|
}
|
||||||
* @param rootJSONObject
|
|
||||||
* @param useShortQName
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private JSONObject setRmNodeValues(NodeRef nodeRef, JSONObject rootJSONObject, boolean useShortQName)
|
|
||||||
{
|
|
||||||
JSONObject rmNodeValues = new JSONObject();
|
|
||||||
|
|
||||||
// UI convenience type
|
@SuppressWarnings("unchecked")
|
||||||
rmNodeValues.put("uiType", getUIType(nodeRef));
|
private void setActions(JSONObject rmNodeValues, NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
if (actions != null && actions.isEmpty() == false)
|
||||||
|
{
|
||||||
|
JSONArray jsonActions = new JSONArray();
|
||||||
|
|
||||||
// Get the 'kind' of the file plan component
|
for (BaseEvaluator action : actions)
|
||||||
FilePlanComponentKind kind = recordsManagementService.getFilePlanComponentKind(nodeRef);
|
{
|
||||||
rmNodeValues.put("kind", kind.toString());
|
if (action.evaluate(nodeRef) == true)
|
||||||
|
|
||||||
// File plan node reference
|
|
||||||
NodeRef filePlan = recordsManagementService.getFilePlan(nodeRef);
|
|
||||||
rmNodeValues.put("filePlan", filePlan.toString());
|
|
||||||
|
|
||||||
// Unfiled container node reference
|
|
||||||
rmNodeValues.put("unfiledRecordContainer", recordService.getUnfiledRecordContainer(filePlan).toString());
|
|
||||||
|
|
||||||
// Set the indicators array
|
|
||||||
setIndicators(rmNodeValues, nodeRef);
|
|
||||||
|
|
||||||
// Set the actions array
|
|
||||||
setActions(rmNodeValues, nodeRef);
|
|
||||||
|
|
||||||
return rmNodeValues;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private void setIndicators(JSONObject rmNodeValues, NodeRef nodeRef)
|
|
||||||
{
|
|
||||||
if (indicators != null && indicators.isEmpty() == false)
|
|
||||||
{
|
|
||||||
JSONArray jsonIndicators = new JSONArray();
|
|
||||||
|
|
||||||
for (BaseEvaluator indicator : indicators)
|
|
||||||
{
|
{
|
||||||
if (indicator.evaluate(nodeRef) == true)
|
jsonActions.add(action.getName());
|
||||||
{
|
|
||||||
jsonIndicators.add(indicator.getName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rmNodeValues.put("indicators", jsonIndicators);
|
rmNodeValues.put("actions", jsonActions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
/**
|
||||||
private void setActions(JSONObject rmNodeValues, NodeRef nodeRef)
|
* Gets the rm 'type' used as a UI convenience and compatibility flag.
|
||||||
{
|
*/
|
||||||
if (actions != null && actions.isEmpty() == false)
|
private String getUIType(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
JSONArray jsonActions = new JSONArray();
|
String result = "unknown";
|
||||||
|
|
||||||
for (BaseEvaluator action : actions)
|
FilePlanComponentKind kind = recordsManagementService.getFilePlanComponentKind(nodeRef);
|
||||||
|
if (kind != null)
|
||||||
|
{
|
||||||
|
switch (kind)
|
||||||
|
{
|
||||||
|
case FILE_PLAN:
|
||||||
{
|
{
|
||||||
if (action.evaluate(nodeRef) == true)
|
result = "fileplan";
|
||||||
{
|
break;
|
||||||
jsonActions.add(action.getName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
case RECORD_CATEGORY:
|
||||||
rmNodeValues.put("actions", jsonActions);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the rm 'type' used as a UI convenience and compatibility flag.
|
|
||||||
*/
|
|
||||||
private String getUIType(NodeRef nodeRef)
|
|
||||||
{
|
|
||||||
String result = "unknown";
|
|
||||||
|
|
||||||
FilePlanComponentKind kind = recordsManagementService.getFilePlanComponentKind(nodeRef);
|
|
||||||
if (kind != null)
|
|
||||||
{
|
|
||||||
switch (kind)
|
|
||||||
{
|
{
|
||||||
case FILE_PLAN:
|
result = "record-category";
|
||||||
{
|
break;
|
||||||
result = "fileplan";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case RECORD_CATEGORY:
|
|
||||||
{
|
|
||||||
result = "record-category";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case RECORD_FOLDER:
|
|
||||||
{
|
|
||||||
if (recordsManagementService.isMetadataStub(nodeRef) == true)
|
|
||||||
{
|
|
||||||
result = "metadata-stub-folder";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result = "record-folder";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case RECORD:
|
|
||||||
{
|
|
||||||
if (recordsManagementService.isMetadataStub(nodeRef) == true)
|
|
||||||
{
|
|
||||||
result = "metadata-stub";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (recordService.isDeclared(nodeRef) == true)
|
|
||||||
{
|
|
||||||
result = "record";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result = "undeclared-record";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case HOLD:
|
|
||||||
{
|
|
||||||
result = "hold-container";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TRANSFER:
|
|
||||||
{
|
|
||||||
result = "transfer-container";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
case RECORD_FOLDER:
|
||||||
|
{
|
||||||
|
if (recordsManagementService.isMetadataStub(nodeRef) == true)
|
||||||
|
{
|
||||||
|
result = "metadata-stub-folder";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = "record-folder";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RECORD:
|
||||||
|
{
|
||||||
|
if (recordsManagementService.isMetadataStub(nodeRef) == true)
|
||||||
|
{
|
||||||
|
result = "metadata-stub";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (recordService.isDeclared(nodeRef) == true)
|
||||||
|
{
|
||||||
|
result = "record";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = "undeclared-record";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case HOLD:
|
||||||
|
{
|
||||||
|
result = "hold-container";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TRANSFER:
|
||||||
|
{
|
||||||
|
result = "transfer-container";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user