Search in sources :

Example 6 with RecordsManagementEvent

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;
}
Also used : JSONTokener(org.json.JSONTokener) JSONObject(org.json.JSONObject) WebScriptException(org.springframework.extensions.webscripts.WebScriptException) HashMap(java.util.HashMap) RecordsManagementEvent(org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) IOException(java.io.IOException)

Example 7 with RecordsManagementEvent

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;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RecordsManagementEvent(org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent)

Example 8 with RecordsManagementEvent

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;
}
Also used : HashMap(java.util.HashMap) RecordsManagementEvent(org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent) RecordsManagementEventType(org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType)

Aggregations

RecordsManagementEvent (org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent)8 HashMap (java.util.HashMap)7 WebScriptException (org.springframework.extensions.webscripts.WebScriptException)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 JSONException (org.json.JSONException)2 JSONObject (org.json.JSONObject)2 JSONTokener (org.json.JSONTokener)2 Serializable (java.io.Serializable)1 Collection (java.util.Collection)1 Date (java.util.Date)1 Map (java.util.Map)1 RecordsManagementEventType (org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType)1 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 QName (org.alfresco.service.namespace.QName)1