use of com.emc.storageos.hds.xmlgen.beans.Operation in project coprhd-controller by CoprHD.
the class InputXMLGenerationClient method getModelSupportedOperation.
/**
* This method will make sure that if a new model is used to test then the
* operation with model "default" will be used to execute commands.
*
* @param attributeMap
* @param availableOperations
* @return
*/
private static Operation getModelSupportedOperation(Map<String, Object> attributeMap, List<Operation> availableOperations) {
String requestedSystemModel = getModelFromMap(attributeMap);
Operation operationToUse = null;
if (null != availableOperations && !availableOperations.isEmpty()) {
for (Operation operation : availableOperations) {
List<String> supportedModelsFromOperation = Arrays.asList(operation.getModels().split(XMLConstants.COMMA_OPERATOR));
if (supportedModelsFromOperation.contains(requestedSystemModel)) {
operationToUse = operation;
break;
} else if (supportedModelsFromOperation.contains(XMLConstants.DEFAULT_MODEL)) {
operationToUse = operation;
}
}
}
return operationToUse;
}
use of com.emc.storageos.hds.xmlgen.beans.Operation in project coprhd-controller by CoprHD.
the class InputXMLGenerationClient method getInputXMLString.
public static String getInputXMLString(String requestedOperationName, Map<String, Object> attributeMap, String xmlInputContextFile, String smooksConfigFile) {
String operationInputXMLString = null;
InputStream stream = null;
try {
List<Operation> availableOperations = new ArrayList<Operation>();
log.debug("XML Context File name to be loaded: {}", xmlInputContextFile);
stream = InputXMLGenerationClient.class.getClass().getResourceAsStream(xmlInputContextFile);
JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(stream, smooksConfigFile);
@SuppressWarnings("unchecked") List<Operation> operationList = (List<Operation>) javaResult.getBean(XMLConstants.OPERATION_LIST_BEAN_NAME);
if (null != operationList && !operationList.isEmpty()) {
log.debug("{} operations found in configuration file", operationList.size());
for (Operation operation : operationList) {
if (operation.getName().equalsIgnoreCase(requestedOperationName)) {
log.debug("Found matching operation {}", operation.getName());
availableOperations.add(operation);
}
}
Operation operation = getModelSupportedOperation(attributeMap, availableOperations);
if (null != operation) {
operationInputXMLString = generateXMLString(operation, attributeMap);
} else {
log.error("No Operation found with the given model");
HDSException.exceptions.unableToGenerateInputXmlDueToUnSupportedModelFound();
}
} else {
log.error("No operation list found to generate input xml.");
HDSException.exceptions.unableToGenerateInputXmlDueToNoOperations();
}
} catch (Exception ex) {
HDSException.exceptions.unableToGenerateInputXmlForGivenRequest(ex.getLocalizedMessage());
}
return operationInputXMLString;
}
Aggregations