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