Package org.exoplatform.services.rest.impl

Examples of org.exoplatform.services.rest.impl.MultivaluedMapImpl


         getPathWS() + "/" + fileNode.getName() + "?time=" + IfModifiedSince.getTimeInMillis() + "&version=1";

      SimpleDateFormat dateFormat = new SimpleDateFormat(WebDavConst.DateFormat.IF_MODIFIED_SINCE_PATTERN, Locale.US);
      String ifModifiedSinceDate = dateFormat.format(IfModifiedSince.getTime());

      MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
      headers.add(ExtHttpHeaders.IF_MODIFIED_SINCE, ifModifiedSinceDate);
      ContainerResponse response = service(WebDAVMethods.GET, path, "", headers, null);
      assertEquals(HTTPStatus.OK, response.getStatus());

      headers.clear();

      IfModifiedSince.add(Calendar.HOUR, +4);
      ifModifiedSinceDate = dateFormat.format(IfModifiedSince.getTime());
      headers.add(ExtHttpHeaders.IF_MODIFIED_SINCE, ifModifiedSinceDate);
      response = service(WebDAVMethods.GET, path, "", headers, null);
      assertEquals(HTTPStatus.NOT_MODIFIED, response.getStatus());
   }
View Full Code Here


      InputStream inputStream = new ByteArrayInputStream(fileContent.getBytes());
      TestUtils.addContent(session, path, inputStream, defaultFileNodeType, "");
      String lockToken = TestUtils.lockNode(session, path, true);
      ContainerResponse response = service(WebDAVMethods.DELETE, getPathWS() + path, "", null, null);
      assertEquals(HTTPStatus.LOCKED, response.getStatus());
      MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
      headers.add(ExtHttpHeaders.LOCKTOKEN, lockToken);
      response = service(WebDAVMethods.DELETE, getPathWS() + path, "", headers, null);
      assertEquals(HTTPStatus.NO_CONTENT, response.getStatus());
      assertFalse(session.getRootNode().hasNode(TextUtil.relativizePath(path)));
   }
View Full Code Here

      ContainerResponse containerResponse =
         service(WebDAVMethods.PUT, getPathWS() + TestUtils.getFileName(), "", null, content.getBytes());
      assertEquals(HTTPStatus.CREATED, containerResponse.getStatus());

      MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
      headers.add(ExtHttpHeaders.FILE_NODETYPE, "nt:folder");
      containerResponse =
         service(WebDAVMethods.PUT, getPathWS() + TestUtils.getFileName(), "", headers, content.getBytes());
      assertEquals(HTTPStatus.BAD_REQUEST, containerResponse.getStatus());

      String fileName = TestUtils.getFileName();
      headers = new MultivaluedMapImpl();
      headers.add(ExtHttpHeaders.FILE_NODETYPE, "nt:file");
      containerResponse = service(WebDAVMethods.PUT, getPathWS() + fileName, "", headers, content.getBytes());
      assertEquals(HTTPStatus.CREATED, containerResponse.getStatus());
      assertEquals("nt:file", TestUtils.getFileNodeType(session, fileName));

   }
View Full Code Here

   public void testPutContentTypeHeader() throws Exception
   {
      String content = TestUtils.getFileContent();
      String fileName = TestUtils.getFileName();

      MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
      headers.add(ExtHttpHeaders.CONTENT_NODETYPE, "webdav:goodres");
      ContainerResponse containerResponse =
         service(WebDAVMethods.PUT, getPathWS() + fileName, "", headers, content.getBytes());
      assertEquals(HTTPStatus.CREATED, containerResponse.getStatus());
      assertEquals("webdav:goodres", TestUtils.getContentNodeType(session, fileName));

      headers = new MultivaluedMapImpl();
      headers.add(ExtHttpHeaders.CONTENT_NODETYPE, "webdav:badres");
      containerResponse =
         service(WebDAVMethods.PUT, getPathWS() + TestUtils.getFileName(), "", headers, content.getBytes());
      assertEquals(HTTPStatus.BAD_REQUEST, containerResponse.getStatus());

   }
View Full Code Here

   public void testPutMixinsHeader() throws Exception
   {
      String content = TestUtils.getFileContent();
      String fileName = TestUtils.getFileName();

      MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
      headers.add(ExtHttpHeaders.CONTENT_NODETYPE, "webdav:goodres");
      headers.add(ExtHttpHeaders.CONTENT_MIXINTYPES, "mix:wdTestMixin1,mix:wdTestMixin2");
      ContainerResponse containerResponse =
         service(WebDAVMethods.PUT, getPathWS() + fileName, "", headers, content.getBytes());
      assertEquals(HTTPStatus.CREATED, containerResponse.getStatus());
      NodeType[] mixins = TestUtils.getContentMixins(session, fileName);
View Full Code Here

   public void testMimeType() throws Exception
   {
      String content = TestUtils.getFileContent();
      String path = TestUtils.getFileName();
      MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
      headers.add(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_XML);
      ContainerResponse containerResponse =
         service(WebDAVMethods.PUT, getPathWS() + path, "", headers, content.getBytes());
      assertEquals(HTTPStatus.CREATED, containerResponse.getStatus());
      assertTrue(session.getRootNode().hasNode(TextUtil.relativizePath(path)));
      Node node = session.getRootNode().getNode(TextUtil.relativizePath(path));
      assertTrue(node.hasNode("jcr:content"));
      Node node2 = node.getNode("jcr:content");
      assertTrue(node2.hasProperty("jcr:mimeType"));
      PropertyImpl property = (PropertyImpl)node2.getProperty("jcr:mimeType");
      assertEquals(headers.getFirst(HttpHeaders.CONTENT_TYPE), property.getString());
   }
View Full Code Here

      String path = TestUtils.getFileName();

      // create User-Agent header indicating that the resource we create
      // has application/octet-stream type
      // though it's extension is .txt
      MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
      headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM);
      headers.add(HttpHeaders.USER_AGENT, "test-user-agent");

      // fullfiling the request
      service(WebDAVMethods.PUT, getPathWS() + path, "", headers, content.getBytes());

      Node node = session.getRootNode().getNode(TextUtil.relativizePath(path)).getNode("jcr:content");
View Full Code Here

      String path = TestUtils.getFileName();

      // create data with 'trusted' user agent
      // (all user agents are considered to be trusted
      // if they are not listed as untrusted)
      MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
      headers.add(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN);

      service(WebDAVMethods.PUT, getPathWS() + path, "", headers, content.getBytes());

      headers.clear();
      content = TestUtils.getFileContent();
      // define user agent to be among untrusted user agents
      headers.add(HttpHeaders.USER_AGENT, "test-user-agent");
      // define incorrect mime-type via seting Content-Type header
      headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM);

      service(WebDAVMethods.PUT, getPathWS() + path, "", headers, content.getBytes());

      Node node = session.getRootNode().getNode(TextUtil.relativizePath(path)).getNode("jcr:content");
      // mime-type should still be correct
View Full Code Here

      service(WebDAVMethods.PUT, getPathWS() + path, "", null, content.getBytes());
      Node node = session.getRootNode().getNode(TextUtil.relativizePath(path));
      // mime-type is defined according to resource's extension
      assertEquals(MediaType.TEXT_HTML, node.getNode("jcr:content").getProperty("jcr:mimeType").getString());

      MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
      headers.add(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_XML);
      service(WebDAVMethods.PUT, getPathWS() + path, "", headers, content.getBytes());
      // mime-type modified according to Content-Type header content
      assertEquals(MediaType.TEXT_XML, node.getNode("jcr:content").getProperty("jcr:mimeType").getString());
   }
View Full Code Here

   public void testMimeTypeDefinedCorrectIfNoExtensionSet() throws Exception
   {
      String filename = IdGenerator.generate();

      MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
      headers.add(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_HTML);

      ContainerResponse containerResponse =
         service(WebDAVMethods.PUT, getPathWS() + "/" + filename, "", headers, "".getBytes());
      assertEquals(HTTPStatus.CREATED, containerResponse.getStatus());

      headers.clear();
      containerResponse =
         service(WebDAVMethods.PUT, getPathWS() + "/" + filename, "", headers, IdGenerator.generate().getBytes());

      Node node = session.getRootNode().getNode(TextUtil.relativizePath(filename));
      assertTrue(node.hasNode("jcr:content"));
View Full Code Here

TOP

Related Classes of org.exoplatform.services.rest.impl.MultivaluedMapImpl

Copyright © 2018 www.massapicom. 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.