use of com.emc.nas.vnxfile.xmlapi.RequestPacket in project coprhd-controller by CoprHD.
the class VNXFileInputRequestBuilder method getSingleQueryStatsPacket.
/**
* Marshal the RequestPacket java object for the given QueryStats
* argument. This will be used when client wants to use QueryStats to retrieve information.
*
* @param stats : QueryStats
* @return : Stream of Input XML generated.
* @throws JAXBException
*/
public InputStream getSingleQueryStatsPacket(QueryStats stats) throws JAXBException {
InputStream inputStream = null;
List<Request> requests = new ArrayList<Request>(1);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
RequestPacket requestPacket = new RequestPacket();
try {
Request request = new Request();
request.setQueryStats(stats);
requests.add(request);
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.RequestPacket 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.RequestPacket 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.RequestPacket in project coprhd-controller by CoprHD.
the class VNXFileInputRequestBuilder method getMultiRequestQueryStatsPacket.
/**
* This method responsible to generate a multiple request packets
* for the given list of QueryStats.
*
* @param stats : list of QueryStats.
* @return : stream
*/
public InputStream getMultiRequestQueryStatsPacket(List<QueryStats> stats) throws JAXBException {
InputStream inputStream = null;
List<Request> requests = new ArrayList<Request>(stats.size());
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
RequestPacket requestPacket = new RequestPacket();
try {
// Create a new Request object for each QueryStat
for (QueryStats querStat : stats) {
Request request = new Request();
request.setQueryStats(querStat);
requests.add(request);
}
requestPacket.getRequestOrRequestEx().addAll(requests);
_marshaller.marshal(requestPacket, outputStream);
inputStream = new ByteArrayInputStream(outputStream.toByteArray());
} finally {
try {
outputStream.close();
} catch (IOException e) {
_logger.error("IOException occurred while querying due to ", e);
}
}
return inputStream;
}
use of com.emc.nas.vnxfile.xmlapi.RequestPacket 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