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());
}
}
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);
}
}
}
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();
}
Aggregations