httpCon = (HttpURLConnection) url.openConnection();
httpCon.connect();
in = httpCon.getInputStream();
} catch (Exception e) {
// SCMP Version request
SCMPMessageFault fault = new SCMPMessageFault(reqMessage.getSCMPVersion(), SCMPError.SERVER_ERROR,
httpCon.getResponseMessage() + " " + e.getMessage());
LOGGER.warn("List file request failed " + httpCon.getResponseMessage());
return fault;
}
try {
// write the data to the client
SCMPMessage reply = null;
byte[] fullBuffer = new byte[Constants.DEFAULT_MESSAGE_PART_SIZE];
int readBytes = in.read(fullBuffer);
if (readBytes < 0) {
// this is the end - SCMP Version request
reply = new SCMPMessage(reqMessage.getSCMPVersion());
reply.setBody(new byte[0]);
in.close();
httpCon.disconnect();
return reply;
}
// set up part request, no poll request - SCMP Version request
reply = new SCMPMessage(reqMessage.getSCMPVersion());
reply.setBody(fullBuffer, 0, readBytes);
return reply;
} catch (Exception e) {
// SCMP Version request
SCMPMessageFault fault = new SCMPMessageFault(reqMessage.getSCMPVersion(), e, SCMPError.SERVER_ERROR);
LOGGER.warn("List file failed " + httpCon.getResponseMessage());
return fault;
}
}