List of usage examples for org.apache.commons.httpclient HttpMethod getResponseBodyAsStream
public abstract InputStream getResponseBodyAsStream() throws IOException;
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
public List<AppLicense> getAppLicensesForCurrentUser() throws Exception { List<AppLicense> appLicenses = new ArrayList<AppLicense>(); String uri = String.format(_baseUri + "/LearningObjectService.svc/AppLicensesForCurrentUser"); HttpMethod method = getInitializedHttpMethod(_httpClient, uri, HttpMethodType.GET); try {/*from w w w .ja v a 2 s .com*/ int statusCode = _httpClient.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { throw new HTTPException(statusCode); } else { if (Integer.parseInt(method.getResponseHeader("Content-Length").getValue()) > 0) { appLicenses = deserializeXMLToAppLicenses(method.getResponseBodyAsStream()); } } } catch (Exception ex) { ExceptionHandler.handle(ex); } finally { method.releaseConnection(); } return appLicenses; }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
public List<LearningObjectInstanceUser> getLearningObjectInstanceUsers(int instanceId, int learningObjectId, int[] userIds, boolean includeTeachers, int pageIndex, int pageSize, LearningObjectInstanceUser.OrderBy orderBy, OrderDirection orderDirection) throws Exception { String uri = String.format(_baseUri + "/LearningObjectService.svc/learningObjects/%s/instances/%s/Users", learningObjectId, instanceId); uri = appendLearningObjectInstanceUsersExtraParameters(uri, userIds, includeTeachers); uri = AppendPagingParams(uri, pageIndex, pageSize, orderBy, orderDirection); HttpMethod method = getInitializedHttpMethod(_httpClient, uri, HttpMethodType.GET); List<LearningObjectInstanceUser> users = new ArrayList<LearningObjectInstanceUser>(); try {/*from w w w . j a v a2s. co m*/ int statusCode = _httpClient.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { throw new HTTPException(statusCode); } else { users = deserializeXMLToListOfLearningObjectInstanceUser(method.getResponseBodyAsStream()); } } catch (Exception ex) { ExceptionHandler.handle(ex); } finally { method.releaseConnection(); } return users; }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
public Site getSiteForCurrentUser() throws Exception { String uri = String.format(_baseUri + "/LearningObjectService.svc/SiteForCurrentUser"); HttpMethod method = getInitializedHttpMethod(_httpClient, uri, HttpMethodType.GET); Site siteForUser = null;// w ww. j a va 2s. c o m try { int statusCode = _httpClient.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { throw new HTTPException(statusCode); } else { if (Integer.parseInt(method.getResponseHeader("Content-Length").getValue()) > 0) { siteForUser = deserializeXMLToSite(method.getResponseBodyAsStream()); } else { return null; } } } catch (Exception ex) { ExceptionHandler.handle(ex); } finally { method.releaseConnection(); } return siteForUser; }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
public List<LearningObjectInstanceUserReport> getLearningObjectInstanceUserReports(int instanceId, int learningObjectId, int pageIndex, int pageSize, LearningObjectInstanceUserReport.OrderBy orderBy, OrderDirection orderDirection) throws Exception { String uri = String.format(_baseUri + "/LearningObjectService.svc/learningObjects/%s/instances/%s/Reports", learningObjectId, instanceId); uri = AppendPagingParams(uri, pageIndex, pageSize, orderBy, orderDirection); HttpMethod method = getInitializedHttpMethod(_httpClient, uri, HttpMethodType.GET); List<LearningObjectInstanceUserReport> reports = new ArrayList<LearningObjectInstanceUserReport>(); try {//from w w w . ja v a 2 s. c o m int statusCode = _httpClient.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { throw new HTTPException(statusCode); } else { reports = deserializeXMLToListOfLearningObjectInstanceUserReport(method.getResponseBodyAsStream()); } } catch (Exception ex) { ExceptionHandler.handle(ex); } finally { method.releaseConnection(); } return reports; }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
public List<AssessmentStatus> getPossibleAssessmentStatuses(int instanceId, int learningObjectId) throws Exception { String uri = String.format( _baseUri + "/LearningObjectService.svc/learningObjects/%s/instances/%s/PossibleAssessmentStatuses", learningObjectId, instanceId); HttpMethod method = getInitializedHttpMethod(_httpClient, uri, HttpMethodType.GET); List<AssessmentStatus> assessmentStatuses = new ArrayList<AssessmentStatus>(); try {// www . j a va 2 s . co m int statusCode = _httpClient.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { throw new HTTPException(statusCode); } else { assessmentStatuses = deserializeXMLToListOfPossibleAssessmentStatuses( method.getResponseBodyAsStream()); } } catch (Exception ex) { ExceptionHandler.handle(ex); } finally { method.releaseConnection(); } return assessmentStatuses; }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
public List<AssessmentStatusItem> getAssessmentStatusItems(int instanceId, int learningObjectId) throws Exception { String uri = String.format( _baseUri + "/LearningObjectService.svc/learningObjects/%s/instances/%s/AssessmentStatusItems", learningObjectId, instanceId); HttpMethod method = getInitializedHttpMethod(_httpClient, uri, HttpMethodType.GET); List<AssessmentStatusItem> assessmentStatusItems = new ArrayList<AssessmentStatusItem>(); try {// w w w . jav a 2 s . co m int statusCode = _httpClient.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { throw new HTTPException(statusCode); } else { assessmentStatusItems = deserializeXMLToListOfAssessmentStatusItems( method.getResponseBodyAsStream()); } } catch (Exception ex) { ExceptionHandler.handle(ex); } finally { method.releaseConnection(); } return assessmentStatusItems; }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
/** * Returns customer settings//from w w w.j a v a 2s. c o m */ public CustomerSettings getCustomerSettings() throws Exception { String uri = String.format(_baseUri + "/LearningObjectService.svc/CustomerSettings"); HttpMethod method = getInitializedHttpMethod(_httpClient, uri, HttpMethodType.GET); CustomerSettings customerSettings = null; try { int statusCode = _httpClient.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { throw new HTTPException(statusCode); } else { if (Integer.parseInt(method.getResponseHeader("Content-Length").getValue()) > 0) { customerSettings = deserializeXMLToCustomerSettings(method.getResponseBodyAsStream()); } else { return null; } } } catch (Exception ex) { ExceptionHandler.handle(ex); } finally { method.releaseConnection(); } return customerSettings; }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
/** * Get a list of collaborations participants for instance. * @param learningObjectId//w w w . j a v a 2s. c o m * @param instanceId * @param collaborationIds The array of user IDs to filter by. * @return * @throws java.lang.Exception */ public List<CollaborationParticipant> getLearningObjectInstanceCollaborationsParticipants(int learningObjectId, int instanceId, int[] collaborationIds) throws Exception { String uri = String.format(_baseUri + "/LearningObjectService.svc/learningObjects/%s/instances/%s/collaborations/participants?collaborationIds=%s", learningObjectId, instanceId, intArrayToCsvString(collaborationIds)); HttpMethod method = getInitializedHttpMethod(_httpClient, uri, HttpMethodType.GET); List<CollaborationParticipant> collaborationParticipants = new ArrayList<CollaborationParticipant>(); try { int statusCode = _httpClient.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { throw new HTTPException(statusCode); } else { collaborationParticipants = deserializeXMLToListOfCollaborationParticipant( method.getResponseBodyAsStream()); } } catch (Exception ex) { ExceptionHandler.handle(ex); } finally { method.releaseConnection(); } return collaborationParticipants; }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
public List<RubricCriteriaItem> getRubricCriteria(int learningObjectId, int instanceId) throws Exception { String uri = String.format( _baseUri + "/LearningObjectService.svc/learningObjects/%s/instances/%s/RubricCriteria", learningObjectId, instanceId); HttpMethod method = getInitializedHttpMethod(_httpClient, uri, HttpMethodType.GET); List<RubricCriteriaItem> criteriaCreator = new ArrayList<RubricCriteriaItem>(); try {/*from w ww.j av a 2s.c om*/ int statusCode = _httpClient.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { throw new HTTPException(statusCode); } else { if (Integer.parseInt(method.getResponseHeader("Content-Length").getValue()) > 0) { criteriaCreator = deserializeXMLToCriteria(method.getResponseBodyAsStream()); } else { return null; } } } catch (Exception ex) { ExceptionHandler.handle(ex); } finally { method.releaseConnection(); } return criteriaCreator; }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
public List<Organisation> getOrganisationsForCurrentUser() throws Exception { String uri = String.format(_baseUri + "/LearningObjectService.svc/OrganizationsForCurrentUser"); HttpMethod method = getInitializedHttpMethod(_httpClient, uri, HttpMethodType.GET); List<Organisation> organizationsForUser = new ArrayList<Organisation>(); try {//from ww w . ja v a 2s . co m int statusCode = _httpClient.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { throw new HTTPException(statusCode); } else { if (Integer.parseInt(method.getResponseHeader("Content-Length").getValue()) > 0) { organizationsForUser = deserializeXMLToOrganisations(method.getResponseBodyAsStream()); } else { return null; } } } catch (Exception ex) { ExceptionHandler.handle(ex); } finally { method.releaseConnection(); } return organizationsForUser; }