Search in sources :

Example 56 with JavaResult

use of org.milyn.payload.JavaResult 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;
}
Also used : InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) Operation(com.emc.storageos.hds.xmlgen.beans.Operation) JavaResult(org.milyn.payload.JavaResult) InvocationTargetException(java.lang.reflect.InvocationTargetException) HDSException(com.emc.storageos.hds.HDSException)

Example 57 with JavaResult

use of org.milyn.payload.JavaResult in project tutorials by eugenp.

the class OrderConverter method convertOrderXMLToOrderObject.

public Order convertOrderXMLToOrderObject(String path) throws IOException, SAXException {
    Smooks smooks = new Smooks(OrderConverter.class.getResourceAsStream("/smooks/smooks-mapping.xml"));
    try {
        JavaResult javaResult = new JavaResult();
        smooks.filterSource(new StreamSource(OrderConverter.class.getResourceAsStream(path)), javaResult);
        return (Order) javaResult.getBean("order");
    } finally {
        smooks.close();
    }
}
Also used : Order(com.baeldung.smooks.model.Order) Smooks(org.milyn.Smooks) StreamSource(javax.xml.transform.stream.StreamSource) JavaResult(org.milyn.payload.JavaResult)

Aggregations

JavaResult (org.milyn.payload.JavaResult)57 InputStream (java.io.InputStream)53 ClientResponse (com.sun.jersey.api.client.ClientResponse)52 URI (java.net.URI)50 IOException (java.io.IOException)42 HashMap (java.util.HashMap)38 StorageArray (com.emc.storageos.hds.model.StorageArray)26 Error (com.emc.storageos.hds.model.Error)17 Get (com.emc.storageos.hds.model.Get)16 EchoCommand (com.emc.storageos.hds.model.EchoCommand)15 LogicalUnit (com.emc.storageos.hds.model.LogicalUnit)13 Add (com.emc.storageos.hds.model.Add)11 HostStorageDomain (com.emc.storageos.hds.model.HostStorageDomain)11 HDSHost (com.emc.storageos.hds.model.HDSHost)8 Delete (com.emc.storageos.hds.model.Delete)7 HDSException (com.emc.storageos.hds.HDSException)6 ReplicationInfo (com.emc.storageos.hds.model.ReplicationInfo)6 Modify (com.emc.storageos.hds.model.Modify)5 Pool (com.emc.storageos.hds.model.Pool)5 ArrayList (java.util.ArrayList)5