List of usage examples for org.apache.commons.httpclient HttpStatus SC_NOT_MODIFIED
int SC_NOT_MODIFIED
To view the source code for org.apache.commons.httpclient HttpStatus SC_NOT_MODIFIED.
Click Source Link
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
public void sendNotification(Notification notification, int instanceId, int learningObjectId) throws Exception { String uri = String.format( _baseUri + "/LearningObjectService.svc/learningObjects/%s/instances/%s/Notification", learningObjectId, instanceId); PostMethod method = (PostMethod) getInitializedHttpMethod(_httpClient, uri, HttpMethodType.POST); String reportAsXml = serializeNotificationToXML(notification); InputStream is = new ByteArrayInputStream(reportAsXml.getBytes("UTF-8")); method.setRequestEntity(new InputStreamRequestEntity(is)); try {// www . j a v a 2 s . c o m int statusCode = _httpClient.executeMethod(method); // POST methods, may return 200, 201, 204 if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_CREATED && statusCode != HttpStatus.SC_NOT_MODIFIED) { throw new HTTPException(statusCode); } } catch (Exception ex) { ExceptionHandler.handle(ex); } finally { method.releaseConnection(); } }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
public void sendNotificationToUsers(Notification notification, int learningObjectId, int instanceId, int[] receiverUserIds, int senderUserId) throws Exception { String uri = String.format( _baseUri + "/LearningObjectService.svc/learningObjects/%s/instances/%s/NotificationToUsers", learningObjectId, instanceId); PostMethod method = (PostMethod) getInitializedHttpMethod(_httpClient, uri, HttpMethodType.POST); String reportAsXml = serializeNotificationToWrappedXML(notification); String userIdsAsXml = serializeUserIdsToWrappedXML(receiverUserIds); String senderUserIdAsXml = "<senderUserId>" + Integer.toString(senderUserId) + "</senderUserId>"; String openingTag = "<SendNotificationToUsers xmlns=\"http://tempuri.org/\">"; String closingTag = "</SendNotificationToUsers>"; StringBuilder xmlBuilder = new StringBuilder(); xmlBuilder.append(openingTag);//from w w w . j a v a 2 s .c o m xmlBuilder.append(reportAsXml); xmlBuilder.append(userIdsAsXml); xmlBuilder.append(senderUserIdAsXml); xmlBuilder.append(closingTag); method.setRequestEntity(new StringRequestEntity(xmlBuilder.toString(), "text/xml", "UTF-8")); try { int statusCode = _httpClient.executeMethod(method); // POST methods, may return 200, 201, 204 if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_CREATED && statusCode != HttpStatus.SC_NOT_MODIFIED) { throw new HTTPException(statusCode); } } catch (Exception ex) { ExceptionHandler.handle(ex); } finally { method.releaseConnection(); } }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
public void setUpdated(int instanceId, int learningObjectId) throws Exception { String uri = String.format(_baseUri + "/LearningObjectService.svc/learningObjects/%s/instances/%s/Updated", learningObjectId, instanceId); PostMethod method = (PostMethod) getInitializedHttpMethod(_httpClient, uri, HttpMethodType.POST); try {//www . j ava2 s .co m int statusCode = _httpClient.executeMethod(method); // POST methods, may return 200, 201, 204 if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_CREATED && statusCode != HttpStatus.SC_NOT_MODIFIED) { throw new HTTPException(statusCode); } } catch (Exception ex) { ExceptionHandler.handle(ex); } finally { method.releaseConnection(); } }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
public void updateLearningObjectInstanceUserReports(List<LearningObjectInstanceUserReport> userReports, int instanceId, int learningObjectId) throws Exception { String uri = String.format(_baseUri + "/LearningObjectService.svc/learningObjects/%s/instances/%s/Reports", learningObjectId, instanceId); PostMethod method = (PostMethod) getInitializedHttpMethod(_httpClient, uri, HttpMethodType.POST); String reportsAsXml = serializeLearningObjectInstanceUserReportsToXML(userReports); InputStream is = new ByteArrayInputStream(reportsAsXml.getBytes("UTF-8")); method.setRequestEntity(new InputStreamRequestEntity(is)); try {/*ww w . j a v a 2 s . c o m*/ int statusCode = _httpClient.executeMethod(method); // POST methods, may return 200, 201, 204 if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_CREATED && statusCode != HttpStatus.SC_NOT_MODIFIED) { throw new HTTPException(statusCode); } } catch (Exception ex) { ExceptionHandler.handle(ex); } finally { method.releaseConnection(); } }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
public void updateLearningObjectInstanceUserReport(LearningObjectInstanceUserReport userReport, int instanceId, int learningObjectId, int userId) throws Exception { String uri = String.format( _baseUri + "/LearningObjectService.svc/learningObjects/%s/instances/%s/Reports/%s", learningObjectId, instanceId, userId); PutMethod method = (PutMethod) getInitializedHttpMethod(_httpClient, uri, HttpMethodType.PUT); String reportAsXml = serializeLearningObjectInstanceUserReportToXML(userReport); InputStream is = new ByteArrayInputStream(reportAsXml.getBytes("UTF-8")); method.setRequestEntity(new InputStreamRequestEntity(is)); try {/*from w ww. j av a 2 s . c o m*/ int statusCode = _httpClient.executeMethod(method); // Put methods, may return 200, 201, 204 if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_CREATED && statusCode != HttpStatus.SC_NOT_MODIFIED) { throw new HTTPException(statusCode); } } catch (Exception ex) { ExceptionHandler.handle(ex); } finally { method.releaseConnection(); } }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
public void updateLearningObjectInstanceUserReportComment( LearningObjectInstanceUserReportCommentOnComment reportComment, int instanceId, int learningObjectId, int userId) throws Exception { String uri = String.format( _baseUri + "/LearningObjectService.svc/learningObjects/%s/instances/%s/Reports/%s/comments", learningObjectId, instanceId, userId); PutMethod method = (PutMethod) getInitializedHttpMethod(_httpClient, uri, HttpMethodType.PUT); String commentAsXml = serializeLearningObjectInstanceUserReportCommentOnCommentToXML(reportComment); InputStream is = new ByteArrayInputStream(commentAsXml.getBytes("UTF-8")); method.setRequestEntity(new InputStreamRequestEntity(is)); try {/*www.jav a 2s . co m*/ int statusCode = _httpClient.executeMethod(method); // Put methods, may return 200, 201, 204 if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_CREATED && statusCode != HttpStatus.SC_NOT_MODIFIED) { throw new HTTPException(statusCode); } } catch (Exception ex) { ExceptionHandler.handle(ex); } finally { method.releaseConnection(); } }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
public void updateLearningObjectInstanceUserReportCommentForCollaboration( LearningObjectInstanceUserReportCommentOnComment reportComment, int instanceId, int learningObjectId, int collaborationId) throws Exception { String uri = String.format(_baseUri + "/LearningObjectService.svc/learningObjects/%s/instances/%s/Collaborations/%s/Report/comments", learningObjectId, instanceId, collaborationId); PutMethod method = (PutMethod) getInitializedHttpMethod(_httpClient, uri, HttpMethodType.PUT); String commentAsXml = serializeLearningObjectInstanceUserReportCommentOnCommentToXML(reportComment); InputStream is = new ByteArrayInputStream(commentAsXml.getBytes("UTF-8")); method.setRequestEntity(new InputStreamRequestEntity(is)); try {// w ww . j a v a2s . co m int statusCode = _httpClient.executeMethod(method); // Put methods, may return 200, 201, 204 if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_CREATED && statusCode != HttpStatus.SC_NOT_MODIFIED) { throw new HTTPException(statusCode); } } catch (Exception ex) { ExceptionHandler.handle(ex); } finally { method.releaseConnection(); } }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
public void updateLearningObjectInstanceUserReportForCollaboration(LearningObjectInstanceUserReport userReport, int learningObjectId, int instanceId, int collaborationId) throws Exception { String uri = String.format( _baseUri + "/LearningObjectService.svc/learningObjects/%s/instances/%s/Collaborations/%s/Report", learningObjectId, instanceId, collaborationId); PutMethod method = (PutMethod) getInitializedHttpMethod(_httpClient, uri, HttpMethodType.PUT); String userReportAsXml = serializeLearningObjectInstanceUserReportToXML(userReport); InputStream is = new ByteArrayInputStream(userReportAsXml.getBytes("UTF-8")); method.setRequestEntity(new InputStreamRequestEntity(is)); try {/*from ww w . j ava 2s.c om*/ int statusCode = _httpClient.executeMethod(method); // Put methods, may return 200, 201, 204 if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_CREATED && statusCode != HttpStatus.SC_NOT_MODIFIED) { throw new HTTPException(statusCode); } } catch (Exception ex) { ExceptionHandler.handle(ex); } finally { method.releaseConnection(); } }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
/** * Deletes learning object instance user reports for specified collaboration ids * @param instanceId/*from w w w .ja v a 2s. c om*/ * @param learningObjectId * @param collaborationIds * @throws java.lang.Exception */ public void deleteLearningObjectInstanceUserReportsForCollaborations(int learningObjectId, int instanceId, int[] collaborationIds) throws Exception { String uri = String.format( _baseUri + "/LearningObjectService.svc/learningObjects/%s/instances/%s/collaborations/Reports", learningObjectId, instanceId); HttpDeleteWithBody method = new HttpDeleteWithBody(uri); StringBuilder xmlBuilder = new StringBuilder(); xmlBuilder.append(serializeListOfIntToWrappedXML(collaborationIds)); method.setEntity(new StringEntity(xmlBuilder.toString())); try { HttpResponse response = _httpClientForDelete.execute(method); StatusLine sl = response.getStatusLine(); int statusCode = sl.getStatusCode(); // Put methods, may return 200, 201, 204 if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_CREATED && statusCode != HttpStatus.SC_NOT_MODIFIED) { throw new HTTPException(statusCode); } } catch (Exception ex) { ExceptionHandler.handle(ex); } finally { method.abort(); } }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
/** * Deletes learning object instance user reports for specified collaboration ids * @param userIds//ww w . jav a 2s . c om * @param learningObjectId * @param instanceId * @throws java.lang.Exception */ public void deleteLearningObjectInstanceUserReports(int[] userIds, int learningObjectId, int instanceId) throws Exception { String uri = String.format(_baseUri + "/LearningObjectService.svc/learningObjects/%s/instances/%s/Reports", learningObjectId, instanceId); HttpDeleteWithBody method = new HttpDeleteWithBody(uri); StringBuilder xmlBuilder = new StringBuilder(); xmlBuilder.append(serializeListOfIntToWrappedXML(userIds)); method.setEntity(new StringEntity(xmlBuilder.toString())); try { HttpResponse response = _httpClientForDelete.execute(method); StatusLine sl = response.getStatusLine(); int statusCode = sl.getStatusCode(); // Put methods, may return 200, 201, 204 if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_CREATED && statusCode != HttpStatus.SC_NOT_MODIFIED) { throw new HTTPException(statusCode); } } catch (Exception ex) { ExceptionHandler.handle(ex); } finally { method.abort(); } }