@param maxBatchSize (mandatory) is the maximum number of messages to retrieve in this request
@see RetrieveMMSResponse
*/
public RetrieveMMSResponse retrieveMessages(String registrationId, int maxBatchSize) {
RetrieveMMSResponse response=new RetrieveMMSResponse();
if (registrationId!=null && maxBatchSize>=0) {
int responseCode=0;
String contentType = null;
try {
logger.debug("endpoint="+endPoints.getRetrieveMMSEndpoint());
String endpoint=endPoints.getRetrieveMMSEndpoint().replaceAll("\\{registrationId\\}", URLEncoder.encode(registrationId, "utf-8")).replaceAll("\\{maxBatchSize\\}", String.valueOf(maxBatchSize));
if (dumpRequestAndResponse) JSONRequest.dumpRequestVariables(endpoint, authorisationHeader, null);
HttpURLConnection con = JSONRequest.setupConnection(endpoint, authorisationHeader);
responseCode=con.getResponseCode();
contentType = con.getContentType();
response.setHTTPResponseCode(responseCode);
response.setContentType(contentType);
response=retrieveMMSprocessor.getResponse(con, OneAPIServlet.OK);
} catch (Exception e) {
logger.error("Exception "+e.getMessage()+" "+e.getLocalizedMessage());
e.printStackTrace();
response.setHTTPResponseCode(responseCode);
response.setContentType(contentType);
response.setRequestError(new RequestError(RequestError.SERVICEEXCEPTION, "SVCJAVA", e.getMessage(), e.getClass().getName()));
}
}
return response;
}