use of org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent in project records-management by Alfresco.
the class RmEventsPost method executeImpl.
/**
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest,
* org.springframework.extensions.webscripts.Status,
* org.springframework.extensions.webscripts.Cache)
*/
@Override
public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
ParameterCheck.mandatory("req", req);
Map<String, Object> model = new HashMap<String, Object>();
JSONObject json = null;
try {
// Convert the request content to JSON
json = new JSONObject(new JSONTokener(req.getContent().getContent()));
// Get the event name
String eventName = getEventName(json);
// Check the event display label
String eventDisplayLabel = getValue(json, "eventDisplayLabel");
doCheck(eventDisplayLabel, "No event display label was provided.");
// Check if the event can be created
canCreateEvent(eventDisplayLabel, eventName);
// Check the event type
String eventType = getValue(json, "eventType");
doCheck(eventType, "No event type was provided.");
// Create event
RecordsManagementEvent event = rmEventService.addEvent(eventType, eventName, eventDisplayLabel);
model.put("event", event);
} catch (IOException iox) {
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not read content from req.", iox);
} catch (JSONException je) {
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not parse JSON from req.", je);
}
return model;
}
use of org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent in project records-management by Alfresco.
the class DispositionAbstractBase method createActionDefModel.
/**
* Helper to create a model to represent the given disposition action definition.
*
* @param actionDef The DispositionActionDefinition instance to generate model for
* @param url The URL for the DispositionActionDefinition
* @return Map representing the model
*/
protected Map<String, Object> createActionDefModel(DispositionActionDefinition actionDef, String url) {
Map<String, Object> model = new HashMap<String, Object>(8);
model.put("id", actionDef.getId());
model.put("index", actionDef.getIndex());
model.put("url", url);
model.put("name", actionDef.getName());
model.put("label", actionDef.getLabel());
model.put("eligibleOnFirstCompleteEvent", actionDef.eligibleOnFirstCompleteEvent());
if (actionDef.getDescription() != null) {
model.put("description", actionDef.getDescription());
}
if (actionDef.getPeriod() != null) {
model.put("period", actionDef.getPeriod().toString());
}
if (actionDef.getPeriodProperty() != null) {
model.put("periodProperty", actionDef.getPeriodProperty().toPrefixString(getNamespaceService()));
}
if (actionDef.getLocation() != null) {
model.put("location", actionDef.getLocation());
}
if (actionDef.getGhostOnDestroy() != null) {
model.put("ghostOnDestroy", actionDef.getGhostOnDestroy());
}
List<RecordsManagementEvent> events = actionDef.getEvents();
if (events != null && events.size() > 0) {
List<String> eventNames = new ArrayList<String>(events.size());
for (RecordsManagementEvent event : events) {
eventNames.add(event.getName());
}
model.put("events", eventNames);
}
return model;
}
use of org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent in project records-management by Alfresco.
the class ManualEventParameterConstraint method getAllowableValuesImpl.
/**
* @see org.alfresco.service.cmr.action.ParameterConstraint#getAllowableValues()
*/
protected Map<String, String> getAllowableValuesImpl() {
List<RecordsManagementEvent> events = recordsManagementEventService.getEvents();
Map<String, String> result = new HashMap<String, String>(events.size());
for (RecordsManagementEvent event : events) {
RecordsManagementEventType eventType = recordsManagementEventService.getEventType(event.getType());
if (eventType != null && !eventType.isAutomaticEvent()) {
result.put(event.getName(), event.getDisplayLabel());
}
}
return result;
}
Aggregations