Examples of MkcolMethod


Examples of org.apache.webdav.lib.methods.MkcolMethod

     * @param expect the return status expected.
     * @return the {@link HttpMethod} which contains the response.
     */
    protected HttpMethod mkCol(String url, int expect)
    {
        MkcolMethod mkColMethod = new MkcolMethod();
        mkColMethod.setDoAuthentication(true);
        mkColMethod.setPath(url);
        testMethod(mkColMethod, expect);
        return mkColMethod;
    }
View Full Code Here

Examples of org.apache.webdav.lib.methods.MkcolMethod

    public void testCreateAndDeleteSpace()
    {
        String spaceUrl = SPACES + "/TestSpace";
        DeleteMethod deleteMethod = new DeleteMethod();
        deleteMethod.setDoAuthentication(true);
        MkcolMethod mkColMethod = new MkcolMethod();
        mkColMethod.setDoAuthentication(true);
        try {
            deleteMethod.setPath(spaceUrl);
            assertEquals(DavServletResponse.SC_NO_CONTENT, getHttpClient().executeMethod(deleteMethod));
            mkColMethod.setPath(spaceUrl);
            assertEquals(DavServletResponse.SC_CREATED, getHttpClient().executeMethod(mkColMethod));
            deleteMethod.setPath(spaceUrl);
            assertEquals(DavServletResponse.SC_NO_CONTENT, getHttpClient().executeMethod(deleteMethod));
        } catch (HttpException ex) {
            fail(ex.getMessage());
View Full Code Here

Examples of org.apache.webdav.lib.methods.MkcolMethod

        String spaceUrl = SPACES + "/TestSpace";
        String relativeDestinationPath = "/xwiki/webdav/spaces/RenamedTestSpace";
        String movedSpaceUrl = SPACES + "/RenamedTestSpace";
        DeleteMethod deleteMethod = new DeleteMethod();
        deleteMethod.setDoAuthentication(true);
        MkcolMethod mkColMethod = new MkcolMethod();
        mkColMethod.setDoAuthentication(true);
        MoveMethod moveMethod = new MoveMethod();
        moveMethod.setDoAuthentication(true);
        try {
            deleteMethod.setPath(spaceUrl);
            assertEquals(DavServletResponse.SC_NO_CONTENT, getHttpClient().executeMethod(deleteMethod));
            deleteMethod.setPath(movedSpaceUrl);
            assertEquals(DavServletResponse.SC_NO_CONTENT, getHttpClient().executeMethod(deleteMethod));
            mkColMethod.setPath(spaceUrl);
            assertEquals(DavServletResponse.SC_CREATED, getHttpClient().executeMethod(mkColMethod));
            moveMethod.setPath(spaceUrl);
            moveMethod.setDestination(relativeDestinationPath);
            assertEquals(DavServletResponse.SC_CREATED, getHttpClient().executeMethod(moveMethod));
            deleteMethod.setPath(movedSpaceUrl);
View Full Code Here

Examples of org.apache.webdav.lib.methods.MkcolMethod

    {
        String spaceUrl = SPACES + "/TestSpace";
        String pageUrl = spaceUrl + "/TestPage";
        DeleteMethod deleteMethod = new DeleteMethod();
        deleteMethod.setDoAuthentication(true);
        MkcolMethod mkColMethod = new MkcolMethod();
        mkColMethod.setDoAuthentication(true);
        try {
            deleteMethod.setPath(spaceUrl);
            assertEquals(DavServletResponse.SC_NO_CONTENT, getHttpClient().executeMethod(deleteMethod));
            mkColMethod.setPath(spaceUrl);
            assertEquals(DavServletResponse.SC_CREATED, getHttpClient().executeMethod(mkColMethod));
            mkColMethod.setPath(pageUrl);
            assertEquals(DavServletResponse.SC_CREATED, getHttpClient().executeMethod(mkColMethod));
            deleteMethod.setPath(pageUrl);
            assertEquals(DavServletResponse.SC_NO_CONTENT, getHttpClient().executeMethod(deleteMethod));
            deleteMethod.setPath(spaceUrl);
            assertEquals(DavServletResponse.SC_NO_CONTENT, getHttpClient().executeMethod(deleteMethod));
View Full Code Here

Examples of org.apache.webdav.lib.methods.MkcolMethod

        String pageUrl = spaceUrl + "/TestPage";
        String wikiTextFileUrl = pageUrl + "/wiki.txt";
        String wikiXMLFileUrl = pageUrl + "/wiki.xml";
        DeleteMethod deleteMethod = new DeleteMethod();
        deleteMethod.setDoAuthentication(true);
        MkcolMethod mkColMethod = new MkcolMethod();
        mkColMethod.setDoAuthentication(true);
        GetMethod getMethod = new GetMethod();
        getMethod.setDoAuthentication(true);
        try {
            deleteMethod.setPath(spaceUrl);
            assertEquals(DavServletResponse.SC_NO_CONTENT, getHttpClient().executeMethod(deleteMethod));
            mkColMethod.setPath(spaceUrl);
            assertEquals(DavServletResponse.SC_CREATED, getHttpClient().executeMethod(mkColMethod));
            mkColMethod.setPath(pageUrl);
            assertEquals(DavServletResponse.SC_CREATED, getHttpClient().executeMethod(mkColMethod));
            getMethod.setPath(wikiTextFileUrl);
            assertEquals(DavServletResponse.SC_OK, getHttpClient().executeMethod(getMethod));
            assertTrue(getMethod.getResponseBodyAsStream().read() != -1);
            getMethod.setPath(wikiXMLFileUrl);
View Full Code Here

Examples of org.apache.webdav.lib.methods.MkcolMethod

        String wikiTextFileUrl = pageUrl + "/wiki.txt";
        String wikiXMLFileUrl = pageUrl + "/wiki.xml";
        String newContent = "New Content";
        DeleteMethod deleteMethod = new DeleteMethod();
        deleteMethod.setDoAuthentication(true);
        MkcolMethod mkColMethod = new MkcolMethod();
        mkColMethod.setDoAuthentication(true);
        PutMethod putMethod = new PutMethod();
        putMethod.setDoAuthentication(true);
        GetMethod getMethod = new GetMethod();
        getMethod.setDoAuthentication(true);
        try {
            deleteMethod.setPath(spaceUrl);
            assertEquals(DavServletResponse.SC_NO_CONTENT, getHttpClient().executeMethod(deleteMethod));
            mkColMethod.setPath(spaceUrl);
            assertEquals(DavServletResponse.SC_CREATED, getHttpClient().executeMethod(mkColMethod));
            mkColMethod.setPath(pageUrl);
            assertEquals(DavServletResponse.SC_CREATED, getHttpClient().executeMethod(mkColMethod));
            putMethod.setPath(wikiTextFileUrl);
            putMethod.setRequestEntity(new InputStreamRequestEntity(new ByteArrayInputStream(newContent.getBytes())));
            // Already existing resource, in which case SC_NO_CONTENT will be the return status.
            assertEquals(DavServletResponse.SC_NO_CONTENT, getHttpClient().executeMethod(putMethod));
View Full Code Here

Examples of org.apache.webdav.lib.methods.MkcolMethod

        String pageUrl = spaceUrl + "/TestPage";
        String attachmentUrl = pageUrl + "/attachment.txt";
        String attachmentContent = "Attachment Content";
        DeleteMethod deleteMethod = new DeleteMethod();
        deleteMethod.setDoAuthentication(true);
        MkcolMethod mkColMethod = new MkcolMethod();
        mkColMethod.setDoAuthentication(true);
        PutMethod putMethod = new PutMethod();
        putMethod.setDoAuthentication(true);
        GetMethod getMethod = new GetMethod();
        getMethod.setDoAuthentication(true);
        try {
            deleteMethod.setPath(spaceUrl);
            assertEquals(DavServletResponse.SC_NO_CONTENT, getHttpClient().executeMethod(deleteMethod));
            mkColMethod.setPath(spaceUrl);
            assertEquals(DavServletResponse.SC_CREATED, getHttpClient().executeMethod(mkColMethod));
            mkColMethod.setPath(pageUrl);
            assertEquals(DavServletResponse.SC_CREATED, getHttpClient().executeMethod(mkColMethod));
            getMethod.setPath(attachmentUrl);
            assertEquals(DavServletResponse.SC_NOT_FOUND, getHttpClient().executeMethod(getMethod));
            putMethod.setPath(attachmentUrl);
            putMethod.setRequestEntity(new InputStreamRequestEntity(new ByteArrayInputStream(attachmentContent
View Full Code Here

Examples of org.apache.webdav.lib.methods.MkcolMethod

     */
    public boolean mkcolMethod(String path)
        throws HttpException, IOException {

        setClient();
        MkcolMethod method = new MkcolMethod(URIUtil.encodePath(path));
        generateIfHeader(method);
        int statusCode = client.executeMethod(method);

        // Possbile MKCOL Status Codes => SC_CREATED
        // WebdavStatus.SC_FORBIDDEN, SC_METHOD_NOT_ALLOWED, SC_CONFLICT,
View Full Code Here

Examples of org.apache.webdav.lib.methods.MkcolMethod

      }

      boolean created = !toBeCreated.empty();
      while(!toBeCreated.empty()) {
         HttpURL newColl = Utils.createHttpURL(httpURL, (String)toBeCreated.pop());
         MkcolMethod mkcol = new MkcolMethod(newColl.getURI());
         mkcol.setFollowRedirects(true);
         generateIfHeader(mkcol, lockToken);
         int status = client.executeMethod(mkcol);
         if (status != WebdavStatus.SC_CREATED) {
            HttpException ex = new HttpException("Can't create collection " +
                                                 newColl);
            ex.setReasonCode(status);
            ex.setReason(mkcol.getStatusText());
            throw ex;
         }
      }
      return created;
   }
View Full Code Here

Examples of org.apache.webdav.lib.methods.MkcolMethod

      Value userExists = getResource(new URIValue(users+username), credentials);
      if ( userExists == NullValue.NULL || userExists != null ) {
            throw new UserExistsException(new ErrorMessage("userExists", new String[] { username }));
        } else {
          URI userUri = new URIValue(users+username);
          MkcolMethod mkcolMethod = new MkcolMethod(domain+userUri.toString());
          mkcolMethod.setDoAuthentication(true);
            HttpState httpState = new HttpState();
            httpState.setCredentials(null, host, credentials);
            int state = mkcolMethod.execute(httpState, new HttpConnection(host, port, protocol));
            if ( state == HttpStatus.SC_CREATED ) {
              changePassword(userUri, null, password, credentials);
              return userUri;
            }
            return null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.