List of usage examples for org.apache.commons.httpclient HttpStatus SC_CREATED
int SC_CREATED
To view the source code for org.apache.commons.httpclient HttpStatus SC_CREATED.
Click Source Link
From source file:davmail.caldav.CaldavConnection.java
protected void handleFolderOrItem(CaldavRequest request) throws IOException { String lastPath = StringUtil.xmlDecode(request.getLastPath()); // folder requests if (request.isPropFind() && "inbox".equals(lastPath)) { sendInbox(request);//ww w.j ava 2 s. com } else if (request.isPropFind() && "outbox".equals(lastPath)) { sendOutbox(request); } else if (request.isPost() && "outbox".equals(lastPath)) { if (request.isFreeBusy()) { sendFreeBusy(request.getBody()); } else { int status = session.sendEvent(request.getBody()); // TODO: implement Itip response body sendHttpResponse(status); } } else if (request.isPropFind()) { sendFolderOrItem(request); } else if (request.isPropPatch()) { patchCalendar(request); } else if (request.isReport()) { reportItems(request); // event requests } else if (request.isPut()) { String etag = request.getHeader("if-match"); String noneMatch = request.getHeader("if-none-match"); ExchangeSession.ItemResult itemResult = session.createOrUpdateItem(request.getFolderPath(), lastPath, request.getBody(), etag, noneMatch); sendHttpResponse(itemResult.status, buildEtagHeader(itemResult.etag), null, "", true); } else if (request.isDelete()) { if (request.getFolderPath().endsWith("inbox")) { session.processItem(request.getFolderPath(), lastPath); } else { session.deleteItem(request.getFolderPath(), lastPath); } sendHttpResponse(HttpStatus.SC_OK); } else if (request.isGet()) { if (request.path.endsWith("/")) { // GET request on a folder => build ics content of all folder events String folderPath = request.getFolderPath(); ExchangeSession.Folder folder = session.getFolder(folderPath); if (folder.isContact()) { List<ExchangeSession.Contact> contacts = session.getAllContacts(folderPath); ChunkedResponse response = new ChunkedResponse(HttpStatus.SC_OK, "text/vcard;charset=UTF-8"); for (ExchangeSession.Contact contact : contacts) { String contactBody = contact.getBody(); if (contactBody != null) { response.append(contactBody); response.append("\n"); } } response.close(); } else if (folder.isCalendar() || folder.isTask()) { List<ExchangeSession.Event> events = session.getAllEvents(folderPath); ChunkedResponse response = new ChunkedResponse(HttpStatus.SC_OK, "text/calendar;charset=UTF-8"); response.append("BEGIN:VCALENDAR\r\n"); response.append("VERSION:2.0\r\n"); response.append("PRODID:-//davmail.sf.net/NONSGML DavMail Calendar V1.1//EN\r\n"); response.append("METHOD:PUBLISH\r\n"); for (ExchangeSession.Event event : events) { String icsContent = StringUtil.getToken(event.getBody(), "BEGIN:VTIMEZONE", "END:VCALENDAR"); if (icsContent != null) { response.append("BEGIN:VTIMEZONE"); response.append(icsContent); } else { icsContent = StringUtil.getToken(event.getBody(), "BEGIN:VEVENT", "END:VCALENDAR"); if (icsContent != null) { response.append("BEGIN:VEVENT"); response.append(icsContent); } } } response.append("END:VCALENDAR"); response.close(); } else { sendHttpResponse(HttpStatus.SC_OK, buildEtagHeader(folder.etag), "text/html", (byte[]) null, true); } } else { ExchangeSession.Item item = session.getItem(request.getFolderPath(), lastPath); sendHttpResponse(HttpStatus.SC_OK, buildEtagHeader(item.getEtag()), item.getContentType(), item.getBody(), true); } } else if (request.isHead()) { // test event ExchangeSession.Item item = session.getItem(request.getFolderPath(), lastPath); sendHttpResponse(HttpStatus.SC_OK, buildEtagHeader(item.getEtag()), item.getContentType(), (byte[]) null, true); } else if (request.isMkCalendar()) { HashMap<String, String> properties = new HashMap<String, String>(); //properties.put("displayname", request.getProperty("displayname")); int status = session.createCalendarFolder(request.getFolderPath(), properties); sendHttpResponse(status, null); } else if (request.isMove()) { String destinationUrl = request.getHeader("destination"); session.moveItem(request.path, URIUtil.decode(new URL(destinationUrl).getPath())); sendHttpResponse(HttpStatus.SC_CREATED, null); } else { sendUnsupported(request); } }
From source file:com.sun.faban.harness.webclient.ResultAction.java
/** * This method is responsible for uploading the runs to repository. * @param uploadSet/*from w w w . ja v a2 s . c o m*/ * @param replaceSet * @return HashSet * @throws java.io.IOException */ public static HashSet<String> uploadRuns(String[] runIds, HashSet<File> uploadSet, HashSet<String> replaceSet) throws IOException { // 3. Upload the run HashSet<String> duplicates = new HashSet<String>(); // Prepare run id set for cross checking. HashSet<String> runIdSet = new HashSet<String>(runIds.length); for (String runId : runIds) { runIdSet.add(runId); } // Prepare the parts for the request. ArrayList<Part> params = new ArrayList<Part>(); params.add(new StringPart("host", Config.FABAN_HOST)); for (String replaceId : replaceSet) { params.add(new StringPart("replace", replaceId)); } for (File jarFile : uploadSet) { params.add(new FilePart("jarfile", jarFile)); } Part[] parts = new Part[params.size()]; parts = params.toArray(parts); // Send the request for each reposotory. for (URL repository : Config.repositoryURLs) { URL repos = new URL(repository, "/controller/uploader/upload_runs"); PostMethod post = new PostMethod(repos.toString()); post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams())); HttpClient client = new HttpClient(); client.getHttpConnectionManager().getParams().setConnectionTimeout(5000); int status = client.executeMethod(post); if (status == HttpStatus.SC_FORBIDDEN) logger.warning("Server denied permission to upload run !"); else if (status == HttpStatus.SC_NOT_ACCEPTABLE) logger.warning("Run origin error!"); else if (status != HttpStatus.SC_CREATED) logger.warning( "Server responded with status code " + status + ". Status code 201 (SC_CREATED) expected."); for (File jarFile : uploadSet) { jarFile.delete(); } String response = post.getResponseBodyAsString(); if (status == HttpStatus.SC_CREATED) { StringTokenizer t = new StringTokenizer(response.trim(), "\n"); while (t.hasMoreTokens()) { String duplicateRun = t.nextToken().trim(); if (duplicateRun.length() > 0) duplicates.add(duplicateRun.trim()); } for (Iterator<String> iter = duplicates.iterator(); iter.hasNext();) { String runId = iter.next(); if (!runIdSet.contains(runId)) { logger.warning("Unexpected archive response from " + repos + ": " + runId); iter.remove(); } } } else { logger.warning("Message from repository: " + response); } } return duplicates; }
From source file:edu.unc.lib.dl.fedora.ManagementClient.java
public String upload(File file, boolean retry) { String result = null;/*from w w w . ja v a 2s. c om*/ String uploadURL = this.getFedoraContextUrl() + "/upload"; PostMethod post = new PostMethod(uploadURL); post.getParams().setBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE, false); log.debug("Uploading file with forwarded groups: " + GroupsThreadStore.getGroupString()); post.addRequestHeader(HttpClientUtil.FORWARDED_GROUPS_HEADER, GroupsThreadStore.getGroupString()); try { log.debug("Uploading to " + uploadURL); Part[] parts = { new FilePart("file", file) }; post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams())); int status = httpClient.executeMethod(post); StringWriter sw = new StringWriter(); try (InputStream in = post.getResponseBodyAsStream(); PrintWriter pw = new PrintWriter(sw)) { int b; while ((b = in.read()) != -1) { pw.write(b); } } switch (status) { case HttpStatus.SC_OK: case HttpStatus.SC_CREATED: case HttpStatus.SC_ACCEPTED: result = sw.toString().trim(); log.info("Upload complete, response=" + result); break; case HttpStatus.SC_FORBIDDEN: log.warn("Authorization to Fedora failed, attempting to reestablish connection."); try { this.initializeConnections(); return upload(file, false); } catch (Exception e) { log.error("Failed to reestablish connection to Fedora", e); } break; case HttpStatus.SC_SERVICE_UNAVAILABLE: throw new FedoraTimeoutException("Fedora service unavailable, upload failed"); default: log.warn("Upload failed, response=" + HttpStatus.getStatusText(status)); log.debug(sw.toString().trim()); break; } } catch (ServiceException ex) { throw ex; } catch (Exception ex) { throw new ServiceException(ex); } finally { post.releaseConnection(); } return result; }
From source file:edu.unc.lib.dl.fedora.ManagementClient.java
public String upload(byte[] bytes, String fileName) { String result = null;/*from w w w .j a v a 2 s . com*/ // construct a post request to Fedora upload service String uploadURL = this.getFedoraContextUrl() + "/upload"; PostMethod post = new PostMethod(uploadURL); post.getParams().setBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE, false); log.debug("Uploading XML with forwarded groups: " + GroupsThreadStore.getGroupString()); post.addRequestHeader(HttpClientUtil.FORWARDED_GROUPS_HEADER, GroupsThreadStore.getGroupString()); try { log.debug("Uploading to " + uploadURL); Part[] parts = { new FilePart("file", new ByteArrayPartSource(fileName, bytes)) }; post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams())); int status = httpClient.executeMethod(post); StringWriter sw = new StringWriter(); try (InputStream in = post.getResponseBodyAsStream(); PrintWriter pw = new PrintWriter(sw)) { int b; while ((b = in.read()) != -1) { pw.write(b); } } if (status == HttpStatus.SC_OK || status == HttpStatus.SC_CREATED || status == HttpStatus.SC_ACCEPTED) { result = sw.toString().trim(); log.debug("Upload complete, response=" + result); } else { log.warn("Upload failed, response=" + HttpStatus.getStatusText(status)); log.debug(sw.toString().trim()); } } catch (Exception ex) { log.error("Upload failed due to error", ex); throw new ServiceException(ex); } finally { post.releaseConnection(); } return result; }
From source file:com.zimbra.qa.unittest.TestCalDav.java
/** * dav - sending http error 302 because: wrong url - redirecting to: * http://pan.local:7070/dav/dav1@pan.local/Calendar/d123f102-42a7-4283-b025-3376dabe53b3.ics * com.zimbra.cs.dav.DavException: wrong url - redirecting to: * http://pan.local:7070/dav/dav1@pan.local/Calendar/d123f102-42a7-4283-b025-3376dabe53b3.ics * at com.zimbra.cs.dav.resource.CalendarCollection.createItem(CalendarCollection.java:431) * at com.zimbra.cs.dav.service.method.Put.handle(Put.java:49) * at com.zimbra.cs.dav.service.DavServlet.service(DavServlet.java:322) *//*from w w w . ja va 2 s. c o m*/ @Test public void testCreateUsingClientChosenName() throws ServiceException, IOException { Account dav1 = users[1].create(); String davBaseName = "clientInvented.now"; String calFolderUrl = getFolderUrl(dav1, "Calendar"); String url = String.format("%s%s", calFolderUrl, davBaseName); HttpClient client = new HttpClient(); PutMethod putMethod = new PutMethod(url); addBasicAuthHeaderForUser(putMethod, dav1); putMethod.addRequestHeader("Content-Type", "text/calendar"); putMethod.setRequestEntity(new ByteArrayRequestEntity(simpleEvent(dav1), MimeConstants.CT_TEXT_CALENDAR)); if (DebugConfig.enableDAVclientCanChooseResourceBaseName) { HttpMethodExecutor.execute(client, putMethod, HttpStatus.SC_CREATED); } else { HttpMethodExecutor.execute(client, putMethod, HttpStatus.SC_MOVED_TEMPORARILY); // Not testing much in this mode but... return; } doGetMethod(url, dav1, HttpStatus.SC_OK); PropFindMethod propFindMethod = new PropFindMethod(getFolderUrl(dav1, "Calendar")); addBasicAuthHeaderForUser(propFindMethod, dav1); TestCalDav.HttpMethodExecutor executor; String respBody; Element respElem; propFindMethod.addRequestHeader("Content-Type", MimeConstants.CT_TEXT_XML); propFindMethod.addRequestHeader("Depth", "1"); propFindMethod.setRequestEntity( new ByteArrayRequestEntity(propFindEtagResType.getBytes(), MimeConstants.CT_TEXT_XML)); executor = new TestCalDav.HttpMethodExecutor(client, propFindMethod, HttpStatus.SC_MULTI_STATUS); respBody = new String(executor.responseBodyBytes, MimeConstants.P_CHARSET_UTF8); respElem = Element.XMLElement.parseXML(respBody); assertEquals("name of top element in propfind response", DavElements.P_MULTISTATUS, respElem.getName()); assertTrue("propfind response should have child elements", respElem.hasChildren()); Iterator<Element> iter = respElem.elementIterator(); boolean hasCalendarHref = false; boolean hasCalItemHref = false; while (iter.hasNext()) { Element child = iter.next(); if (DavElements.P_RESPONSE.equals(child.getName())) { Iterator<Element> hrefIter = child.elementIterator(DavElements.P_HREF); while (hrefIter.hasNext()) { Element href = hrefIter.next(); calFolderUrl.endsWith(href.getText()); hasCalendarHref = hasCalendarHref || calFolderUrl.endsWith(href.getText()); hasCalItemHref = hasCalItemHref || url.endsWith(href.getText()); } } } assertTrue("propfind response contained entry for calendar", hasCalendarHref); assertTrue("propfind response contained entry for calendar entry ", hasCalItemHref); doDeleteMethod(url, dav1, HttpStatus.SC_NO_CONTENT); }
From source file:com.zimbra.qa.unittest.TestCalDav.java
/** Mostly checking that if attendees cease to exist (even via DLs) then modification and cancel iTip * messages still work to the remaining attendees. *//*from w w w .java2 s . co m*/ @Test public void testCreateModifyDeleteAttendeeModifyAndCancel() throws ServiceException, IOException { Account dav1 = users[1].create(); Account dav2 = users[2].create(); Account dav3 = users[3].create(); Account dav4 = users[4].create(); DistributionList dl = TestUtil.createDistributionList(DL1); String[] members = { dav4.getName() }; prov.addMembers(dl, members); List<MailTarget> attendees = Lists.newArrayList(); attendees.add(dav1); attendees.add(dav2); attendees.add(dav3); attendees.add(dl); ZVCalendar vCal = simpleMeeting(dav1, attendees, "1", 8); ZProperty uidProp = vCal.getComponent(ICalTok.VEVENT).getProperty(ICalTok.UID); String uid = uidProp.getValue(); String davBaseName = uid + ".ics"; String url = String.format("%s%s", getFolderUrl(dav1, "Calendar"), davBaseName); doIcalPut(url, dav1, zvcalendarToBytes(vCal), HttpStatus.SC_CREATED); String inboxhref = TestCalDav.waitForNewSchedulingRequestByUID(dav2, uid); assertTrue("Found meeting request for newly created item", inboxhref.contains(uid)); doDeleteMethod(getLocalServerRoot().append(inboxhref).toString(), dav2, HttpStatus.SC_NO_CONTENT); // attendee via DL inboxhref = TestCalDav.waitForNewSchedulingRequestByUID(dav4, uid); assertTrue("Found meeting request for newly created item", inboxhref.contains(uid)); doDeleteMethod(getLocalServerRoot().append(inboxhref).toString(), dav4, HttpStatus.SC_NO_CONTENT); vCal = simpleMeeting(dav1, attendees, uid, "2", 9); doIcalPut(url, dav1, zvcalendarToBytes(vCal), HttpStatus.SC_CREATED); inboxhref = TestCalDav.waitForNewSchedulingRequestByUID(dav2, uid); assertTrue("Found meeting request for newly created item", inboxhref.contains(uid)); doDeleteMethod(getLocalServerRoot().append(inboxhref).toString(), dav2, HttpStatus.SC_NO_CONTENT); // attendee via DL inboxhref = TestCalDav.waitForNewSchedulingRequestByUID(dav4, uid); assertTrue("Found meeting request for newly created item", inboxhref.contains(uid)); doDeleteMethod(getLocalServerRoot().append(inboxhref).toString(), dav4, HttpStatus.SC_NO_CONTENT); // Test that iTip handling still happens when some of the attendees no longer exist. users[3].cleanup(); users[4].cleanup(); // attendee via DL vCal = simpleMeeting(dav1, attendees, uid, "3", 10); doIcalPut(url, dav1, zvcalendarToBytes(vCal), HttpStatus.SC_CREATED); inboxhref = TestCalDav.waitForNewSchedulingRequestByUID(dav2, uid); assertTrue("Found meeting request for newly created item", inboxhref.contains(uid)); doDeleteMethod(getLocalServerRoot().append(inboxhref).toString(), dav2, HttpStatus.SC_NO_CONTENT); String dav2Url = String.format("%s%s", getFolderUrl(dav2, "Calendar"), davBaseName); doGetMethod(dav2Url, dav2, HttpStatus.SC_OK); // Cancel meeting by deleting it doDeleteMethod(url, dav1, HttpStatus.SC_NO_CONTENT); inboxhref = TestCalDav.waitForNewSchedulingRequestByUID(dav2, uid); assertTrue("Found meeting request for newly created item", inboxhref.contains(uid)); doDeleteMethod(getLocalServerRoot().append(inboxhref).toString(), dav2, HttpStatus.SC_NO_CONTENT); // The associated calendar item should have been deleted as a result of the Cancel doGetMethod(dav2Url, dav2, HttpStatus.SC_NOT_FOUND); }
From source file:com.zimbra.cs.service.UserServlet.java
private static Pair<Header[], HttpMethod> doHttpOp(ZAuthToken authToken, HttpMethod method) throws ServiceException { // create an HTTP client with the same cookies String url = ""; String hostname = ""; try {//from www .ja v a 2s. c om url = method.getURI().toString(); hostname = method.getURI().getHost(); } catch (IOException e) { log.warn("can't parse target URI", e); } HttpClient client = ZimbraHttpConnectionManager.getInternalHttpConnMgr().newHttpClient(); Map<String, String> cookieMap = authToken.cookieMap(false); if (cookieMap != null) { HttpState state = new HttpState(); for (Map.Entry<String, String> ck : cookieMap.entrySet()) { state.addCookie(new org.apache.commons.httpclient.Cookie(hostname, ck.getKey(), ck.getValue(), "/", null, false)); } client.setState(state); client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); } if (method instanceof PutMethod) { long contentLength = ((PutMethod) method).getRequestEntity().getContentLength(); if (contentLength > 0) { int timeEstimate = Math.max(10000, (int) (contentLength / 100)); // 100kbps in millis // cannot set connection time using our ZimbrahttpConnectionManager, // see comments in ZimbrahttpConnectionManager. // actually, length of the content to Put should not be a factor for // establishing a connection, only read time out matter, which we set // client.getHttpConnectionManager().getParams().setConnectionTimeout(timeEstimate); method.getParams().setSoTimeout(timeEstimate); } } try { int statusCode = HttpClientUtil.executeMethod(client, method); if (statusCode == HttpStatus.SC_NOT_FOUND || statusCode == HttpStatus.SC_FORBIDDEN) throw MailServiceException.NO_SUCH_ITEM(-1); else if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_CREATED && statusCode != HttpStatus.SC_NO_CONTENT) throw ServiceException.RESOURCE_UNREACHABLE(method.getStatusText(), null, new ServiceException.InternalArgument(HTTP_URL, url, ServiceException.Argument.Type.STR), new ServiceException.InternalArgument(HTTP_STATUS_CODE, statusCode, ServiceException.Argument.Type.NUM)); List<Header> headers = new ArrayList<Header>(Arrays.asList(method.getResponseHeaders())); headers.add(new Header("X-Zimbra-Http-Status", "" + statusCode)); return new Pair<Header[], HttpMethod>(headers.toArray(new Header[0]), method); } catch (HttpException e) { throw ServiceException.RESOURCE_UNREACHABLE("HttpException while fetching " + url, e); } catch (IOException e) { throw ServiceException.RESOURCE_UNREACHABLE("IOException while fetching " + url, e); } }
From source file:com.zimbra.qa.unittest.TestCalDav.java
@Test public void testAndroidMeetingSeries() throws Exception { Account dav1 = users[1].create();//from w w w. j a v a 2 s . c om Account dav2 = users[2].create(); users[2].getZMailbox(); // Force creation of mailbox - shouldn't be needed String calFolderUrl = getFolderUrl(dav1, "Calendar").replaceAll("@", "%40"); String url = String.format("%s%s.ics", calFolderUrl, androidSeriesMeetingUid); HttpClient client = new HttpClient(); PutMethod putMethod = new PutMethod(url); addBasicAuthHeaderForUser(putMethod, dav1); putMethod.addRequestHeader("Content-Type", "text/calendar"); String body = androidSeriesMeetingTemplate.replace("%%ORG%%", dav1.getName()) .replace("%%ATT%%", dav2.getName()).replace("%%UID%%", androidSeriesMeetingUid); putMethod.setRequestEntity(new ByteArrayRequestEntity(body.getBytes(), MimeConstants.CT_TEXT_CALENDAR)); HttpMethodExecutor.execute(client, putMethod, HttpStatus.SC_CREATED); String inboxhref = TestCalDav.waitForNewSchedulingRequestByUID(dav2, androidSeriesMeetingUid); assertTrue("Found meeting request for newly created item", inboxhref.contains(androidSeriesMeetingUid)); GetMethod getMethod = new GetMethod(url); addBasicAuthHeaderForUser(getMethod, dav1); HttpMethodExecutor exe = HttpMethodExecutor.execute(client, getMethod, HttpStatus.SC_OK); String etag = null; for (Header hdr : exe.respHeaders) { if (DavProtocol.HEADER_ETAG.equals(hdr.getName())) { etag = hdr.getValue(); } } assertNotNull("ETag from get", etag); // Check that we fail if the etag is wrong putMethod = new PutMethod(url); addBasicAuthHeaderForUser(putMethod, dav1); putMethod.addRequestHeader("Content-Type", "text/calendar"); putMethod.addRequestHeader(DavProtocol.HEADER_IF_MATCH, "willNotMatch"); putMethod.setRequestEntity(new ByteArrayRequestEntity(body.getBytes(), MimeConstants.CT_TEXT_CALENDAR)); HttpMethodExecutor.execute(client, putMethod, HttpStatus.SC_PRECONDITION_FAILED); PropFindMethod propFindMethod = new PropFindMethod(getFolderUrl(dav1, "Calendar")); addBasicAuthHeaderForUser(propFindMethod, dav1); TestCalDav.HttpMethodExecutor executor; String respBody; Element respElem; propFindMethod.addRequestHeader("Content-Type", MimeConstants.CT_TEXT_XML); propFindMethod.addRequestHeader("Depth", "1"); propFindMethod.setRequestEntity( new ByteArrayRequestEntity(propFindEtagResType.getBytes(), MimeConstants.CT_TEXT_XML)); executor = new TestCalDav.HttpMethodExecutor(client, propFindMethod, HttpStatus.SC_MULTI_STATUS); respBody = new String(executor.responseBodyBytes, MimeConstants.P_CHARSET_UTF8); respElem = Element.XMLElement.parseXML(respBody); assertEquals("name of top element in propfind response", DavElements.P_MULTISTATUS, respElem.getName()); assertTrue("propfind response should have child elements", respElem.hasChildren()); Iterator<Element> iter = respElem.elementIterator(); boolean hasCalendarHref = false; boolean hasCalItemHref = false; while (iter.hasNext()) { Element child = iter.next(); if (DavElements.P_RESPONSE.equals(child.getName())) { Iterator<Element> hrefIter = child.elementIterator(DavElements.P_HREF); while (hrefIter.hasNext()) { Element href = hrefIter.next(); calFolderUrl.endsWith(href.getText()); hasCalendarHref = hasCalendarHref || calFolderUrl.endsWith(href.getText()); hasCalItemHref = hasCalItemHref || url.endsWith(href.getText()); } } } assertTrue("propfind response contained entry for calendar", hasCalendarHref); assertTrue("propfind response contained entry for calendar entry ", hasCalItemHref); DeleteMethod deleteMethod = new DeleteMethod(url); addBasicAuthHeaderForUser(deleteMethod, dav1); HttpMethodExecutor.execute(client, deleteMethod, HttpStatus.SC_NO_CONTENT); }
From source file:davmail.exchange.ews.EwsExchangeSession.java
/** * @inheritDoc/* w w w . j ava 2 s. c o m*/ */ @Override public int createFolder(String folderPath, String folderClass, Map<String, String> properties) throws IOException { FolderPath path = new FolderPath(folderPath); EWSMethod.Item folder = new EWSMethod.Item(); folder.type = "Folder"; folder.put("FolderClass", folderClass); folder.put("DisplayName", path.folderName); // TODO: handle properties CreateFolderMethod createFolderMethod = new CreateFolderMethod(getFolderId(path.parentPath), folder); executeMethod(createFolderMethod); return HttpStatus.SC_CREATED; }
From source file:davmail.exchange.ews.EwsExchangeSession.java
/** * @inheritDoc/*from w w w .jav a 2 s . c o m*/ */ @Override public int updateFolder(String folderPath, Map<String, String> properties) throws IOException { ArrayList<FieldUpdate> updates = new ArrayList<FieldUpdate>(); for (Map.Entry<String, String> entry : properties.entrySet()) { updates.add(new FieldUpdate(Field.get(entry.getKey()), entry.getValue())); } UpdateFolderMethod updateFolderMethod = new UpdateFolderMethod(internalGetFolder(folderPath).folderId, updates); executeMethod(updateFolderMethod); return HttpStatus.SC_CREATED; }