use of com.emc.storageos.primitives.java.vipr.CustomServicesViPRPrimitive in project coprhd-controller by CoprHD.
the class CustomServicesViprPrimitiveDAO method bulk.
@Override
public Iterator<CustomServicesPrimitiveRestRep> bulk(final Collection<URI> ids) {
ImmutableList.Builder<CustomServicesPrimitiveRestRep> primitives = ImmutableList.<CustomServicesPrimitiveRestRep>builder();
for (final URI id : ids) {
final CustomServicesViPRPrimitive primitive = PRIMITIVES_MAP.get(id);
final ModelObject model = primitive == null ? null : primitive.asModelObject();
ArgValidator.checkEntityNotNull(model, id, false);
primitives.add(CustomServicesPrimitiveMapper.map(primitive));
}
return primitives.build().iterator();
}
use of com.emc.storageos.primitives.java.vipr.CustomServicesViPRPrimitive in project coprhd-controller by CoprHD.
the class CustomServicesService method updateViproutput.
private Map<String, List<String>> updateViproutput(final Step step, final String res) throws Exception {
final CustomServicesViPRPrimitive primitive = customServicesViprDao.get(step.getOperation());
if (null == primitive) {
throw new RuntimeException("Primitive " + step.getOperation() + " not found ");
}
if (StringUtils.isEmpty(primitive.response())) {
logger.debug("Vipr primitive" + primitive.name() + " has no response defined.");
return null;
}
final String classname = primitive.response();
logger.debug("Result is:{}", res);
final ObjectMapper mapper = new ObjectMapper();
mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
final Class<?> clazz = Class.forName(classname);
final Object responseEntity = mapper.readValue(res, clazz.newInstance().getClass());
final Map<String, List<String>> output = parseViprOutput(responseEntity, step);
logger.info("ViPR output for step ID: " + step.getId() + " is " + output);
return output;
}
Aggregations