package de.msquadrat.blobwizard.resources;

import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;

import com.codahale.metrics.annotation.Timed;

import de.msquadrat.blobwizard.BlobStoreManager;
import de.msquadrat.blobwizard.BlobStoreManager.Store;

@Path("/blob/{store}/{path:.+}")
public class BlobResource {
    private final BlobStoreManager stores;

    public BlobResource(BlobStoreManager storeManager) {
        stores = storeManager;
    }

    private Store getStore(String name) {
        Store store = stores.get(name);
        if (store == null) {
            throw new NotFoundException("Unknown BLOB store " + name);
        }
        return store;
    }

    @PUT
    @Timed
    public void putBlob(@PathParam("store") String store,
            @PathParam("container") String container,
            @PathParam("path") String path, Object data) {
        getStore(store).put(container, path, data);
    }

    @GET
    @Timed
    public Object getBlob(@PathParam("store") String store,
            @PathParam("container") String container,
            @PathParam("path") String path) {
        Object blob = getStore(store).get(container, path).orNull();
        if (blob == null) {
            throw new NotFoundException();
        }
        return blob;
    }

    @DELETE
    @Timed
    public void deleteBlob(@PathParam("store") String store,
            @PathParam("container") String container,
            @PathParam("path") String path) {
        getStore(store).delete(container, path);
    }

}

@@ -206,16 +206,74 @@
 Param;%0A%0A
+import org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0A
 import c
@@ -438,16 +438,28 @@
 store%7D/%7B
+container%7D/%7B
 path:.+%7D
@@ -489,16 +489,107 @@
 ource %7B%0A
+    private static final Logger LOGGER = LoggerFactory.getLogger(BlobResource.class);%0A    %0A
     priv
@@ -822,32 +822,86 @@
 tore == null) %7B%0A
+            LOGGER.debug(%22Store %7B%7D not found%22, name);%0A
             thro

Fix resource path