use of org.alfresco.rest.framework.core.exceptions.EntityNotFoundException in project alfresco-remote-api by Alfresco.
the class ProcessesImpl method getVariables.
@Override
public CollectionWithPagingInfo<Variable> getVariables(String processId, Paging paging) {
CollectionWithPagingInfo<Variable> result = null;
// Check if user is allowed to get variables
List<HistoricVariableInstance> variableInstances = validateIfUserAllowedToWorkWithProcess(processId);
Map<String, Object> variables = new HashMap<String, Object>();
for (HistoricVariableInstance variable : variableInstances) {
variables.put(variable.getVariableName(), variable.getValue());
}
ProcessInstance processInstance = activitiProcessEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(processId).singleResult();
String processDefinitionId = null;
if (processInstance != null) {
processDefinitionId = processInstance.getProcessDefinitionId();
} else {
// Completed process instance
HistoricProcessInstance historicInstance = activitiProcessEngine.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(processId).singleResult();
if (historicInstance == null) {
throw new EntityNotFoundException(processId);
}
processDefinitionId = historicInstance.getProcessDefinitionId();
}
// Get start-task definition for explicit typing of variables submitted at the start
String formKey = null;
StartFormData startFormData = activitiProcessEngine.getFormService().getStartFormData(processDefinitionId);
if (startFormData != null) {
formKey = startFormData.getFormKey();
}
TypeDefinition startTaskTypeDefinition = getWorkflowFactory().getTaskFullTypeDefinition(formKey, true);
// Convert raw variables to Variable objects
List<Variable> resultingVariables = restVariableHelper.getVariables(variables, startTaskTypeDefinition);
result = CollectionWithPagingInfo.asPaged(paging, resultingVariables);
return result;
}
use of org.alfresco.rest.framework.core.exceptions.EntityNotFoundException in project alfresco-remote-api by Alfresco.
the class CustomModelsImpl method getCustomModelConstraint.
@Override
public CustomModelConstraint getCustomModelConstraint(String modelName, String constraintName, Parameters parameters) {
if (constraintName == null) {
throw new InvalidArgumentException(CONSTRAINT_NAME_NULL_ERR);
}
final CustomModelDefinition modelDef = getCustomModelImpl(modelName);
QName constraintQname = QName.createQName(modelDef.getName().getNamespaceURI(), constraintName);
ConstraintDefinition constraintDef = customModelService.getCustomConstraint(constraintQname);
if (constraintDef == null) {
throw new EntityNotFoundException(constraintName);
}
return new CustomModelConstraint(constraintDef, dictionaryService);
}
use of org.alfresco.rest.framework.core.exceptions.EntityNotFoundException in project alfresco-remote-api by Alfresco.
the class CustomModelsImpl method deleteCustomAspect.
@Override
public void deleteCustomAspect(String modelName, String aspectName) {
// Check the current user is authorised to delete the custom model's aspect
validateCurrentUser();
if (aspectName == null) {
throw new InvalidArgumentException(ASPECT_NAME_NULL_ERR);
}
ModelDetails existingModelDetails = new ModelDetails(getCustomModelImpl(modelName));
if (existingModelDetails.isActive()) {
throw new ConstraintViolatedException("cmm.rest_api.aspect_cannot_delete");
}
Map<String, CustomAspect> allAspects = transformToMap(existingModelDetails.getAspects(), toNameFunction());
CustomAspect aspectToBeDeleted = allAspects.get(aspectName);
if (aspectToBeDeleted == null) {
throw new EntityNotFoundException(aspectName);
}
// Validate aspect's dependency
validateTypeAspectDelete(allAspects.values(), aspectToBeDeleted.getPrefixedName());
// Remove the validated aspect
allAspects.remove(aspectName);
existingModelDetails.setAspects(new ArrayList<>(allAspects.values()));
updateModel(existingModelDetails, "cmm.rest_api.aspect_delete_failure");
}
use of org.alfresco.rest.framework.core.exceptions.EntityNotFoundException in project alfresco-remote-api by Alfresco.
the class CustomModelsImpl method getCustomAspect.
@Override
public CustomAspect getCustomAspect(String modelName, String aspectName, Parameters parameters) {
if (aspectName == null) {
throw new InvalidArgumentException(ASPECT_NAME_NULL_ERR);
}
final CustomModelDefinition modelDef = getCustomModelImpl(modelName);
QName aspectQname = QName.createQName(modelDef.getName().getNamespaceURI(), aspectName);
AspectDefinition customAspectDef = customModelService.getCustomAspect(aspectQname);
if (customAspectDef == null) {
throw new EntityNotFoundException(aspectName);
}
// Check if inherited properties have been requested
boolean includeInheritedProps = hasSelectProperty(parameters, SELECT_ALL_PROPS);
return convertToCustomAspect(customAspectDef, includeInheritedProps);
}
use of org.alfresco.rest.framework.core.exceptions.EntityNotFoundException in project alfresco-remote-api by Alfresco.
the class DeletedNodesImpl method restoreArchivedNode.
@Override
public Node restoreArchivedNode(String archivedId, NodeTargetAssoc nodeTargetAssoc) {
// First check the node is valid and has been archived.
NodeRef validatedNodeRef = nodes.validateNode(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, archivedId);
RestoreNodeReport restored = null;
if (nodeTargetAssoc != null) {
NodeRef targetNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, nodeTargetAssoc.getTargetParentId());
QName assocType = nodes.getAssocType(nodeTargetAssoc.getAssocType());
restored = nodeArchiveService.restoreArchivedNode(validatedNodeRef, targetNodeRef, assocType, null);
} else {
restored = nodeArchiveService.restoreArchivedNode(validatedNodeRef);
}
switch(restored.getStatus()) {
case SUCCESS:
return nodes.getFolderOrDocumentFullInfo(restored.getRestoredNodeRef(), null, null, null, null);
case FAILURE_PERMISSION:
throw new PermissionDeniedException();
case FAILURE_INTEGRITY:
throw new IntegrityException("Restore failed due to an integrity error", null);
case FAILURE_DUPLICATE_CHILD_NODE_NAME:
throw new ConstraintViolatedException("Name already exists in target");
case FAILURE_INVALID_ARCHIVE_NODE:
throw new EntityNotFoundException(archivedId);
case FAILURE_INVALID_PARENT:
throw new NotFoundException("Invalid parent id " + restored.getTargetParentNodeRef());
default:
throw new ApiException("Unable to restore node " + archivedId);
}
}
Aggregations