use of org.alfresco.error.AlfrescoRuntimeException in project records-management by Alfresco.
the class DispositionServiceImpl method getAssociatedDispositionScheduleImpl.
/**
* Gets the node reference of the disposition schedule associated with the container.
*
* @param nodeRef node reference of the container
* @return {@link NodeRef} node reference of the disposition schedule, null if none
*/
private NodeRef getAssociatedDispositionScheduleImpl(NodeRef nodeRef) {
NodeRef result = null;
ParameterCheck.mandatory("nodeRef", nodeRef);
// Make sure we are dealing with an RM node
if (!filePlanService.isFilePlanComponent(nodeRef)) {
throw new AlfrescoRuntimeException("Can not find the associated retention schedule for a non records management component. (nodeRef=" + nodeRef.toString() + ")");
}
if (this.nodeService.hasAspect(nodeRef, ASPECT_SCHEDULED)) {
List<ChildAssociationRef> childAssocs = this.nodeService.getChildAssocs(nodeRef, ASSOC_DISPOSITION_SCHEDULE, RegexQNamePattern.MATCH_ALL);
if (!childAssocs.isEmpty()) {
ChildAssociationRef firstChildAssocRef = childAssocs.get(0);
result = firstChildAssocRef.getChildRef();
}
}
return result;
}
use of org.alfresco.error.AlfrescoRuntimeException in project records-management by Alfresco.
the class RecordsManagementEventServiceImpl method canEditEvent.
/**
* @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#canEditEvent(java.lang.String, java.lang.String, java.lang.String)
*/
@SuppressWarnings("rawtypes")
public boolean canEditEvent(String eventDisplayLabel, String eventName, String eventType) {
ParameterCheck.mandatoryString("eventDisplayLabel", eventDisplayLabel);
ParameterCheck.mandatoryString("eventName", eventName);
ParameterCheck.mandatoryString("eventType", eventType);
boolean canEditEvent = true;
if (!existsEvent(eventName)) {
throw new AlfrescoRuntimeException("The event '" + eventName + "' does not exist.");
}
for (Iterator iterator = getEventMap().values().iterator(); iterator.hasNext(); ) {
RecordsManagementEvent recordsManagementEvent = (RecordsManagementEvent) iterator.next();
if (recordsManagementEvent.getDisplayLabel().equalsIgnoreCase(eventDisplayLabel)) {
if (recordsManagementEvent.getName().equalsIgnoreCase(eventName)) {
if (!recordsManagementEvent.getType().equalsIgnoreCase(eventType)) {
canEditEvent = true;
} else {
canEditEvent = false;
}
} else {
throw new AlfrescoRuntimeException("Cannot edit event. An event with the display label '" + eventDisplayLabel + "' already exist.");
}
break;
}
}
return canEditEvent;
}
use of org.alfresco.error.AlfrescoRuntimeException in project records-management by Alfresco.
the class FilePlanServiceImpl method getContained.
/**
* Get contained nodes of a particular type. If null return all.
*
* @param container container node reference
* @param typeFilter type filter, null if none
* @return {@link List}<{@link NodeRef> list of contained node references
*/
private List<NodeRef> getContained(NodeRef container, QName typeFilter, boolean deep) {
// Parameter check
ParameterCheck.mandatory("container", container);
// Check we have a container in our hands
if (!isRecordCategory(container)) {
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CONTAINER_EXPECTED));
}
List<NodeRef> result = new ArrayList<NodeRef>(1);
List<ChildAssociationRef> assocs = this.nodeService.getChildAssocs(container, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef assoc : assocs) {
NodeRef child = assoc.getChildRef();
QName childType = nodeService.getType(child);
if (typeFilter == null || typeFilter.equals(childType) || dictionaryService.isSubClass(childType, typeFilter)) {
result.add(child);
}
// Inspect the containers and add children if deep
if (deep && (TYPE_RECORD_CATEGORY.equals(childType) || dictionaryService.isSubClass(childType, TYPE_RECORD_CATEGORY))) {
result.addAll(getContained(child, typeFilter, deep));
}
}
return result;
}
use of org.alfresco.error.AlfrescoRuntimeException in project records-management by Alfresco.
the class FilePlanServiceImpl method createRecordCategory.
/**
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createRecordCategory(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName, java.util.Map)
*/
public NodeRef createRecordCategory(NodeRef parent, String name, QName type, Map<QName, Serializable> properties) {
ParameterCheck.mandatory("parent", parent);
ParameterCheck.mandatory("name", name);
ParameterCheck.mandatory("type", type);
// Check that the parent is a container
QName parentType = nodeService.getType(parent);
if (!TYPE_RECORDS_MANAGEMENT_CONTAINER.equals(parentType) && !dictionaryService.isSubClass(parentType, TYPE_RECORDS_MANAGEMENT_CONTAINER)) {
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CONTAINER_PARENT_TYPE, parentType.toString()));
}
// Check that the the provided type is a sub-type of rm:recordCategory
if (!TYPE_RECORD_CATEGORY.equals(type) && !dictionaryService.isSubClass(type, TYPE_RECORD_CATEGORY)) {
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CONTAINER_TYPE, type.toString()));
}
// Set the properties for the record category
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
if (properties != null && properties.size() != 0) {
props.putAll(properties);
}
props.put(ContentModel.PROP_NAME, name);
return nodeService.createNode(parent, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, (name.length() > QName.MAX_LENGTH ? name.substring(0, QName.MAX_LENGTH) : name)), type, props).getChildRef();
}
use of org.alfresco.error.AlfrescoRuntimeException in project records-management by Alfresco.
the class CustomEmailMappingServiceImpl method loadConfig.
/**
* Loads the custom mappings from the configuration file.
*
* @return
*/
private Set<CustomMapping> loadConfig() {
Set<CustomMapping> result = new HashSet<CustomMapping>();
ContentReader cr = contentService.getReader(CONFIG_NODE_REF, ContentModel.PROP_CONTENT);
if (cr != null) {
String text = cr.getContentString();
try {
JSONArray jsonArray = new JSONArray(new JSONTokener(text));
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject obj = jsonArray.getJSONObject(i);
CustomMapping mapping = new CustomMapping();
mapping.setFrom(obj.getString("from"));
mapping.setTo(obj.getString("to"));
result.add(mapping);
}
} catch (JSONException je) {
throw new AlfrescoRuntimeException("Unable to read custom email configuration", je);
}
}
return result;
}
Aggregations