// Path: osgi.enroute.examples.backend.application/src/osgi/enroute/examples/backend/api/Backend.java
// public interface Backend {
// 	String TYPE = "type";
// 
// 	/**
// 	 * Save a blob
// 	 * 
// 	 * @param name
// 	 *            The name of the blob
// 	 * @param data
// 	 *            The actual data
// 	 * @return the meta data describing the details of the store
// 	 */
// 	MetaData save(String name, byte[] data) throws Exception;
// 
// 	/**
// 	 * Read the blob with the given name.
// 	 * 
// 	 * @param name
// 	 *            The name of the resource
// 	 * @return the data
// 	 */
// 	byte[] read(String name) throws Exception;
// 
// 	/**
// 	 * Return a list of the meta data of what the store has.
// 	 * 
// 	 * @return The list
// 	 */
// 	Collection<? extends MetaData> list() throws Exception;
// 
// 	/**
// 	 * Delete a blob
// 	 * 
// 	 * @param name
// 	 *            The name of the blob
// 	 * @return true if deleted, false if could not be deleted (might not exist)
// 	 */
// 	boolean delete(String name) throws Exception;
// }
// 
// Path: osgi.enroute.examples.backend.application/src/osgi/enroute/examples/backend/api/MetaData.java
// public class MetaData extends DTO {
// 	/**
// 	 * The name of the blob
// 	 */
// 	public String name;
// 
// 	/**
// 	 * The size of the blob
// 	 */
// 	public long size;
// 
// 	/**
// 	 * The epoch time when it was last modified.
// 	 */
// 	public long modified;
// }


import java.io.FileNotFoundException;
import java.util.Collection;
import org.osgi.dto.DTO;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import osgi.enroute.examples.backend.api.Backend;
import osgi.enroute.examples.backend.api.MetaData;
import osgi.enroute.rest.api.REST;
import osgi.enroute.rest.api.RESTRequest;
package osgi.enroute.examples.backend.application;




/**
 * The Backend REST API provides a REST interface into the Backend Application.
 * It provides the REST CRUD operations. The URI for this REST API has the
 * following syntax:
 * 
 * <pre>
 * 	/rest/backend                GET Return an array of types 
 *  /rest/backend/<type>         GET Return a list of MetaData 
 *                                   for the entries in the <type> 
 *                                   backend
 *  /rest/backend/<type>/<name>  GET Get the blob
 *                               PUT Put the blob 
 *                               DELETE Delete the blob
 * </pre>
 * 
 */
@Component
public class BackendREST implements REST {

	@Reference
	BackendApplication model;

	/*
	 * Defines how the body looks like
	 */
	interface PutRequest extends RESTRequest {
		String _body();
	}

	/**
	 * Used to return data with some of its metadata.
	 */
	public static class Data extends DTO {
		public String name;
		public String type;
		public String data;
	}

	/*
	 * This is the {@code PUT /rest/backend/<type>/<name>}. Get the backend and
	 * save the blob
	 */
// Path: osgi.enroute.examples.backend.application/src/osgi/enroute/examples/backend/api/Backend.java
// public interface Backend {
// 	String TYPE = "type";
// 
// 	/**
// 	 * Save a blob
// 	 * 
// 	 * @param name
// 	 *            The name of the blob
// 	 * @param data
// 	 *            The actual data
// 	 * @return the meta data describing the details of the store
// 	 */
// 	MetaData save(String name, byte[] data) throws Exception;
// 
// 	/**
// 	 * Read the blob with the given name.
// 	 * 
// 	 * @param name
// 	 *            The name of the resource
// 	 * @return the data
// 	 */
// 	byte[] read(String name) throws Exception;
// 
// 	/**
// 	 * Return a list of the meta data of what the store has.
// 	 * 
// 	 * @return The list
// 	 */
// 	Collection<? extends MetaData> list() throws Exception;
// 
// 	/**
// 	 * Delete a blob
// 	 * 
// 	 * @param name
// 	 *            The name of the blob
// 	 * @return true if deleted, false if could not be deleted (might not exist)
// 	 */
// 	boolean delete(String name) throws Exception;
// }
// 
// Path: osgi.enroute.examples.backend.application/src/osgi/enroute/examples/backend/api/MetaData.java
// public class MetaData extends DTO {
// 	/**
// 	 * The name of the blob
// 	 */
// 	public String name;
// 
// 	/**
// 	 * The size of the blob
// 	 */
// 	public long size;
// 
// 	/**
// 	 * The epoch time when it was last modified.
// 	 */
// 	public long modified;
// }


// Path: osgi.enroute.examples.backend.application/src/osgi/enroute/examples/backend/application/BackendREST.java
import java.io.FileNotFoundException;
import java.util.Collection;
import org.osgi.dto.DTO;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import osgi.enroute.examples.backend.api.Backend;
import osgi.enroute.examples.backend.api.MetaData;
import osgi.enroute.rest.api.REST;
import osgi.enroute.rest.api.RESTRequest;

package osgi.enroute.examples.backend.application;




/**
 * The Backend REST API provides a REST interface into the Backend Application.
 * It provides the REST CRUD operations. The URI for this REST API has the
 * following syntax:
 * 
 * <pre>
 * 	/rest/backend                GET Return an array of types 
 *  /rest/backend/<type>         GET Return a list of MetaData 
 *                                   for the entries in the <type> 
 *                                   backend
 *  /rest/backend/<type>/<name>  GET Get the blob
 *                               PUT Put the blob 
 *                               DELETE Delete the blob
 * </pre>
 * 
 */
@Component
public class BackendREST implements REST {

	@Reference
	BackendApplication model;

	/*
	 * Defines how the body looks like
	 */
	interface PutRequest extends RESTRequest {
		String _body();
	}

	/**
	 * Used to return data with some of its metadata.
	 */
	public static class Data extends DTO {
		public String name;
		public String type;
		public String data;
	}

	/*
	 * This is the {@code PUT /rest/backend/<type>/<name>}. Get the backend and
	 * save the blob
	 */
	public MetaData putBackend(PutRequest pr, String type, String name)