Java Code Examples for org.apache.commons.httpclient.HttpStatus#SC_NO_CONTENT
The following examples show how to use
org.apache.commons.httpclient.HttpStatus#SC_NO_CONTENT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EwsExchangeSession.java From davmail with GNU General Public License v2.0 | 5 votes |
@Override public int sendEvent(String icsBody) throws IOException { String itemName = UUID.randomUUID().toString() + ".EML"; byte[] mimeContent = new Event(DRAFTS, itemName, "urn:content-classes:calendarmessage", icsBody, null, null).createMimeContent(); if (mimeContent == null) { // no recipients, cancel return HttpStatus.SC_NO_CONTENT; } else { sendMessage(null, mimeContent); return HttpStatus.SC_OK; } }
Example 2
Source File: DavExchangeSession.java From davmail with GNU General Public License v2.0 | 5 votes |
@Override public int sendEvent(String icsBody) throws IOException { String itemName = UUID.randomUUID().toString() + ".EML"; byte[] mimeContent = (new Event(getFolderPath(DRAFTS), itemName, "urn:content-classes:calendarmessage", icsBody, null, null)).createMimeContent(); if (mimeContent == null) { // no recipients, cancel return HttpStatus.SC_NO_CONTENT; } else { sendMessage(mimeContent); return HttpStatus.SC_OK; } }
Example 3
Source File: SOLRAPIClient.java From SearchServices with GNU Lesser General Public License v3.0 | 5 votes |
private void setStatus() { int status = response.getStatus(); if(status == HttpStatus.SC_NOT_MODIFIED) { this.status = SolrApiContentStatus.NOT_MODIFIED; } else if(status == HttpStatus.SC_INTERNAL_SERVER_ERROR) { this.status = SolrApiContentStatus.GENERAL_FAILURE; } else if(status == HttpStatus.SC_OK) { this.status = SolrApiContentStatus.OK; } else if(status == HttpStatus.SC_NO_CONTENT) { if(transformStatusStr == null) { this.status = SolrApiContentStatus.UNKNOWN; } else { if(transformStatusStr.equals("noTransform")) { this.status = SolrApiContentStatus.NO_TRANSFORM; } else if(transformStatusStr.equals("transformFailed")) { this.status = SolrApiContentStatus.TRANSFORM_FAILED; } else { this.status = SolrApiContentStatus.UNKNOWN; } } } }
Example 4
Source File: SystemRegistrationWorker.java From olat with Apache License 2.0 | 4 votes |
protected boolean doTheWork(String registrationData, String url, String version) { String registrationKey = propertyService.getStringProperty(PropertyLocator.SYSTEM_REG_SECRET_KEY); boolean regStatus = false; if (StringHelper.containsNonWhitespace(registrationData)) { // only send when there is something to send final HttpClient client = HttpClientFactory.getHttpClientInstance(); client.getParams().setParameter("http.useragent", "OLAT Registration Agent ; " + version); log.info("URL:" + url, null); final PutMethod method = new PutMethod(url); if (registrationKey != null) { // updating method.setRequestHeader("Authorization", registrationKey); if (log.isDebugEnabled()) { log.debug("Authorization: " + registrationKey, null); } else { log.debug("Authorization: EXISTS", null); } } else { log.info("Authorization: NONE", null); } method.setRequestHeader("Content-Type", "application/xml; charset=utf-8"); try { method.setRequestEntity(new StringRequestEntity(registrationData, "application/xml", "UTF8")); client.executeMethod(method); final int status = method.getStatusCode(); if (status == HttpStatus.SC_NOT_MODIFIED || status == HttpStatus.SC_OK) { log.info("Successfully registered OLAT installation on olat.org server, thank you for your support!", null); registrationKey = method.getResponseBodyAsString(); propertyService.setProperty(PropertyLocator.SYSTEM_REG_SECRET_KEY, registrationKey); regStatus = true; } else if (method.getStatusCode() == HttpStatus.SC_NOT_FOUND) { log.error("File could be created not on registration server::" + method.getStatusLine().toString(), null); regStatus = false; } else if (method.getStatusCode() == HttpStatus.SC_NO_CONTENT) { log.info(method.getResponseBodyAsString() + method.getStatusText()); regStatus = false; } else { log.error("Unexpected HTTP Status::" + method.getStatusLine().toString() + " during registration call", null); regStatus = false; } } catch (final Exception e) { log.error("Unexpected exception during registration call", e); regStatus = false; } } else { log.warn( "****************************************************************************************************************************************************************************", null); log.warn( "* This OLAT installation is not registered. Please, help us with your statistical data and register your installation under Adminisration - Systemregistration. THANK YOU! *", null); log.warn( "****************************************************************************************************************************************************************************", null); } return regStatus; }
Example 5
Source File: SystemRegistrationWorker.java From olat with Apache License 2.0 | 4 votes |
protected boolean doTheWork(String registrationData, String url, String version) { String registrationKey = propertyService.getStringProperty(PropertyLocator.SYSTEM_REG_SECRET_KEY); boolean regStatus = false; if (StringHelper.containsNonWhitespace(registrationData)) { // only send when there is something to send final HttpClient client = HttpClientFactory.getHttpClientInstance(); client.getParams().setParameter("http.useragent", "OLAT Registration Agent ; " + version); log.info("URL:" + url, null); final PutMethod method = new PutMethod(url); if (registrationKey != null) { // updating method.setRequestHeader("Authorization", registrationKey); if (log.isDebugEnabled()) { log.debug("Authorization: " + registrationKey, null); } else { log.debug("Authorization: EXISTS", null); } } else { log.info("Authorization: NONE", null); } method.setRequestHeader("Content-Type", "application/xml; charset=utf-8"); try { method.setRequestEntity(new StringRequestEntity(registrationData, "application/xml", "UTF8")); client.executeMethod(method); final int status = method.getStatusCode(); if (status == HttpStatus.SC_NOT_MODIFIED || status == HttpStatus.SC_OK) { log.info("Successfully registered OLAT installation on olat.org server, thank you for your support!", null); registrationKey = method.getResponseBodyAsString(); propertyService.setProperty(PropertyLocator.SYSTEM_REG_SECRET_KEY, registrationKey); regStatus = true; } else if (method.getStatusCode() == HttpStatus.SC_NOT_FOUND) { log.error("File could be created not on registration server::" + method.getStatusLine().toString(), null); regStatus = false; } else if (method.getStatusCode() == HttpStatus.SC_NO_CONTENT) { log.info(method.getResponseBodyAsString() + method.getStatusText()); regStatus = false; } else { log.error("Unexpected HTTP Status::" + method.getStatusLine().toString() + " during registration call", null); regStatus = false; } } catch (final Exception e) { log.error("Unexpected exception during registration call", e); regStatus = false; } } else { log.warn( "****************************************************************************************************************************************************************************", null); log.warn( "* This OLAT installation is not registered. Please, help us with your statistical data and register your installation under Adminisration - Systemregistration. THANK YOU! *", null); log.warn( "****************************************************************************************************************************************************************************", null); } return regStatus; }