List of usage examples for org.apache.commons.httpclient HttpStatus SC_MULTI_STATUS
int SC_MULTI_STATUS
To view the source code for org.apache.commons.httpclient HttpStatus SC_MULTI_STATUS.
Click Source Link
From source file:davmail.caldav.TestCaldav.java
public void testPropfindPrincipal() throws IOException, DavException { //Settings.setLoggingLevel("httpclient.wire", Level.DEBUG); DavPropertyNameSet davPropertyNameSet = new DavPropertyNameSet(); davPropertyNameSet.add(DavPropertyName.create("calendar-home-set", Namespace.getNamespace("urn:ietf:params:xml:ns:caldav"))); davPropertyNameSet.add(DavPropertyName.create("calendar-user-address-set", Namespace.getNamespace("urn:ietf:params:xml:ns:caldav"))); davPropertyNameSet.add(DavPropertyName.create("schedule-inbox-URL", Namespace.getNamespace("urn:ietf:params:xml:ns:caldav"))); davPropertyNameSet.add(DavPropertyName.create("schedule-outbox-URL", Namespace.getNamespace("urn:ietf:params:xml:ns:caldav"))); PropFindMethod method = new PropFindMethod("/principals/users/" + session.getEmail() + "/", davPropertyNameSet, 0);// www. jav a 2s. c o m httpClient.executeMethod(method); assertEquals(HttpStatus.SC_MULTI_STATUS, method.getStatusCode()); MultiStatus multiStatus = method.getResponseBodyAsMultiStatus(); MultiStatusResponse[] responses = multiStatus.getResponses(); assertEquals(1, responses.length); }
From source file:davmail.caldav.TestCaldav.java
public void testPrincipalUrl() throws IOException, DavException { DavPropertyNameSet davPropertyNameSet = new DavPropertyNameSet(); davPropertyNameSet.add(DavPropertyName.create("principal-URL", Namespace.getNamespace("DAV:"))); PropFindMethod method = new PropFindMethod("/principals/users/" + session.getEmail(), davPropertyNameSet, 0);/* w ww. ja v a2s . c o m*/ httpClient.executeMethod(method); method.getResponseBodyAsMultiStatus(); assertEquals(HttpStatus.SC_MULTI_STATUS, method.getStatusCode()); }
From source file:davmail.caldav.TestCaldav.java
public void testPropfindRoot() throws IOException, DavException { DavPropertyNameSet davPropertyNameSet = new DavPropertyNameSet(); davPropertyNameSet.add(DavPropertyName.create("current-user-principal", Namespace.getNamespace("DAV:"))); davPropertyNameSet.add(DavPropertyName.create("principal-URL", Namespace.getNamespace("DAV:"))); davPropertyNameSet.add(DavPropertyName.create("resourcetype", Namespace.getNamespace("DAV:"))); PropFindMethod method = new PropFindMethod("/", davPropertyNameSet, 0); httpClient.executeMethod(method);//w ww. ja v a 2s . co m assertEquals(HttpStatus.SC_MULTI_STATUS, method.getStatusCode()); method.getResponseBodyAsMultiStatus(); }
From source file:davmail.caldav.TestCaldav.java
public void testPropfindAddressBook() throws IOException, DavException { DavPropertyNameSet davPropertyNameSet = new DavPropertyNameSet(); //davPropertyNameSet.add(DavPropertyName.create("getctag", Namespace.getNamespace("http://calendarserver.org/ns/"))); davPropertyNameSet.add(DavPropertyName.create("getetag", Namespace.getNamespace("DAV:"))); PropFindMethod method = new PropFindMethod("/users/" + session.getEmail() + "/addressbook/", davPropertyNameSet, 1);/* w w w . j av a 2 s .c o m*/ httpClient.getParams().setParameter(HttpMethodParams.USER_AGENT, "Address%20Book/883 CFNetwork/454.12.4 Darwin/10.8.0 (i386) (MacBookPro3%2C1)"); httpClient.executeMethod(method); assertEquals(HttpStatus.SC_MULTI_STATUS, method.getStatusCode()); method.getResponseBodyAsMultiStatus(); }
From source file:com.zimbra.qa.unittest.TestCalDav.java
public static Document calendarQuery(String url, Account acct) throws IOException, XmlParseException { ReportMethod method = new ReportMethod(url); addBasicAuthHeaderForUser(method, acct); HttpClient client = new HttpClient(); TestCalDav.HttpMethodExecutor executor; method.addRequestHeader("Content-Type", MimeConstants.CT_TEXT_XML); method.setRequestEntity(/*from w w w .jav a 2 s .c om*/ new ByteArrayRequestEntity(calendar_query_etags_by_vevent.getBytes(), MimeConstants.CT_TEXT_XML)); executor = new TestCalDav.HttpMethodExecutor(client, method, HttpStatus.SC_MULTI_STATUS); String respBody = new String(executor.responseBodyBytes, MimeConstants.P_CHARSET_UTF8); Document doc = W3cDomUtil.parseXMLToDoc(respBody); org.w3c.dom.Element docElement = doc.getDocumentElement(); assertEquals("Report node name", DavElements.P_MULTISTATUS, docElement.getLocalName()); return doc; }
From source file:davmail.http.DavGatewayHttpClientFacade.java
/** * Execute webdav request.//www .j a va 2 s . c o m * * @param httpClient http client instance * @param method webdav method * @return Responses enumeration * @throws IOException on error */ public static MultiStatusResponse[] executeMethod(HttpClient httpClient, DavMethodBase method) throws IOException { MultiStatusResponse[] responses = null; try { int status = httpClient.executeMethod(method); // need to follow redirects (once) on public folders if (isRedirect(status)) { method.releaseConnection(); URI targetUri = new URI(method.getResponseHeader("Location").getValue(), true); checkExpiredSession(targetUri.getQuery()); method.setURI(targetUri); status = httpClient.executeMethod(method); } if (status != HttpStatus.SC_MULTI_STATUS) { throw buildHttpException(method); } responses = method.getResponseBodyAsMultiStatus().getResponses(); } catch (DavException e) { throw new IOException(e.getMessage()); } finally { method.releaseConnection(); } return responses; }
From source file:davmail.http.DavGatewayHttpClientFacade.java
/** * Execute webdav request./*from w ww. j a va 2s . c om*/ * * @param httpClient http client instance * @param method webdav method * @return Responses enumeration * @throws IOException on error */ public static MultiStatusResponse[] executeMethod(HttpClient httpClient, ExchangeDavMethod method) throws IOException { MultiStatusResponse[] responses = null; try { int status = httpClient.executeMethod(method); // need to follow redirects (once) on public folders if (isRedirect(status)) { method.releaseConnection(); URI targetUri = new URI(method.getResponseHeader("Location").getValue(), true); checkExpiredSession(targetUri.getQuery()); method.setURI(targetUri); status = httpClient.executeMethod(method); } if (status != HttpStatus.SC_MULTI_STATUS) { throw buildHttpException(method); } responses = method.getResponses(); } finally { method.releaseConnection(); } return responses; }
From source file:davmail.caldav.CaldavConnection.java
/** * Send inbox response for request./* w ww .j a v a 2 s.c o m*/ * * @param request Caldav request * @throws IOException on error */ public void sendInbox(CaldavRequest request) throws IOException { CaldavResponse response = new CaldavResponse(HttpStatus.SC_MULTI_STATUS); response.startMultistatus(); appendInbox(response, request, null); // do not try to access inbox on shared calendar if (!session.isSharedFolder(request.getFolderPath(null)) && request.getDepth() == 1 && !request.isLightning()) { try { DavGatewayTray.debug(new BundleMessage("LOG_SEARCHING_CALENDAR_MESSAGES")); List<ExchangeSession.Event> events = session.getEventMessages(request.getFolderPath()); DavGatewayTray.debug(new BundleMessage("LOG_FOUND_CALENDAR_MESSAGES", events.size())); appendEventsResponses(response, request, events); } catch (HttpException e) { // unauthorized access, probably an inbox on shared calendar DavGatewayTray .debug(new BundleMessage("LOG_ACCESS_FORBIDDEN", request.getFolderPath(), e.getMessage())); } } response.endMultistatus(); response.close(); }
From source file:com.zimbra.qa.unittest.TestCalDav.java
public void checkPropFindSupportedReportSet(Account user, String fullurl, String shorturl) throws Exception { PropFindMethod method = new PropFindMethod(fullurl); addBasicAuthHeaderForUser(method, user); HttpClient client = new HttpClient(); TestCalDav.HttpMethodExecutor executor; String respBody;// ww w.j a v a2 s . c o m Element respElem; method.addRequestHeader("Content-Type", MimeConstants.CT_TEXT_XML); method.setRequestEntity( new ByteArrayRequestEntity(propFindSupportedReportSet.getBytes(), MimeConstants.CT_TEXT_XML)); executor = new TestCalDav.HttpMethodExecutor(client, method, HttpStatus.SC_MULTI_STATUS); respBody = new String(executor.responseBodyBytes, MimeConstants.P_CHARSET_UTF8); respElem = Element.XMLElement.parseXML(respBody); assertEquals("name of top element in response", DavElements.P_MULTISTATUS, respElem.getName()); assertTrue("top element response should have child elements", respElem.hasChildren()); checkSupportedReportSet(respElem, shorturl); }
From source file:davmail.caldav.CaldavConnection.java
/** * Send outbox response for request.// w ww .j a v a2 s .c om * * @param request Caldav request * @throws IOException on error */ public void sendOutbox(CaldavRequest request) throws IOException { CaldavResponse response = new CaldavResponse(HttpStatus.SC_MULTI_STATUS); response.startMultistatus(); appendOutbox(response, request, null); response.endMultistatus(); response.close(); }