Search in sources :

Example 1 with APIVersion

use of com.emc.nas.vnxfile.xmlapi.APIVersion in project coprhd-controller by CoprHD.

the class VNXFileInputRequestBuilder method getQueryExParamPacket.

public InputStream getQueryExParamPacket(Object queryParam) throws JAXBException {
    InputStream inputStream = null;
    List<RequestEx> requests = new ArrayList<RequestEx>(1);
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    RequestPacket requestPacket = new RequestPacket();
    try {
        QueryEx query = new QueryEx();
        query.getQueryRequestChoiceEx().add(queryParam);
        RequestEx request = new RequestEx();
        request.setQuery(query);
        requests.add(request);
        APIVersion apiVer = APIVersion.V_1_1;
        requestPacket.setApiVersion(apiVer);
        requestPacket.getRequestOrRequestEx().addAll(requests);
        _marshaller.marshal(requestPacket, outputStream);
        inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    } finally {
        try {
            outputStream.close();
        } catch (IOException e) {
            _logger.error("Exception occurred while closing the stream due to ", e);
        }
    }
    return inputStream;
}
Also used : RequestPacket(com.emc.nas.vnxfile.xmlapi.RequestPacket) APIVersion(com.emc.nas.vnxfile.xmlapi.APIVersion) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) RequestEx(com.emc.nas.vnxfile.xmlapi.RequestEx) QueryEx(com.emc.nas.vnxfile.xmlapi.QueryEx)

Example 2 with APIVersion

use of com.emc.nas.vnxfile.xmlapi.APIVersion in project coprhd-controller by CoprHD.

the class VNXFileInputRequestBuilder method getQueryParamPacket.

/**
 * Marshal the generated XML for a given QueryParam.
 *
 * @param queryParam : queryParam object.
 * @return
 */
public InputStream getQueryParamPacket(Object queryParam, boolean is_1_2_VerionToSet) throws JAXBException {
    InputStream inputStream = null;
    List<Request> requests = new ArrayList<Request>(1);
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    RequestPacket requestPacket = new RequestPacket();
    try {
        Query query = new Query();
        query.getQueryRequestChoice().add(queryParam);
        Request request = new Request();
        request.setQuery(query);
        requests.add(request);
        _logger.info("API Version to set {}", is_1_2_VerionToSet);
        if (is_1_2_VerionToSet) {
            _logger.info("Setting the API Version on Request Packet");
            APIVersion apiVer = APIVersion.V_1_2;
            requestPacket.setApiVersion(apiVer);
        }
        requestPacket.getRequestOrRequestEx().addAll(requests);
        _marshaller.marshal(requestPacket, outputStream);
        inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    } finally {
        try {
            outputStream.close();
        } catch (IOException e) {
            _logger.error("Exception occurred while closing the stream due to ", e);
        }
    }
    return inputStream;
}
Also used : RequestPacket(com.emc.nas.vnxfile.xmlapi.RequestPacket) Query(com.emc.nas.vnxfile.xmlapi.Query) APIVersion(com.emc.nas.vnxfile.xmlapi.APIVersion) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Request(com.emc.nas.vnxfile.xmlapi.Request) ArrayList(java.util.ArrayList) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Example 3 with APIVersion

use of com.emc.nas.vnxfile.xmlapi.APIVersion in project coprhd-controller by CoprHD.

the class VNXFileInputRequestBuilder method getTaskParamPacket.

public InputStream getTaskParamPacket(Object taskParam, boolean setApiVersion) throws JAXBException {
    InputStream inputStream = null;
    List<Request> requests = new ArrayList<Request>(1);
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    RequestPacket reqPacket = new RequestPacket();
    try {
        Task task = (Task) taskParam;
        Long timeout = 3000L;
        String timeoutStr = getTimeout();
        _logger.info("Time out value " + timeoutStr);
        if (timeoutStr != null && !timeoutStr.isEmpty()) {
            timeout = Long.parseLong(timeoutStr);
        }
        task.setTimeout(timeout);
        Request request = new Request();
        request.setStartTask(task);
        requests.add(request);
        if (setApiVersion) {
            APIVersion apiVer = APIVersion.V_1_1;
            reqPacket.setApiVersion(apiVer);
        }
        reqPacket.getRequestOrRequestEx().addAll(requests);
        _marshaller.marshal(reqPacket, outputStream);
        inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    } finally {
        try {
            outputStream.close();
        } catch (IOException e) {
            _logger.error("Exception occurred while closing the stream due to ", e);
        }
    }
    return inputStream;
}
Also used : Task(com.emc.nas.vnxfile.xmlapi.Task) RequestPacket(com.emc.nas.vnxfile.xmlapi.RequestPacket) APIVersion(com.emc.nas.vnxfile.xmlapi.APIVersion) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Request(com.emc.nas.vnxfile.xmlapi.Request) ArrayList(java.util.ArrayList) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Aggregations

APIVersion (com.emc.nas.vnxfile.xmlapi.APIVersion)3 RequestPacket (com.emc.nas.vnxfile.xmlapi.RequestPacket)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 ArrayList (java.util.ArrayList)3 Request (com.emc.nas.vnxfile.xmlapi.Request)2 Query (com.emc.nas.vnxfile.xmlapi.Query)1 QueryEx (com.emc.nas.vnxfile.xmlapi.QueryEx)1 RequestEx (com.emc.nas.vnxfile.xmlapi.RequestEx)1 Task (com.emc.nas.vnxfile.xmlapi.Task)1