public class OcciConfig extends XMLConfiguration {
	private static final long serialVersionUID = 1L;
	private static final Logger LOGGER = LoggerFactory
			.getLogger(OcciConfig.class);
	/**
	 * Instance of OcciConfig
	 */
	private static OcciConfig instance = null;
	private static ConfigurationFactory factory;
	/**
	 * Configuration for all occi properties
	 */
	public Configuration config;

	private OcciConfig() {
		factory = new ConfigurationFactory();
		// load configuration file
		URL configURL = getClass().getResource("/conf/config.xml");
		factory.setConfigurationURL(configURL);
		try {
			// pick up configuration
			config = factory.getConfiguration();
		} catch (ConfigurationException e) {
			LOGGER.error("Failed to load config file.");
		}
	}

	public static OcciConfig getInstance() {
		if (instance == null) {
			// create OcciConfig instance
			instance = new OcciConfig();
		}
		return instance;
	}

	public static void main(String[] args) {
		new OcciConfig();
	}
} public abstract class Action {
	/**
	 * The identifying Category of the Action. 
	 */
	private static Category category;

	public abstract void execute(URI uri, Method method);

	/**
	 * Returns the category of the action. 
	 * 
	 * @return the category
	 */
	public Category getCategory() {
		return category;
	}
} public class Kind extends Category {
	/**
	 * Set of Actions defined by the Kind instance.
	 */
	private Set<Action> actions;
	/**
	 * Set of related instances.
	 */
	private Set<Kind> related;
	/**
	 * Entity type uniquely identified by the Kind instance.
	 */
	private static Entity entity_type;
	/**
	 * Set of resource instances, i.e. Entity sub-type instances. Resources
	 * instantiated from the Entity sub-type which is uniquely identified by
	 * this Kind instance. [T. Metsch, A. Edmonds, R. Nyren and A.Papaspyrou -
	 * Open Cloud Computing Interface - Core,
	 * http://ogf.org/documents/GFD.183.pdf, Apr. 2011]
	 */
	private Set<Entity> entities;
	private Set<String> actionNames = new HashSet<String>();
	/*
	 * set of existing kind instances, for the query interface
	 */
	private static Set<Kind> kinds = new HashSet<Kind>();

	public Kind(Set<Action> actions, Set<Kind> related, Set<Entity> entities,
			Entity entity_type, String term, String title, String scheme,
			Set<String> attributes) throws SchemaViolationException,
			URISyntaxException {
		super(term, scheme, title, attributes);

		this.actions = actions;
		this.related = related;
		this.entities = entities;
		Kind.entity_type = entity_type;

		kinds.add(this);
	}

	public Kind(Set<Entity> entities, Entity entity_type, String term,
			String title, Set<String> attributes)
			throws SchemaViolationException, URISyntaxException {
		super(term, OcciConfig.getInstance().config.getString("occi.scheme"),
				title, attributes);

		this.entities = entities;
		Kind.entity_type = entity_type;

		kinds.add(this);
	}

	public Kind(Set<Kind> related, Set<Entity> entities, Entity entity_type,
			String term, String title, Set<String> attributes)
			throws SchemaViolationException, URISyntaxException {
		super(term, OcciConfig.getInstance().config.getString("occi.scheme"),
				title, attributes);

		this.related = related;
		this.entities = entities;
		Kind.entity_type = entity_type;

		kinds.add(this);
	}

	public Kind(Entity entity_type, String term, String title,
			Set<String> attributes) throws SchemaViolationException,
			URISyntaxException {
		super(term, "http://schemas.ogf.org/occi/", title, attributes);

		Kind.entity_type = entity_type;

		kinds.add(this);
	}

	public Kind(Entity entity_type, Set<String> attributes)
			throws SchemaViolationException, URISyntaxException {
		super(entity_type.getKind().getTerm(), OcciConfig.getInstance().config
				.getString("occi.scheme"), entity_type.getTitle(), attributes);

		Kind.entity_type = entity_type;

		kinds.add(this);
	}

	/**
	 * Returns all action names as set.
	 * 
	 * @return Action names
	 */
	public Set<String> getActionNames() {
		return this.actionNames;
	}

	/**
	 * Sets a set of action names.
	 * 
	 * @param actionNames
	 */
	public void setActionNames(Set<String> actionNames) {
		this.actionNames = actionNames;
	}

	/**
	 * Returns actions.
	 * 
	 * @return actions
	 */
	public Set<Action> getActions() {
		return this.actions;
	}

	/**
	 * Returns related Kind.
	 * 
	 * @return related Kind
	 */
	public Set<Kind> getRelated() {
		return this.related;
	}

	/**
	 * Returns entities.
	 * 
	 * @return entities
	 */
	public Set<Entity> getEntities() {
		return this.entities;
	}

	/**
	 * Returns entity_Type.
	 * 
	 * @return entity_Type
	 */
	public Entity getEntity_type() {
		return entity_type;
	}

	/**
	 * Returns all active Kinds.
	 * 
	 * @return all active Kinds
	 */
	public static Set<Kind> getKinds() {
		return kinds;
	}
} public class Link extends Entity {
	/**
	 * The Resource instances the Link Link instance originates from.
	 */
	private Resource link;
	/**
	 * The Resource instances the Link instance points to.
	 */
	private Resource target;

	/*
	 * set of existing link instances, for the query interface
	 */
	private static Set<Link> links = new HashSet<Link>();

	public Link(Resource link, Resource target) throws URISyntaxException {
		super(new URI(UUID.randomUUID().toString()), "link", null, null);
		this.link = link;
		this.target = target;

		links.add(this);
	}

	/**
	 * Returns link.
	 * 
	 * @return link
	 */
	public Resource getLink() {
		return link;
	}

	/**
	 * Sets link.
	 * 
	 * @param link
	 */
	public void setLink(Resource link) {
		this.link = link;
	}

	/**
	 * Returns target.
	 * 
	 * @return target
	 */
	public Resource getTarget() {
		return target;
	}

	/**
	 * Sets target.
	 * 
	 * @param target
	 */
	public void setTarget(Resource target) {
		this.target = target;
	}

	/**
	 * Returns all active links.
	 * 
	 * @return all active links
	 */
	public static Set<Link> getLinks() {
		return links;
	}

	public String getScheme() {
		return getKind().getScheme() + "infrastructure#";
	}
} public class Mixin extends Category {
	/**
	 * Set of Actions defined by the Mixin instance.
	 */
	private Set<Action> actions;
	/**
	 * Set of related Mixin instances.
	 */
	private Set<Mixin> related;
	/**
	 * Set of resource instances, i.e. Entity sub-type instances, associated
	 * with the Mixin instance. [T. Metsch, A. Edmonds, R. Nyren and
	 * A.Papaspyrou - Open Cloud Computing Interface - Core,
	 * http://ogf.org/documents/GFD.183.pdf, Apr. 2011]
	 */
	private Set<Entity> entities;
	/**
	 * set of existing mixin instances, for the query interface
	 */
	private static Set<Mixin> mixins = new HashSet<Mixin>();

	/**
	 * Mixin Constructor
	 * 
	 * @param actions
	 * @param related
	 * @param entities
	 * @throws URISyntaxException
	 */
	public Mixin(Set<Action> actions, Set<Mixin> related, Set<Entity> entities)
			throws URISyntaxException, SchemaViolationException {
		super(null, "http://schemas.ogf.org/occi/core#", null, null);
		this.actions = actions;
		this.related = related;
		this.entities = entities;

		mixins.add(this);
	}

	public Mixin(Set<Mixin> related, Set<Entity> entities)
			throws URISyntaxException, SchemaViolationException {
		super(null, "http://schemas.ogf.org/occi/core#", null, null);
		this.related = related;
		this.entities = entities;

		mixins.add(this);
	}

	public Mixin(Set<Entity> entities) throws URISyntaxException,
			SchemaViolationException {
		super(null, "http://schemas.ogf.org/occi/core#", null, null);
		this.entities = entities;

		mixins.add(this);
	}

	public Mixin(Set<Mixin> related, String term, String title, String scheme,
			Set<String> attributes) throws URISyntaxException,
			SchemaViolationException {
		super(term, scheme, title, attributes);
		this.related = related;

		mixins.add(this);
	}

	/**
	 * Returns actions
	 * 
	 * @return actions
	 */
	public Set<Action> getActions() {
		return actions;
	}

	/**
	 * Returns related mixin
	 * 
	 * @return related mixin
	 */
	public Set<Mixin> getRelated() {
		return related;
	}

	/**
	 * Returns entities
	 * 
	 * @return entities
	 */
	public Set<Entity> getEntities() {
		return entities;
	}

	/**
	 * Sets entities
	 * 
	 * @param entities
	 */
	public void setEntities(Set<Entity> entities) {
		this.entities = entities;
	}

	/**
	 * Returns all active Mixins
	 * 
	 * @return all active mixins
	 */
	public static Set<Mixin> getMixins() {
		return mixins;
	}
} public class OcciCheck extends ServerResource {
	private static final Logger LOGGER = LoggerFactory
			.getLogger(OcciCheck.class);

	/**
	 * Class checks some statements, if they start with capital or not and gives
	 * the string back.
	 * 
	 * @param string
	 * @return String
	 */
	public static Map<String, String> checkCaseSensitivity(String string) {
		Map<String, String> caseMap = new HashMap<String, String>();
		if (string.contains("x-occi-location")) {
			caseMap.put("x-occi-location", "x-occi-location");
		} else if (string.contains("X-OCCI-Location")) {
			caseMap.put("x-occi-location", "X-OCCI-Location");
		}

		if (string.contains("occi.compute.Category")) {
			caseMap.put("occi.compute.category", "occi.compute.Category");
		}

		if (string.contains("Category")) {
			caseMap.put("category", "Category");
		} else if (string.contains("category")) {
			caseMap.put("category", "category");
		}

		if (string.contains("x-occi-attribute")) {
			caseMap.put("x-occi-attribute", "x-occi-attribute");
		} else if (string.contains("X-OCCI-Attribute")) {
			caseMap.put("x-occi-attribute", "X-OCCI-Attribute");
		}

		if (string.contains("content-type")) {
			caseMap.put("accept", "content-type");
		} else if (string.contains("Content-Type")) {
			caseMap.put("accept", "Content-Type");
		}

		// Comma-separated because the contains() Method of String matches also
		// the Accept-* Keys. But the needed key is comma-separated from the
		// value in the String
		if (string.contains("Accept,")) {
			caseMap.put("accept", "Accept");
		} else if (string.contains("accept,")) {
			caseMap.put("accept", "accept");
		}

		return caseMap;
	}

	public static Representation checkContentType(Form requestHeaders,
			StringBuffer buffer, Response response) {
		Representation representation = null;

		LOGGER.debug("Request Headers: " + requestHeaders);
		String acceptCase = "";
		if (OcciCheck.checkCaseSensitivity(requestHeaders.toString()).get(
				"accept") != null) {
			acceptCase = OcciCheck.checkCaseSensitivity(
					requestHeaders.toString()).get("accept");
		} else {
			acceptCase = OcciCheck.checkCaseSensitivity(
					requestHeaders.toString()).get("content-type");
		}

		LOGGER.debug("acceptCase: " + acceptCase);
		String acceptHeader = requestHeaders.getFirstValue(acceptCase);
		LOGGER.debug("acceptHeader: " + acceptHeader);
		if (acceptHeader == null) {
			acceptHeader = " ";
		}

		// if text/occi is requested return text/occi, otherwise text/plain
		if (acceptHeader.equalsIgnoreCase("text/occi")) {
			representation = new StringRepresentation(" ", new MediaType(
					"text/occi"));
			response.setStatus(Status.SUCCESS_OK, buffer.toString());
		} else if ((acceptHeader.equalsIgnoreCase("text/plain"))
				|| (acceptHeader.equalsIgnoreCase(" "))
				|| (acceptHeader.equalsIgnoreCase("*/*"))) {
			representation = new StringRepresentation(buffer.toString(),
					MediaType.TEXT_PLAIN);
			response.setStatus(Status.SUCCESS_OK, buffer.toString());
		} else {
			representation = new StringRepresentation("Unsupported Media Type",
					MediaType.TEXT_PLAIN);
			response.setStatus(Status.CLIENT_ERROR_UNSUPPORTED_MEDIA_TYPE);
		}
		// set character set to null
		representation.setCharacterSet(null);
		return representation;
	}

	/**
	 * Count the colons of the given String
	 * 
	 * @param attributes
	 * @throws Exception
	 */
	public static void countColons(String attributes, int i) throws Exception {
		int count = 0;
		LOGGER.debug("Counting colons");
		// Iterate over every char
		for (char c : attributes.toCharArray()) {
			// Check if the char is a colon and increase count
			if (c == ':') {
				LOGGER.debug("Colon found");
				count++;
			}
		}
		// Throw new Exception, if more than one colon is found in the request
		if (count > i) {
			LOGGER.error("One Colon found in the Request");
			throw new Exception(
					"One Colon found in the Request. Please use the Request like this: XOCCI-Attribute: occi.compute.cores=2 [...]");
		}
	}

	/**
	 * Adds a whitespace after every semicolon and removes leading and trailing
	 * whitespaces.
	 * 
	 * @param string
	 * @return string
	 */
	public static String addWhitespaceAfterSemicolonAndTrim(String string) {
		if (string.contains(";")) {
			string = string.replace(";", "; ");
		}
		string = string.trim();

		return string;
	}

	/**
	 * Specific method for header rendering for the query interface. Generates
	 * the header rendering with the given params.
	 * 
	 * @param queryKinds
	 * @param compute
	 * @param attributes
	 */
	public void setHeaderRendering(LinkedList<Kind> queryKinds) {
		Form xOcciLocation = new Form();
		Response.getCurrent().getAttributes()
				.put("org.restlet.http.headers", xOcciLocation);
		String location = "";
		String category = "";
		if (queryKinds != null) {
			for (Mixin mixin : Mixin.getMixins()) {
				category += mixin.getTitle() + "; scheme=\""
						+ mixin.getScheme() + "\"" + "; class=\"mixin\"" + ", ";
				location += "/" + mixin.getTitle() + "/,";
			}
			for (Kind kind : queryKinds) {
				if (!kind.equals(queryKinds.getLast())) {
					category += kind.getTerm() + "; scheme=\""
							+ kind.getScheme() + "\"" + "; class=\"mixin\""
							+ ", ";
				} else {
					category += kind.getTerm();
				}
				if (kind.equals(queryKinds.getLast())) {
					location += "/" + kind.getTerm() + "/";
				} else if (!kind.equals(queryKinds.getLast())) {
					location += "/" + kind.getTerm() + "/,";
				} else if (kind.equals(queryKinds.getFirst())) {
					location += "/" + kind.getTerm() + "/,";
				}
			}
		}

		xOcciLocation.add("Category", category);
		xOcciLocation.add("X-OCCI-Location", location);
		xOcciLocation.add("Link",
				"setHeaderRendering(LinkedList<Kind> queryKinds)");
	}

	/**
	 * Specific method for header rendering for the query interface. Generates
	 * the header rendering with the given params.
	 * 
	 * @param queryKinds
	 * @param compute
	 * @param attributes
	 */
	public void setHeaderRendering(LinkedList<Kind> queryKinds,
			Resource resource, String attributes, StringBuffer link) {
		Form xOcciLocation = new Form();
		Response.getCurrent().getAttributes()
				.put("org.restlet.http.headers", xOcciLocation);
		String location = "";
		String category = "";
		StringBuffer linkBuffer = new StringBuffer();
		if (queryKinds != null) {
			for (Mixin mixin : Mixin.getMixins()) {
				// category += mixin.getTitle() + ",";
				category += mixin.getTitle() + "; scheme=\""
						+ mixin.getScheme() + "\"" + "; class=\"mixin\"" + ", ";
				location += "/" + mixin.getTitle() + "/,";
			}
			for (Kind kind : queryKinds) {
				if (!kind.equals(queryKinds.getLast())) {
					category += kind.getTerm() + ",";
				} else {
					category += kind.getTerm();
				}
				if (kind.equals(queryKinds.getLast())) {
					location += "/" + kind.getTerm() + "/";
				} else if (!kind.equals(queryKinds.getLast())) {
					location += "/" + kind.getTerm() + "/,";
				} else if (kind.equals(queryKinds.getFirst())) {
					location += "/" + kind.getTerm() + "/,";
				}
			}
		}

		if ((resource != null) && (attributes != null)) {
			category = null;
			// xOcciLocation = null;
			Response.getCurrent().getAttributes()
					.put("org.restlet.http.headers", xOcciLocation);
			category = ""; // resource.getKind().getTerm();

			// add information about category and location to the header
			if (resource.getKind() != null) {
				for (Category mixin : resource.getKind().getCategories()) {
					if (!mixin.getTitle().equalsIgnoreCase("action")) {
						category += mixin.getTitle() + "; scheme=\""
								+ mixin.getScheme().toString()
								+ "\"; class=\"mixin\";";
					}

				}
			}

			for (String actionName : resource.getKind().getActionNames()) {
				String actionScheme = resource.getKind().getScheme().toString();
				String actionSchemeSubStr = actionScheme.substring(0,
						actionScheme.length() - 1);
				linkBuffer.append("</");
				linkBuffer.append(resource.getKind().getTerm() + "/");
				linkBuffer.append(resource.getId());
				linkBuffer.append("/?action=");
				linkBuffer.append(actionName.substring(actionName
						.lastIndexOf("#") + 1));
				linkBuffer.append(">;rel=\"" + actionSchemeSubStr + "/");
				linkBuffer.append(resource.getKind().getTerm() + "/action#");
				linkBuffer.append(actionName.substring(actionName
						.lastIndexOf("#") + 1) + "\" ");

			}
		}
		if (link != null) {
			linkBuffer.append(link);
		}

		if (location.isEmpty()) {
			xOcciLocation.add("X-OCCI-Location", location);
		}

		xOcciLocation.add("Link", linkBuffer.toString());
		xOcciLocation.add("Category", category);
		xOcciLocation.add("X-OCCI-Attribute", attributes);
	}

	/**
	 * Specific method for header rendering for the query interface. Generates
	 * the header rendering with the given params.
	 * 
	 * @param queryKinds
	 * @param link
	 * @param attributes
	 * @param linked
	 */
	public void setHeaderRendering(LinkedList<Kind> queryKinds, Link link,
			String attributes, StringBuffer linked) {
		Form xOcciLocation = new Form();
		Response.getCurrent().getAttributes()
				.put("org.restlet.http.headers", xOcciLocation);
		String location = link.getKind().getTitle() + "/" + link.getId();

		String category = "";
		StringBuffer linkBuffer = new StringBuffer();
		if (queryKinds != null) {

			for (Mixin mixin : Mixin.getMixins()) {
				// category += mixin.getTitle() + ",";
				category += mixin.getTitle() + "; scheme=\"" + link.getScheme()
						+ "\"" + "; class=\"kind\"" + ", ";
				location += "/" + mixin.getTitle() + "/,";
			}
			for (Kind kind : queryKinds) {
				if (!kind.equals(queryKinds.getLast())) {
					category += kind.getTerm() + ",";
				} else {
					category += kind.getTerm();
				}
				if (kind.equals(queryKinds.getLast())) {
					location += "/" + kind.getTerm() + "/";
				} else if (!kind.equals(queryKinds.getLast())) {
					location += "/" + kind.getTerm() + "/,";
				} else if (kind.equals(queryKinds.getFirst())) {
					location += "/" + kind.getTerm() + "/,";
				}
			}
		}

		if ((link != null) && (attributes != null)) {
			category = "";
			// xOcciLocation = null;
			Response.getCurrent().getAttributes()
					.put("org.restlet.http.headers", xOcciLocation);

			// add information about category and location to the header
			if (link.getKind() != null) {
				// for (Category mixin : link.getKind()) {
				if (!link.getKind().getTitle().equalsIgnoreCase("action")) {
					category += link.getKind().getTitle() + "; scheme=\""
							+ link.getScheme() + "\"; class=\"kind\";";
				}

				// }
			}

			if (link.getKind() != null) {
				for (String actionName : link.getKind().getActionNames()) {
					String actionScheme = link.getKind().getScheme().toString();
					String actionSchemeSubStr = actionScheme.substring(0,
							actionScheme.length() - 1);
					linkBuffer.append("</");
					linkBuffer.append(link.getKind().getTerm() + "/");
					linkBuffer.append(link.getId());
					linkBuffer.append("/?action=");
					linkBuffer.append(actionName.substring(actionName
							.lastIndexOf("#") + 1));
					linkBuffer.append(">;rel=\"" + actionSchemeSubStr + "/");
					linkBuffer.append(link.getKind().getTerm() + "/action#");
					linkBuffer.append(actionName.substring(actionName
							.lastIndexOf("#") + 1) + "\" ");

				}
			}
		}
		if (linked != null) {
			linkBuffer.append(linked);
		}

		// xOcciLocation.add("Link", linkBuffer.toString());

		xOcciLocation.add("Category", category);
		xOcciLocation.add("X-OCCI-Location", location);
		xOcciLocation.add("X-OCCI-Attribute",
				linkBuffer.toString().replace("X-OCCI-Attribute: ", ""));
	}

	public static void setHeaderRendering(Mixin mixin) {
		Form xOcciLocation = new Form();
		Response.getCurrent().getAttributes()
				.put("org.restlet.http.headers", xOcciLocation);
		String category = mixin.getTitle();
		String clazz = "mixin";
		String scheme = mixin.getScheme().toString();
		String rel = "";
		int i = 1;
		if (mixin.getRelated() != null) {
			for (Mixin related : mixin.getRelated()) {
				if (mixin.getRelated().size() >= i) {
					rel += related.getTerm();
				} else {
					rel += related.getTerm() + ",";
				}
				i++;
			}
		}
		String entities = "";
		if (mixin.getEntities() != null) {
			for (Entity entity : mixin.getEntities()) {
				entities += entity.getKind().getTerm() + "/" + entity.getId();
			}
		}
		xOcciLocation.add("Category", category);
		xOcciLocation.add("Class", clazz);
		xOcciLocation.add("Scheme", scheme);
		if (!entities.equals("")) {
			xOcciLocation.add("X-OCCI-Location", entities);
		}
	}

	public static boolean isUUID(String string) {
		if (!string.matches("[\\w]{8}-[\\w]{4}-[\\w]{4}-[\\w]{4}-[\\w]{12}")) {
			return false;
		} else {
			return true;
		}
	}
} public class Compute extends Resource {
	/**
	 * Enumeration for CPU Architecture of the instance
	 */
	public enum Architecture {
		x86, x64
	}

	/**
	 * Number of CPU Cores assigned to the Instance
	 */
	private int cores;

	/**
	 * String DNS hostname for the Instance
	 */
	private String hostname;

	/**
	 * Float CPU Clock frequency in gigahertz
	 */
	private float speed;

	/**
	 * Float RAM in gigabytes allocated to the instance
	 */
	private float memory;

	/**
	 * State of the compute resource
	 */
	private State state;

	/**
	 * Architecture of the compute resource
	 */
	private Architecture architecture;

	/**
	 * Current State of the instance
	 */
	public enum State {
		active, inactive, suspended
	}

	/**
	 * Static Hashmap of all Compute Resources. The Key is a UUID, the Value a
	 * Compute Object.
	 */
	private static Map<UUID, Compute> computeList = new HashMap<UUID, Compute>();

	/**
	 * Static HashSet of all compute attributes.
	 */
	private static HashSet<String> attributes = new HashSet<String>();

	/**
	 * Random UUID of the compute resource.
	 */
	private final UUID uuid;

	/*
	 * All possible compute actions.
	 */
	private static ListableBeanFactory beanFactory = new ClassPathXmlApplicationContext(
			"occiConfig.xml");
	private Action start = (Action) beanFactory.getBean("start");
	private Action stop = (Action) beanFactory.getBean("stop");
	private Action suspend = (Action) beanFactory.getBean("suspend");
	private Action restart = (Action) beanFactory.getBean("restart");

	private static final HashSet<Action> actionSet = new HashSet<Action>();
	private static final HashSet<String> actionNames = new HashSet<String>();

	public Compute(Architecture architecture, int cores, String hostname,
			float speed, float memory, State state, Set<String> attributes)
			throws URISyntaxException, NumberFormatException,
			IllegalArgumentException, NamingException {
		super("Compute", links, attributes);
		this.architecture = architecture;
		this.cores = cores;
		this.hostname = hostname;
		this.speed = speed;
		this.memory = memory;
		this.state = state;

		generateActionNames();

		// check if all attributes are correct
		if ((cores < 1)) {
			throw new NumberFormatException("Number of cores is negative!");
		} else if (speed < 0) {
			throw new NumberFormatException("Number of speed is negative!");
		} else if (memory < 0) {
			throw new NumberFormatException("Number of memory is negative!");
		}
		// check if there is a hostname
		if (hostname.length() == 0) {
			throw new NamingException(
					"Name of the Compute resource can not be null");
		}
		/*
		 * set Category
		 */
		setKind(new Kind(actionSet, null, null, null, "compute", "Compute",
				OcciConfig.getInstance().config.getString("occi.scheme")
						+ "/infrastructure#", attributes));
		getKind().setActionNames(actionNames);
		// set uuid for the resource
		uuid = UUID.randomUUID();
		setId(new URI(uuid.toString()));
		// put resource into compute list
		computeList.put(uuid, this);

		// Generate attribute list
		generateAttributeList();
	}

	/**
	 * Return the full computeList
	 * 
	 * @return all compute resources
	 */
	public static final Map<UUID, Compute> getComputeList() {
		return computeList;
	}

	/**
	 * Set compute list
	 * 
	 * @param computeList
	 */
	public static final void setComputeList(Map<UUID, Compute> computeList) {
		Compute.computeList = computeList;
	}

	/**
	 * Returns the current UUID as a UUID Value
	 * 
	 * @return current UUID assigned to the Instance
	 */
	public final UUID getUuid() {
		return uuid;
	}

	/**
	 * Returns the current Cores as a int Value
	 * 
	 * @return current Cores assigned to the Instance
	 */
	public final int getCores() {
		return cores;
	}

	/**
	 * Sets the cores of the current Instance
	 * 
	 * @param cores
	 *            of the current Instance as an int
	 */
	public final void setCores(int cores) {
		this.cores = cores;
	}

	/**
	 * Returns the Hostname represented as a String of the current Instance
	 * 
	 * @return Hostname as a String
	 */
	public final String getHostname() {
		return hostname;
	}

	/**
	 * Sets the hostname of the current Instance
	 * 
	 * @param hostname
	 *            of the current Instance as a String
	 */
	public final void setHostname(String hostname) {
		this.hostname = hostname;
	}

	/**
	 * Returns the speed of the current Instance as a float
	 * 
	 * @return speed of the current Instance
	 */
	public final float getSpeed() {
		return speed;
	}

	/**
	 * Sets the speed of the current Instance
	 * 
	 * @param speed
	 *            of the current Instance as a float
	 */
	public final void setSpeed(float speed) {
		this.speed = speed;
	}

	/**
	 * Returns the memory of the current Instace as a float
	 * 
	 * @return
	 */
	public final float getMemory() {
		return memory;
	}

	/**
	 * Sets the memory of the current Instance
	 * 
	 * @param memory
	 *            of the current Instance as a float
	 */
	public final void setMemory(float memory) {
		this.memory = memory;
	}

	/**
	 * Returns the State of the current Instance
	 * 
	 * @return State of the current Instance
	 */
	public final State getState() {
		return state;
	}

	/**
	 * Sets the State of the current Instance
	 * 
	 * @param State
	 *            state of the current Instance
	 */
	public final void setState(State state) {
		this.state = state;
	}

	/**
	 * Returns the Architecture of the current Instance
	 * 
	 * @return architecture of the current Instance of enum-type Architectures
	 */
	public final Architecture getArchitecture() {
		return architecture;
	}

	/**
	 * Sets the Architecture of the current Instance
	 * 
	 * @param architecture
	 *            of the current Instance
	 */
	public final void setArchitecture(Architecture architecture) {
		this.architecture = architecture;
	}

	/**
	 * Return list of all action names.
	 * 
	 * @return action names
	 */
	public static final HashSet<String> getActionNames() {
		return actionNames;
	}

	/**
	 * Generate list with action names.
	 */
	public static final HashSet<String> generateActionNames() {
		if (actionNames.isEmpty()) {
			for (int i = 0; i < beanFactory.getBeanDefinitionNames().length; i++) {
				if (beanFactory
						.getBean(beanFactory.getBeanDefinitionNames()[i])
						.toString().contains("compute")) {
					actionNames.add(OcciConfig.getInstance().config
							.getString("occi.scheme")
							+ "/infrastructure/compute/action#"
							+ beanFactory.getBeanDefinitionNames()[i]);
				}
			}
		}
		return actionNames;
	}

	/**
	 * Generate list with actions.
	 */
	public static final HashSet<Action> generateActionSet() {
		if (actionSet.isEmpty()) {
			for (int i = 0; i < beanFactory.getBeanDefinitionNames().length; i++) {
				if (beanFactory
						.getBean(beanFactory.getBeanDefinitionNames()[i])
						.toString().contains("compute")) {
					actionSet.add((Action) beanFactory.getBean(beanFactory
							.getBeanDefinitionNames()[i]));
				}
			}
		}
		return actionSet;
	}

	/**
	 * Generate attribute List.
	 */
	public static final void generateAttributeList() {
		if (attributes.isEmpty()) {
			// add all attributes to attribute list
			attributes.add("occi.compute.architecture");
			attributes.add("occi.compute.cores");
			attributes.add("occi.compute.hostname");
			attributes.add("occi.compute.memory");
			attributes.add("occi.compute.speed");
			attributes.add("occi.compute.state");
		}
	}

	/**
	 * Return the compute attributes.
	 * 
	 * @return attributes
	 */
	public static final HashSet<String> getAttributes() {
		return attributes;
	}

	/**
	 * @param start
	 *            the start to set
	 */
	public final void setStart(Action start) {
		this.start = start;
	}

	/**
	 * @return the start
	 */
	public final Action getStart() {
		return start;
	}

	/**
	 * @param stop
	 *            the stop to set
	 */
	public final void setStop(Action stop) {
		this.stop = stop;
	}

	/**
	 * @return the stop
	 */
	public final Action getStop() {
		return stop;
	}

	/**
	 * @param restart
	 *            the restart to set
	 */
	public final void setRestart(Action restart) {
		this.restart = restart;
	}

	/**
	 * @return the restart
	 */
	public final Action getRestart() {
		return restart;
	}

	/**
	 * @param suspend
	 *            the suspend to set
	 */
	public final void setSuspend(Action suspend) {
		this.suspend = suspend;
	}

	/**
	 * @return the suspend
	 */
	public final Action getSuspend() {
		return suspend;
	}
} public class Network extends Resource {
	/**
	 * 802.1q VLAN Ientifier (e.g. 343).
	 */
	private int vlan;
	/**
	 * Tag based VLANs (e.g. external-dmz).
	 */
	private String label;
	/**
	 * Current state of the instance.
	 */
	private State state;

	/**
	 * Possible status of the instance
	 */
	public enum State {
		active, inactive
	}

	/**
	 * Static HashSet of all network attributes.
	 */
	private static HashSet<String> attributes = new HashSet<String>();

	/**
	 * Static Hashmap of all Network Resources. The Key is a UUID, the Value a
	 * Network Object.
	 */
	private static Map<UUID, Network> networkList = new HashMap<UUID, Network>();

	/*
	 * All possible network actions.
	 */
	private static ListableBeanFactory beanFactory = new ClassPathXmlApplicationContext(
			"occiConfig.xml");
	private static Action up = (Action) beanFactory.getBean("up");
	private static Action down = (Action) beanFactory.getBean("down");

	private final static HashSet<Action> actionSet = new HashSet<Action>();
	private final static HashSet<String> actionNames = new HashSet<String>();

	/**
	 * Minimal constructor.
	 * 
	 * @param links
	 * @param attributes
	 * @throws URISyntaxException
	 * @throws SchemaViolationException
	 */
	public Network(State state, Set<Link> links, Set<String> attributes)
			throws URISyntaxException, SchemaViolationException {
		super(links, attributes);
		this.state = state;

		setKind(new Kind(actionSet, null, null, null, "network", "network",
				OcciConfig.getInstance().config.getString("occi.scheme")
						+ "/infrastructure#", attributes));

		networkList.put(UUID.fromString(getId().toString()), this);
		generateActionNames();
		generateActionNames();
		generateAttributeList();
	}

	public Network(State state, String label, Set<Link> links,
			Set<String> attributes) throws URISyntaxException,
			SchemaViolationException {
		super(links, attributes);
		this.state = state;
		this.label = label;

		networkList.put(UUID.fromString(getId().toString()), this);
		generateActionNames();
		generateAttributeList();
	}

	public Network(State state, int vlan, Set<Link> links,
			Set<String> attributes) throws URISyntaxException,
			SchemaViolationException {
		super(links, attributes);
		this.state = state;
		this.vlan = vlan;

		networkList.put(UUID.fromString(getId().toString()), this);
		generateActionNames();
		generateAttributeList();
	}

	public Network(State state, String label, int vlan, Set<Link> links,
			Set<String> attributes) throws URISyntaxException,
			SchemaViolationException {
		super(links, attributes);
		this.state = state;

		networkList.put(UUID.fromString(getId().toString()), this);
		generateActionNames();
		generateAttributeList();
	}

	public Network(HashMap<String, String> attributes)
			throws SchemaViolationException, URISyntaxException {
		super(attributes);

		networkList.put(UUID.fromString(getId().toString()), this);
		generateActionNames();
		generateAttributeList();
	}

	/**
	 * Sets vlan integer.
	 * 
	 * @param vlan
	 */
	public final void setVlan(int vlan) {
		this.vlan = vlan;
	}

	/**
	 * Returns vlan of the network interface.
	 * 
	 * @return vlan
	 */
	public final int getVlan() {
		return vlan;
	}

	/**
	 * Returns state of the network interface.
	 * 
	 * @return state
	 */
	public final State getState() {
		return this.state;
	}

	/**
	 * Sets the state of the instance.
	 * 
	 * @param state
	 */
	public final void setState(State state) {
		this.state = state;
	}

	/**
	 * Sets the label of the instance.
	 * 
	 * @param label
	 */
	public final void setLabel(String label) {
		this.label = label;
	}

	/**
	 * Returns the label of the instance.
	 * 
	 * @return label
	 */
	public final String getLabel() {
		return label;
	}

	/**
	 * Returns list of all network resources.
	 * 
	 * @return network map
	 */
	public final static Map<UUID, Network> getNetworkList() {
		return networkList;
	}

	/**
	 * Return list of all action names.
	 * 
	 * @return action names
	 */
	public final static HashSet<String> getActionNames() {
		return actionNames;
	}

	/**
	 * Generate list with action names.
	 */
	public final static HashSet<String> generateActionNames() {
		if (actionNames.isEmpty()) {
			for (int i = 0; i < beanFactory.getBeanDefinitionNames().length; i++) {
				if (beanFactory
						.getBean(beanFactory.getBeanDefinitionNames()[i])
						.toString().contains("network")) {
					actionNames.add(OcciConfig.getInstance().config
							.getString("occi.scheme")
							+ "/infrastructure/network/action#"
							+ beanFactory.getBeanDefinitionNames()[i]);
				}
			}
		}
		return actionNames;
	}

	/**
	 * Generate list with actions.
	 * 
	 * @return hash set of actions
	 */
	public final static HashSet<Action> generateActionSet() {
		if (actionSet.isEmpty()) {
			for (int i = 0; i < beanFactory.getBeanDefinitionNames().length; i++) {
				if (beanFactory
						.getBean(beanFactory.getBeanDefinitionNames()[i])
						.toString().contains("network")) {
					actionSet.add((Action) beanFactory.getBean(beanFactory
							.getBeanDefinitionNames()[i]));
				}
			}
		}
		return actionSet;
	}

	/**
	 * Generate attribute List.
	 */
	public final static void generateAttributeList() {
		if (attributes.isEmpty()) {
			// add all attributes to attribute list
			attributes.add("occi.network.vlan");
			attributes.add("occi.network.label");
			attributes.add("occi.network.state");
		}
	}

	/**
	 * Return the network attributes.
	 * 
	 * @return attributes
	 */
	public static HashSet<String> getAttributes() {
		return attributes;
	}
} public class Storage extends Resource {
	/**
	 * Storage size in gigabytes of the instance.
	 */
	private float size;
	/**
	 * Current status of the instance.
	 */
	private State state;

	/**
	 * Possible status of the instance.
	 */
	public enum State {
		online, offline, degraded
	}

	/**
	 * Static Hashmap of all Storage Resources. The Key is a UUID, the Value a
	 * Storage Object.
	 */
	private static Map<UUID, Storage> storageList = new HashMap<UUID, Storage>();

	/**
	 * Static HashSet of all storage attributes.
	 */
	private static HashSet<String> attributes = new HashSet<String>();

	/*
	 * All possible storage actions.
	 */
	private static ListableBeanFactory beanFactory = new ClassPathXmlApplicationContext(
			"occiConfig.xml");
	private Action online = (Action) beanFactory.getBean("online");
	private Action offline = (Action) beanFactory.getBean("offline");
	private Action resize = (Action) beanFactory.getBean("resize");
	private Action backup = (Action) beanFactory.getBean("backup");
	private Action snapshot = (Action) beanFactory.getBean("snapshot");
	private Action create = (Action) beanFactory.getBean("create");

	private static final HashSet<Action> actionSet = new HashSet<Action>();
	private static final HashSet<String> actionNames = new HashSet<String>();

	public Storage(Set<Link> links, Set<String> attributes)
			throws URISyntaxException, SchemaViolationException {
		super(links, attributes);
		storageList.put(UUID.fromString(this.getId().toString()), this);
		generateActionNames();
		generateAttributeList();
	}

	public Storage(float size, State state, Set<Link> links,
			Set<String> attributes) throws URISyntaxException,
			SchemaViolationException {
		super(links, attributes);
		this.size = size;
		this.state = state;
		storageList.put(UUID.fromString(this.getId().toString()), this);
		generateActionNames();
		generateAttributeList();
	}

	/**
	 * Set size of the storage resource.
	 * 
	 * @param size
	 */
	public final void setSize(float size) {
		this.size = size;
	}

	/**
	 * Returns the size of the storage resource.
	 * 
	 * @return size
	 */
	public final float getSize() {
		return size;
	}

	/**
	 * Set state of the storage resource.
	 * 
	 * @param state
	 */
	public final void setState(State state) {
		this.state = state;
	}

	/**
	 * Return the state of the storage resource.
	 * 
	 * @return state
	 */
	public final State getState() {
		return state;
	}

	/**
	 * Returns list of all storage resources.
	 * 
	 * @return network map
	 */
	public static final Map<UUID, Storage> getStorageList() {
		return storageList;
	}

	/**
	 * Return list of all action names.
	 * 
	 * @return action names
	 */
	public static final HashSet<String> getActionNames() {
		return actionNames;
	}

	/**
	 * Generate attribute List.
	 */
	public static final void generateAttributeList() {
		if (attributes.isEmpty()) {
			// add all attributes to attribute list
			attributes.add("occi.storage.size");
			attributes.add("occi.storage.state");
		}
	}

	/**
	 * Generate Action Names.
	 */
	public static final HashSet<String> generateActionNames() {
		if (actionNames.isEmpty()) {
			for (int i = 0; i < beanFactory.getBeanDefinitionNames().length; i++) {
				if (beanFactory
						.getBean(beanFactory.getBeanDefinitionNames()[i])
						.toString().contains("storage")) {
					actionNames.add(OcciConfig.getInstance().config
							.getString("occi.scheme")
							+ "/infrastructure/storage/action#"
							+ beanFactory.getBeanDefinitionNames()[i]);
				}
			}
		}
		return actionNames;
	}

	/**
	 * Generate Action Set.
	 */
	public static final HashSet<Action> generateActionSet() {
		if (actionSet.isEmpty()) {
			for (int i = 0; i < beanFactory.getBeanDefinitionNames().length; i++) {
				if (beanFactory
						.getBean(beanFactory.getBeanDefinitionNames()[i])
						.toString().contains("storage")) {
					actionSet.add((Action) beanFactory.getBean(beanFactory
							.getBeanDefinitionNames()[i]));
				}
			}
		}
		return actionSet;
	}

	/**
	 * Return the storage attributes.
	 * 
	 * @return attributes
	 */
	public static final HashSet<String> getAttributes() {
		return attributes;
	}

	/**
	 * @param online
	 *            the online to set
	 */
	public void setOnline(Action online) {
		this.online = online;
	}

	/**
	 * @return the online
	 */
	public Action getOnline() {
		return online;
	}

	/**
	 * @param create
	 *            the create to set
	 */
	public void setCreate(Action create) {
		this.create = create;
	}

	/**
	 * @return the create
	 */
	public Action getCreate() {
		return create;
	}

	/**
	 * @param snapshot
	 *            the snapshot to set
	 */
	public void setSnapshot(Action snapshot) {
		this.snapshot = snapshot;
	}

	/**
	 * @return the snapshot
	 */
	public Action getSnapshot() {
		return snapshot;
	}

	/**
	 * @param offline
	 *            the offline to set
	 */
	public void setOffline(Action offline) {
		this.offline = offline;
	}

	/**
	 * @return the offline
	 */
	public Action getOffline() {
		return offline;
	}

	/**
	 * @param resize
	 *            the resize to set
	 */
	public void setResize(Action resize) {
		this.resize = resize;
	}

	/**
	 * @return the resize
	 */
	public Action getResize() {
		return resize;
	}

	/**
	 * @param backup
	 *            the backup to set
	 */
	public void setBackup(Action backup) {
		this.backup = backup;
	}

	/**
	 * @return the backup
	 */
	public Action getBackup() {
		return backup;
	}
} public class IPNetworkInterface extends Mixin {
	/**
	 * Internet Protocol(IP) network address (e.g. 192.168.0.1/24, fc00::/7) of
	 * the link [T. Metsch, A. Edmonds - Open Cloud Computing Interface -
	 * Infrastructure, http://ogf.org/documents/GFD.184.pdf, Apr. 2011]
	 */
	private String ip;
	/**
	 * Internet Protocol(IP) network address (e.g. 192.168.0.1/24, fc00::/7) [T.
	 * Metsch, A. Edmonds - Open Cloud Computing Interface - Infrastructure,
	 * http://ogf.org/documents/GFD.184.pdf, Apr. 2011]
	 */
	private String gateway;
	/**
	 * Address mechanism: dynamic e.g. uses the dynamic host configuration
	 * protocol, static e.g. uses user supplied static net- work configurations.
	 * [T. Metsch, A. Edmonds - Open Cloud Computing Interface - Infrastructure,
	 * http://ogf.org/documents/GFD.184.pdf, Apr. 2011]
	 */
	private Allocation allocation;

	/**
	 * Possible allocations.
	 */
	public enum Allocation {
		DYNAMIC, STATIC
	}

	/**
	 * Static HashSet of all network interface attributes.
	 */
	public static HashSet<String> attributes = new HashSet<String>();

	public IPNetworkInterface(String ip, String gateway, Allocation allocation)
			throws SchemaViolationException, URISyntaxException {
		super(null, "ipnetwork", "ipnetwork",
				"http://schemas.ogf.org/occi/infrastructure/network#", null);
		this.ip = ip;
		this.gateway = gateway;
		this.allocation = allocation;

		generateAttributeList();
	}

	/**
	 * Constructor for the query interface. Necessary.
	 * 
	 * @param term
	 * @param title
	 * @param scheme
	 * @throws SchemaViolationException
	 * @throws URISyntaxException
	 */
	public IPNetworkInterface(Set<Mixin> related, String term, String title,
			String scheme, Set<String> attributes)
			throws SchemaViolationException, URISyntaxException {
		super(related, term, title, scheme, attributes);

		generateAttributeList();
	}

	/**
	 * Generate attribute List.
	 */
	public static void generateAttributeList() {
		if (attributes.isEmpty()) {
			// add all attributes to attribute list
			attributes.add("occi.network.address");
			attributes.add("occi.network.gateway");
			attributes.add("occi.network.allocation");
		}
	}

	/**
	 * Sets the network interface ip.
	 * 
	 * @param ip
	 */
	public void setIp(String ip) {
		this.ip = ip;
	}

	/**
	 * Returns the network interface ip.
	 * 
	 * @param ip
	 */
	public String getIp() {
		return ip;
	}

	/**
	 * Sets the network interface gateway.
	 * 
	 * @param ip
	 */
	public void setGateway(String gateway) {
		this.gateway = gateway;
	}

	/**
	 * Returns the network interface gateway.
	 * 
	 * @param gateway
	 */
	public String getGateway() {
		return gateway;
	}

	/**
	 * Sets the network interface allocation.
	 * 
	 * @param allocation
	 */
	public void setAllocation(Allocation allocation) {
		this.allocation = allocation;
	}

	/**
	 * Returns the network interface allocation.
	 * 
	 * @param allocation
	 */
	public Allocation getAllocation() {
		return allocation;
	}
} public class NetworkInterface extends Link {
	/**
	 * Identifier that relates the link to the link's device interface. [T. Metsch, A. Edmonds - Open Cloud Computing Interface - Infrastructure, http://ogf.org/documents/GFD.184.pdf, Apr. 2011]
	 */
	private final String networkInterface;
	/**
	 * MAC address associated with the link's device interface. [T. Metsch, A. Edmonds - Open Cloud Computing Interface - Infrastructure, http://ogf.org/documents/GFD.184.pdf, Apr. 2011]
	 */
	private String mac;
	/**
	 * Current status of the instance. [T. Metsch, A. Edmonds - Open Cloud Computing Interface - Infrastructure, http://ogf.org/documents/GFD.184.pdf, Apr. 2011]
	 */
	private final State state;

	/**
	 * Possible status of the instance. [T. Metsch, A. Edmonds - Open Cloud Computing Interface - Infrastructure, http://ogf.org/documents/GFD.184.pdf, Apr. 2011]
	 */
	public enum State {
		active, inactive
	}

	/**
	 * Random UUID of the compute resource.
	 */
	private final UUID uuid;

	public static Map<UUID, NetworkInterface> networkInterfaceList = new HashMap<UUID, NetworkInterface>();

	/**
	 * Static HashSet of all network interface attributes.
	 */
	private static HashSet<String> attributes = new HashSet<String>();

	public NetworkInterface(String networkInterface, String mac, State state,
			Resource link, Resource target) throws URISyntaxException,
			SchemaViolationException {
		super(link, target);
		this.networkInterface = networkInterface;
		this.mac = mac;
		this.state = state;
		uuid = UUID.randomUUID();
		setId(new URI(uuid.toString()));
		// put resource into networkinterface list
		networkInterfaceList.put(uuid, this);

		// setKind(new Kind(this, target.getKind().getTerm(), target.getKind()
		// .getTitle(), attributes));

		// Generate attribute list
		generateAttributeList();
	}

	/**
	 * Generate attribute List.
	 */
	public static void generateAttributeList() {
		if (attributes.isEmpty()) {
			// add all attributes to attribute list
			attributes.add("occi.networkinterface.interface");
			attributes.add("occi.networkinterface.mac");
			attributes.add("occi.networkinterface.state");
		}
	}

	/**
	 * Return the network interface attributes.
	 * 
	 * @return attributes
	 */
	public static HashSet<String> getAttributes() {
		return attributes;
	}

	/**
	 * Returns the network interface.
	 * 
	 * @return string
	 */
	public String getNetworkInterface() {
		return networkInterface;
	}

	/**
	 * Sets the mac adress of the network interface.
	 * 
	 * @param mac
	 */
	public void setMac(String mac) {
		this.mac = mac;
	}

	/**
	 * Returns the mac adress of the network interface.
	 * 
	 * @return string
	 */
	public String getMac() {
		return mac;
	}

	/**
	 * Returns the state of the network interface.
	 * 
	 * @return state
	 */
	public State getState() {
		return state;
	}
	
	/**
	 * Returns the list with all network interface instances.
	 * 
	 * @return list with network interfaces
	 */
	public static Map<UUID, NetworkInterface> getNetworkInterfaceList() {
		return networkInterfaceList;
	}
	
	/**
	 * Sets the network interface list.
	 * 
	 * @param networkInterfaceList
	 */
	public void setNetworkInterfaceList(Map<UUID, NetworkInterface> networkInterfaceList) {
		NetworkInterface.networkInterfaceList = networkInterfaceList;
	}
} public class StorageLink extends Link {
	/**
	 * Device identifier as defined by the OCCI service provider. [T. Metsch, A. Edmonds - Open Cloud Computing Interface - Infrastructure, http://ogf.org/documents/GFD.184.pdf, Apr. 2011]
	 */
	private String deviceid;
	/**
	 * Point to where the storage is mounted in the guest OS. [T. Metsch, A. Edmonds - Open Cloud Computing Interface - Infrastructure, http://ogf.org/documents/GFD.184.pdf, Apr. 2011]
	 */
	private String mountpoint;
	/**
	 * Current status of the instance. [T. Metsch, A. Edmonds - Open Cloud Computing Interface - Infrastructure, http://ogf.org/documents/GFD.184.pdf, Apr. 2011]
	 */
	private State state;

	/**
	 * Possible status of the instance.
	 */
	private enum State {
		active, inactive
	}

	/**
	 * Static HashSet of all storage link attributes.
	 */
	public static HashSet<String> attributes = new HashSet<String>();

	public StorageLink(String deviceid, State state, Resource link,
			Resource target) throws URISyntaxException {
		super(link, target);
		this.deviceid = deviceid;
		this.state = state;
	}

	public StorageLink(String deviceid, State state, String mountpoint,
			Resource link, Resource target) throws URISyntaxException {
		super(link, target);
		this.deviceid = deviceid;
		this.state = state;
		this.mountpoint = mountpoint;
	}

	/**
	 * Generate attribute List.
	 */
	public static void generateAttributeList() {
		if (attributes.isEmpty()) {
			// add all attributes to attribute list
			attributes.add("occi.storagelink.deviceid");
			attributes.add("occi.storagelink.state");
			attributes.add("occi.storagelink.mountpoint");
		}
	}

	/**
	 * Sets devices id.
	 * 
	 * @param deviceid
	 */
	public void setDeviceid(String deviceid) {
		this.deviceid = deviceid;
	}

	/**
	 * Returns device id of the storage link.
	 * 
	 * @return devices id
	 */
	public String getDeviceid() {
		return deviceid;
	}

	/**
	 * Sets mountpoint of the storage link.
	 * 
	 * @param mountpoint
	 */
	public void setMountpoint(String mountpoint) {
		this.mountpoint = mountpoint;
	}

	/**
	 * Returns mountpoint of the storage link.
	 * 
	 * @return mountpoint
	 */
	public String getMountpoint() {
		return mountpoint;
	}

	/**
	 * Returns state of the storage link.
	 * 
	 * @return state
	 */
	public State getState() {
		return state;
	}
}
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import javax.naming.directory.SchemaViolationException;
import occi.config.OcciConfig;
import occi.core.Action;
import occi.core.Kind;
import occi.core.Link;
import occi.core.Mixin;
import occi.http.check.OcciCheck;
import occi.infrastructure.Compute;
import occi.infrastructure.Network;
import occi.infrastructure.Storage;
import occi.infrastructure.links.IPNetworkInterface;
import occi.infrastructure.links.NetworkInterface;
import occi.infrastructure.links.StorageLink;
import org.restlet.data.Form;
import org.restlet.data.Status;
import org.restlet.representation.Representation;
import org.restlet.resource.Delete;
import org.restlet.resource.Get;
import org.restlet.resource.Put;
import org.restlet.resource.ServerResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
				buffer.append("\r\n");
				buffer.append("\t\t location=/").append(kind.getTerm())
						.append("/;");
				buffer.append("\r\n");
			}
		}

		/*
		 * Print all link properties.
		 */
		for (Link link : queryLinks) {
			if (link != null) {
				buffer.append("Category: ").append(link.getKind().getTerm())
						.append(";");
				buffer.append("\t\t scheme=\"")
						.append(link.getKind().getScheme()).append("\";");
				buffer.append("\r\n");
				buffer.append("\t\t class=\"link\";");
				buffer.append("\r\n");
				// append related scheme to buffer, if kind has a related kind
				if (link.getKind().getRelated() != null) {
					for (Kind related : link.getKind().getRelated()) {
						if (related != null) {
							buffer.append("\t\t rel=")
									.append(related.getScheme()).append(";\n");
						}
					}
				}
				buffer.append("\t\t attributes=\"");
				if (link.getKind().getAttributes() != null) {
					for (String attribute : link.getKind().getAttributes()) {
						if (attribute != null) {
							buffer.append(attribute + " ");
						}
					}
				}
				buffer.append("\";\n");
				buffer.append("\t\t actions=");
				for (String actionName : link.getKind().getActionNames()) {
					if (actionName != null) {
						buffer.append(actionName).append(" ");
					}
				}
				buffer.append(";");
				buffer.append("\r\n");
				buffer.append("\t\t location=/")
						.append(link.getKind().getTerm()).append("/;");
				buffer.append("\r\n");
			}
		}

		/*
		 * Print all properties of the mixin instance
		 */

		if (ipNetworkInterface != null) {
			buffer.append("Category: ").append(ipNetworkInterface.getTitle())
					.append(";");
			buffer.append("\t\t scheme=\"")
					.append(ipNetworkInterface.getScheme()).append("\";");
			buffer.append("\r\n");
			buffer.append("\t\t class=\"mixin\"");
			buffer.append("\r\n");
			// append related scheme to buffer, if kind has a related
			// kind
			if (ipNetworkInterface.getRelated() != null) {
				for (Mixin related : ipNetworkInterface.getRelated()) {
					if (related != null) {
						buffer.append("\t\t rel=").append(related.getScheme())
								.append(";\n");
					}
				}
			}
			buffer.append("\t\t attributes=\"");
			if (ipNetworkInterface.getAttributes() != null) {
				for (String attribute : ipNetworkInterface.getAttributes()) {
					if (attribute != null) {
						buffer.append(attribute).append(" ");
					}
				}
			}
			buffer.append("\";\n");
			buffer.append("\t\t location=/")
					.append(ipNetworkInterface.getTerm()).append("/;");
			buffer.append("\r\n");
		}

		/*
		 * Print all properties of the mixin instance
		 */
		for (Mixin mixin : Mixin.getMixins()) {
			if (mixin != null && !mixin.getTerm().equals("ipnetwork")) {
				buffer.append("Category: " + mixin.getTitle()).append(";");

				buffer.append("\r\n");
				buffer.append("\t\t class=\"mixin\"");
				buffer.append("\r\n");
				// append related scheme to buffer, if kind has a related
				// kind
				if (mixin.getRelated() != null) {
					for (Mixin related : mixin.getRelated()) {
						if (related != null) {
							buffer.append("\t\t rel=")
									.append(related.getScheme()).append(";\n");
						}
					}
				}
				buffer.append("\t\t scheme=").append(mixin.getScheme())
						.append(";");
				buffer.append("\r\n");
				buffer.append("\t\t location=/").append(mixin.getTerm())
						.append("/;");
				buffer.append("\r\n");
			}
		}
		buffer.append("\r\n");

		// Generate all action names list
		Network.generateActionNames();
		Storage.generateActionNames();
		Compute.generateActionNames();