Package com.sun.jersey.samples.storageservice

Examples of com.sun.jersey.samples.storageservice.Container


    assertTrue(containers.getContainer() == null || containers.getContainer().isEmpty());

    response = resource.path("containers/one").get(ClientResponse.class);
    assertEquals(404, response.getStatus());

    Container containerOne = new Container();
    response = resource.path("containers/one").put(ClientResponse.class, containerOne);
    assertEquals(201, response.getStatus());

    response = resource.path("containers").accept("application/xml").get(ClientResponse.class);
    assertEquals(200, response.getStatus());
    containers = response.getEntity(Containers.class);
    assertEquals(1, containers.getContainer().size());

    response = resource.path("containers/one").get(ClientResponse.class);
    assertEquals(200, response.getStatus());
    containerOne = response.getEntity(Container.class);
    assertEquals("one", containerOne.getName());
    assertNotNull(containerOne.getUri());
    assertTrue(containerOne.getItem() == null || containerOne.getItem().isEmpty());

    String stringItem = "here is a string that we want to store";
    response = resource.path("containers/one/string").type("text/plain").put(ClientResponse.class, stringItem);
    assertEquals(201, response.getStatus());

    response = resource.path("containers/one").get(ClientResponse.class);
    assertEquals(200, response.getStatus());
    containerOne = response.getEntity(Container.class);
    assertEquals(1, containerOne.getItem().size());
    assertEquals("text/plain", containerOne.getItem("string").getMimeType());

    response = resource.path("containers/one/string").get(ClientResponse.class);
    assertEquals(200, response.getStatus());
    assertEquals(stringItem, response.getEntity(String.class));
  }
View Full Code Here


   
    @GET
    public Container getContainer(@QueryParam("search") String search) {
        System.out.println("GET CONTAINER " + container + ", search = " + search);

        Container c = MemoryStore.MS.getContainer(container);
        if (c == null)
            throw new NotFoundException("Container not found");
       
       
        if (search != null) {
            c = c.clone();
            Iterator<Item> i = c.getItem().iterator();
            byte[] searchBytes = search.getBytes();
            while (i.hasNext()) {
                if (!match(searchBytes, container, i.next().getName()))
                    i.remove();
            }
View Full Code Here

    assertTrue(containers.getContainer() == null || containers.getContainer().isEmpty());

    response = resource.path("containers/one").get(ClientResponse.class);
    assertEquals(404, response.getStatus());

    Container containerOne = new Container();
    response = resource.path("containers/one").put(ClientResponse.class, containerOne);
    assertEquals(201, response.getStatus());

    response = resource.path("containers").get(ClientResponse.class);
    assertEquals(200, response.getStatus());
    containers = response.getEntity(Containers.class);
    assertEquals(1, containers.getContainer().size());

    response = resource.path("containers/one").get(ClientResponse.class);
    assertEquals(200, response.getStatus());
    containerOne = response.getEntity(Container.class);
    assertEquals("one", containerOne.getName());
    assertNotNull(containerOne.getUri());
    assertTrue(containerOne.getItem() == null || containerOne.getItem().isEmpty());

    String stringItem = "here is a string that we want to store";
    response = resource.path("containers/one/string").type("text/plain").put(ClientResponse.class, stringItem);
    assertEquals(201, response.getStatus());

    response = resource.path("containers/one").get(ClientResponse.class);
    assertEquals(200, response.getStatus());
    containerOne = response.getEntity(Container.class);
    assertEquals(1, containerOne.getItem().size());
    assertEquals("text/plain", containerOne.getItem("string").getMimeType());

    response = resource.path("containers/one/string").get(ClientResponse.class);
    assertEquals(200, response.getStatus());
    assertEquals(stringItem, response.getEntity(String.class));
View Full Code Here

        Item ii = MemoryStore.MS.createOrUpdateItem(container, i, data);
        if (ii == null) {
            // Create the container if one has not been created
            URI containerUri = uriInfo.getAbsolutePathBuilder().path("..").
                    build().normalize();
            Container c = new Container(container, containerUri.toString());
            MemoryStore.MS.createContainer(c);
            i = MemoryStore.MS.createOrUpdateItem(container, i, data);
            if (i == null)
                throw new NotFoundException("Container not found");
        }
View Full Code Here

    @TypeHint (Container.class)
    public Response putContainer() throws WebApplicationException {
        System.out.println("PUT CONTAINER " + container);
       
        URI uri =  uriInfo.getAbsolutePath();
        Container c = new Container(container, uri.toString());
       
        Response r;
        if (!MemoryStore.MS.hasContainer(c)) {
            r = Response.created(uri).build();
        } else {
View Full Code Here

   
    @DELETE
    public void deleteContainer() {
        System.out.println("DELETE CONTAINER " + container);
       
        Container c = MemoryStore.MS.deleteContainer(container);
        if (c == null)
            throw new NotFoundException("Container not found");
    }
View Full Code Here

   
    @GET
    public Container getContainer(@QueryParam("search") String search) {
        System.out.println("GET CONTAINER " + container + ", search = " + search);

        Container c = MemoryStore.MS.getContainer(container);
        if (c == null)
            throw new NotFoundException("Container not found");
       
       
        if (search != null) {
            c = c.clone();
            Iterator<Item> i = c.getItem().iterator();
            byte[] searchBytes = search.getBytes();
            while (i.hasNext()) {
                if (!match(searchBytes, container, i.next().getName()))
                    i.remove();
            }
View Full Code Here

    @PUT
    public Response putContainer() {
        System.out.println("PUT CONTAINER " + container);
       
        URI uri =  uriInfo.getAbsolutePath();
        Container c = new Container(container, uri.toString());
       
        Response r;
        if (!MemoryStore.MS.hasContainer(c)) {
            r = Response.created(uri).build();
        } else {
View Full Code Here

   
    @DELETE
    public void deleteContainer() {
        System.out.println("DELETE CONTAINER " + container);
       
        Container c = MemoryStore.MS.deleteContainer(container);
        if (c == null)
            throw new NotFoundException("Container not found");
    }
View Full Code Here

        Item ii = MemoryStore.MS.createOrUpdateItem(container, i, data);
        if (ii == null) {
            // Create the container if one has not been created
            URI containerUri = uriInfo.getAbsolutePathBuilder().path("..").
                    build().normalize();
            Container c = new Container(container, containerUri.toString());
            MemoryStore.MS.createContainer(c);
            i = MemoryStore.MS.createOrUpdateItem(container, i, data);
            if (i == null)
                throw new NotFoundException("Container not found");
        }
View Full Code Here

TOP

Related Classes of com.sun.jersey.samples.storageservice.Container

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.