Search in sources :

Example 1 with InputUpdateList

use of com.emc.storageos.model.customservices.InputUpdateParam.InputUpdateList in project coprhd-controller by CoprHD.

the class WorkflowBuilder method editRestAPIPrimitive.

private static void editRestAPIPrimitive(final RestAPIPrimitiveForm restAPIPrimitive) {
    try {
        final URI restPrimitiveID = new URI(restAPIPrimitive.getId());
        final CustomServicesPrimitiveRestRep primitiveRestRep = getCatalogClient().customServicesPrimitives().getPrimitive(restPrimitiveID);
        if (null != primitiveRestRep) {
            // Update name, description
            final CustomServicesPrimitiveUpdateParam primitiveUpdateParam = new CustomServicesPrimitiveUpdateParam();
            primitiveUpdateParam.setName(restAPIPrimitive.getName());
            primitiveUpdateParam.setFriendlyName(restAPIPrimitive.getName());
            primitiveUpdateParam.setDescription(restAPIPrimitive.getDescription());
            // Get and update differences between existing and new inputs
            final InputUpdateParam inputUpdateParam = new InputUpdateParam();
            inputUpdateParam.setRemove(new HashMap<String, InputUpdateList>());
            inputUpdateParam.setAdd(new HashMap<String, InputUpdateList>());
            prepareInputUpdates(CustomServicesConstants.INPUT_PARAMS, restAPIPrimitive.getInputs(), primitiveRestRep, inputUpdateParam);
            prepareInputUpdates(CustomServicesConstants.HEADERS, restAPIPrimitive.getHeaders(), primitiveRestRep, inputUpdateParam);
            prepareInputUpdates(CustomServicesConstants.QUERY_PARAMS, restAPIPrimitive.getQueryParams(), primitiveRestRep, inputUpdateParam);
            primitiveUpdateParam.setInput(inputUpdateParam);
            // Get and update differences between existing and new outputs
            final List<String> newOutputs = getListFromInputOutputString(restAPIPrimitive.getOutputs());
            final List<String> existingOutputs = convertOutputGroupsToList(primitiveRestRep.getOutput());
            final OutputUpdateParam outputUpdateParam = new OutputUpdateParam();
            outputUpdateParam.setRemove((List<String>) CollectionUtils.subtract(existingOutputs, newOutputs));
            outputUpdateParam.setAdd((List<String>) CollectionUtils.subtract(newOutputs, existingOutputs));
            primitiveUpdateParam.setOutput(outputUpdateParam);
            // Set attributes
            primitiveUpdateParam.setAttributes(new HashMap<String, String>());
            primitiveUpdateParam.getAttributes().put(CustomServicesConstants.PATH.toString(), restAPIPrimitive.getRequestURL());
            if (restAPIPrimitive.getRawBody() == null) {
                primitiveUpdateParam.getAttributes().put(CustomServicesConstants.BODY.toString(), "");
            } else {
                primitiveUpdateParam.getAttributes().put(CustomServicesConstants.BODY.toString(), restAPIPrimitive.getRawBody());
            }
            // Only supported protocol is "https". Once other protocols are supported this value should come from UI form
            primitiveUpdateParam.getAttributes().put(CustomServicesConstants.METHOD.toString(), restAPIPrimitive.getMethod());
            primitiveUpdateParam.getAttributes().put(CustomServicesConstants.AUTH_TYPE.toString(), restAPIPrimitive.getAuthType());
            getCatalogClient().customServicesPrimitives().updatePrimitive(restPrimitiveID, primitiveUpdateParam);
            flash.success(MessagesUtils.get("wfBuilder.operation.edit.success"));
        }
    } catch (final Exception e) {
        Logger.error(e.getMessage());
        flash.error(e.getMessage());
    }
}
Also used : InputUpdateParam(com.emc.storageos.model.customservices.InputUpdateParam) CustomServicesPrimitiveRestRep(com.emc.storageos.model.customservices.CustomServicesPrimitiveRestRep) CustomServicesPrimitiveUpdateParam(com.emc.storageos.model.customservices.CustomServicesPrimitiveUpdateParam) OutputUpdateParam(com.emc.storageos.model.customservices.OutputUpdateParam) InputUpdateList(com.emc.storageos.model.customservices.InputUpdateParam.InputUpdateList) URI(java.net.URI) URISyntaxException(java.net.URISyntaxException)

Example 2 with InputUpdateList

use of com.emc.storageos.model.customservices.InputUpdateParam.InputUpdateList in project coprhd-controller by CoprHD.

the class CustomServicesDBHelper method addInput.

private static void addInput(final Set<String> keys, final Map<String, InputUpdateList> map, final StringSetMap update) {
    if (null == map) {
        return;
    }
    for (final Entry<String, InputUpdateList> entry : map.entrySet()) {
        if (!keys.contains(entry.getKey())) {
            throw APIException.badRequests.invalidParameter("input", entry.getKey());
        }
        if (null != entry.getValue().getInput()) {
            final StringSet add = new StringSet();
            add.addAll(entry.getValue().getInput());
            update.put(entry.getKey(), add);
        }
    }
}
Also used : StringSet(com.emc.storageos.db.client.model.StringSet) InputUpdateList(com.emc.storageos.model.customservices.InputUpdateParam.InputUpdateList)

Example 3 with InputUpdateList

use of com.emc.storageos.model.customservices.InputUpdateParam.InputUpdateList in project coprhd-controller by CoprHD.

the class WorkflowBuilder method getInputDiff.

private static Map<String, InputUpdateList> getInputDiff(final List<String> left, final List<String> right, final String inputGroupType) {
    final List<String> updateList = (List<String>) CollectionUtils.subtract(left, right);
    if (CollectionUtils.isEmpty(updateList)) {
        return ImmutableMap.<String, InputUpdateList>builder().build();
    }
    final InputUpdateList update = new InputUpdateList();
    update.setInput(updateList);
    return ImmutableMap.<String, InputUpdateList>builder().put(inputGroupType, update).build();
}
Also used : CustomServicesWorkflowList(com.emc.storageos.model.customservices.CustomServicesWorkflowList) InputUpdateList(com.emc.storageos.model.customservices.InputUpdateParam.InputUpdateList) InputCreateList(com.emc.storageos.model.customservices.CustomServicesPrimitiveCreateParam.InputCreateList) List(java.util.List) ArrayList(java.util.ArrayList) CustomServicesPrimitiveList(com.emc.storageos.model.customservices.CustomServicesPrimitiveList) CustomServicesPrimitiveResourceList(com.emc.storageos.model.customservices.CustomServicesPrimitiveResourceList) InputUpdateList(com.emc.storageos.model.customservices.InputUpdateParam.InputUpdateList)

Aggregations

InputUpdateList (com.emc.storageos.model.customservices.InputUpdateParam.InputUpdateList)3 StringSet (com.emc.storageos.db.client.model.StringSet)1 InputCreateList (com.emc.storageos.model.customservices.CustomServicesPrimitiveCreateParam.InputCreateList)1 CustomServicesPrimitiveList (com.emc.storageos.model.customservices.CustomServicesPrimitiveList)1 CustomServicesPrimitiveResourceList (com.emc.storageos.model.customservices.CustomServicesPrimitiveResourceList)1 CustomServicesPrimitiveRestRep (com.emc.storageos.model.customservices.CustomServicesPrimitiveRestRep)1 CustomServicesPrimitiveUpdateParam (com.emc.storageos.model.customservices.CustomServicesPrimitiveUpdateParam)1 CustomServicesWorkflowList (com.emc.storageos.model.customservices.CustomServicesWorkflowList)1 InputUpdateParam (com.emc.storageos.model.customservices.InputUpdateParam)1 OutputUpdateParam (com.emc.storageos.model.customservices.OutputUpdateParam)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1