Removed all sources from repository and using watch-file instead.
+++ /dev/null
-build.xml
-/nbproject
-nb-configuration.xml
-/target/
-nbactions.xml
+++ /dev/null
-language: java
-
-jdk:
- - openjdk7
- - oraclejdk7
- - oraclejdk8
-
-bracnhes:
- only:
- - master
+++ /dev/null
-The work represented by this source file is partially or entirely funded
-by the EGI-InSPIRE project through the European Commission's 7th Framework
-Programme (contract # INFSO-RI-261323)
-
-Copyright (c) 2014-2015 CESNET
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
+++ /dev/null
-jOCCI-api - A Java OCCI Framework
-==================================
-
-[](http://travis-ci.org/EGI-FCTF/jOCCI-api)
-
-Requirements
-------------
-* JDK 7+
-* Maven
-
-Instalation
------------
-Using Maven:
-```xml
-<dependency>
- <groupId>cz.cesnet.cloud</groupId>
- <artifactId>jocci-api</artifactId>
- <version>0.2.6</version>
-</dependency>
-```
-
-Usage
------
-Detailed documentation is available in project's [Wiki](https://github.com/EGI-FCTF/jOCCI-api/wiki).
-
-### Continuous integration
-
-[Continuous integration for jOCCI by Travis-CI](http://travis-ci.org/EGI-FCTF/jOCCI-api/)
-
-### Contribute
-
-1. Fork it.
-2. Create a branch (git checkout -b my_markup)
-3. Commit your changes (git commit -am "My changes")
-4. Push to the branch (git push origin my_markup)
-5. Create an Issue with a link to your branch
--- /dev/null
+version=3
+opts="filenamemangle=s/(?:.*)?jocci-api-?(\d[\d\.]*)\.tar\.gz/jOCCI-api-$1.tar.gz/" \
+ https://github.com/EGI-FCTF/jOCCI-api/tags (?:.*/)?jocci-api-?(\d[\d\.]*)\.tar\.gz
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>cz.cesnet.cloud</groupId>
- <artifactId>jocci-api</artifactId>
- <version>0.2.6</version>
- <packaging>jar</packaging>
- <name>${project.groupId}:${project.artifactId}</name>
- <description>A Java OCCI framework - transport api library.</description>
- <url>https://github.com/EGI-FCTF/jOCCI-api</url>
- <licenses>
- <license>
- <name>The Apache License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- <developers>
- <developer>
- <name>Michal Kimle</name>
- <email>kimle.michal@gmail.com</email>
- <organization>CESNET</organization>
- <organizationUrl>http://www.cesnet.cz/</organizationUrl>
- </developer>
- </developers>
- <scm>
- <connection>scm:git:git@github.com:EGI-FCTF/jOCCI-api.git</connection>
- <developerConnection>scm:git:git@github.com:EGI-FCTF/jOCCI-api.git</developerConnection>
- <url>https://github.com/EGI-FCTF/jOCCI-api</url>
- <tag>jocci-api-0.2.6</tag>
- </scm>
- <dependencies>
- <dependency>
- <groupId>cz.cesnet.cloud</groupId>
- <artifactId>jocci-core</artifactId>
- <version>0.2.4</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.7.7</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>1.7.7</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.10</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.github.tomakehurst</groupId>
- <artifactId>wiremock</artifactId>
- <version>1.53</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- <version>4.3.6</version>
- </dependency>
- <dependency>
- <groupId>org.bouncycastle</groupId>
- <artifactId>bcprov-jdk16</artifactId>
- <version>1.46</version>
- </dependency>
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- <version>2.5</version>
- </dependency>
- </dependencies>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <maven.compiler.source>1.7</maven.compiler.source>
- <maven.compiler.target>1.7</maven.compiler.target>
- </properties>
- <distributionManagement>
- <snapshotRepository>
- <id>ossrh</id>
- <url>https://oss.sonatype.org/content/repositories/snapshots</url>
- </snapshotRepository>
- <repository>
- <id>ossrh</id>
- <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
- </repository>
- </distributionManagement>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.9</version>
- <reportSets>
- <reportSet>
- <reports>
- <report>javadoc</report>
- </reports>
- </reportSet>
- <reportSet>
- <id>aggregate</id>
- <inherited>false</inherited>
- <reports>
- <report>aggregate</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- </plugins>
- </reporting>
- <build>
- <plugins>
- <plugin>
- <groupId>org.sonatype.plugins</groupId>
- <artifactId>nexus-staging-maven-plugin</artifactId>
- <version>1.6.3</version>
- <extensions>true</extensions>
- <configuration>
- <serverId>ossrh</serverId>
- <nexusUrl>https://oss.sonatype.org/</nexusUrl>
- <autoReleaseAfterClose>true</autoReleaseAfterClose>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-release-plugin</artifactId>
- <version>2.5</version>
- <configuration>
- <autoVersionSubmodules>true</autoVersionSubmodules>
- <useReleaseProfile>false</useReleaseProfile>
- <releaseProfiles>release</releaseProfiles>
- <goals>deploy</goals>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-site-plugin</artifactId>
- <version>3.4</version>
- </plugin>
- <plugin>
- <groupId>com.github.github</groupId>
- <artifactId>site-maven-plugin</artifactId>
- <version>0.11</version>
- <configuration>
- <message>Creating site for ${project.version}</message>
- <server>github</server>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>site</goal>
- </goals>
- <phase>site</phase>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <profiles>
- <profile>
- <id>release</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <version>2.2.1</version>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar-no-fork</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.9.1</version>
- <executions>
- <execution>
- <id>attach-javadocs</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-gpg-plugin</artifactId>
- <version>1.5</version>
- <executions>
- <execution>
- <id>sign-artifacts</id>
- <phase>verify</phase>
- <goals>
- <goal>sign</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
\ No newline at end of file
+++ /dev/null
-package cz.cesnet.cloud.occi.api;
-
-import cz.cesnet.cloud.occi.api.exception.CommunicationException;
-
-/**
- * Authentication method interface
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public interface Authentication {
-
- /**
- * Returns unique identifier for this authentication method.
- *
- * @return unique authentication identifier
- */
- String getIdentifier();
-
- /**
- * Returns authentication's fallback authentication method.
- *
- * @return fallback authentication method
- */
- Authentication getFallback();
-
- /**
- * Runs the authentication.
- *
- * @throws CommunicationException when error occures during the
- * communication
- */
- void authenticate() throws CommunicationException;
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.api;
-
-import cz.cesnet.cloud.occi.Model;
-import cz.cesnet.cloud.occi.api.exception.CommunicationException;
-import cz.cesnet.cloud.occi.core.ActionInstance;
-import cz.cesnet.cloud.occi.core.Entity;
-import java.net.URI;
-import java.util.List;
-
-/**
- * Abstract class representing an OCCI client.
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public abstract class Client {
-
- public static final String MODEL_URI = "/-/";
- private URI endpoint;
- private Model model;
- private boolean connected;
- private Authentication authentication;
-
- /**
- * Returns client's endpoint.
- *
- * @return client's endpoint
- */
- public URI getEndpoint() {
- return endpoint;
- }
-
- /**
- * Sets client's endpoint.
- *
- * @param endpoint client's endpoint
- */
- public void setEndpoint(URI endpoint) {
- this.endpoint = endpoint.normalize();
- }
-
- /**
- * Returns model.
- *
- * @return model
- */
- public Model getModel() {
- return model;
- }
-
- /**
- * Sets model.
- *
- * @param model model
- */
- public void setModel(Model model) {
- this.model = model;
- }
-
- /**
- * Checks whether client is connected.
- *
- * @return true if client is connected false otherwise
- */
- public boolean isConnected() {
- return connected;
- }
-
- /**
- * Sets whether client is connected or not.
- *
- * @param connected client's connection status
- */
- public void setConnected(boolean connected) {
- this.connected = connected;
- }
-
- /**
- * Returns client's authentication method.
- *
- * @return client's authentication method
- */
- public Authentication getAuthentication() {
- return authentication;
- }
-
- /**
- * Sets client's authentication method.
- *
- * @param authentication client's authentication method
- */
- public void setAuthentication(Authentication authentication) {
- this.authentication = authentication;
- }
-
- /**
- * <p>
- * Retrieves all available resources represented by resource locations
- * (URIs).</p>
- *
- * <p>
- * Example:</p>
- *
- * <pre>{@code
- * List<URI> list = client.list();}</pre>
- *
- * @return resources represented by resource locations (URIs)
- * @throws CommunicationException when error occured during the
- * communication with server
- */
- public abstract List<URI> list() throws CommunicationException;
-
- /**
- * Retrieves available resources of a certain type represented by resource
- * locations (URIs).
- *
- * <p>
- * Example:</p>
- *
- * <pre>{@code
- * List<URI> list = client.list("compute");}</pre>
- *
- * @param resourceType resource type in shortened format (e.g. "compute",
- * "storage", "network")
- * @return resources represented by resource locations (URIs)
- * @throws CommunicationException when error occured during the
- * communication with server
- */
- public abstract List<URI> list(String resourceType) throws CommunicationException;
-
- /**
- * Retrieves available resources of a certain type represented by resource
- * locations (URIs).
- *
- * <p>
- * Example:</p>
- *
- * <pre>{@code
- * List<URI> list = client.list(URI.create("http://schemas.ogf.org/occi/infrastructure#network"));}</pre>
- *
- * @param resourceIdentifier full resource type identifier
- * @return resources represented by resource locations (URIs)
- * @throws CommunicationException when error occured during the
- * communication with server
- */
- public abstract List<URI> list(URI resourceIdentifier) throws CommunicationException;
-
- /**
- * Retrieves descriptions for all available resources.
- *
- * <p>
- * Example:</p>
- *
- * <pre>{@code
- * List<Entity> list = client.describe();}</pre>
- *
- * @return list of resource or link descriptions
- * @throws CommunicationException when error occured during the
- * communication with server
- */
- public abstract List<Entity> describe() throws CommunicationException;
-
- /**
- * Retrieves descriptions for available resources of a certain type.
- *
- * <p>
- * Example:</p>
- *
- * <pre>{@code
- * List<Entity> list = client.describe("compute");}</pre>
- *
- * @param resourceType resource type in shortened format (e.g. "compute",
- * "storage", "network")
- * @return list of resource or link descriptions
- * @throws CommunicationException when error occured during the
- * communication with server
- */
- public abstract List<Entity> describe(String resourceType) throws CommunicationException;
-
- /**
- * Retrieves descriptions for available resources specified by a type
- * identifier or resource identifier.
- *
- * <p>
- * Example:</p>
- *
- * <pre>{@code
- * List<Entity> list = client.describe(URI.create("http://schemas.ogf.org/occi/infrastructure#network"));
- *...
- *list = client.describe(URI.create("https://remote.server.net/storage/123"));}</pre>
- *
- * @param resourceIdentifier either full resource type identifier or full
- * resource identifier
- * @return list of resource or link descriptions
- * @throws CommunicationException when error occured during the
- * communication with server
- */
- public abstract List<Entity> describe(URI resourceIdentifier) throws CommunicationException;
-
- /**
- * Creates a new resource on the server.
- *
- * <p>
- * Example:</p>
- *
- * <pre>{@code
- * Model model = client.getModel();
- *EntityBuilder entityBuilder = new EntityBuilder(model);
- *Compute compute = entityBuilder.getCompute();
- *compute.addMixin(model.findMixin("debian7", "os_tpl"));
- *compute.addMixin(model.findMixin("small", "resource_tpl"));
- *compute.setMemory(1024);
- *compute.setCores(4);
- *URI location = client.create(compute);}</pre>
- *
- * @param entity Creates a new resource on the server.
- * @return URI of the new resource
- * @throws CommunicationException when error occured during the
- * communication with server
- */
- public abstract URI create(Entity entity) throws CommunicationException;
-
- public abstract URI update(Entity entity) throws CommunicationException;
-
- /**
- * Deletes all resource of a certain resource type from the server.
- *
- * <p>
- * Example:</p>
- *
- * <pre>{@code
- * boolean wasSuccessful = client.delete("compute");}</pre>
- *
- * @param resourceType resource type in shortened format (e.g. "compute",
- * "storage", "network")
- * @return true if the deletion was successful, false otherwise
- * @throws CommunicationException when error occured during the
- * communication with server
- */
- public abstract boolean delete(String resourceType) throws CommunicationException;
-
- /**
- * Deletes all resource of a certain resource type or specific resource from
- * the server.
- *
- * <p>
- * Example:</p>
- *
- * <pre>{@code
- * boolean wasSuccessful = client.delete(URI.create("http://schemas.ogf.org/occi/infrastructure#network"));
- *...
- *wasSuccessful = client.delete(URI.create("https://remote.server.net/storage/123"));}</pre>
- *
- * @param resourceIdentifier either full resource type identifier or full
- * resource identifier
- * @return true if the deletion was successful, false otherwise
- * @throws CommunicationException when error occured during the
- * communication with server
- */
- public abstract boolean delete(URI resourceIdentifier) throws CommunicationException;
-
- /**
- * Triggers given action on a specified set of resources.
- *
- * <p>
- * Example:</p>
- *
- * <pre>{@code
- * Model model = client.getModel();
- *EntityBuilder entityBuilder = new EntityBuilder(model);
- *ActionInstance actionInstance = entityBuilder.getActionInstance("start");
- *boolean wasSuccessful = client.trigger("compute", actionInstance);}</pre>
- *
- * @param resourceType resource type in shortened format (e.g. "compute",
- * "storage", "network")
- * @param action type of action
- * @return true if the action was successful, false otherwise
- * @throws CommunicationException when error occured during the
- * communication with server
- */
- public abstract boolean trigger(String resourceType, ActionInstance action) throws CommunicationException;
-
- /**
- * Triggers given action on a set of resources or on a specified resource.
- *
- * <p>
- * Example:</p>
- *
- * <pre>{@code
- * Model model = client.getModel();
- *EntityBuilder entityBuilder = new EntityBuilder(model);
- *ActionInstance actionInstance = entityBuilder.getActionInstance("start");
- *boolean wasSuccessful = client.trigger(URI.create("http://schemas.ogf.org/occi/infrastructure#network"), actionInstance);
- *...
- *wasSuccessful = client.trigger(URI.create("https://remote.server.net/compute/456"), actionInstance);}</pre>
- *
- * @param resourceIdentifier either full resource type identifier or full
- * resource identifier
- * @param action type of action
- * @return true if the action was successful, false otherwise
- * @throws CommunicationException when error occured during the
- * communication with server
- */
- public abstract boolean trigger(URI resourceIdentifier, ActionInstance action) throws CommunicationException;
-
- /**
- * Refreshes the Model used inside the client. Useful for updating the model
- * without creating a new instance or reconnecting. Saves a lot of time in
- * an interactive mode.
- *
- * @throws CommunicationException when error occured during the
- * communication with server
- */
- public abstract void refresh() throws CommunicationException;
-
- /**
- * Establishes a connection.
- *
- * @throws CommunicationException when error occured during the
- * communication with server
- */
- public abstract void connect() throws CommunicationException;
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.api;
-
-import cz.cesnet.cloud.occi.Model;
-import cz.cesnet.cloud.occi.api.exception.EntityBuildingException;
-import cz.cesnet.cloud.occi.core.Action;
-import cz.cesnet.cloud.occi.core.ActionInstance;
-import cz.cesnet.cloud.occi.core.Kind;
-import cz.cesnet.cloud.occi.core.Link;
-import cz.cesnet.cloud.occi.core.Mixin;
-import cz.cesnet.cloud.occi.core.Resource;
-import cz.cesnet.cloud.occi.exception.AmbiguousIdentifierException;
-import cz.cesnet.cloud.occi.exception.InvalidAttributeValueException;
-import cz.cesnet.cloud.occi.infrastructure.Compute;
-import cz.cesnet.cloud.occi.infrastructure.IPNetwork;
-import cz.cesnet.cloud.occi.infrastructure.IPNetworkInterface;
-import cz.cesnet.cloud.occi.infrastructure.Network;
-import cz.cesnet.cloud.occi.infrastructure.NetworkInterface;
-import cz.cesnet.cloud.occi.infrastructure.Storage;
-import cz.cesnet.cloud.occi.infrastructure.StorageLink;
-import java.net.URI;
-import java.util.UUID;
-
-/**
- * Builder class that helps with creation of OCCI entities.
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class EntityBuilder {
-
- private Model model;
-
- /**
- * Default constructor.
- *
- * @param model cannot be null
- */
- public EntityBuilder(Model model) {
- if (model == null) {
- throw new NullPointerException("model cannot be null");
- }
-
- this.model = model;
- }
-
- private Kind getKind(String type) throws EntityBuildingException, AmbiguousIdentifierException {
- Kind kind = model.findKind(type);
- if (kind == null) {
- throw new EntityBuildingException("unknown type '" + type + "'");
- }
-
- return kind;
- }
-
- private Kind getKind(URI identifier) throws EntityBuildingException {
- Kind kind = model.findKind(identifier);
- if (kind == null) {
- throw new EntityBuildingException("unknown identifier '" + identifier + "'");
- }
-
- return kind;
- }
-
- private Kind getKind(Class resourceClass) throws EntityBuildingException {
- URI uri = null;
- Kind defaultKind = null;
-
- if (resourceClass.equals(Compute.class)) {
- uri = URI.create(Compute.KIND_IDENTIFIER_DEFAULT);
- defaultKind = Compute.getDefaultKind();
- } else if (resourceClass.equals(Network.class)) {
- uri = URI.create(Network.KIND_IDENTIFIER_DEFAULT);
- defaultKind = Network.getDefaultKind();
- } else if (resourceClass.equals(Storage.class)) {
- uri = URI.create(Storage.KIND_IDENTIFIER_DEFAULT);
- defaultKind = Storage.getDefaultKind();
- } else if (resourceClass.equals(StorageLink.class)) {
- uri = URI.create(StorageLink.KIND_IDENTIFIER_DEFAULT);
- defaultKind = StorageLink.getDefaultKind();
- } else if (resourceClass.equals(NetworkInterface.class)) {
- uri = URI.create(NetworkInterface.KIND_IDENTIFIER_DEFAULT);
- defaultKind = NetworkInterface.getDefaultKind();
- } else {
- throw new EntityBuildingException("unknown class '" + resourceClass.getName() + "'");
- }
-
- Kind kind;
- try {
- kind = getKind(uri);
- } catch (EntityBuildingException ex) {
- kind = defaultKind;
- }
-
- return kind;
- }
-
- private Mixin getMixin(URI identifier) throws EntityBuildingException {
- Mixin mixin = model.findMixin(identifier);
- if (mixin == null) {
- throw new EntityBuildingException("unknown identifier '" + identifier + "'");
- }
-
- return mixin;
- }
-
- private Action getAction(String type) throws EntityBuildingException, AmbiguousIdentifierException {
- Action action = model.findAction(type);
- if (action == null) {
- throw new EntityBuildingException("unknown type '" + type + "'");
- }
-
- return action;
- }
-
- private Action getAction(URI identifier) throws EntityBuildingException {
- Action action = model.findAction(identifier);
- if (action == null) {
- throw new EntityBuildingException("unknown identifier '" + identifier + "'");
- }
-
- return action;
- }
-
- /**
- * Creates a link of given linkType (kind's term).
- *
- * @param linkType
- * @return new Link instance of given linkType
- * @throws EntityBuildingException if link type is ambiguous
- */
- public Link getLink(String linkType) throws EntityBuildingException {
- try {
- Kind kind = getKind(linkType);
- return createLink(kind);
- } catch (AmbiguousIdentifierException ex) {
- throw new EntityBuildingException(ex);
- }
- }
-
- /**
- * Creates a link identified by linkIdentifier (kind's scheme+term).
- *
- * @param linkIdentifier
- * @return new Link instance identified by linkIdentifier
- * @throws EntityBuildingException if kind with specified identifier is not
- * found in the model
- */
- public Link getLink(URI linkIdentifier) throws EntityBuildingException {
- return createLink(getKind(linkIdentifier));
- }
-
- /**
- * Creates a resource of given resourceType (kind's term).
- *
- * @param resourceType
- * @return new Resource instance of given resourceType
- * @throws EntityBuildingException if resource type is ambiguous
- */
- public Resource getResource(String resourceType) throws EntityBuildingException {
- try {
- Kind kind = getKind(resourceType);
- return createResource(kind);
- } catch (AmbiguousIdentifierException ex) {
- throw new EntityBuildingException(ex);
- }
- }
-
- /**
- * Creates a resource identified by resourceIdentifier (kind's scheme+term).
- *
- * @param resourceIdentifier
- * @return new Resource instance identified by resourceIdentifier
- * @throws EntityBuildingException if kind with specified identifier is not
- * found in the model
- */
- public Resource getResource(URI resourceIdentifier) throws EntityBuildingException {
- return createResource(getKind(resourceIdentifier));
- }
-
- /**
- * Creates an action instance of given actionType (action's term).
- *
- * @param actionType
- * @return new ActionInstance instance of given actionType
- * @throws EntityBuildingException if action type is ambiguous
- */
- public ActionInstance getActionInstance(String actionType) throws EntityBuildingException {
- try {
- Action action = getAction(actionType);
- return createActionInstance(action);
- } catch (AmbiguousIdentifierException ex) {
- throw new EntityBuildingException(ex);
- }
- }
-
- /**
- * Creates an action instance identified by actionIdentifier (action's
- * scheme+term).
- *
- * @param actionIdentifier
- * @return new ActionInstance instance identified by actionIdentifier
- * @throws EntityBuildingException if action with specified identifier is
- * not found in the model
- */
- public ActionInstance getActionInstance(URI actionIdentifier) throws EntityBuildingException {
- return createActionInstance(getAction(actionIdentifier));
- }
-
- /**
- * Creates an compute instance identified by resourceIdentifier (compute's
- * scheme+term).
- *
- * @param resourceIdentifier
- * @return new Compute instance identified by resourceIdentifier
- * @throws EntityBuildingException if compute with specified identifier is
- * not found in the model
- */
- public Compute getCompute(URI resourceIdentifier) throws EntityBuildingException {
- return createCompute(getKind(resourceIdentifier));
- }
-
- /**
- * Creates a default compute instance.
- *
- * @return new default Compute instance
- * @throws EntityBuildingException
- */
- public Compute getCompute() throws EntityBuildingException {
- return createCompute(getKind(Compute.class));
- }
-
- /**
- * Creates an network instance identified by resourceIdentifier (network's
- * scheme+term).
- *
- * @param resourceIdentifier
- * @return new Network instance identified by resourceIdentifier
- * @throws EntityBuildingException
- */
- public Network getNetwork(URI resourceIdentifier) throws EntityBuildingException {
- return createNetwork(getKind(resourceIdentifier));
- }
-
- /**
- * Creates a default network instance.
- *
- * @return new default Network instance
- * @throws EntityBuildingException
- */
- public Network getNetwork() throws EntityBuildingException {
- return createNetwork(getKind(Network.class));
- }
-
- /**
- * Creates an storage instance identified by resourceIdentifier (storage's
- * scheme+term).
- *
- * @param resourceIdentifier
- * @return new Storage instance identified by resourceIdentifier
- * @throws EntityBuildingException
- */
- public Storage getStorage(URI resourceIdentifier) throws EntityBuildingException {
- return createStorage(getKind(resourceIdentifier));
- }
-
- /**
- * Creates a default storage instance.
- *
- * @return new default Storage instance
- * @throws EntityBuildingException
- */
- public Storage getStorage() throws EntityBuildingException {
- return createStorage(getKind(Storage.class));
- }
-
- /**
- * Creates an storage link instance identified by resourceIdentifier (link's
- * scheme+term).
- *
- * @param resourceIdentifier
- * @return new StorageLink instance identified by resourceIdentifier
- * @throws EntityBuildingException
- */
- public StorageLink getStorageLink(URI resourceIdentifier) throws EntityBuildingException {
- return createStorageLink(getKind(resourceIdentifier));
- }
-
- /**
- * Creates a default storage link instance.
- *
- * @return new default StorageLink instance
- * @throws EntityBuildingException
- */
- public StorageLink getStorageLink() throws EntityBuildingException {
- return createStorageLink(getKind(StorageLink.class));
- }
-
- /**
- * Creates an network interface instance identified by resourceIdentifier
- * (interface's scheme+term).
- *
- * @param resourceIdentifier
- * @return new NetworkInterface instance identified by resourceIdentifier
- * @throws EntityBuildingException
- */
- public NetworkInterface getNetworkInterface(URI resourceIdentifier) throws EntityBuildingException {
- return createNetworkInterface(getKind(resourceIdentifier));
- }
-
- /**
- * Creates a default network interface instance.
- *
- * @return new default NetworkInterface instance
- * @throws EntityBuildingException
- */
- public NetworkInterface getNetworkInterface() throws EntityBuildingException {
- return createNetworkInterface(getKind(NetworkInterface.class));
- }
-
- /**
- * Creates an ip network instance identified by kind and mixin identifier
- * (scheme+term).
- *
- * @param kindIdentifier
- * @param mixinIdentifier
- * @return new IPNetwork instance identified by its kind and mixin
- * identifiers
- * @throws EntityBuildingException
- */
- public IPNetwork getIPNetwork(URI kindIdentifier, URI mixinIdentifier) throws EntityBuildingException {
- return createIPNetwork(getKind(kindIdentifier), getMixin(mixinIdentifier));
- }
-
- /**
- * Creates a default ip network instance.
- *
- * @return new default IPNetwork instance
- * @throws EntityBuildingException
- */
- public IPNetwork getIPNetwork() throws EntityBuildingException {
- Kind kind = getKind(Network.class);
-
- Mixin mixin;
- try {
- mixin = getMixin(URI.create(IPNetwork.MIXIN_IDENTIFIER_DEFAULT));
- } catch (EntityBuildingException ex) {
- mixin = IPNetwork.getDefaultMixin();
- }
-
- return createIPNetwork(kind, mixin);
- }
-
- /**
- * Creates an ip network interface instance identified by kind and mixin
- * identifier (scheme+term).
- *
- * @param kindIdentifier
- * @param mixinIdentifier
- * @return new IPNetworkInterface instance identified by its kind and mixin
- * identifiers
- * @throws EntityBuildingException
- */
- public IPNetworkInterface getIPNetworkInterface(URI kindIdentifier, URI mixinIdentifier) throws EntityBuildingException {
- return createIPNetworkInterface(getKind(kindIdentifier), getMixin(mixinIdentifier));
- }
-
- /**
- * Creates a default ip network interface instance.
- *
- * @return new default IPNetworkInterface instance
- * @throws EntityBuildingException
- */
- public IPNetworkInterface getIPNetworkInterface() throws EntityBuildingException {
- Kind kind = getKind(NetworkInterface.class);
-
- Mixin mixin;
- try {
- mixin = getMixin(URI.create(IPNetworkInterface.MIXIN_IDENTIFIER_DEFAULT));
- } catch (EntityBuildingException ex) {
- mixin = IPNetworkInterface.getDefaultMixin();
- }
-
- return createIPNetworkInterface(kind, mixin);
- }
-
- private Resource createResource(Kind kind) {
- try {
- Resource resource = new Resource(UUID.randomUUID().toString(), kind);
- resource.setModel(model);
- return resource;
- } catch (InvalidAttributeValueException ex) {
- throw new RuntimeException("Invalid ID attribute value. This should not happen!", ex);
- }
- }
-
- private Link createLink(Kind kind) {
- try {
- Link link = new Link(UUID.randomUUID().toString(), kind);
- link.setModel(model);
- return link;
- } catch (InvalidAttributeValueException ex) {
- throw new RuntimeException("Invalid ID attribute value. This should not happen!", ex);
- }
- }
-
- private ActionInstance createActionInstance(Action action) {
- ActionInstance ai = new ActionInstance(action);
- ai.setModel(model);
- return ai;
- }
-
- private Compute createCompute(Kind kind) {
- try {
- Compute compute = new Compute(UUID.randomUUID().toString(), kind);
- compute.setModel(model);
- return compute;
- } catch (InvalidAttributeValueException ex) {
- throw new RuntimeException("Invalid ID attribute value. This should not happen!", ex);
- }
- }
-
- private Network createNetwork(Kind kind) {
- try {
- Network network = new Network(UUID.randomUUID().toString(), kind);
- network.setModel(model);
- return network;
- } catch (InvalidAttributeValueException ex) {
- throw new RuntimeException("Invalid ID attribute value. This should not happen!", ex);
- }
- }
-
- private Storage createStorage(Kind kind) {
- try {
- Storage storage = new Storage(UUID.randomUUID().toString(), kind);
- storage.setModel(model);
- return storage;
- } catch (InvalidAttributeValueException ex) {
- throw new RuntimeException("Invalid ID attribute value. This should not happen!", ex);
- }
- }
-
- private StorageLink createStorageLink(Kind kind) {
- try {
- StorageLink storageLink = new StorageLink(UUID.randomUUID().toString(), kind);
- storageLink.setModel(model);
- return storageLink;
- } catch (InvalidAttributeValueException ex) {
- throw new RuntimeException("Invalid ID attribute value. This should not happen!", ex);
- }
- }
-
- private NetworkInterface createNetworkInterface(Kind kind) {
- try {
- NetworkInterface networkInterface = new NetworkInterface(UUID.randomUUID().toString(), kind);
- networkInterface.setModel(model);
- return networkInterface;
- } catch (InvalidAttributeValueException ex) {
- throw new RuntimeException("Invalid ID attribute value. This should not happen!", ex);
- }
- }
-
- private IPNetwork createIPNetwork(Kind kind, Mixin mixin) {
- try {
- IPNetwork ipnetwork = new IPNetwork(UUID.randomUUID().toString(), kind);
- ipnetwork.setModel(model);
- ipnetwork.addMixin(mixin);
- return ipnetwork;
- } catch (InvalidAttributeValueException ex) {
- throw new RuntimeException("Invalid ID attribute value. This should not happen!", ex);
- }
- }
-
- private IPNetworkInterface createIPNetworkInterface(Kind kind, Mixin mixin) {
- try {
- IPNetworkInterface ipnetworkInterface = new IPNetworkInterface(UUID.randomUUID().toString(), kind);
- ipnetworkInterface.setModel(model);
- ipnetworkInterface.addMixin(mixin);
- return ipnetworkInterface;
- } catch (InvalidAttributeValueException ex) {
- throw new RuntimeException("Invalid ID attribute value. This should not happen!", ex);
- }
- }
-
- /**
- * Returns model.
- *
- * @return model
- */
- public Model getModel() {
- return model;
- }
-
- /**
- * Sets model.
- *
- * @param model model
- */
- public void setModel(Model model) {
- this.model = model;
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.api.example;
-
-import cz.cesnet.cloud.occi.Model;
-import cz.cesnet.cloud.occi.api.Client;
-import cz.cesnet.cloud.occi.api.EntityBuilder;
-import cz.cesnet.cloud.occi.api.exception.CommunicationException;
-import cz.cesnet.cloud.occi.api.exception.EntityBuildingException;
-import cz.cesnet.cloud.occi.api.http.HTTPClient;
-import cz.cesnet.cloud.occi.api.http.auth.HTTPAuthentication;
-import cz.cesnet.cloud.occi.api.http.auth.X509Authentication;
-import cz.cesnet.cloud.occi.core.ActionInstance;
-import cz.cesnet.cloud.occi.core.Entity;
-import cz.cesnet.cloud.occi.core.Mixin;
-import cz.cesnet.cloud.occi.core.Resource;
-import cz.cesnet.cloud.occi.exception.AmbiguousIdentifierException;
-import cz.cesnet.cloud.occi.exception.InvalidAttributeValueException;
-import cz.cesnet.cloud.occi.exception.RenderingException;
-import cz.cesnet.cloud.occi.infrastructure.Compute;
-import cz.cesnet.cloud.occi.parser.MediaType;
-import java.net.URI;
-import java.util.List;
-
-/**
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class AdvancedUsageExample {
-
- public static void main(String[] args) {
- try {
- HTTPAuthentication authentication = new X509Authentication("/path/to/certificate.pem", "password");
- //set custom certificates if needed
- authentication.setCAPath("/path/to/certificate/directory");
- Client client = new HTTPClient(URI.create("https://localhost:1234"), authentication, MediaType.TEXT_PLAIN, false);
-
- //connect client
- client.connect();
-
- //list all resources
- System.out.println("Listing resources...");
- List<URI> list = client.list();
- System.out.println("Locations:");
- for (URI uri : list) {
- System.out.println(uri);
- }
-
- //creating a compute resource
- System.out.println("Creating compute resource...");
-
- Model model = client.getModel();
- EntityBuilder eb = new EntityBuilder(model);
-
- System.out.println("Listing available os template mixins...");
- List<Mixin> mixins = model.findRelatedMixins("os_tpl");
-
- if (mixins.isEmpty()) {
- System.err.println("No os template mixins available. Quiting.");
- return;
- }
-
- Resource compute = eb.getResource("compute");
- Mixin mixin = mixins.get(0);
- System.out.println("Mixin:");
- System.out.println(mixin.toText());
- compute.addMixin(mixins.get(0));
- compute.addAttribute(Compute.ARCHITECTURE_ATTRIBUTE_NAME, "x86");
- compute.addAttribute(Compute.CORES_ATTRIBUTE_NAME, "2");
- compute.addAttribute(Compute.HOSTNAME_ATTRIBUTE_NAME, "jocci-test");
- compute.addAttribute(Compute.MEMORY_ATTRIBUTE_NAME, "2");
-
- URI location = client.create(compute);
- System.out.println("Created compute instance at location: '" + location + "'.");
-
- //describing resource
- List<Entity> entities = client.describe(location);
- System.out.println("Description:");
- System.out.println(entities.get(0).toText());
-
- System.out.println("Waiting for compute to become active...");
- for (int i = 0; i < 5; i++) {
- entities = client.describe(location);
- if (entities.get(0).getValue(Compute.STATE_ATTRIBUTE_NAME).equals("active")) {
- System.out.println("Compute active.");
- break;
- }
- System.out.println(".");
- Thread.sleep(5000);
- }
-
- //triggering actions
- //stopping compute
- System.out.println("Stopping previously created compute...");
- ActionInstance actionInstance = eb.getActionInstance(URI.create("http://schemas.ogf.org/occi/infrastructure/compute/action#stop"));
- boolean status = client.trigger(location, actionInstance);
- if (status) {
- System.out.println("Triggered: OK");
- } else {
- System.out.println("Triggered: FAIL");
- }
-
- //starting compute
- System.out.println("Starting previously created compute...");
- actionInstance = eb.getActionInstance(URI.create("http://schemas.ogf.org/occi/infrastructure/compute/action#start"));
- status = client.trigger(location, actionInstance);
- if (status) {
- System.out.println("Triggered: OK");
- } else {
- System.out.println("Triggered: FAIL");
- }
-
- //deleting resource
- System.out.println("Deleting previously created compute...");
- status = client.delete(location);
- if (status) {
- System.out.println("Deleted: OK");
- } else {
- System.out.println("Deleted: FAIL");
- }
- } catch (CommunicationException | AmbiguousIdentifierException | EntityBuildingException |
- InvalidAttributeValueException | RenderingException | InterruptedException ex) {
- throw new RuntimeException(ex);
- }
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.api.example;
-
-import cz.cesnet.cloud.occi.api.Authentication;
-import cz.cesnet.cloud.occi.api.Client;
-import cz.cesnet.cloud.occi.api.exception.CommunicationException;
-import cz.cesnet.cloud.occi.api.http.HTTPClient;
-import cz.cesnet.cloud.occi.api.http.auth.BasicAuthentication;
-import java.net.URI;
-import java.util.List;
-
-/**
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class BasicAuthenticationExample {
-
- public static void main(String[] args) {
- try {
- Authentication authentication = new BasicAuthentication("username", "password");
- Client client = new HTTPClient(URI.create("http://localhost:1234"), authentication);
-
- List<URI> list = client.list();
- System.out.println("Locations:");
- for (URI uri : list) {
- System.out.println(uri);
- }
- } catch (CommunicationException ex) {
- throw new RuntimeException(ex);
- }
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.api.example;
-
-import cz.cesnet.cloud.occi.api.Authentication;
-import cz.cesnet.cloud.occi.api.Client;
-import cz.cesnet.cloud.occi.api.exception.CommunicationException;
-import cz.cesnet.cloud.occi.api.http.HTTPClient;
-import cz.cesnet.cloud.occi.api.http.auth.DigestAuthentication;
-import java.net.URI;
-import java.util.List;
-
-/**
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class DigestAuthenticationExample {
-
- public static void main(String[] args) {
- try {
- Authentication authentication = new DigestAuthentication("username", "password");
- Client client = new HTTPClient(URI.create("http://localhost:1234"), authentication);
-
- List<URI> list = client.list();
- System.out.println("Locations:");
- for (URI uri : list) {
- System.out.println(uri);
- }
- } catch (CommunicationException ex) {
- throw new RuntimeException(ex);
- }
- }
-
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.api.example;
-
-import cz.cesnet.cloud.occi.api.Client;
-import cz.cesnet.cloud.occi.api.exception.CommunicationException;
-import cz.cesnet.cloud.occi.api.http.HTTPClient;
-import java.net.URI;
-import java.util.List;
-
-/**
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class SimpleUsageExample {
-
- public static void main(String[] args) {
-
- try {
- Client client = new HTTPClient(URI.create("http://localhost:1234"));
- client.connect();
-
- List<URI> list = client.list();
- System.out.println("Locations:");
- for (URI uri : list) {
- System.out.println(uri);
- }
- } catch (CommunicationException ex) {
- throw new RuntimeException(ex);
- }
- }
-
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.api.example;
-
-import cz.cesnet.cloud.occi.api.Client;
-import cz.cesnet.cloud.occi.api.exception.CommunicationException;
-import cz.cesnet.cloud.occi.api.http.HTTPClient;
-import cz.cesnet.cloud.occi.api.http.auth.HTTPAuthentication;
-import cz.cesnet.cloud.occi.api.http.auth.VOMSAuthentication;
-import java.net.URI;
-import java.util.List;
-
-/**
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class VOMSAuthenticationExample {
-
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- try {
- HTTPAuthentication authentication = new VOMSAuthentication("/path/to/certificate.pem");
- //if custom certificates are needed
- authentication.setCAPath("/path/to/certificate/directory");
- Client client = new HTTPClient(URI.create("https://localhost:1234"), authentication);
-
- List<URI> list = client.list();
- System.out.println("Locations:");
- for (URI uri : list) {
- System.out.println(uri);
- }
- } catch (CommunicationException ex) {
- throw new RuntimeException(ex);
- }
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.api.example;
-
-import cz.cesnet.cloud.occi.api.Client;
-import cz.cesnet.cloud.occi.api.exception.CommunicationException;
-import cz.cesnet.cloud.occi.api.http.HTTPClient;
-import cz.cesnet.cloud.occi.api.http.auth.HTTPAuthentication;
-import cz.cesnet.cloud.occi.api.http.auth.X509Authentication;
-import java.net.URI;
-import java.util.List;
-
-/**
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class X509AuthenticationExample {
-
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- try {
- HTTPAuthentication authentication = new X509Authentication("/path/to/certificate.pem", "password");
- //if custom certificates are needed
- authentication.setCAPath("/path/to/certificate/directory");
- Client client = new HTTPClient(URI.create("https://localhost:1234"), authentication);
-
- List<URI> list = client.list();
- System.out.println("Locations:");
- for (URI uri : list) {
- System.out.println(uri);
- }
- } catch (CommunicationException ex) {
- throw new RuntimeException(ex);
- }
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.api.exception;
-
-/**
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class AuthenticationException extends CommunicationException {
-
- public AuthenticationException(String message) {
- super(message);
- }
-
- public AuthenticationException(String message, Throwable ex) {
- super(message, ex);
- }
-
- public AuthenticationException(Throwable ex) {
- super(ex);
- }
-
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.api.exception;
-
-/**
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class CommunicationException extends Exception {
-
- public CommunicationException(String message) {
- super(message);
- }
-
- public CommunicationException(String message, Throwable ex) {
- super(message, ex);
- }
-
- public CommunicationException(Throwable ex) {
- super(ex);
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.api.exception;
-
-/**
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class EntityBuildingException extends Exception {
-
- public EntityBuildingException(String message) {
- super(message);
- }
-
- public EntityBuildingException(String message, Throwable ex) {
- super(message, ex);
- }
-
- public EntityBuildingException(Throwable ex) {
- super(ex);
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.api.http;
-
-import com.sun.net.httpserver.Headers;
-import cz.cesnet.cloud.occi.Collection;
-import cz.cesnet.cloud.occi.Model;
-import cz.cesnet.cloud.occi.api.Authentication;
-import cz.cesnet.cloud.occi.api.Client;
-import cz.cesnet.cloud.occi.api.exception.CommunicationException;
-import cz.cesnet.cloud.occi.api.http.auth.HTTPAuthentication;
-import cz.cesnet.cloud.occi.api.http.auth.NoAuthentication;
-import cz.cesnet.cloud.occi.core.ActionInstance;
-import cz.cesnet.cloud.occi.core.Entity;
-import cz.cesnet.cloud.occi.core.Kind;
-import cz.cesnet.cloud.occi.exception.AmbiguousIdentifierException;
-import cz.cesnet.cloud.occi.exception.ParsingException;
-import cz.cesnet.cloud.occi.exception.RenderingException;
-import cz.cesnet.cloud.occi.parser.CollectionType;
-import cz.cesnet.cloud.occi.parser.MediaType;
-import cz.cesnet.cloud.occi.parser.TextParser;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpMessage;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpDelete;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.util.EntityUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Class representing HTTP OCCI client.
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class HTTPClient extends Client {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(HTTPClient.class);
- private static final String ACTION_URL_PARAMETER = "?action=";
- private final HTTPConnection connection = new HTTPConnection();
- private HttpHost target;
- private String responseMediaType;
- private String responseBody;
- private String mediaType;
- private Headers responseHeaders;
- private final TextParser parser = new TextParser();
-
- /**
- * Constructor.
- *
- * <p>
- * HTTPClient has three constructors via which one can set remote server's
- * endpoint, authentication method, media type for HTTP messages and whether
- * client should automatically connect to the server or not.</p>
- *
- * <p>
- * By default text/plain is used as media type and client is initialized
- * without authentication method. Client automatically connects to the
- * remote server by default when authentication method is set.</p>
- *
- * <p>
- * Examples:</p>
- *
- * <pre>{@code
- * Client client = new HTTPClient(URI.create("https://remote.server.net")); client.connect();}</pre>
- *
- * <pre>{@code
- * Client client = new HTTPClient(URI.create("https://remote.server.net"), new BasicAuthentication("username", "password"), MediaType.TEXT_OCCI, true);}</pre>
- *
- * @param endpoint cannot be null
- * @param authentication authentication method which will be used to
- * authenticate client against the server
- * @param mediaType string representing HTTP media type used in
- * communication
- * @param autoconnect
- * @throws CommunicationException
- */
- public HTTPClient(URI endpoint, Authentication authentication, String mediaType, boolean autoconnect) throws CommunicationException {
- //to avoid SSL handshake unrecognized_name error
- System.setProperty("jsse.enableSNIExtension", "false");
-
- if (endpoint == null) {
- throw new NullPointerException("endpoint cannot be null");
- }
- if (authentication == null) {
- authentication = new NoAuthentication();
- }
-
- setEndpoint(endpoint);
- target = new HttpHost(endpoint.getHost(), endpoint.getPort(), endpoint.getScheme());
- connection.setPrefix(endpoint.getPath());
- setAuthentication(authentication);
-
- setMediaType(mediaType);
-
- if (autoconnect) {
- connect();
- }
- }
-
- /**
- * Constructor.
- *
- * @param endpoint cannot be null
- * @param authentication
- * @throws CommunicationException
- */
- public HTTPClient(URI endpoint, Authentication authentication) throws CommunicationException {
- this(endpoint, authentication, MediaType.TEXT_PLAIN, true);
- }
-
- /**
- * Constructor.
- *
- * @param endpoint cannot be null
- * @throws CommunicationException
- */
- public HTTPClient(URI endpoint) throws CommunicationException {
- this(endpoint, null, MediaType.TEXT_PLAIN, false);
- }
-
- /**
- * Sets media type for the connection.
- *
- * @param mediaType media type
- */
- public void setMediaType(String mediaType) {
- this.mediaType = mediaType;
- connection.setMediaType(mediaType);
- }
-
- /**
- * Returns media type of the connection.
- *
- * @return media type
- */
- public String getMediaType() {
- return this.mediaType;
- }
-
- /**
- * @see Client#connect()
- */
- @Override
- public void connect() throws CommunicationException {
- Authentication auth = getAuthentication();
- if (!(auth instanceof HTTPAuthentication)) {
- throw new CommunicationException("authentication method '" + auth + "' is not a valid HTTP authentication method");
- }
-
- HTTPAuthentication httpAuth = (HTTPAuthentication) auth;
- httpAuth.setTarget(target);
- httpAuth.setConnection(connection);
- httpAuth.authenticate();
-
- setConnected(true);
- obtainModel();
- }
-
- private void checkConnection() throws CommunicationException {
- if (!isConnected()) {
- connect();
- }
- }
-
- private Headers convertHeaders(Header[] apacheHeaders) {
- Headers javaHeaders = new Headers();
- for (Header header : apacheHeaders) {
- javaHeaders.add(header.getName().toLowerCase(), header.getValue());
- }
-
- return javaHeaders;
- }
-
- private void runAndParseRequest(HttpRequest request, int[] statuses) throws CommunicationException {
- try {
- try (CloseableHttpResponse response = HTTPHelper.runRequest(request, target, connection.getClient(), connection.getContext(), statuses)) {
- responseMediaType = response.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue();
- if (responseMediaType.contains(";")) {
- responseMediaType = responseMediaType.substring(0, responseMediaType.indexOf(";"));
- }
- responseHeaders = convertHeaders(response.getAllHeaders());
- HttpEntity responseEntity = response.getEntity();
- if (responseEntity == null) {
- responseBody = "";
- } else {
- responseBody = EntityUtils.toString(responseEntity);
- }
- }
- } catch (IOException ex) {
- throw new CommunicationException(ex);
- }
- }
-
- private void runAndParseRequest(HttpRequest request) throws CommunicationException {
- runAndParseRequest(request, new int[]{HttpStatus.SC_OK, HttpStatus.SC_NO_CONTENT});
- }
-
- private void obtainModel() throws CommunicationException {
- try {
- LOGGER.debug("Obtaining model...");
- checkConnection();
- HttpGet httpGet = HTTPHelper.prepareGet(Client.MODEL_URI, connection.getHeaders(), connection.getPrefix());
- runAndParseRequest(httpGet);
- setModel(parser.parseModel(responseMediaType, responseBody, responseHeaders));
- LOGGER.debug("Model: {}", getModel());
- } catch (ParsingException ex) {
- throw new CommunicationException(ex);
- }
- }
-
- /**
- * @see Client#list()
- */
- @Override
- public List<URI> list() throws CommunicationException {
- return list("");
- }
-
- /**
- * @see Client#list(java.lang.String)
- */
- @Override
- public List<URI> list(String resourceType) throws CommunicationException {
- HttpGet httpGet;
- if (resourceType.isEmpty()) {
- httpGet = HTTPHelper.prepareGet("/", connection.getHeaders(), connection.getPrefix());
- } else {
- Kind kind;
- try {
- checkConnection();
- kind = getModel().findKind(resourceType);
- } catch (AmbiguousIdentifierException ex) {
- throw new CommunicationException(ex);
- }
- if (kind == null) {
- throw new CommunicationException("unknown resource type '" + resourceType + "'");
- }
- httpGet = HTTPHelper.prepareGet(kind.getLocation(), connection.getHeaders(), connection.getPrefix());
- }
-
- return runListGet(httpGet);
- }
-
- /**
- * @see Client#list(java.net.URI)
- */
- @Override
- public List<URI> list(URI resourceIdentifier) throws CommunicationException {
- checkConnection();
- Kind kind = getModel().findKind(resourceIdentifier);
- if (kind == null) {
- throw new CommunicationException("unknown resource identifier '" + resourceIdentifier + "'");
- }
- HttpGet httpGet = HTTPHelper.prepareGet(kind.getLocation(), connection.getHeaders(), connection.getPrefix());
- return runListGet(httpGet);
- }
-
- private List<URI> runListGet(HttpGet httpGet) throws CommunicationException {
- try {
- checkConnection();
- runAndParseRequest(httpGet);
- List<URI> locations = parser.parseLocations(responseMediaType, responseBody, responseHeaders);
- LOGGER.debug("Locations: {}", locations);
- return locations;
- } catch (ParsingException ex) {
- throw new CommunicationException(ex);
- }
- }
-
- /**
- * @see Client#describe()
- */
- @Override
- public List<Entity> describe() throws CommunicationException {
- List<URI> locations = list();
- Collection collection = new Collection();
- for (URI location : locations) {
- collection.merge(describeLocation(location));
- }
-
- return generateEntityListFromCollection(collection);
- }
-
- /**
- * @see Client#describe(java.lang.String)
- */
- @Override
- public List<Entity> describe(String resourceType) throws CommunicationException {
- checkConnection();
- Model model = getModel();
- try {
- Kind kind = model.findKind(resourceType);
- if (kind == null) {
- throw new CommunicationException("unknown resource type '" + resourceType + "'");
- }
- CollectionType type = model.findKindType(kind);
- if (type == null) {
- throw new CommunicationException("unknown resource type '" + resourceType + "'");
- }
-
- return describe(list(resourceType), type);
- } catch (AmbiguousIdentifierException ex) {
- throw new CommunicationException(ex);
- }
- }
-
- /**
- * @see Client#describe(java.net.URI)
- */
- @Override
- public List<Entity> describe(URI resourceIdentifier) throws CommunicationException {
- checkConnection();
- Model model = getModel();
- Kind kind = model.findKind(resourceIdentifier);
- if (kind != null) {
- CollectionType type = model.findKindType(kind);
- if (type == null) {
- throw new CommunicationException("unknown resource identifier '" + resourceIdentifier + "'");
- }
-
- return describe(list(resourceIdentifier), type);
- } else {
- Collection collection = describeLocation(resourceIdentifier);
-
- return generateEntityListFromCollection(collection);
- }
- }
-
- private Collection describeLocation(URI location) throws CommunicationException {
- location = getFullUri(location);
- String path = location.getPath();
- String[] segments = TextParser.divideUriByLastSegment(path);
- CollectionType type = getModel().findKindType(segments[1]);
- if (type == null) {
- throw new CommunicationException("unknown resource identifier '" + location + "'");
- }
-
- HttpGet httpGet = HTTPHelper.prepareGet(location, connection.getHeaders(), connection.getPrefix());
- return runDescribeGet(httpGet, type);
- }
-
- private List<Entity> describe(List<URI> locations, CollectionType type) throws CommunicationException {
- Collection collection = new Collection();
- for (URI location : locations) {
- HttpGet httpGet = HTTPHelper.prepareGet(location, connection.getHeaders(), connection.getPrefix());
- collection.merge(runDescribeGet(httpGet, type));
- }
-
- return generateEntityListFromCollection(collection);
- }
-
- private List<Entity> generateEntityListFromCollection(Collection collection) {
- List<Entity> list = new ArrayList();
- list.addAll(collection.getLinks());
- list.addAll(collection.getResources());
-
- return list;
- }
-
- private Collection runDescribeGet(HttpGet httpGet, CollectionType type) throws CommunicationException {
- try {
- checkConnection();
- runAndParseRequest(httpGet);
- Collection collection = parser.parseCollection(responseMediaType, responseBody, responseHeaders, type);
- LOGGER.debug("Collection: {}", collection);
- return collection;
- } catch (ParsingException ex) {
- throw new CommunicationException(ex);
- }
- }
-
- /**
- * @see Client#create(cz.cesnet.cloud.occi.core.Entity)
- */
- @Override
- public URI create(Entity entity) throws CommunicationException {
- Kind kind = entity.getKind();
- if (kind == null) {
- throw new CommunicationException("entity with empty kind");
- }
-
- HttpPost httpPost = HTTPHelper.preparePost(kind.getLocation(), connection.getHeaders(), connection.getPrefix());
- try {
- switch (mediaType) {
- case MediaType.TEXT_OCCI: {
- Headers headers = entity.toHeaders();
- addHeaders(httpPost, headers);
- }
- break;
- case MediaType.TEXT_PLAIN: {
- HttpEntity httpEntity = new StringEntity(entity.toText());
- httpPost.setEntity(httpEntity);
- }
- break;
- default:
- throw new CommunicationException("unsupported media type '" + mediaType + "'");
- }
-
- checkConnection();
- runAndParseRequest(httpPost, new int[]{HttpStatus.SC_CREATED, HttpStatus.SC_OK});
-
- //HACK
- //so communication with servers with WRONG OCCI implementation will work
- if (!responseMediaType.equals(MediaType.TEXT_OCCI) && responseBody.trim().equals("OK") && responseHeaders.containsKey("Location")) {
- responseMediaType = MediaType.TEXT_OCCI;
- }
- //HACK
-
- List<URI> locations = parser.parseLocations(responseMediaType, responseBody, responseHeaders);
- if (locations == null || locations.isEmpty()) {
- throw new CommunicationException("no location returned");
- }
-
- return locations.get(0);
- } catch (RenderingException | ParsingException | UnsupportedEncodingException ex) {
- throw new CommunicationException(ex);
- }
- }
-
- /**
- * @see Client#update(cz.cesnet.cloud.occi.core.Entity)
- */
- @Override
- public URI update(Entity entity) throws CommunicationException {
- Kind kind = entity.getKind();
- if (kind == null) {
- throw new CommunicationException("entity with empty kind");
- }
-
- HttpPut httpPut = HTTPHelper.preparePut(kind.getLocation() + entity.getId(), connection.getHeaders(), connection.getPrefix());
- try {
- switch (mediaType) {
- case MediaType.TEXT_OCCI: {
- Headers headers = entity.toHeaders();
- addHeaders(httpPut, headers);
- }
- break;
- case MediaType.TEXT_PLAIN: {
- HttpEntity httpEntity = new StringEntity(entity.toText());
- httpPut.setEntity(httpEntity);
- }
- break;
- default:
- throw new CommunicationException("unsupported media type '" + mediaType + "'");
- }
-
- checkConnection();
- runAndParseRequest(httpPut, new int[]{HttpStatus.SC_CREATED, HttpStatus.SC_OK});
-
- //HACK
- //so communication with servers with WRONG OCCI implementation will work
- if (!responseMediaType.equals(MediaType.TEXT_OCCI) && responseBody.trim().equals("OK") && responseHeaders.containsKey("Location")) {
- responseMediaType = MediaType.TEXT_OCCI;
- }
- //HACK
-
- List<URI> locations = parser.parseLocations(responseMediaType, responseBody, responseHeaders);
- if (locations == null || locations.isEmpty()) {
- throw new CommunicationException("no location returned");
- }
-
- return locations.get(0);
- } catch (RenderingException | ParsingException | UnsupportedEncodingException ex) {
- throw new CommunicationException(ex);
- }
- }
-
- /**
- * @see Client#delete(java.lang.String)
- */
- @Override
- public boolean delete(String resourceType) throws CommunicationException {
- Kind kind;
- try {
- checkConnection();
- kind = getModel().findKind(resourceType);
- } catch (AmbiguousIdentifierException ex) {
- throw new CommunicationException(ex);
- }
- if (kind == null) {
- throw new CommunicationException("unknown resource type '" + resourceType + "'");
- }
- HttpDelete httpDelete = HTTPHelper.prepareDelete(kind.getLocation(), connection.getHeaders(), connection.getPrefix());
-
- checkConnection();
- return HTTPHelper.runRequestForStatus(httpDelete, target, connection.getClient(), connection.getContext());
- }
-
- /**
- * @see Client#delete(java.net.URI)
- */
- @Override
- public boolean delete(URI resourceIdentifier) throws CommunicationException {
- checkConnection();
- Kind kind = getModel().findKind(resourceIdentifier);
- HttpDelete httpDelete;
- if (kind != null) {
- httpDelete = HTTPHelper.prepareDelete(kind.getLocation(), connection.getHeaders(), connection.getPrefix());
- } else {
- resourceIdentifier = getFullUri(resourceIdentifier);
- httpDelete = HTTPHelper.prepareDelete(resourceIdentifier, connection.getHeaders(), connection.getPrefix());
- }
-
- checkConnection();
- return HTTPHelper.runRequestForStatus(httpDelete, target, connection.getClient(), connection.getContext());
- }
-
- /**
- * @see Client#trigger(java.lang.String,
- * cz.cesnet.cloud.occi.core.ActionInstance)
- */
- @Override
- public boolean trigger(String resourceType, ActionInstance action) throws CommunicationException {
- Kind kind;
- try {
- checkConnection();
- kind = getModel().findKind(resourceType);
- } catch (AmbiguousIdentifierException ex) {
- throw new CommunicationException(ex);
- }
- if (kind == null) {
- throw new CommunicationException("unknown resource type '" + resourceType + "'");
- }
-
- try {
- String url = kind.getLocation().toString() + ACTION_URL_PARAMETER + action.getAction().getTerm();
- HttpPost httpPost = HTTPHelper.preparePost(url, connection.getHeaders(), connection.getPrefix());
- switch (mediaType) {
- case MediaType.TEXT_OCCI: {
- Headers headers = action.toHeaders();
- addHeaders(httpPost, headers);
- }
- break;
- case MediaType.TEXT_PLAIN: {
- HttpEntity httpEntity = new StringEntity(action.toText());
- httpPost.setEntity(httpEntity);
- }
- break;
- default:
- throw new CommunicationException("unsupported media type '" + mediaType + "'");
- }
-
- checkConnection();
- return HTTPHelper.runRequestForStatus(httpPost, target, connection.getClient(), connection.getContext());
- } catch (UnsupportedEncodingException ex) {
- throw new CommunicationException(ex);
- }
- }
-
- /**
- * @see Client#trigger(java.net.URI,
- * cz.cesnet.cloud.occi.core.ActionInstance)
- */
- @Override
- public boolean trigger(URI resourceIdentifier, ActionInstance action) throws CommunicationException {
- checkConnection();
- Kind kind = getModel().findKind(resourceIdentifier);
- String url;
- if (kind != null) {
- url = kind.getLocation().toString() + ACTION_URL_PARAMETER + action.getAction().getTerm();
- } else {
- resourceIdentifier = getFullUri(resourceIdentifier);
- url = resourceIdentifier.toString() + ACTION_URL_PARAMETER + action.getAction().getTerm();
- }
-
- HttpPost httpPost = HTTPHelper.preparePost(url, connection.getHeaders(), connection.getPrefix());
- try {
- switch (mediaType) {
- case MediaType.TEXT_OCCI: {
- Headers headers = action.toHeaders();
- addHeaders(httpPost, headers);
- }
- break;
- case MediaType.TEXT_PLAIN: {
- HttpEntity httpEntity = new StringEntity(action.toText());
- httpPost.setEntity(httpEntity);
- }
- break;
- default:
- throw new CommunicationException("unsupported media type '" + mediaType + "'");
- }
-
- checkConnection();
- return HTTPHelper.runRequestForStatus(httpPost, target, connection.getClient(), connection.getContext());
- } catch (UnsupportedEncodingException ex) {
- throw new CommunicationException(ex);
- }
- }
-
- private URI getFullUri(URI uri) throws CommunicationException {
- if (uri.getHost() == null) {
- try {
- uri = new URI(getEndpoint().toString() + uri.toString()).normalize();
- } catch (URISyntaxException ex) {
- throw new CommunicationException(ex);
- }
- }
-
- return uri;
- }
-
- private void addHeaders(HttpMessage message, Headers headers) {
- for (String headerName : headers.keySet()) {
- for (String value : headers.get(headerName)) {
- message.addHeader(headerName, value);
- }
- }
- }
-
- /**
- * @see Client#refresh()
- */
- @Override
- public void refresh() throws CommunicationException {
- obtainModel();
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.api.http;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.http.Header;
-import org.apache.http.HttpHeaders;
-import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.protocol.HttpContext;
-
-/**
- * Class containing context of HTTP connections.
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class HTTPConnection {
-
- private CloseableHttpClient client = null;
- private HttpContext context = HttpClientContext.create();
- private List<Header> headers = new ArrayList<>();
- private String prefix = "";
-
- public CloseableHttpClient getClient() {
- return client;
- }
-
- public void setClient(CloseableHttpClient client) {
- this.client = client;
- }
-
- public HttpContext getContext() {
- return context;
- }
-
- public void setContext(HttpContext context) {
- this.context = context;
- }
-
- public String getPrefix() {
- return prefix;
- }
-
- public void setPrefix(String prefix) {
- this.prefix = prefix;
- if (prefix == null) {
- this.prefix = "";
- }
- }
-
- public Header[] getHeaders() {
- return headers.toArray(new Header[0]);
- }
-
- /**
- * Adds header that will be used in HTTP requests. If connection already
- * have the header set, its value will be replaced.
- *
- * @param header
- */
- public void addHeader(Header header) {
- for (Header h : headers) {
- if (h.getName().equals(header.getName())) {
- headers.remove(h);
- }
- }
-
- headers.add(header);
- }
-
- /**
- * Removes all headers from connection.
- */
- public void clearHeaders() {
- headers = new ArrayList<>();
- }
-
- /**
- * Sets headers 'Content-type' and 'Accept' to given media type.
- *
- * @param mediaType media type
- */
- public void setMediaType(String mediaType) {
- addHeader(new BasicHeader(HttpHeaders.CONTENT_TYPE, mediaType));
- addHeader(new BasicHeader(HttpHeaders.ACCEPT, mediaType));
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.api.http;
-
-import cz.cesnet.cloud.occi.api.exception.CommunicationException;
-import java.io.IOException;
-import java.net.URI;
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpDelete;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpHead;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.EntityUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Class that helps with HTTP requests.
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class HTTPHelper {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(HTTPHelper.class);
-
- public static HttpGet prepareGet(String uri, Header[] headers, String prefix) {
- HttpGet httpGet = new HttpGet(addPrefix(uri, prefix));
- httpGet.setHeaders(headers);
- return httpGet;
- }
-
- public static HttpGet prepareGet(String uri) {
- return prepareGet(uri, null, "");
- }
-
- public static HttpHead prepareHead(String uri, Header[] headers, String prefix) {
- HttpHead httpHead = new HttpHead(addPrefix(uri, prefix));
- httpHead.setHeaders(headers);
- return httpHead;
- }
-
- public static HttpHead prepareHead(String uri) {
- return prepareHead(uri, null, "");
- }
-
- public static HttpGet prepareGet(URI uri, Header[] headers, String prefix) {
- HttpGet httpGet = new HttpGet(addPrefix(uri.toString(), prefix));
- httpGet.setHeaders(headers);
- return httpGet;
- }
-
- public static HttpGet prepareGet(URI uri) {
- return prepareGet(uri, null, "");
- }
-
- public static HttpHead prepareHead(URI uri, Header[] headers, String prefix) {
- HttpHead httpHead = new HttpHead(addPrefix(uri.toString(), prefix));
- httpHead.setHeaders(headers);
- return httpHead;
- }
-
- public static HttpHead prepareHead(URI uri) {
- return prepareHead(uri, null, "");
- }
-
- public static HttpDelete prepareDelete(String uri, Header[] headers, String prefix) {
- HttpDelete httpDelete = new HttpDelete(addPrefix(uri, prefix));
- httpDelete.setHeaders(headers);
- return httpDelete;
- }
-
- public static HttpDelete prepareDelete(String uri) {
- return prepareDelete(uri, null, "");
- }
-
- public static HttpDelete prepareDelete(URI uri, Header[] headers, String prefix) {
- HttpDelete httpDelete = new HttpDelete(addPrefix(uri.toString(), prefix));
- httpDelete.setHeaders(headers);
- return httpDelete;
- }
-
- public static HttpDelete prepareDelete(URI uri) {
- return prepareDelete(uri, null, "");
- }
-
- public static HttpPost preparePost(String uri, Header[] headers, String prefix) {
- HttpPost httpPost = new HttpPost(addPrefix(uri, prefix));
- httpPost.setHeaders(headers);
- return httpPost;
- }
-
- public static HttpPost preparePost(String uri) {
- return preparePost(uri, null, "");
- }
-
- public static HttpPost preparePost(URI uri, Header[] headers, String prefix) {
- HttpPost httpPost = new HttpPost(addPrefix(uri.toString(), prefix));
- httpPost.setHeaders(headers);
- return httpPost;
- }
-
- public static HttpPost preparePost(URI uri) {
- return preparePost(uri, null, "");
- }
-
- public static HttpPut preparePut(String uri, Header[] headers, String prefix) {
- HttpPut httpPut = new HttpPut(addPrefix(uri, prefix));
- httpPut.setHeaders(headers);
- return httpPut;
- }
-
- public static HttpPut preparePut(String uri) {
- return preparePut(uri, null, "");
- }
-
- public static HttpPut preparePut(URI uri, Header[] headers, String prefix) {
- HttpPut httpPut = new HttpPut(addPrefix(uri.toString(), prefix));
- httpPut.setHeaders(headers);
- return httpPut;
- }
-
- public static HttpPut preparePut(URI uri) {
- return preparePut(uri, null, "");
- }
-
- public static CloseableHttpResponse runRequest(HttpRequest httpRequest, HttpHost target, CloseableHttpClient client, HttpContext context, int[] statuses
- ) throws CommunicationException {
- try {
- CloseableHttpResponse response = client.execute(target, httpRequest, context);
- boolean acceptableStatus = false;
- for (int status : statuses) {
- if (response.getStatusLine().getStatusCode() == status) {
- acceptableStatus = true;
- }
- }
- if (!acceptableStatus) {
- HttpEntity entity = response.getEntity();
- String body = "";
- if (entity != null) {
- body = EntityUtils.toString(entity);
- }
- LOGGER.debug("Response: {}\nHeaders: {}\nBody: {}", response.getStatusLine().toString(), response.getAllHeaders(), body);
- throw new CommunicationException(response.getStatusLine().toString() + "\n" + body);
- }
-
- return response;
- } catch (IOException ex) {
- throw new CommunicationException(ex);
- }
- }
-
- public static CloseableHttpResponse runRequest(HttpRequest httpRequest, HttpHost target, CloseableHttpClient client, HttpContext context) throws CommunicationException {
- return runRequest(httpRequest, target, client, context, new int[]{HttpStatus.SC_OK});
- }
-
- public static boolean runRequestForStatus(HttpRequest httpRequest, HttpHost target, CloseableHttpClient client, HttpContext context, int[] statuses
- ) throws CommunicationException {
- try {
- try (CloseableHttpResponse response = client.execute(target, httpRequest, context)) {
- boolean acceptableStatus = false;
- for (int status : statuses) {
- if (response.getStatusLine().getStatusCode() == status) {
- acceptableStatus = true;
- }
- }
- return acceptableStatus;
- }
- } catch (IOException ex) {
- throw new CommunicationException(ex);
- }
- }
-
- public static boolean runRequestForStatus(HttpRequest httpRequest, HttpHost target, CloseableHttpClient client, HttpContext context) throws CommunicationException {
- return runRequestForStatus(httpRequest, target, client, context, new int[]{HttpStatus.SC_OK, HttpStatus.SC_NO_CONTENT});
- }
-
- private static String addPrefix(String uri, String prefix) {
- if (uri.contains(prefix)) {
- return uri;
- } else {
- return prefix + uri;
- }
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.api.http.auth;
-
-import cz.cesnet.cloud.occi.api.Authentication;
-import cz.cesnet.cloud.occi.api.exception.CommunicationException;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.config.AuthSchemes;
-import org.apache.http.impl.client.BasicCredentialsProvider;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Class representing BASIC HTTP authentication method.
- *
- * <p>
- * This method has a Keystone authentication method as fallback.</p>
- *
- * <p>
- * Example:</p>
- *
- * <pre>{@code
- * HTTPAuthentication auth = new BasicAuthentication("username", "password");
- *auth.setCAPath("/etc/grid-security/certificates/"); //path to CA directory
- *Client client = new HTTPClient(URI.create("https://remote.server.net"), auth);}</pre>
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class BasicAuthentication extends HTTPAuthentication {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(BasicAuthentication.class);
- public static final String IDENTIFIER = "OCCIBasicAuthentication";
- private String username;
- private String password;
- private String authScheme;
-
- public BasicAuthentication(String username, String password) {
- this.username = username;
- this.password = password;
- this.authScheme = AuthSchemes.BASIC;
- }
-
- protected void setAuthScheme(String authScheme) {
- this.authScheme = authScheme;
- }
-
- /**
- * Returns username.
- *
- * @return username
- */
- public String getUsername() {
- return username;
- }
-
- /**
- * Sets username.
- *
- * @param username username
- */
- public void setUsername(String username) {
- this.username = username;
- }
-
- /**
- * Returns password.
- *
- * @return password
- */
- public String getPassword() {
- return password;
- }
-
- /**
- * Sets password
- *
- * @param password password
- */
- public void setPassword(String password) {
- this.password = password;
- }
-
- @Override
- public String getIdentifier() {
- return IDENTIFIER;
- }
-
- @Override
- public Authentication getFallback() {
- return new KeystoneAuthentication(this);
- }
-
- @Override
- public void authenticate() throws CommunicationException {
- LOGGER.debug("Creating credentials provider with username: '{}' and password: '{}'", username, password);
- CredentialsProvider credsProvider = new BasicCredentialsProvider();
- credsProvider.setCredentials(
- new AuthScope(getTarget().getHostName(), getTarget().getPort(), null, authScheme),
- new UsernamePasswordCredentials(username, password));
- setCredentialsProvider(credsProvider);
- super.authenticate();
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.api.http.auth;
-
-import cz.cesnet.cloud.occi.api.Authentication;
-import cz.cesnet.cloud.occi.api.exception.AuthenticationException;
-import cz.cesnet.cloud.occi.api.exception.CommunicationException;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.security.KeyManagementException;
-import java.security.KeyPair;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.PrivateKey;
-import java.security.Security;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import javax.net.ssl.SSLContext;
-import org.apache.http.conn.ssl.SSLContexts;
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.bouncycastle.openssl.PEMReader;
-import org.bouncycastle.openssl.PasswordFinder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Class representing HTTP authentication method via X509 or VOMS certificates.
- *
- * <p>
- * Supports certificates in pk12 or pem format. This method has a Keystone
- * authentication method as fallback.</p>
- *
- * <p>
- * Example:</p>
- *
- * <pre>{@code
- * HTTPAuthentication auth = new CertificateAuthentication("/path/to/certificate.pem", "password");
- * auth.setCAPath("/etc/grid-security/certificates/"); //path to CA directory
- * Client client = new HTTPClient(URI.create("https://remote.server.net"), auth);}</pre>
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-abstract public class CertificateAuthentication extends HTTPAuthentication {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(CertificateAuthentication.class);
- private static final String CERT_BEGIN = "-----BEGIN CERTIFICATE-----";
- private static final String CERT_END = "-----END CERTIFICATE-----";
- private static final String GROUP_WHOLE = "whole";
- private static final String GROUP_TYPE = "type";
- private String certificate;
- private String password;
-
- /**
- * Returns user's certificate.
- *
- * @return user's certificate
- */
- public String getCertificate() {
- return certificate;
- }
-
- /**
- * Sets user's certificate.
- *
- * @param certificate user's certificate, cannot be null nor empty
- */
- public void setCertificate(String certificate) {
- if (certificate == null) {
- throw new NullPointerException("certificate cannot be null");
- }
- if (certificate.isEmpty()) {
- throw new IllegalArgumentException("certificate cannot be empty");
- }
-
- this.certificate = certificate;
- }
-
- /**
- * Returns user's password.
- *
- * @return user's password
- */
- public String getPassword() {
- return password;
- }
-
- /**
- * Sets user's password.
- *
- * @param password user's password, cannot be null
- */
- public void setPassword(String password) {
- if (password == null) {
- throw new NullPointerException("password cannot be null");
- }
-
- this.password = password;
- }
-
- @Override
- protected SSLContext createSSLContext() throws AuthenticationException {
- Security.addProvider(new BouncyCastleProvider());
- KeyStore trustStore = loadCAs();
-
- try {
- KeyStore keyStore;
- if (certificate.endsWith(".p12")) {
- keyStore = loadUserCertificateFromPK12();
- } else {
- keyStore = loadUserCertificateFromPEM();
- }
-
- SSLContext sslContext = SSLContexts.custom()
- .loadTrustMaterial(trustStore)
- .loadKeyMaterial(keyStore, password.toCharArray())
- .build();
-
- return sslContext;
- } catch (KeyStoreException | KeyManagementException | NoSuchAlgorithmException | UnrecoverableKeyException ex) {
- throw new AuthenticationException(ex);
- }
-
- }
-
- private KeyStore loadUserCertificateFromPK12() throws AuthenticationException {
- try {
- KeyStore keyStore = KeyStore.getInstance("PKCS12");
- FileInputStream instream = new FileInputStream(new File(certificate));
- keyStore.load(instream, password.toCharArray());
-
- return keyStore;
- } catch (KeyStoreException | IOException | NoSuchAlgorithmException | CertificateException ex) {
- throw new AuthenticationException(ex);
- }
- }
-
- private KeyStore loadUserCertificateFromPEM() throws AuthenticationException {
- try {
- String certFileString = new String(Files.readAllBytes(Paths.get(certificate)));
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- List<X509Certificate> certChain = new ArrayList<>();
- int startIndex = certFileString.indexOf(CERT_BEGIN, 0);
- int endIndex;
-
- PEMReader reader;
- while (startIndex != -1) {
- endIndex = certFileString.indexOf(CERT_END, startIndex);
- String oneCert = certFileString.substring(startIndex, endIndex + CERT_END.length());
- reader = new PEMReader(new InputStreamReader(new ByteArrayInputStream(oneCert.getBytes())), new PasswordFinder() {
- @Override
- public char[] getPassword() {
- return password == null ? null : password.toCharArray();
- }
- });
- X509Certificate cert = (X509Certificate) reader.readObject();
- if (cert == null) {
- throw new AuthenticationException("cannot load user certificate");
- }
- certChain.add(cert);
-
- startIndex = certFileString.indexOf(CERT_BEGIN, startIndex + 1);
- }
-
- Pattern pattern = Pattern.compile("(?<" + GROUP_WHOLE + ">-----BEGIN (?<" + GROUP_TYPE + ">RSA |DSA |EC |DH )*PRIVATE KEY-----)");
- Matcher matcher = pattern.matcher(certFileString);
- if (!matcher.find()) {
- throw new AuthenticationException("cannot read certificate key");
- }
- //cannot use GROUP_WHOLE descriptor because of Java 7 compatibility
- startIndex = matcher.start(1);
-
- pattern = Pattern.compile("(?<" + GROUP_WHOLE + ">-----END (?<" + GROUP_TYPE + ">RSA |DSA |EC |DH )*PRIVATE KEY-----)");
- matcher = pattern.matcher(certFileString);
- if (!matcher.find(startIndex)) {
- throw new AuthenticationException("cannot read certificate key");
- }
- //cannot use GROUP_WHOLE descriptor because of Java 7 compatibility
- endIndex = matcher.end(1);
-
- String key = certFileString.substring(startIndex, endIndex).trim();
- reader = new PEMReader(new InputStreamReader(new ByteArrayInputStream(key.getBytes())), new PasswordFinder() {
- @Override
- public char[] getPassword() {
- return password == null ? null : password.toCharArray();
- }
- });
-
- Object object = reader.readObject();
- PrivateKey pk = null;
- if (object instanceof PrivateKey) {
- pk = (PrivateKey) object;
- }
- if (object instanceof KeyPair) {
- pk = ((KeyPair) object).getPrivate();
- }
-
- if (pk == null) {
- throw new AuthenticationException("cannot load private key");
- }
-
- KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
- ks.load(null);
- for (X509Certificate x509Cert : certChain) {
- ks.setCertificateEntry(x509Cert.getSubjectX500Principal().getName(), x509Cert);
- LOGGER.debug("adding certificate: " + x509Cert.getSubjectX500Principal().getName());
- }
-
- ks.setKeyEntry("private_key", pk, password.toCharArray(), certChain.toArray(new Certificate[0]));
- return ks;
- } catch (IOException | CertificateException | NoSuchAlgorithmException | KeyStoreException ex) {
- throw new AuthenticationException(ex);
- }
- }
-
- @Override
- public void authenticate() throws CommunicationException {
- super.authenticate();
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.api.http.auth;
-
-import org.apache.http.client.config.AuthSchemes;
-
-/**
- * Class representing Digest HTTP authentication method.
- *
- * <p>
- * This method has a Keystone authentication method as fallback.</p>
- *
- * <p>
- * Example:</p>
- *
- * <pre>{@code
- * HTTPAuthentication auth = new DigestAuthentication("username", "password");
- *auth.setCAPath("/etc/grid-security/certificates/"); //path to CA directory
- *Client client = new HTTPClient(URI.create("https://remote.server.net"), auth);}</pre>
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class DigestAuthentication extends BasicAuthentication {
-
- public static final String IDENTIFIER = "OCCIDigestAuthentication";
-
- public DigestAuthentication(String username, String password) {
- super(username, password);
- setAuthScheme(AuthSchemes.DIGEST);
- }
-
- @Override
- public String getIdentifier() {
- return IDENTIFIER;
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.api.http.auth;
-
-import cz.cesnet.cloud.occi.api.Authentication;
-import cz.cesnet.cloud.occi.api.Client;
-import cz.cesnet.cloud.occi.api.exception.AuthenticationException;
-import cz.cesnet.cloud.occi.api.exception.CommunicationException;
-import cz.cesnet.cloud.occi.api.http.HTTPConnection;
-import cz.cesnet.cloud.occi.api.http.HTTPHelper;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.security.KeyManagementException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.Security;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-import java.util.List;
-import javax.net.ssl.SSLContext;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpHead;
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.conn.ssl.SSLContexts;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.params.HttpConnectionParams;
-import org.apache.http.util.EntityUtils;
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.bouncycastle.openssl.PEMReader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Abstract class representing HTTP authentication methods. Lets set either
- * directory path or file containing CAs and uses them during establishing of
- * connection.
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public abstract class HTTPAuthentication implements Authentication {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(HTTPAuthentication.class);
- private HttpHost target;
- private HTTPConnection connection;
- private CredentialsProvider credentialsProvider;
- private String CAPath;
- private String CAFile;
-
- /**
- * Returns server that authentication is run against.
- *
- * @return
- */
- public HttpHost getTarget() {
- return target;
- }
-
- /**
- * Sets server to run authentication against.
- *
- * @param target server
- */
- public void setTarget(HttpHost target) {
- this.target = target;
- }
-
- public HTTPConnection getConnection() {
- return connection;
- }
-
- public void setConnection(HTTPConnection connection) {
- this.connection = connection;
- }
-
- public CredentialsProvider getCredentialsProvider() {
- return credentialsProvider;
- }
-
- public void setCredentialsProvider(CredentialsProvider credentialsProvider) {
- this.credentialsProvider = credentialsProvider;
- }
-
- /**
- * Returns path to the custom CA directory.
- *
- * @return path to the custom CA directory
- */
- public String getCAPath() {
- return CAPath;
- }
-
- /**
- * Sets path to custom CA directory.
- *
- * @param CAPath path to custom CA directory
- */
- public void setCAPath(String CAPath) {
- this.CAPath = CAPath;
- }
-
- /**
- * Returns path to custom CA file.
- *
- * @return path to custom CA file
- */
- public String getCAFile() {
- return CAFile;
- }
-
- /**
- * Sets path to custom CA file
- *
- * @param CAFile path to custom CA file
- */
- public void setCAFile(String CAFile) {
- this.CAFile = CAFile;
- }
-
- @Override
- public abstract String getIdentifier();
-
- @Override
- public abstract Authentication getFallback();
-
- /**
- * Creates a ssl context with custom CAs if set.
- *
- * @return ssl context
- * @throws AuthenticationException
- */
- protected SSLContext createSSLContext() throws AuthenticationException {
- Security.addProvider(new BouncyCastleProvider());
- KeyStore keyStore = loadCAs();
-
- try {
- SSLContext sslContext;
- if (keyStore == null) {
- sslContext = SSLContexts.createSystemDefault();
- } else {
- sslContext = SSLContexts.custom().loadTrustMaterial(keyStore).build();
- }
- return sslContext;
- } catch (NoSuchAlgorithmException | KeyStoreException | KeyManagementException ex) {
- throw new AuthenticationException(ex);
- }
- }
-
- @Override
- public void authenticate() throws CommunicationException {
- SSLContext sslContext = createSSLContext();
- SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext);
-
- LOGGER.debug("Running authentication...");
- try {
-
- RequestConfig defaultRequestConfig = RequestConfig.custom()
- .setSocketTimeout(10000)
- .setConnectTimeout(10000)
- .setConnectionRequestTimeout(10000)
- .build();
-
- HttpClientBuilder builder = HttpClients.custom()
- .setDefaultCredentialsProvider(credentialsProvider)
- .setSSLSocketFactory(sslsf)
- .setDefaultRequestConfig(defaultRequestConfig);
- if (LOGGER.isDebugEnabled()) {
- builder.disableContentCompression();
- }
-
- CloseableHttpClient client = builder.build();
- connection.setClient(client);
- HttpHead httpHead = HTTPHelper.prepareHead(Client.MODEL_URI, connection.getHeaders(), connection.getPrefix());
- try (CloseableHttpResponse response = connection.getClient().execute(target, httpHead, connection.getContext())) {
- if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
- Authentication fallback = getFallback();
- if (response.getStatusLine().getStatusCode() == HttpStatus.SC_UNAUTHORIZED && fallback != null) {
- if (fallback instanceof KeystoneAuthentication) {
- LOGGER.debug("Running Keystone fallback...");
- KeystoneAuthentication ka = (KeystoneAuthentication) fallback;
- ka.setOriginalResponse(response);
- ka.authenticate();
- } else {
- throw new AuthenticationException("unknown fallback method");
- }
- } else {
- if (response.getEntity() == null) {
- LOGGER.error("Response: {}\nHeaders: {}\nBody:\n", response.getStatusLine().toString(), response.getAllHeaders());
- } else {
- LOGGER.error("Response: {}\nHeaders: {}\nBody: {}", response.getStatusLine().toString(), response.getAllHeaders(), EntityUtils.toString(response.getEntity()));
- }
- throw new AuthenticationException(response.getStatusLine().toString());
- }
- }
- }
- } catch (IOException ex) {
- throw new CommunicationException(ex);
- }
- }
-
- /**
- * Loads custom CAs either from file or directory. If both set, CA file has
- * higher priority.
- *
- * @return keystore with custom CAs loaded
- * @throws AuthenticationException
- */
- protected KeyStore loadCAs() throws AuthenticationException {
- KeyStore keyStore = null;
- if (CAFile != null && !CAFile.isEmpty()) {
- keyStore = loadCAsFromFile();
- } else if (CAPath != null && !CAPath.isEmpty()) {
- keyStore = loadCAsFromPath();
- }
-
- return keyStore;
- }
-
- private KeyStore loadCAsFromFile() throws AuthenticationException {
- try {
- KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
- FileInputStream instream = new FileInputStream(new File(CAFile));
- trustStore.load(instream, null);
-
- return trustStore;
- } catch (KeyStoreException | IOException | NoSuchAlgorithmException | CertificateException ex) {
- throw new AuthenticationException(ex);
- }
- }
-
- private KeyStore loadCAsFromPath() throws AuthenticationException {
- try {
- File CADir = new File(CAPath);
- if (!CADir.isDirectory()) {
- throw new AuthenticationException("'" + CAPath + "' is not a directory.");
- }
-
- FilenameFilter fileNameFilter = new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- if (name.lastIndexOf('.') > 0) {
- int lastIndex = name.lastIndexOf('.');
- String str = name.substring(lastIndex);
- if (str.equals(".pem")) {
- return true;
- }
- }
- return false;
- }
- };
-
- File[] certs = CADir.listFiles(fileNameFilter);
- KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
- ks.load(null);
- List<Certificate> rootCertificates = new ArrayList<>();
- PEMReader reader;
- for (File cert : certs) {
- reader = new PEMReader(new InputStreamReader(new FileInputStream(cert)));
- rootCertificates.add((X509Certificate) reader.readObject());
- }
-
- for (Certificate cert : rootCertificates) {
- X509Certificate x509Cert = (X509Certificate) cert;
- ks.setCertificateEntry(x509Cert.getSubjectX500Principal().getName(), x509Cert);
- LOGGER.debug("adding certificate: " + x509Cert.getSubjectX500Principal().getName());
- }
-
- return ks;
- } catch (KeyStoreException | IOException | NoSuchAlgorithmException | CertificateException ex) {
- throw new AuthenticationException(ex);
- }
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.api.http.auth;
-
-import com.google.gson.stream.JsonReader;
-import com.google.gson.stream.JsonWriter;
-import cz.cesnet.cloud.occi.api.Authentication;
-import cz.cesnet.cloud.occi.api.exception.AuthenticationException;
-import cz.cesnet.cloud.occi.api.exception.CommunicationException;
-import cz.cesnet.cloud.occi.api.http.HTTPConnection;
-import cz.cesnet.cloud.occi.api.http.HTTPHelper;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.StringReader;
-import java.net.URI;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.apache.http.Header;
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpHost;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.EntityUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Class representing OpenStack's Keystone HTTP authentication method.
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class KeystoneAuthentication extends HTTPAuthentication {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(KeystoneAuthentication.class);
- public static final String IDENTIFIER = "OCCIKeystoneAuthentication";
- private static final String HEADER_AUTH = "Www-Authenticate";
- private static final String HEADER_X_AUTH_TOKEN = "X-Auth-Token";
- private static final String GROUP_URI = "uri";
- private static final String REGEXP_KEYSTONE_URI = "^(?:Keystone|snf-auth) uri='(?<" + GROUP_URI + ">.+)'$";
- private static final Pattern PATTERN_KEYSTONE_URI = Pattern.compile(REGEXP_KEYSTONE_URI);
- private static final String PATH_DEFAULT = "/v2.0";
- private final HTTPAuthentication originalAuthentication;
- private CloseableHttpResponse originalResponse = null;
- private String authToken = null;
-
- public KeystoneAuthentication(HTTPAuthentication originalAuthentication) {
- this.originalAuthentication = originalAuthentication;
- }
-
- public CloseableHttpResponse getOriginalResponse() {
- return originalResponse;
- }
-
- public void setOriginalResponse(CloseableHttpResponse response) {
- this.originalResponse = response;
- }
-
- @Override
- public String getIdentifier() {
- return IDENTIFIER;
- }
-
- @Override
- public Authentication getFallback() {
- return null;
- }
-
- private void checkResponse() throws AuthenticationException {
- if (originalResponse == null) {
- throw new AuthenticationException("no response to react to");
- }
-
- if (!originalResponse.containsHeader(HEADER_AUTH)) {
- throw new AuthenticationException("missing '" + HEADER_AUTH + "' header");
- }
- }
-
- @Override
- public void authenticate() throws CommunicationException {
- checkResponse();
-
- Matcher matcher = PATTERN_KEYSTONE_URI.matcher(originalResponse.getFirstHeader(HEADER_AUTH).getValue());
- if (!matcher.find()) {
- throw new AuthenticationException("incorrect " + HEADER_AUTH + " content");
- }
-
- URI keystoneURI = URI.create(matcher.group(GROUP_URI));
- HttpHost target = new HttpHost(keystoneURI.getHost(), keystoneURI.getPort(), keystoneURI.getScheme());
- //TODO
- //this path normalization should be handled in a better way
- String path = keystoneURI.getPath();
- if (path == null) {
- path = "";
- }
-
- if (path.endsWith("/")) {
- path = path.substring(0, path.length() - 1);
- }
-
- if (!path.endsWith(PATH_DEFAULT)) {
- path = path + PATH_DEFAULT;
- }
-
- HTTPConnection connection = originalAuthentication.getConnection();
- CloseableHttpClient client = connection.getClient();
- HttpContext context = connection.getContext();
-
- String response = authenticateAgainstKeystone(target, path, client, context, null);
- authToken = parseId(response);
- response = getTenants(target, path, client, context);
- tryTenants(response, target, path, client, context);
-
- LOGGER.debug("Scoped token: " + authToken);
- connection.addHeader(new BasicHeader(HEADER_X_AUTH_TOKEN, authToken));
- }
-
- private String authenticateAgainstKeystone(HttpHost target, String path, CloseableHttpClient client, HttpContext context, String tenant) throws CommunicationException {
- try {
- HttpPost httpPost = HTTPHelper.preparePost("/tokens", getHeaders(), path);
- httpPost.setEntity(new StringEntity(getRequestBody(tenant)));
-
- try (CloseableHttpResponse response = HTTPHelper.runRequest(httpPost, target, client, context)) {
- return EntityUtils.toString(response.getEntity());
- }
- } catch (IOException ex) {
- throw new CommunicationException(ex);
- }
- }
-
- private String getTenants(HttpHost target, String path, CloseableHttpClient client, HttpContext context) throws CommunicationException {
- try {
- HttpGet httpGet = HTTPHelper.prepareGet("/tenants", getHeaders(), path);
- try (CloseableHttpResponse response = HTTPHelper.runRequest(httpGet, target, client, context)) {
- return EntityUtils.toString(response.getEntity());
- }
- } catch (IOException ex) {
- throw new CommunicationException(ex);
- }
- }
-
- private void tryTenants(String json, HttpHost target, String path, CloseableHttpClient client, HttpContext context) throws AuthenticationException, CommunicationException {
- try (JsonReader reader = new JsonReader(new StringReader(json))) {
- reader.beginObject();
- while (reader.hasNext()) {
- String name = reader.nextName();
- if (!name.equals("tenants")) {
- reader.skipValue();
- continue;
- }
-
- reader.beginArray();
- while (reader.hasNext()) {
- reader.beginObject();
- while (reader.hasNext()) {
- name = reader.nextName();
- if (!name.equals("name")) {
- reader.skipValue();
- continue;
- }
-
- String tenant = reader.nextString();
- try {
- String response = authenticateAgainstKeystone(target, path, client, context, tenant);
- authToken = parseId(response);
- return;
- } catch (CommunicationException ex) {
- //ignoring and trying the next tenant
- }
- }
- reader.endObject();
- }
- reader.endArray();
- throw new AuthenticationException("no suitable tenant found");
- }
- } catch (IOException ex) {
- throw new CommunicationException(ex);
- }
- }
-
- private String getRequestBody(String tenant) throws AuthenticationException, CommunicationException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- try (JsonWriter writer = new JsonWriter(new OutputStreamWriter(out))) {
- writer.beginObject();
- writer.name("auth");
- writer.beginObject();
-
- String identifier = originalAuthentication.getIdentifier();
- switch (identifier) {
- //case X509Authentication.IDENTIFIER: // not sure if should be here or not
- case VOMSAuthentication.IDENTIFIER: {
- writer.name("voms").value(true);
- }
- break;
- case BasicAuthentication.IDENTIFIER:
- case DigestAuthentication.IDENTIFIER: {
- BasicAuthentication ba = (BasicAuthentication) originalAuthentication;
- writer.name("passwordCredentials");
- writer.beginObject();
- writer.name("username").value(ba.getUsername());
- writer.name("password").value(ba.getPassword());
- writer.endObject();
- }
- break;
- default:
- throw new AuthenticationException("unknown original authentication method");
- }
-
- if (tenant != null) {
- writer.name("tenantName").value(tenant);
- }
- writer.endObject();
- writer.endObject();
- writer.close();
-
- return out.toString();
- } catch (IOException ex) {
- throw new CommunicationException(ex);
- }
- }
-
- private String parseId(String json) throws CommunicationException {
- try (JsonReader reader = new JsonReader(new StringReader(json))) {
- String id = null;
- reader.beginObject();
- while (reader.hasNext()) {
- String name = reader.nextName();
- if (!name.equals("access")) {
- reader.skipValue();
- continue;
- }
-
- reader.beginObject();
- while (reader.hasNext()) {
- name = reader.nextName();
- if (!name.equals("token")) {
- reader.skipValue();
- continue;
- }
-
- reader.beginObject();
- while (reader.hasNext()) {
- name = reader.nextName();
- if (!name.equals("id")) {
- reader.skipValue();
- continue;
- }
-
- id = reader.nextString();
- break;
- }
- break;
- }
- break;
- }
-
- return id;
- } catch (IOException ex) {
- throw new CommunicationException(ex);
- }
- }
-
- private Header[] getHeaders() {
- Header[] headers;
- if (authToken != null) {
- headers = new Header[3];
- headers[2] = new BasicHeader(HEADER_X_AUTH_TOKEN, authToken);
- } else {
- headers = new Header[2];
- }
-
- headers[0] = new BasicHeader(HttpHeaders.CONTENT_TYPE, "application/json");
- headers[1] = new BasicHeader(HttpHeaders.ACCEPT, "application/json");
-
- return headers;
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.api.http.auth;
-
-import cz.cesnet.cloud.occi.api.Authentication;
-
-/**
- * Dummy authentication method representing no authentication.
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class NoAuthentication extends HTTPAuthentication {
-
- public static final String IDENTIFIER = "OCCINoAuthentication";
-
- @Override
- public String getIdentifier() {
- return IDENTIFIER;
- }
-
- @Override
- public Authentication getFallback() {
- return null;
- }
-
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.api.http.auth;
-
-import cz.cesnet.cloud.occi.api.Authentication;
-
-/**
- * Class representing HTTP authentication method via VOMS certificates.
- *
- * <p>
- * Supports certificates in pk12 or pem format. This method has a Keystone
- * authentication method as fallback.</p>
- *
- * <p>
- * Example:</p>
- *
- * <pre>{@code
- * HTTPAuthentication auth = new VOMSAuthentication("/path/to/certificate.pem");
- * auth.setCAPath("/etc/grid-security/certificates/"); //path to CA directory
- * Client client = new HTTPClient(URI.create("https://remote.server.net"), auth);}</pre>
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class VOMSAuthentication extends CertificateAuthentication {
-
- public static final String IDENTIFIER = "OCCIVOMSAuthentication";
-
- /**
- * Constructor.
- *
- * @param certificate cannot be null nor empty
- */
- public VOMSAuthentication(String certificate) {
- setCertificate(certificate);
- setPassword("");
- }
-
- @Override
- public String getIdentifier() {
- return IDENTIFIER;
- }
-
- @Override
- public Authentication getFallback() {
- return new KeystoneAuthentication(this);
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.api.http.auth;
-
-import cz.cesnet.cloud.occi.api.Authentication;
-
-/**
- * Class representing HTTP authentication method via X509 certificates.
- *
- * <p>
- * Supports certificates in pk12 or pem format. This method has a Keystone
- * authentication method as fallback.</p>
- *
- * <p>
- * Example:</p>
- *
- * <pre>{@code
- * HTTPAuthentication auth = new X509Authentication("/path/to/certificate.pem", "password");
- * auth.setCAPath("/etc/grid-security/certificates/"); //path to CA directory
- * Client client = new HTTPClient(URI.create("https://remote.server.net"), auth);}</pre>
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class X509Authentication extends CertificateAuthentication {
-
- public static final String IDENTIFIER = "OCCIX509Authentication";
-
- /**
- * Constructor.
- *
- * @param certificate cannot be null nor empty
- * @param password cannot be null nor empty
- */
- public X509Authentication(String certificate, String password) {
- if (password.isEmpty()) {
- throw new IllegalArgumentException("password cannot be empty");
- }
-
- setCertificate(certificate);
- super.setPassword(password);
- }
-
- @Override
- public String getIdentifier() {
- return IDENTIFIER;
- }
-
- @Override
- public Authentication getFallback() {
- return new KeystoneAuthentication(this);
- }
-
- /**
- * Sets user's password.
- *
- * @param password user's password, cannot be null nor empty
- */
- @Override
- public void setPassword(String password) {
- if (password.isEmpty()) {
- throw new IllegalArgumentException("password cannot be empty");
- }
-
- super.setPassword(password);
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi;
-
-import cz.cesnet.cloud.occi.core.Action;
-import cz.cesnet.cloud.occi.core.ActionInstance;
-import cz.cesnet.cloud.occi.core.Attribute;
-import cz.cesnet.cloud.occi.core.Entity;
-import cz.cesnet.cloud.occi.core.Kind;
-import cz.cesnet.cloud.occi.core.Link;
-import cz.cesnet.cloud.occi.core.Mixin;
-import cz.cesnet.cloud.occi.core.Resource;
-import cz.cesnet.cloud.occi.exception.InvalidAttributeValueException;
-import cz.cesnet.cloud.occi.infrastructure.Compute;
-import cz.cesnet.cloud.occi.infrastructure.NetworkInterface;
-import cz.cesnet.cloud.occi.infrastructure.StorageLink;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-public class DataGenerator {
-
- public static List<Kind> getMinimalKind() throws URISyntaxException {
- List<Kind> kinds = new ArrayList<>();
- Kind kind = new Kind(new URI("http://schemas.ogf.org/occi/core#"), "entity");
- kind.setLocation(new URI("/entity/"));
- kinds.add(kind);
-
- return kinds;
- }
-
- public static List<Kind> getFiveKinds() throws URISyntaxException {
- Set<Attribute> attributes = new HashSet<>();
- List<Kind> kinds = new ArrayList<>();
-
- Attribute a = new Attribute("occi.core.id");
- attributes.add(a);
- a = new Attribute("occi.core.title");
- attributes.add(a);
- Kind entity = new Kind(new URI("http://schemas.ogf.org/occi/core#"), "entity", "Entity", new URI("/entity/"), attributes);
- kinds.add(entity);
-
- attributes.clear();
- a = new Attribute("occi.core.summary");
- attributes.add(a);
- Kind resource = new Kind(new URI("http://schemas.ogf.org/occi/core#"), "resource", "Resource", new URI("/resource/"), attributes);
- resource.addRelation(entity);
- resource.setParentKind(entity);
- kinds.add(resource);
-
- attributes.clear();
- a = new Attribute("occi.core.target");
- attributes.add(a);
- a = new Attribute("occi.core.source");
- attributes.add(a);
- Kind link = new Kind(new URI("http://schemas.ogf.org/occi/core#"), "link", "Link", new URI("/link/"), attributes);
- link.addRelation(entity);
- link.setParentKind(entity);
- kinds.add(link);
-
- attributes.clear();
- a = new Attribute("occi.compute.architecture", false, true);
- attributes.add(a);
- a = new Attribute("occi.compute.cores");
- attributes.add(a);
- a = new Attribute("occi.compute.hostname");
- attributes.add(a);
- a = new Attribute("occi.compute.speed");
- attributes.add(a);
- a = new Attribute("occi.compute.memory");
- attributes.add(a);
- a = new Attribute("occi.compute.state");
- attributes.add(a);
- Kind k = new Kind(new URI("http://schemas.ogf.org/occi/infrastructure#"), "compute", "Compute Resource", new URI("/compute/"), attributes);
- Action ac = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/compute/action#"), "start");
- k.addAction(ac);
- ac = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/compute/action#"), "stop");
- k.addAction(ac);
- ac = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/compute/action#"), "restart");
- k.addAction(ac);
- ac = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/compute/action#"), "suspend");
- k.addAction(ac);
- k.addRelation(resource);
- k.setParentKind(resource);
- kinds.add(k);
-
- attributes.clear();
- a = new Attribute("occi.storagelink.deviceid", true, false);
- attributes.add(a);
- a = new Attribute("occi.storagelink.mountpoint");
- attributes.add(a);
- a = new Attribute("occi.storagelink.state", true, true);
- attributes.add(a);
- k = new Kind(new URI("http://schemas.ogf.org/occi/infrastructure#"), "storagelink", "Storage Link", new URI("/storagelink/"), attributes);
- k.addRelation(link);
- k.setParentKind(link);
- kinds.add(k);
-
- return kinds;
- }
-
- public static List<Mixin> getMinimalMixin() throws URISyntaxException {
- List<Mixin> mixins = new ArrayList<>();
- Mixin ostpl = new Mixin(new URI("http://schemas.ogf.org/occi/infrastructure#"), "os_tpl");
- ostpl.setLocation(new URI("/mixins/os_tpl/"));
- mixins.add(ostpl);
-
- return mixins;
- }
-
- public static List<Mixin> getFiveMixins() throws URISyntaxException {
- Set<Attribute> attributes = new HashSet<>();
- List<Mixin> mixins = new ArrayList<>();
-
- Mixin ostpl = new Mixin(new URI("http://schemas.ogf.org/occi/infrastructure#"), "os_tpl", "Operating System Template", new URI("/mixins/os_tpl/"), attributes);
- mixins.add(ostpl);
-
- attributes.clear();
- Attribute a = new Attribute("occi.network.address", true, false);
- attributes.add(a);
- a = new Attribute("occi.network.gateway");
- attributes.add(a);
- a = new Attribute("occi.network.allocation");
- attributes.add(a);
- a = new Attribute("occi.network.state");
- attributes.add(a);
- Mixin m = new Mixin(new URI("http://schemas.ogf.org/occi/infrastructure/network#"), "ipnetwork", "IP Network Mixin", new URI("/mixins/ipnetwork/"), attributes);
- mixins.add(m);
-
- attributes.clear();
- Mixin resourcetpl = new Mixin(new URI("http://schemas.ogf.org/occi/infrastructure#"), "resource_tpl", "Resource Template", new URI("/mixins/resource_tpl/"), attributes);
- mixins.add(resourcetpl);
-
- attributes.clear();
- a = new Attribute("occi.compute.architecture");
- attributes.add(a);
- a = new Attribute("occi.compute.cores", true, true);
- attributes.add(a);
- a = new Attribute("occi.compute.speed");
- attributes.add(a);
- a = new Attribute("occi.compute.memory", false, true);
- attributes.add(a);
- m = new Mixin(new URI("https://occi.localhost/occi/infrastructure/resource_tpl#"), "larger", "Larger Instance - 4 cores and 10 GB of RAM", new URI("/mixins/larger/"), attributes);
- m.addRelation(resourcetpl);
- mixins.add(m);
-
- attributes.clear();
- m = new Mixin(new URI("https://occi.localhost/occi/infrastructure/os_tpl#"), "debianvm", "debianvm", new URI("/mixins/debianvm/"), attributes);
- m.addRelation(ostpl);
- mixins.add(m);
-
- return mixins;
- }
-
- public static List<Action> getMinimalAction() throws URISyntaxException {
- List<Action> actions = new ArrayList<>();
- Action ac = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/network/action#"), "up");
- actions.add(ac);
-
- return actions;
- }
-
- public static List<Action> getFiveActions() throws URISyntaxException {
- List<Action> actions = new ArrayList<>();
- Set<Attribute> attributes = new HashSet<>();
-
- attributes.clear();
- Attribute a = new Attribute("method");
- attributes.add(a);
- Action ac = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/compute/action#"), "restart", "Restart Compute instance", attributes);
- actions.add(ac);
-
- attributes.clear();
- a = new Attribute("method");
- attributes.add(a);
- ac = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/compute/action#"), "suspend", "Suspend Compute instance", attributes);
- actions.add(ac);
-
- ac = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/network/action#"), "up", "Activate network", null);
- actions.add(ac);
-
- ac = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/network/action#"), "down", "Deactivate network", null);
- actions.add(ac);
-
- ac = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/storage/action#"), "backup", "Backup Storage", null);
- actions.add(ac);
-
- return actions;
- }
-
- public static List<URI> getLocations() throws URISyntaxException {
- List<URI> locations = new ArrayList<>();
- locations.add(new URI("http://rocci-server-1-1-x.herokuapp.com:80/compute/87f3bfc3-42d4-4474-b45c-757e55e093e9"));
- locations.add(new URI("http://rocci-server-1-1-x.herokuapp.com:80/compute/17679ebd-975f-4ea0-b42b-47405178c360"));
- locations.add(new URI("http://rocci-server-1-1-x.herokuapp.com:80/compute/509afbd3-abff-427c-9b25-7913d17e5102"));
-
- return locations;
- }
-
- public static Resource getResource() throws InvalidAttributeValueException, URISyntaxException {
- Kind k = new Kind(new URI("http://schemas.ogf.org/occi/infrastructure#"), "compute", "compute resource", new URI("/compute/"), null);
- Resource r = new Resource("87f3bfc3-42d4-4474-b45c-757e55e093e9", k);
- r.setTitle("compute1");
- r.addAttribute(Compute.ARCHITECTURE_ATTRIBUTE_NAME, "x86");
- r.addAttribute(Compute.HOSTNAME_ATTRIBUTE_NAME, "compute1.example.org");
- r.addAttribute(Compute.MEMORY_ATTRIBUTE_NAME, "1.7");
- r.addAttribute(Compute.SPEED_ATTRIBUTE_NAME, "1.0");
- r.addAttribute(Compute.STATE_ATTRIBUTE_NAME, "active");
-
- List<Mixin> mixins = getFiveMixins();
- for (Mixin mixin : mixins) {
- r.addMixin(mixin);
- }
-
- List<Link> links = getLinks();
- for (Link link : links) {
- link.setSource(r);
- r.addLink(link);
- }
-
- List<Action> actions = getActions();
- for (Action action : actions) {
- r.addAction(action);
- }
-
- return r;
- }
-
- public static List<Action> getActions() throws URISyntaxException {
- List<Action> actions = new ArrayList<>();
- actions.add(new Action(new URI("http://schemas.ogf.org/occi/infrastructure/compute/action#"), "start"));
- actions.add(new Action(new URI("http://schemas.ogf.org/occi/infrastructure/compute/action#"), "stop"));
-
- return actions;
- }
-
- public static List<Link> getLinks() throws URISyntaxException, InvalidAttributeValueException {
- List<Link> links = new ArrayList<>();
-
- Kind k = new Kind(new URI("http://schemas.ogf.org/occi/infrastructure#"), "networkinterface", null, new URI("/link/networkinterface/"), null);
- Link l = new Link("456", k);
- l.addAttribute(NetworkInterface.INTERFACE_ATTRIBUTE_NAME, "eth0");
- l.addAttribute(NetworkInterface.MAC_ATTRIBUTE_NAME, "00:11:22:33:44:55");
- l.addAttribute(NetworkInterface.STATE_ATTRIBUTE_NAME, "active");
- l.setTarget("/network/123");
- l.setRelation("http://schemas.ogf.org/occi/infrastructure#network");
- links.add(l);
-
- k = new Kind(new URI("http://schemas.ogf.org/occi/infrastructure#"), "storagelink", null, new URI("/link/storagelink/"), null);
- l = new Link("789", k);
- l.addAttribute(StorageLink.DEVICE_ID_ATTRIBUTE_NAME, "1234qwerty");
- l.addAttribute(StorageLink.MOUNTPOINT_ATTRIBUTE_NAME, "/mnt/somewhere/");
- l.addAttribute(StorageLink.STATE_ATTRIBUTE_NAME, "active");
- l.setTarget("/storage/852");
- l.setRelation("http://schemas.ogf.org/occi/infrastructure#storage");
- links.add(l);
-
- return links;
- }
-
- public static Link getLink() throws InvalidAttributeValueException, URISyntaxException {
- Kind k = new Kind(new URI("http://schemas.ogf.org/occi/infrastructure#"), "networkinterface", null, null, null);
- Link l = new Link("87f3bfc3-42d4-4474-b45c-757e55e093e9", k);
- l.addAttribute(NetworkInterface.INTERFACE_ATTRIBUTE_NAME, "eth0");
- l.addAttribute(NetworkInterface.MAC_ATTRIBUTE_NAME, "00:11:22:33:44:55");
- l.addAttribute(NetworkInterface.STATE_ATTRIBUTE_NAME, "active");
- l.setSource("/vms/foo/vm1");
- l.setTarget("/network/123");
-
- List<Mixin> mixins = getFiveMixins();
- for (Mixin mixin : mixins) {
- l.addMixin(mixin);
- }
-
- return l;
- }
-
- public static ActionInstance getAction() throws InvalidAttributeValueException, URISyntaxException {
- Action a = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/storage/action#"), "backup", "Backup Storage", null);
- ActionInstance ai = new ActionInstance(a);
- ai.addAttribute(new Attribute(Entity.ID_ATTRIBUTE_NAME), "87f3bfc3-42d4-4474-b45c-757e55e093e9");
- ai.addAttribute(new Attribute(NetworkInterface.INTERFACE_ATTRIBUTE_NAME), "eth0");
- ai.addAttribute(new Attribute(NetworkInterface.MAC_ATTRIBUTE_NAME), "00:11:22:33:44:55");
- ai.addAttribute(new Attribute(NetworkInterface.STATE_ATTRIBUTE_NAME), "active");
- ai.addAttribute(new Attribute(Link.SOURCE_ATTRIBUTE_NAME), "/vms/foo/vm1");
- ai.addAttribute(new Attribute(Link.TARGET_ATTRIBUTE_NAME), "/network/123");
-
- return ai;
- }
-
- public static Kind getCustomComputeKind() throws URISyntaxException {
- return new Kind(new URI("http://custom.testing.org/occi/infra#"), "compute", null, null, null);
- }
-
- public static Kind getCustomStorageKind() throws URISyntaxException {
- return new Kind(new URI("http://custom.testing.org/occi/infra#"), "storage", null, null, null);
- }
-
- public static Kind getCustomNetworkKind() throws URISyntaxException {
- return new Kind(new URI("http://custom.testing.org/occi/infra#"), "network", null, null, null);
- }
-
- public static Kind getCustomStorageLinkKind() throws URISyntaxException {
- return new Kind(new URI("http://custom.testing.org/occi/infra#"), "storagelink", null, null, null);
- }
-
- public static Kind getCustomNetworkInterfaceKind() throws URISyntaxException {
- return new Kind(new URI("http://custom.testing.org/occi/infra#"), "networkinterface", null, null, null);
- }
-
- public static Mixin getCustomIPNetworkMixin() throws URISyntaxException {
- return new Mixin(new URI("http://custom.testing.org/occi/infra#"), "ipnetwork", null, null, null);
- }
-
- public static Mixin getCustomIPNetworkInterfaceMixin() throws URISyntaxException {
- return new Mixin(new URI("http://custom.testing.org/occi/infra#"), "ipnetworkinterface", null, null, null);
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.api;
-
-import cz.cesnet.cloud.occi.DataGenerator;
-import cz.cesnet.cloud.occi.Model;
-import cz.cesnet.cloud.occi.api.exception.EntityBuildingException;
-import cz.cesnet.cloud.occi.core.Action;
-import cz.cesnet.cloud.occi.core.ActionInstance;
-import cz.cesnet.cloud.occi.core.Kind;
-import cz.cesnet.cloud.occi.core.Link;
-import cz.cesnet.cloud.occi.core.Mixin;
-import cz.cesnet.cloud.occi.core.Resource;
-import cz.cesnet.cloud.occi.infrastructure.Compute;
-import cz.cesnet.cloud.occi.infrastructure.IPNetwork;
-import cz.cesnet.cloud.occi.infrastructure.IPNetworkInterface;
-import cz.cesnet.cloud.occi.infrastructure.Network;
-import cz.cesnet.cloud.occi.infrastructure.NetworkInterface;
-import cz.cesnet.cloud.occi.infrastructure.Storage;
-import cz.cesnet.cloud.occi.infrastructure.StorageLink;
-import java.net.URI;
-import java.net.URISyntaxException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class EntityBuilderTest {
-
- private Model model;
- private EntityBuilder eb;
-
- @Before
- public void setUp() throws Exception {
- model = new Model();
-
- for (Kind kind : DataGenerator.getFiveKinds()) {
- model.addKind(kind);
- }
-
- for (Mixin mixin : DataGenerator.getFiveMixins()) {
- model.addMixin(mixin);
- }
-
- for (Action action : DataGenerator.getFiveActions()) {
- model.addAction(action);
- }
-
- eb = new EntityBuilder(model);
- }
-
- private void setUpCustom() throws URISyntaxException {
- model.addKind(DataGenerator.getCustomComputeKind());
- model.addKind(DataGenerator.getCustomNetworkKind());
- model.addKind(DataGenerator.getCustomStorageKind());
- model.addKind(DataGenerator.getCustomNetworkInterfaceKind());
- model.addKind(DataGenerator.getCustomStorageLinkKind());
- model.addMixin(DataGenerator.getCustomIPNetworkInterfaceMixin());
- model.addMixin(DataGenerator.getCustomIPNetworkMixin());
- }
-
- @Test
- public void testConstructor() {
- EntityBuilder eb = new EntityBuilder(model);
-
- assertEquals(model, eb.getModel());
- }
-
- @Test
- public void testInvalidConstructor() {
- try {
- new EntityBuilder(null);
- fail();
- } catch (NullPointerException ex) {
- //cool
- }
- }
-
- @Test
- public void testGetResourceWithString() throws Exception {
- Kind kind = DataGenerator.getFiveKinds().get(3);
- Resource resource = eb.getResource("compute");
-
- assertEquals(kind, resource.getKind());
- assertNotNull(resource.getId());
- }
-
- @Test
- public void testInvalidGetResourceWithString() throws Exception {
- try {
- eb.getResource("nonexisting");
- } catch (EntityBuildingException ex) {
- //cool
- }
-
- try {
- Kind k = new Kind(new URI("http://different.uri.same/term/infrastructure#"), "compute", "Compute Resource", new URI("/compute/"), null);
- model.addKind(k);
- eb.getResource("compute");
- } catch (EntityBuildingException ex) {
- //cool
- }
- }
-
- @Test
- public void testGetResourceWithURI() throws Exception {
- Kind kind = DataGenerator.getFiveKinds().get(3);
- Resource resource = eb.getResource(URI.create("http://schemas.ogf.org/occi/infrastructure#compute"));
-
- assertEquals(kind, resource.getKind());
- assertNotNull(resource.getId());
- }
-
- @Test
- public void testInvalidGetResourceWithURI() throws Exception {
- try {
- eb.getResource(URI.create("http://nonexisting.abc.org/icco/infrastructure#compute"));
- } catch (EntityBuildingException ex) {
- //cool
- }
- }
-
- @Test
- public void testGetLinkWithString() throws Exception {
- Kind kind = DataGenerator.getFiveKinds().get(4);
- Link link = eb.getLink("storagelink");
-
- assertEquals(kind, link.getKind());
- assertNotNull(link.getId());
- }
-
- @Test
- public void testInvalidGetLinkWithString() throws Exception {
- try {
- eb.getLink("nonexisting");
- } catch (EntityBuildingException ex) {
- //cool
- }
-
- try {
- Kind k = new Kind(new URI("http://different.uri.same/term/infrastructure#"), "storagelink", "Storage Link", new URI("/storagelink/"), null);
- model.addKind(k);
- eb.getLink("storagelink");
- } catch (EntityBuildingException ex) {
- //cool
- }
- }
-
- @Test
- public void testGetLinkWithURI() throws Exception {
- Kind kind = DataGenerator.getFiveKinds().get(4);
- Link link = eb.getLink(URI.create("http://schemas.ogf.org/occi/infrastructure#storagelink"));
-
- assertEquals(kind, link.getKind());
- assertNotNull(link.getId());
- }
-
- @Test
- public void testInvalidLinkWithURI() throws Exception {
- try {
- eb.getLink(URI.create("http://nonexisting.abc.org/icco/infrastructure#storagelink"));
- } catch (EntityBuildingException ex) {
- //cool
- }
- }
-
- @Test
- public void testGetActionInstanceWithString() throws Exception {
- Action action = DataGenerator.getFiveActions().get(2);
- ActionInstance ai = eb.getActionInstance("up");
-
- assertEquals(new ActionInstance(action), ai);
- }
-
- @Test
- public void testInvalidGetActionInstanceWithString() throws Exception {
- try {
- eb.getActionInstance("nonexisting");
- } catch (EntityBuildingException ex) {
- //cool
- }
-
- try {
- Action ac = new Action(new URI("http://different.uri.same/term/infrastructure/network/action#"), "up", "Activate network", null);
- model.addAction(ac);
- eb.getActionInstance("up");
- } catch (EntityBuildingException ex) {
- //cool
- }
- }
-
- @Test
- public void testGetActionInstanceWithURI() throws Exception {
- Action action = DataGenerator.getFiveActions().get(2);
- ActionInstance ai = eb.getActionInstance(URI.create("http://schemas.ogf.org/occi/infrastructure/network/action#up"));
-
- assertEquals(new ActionInstance(action), ai);
- }
-
- @Test
- public void testInvalidGetActionInstanceWithURI() throws Exception {
- try {
- eb.getActionInstance(URI.create("http://nonexisting.abc.org/icco/infrastructure/network/action#up"));
- } catch (EntityBuildingException ex) {
- //cool
- }
- }
-
- @Test
- public void testGetComputeWithURI() throws Exception {
- setUpCustom();
- Kind kind = DataGenerator.getCustomComputeKind();
- Compute compute = eb.getCompute(URI.create("http://custom.testing.org/occi/infra#compute"));
-
- assertEquals(kind, compute.getKind());
- assertNotNull(compute.getId());
- }
-
- @Test
- public void testInvalidGetComputeWithURI() throws Exception {
- try {
- eb.getCompute(URI.create("http://nonexisting.abc.org/icco/infra#compute"));
- } catch (EntityBuildingException ex) {
- //cool
- }
- }
-
- @Test
- public void testGetCompute() throws Exception {
- setUpCustom();
- model = new Model();
- model.addKind(Compute.getDefaultKind());
-
- Compute compute = eb.getCompute();
- assertEquals(Compute.getDefaultKind(), compute.getKind());
- assertNotNull(compute.getId());
- }
-
- @Test
- public void testGetNetworkWithURI() throws Exception {
- setUpCustom();
- Kind kind = DataGenerator.getCustomNetworkKind();
- Network network = eb.getNetwork(URI.create("http://custom.testing.org/occi/infra#network"));
-
- assertEquals(kind, network.getKind());
- assertNotNull(network.getId());
- }
-
- @Test
- public void testInvalidGetNetworkWithURI() throws Exception {
- try {
- eb.getNetwork(URI.create("http://nonexisting.abc.org/icco/infra#network"));
- } catch (EntityBuildingException ex) {
- //cool
- }
- }
-
- @Test
- public void testGetNetwork() throws Exception {
- setUpCustom();
- model = new Model();
- model.addKind(Network.getDefaultKind());
-
- Network network = eb.getNetwork();
- assertEquals(Network.getDefaultKind(), network.getKind());
- assertNotNull(network.getId());
- }
-
- @Test
- public void testGetStorageWithURI() throws Exception {
- setUpCustom();
- Kind kind = DataGenerator.getCustomStorageKind();
- Storage storage = eb.getStorage(URI.create("http://custom.testing.org/occi/infra#storage"));
-
- assertEquals(kind, storage.getKind());
- assertNotNull(storage.getId());
- }
-
- @Test
- public void testInvalidGetStorageWithURI() throws Exception {
- try {
- eb.getStorage(URI.create("http://nonexisting.abc.org/icco/infra#storage"));
- } catch (EntityBuildingException ex) {
- //cool
- }
- }
-
- @Test
- public void testGetStorage() throws Exception {
- setUpCustom();
- model = new Model();
- model.addKind(Storage.getDefaultKind());
-
- Storage storage = eb.getStorage();
- assertEquals(Storage.getDefaultKind(), storage.getKind());
- assertNotNull(storage.getId());
- }
-
- @Test
- public void testGetStorageLinkWithURI() throws Exception {
- setUpCustom();
- Kind kind = DataGenerator.getCustomStorageLinkKind();
- StorageLink storagelink = eb.getStorageLink(URI.create("http://custom.testing.org/occi/infra#storagelink"));
-
- assertEquals(kind, storagelink.getKind());
- assertNotNull(storagelink.getId());
- }
-
- @Test
- public void testInvalidGetStorageLinkWithURI() throws Exception {
- try {
- eb.getStorageLink(URI.create("http://nonexisting.abc.org/icco/infra#storagelink"));
- } catch (EntityBuildingException ex) {
- //cool
- }
- }
-
- @Test
- public void testGetStorageLink() throws Exception {
- setUpCustom();
- model = new Model();
- model.addKind(StorageLink.getDefaultKind());
-
- StorageLink storagelink = eb.getStorageLink();
- assertEquals(StorageLink.getDefaultKind(), storagelink.getKind());
- assertNotNull(storagelink.getId());
- }
-
- @Test
- public void testGetNetworkInterfaceWithURI() throws Exception {
- setUpCustom();
- Kind kind = DataGenerator.getCustomNetworkInterfaceKind();
- NetworkInterface networkinterface = eb.getNetworkInterface(URI.create("http://custom.testing.org/occi/infra#networkinterface"));
-
- assertEquals(kind, networkinterface.getKind());
- assertNotNull(networkinterface.getId());
- }
-
- @Test
- public void testInvalidGetNetworkInterfaceWithURI() throws Exception {
- try {
- eb.getNetworkInterface(URI.create("http://nonexisting.abc.org/icco/infra#networkinterface"));
- } catch (EntityBuildingException ex) {
- //cool
- }
- }
-
- @Test
- public void testGetNetworkInterface() throws Exception {
- setUpCustom();
- model = new Model();
- model.addKind(NetworkInterface.getDefaultKind());
-
- NetworkInterface networkinterface = eb.getNetworkInterface();
- assertEquals(NetworkInterface.getDefaultKind(), networkinterface.getKind());
- assertNotNull(networkinterface.getId());
- }
-
- @Test
- public void testGetIPNetworkWithURI() throws Exception {
- setUpCustom();
- Kind kind = DataGenerator.getCustomNetworkKind();
- Mixin mixin = DataGenerator.getCustomIPNetworkMixin();
- IPNetwork ipNetwork = eb.getIPNetwork(URI.create("http://custom.testing.org/occi/infra#network"), URI.create("http://custom.testing.org/occi/infra#ipnetwork"));
-
- assertEquals(kind, ipNetwork.getKind());
- assertEquals(mixin, ipNetwork.getMixin("http://custom.testing.org/occi/infra#ipnetwork"));
- assertNotNull(ipNetwork.getId());
- }
-
- @Test
- public void testInvalidGetIPNetworkWithURI() throws Exception {
- try {
- eb.getIPNetwork(URI.create("http://nonexisting.abc.org/icco/infra#network"), URI.create("http://nonexisting.abc.org/icco/infra#ipnetwork"));
- } catch (EntityBuildingException ex) {
- //cool
- }
- }
-
- @Test
- public void testGetIPNetwork() throws Exception {
- setUpCustom();
- model = new Model();
- model.addKind(Network.getDefaultKind());
- model.addMixin(IPNetwork.getDefaultMixin());
-
- IPNetwork ipNetwork = eb.getIPNetwork();
- assertEquals(Network.getDefaultKind(), ipNetwork.getKind());
- assertEquals(IPNetwork.getDefaultMixin(), ipNetwork.getMixin(IPNetwork.MIXIN_IDENTIFIER_DEFAULT));
- assertNotNull(ipNetwork.getId());
- }
-
- @Test
- public void testGetIPNetworkInterfaceWithURI() throws Exception {
- setUpCustom();
- Kind kind = DataGenerator.getCustomNetworkInterfaceKind();
- Mixin mixin = DataGenerator.getCustomIPNetworkInterfaceMixin();
- IPNetworkInterface iPNetworkInterface = eb.getIPNetworkInterface(URI.create("http://custom.testing.org/occi/infra#networkinterface"), URI.create("http://custom.testing.org/occi/infra#ipnetworkinterface"));
-
- assertEquals(kind, iPNetworkInterface.getKind());
- assertEquals(mixin, iPNetworkInterface.getMixin("http://custom.testing.org/occi/infra#ipnetworkinterface"));
- assertNotNull(iPNetworkInterface.getId());
- }
-
- @Test
- public void testInvalidGetIPNetworkInterfaceWithURI() throws Exception {
- try {
- eb.getIPNetworkInterface(URI.create("http://nonexisting.abc.org/icco/infra#networkinterface"), URI.create("http://nonexisting.abc.org/icco/infra#ipnetworkinterface"));
- } catch (EntityBuildingException ex) {
- //cool
- }
- }
-
- @Test
- public void testGetIPNetworkInterface() throws Exception {
- setUpCustom();
- model = new Model();
- model.addKind(NetworkInterface.getDefaultKind());
- model.addMixin(IPNetworkInterface.getDefaultMixin());
-
- System.out.println(model.getMixins());
-
- IPNetworkInterface iPNetworkInterface = eb.getIPNetworkInterface();
- assertEquals(NetworkInterface.getDefaultKind(), iPNetworkInterface.getKind());
- assertEquals(IPNetworkInterface.getDefaultMixin(), iPNetworkInterface.getMixin(IPNetworkInterface.MIXIN_IDENTIFIER_DEFAULT));
- assertNotNull(iPNetworkInterface.getId());
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.api.http;
-
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-import cz.cesnet.cloud.occi.Model;
-import cz.cesnet.cloud.occi.api.EntityBuilder;
-import cz.cesnet.cloud.occi.api.exception.CommunicationException;
-import cz.cesnet.cloud.occi.api.http.auth.BasicAuthentication;
-import cz.cesnet.cloud.occi.api.http.auth.NoAuthentication;
-import cz.cesnet.cloud.occi.core.ActionInstance;
-import cz.cesnet.cloud.occi.core.Attribute;
-import cz.cesnet.cloud.occi.core.Entity;
-import cz.cesnet.cloud.occi.core.Kind;
-import cz.cesnet.cloud.occi.core.Link;
-import cz.cesnet.cloud.occi.core.Mixin;
-import cz.cesnet.cloud.occi.core.Resource;
-import cz.cesnet.cloud.occi.infrastructure.Compute;
-import cz.cesnet.cloud.occi.infrastructure.Network;
-import cz.cesnet.cloud.occi.infrastructure.NetworkInterface;
-import cz.cesnet.cloud.occi.infrastructure.Storage;
-import cz.cesnet.cloud.occi.infrastructure.enumeration.Architecture;
-import cz.cesnet.cloud.occi.infrastructure.enumeration.ComputeState;
-import cz.cesnet.cloud.occi.infrastructure.enumeration.NetworkState;
-import cz.cesnet.cloud.occi.infrastructure.enumeration.StorageState;
-import cz.cesnet.cloud.occi.parser.MediaType;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.Rule;
-
-/**
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class HTTPClientTest {
-
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(8123);
-
- private HTTPClient client;
-
- @Before
- public void setUp() throws Exception {
- client = new HTTPClient(URI.create("http://localhost:8123"), null, MediaType.TEXT_PLAIN, false);
- }
-
- @Test
- public void testFullConstructor() throws Exception {
- HTTPClient client = new HTTPClient(URI.create("http://localhost:8123"), null, MediaType.TEXT_PLAIN, true);
-
- assertEquals(client.getMediaType(), "text/plain");
- assertTrue(client.getAuthentication() instanceof NoAuthentication);
- assertTrue(client.isConnected());
-
- client = new HTTPClient(URI.create("http://localhost:8123"), new BasicAuthentication("username", "password"), MediaType.TEXT_OCCI, false);
-
- assertEquals(client.getMediaType(), MediaType.TEXT_OCCI);
- assertTrue(client.getAuthentication() instanceof BasicAuthentication);
- assertFalse(client.isConnected());
- }
-
- @Test
- public void testPartialConstructor() throws Exception {
- HTTPClient client = new HTTPClient(URI.create("http://localhost:8123"), new NoAuthentication());
-
- assertEquals(client.getMediaType(), MediaType.TEXT_PLAIN);
- assertTrue(client.getAuthentication() instanceof NoAuthentication);
- assertTrue(client.isConnected());
- }
-
- @Test
- public void testMinimalConstructor() throws Exception {
- HTTPClient client = new HTTPClient(URI.create("http://localhost:8123"));
-
- assertEquals(client.getMediaType(), MediaType.TEXT_PLAIN);
- assertTrue(client.getAuthentication() instanceof NoAuthentication);
- assertFalse(client.isConnected());
- }
-
- @Test
- public void testSetMediaType() {
- client.setMediaType("xyz/uvw");
- assertEquals(client.getMediaType(), "xyz/uvw");
- }
-
- @Test
- public void testConnect() throws Exception {
- client.connect();
-
- assertTrue(client.isConnected());
- }
-
- @Test
- public void testList() throws Exception {
- List<URI> list = listOfAll();
- client.connect();
-
- assertEquals(list, client.list());
- client.setMediaType(MediaType.TEXT_OCCI);
- assertEquals(list, client.list());
- }
-
- @Test
- public void testListWithString() throws Exception {
- List<URI> list = listOfComputes();
- client.connect();
-
- assertEquals(list, client.list("compute"));
- client.setMediaType(MediaType.TEXT_OCCI);
- assertEquals(list, client.list("compute"));
- }
-
- @Test
- public void testInvalidListWithString() throws Exception {
- client.connect();
- try {
- client.list("unknown");
- } catch (CommunicationException ex) {
- //cool
- }
-
- try {
- Kind kind = new Kind(URI.create("http://different.uri.same/term/infrastructure#"), "compute");
- client.getModel().addKind(kind);
- client.list("compute");
- } catch (CommunicationException ex) {
- //cool
- }
- }
-
- @Test
- public void testListWithURI() throws Exception {
- List<URI> list = listOfComputes();
- client.connect();
-
- assertEquals(list, client.list(URI.create("http://schemas.ogf.org/occi/infrastructure#compute")));
- client.setMediaType(MediaType.TEXT_OCCI);
- assertEquals(list, client.list(URI.create("http://schemas.ogf.org/occi/infrastructure#compute")));
- }
-
- @Test
- public void testInvalidListWithURI() throws Exception {
- client.connect();
- try {
- client.list(URI.create("http://nonexisting.abc.org/icco/infrastructure#compute"));
- } catch (CommunicationException ex) {
- //cool
- }
- }
-
- private List<URI> listOfComputes() {
- List<URI> list = new ArrayList<>();
- list.add(URI.create("http://rocci-server-1-1-x.herokuapp.com:80/compute/0054b25a-ddb9-412e-869e-7b800a13aa46"));
- list.add(URI.create("http://rocci-server-1-1-x.herokuapp.com:80/compute/29ce3084-23b6-44e0-b53e-55a34b924920"));
- list.add(URI.create("http://rocci-server-1-1-x.herokuapp.com:80/compute/987654321"));
- list.add(URI.create("http://rocci-server-1-1-x.herokuapp.com:80/compute/9b36c234-7e4a-400d-bab8-58dead9e0ef8"));
- list.add(URI.create("http://rocci-server-1-1-x.herokuapp.com:80/compute/29b814ad-c5b2-4bc4-888b-470f769a2930"));
- list.add(URI.create("http://rocci-server-1-1-x.herokuapp.com:80/compute/123456789"));
-
- return list;
- }
-
- private List<URI> listOfNetworks() {
- List<URI> list = new ArrayList<>();
- list.add(URI.create("http://rocci-server-1-1-x.herokuapp.com:80/network/05940332-7926-4cf5-b1fc-7479b529524a"));
- list.add(URI.create("http://rocci-server-1-1-x.herokuapp.com:80/network/1bdff9e2-7a5d-4e87-b2e3-9a6cfb7b6619"));
- list.add(URI.create("http://rocci-server-1-1-x.herokuapp.com:80/network/24b94558-c46a-41e3-981d-16600f71cddb"));
-
- return list;
- }
-
- private List<URI> listOfStorages() {
- List<URI> list = new ArrayList<>();
- list.add(URI.create("http://rocci-server-1-1-x.herokuapp.com:80/storage/8f423fd4-0fdb-4422-a01b-fb6594173fbb"));
- list.add(URI.create("http://rocci-server-1-1-x.herokuapp.com:80/storage/1902326a-2092-4cb6-b998-6d6e73be6212"));
- list.add(URI.create("http://rocci-server-1-1-x.herokuapp.com:80/storage/a7eeebf0-a93f-4187-bd86-dab2725d5bfa"));
-
- return list;
- }
-
- private List<URI> listOfAll() {
- List<URI> list = listOfComputes();
- list.addAll(listOfNetworks());
- list.addAll(listOfStorages());
-
- return list;
- }
-
- @Test
- public void testDescribe() throws Exception {
- Set<Entity> expectedSet = new HashSet<>(descriptionOfAll());
- client.connect();
-
- Set<Entity> clientSet = new HashSet<>(client.describe());
- assertEquals(expectedSet, clientSet);
- client.setMediaType(MediaType.TEXT_OCCI);
- assertEquals(expectedSet, clientSet);
-
- }
-
- @Test
- public void testDescribeWithString() throws Exception {
- Set<Entity> expectedSet = new HashSet<>(descriptionOfComputes());
- client.connect();
-
- Set<Entity> clientSet = new HashSet<>(client.describe("compute"));
- assertEquals(expectedSet, clientSet);
- client.setMediaType(MediaType.TEXT_OCCI);
- assertEquals(expectedSet, clientSet);
- }
-
- @Test
- public void testInvalidDescribeWithString() throws Exception {
- client.connect();
- try {
- client.describe("unknown");
- } catch (CommunicationException ex) {
- //cool
- }
-
- try {
- Kind kind = new Kind(URI.create("http://different.uri.same/term/infrastructure#"), "compute");
- client.getModel().addKind(kind);
- client.describe("compute");
- } catch (CommunicationException ex) {
- //cool
- }
- }
-
- @Test
- public void testDescribeWithURI() throws Exception {
- Set<Entity> expectedSet = new HashSet<>(descriptionOfComputes());
- client.connect();
-
- Set<Entity> clientSet = new HashSet<>(client.describe(URI.create("http://schemas.ogf.org/occi/infrastructure#compute")));
- assertEquals(expectedSet, clientSet);
- client.setMediaType(MediaType.TEXT_OCCI);
- assertEquals(expectedSet, clientSet);
-
- client.setMediaType(MediaType.TEXT_PLAIN);
- expectedSet = new HashSet<>(descriptionOfSpecificCompute());
- clientSet = new HashSet<>(client.describe(URI.create("http://rocci-server-1-1-x.herokuapp.com:80/compute/9b36c234-7e4a-400d-bab8-58dead9e0ef8")));
- assertEquals(expectedSet, clientSet);
- client.setMediaType(MediaType.TEXT_OCCI);
- assertEquals(expectedSet, clientSet);
- }
-
- @Test
- public void testInvalidDescribeWithURI() throws Exception {
- client.connect();
- try {
- client.describe(URI.create("http://nonexisting.abc.org/icco/infrastructure#compute"));
- } catch (CommunicationException ex) {
- //cool
- }
-
- try {
- client.describe(URI.create("http://rocci-server-1-1-x.herokuapp.com:80/compute/nonexistent-id"));
- } catch (CommunicationException ex) {
- //cool
- }
- }
-
- private List<Entity> descriptionOfComputes() throws Exception {
- List<Entity> entities = new ArrayList<>();
- List<Attribute> computeAttributes = new ArrayList<>();
- computeAttributes.add(new Attribute(Compute.ID_ATTRIBUTE_NAME));
- computeAttributes.add(new Attribute(Compute.TITLE_ATTRIBUTE_NAME));
- computeAttributes.add(new Attribute(Compute.SUMMARY_ATTRIBUTE_NAME));
- computeAttributes.add(new Attribute(Compute.ARCHITECTURE_ATTRIBUTE_NAME));
- computeAttributes.add(new Attribute(Compute.CORES_ATTRIBUTE_NAME));
- computeAttributes.add(new Attribute(Compute.HOSTNAME_ATTRIBUTE_NAME));
- computeAttributes.add(new Attribute(Compute.MEMORY_ATTRIBUTE_NAME));
- computeAttributes.add(new Attribute(Compute.SPEED_ATTRIBUTE_NAME));
- computeAttributes.add(new Attribute(Compute.STATE_ATTRIBUTE_NAME));
- Kind compute = new Kind(URI.create("http://schemas.ogf.org/occi/infrastructure#"), "compute", "compute resource", URI.create("/compute/"), computeAttributes);
- Mixin debian6 = new Mixin(URI.create("http://occi.example.org/occi/infrastructure/os_tpl#"), "debian6", "debian", URI.create("/mixin/os_tpl/debian6/"), null);
- Mixin small = new Mixin(URI.create("http://occi.example.org/occi/infrastructure/resource_tpl#"), "small", "Small Instance - 1 core and 2 GB RAM", URI.create("/mixin/resource_tpl/small/"), null);
- Mixin sl6golden = new Mixin(URI.create("http://occi.example.org/occi/infrastructure/os_tpl#"), "sl6golden", "monitoring", URI.create("/mixin/os_tpl/sl6golden/"), null);
- Mixin mammoth = new Mixin(URI.create("http://occi.example.org/occi/infrastructure/resource_tpl#"), "mammoth", "Mammoth Instance - 8 cores and 32 GB RAM", URI.create("/mixin/resource_tpl/mammoth/"), null);
- Kind networkinterface = new Kind(URI.create("http://schemas.ogf.org/occi/infrastructure#"), "networkinterface");
-
- Compute c = new Compute("0054b25a-ddb9-412e-869e-7b800a13aa46", compute);
- c.setTitle("test_title");
- c.setArchitecture(Architecture.X_86);
- c.setCores(1);
- c.setMemory(2);
- c.setSpeed(1);
- c.setState(ComputeState.ACTIVE);
- c.addAttribute("eu.egi.fedcloud.appdb.uuid", "appdb:uuid:debian6");
- c.addMixin(debian6);
- c.addMixin(small);
- entities.add(c);
-
- c = new Compute("29ce3084-23b6-44e0-b53e-55a34b924920", compute);
- c.setTitle("fhkgf");
- c.setArchitecture(Architecture.X_86);
- c.setCores(8);
- c.setMemory(32);
- c.setSpeed(1);
- c.setState(ComputeState.ACTIVE);
- c.addAttribute("eu.egi.fedcloud.appdb.uuid", "appdb:uuid:sl6golden");
- c.addMixin(sl6golden);
- c.addMixin(mammoth);
- entities.add(c);
-
- Link link = new Link("e5f8f7bd-7d84-4c46-9a4e-325cc950f0ed", networkinterface);
- link.setTarget("http://rocci-server-1-1-x.herokuapp.com:80/network/e36ee51c-bfb6-4264-a5bf-2e71b9145b14");
- link.setRelation("http://schemas.ogf.org/occi/core#link");
- link.setSource("http://rocci-server-1-1-x.herokuapp.com:80/compute/987654321");
-
- c = new Compute("987654321", compute);
- c.setTitle("vm_test02");
- c.setArchitecture(Architecture.X_86);
- c.setCores(1);
- c.setMemory(2);
- c.setSpeed(1);
- c.setState(ComputeState.ACTIVE);
- c.addMixin(debian6);
- c.addMixin(small);
- c.addLink(link);
- entities.add(c);
-
- link = new Link("31f185d5-9379-4479-9809-b4cce6bcfdee", networkinterface);
- link.setTarget("/network/e36ee51c-bfb6-4264-a5bf-2e71b9145b14");
- link.setRelation("http://schemas.ogf.org/occi/core#link");
- link.setSource("/compute/9b36c234-7e4a-400d-bab8-58dead9e0ef8");
- link.addAttribute(NetworkInterface.INTERFACE_ATTRIBUTE_NAME, "eth0");
- link.addAttribute(NetworkInterface.MAC_ATTRIBUTE_NAME, "00:11:22:33:44:55");
- link.addAttribute(NetworkInterface.STATE_ATTRIBUTE_NAME, NetworkState.ACTIVE.toString());
-
- c = new Compute("9b36c234-7e4a-400d-bab8-58dead9e0ef8", compute);
- c.setTitle("VMTest");
- c.setArchitecture(Architecture.X_86);
- c.setCores(1);
- c.setMemory(2);
- c.setSpeed(1);
- c.setState(ComputeState.ACTIVE);
- c.addMixin(debian6);
- c.addMixin(small);
- c.addLink(link);
- entities.add(c);
-
- link = new Link("920ad837-1fa3-40a2-8810-fb8f2dc1wrt7", networkinterface);
- link.setTarget("/network/e36ee51c-bfb6-4264-a5bf-2e71b9145b14");
- link.setRelation("http://schemas.ogf.org/occi/core#link");
- link.setSource("/compute/29b814ad-c5b2-4bc4-888b-470f769a2930");
-
- c = new Compute("29b814ad-c5b2-4bc4-888b-470f769a2930", compute);
- c.setTitle("VMTest2");
- c.setArchitecture(Architecture.X_86);
- c.setCores(1);
- c.setMemory(2);
- c.setSpeed(1);
- c.setState(ComputeState.ACTIVE);
- c.addMixin(debian6);
- c.addMixin(small);
- c.addLink(link);
- entities.add(c);
-
- link = new Link("9e9aced1-a2a8-459e-8fc8-690beb3f1533", networkinterface);
- link.setTarget("/network/e36ee51c-bfb6-4264-a5bf-2e71b9145b14");
- link.setRelation("http://schemas.ogf.org/occi/core#link");
- link.setSource("/compute/123456789");
- link.addAttribute(NetworkInterface.INTERFACE_ATTRIBUTE_NAME, "eth0");
- link.addAttribute(NetworkInterface.MAC_ATTRIBUTE_NAME, "00:11:22:33:44:55");
- link.addAttribute(NetworkInterface.STATE_ATTRIBUTE_NAME, NetworkState.ACTIVE.toString());
-
- c = new Compute("123456789", compute);
- c.setTitle("vm_test01");
- c.setArchitecture(Architecture.X_86);
- c.setCores(1);
- c.setMemory(2);
- c.setSpeed(1);
- c.setState(ComputeState.ACTIVE);
- c.addMixin(debian6);
- c.addMixin(small);
- c.addLink(link);
- entities.add(c);
-
- return entities;
- }
-
- private List<Entity> descriptionOfSpecificCompute() throws Exception {
- List<Entity> entities = new ArrayList<>();
- List<Attribute> computeAttributes = new ArrayList<>();
- computeAttributes.add(new Attribute(Compute.ID_ATTRIBUTE_NAME));
- computeAttributes.add(new Attribute(Compute.TITLE_ATTRIBUTE_NAME));
- computeAttributes.add(new Attribute(Compute.SUMMARY_ATTRIBUTE_NAME));
- computeAttributes.add(new Attribute(Compute.ARCHITECTURE_ATTRIBUTE_NAME));
- computeAttributes.add(new Attribute(Compute.CORES_ATTRIBUTE_NAME));
- computeAttributes.add(new Attribute(Compute.HOSTNAME_ATTRIBUTE_NAME));
- computeAttributes.add(new Attribute(Compute.MEMORY_ATTRIBUTE_NAME));
- computeAttributes.add(new Attribute(Compute.SPEED_ATTRIBUTE_NAME));
- computeAttributes.add(new Attribute(Compute.STATE_ATTRIBUTE_NAME));
- Kind compute = new Kind(URI.create("http://schemas.ogf.org/occi/infrastructure#"), "compute", "compute resource", URI.create("/compute/"), computeAttributes);
- Mixin debian6 = new Mixin(URI.create("http://occi.example.org/occi/infrastructure/os_tpl#"), "debian6", "debian", URI.create("/mixin/os_tpl/debian6/"), null);
- Mixin small = new Mixin(URI.create("http://occi.example.org/occi/infrastructure/resource_tpl#"), "small", "Small Instance - 1 core and 2 GB RAM", URI.create("/mixin/resource_tpl/small/"), null);
- Kind networkinterface = new Kind(URI.create("http://schemas.ogf.org/occi/infrastructure#"), "networkinterface");
-
- Link link = new Link("31f185d5-9379-4479-9809-b4cce6bcfdee", networkinterface);
- link.setTarget("/network/e36ee51c-bfb6-4264-a5bf-2e71b9145b14");
- link.setRelation("http://schemas.ogf.org/occi/core#link");
- link.setSource("/compute/9b36c234-7e4a-400d-bab8-58dead9e0ef8");
- link.addAttribute(NetworkInterface.INTERFACE_ATTRIBUTE_NAME, "eth0");
- link.addAttribute(NetworkInterface.MAC_ATTRIBUTE_NAME, "00:11:22:33:44:55");
- link.addAttribute(NetworkInterface.STATE_ATTRIBUTE_NAME, NetworkState.ACTIVE.toString());
-
- Compute c = new Compute("9b36c234-7e4a-400d-bab8-58dead9e0ef8", compute);
- c.setTitle("VMTest");
- c.setArchitecture(Architecture.X_86);
- c.setCores(1);
- c.setMemory(2);
- c.setSpeed(1);
- c.setState(ComputeState.ACTIVE);
- c.addMixin(debian6);
- c.addMixin(small);
- c.addLink(link);
- entities.add(c);
-
- return entities;
- }
-
- private List<Entity> descriptionOfNetworks() throws Exception {
- List<Entity> entities = new ArrayList<>();
- List<Attribute> networkAttributes = new ArrayList<>();
- networkAttributes.add(new Attribute(Network.ID_ATTRIBUTE_NAME));
- networkAttributes.add(new Attribute(Network.STATE_ATTRIBUTE_NAME));
- Kind network = new Kind(URI.create("http://schemas.ogf.org/occi/infrastructure#"), "network", "network resource", URI.create("/network/"), networkAttributes);
-
- Network n = new Network("05940332-7926-4cf5-b1fc-7479b529524a", network);
- n.setState(NetworkState.INACTIVE);
- entities.add(n);
-
- n = new Network("1bdff9e2-7a5d-4e87-b2e3-9a6cfb7b6619", network);
- n.setState(NetworkState.INACTIVE);
- entities.add(n);
-
- n = new Network("24b94558-c46a-41e3-981d-16600f71cddb", network);
- n.setState(NetworkState.INACTIVE);
- entities.add(n);
-
- return entities;
- }
-
- private List<Entity> descriptionOfStorages() throws Exception {
- List<Entity> entities = new ArrayList<>();
- List<Attribute> storageAttributes = new ArrayList<>();
- storageAttributes.add(new Attribute(Storage.ID_ATTRIBUTE_NAME));
- storageAttributes.add(new Attribute(Storage.STATE_ATTRIBUTE_NAME));
- Kind storage = new Kind(URI.create("http://schemas.ogf.org/occi/infrastructure#"), "storage", "storage resource", URI.create("/storage/"), storageAttributes);
-
- Storage s = new Storage("1902326a-2092-4cb6-b998-6d6e73be6212", storage);
- s.setState(StorageState.OFFLINE);
- entities.add(s);
-
- s = new Storage("8f423fd4-0fdb-4422-a01b-fb6594173fbb", storage);
- s.setState(StorageState.OFFLINE);
- entities.add(s);
-
- s = new Storage("a7eeebf0-a93f-4187-bd86-dab2725d5bfa", storage);
- s.setState(StorageState.OFFLINE);
- entities.add(s);
-
- return entities;
- }
-
- private List<Entity> descriptionOfAll() throws Exception {
- List<Entity> entities = descriptionOfComputes();
- entities.addAll(descriptionOfNetworks());
- entities.addAll(descriptionOfStorages());
-
- return entities;
- }
-
- @Test
- public void testCreate() throws Exception {
- client.connect();
- Model model = client.getModel();
- EntityBuilder eb = new EntityBuilder(model);
- Resource r = eb.getResource("compute");
- r.setId("157754bb-af01-40be-853a-6a1f1b5ac500");
- r.addMixin(model.findMixin("debian6", "os_tpl"));
- r.addMixin(model.findMixin("small"));
-
- assertEquals(URI.create("http://rocci-server-1-1-x.herokuapp.com:80/compute/157754bb-af01-40be-853a-6a1f1b5ac500"), client.create(r));
- client.setMediaType(MediaType.TEXT_OCCI);
- r.setId("5537b49a-bb2e-4302-bf8b-da38611247ca");
- assertEquals(URI.create("http://rocci-server-1-1-x.herokuapp.com/compute/5537b49a-bb2e-4302-bf8b-da38611247ca"), client.create(r));
- }
-
- @Test
- public void testUpdate() throws Exception {
- client.connect();
- Model model = client.getModel();
- EntityBuilder eb = new EntityBuilder(model);
- Resource r = eb.getResource("compute");
- r.setId("157754bb-af01-40be-853a-6a1f1b5ac500");
-
- assertEquals(URI.create("http://rocci-server-1-1-x.herokuapp.com:80/compute/157754bb-af01-40be-853a-6a1f1b5ac500"), client.update(r));
- client.setMediaType(MediaType.TEXT_OCCI);
- r.setId("5537b49a-bb2e-4302-bf8b-da38611247ca");
- assertEquals(URI.create("http://rocci-server-1-1-x.herokuapp.com:80/compute/5537b49a-bb2e-4302-bf8b-da38611247ca"), client.update(r));
- }
-
- @Test
- public void testDeleteWithString() throws Exception {
- client.connect();
-
- assertTrue(client.delete("network"));
- client.setMediaType(MediaType.TEXT_OCCI);
- assertTrue(client.delete("network"));
- }
-
- @Test
- public void testInvalidDeleteWithString() throws Exception {
- client.connect();
- try {
- client.delete("unknown");
- } catch (CommunicationException ex) {
- //cool
- }
-
- try {
- Kind kind = new Kind(URI.create("http://different.uri.same/term/infrastructure#"), "network");
- client.getModel().addKind(kind);
- client.delete("network");
- } catch (CommunicationException ex) {
- //cool
- }
- }
-
- @Test
- public void testDeleteWithURI() throws Exception {
- client.connect();
-
- assertTrue(client.delete(URI.create("http://schemas.ogf.org/occi/infrastructure#storage")));
- client.setMediaType(MediaType.TEXT_OCCI);
- assertTrue(client.delete(URI.create("http://schemas.ogf.org/occi/infrastructure#storage")));
-
- client.setMediaType(MediaType.TEXT_PLAIN);
- assertTrue(client.delete(URI.create("http://rocci-server-1-1-x.herokuapp.com/compute/157754bb-af01-40be-853a-6a1f1b5ac500")));
- client.setMediaType(MediaType.TEXT_OCCI);
- assertTrue(client.delete(URI.create("http://rocci-server-1-1-x.herokuapp.com/compute/5537b49a-bb2e-4302-bf8b-da38611247ca")));
- }
-
- @Test
- public void testInvalidDeleteWithURI() throws Exception {
- client.connect();
- try {
- client.delete(URI.create("http://nonexisting.abc.org/icco/infrastructure#network"));
- } catch (CommunicationException ex) {
- //cool
- }
-
- try {
- client.delete(URI.create("http://rocci-server-1-1-x.herokuapp.com/compute/nonexisting-id"));
- } catch (CommunicationException ex) {
- //cool
- }
- }
-
- @Test
- public void testTriggerWithStringAndActionInstance() throws Exception {
- client.connect();
- Model model = client.getModel();
- EntityBuilder eb = new EntityBuilder(model);
- ActionInstance a = eb.getActionInstance("start");
-
- assertTrue(client.trigger("compute", a));
- client.setMediaType(MediaType.TEXT_OCCI);
- assertTrue(client.trigger("compute", a));
- }
-
- @Test
- public void testInvalidTriggerWithStringAndActionInstance() throws Exception {
- client.connect();
- Model model = client.getModel();
- EntityBuilder eb = new EntityBuilder(model);
- ActionInstance a = eb.getActionInstance("start");
- try {
- client.trigger("unknown", a);
- } catch (CommunicationException ex) {
- //cool
- }
-
- try {
- Kind kind = new Kind(URI.create("http://different.uri.same/term/infrastructure#"), "compute");
- model.addKind(kind);
- client.trigger("compute", a);
- } catch (CommunicationException ex) {
- //cool
- }
- }
-
- @Test
- public void testTriggerWithURIAndActionInstance() throws Exception {
- client.connect();
- Model model = client.getModel();
- EntityBuilder eb = new EntityBuilder(model);
- ActionInstance a = eb.getActionInstance("start");
-
- assertTrue(client.trigger(URI.create("http://schemas.ogf.org/occi/infrastructure#compute"), a));
- client.setMediaType(MediaType.TEXT_OCCI);
- assertTrue(client.trigger(URI.create("http://schemas.ogf.org/occi/infrastructure#compute"), a));
-
- client.setMediaType(MediaType.TEXT_PLAIN);
- assertTrue(client.trigger(URI.create("http://rocci-server-1-1-x.herokuapp.com:80/compute/29b814ad-c5b2-4bc4-888b-470f769a2930"), a));
- client.setMediaType(MediaType.TEXT_OCCI);
- assertTrue(client.trigger(URI.create("http://rocci-server-1-1-x.herokuapp.com:80/compute/29b814ad-c5b2-4bc4-888b-470f769a2930"), a));
- }
-
- @Test
- public void testInvalidTriggerWithURIAndActionInstance() throws Exception {
- client.connect();
- Model model = client.getModel();
- EntityBuilder eb = new EntityBuilder(model);
- ActionInstance a = eb.getActionInstance("start");
- try {
- client.trigger(URI.create("http://rocci-server-1-1-x.herokuapp.com/compute/nonexisting-id"), a);
- } catch (CommunicationException ex) {
- //cool
- }
-
- try {
- client.trigger(URI.create("http://nonexisting.abc.org/icco/infrastructure#network"), a);
- } catch (CommunicationException ex) {
- //cool
- }
- }
-
- @Test
- public void testRefresh() throws Exception {
- client.connect();
- Model model = client.getModel();
- Kind kind = new Kind(URI.create("http://different.uri.same/term/infrastructure#"), "network");
- model.addKind(kind);
-
- client.refresh();
- assertFalse(model.equals(client.getModel()));
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.api.http;
-
-import org.apache.http.HttpHeaders;
-import org.apache.http.message.BasicHeader;
-import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class HTTPConnectionTest {
-
- HTTPConnection con;
-
- @Before
- public void setUp() {
- con = new HTTPConnection();
- con.addHeader(new BasicHeader(HttpHeaders.AGE, "aaa"));
- con.addHeader(new BasicHeader(HttpHeaders.DEPTH, "ddd"));
- con.addHeader(new BasicHeader(HttpHeaders.FROM, "fff"));
- }
-
- @Test
- public void testGetHeaders() {
- assertEquals(3, con.getHeaders().length);
- assertEquals(HttpHeaders.AGE, con.getHeaders()[0].getName());
- assertEquals("aaa", con.getHeaders()[0].getValue());
- assertEquals(HttpHeaders.DEPTH, con.getHeaders()[1].getName());
- assertEquals("ddd", con.getHeaders()[1].getValue());
- assertEquals(HttpHeaders.FROM, con.getHeaders()[2].getName());
- assertEquals("fff", con.getHeaders()[2].getValue());
- }
-
- @Test
- public void testAddHeader() {
- con.addHeader(new BasicHeader(HttpHeaders.TE, "ttt"));
-
- assertEquals(4, con.getHeaders().length);
- assertEquals(HttpHeaders.AGE, con.getHeaders()[0].getName());
- assertEquals("aaa", con.getHeaders()[0].getValue());
- assertEquals(HttpHeaders.DEPTH, con.getHeaders()[1].getName());
- assertEquals("ddd", con.getHeaders()[1].getValue());
- assertEquals(HttpHeaders.FROM, con.getHeaders()[2].getName());
- assertEquals("fff", con.getHeaders()[2].getValue());
- assertEquals(HttpHeaders.TE, con.getHeaders()[3].getName());
- assertEquals("ttt", con.getHeaders()[3].getValue());
- }
-
- @Test
- public void testClearHeaders() {
- assertEquals(3, con.getHeaders().length);
- con.clearHeaders();
- assertEquals(0, con.getHeaders().length);
- }
-
- @Test
- public void testSetMediaType() {
- assertEquals(3, con.getHeaders().length);
- con.setMediaType("mediaType");
- assertEquals(5, con.getHeaders().length);
- assertEquals(HttpHeaders.CONTENT_TYPE, con.getHeaders()[3].getName());
- assertEquals("mediaType", con.getHeaders()[3].getValue());
- assertEquals(HttpHeaders.ACCEPT, con.getHeaders()[4].getName());
- assertEquals("mediaType", con.getHeaders()[4].getValue());
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.api.http;
-
-import java.net.URI;
-import org.apache.http.Header;
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.methods.HttpDelete;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpHead;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.protocol.HttpContext;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-import cz.cesnet.cloud.occi.api.exception.CommunicationException;
-import org.apache.http.HttpHost;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import org.junit.Rule;
-
-/**
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class HTTPHelperTest {
-
- private Header[] headers;
- private String uri;
- private URI uuri;
- private CloseableHttpClient client;
- private HttpContext context;
- private int[] statuses;
- private HttpHost target;
- private String prefix;
-
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(8123);
-
- @Before
- public void setUp() {
- headers = new Header[2];
- headers[0] = new BasicHeader(HttpHeaders.ACCEPT, "text/plain");
- headers[1] = new BasicHeader(HttpHeaders.CONTENT_TYPE, "text/plain");
- uri = "/some/path";
- uuri = URI.create(uri);
- client = HttpClients.createDefault();
- context = HttpClientContext.create();
- statuses = new int[]{HttpStatus.SC_ACCEPTED};
- target = new HttpHost("localhost", 8123, "http");
- prefix = "/prefix";
- }
-
- @Test
- public void testPrepareGetWithStringAndHeaders() {
- HttpGet message = HTTPHelper.prepareGet(uri, headers, "");
-
- assertArrayEquals(headers, message.getAllHeaders());
- assertEquals(uri, message.getURI().toString());
- }
-
- @Test
- public void testPrepareGetWithString() {
- HttpGet message = HTTPHelper.prepareGet(uri);
-
- assertEquals(0, message.getAllHeaders().length);
- assertEquals(uri, message.getURI().toString());
- }
-
- @Test
- public void testPrepareHeadWithStringAndHeaders() {
- HttpHead message = HTTPHelper.prepareHead(uri, headers, prefix);
-
- assertArrayEquals(headers, message.getAllHeaders());
- assertEquals(prefix + uri, message.getURI().toString());
- }
-
- @Test
- public void testPrepareHeadWithString() {
- HttpHead message = HTTPHelper.prepareHead(uri);
-
- assertEquals(0, message.getAllHeaders().length);
- assertEquals(uri, message.getURI().toString());
- }
-
- @Test
- public void testPrepareGetWithURIAndHeaders() {
- HttpGet message = HTTPHelper.prepareGet(uuri, headers, "");
-
- assertArrayEquals(headers, message.getAllHeaders());
- assertEquals(uuri, message.getURI());
- }
-
- @Test
- public void testPrepareGetWithURI() {
- HttpGet message = HTTPHelper.prepareGet(uuri);
-
- assertEquals(0, message.getAllHeaders().length);
- assertEquals(uuri, message.getURI());
- }
-
- @Test
- public void testPrepareHeadWithURIAndHeaders() {
- HttpHead message = HTTPHelper.prepareHead(uuri, headers, prefix);
-
- assertArrayEquals(headers, message.getAllHeaders());
- assertEquals(prefix + uuri, message.getURI().toString());
- }
-
- @Test
- public void testPrepareHeadWithURI() {
- HttpHead message = HTTPHelper.prepareHead(uuri);
-
- assertEquals(0, message.getAllHeaders().length);
- assertEquals(uuri, message.getURI());
- }
-
- @Test
- public void testPrepareDeleteWithStringAndHeaders() {
- HttpDelete message = HTTPHelper.prepareDelete(uri, headers, "");
-
- assertArrayEquals(headers, message.getAllHeaders());
- assertEquals(uri, message.getURI().toString());
- }
-
- @Test
- public void testPrepareDeleteWithString() {
- HttpDelete message = HTTPHelper.prepareDelete(uri);
-
- assertEquals(0, message.getAllHeaders().length);
- assertEquals(uri, message.getURI().toString());
- }
-
- @Test
- public void testPrepareDeleteWithURIAndHeaders() {
- HttpDelete message = HTTPHelper.prepareDelete(uuri, headers, prefix);
-
- assertArrayEquals(headers, message.getAllHeaders());
- assertEquals(prefix + uuri, message.getURI().toString());
- }
-
- @Test
- public void testPrepareDeleteWithURI() {
- HttpDelete message = HTTPHelper.prepareDelete(uuri);
-
- assertEquals(0, message.getAllHeaders().length);
- assertEquals(uuri, message.getURI());
- }
-
- @Test
- public void testPreparePostWithStringAndHeaders() {
- HttpPost message = HTTPHelper.preparePost(uri, headers, "");
-
- assertArrayEquals(headers, message.getAllHeaders());
- assertEquals(uri, message.getURI().toString());
- }
-
- @Test
- public void testPreparePostWithString() {
- HttpPost message = HTTPHelper.preparePost(uri);
-
- assertEquals(0, message.getAllHeaders().length);
- assertEquals(uri, message.getURI().toString());
- }
-
- @Test
- public void testPreparePostWithURIAndHeaders() {
- HttpPost message = HTTPHelper.preparePost(uuri, headers, prefix);
-
- assertArrayEquals(headers, message.getAllHeaders());
- assertEquals(prefix + uuri, message.getURI().toString());
- }
-
- @Test
- public void testPreparePostWithURI() {
- HttpPost message = HTTPHelper.preparePost(uuri);
-
- assertEquals(0, message.getAllHeaders().length);
- assertEquals(uuri, message.getURI());
- }
-
- @Test
- public void testRunRequestWithStatus() throws Exception {
- HttpRequest httpRequest = HTTPHelper.prepareGet("/differentcode/", headers, "");
- CloseableHttpResponse response = HTTPHelper.runRequest(httpRequest, target, client, context, statuses);
-
- assertNotNull(response);
- assertEquals(HttpStatus.SC_ACCEPTED, response.getStatusLine().getStatusCode());
- }
-
- @Test
- public void testInvalidRunRequestWithStatus() throws Exception {
- HttpRequest httpRequest = HTTPHelper.prepareGet("/xyz/", headers, "");
- try {
- CloseableHttpResponse response = HTTPHelper.runRequest(httpRequest, target, client, context, statuses);
- } catch (CommunicationException ex) {
- //cool
- }
-
- target = new HttpHost("nonexisting", 8123, "http");
- try {
- CloseableHttpResponse response = HTTPHelper.runRequest(httpRequest, target, client, context, statuses);
- } catch (CommunicationException ex) {
- //cool
- }
- }
-
- @Test
- public void testRunRequestWithoutStatus() throws Exception {
- HttpRequest httpRequest = HTTPHelper.prepareGet("/", headers, "");
- CloseableHttpResponse response = HTTPHelper.runRequest(httpRequest, target, client, context);
-
- assertNotNull(response);
- assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
- }
-
- @Test
- public void testInvalidRunRequestWithoutStatus() throws Exception {
- HttpRequest httpRequest = HTTPHelper.prepareGet("/xyz/", headers, "");
- try {
- CloseableHttpResponse response = HTTPHelper.runRequest(httpRequest, target, client, context);
- } catch (CommunicationException ex) {
- //cool
- }
-
- target = new HttpHost("nonexisting", 8123, "http");
- try {
- CloseableHttpResponse response = HTTPHelper.runRequest(httpRequest, target, client, context);
- } catch (CommunicationException ex) {
- //cool
- }
- }
-
- @Test
- public void testRunRequestForStatusWithStatus() throws Exception {
- HttpRequest httpRequest = HTTPHelper.prepareGet("/differentcode/", headers, "");
- boolean isOk = HTTPHelper.runRequestForStatus(httpRequest, target, client, context, statuses);
- assertTrue(isOk);
-
- httpRequest = HTTPHelper.prepareGet("/", headers, "");
- isOk = HTTPHelper.runRequestForStatus(httpRequest, target, client, context, statuses);
- assertFalse(isOk);
- }
-
- @Test
- public void testRunRequestForStatusWithoutStatus() throws Exception {
- HttpRequest httpRequest = HTTPHelper.prepareGet("/", headers, "");
- boolean isOk = HTTPHelper.runRequestForStatus(httpRequest, target, client, context);
- assertTrue(isOk);
-
- httpRequest = HTTPHelper.prepareGet("/differentcode/", headers, "");
- isOk = HTTPHelper.runRequestForStatus(httpRequest, target, client, context);
- assertFalse(isOk);
- }
-}
+++ /dev/null
-X-OCCI-Location: http://rocci-server-1-1-x.herokuapp.com:80/compute/0054b25a-ddb9-412e-869e-7b800a13aa46
-X-OCCI-Location: http://rocci-server-1-1-x.herokuapp.com:80/compute/29ce3084-23b6-44e0-b53e-55a34b924920
-X-OCCI-Location: http://rocci-server-1-1-x.herokuapp.com:80/compute/987654321
-X-OCCI-Location: http://rocci-server-1-1-x.herokuapp.com:80/compute/9b36c234-7e4a-400d-bab8-58dead9e0ef8
-X-OCCI-Location: http://rocci-server-1-1-x.herokuapp.com:80/compute/29b814ad-c5b2-4bc4-888b-470f769a2930
-X-OCCI-Location: http://rocci-server-1-1-x.herokuapp.com:80/compute/123456789
-X-OCCI-Location: http://rocci-server-1-1-x.herokuapp.com:80/network/05940332-7926-4cf5-b1fc-7479b529524a
-X-OCCI-Location: http://rocci-server-1-1-x.herokuapp.com:80/network/1bdff9e2-7a5d-4e87-b2e3-9a6cfb7b6619
-X-OCCI-Location: http://rocci-server-1-1-x.herokuapp.com:80/network/24b94558-c46a-41e3-981d-16600f71cddb
-X-OCCI-Location: http://rocci-server-1-1-x.herokuapp.com:80/storage/8f423fd4-0fdb-4422-a01b-fb6594173fbb
-X-OCCI-Location: http://rocci-server-1-1-x.herokuapp.com:80/storage/1902326a-2092-4cb6-b998-6d6e73be6212
-X-OCCI-Location: http://rocci-server-1-1-x.herokuapp.com:80/storage/a7eeebf0-a93f-4187-bd86-dab2725d5bfa
\ No newline at end of file
+++ /dev/null
-Category: entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="entity";location="/entity/";attributes="occi.core.id{immutable required} occi.core.title"
-Category: resource;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="resource";rel="http://schemas.ogf.org/occi/core#entity";location="/resource/";attributes="occi.core.id{immutable required} occi.core.title occi.core.summary"
-Category: link;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="link";rel="http://schemas.ogf.org/occi/core#entity";location="/link/";attributes="occi.core.id{immutable required} occi.core.title occi.core.target occi.core.source{required}"
-Category: compute;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";title="compute resource";rel="http://schemas.ogf.org/occi/core#resource";location="/compute/";attributes="occi.core.id{immutable required} occi.core.title occi.core.summary occi.compute.architecture occi.compute.cores occi.compute.hostname occi.compute.memory occi.compute.speed occi.compute.state{immutable}";actions="http://schemas.ogf.org/occi/infrastructure/compute/action#start http://schemas.ogf.org/occi/infrastructure/compute/action#stop http://schemas.ogf.org/occi/infrastructure/compute/action#restart http://schemas.ogf.org/occi/infrastructure/compute/action#suspend"
-Category: storage;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";title="storage resource";rel="http://schemas.ogf.org/occi/core#resource";location="/storage/";attributes="occi.core.id{immutable required} occi.core.title occi.core.summary occi.storage.size occi.storage.state";actions="http://schemas.ogf.org/occi/infrastructure/storage/action#online http://schemas.ogf.org/occi/infrastructure/storage/action#offline http://schemas.ogf.org/occi/infrastructure/storage/action#backup http://schemas.ogf.org/occi/infrastructure/storage/action#snapshot http://schemas.ogf.org/occi/infrastructure/storage/action#resize"
-Category: network;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";title="network resource";rel="http://schemas.ogf.org/occi/core#resource";location="/network/";attributes="occi.core.id{immutable required} occi.core.title occi.core.summary occi.network.vlan occi.network.label occi.network.state{immutable}";actions="http://schemas.ogf.org/occi/infrastructure/network/action#up http://schemas.ogf.org/occi/infrastructure/network/action#down"
-Category: networkinterface;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";title="networkinterface link";rel="http://schemas.ogf.org/occi/core#link";location="/link/networkinterface/";attributes="occi.core.id{immutable required} occi.core.title occi.core.target occi.core.source{required} occi.networkinterface.interface{immutable} occi.networkinterface.mac occi.networkinterface.state{immutable}";actions="http://schemas.ogf.org/occi/infrastructure/networkinterface/action#up http://schemas.ogf.org/occi/infrastructure/networkinterface/action#down"
-Category: storagelink;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";title="storage link";rel="http://schemas.ogf.org/occi/core#link";location="/link/storagelink/";attributes="occi.core.id{immutable required} occi.core.title occi.core.target occi.core.source{required} occi.storagelink.deviceid occi.storagelink.mountpoint occi.storagelink.state{immutable}";actions="http://schemas.ogf.org/occi/infrastructure/storagelink/action#online http://schemas.ogf.org/occi/infrastructure/storagelink/action#offline"
-Category: resource_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin";title="resource template";location="/mixin/resource_tpl/"
-Category: os_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin";title="operating system template";location="/mixin/os_tpl/"
-Category: ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure/network#";class="mixin";title="IP network mixin";location="/mixin/ipnetwork/";attributes="occi.network.address occi.network.gateway occi.network.allocation"
-Category: ipnetworkinterface;scheme="http://schemas.ogf.org/occi/infrastructure/networkinterface#";class="mixin";title="IP network interface mixin";location="/mixin/ipnetworkinterface/";attributes="occi.networkinterface.address occi.networkinterface.gateway occi.networkinterface.allocation"
-Category: debian6;scheme="http://occi.example.org/occi/infrastructure/os_tpl#";class="mixin";title="debian";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl";location="/mixin/os_tpl/debian6/";attributes="eu.egi.fedcloud.appdb.uuid{immutable required}"
-Category: sl6golden;scheme="http://occi.example.org/occi/infrastructure/os_tpl#";class="mixin";title="monitoring";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl";location="/mixin/os_tpl/sl6golden/";attributes="eu.egi.fedcloud.appdb.uuid{immutable required}"
-Category: goliath;scheme="http://occi.example.org/occi/infrastructure/resource_tpl#";class="mixin";title="Goliath Instance - 16 cores and 64 GB RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl";location="/mixin/resource_tpl/goliath/";attributes="occi.compute.architecture{immutable} occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable}"
-Category: mammoth;scheme="http://occi.example.org/occi/infrastructure/resource_tpl#";class="mixin";title="Mammoth Instance - 8 cores and 32 GB RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl";location="/mixin/resource_tpl/mammoth/";attributes="occi.compute.architecture{immutable} occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable}"
-Category: extra_large;scheme="http://occi.example.org/occi/infrastructure/resource_tpl#";class="mixin";title="Extra Large Instance - 4 cores and 16 GB RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl";location="/mixin/resource_tpl/extra_large/";attributes="occi.compute.architecture{immutable} occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable}"
-Category: large;scheme="http://occi.example.org/occi/infrastructure/resource_tpl#";class="mixin";title="Large Instance - 4 cores and 8 GB RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl";location="/mixin/resource_tpl/large/";attributes="occi.compute.architecture{immutable} occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable}"
-Category: medium;scheme="http://occi.example.org/occi/infrastructure/resource_tpl#";class="mixin";title="Medium Instance - 2 cores and 4 GB RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl";location="/mixin/resource_tpl/medium/";attributes="occi.compute.architecture occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable}"
-Category: small;scheme="http://occi.example.org/occi/infrastructure/resource_tpl#";class="mixin";title="Small Instance - 1 core and 2 GB RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl";location="/mixin/resource_tpl/small/";attributes="occi.compute.architecture occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable}"
-Category: start;scheme="http://schemas.ogf.org/occi/infrastructure/compute/action#";class="action";title="start compute instance"
-Category: stop;scheme="http://schemas.ogf.org/occi/infrastructure/compute/action#";class="action";title="stop compute instance";attributes="method"
-Category: restart;scheme="http://schemas.ogf.org/occi/infrastructure/compute/action#";class="action";title="restart compute instance";attributes="method"
-Category: suspend;scheme="http://schemas.ogf.org/occi/infrastructure/compute/action#";class="action";title="suspend compute instance";attributes="method"
-Category: online;scheme="http://schemas.ogf.org/occi/infrastructure/storage/action#";class="action";title="activate storage"
-Category: offline;scheme="http://schemas.ogf.org/occi/infrastructure/storage/action#";class="action";title="deactivate storage"
-Category: backup;scheme="http://schemas.ogf.org/occi/infrastructure/storage/action#";class="action";title="backup storage"
-Category: snapshot;scheme="http://schemas.ogf.org/occi/infrastructure/storage/action#";class="action";title="snapshot storage"
-Category: resize;scheme="http://schemas.ogf.org/occi/infrastructure/storage/action#";class="action";title="resize storage";attributes="size{required}"
-Category: up;scheme="http://schemas.ogf.org/occi/infrastructure/network/action#";class="action";title="activate network"
-Category: down;scheme="http://schemas.ogf.org/occi/infrastructure/network/action#";class="action";title="deactivate network"
-Category: up;scheme="http://schemas.ogf.org/occi/infrastructure/networkinterface/action#";class="action";title="activate networkinterface"
-Category: down;scheme="http://schemas.ogf.org/occi/infrastructure/networkinterface/action#";class="action";title="deactivate networkinterface"
-Category: online;scheme="http://schemas.ogf.org/occi/infrastructure/storagelink/action#";class="action";title="activate storagelink"
-Category: offline;scheme="http://schemas.ogf.org/occi/infrastructure/storagelink/action#";class="action";title="deactivate storagelink"
+++ /dev/null
-Category: compute;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";location="/compute/";title="compute resource"
-Category: debian6;scheme="http://occi.example.org/occi/infrastructure/os_tpl#";class="mixin";location="/mixin/os_tpl/debian6/";title="debian"
-Category: small;scheme="http://occi.example.org/occi/infrastructure/resource_tpl#";class="mixin";location="/mixin/resource_tpl/small/";title="Small Instance - 1 core and 2 GB RAM"
-X-OCCI-Attribute: occi.core.id="0054b25a-ddb9-412e-869e-7b800a13aa46"
-X-OCCI-Attribute: occi.core.title="test_title"
-X-OCCI-Attribute: occi.compute.architecture="x86"
-X-OCCI-Attribute: occi.compute.cores=1
-X-OCCI-Attribute: occi.compute.memory=2
-X-OCCI-Attribute: occi.compute.speed=1
-X-OCCI-Attribute: occi.compute.state="active"
-X-OCCI-Attribute: eu.egi.fedcloud.appdb.uuid="appdb:uuid:debian6"
\ No newline at end of file
+++ /dev/null
-X-OCCI-Location: http://rocci-server-1-1-x.herokuapp.com:80/compute/157754bb-af01-40be-853a-6a1f1b5ac500
\ No newline at end of file
+++ /dev/null
-X-OCCI-Location: http://rocci-server-1-1-x.herokuapp.com:80/compute/0054b25a-ddb9-412e-869e-7b800a13aa46
-X-OCCI-Location: http://rocci-server-1-1-x.herokuapp.com:80/compute/29ce3084-23b6-44e0-b53e-55a34b924920
-X-OCCI-Location: http://rocci-server-1-1-x.herokuapp.com:80/compute/987654321
-X-OCCI-Location: http://rocci-server-1-1-x.herokuapp.com:80/compute/9b36c234-7e4a-400d-bab8-58dead9e0ef8
-X-OCCI-Location: http://rocci-server-1-1-x.herokuapp.com:80/compute/29b814ad-c5b2-4bc4-888b-470f769a2930
-X-OCCI-Location: http://rocci-server-1-1-x.herokuapp.com:80/compute/123456789
\ No newline at end of file
+++ /dev/null
-Category: compute;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";location="/compute/";title="compute resource"
-Category: debian6;scheme="http://occi.example.org/occi/infrastructure/os_tpl#";class="mixin";location="/mixin/os_tpl/debian6/";title="debian"
-Category: small;scheme="http://occi.example.org/occi/infrastructure/resource_tpl#";class="mixin";location="/mixin/resource_tpl/small/";title="Small Instance - 1 core and 2 GB RAM"
-X-OCCI-Attribute: occi.core.id="123456789"
-X-OCCI-Attribute: occi.core.title="vm_test01"
-X-OCCI-Attribute: occi.compute.architecture="x86"
-X-OCCI-Attribute: occi.compute.cores=1
-X-OCCI-Attribute: occi.compute.hostname="vm_test01"
-X-OCCI-Attribute: occi.compute.memory=2
-X-OCCI-Attribute: occi.compute.speed=1
-X-OCCI-Attribute: occi.compute.state="active"
-Link: </network/e36ee51c-bfb6-4264-a5bf-2e71b9145b14>;rel="http://schemas.ogf.org/occi/core#link";self="/link/networkinterface/9e9aced1-a2a8-459e-8fc8-690beb3f1533";category="http://schemas.ogf.org/occi/infrastructure#networkinterface";occi.core.id="9e9aced1-a2a8-459e-8fc8-690beb3f1533";occi.core.target="/network/e36ee51c-bfb6-4264-a5bf-2e71b9145b14";occi.core.source="/compute/123456789";occi.networkinterface.interface="eth0";occi.networkinterface.mac="00:11:22:33:44:55";occi.networkinterface.state="active"
\ No newline at end of file
+++ /dev/null
-X-OCCI-Location: http://rocci-server-1-1-x.herokuapp.com:80/compute/157754bb-af01-40be-853a-6a1f1b5ac500
+++ /dev/null
-Category: compute;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";location="/compute/";title="compute resource"
-Category: debian6;scheme="http://occi.example.org/occi/infrastructure/os_tpl#";class="mixin";location="/mixin/os_tpl/debian6/";title="debian"
-Category: small;scheme="http://occi.example.org/occi/infrastructure/resource_tpl#";class="mixin";location="/mixin/resource_tpl/small/";title="Small Instance - 1 core and 2 GB RAM"
-X-OCCI-Attribute: occi.core.id="29b814ad-c5b2-4bc4-888b-470f769a2930"
-X-OCCI-Attribute: occi.core.title="VMTest2"
-X-OCCI-Attribute: occi.compute.architecture="x86"
-X-OCCI-Attribute: occi.compute.cores=1
-X-OCCI-Attribute: occi.compute.hostname="VMTest2"
-X-OCCI-Attribute: occi.compute.memory=2
-X-OCCI-Attribute: occi.compute.speed=1
-X-OCCI-Attribute: occi.compute.state="active"
-Link: </network/e36ee51c-bfb6-4264-a5bf-2e71b9145b14>;rel="http://schemas.ogf.org/occi/core#link";self="/link/networkinterface/920ad837-1fa3-40a2-8810-fb8f2dc1wrt7";category="http://schemas.ogf.org/occi/infrastructure#networkinterface";occi.core.id="920ad837-1fa3-40a2-8810-fb8f2dc1wrt7";occi.core.target="/network/e36ee51c-bfb6-4264-a5bf-2e71b9145b14";occi.core.source="/compute/29b814ad-c5b2-4bc4-888b-470f769a2930"
\ No newline at end of file
+++ /dev/null
-Category: compute;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";location="/compute/";title="compute resource"
-Category: sl6golden;scheme="http://occi.example.org/occi/infrastructure/os_tpl#";class="mixin";location="/mixin/os_tpl/sl6golden/";title="monitoring"
-Category: mammoth;scheme="http://occi.example.org/occi/infrastructure/resource_tpl#";class="mixin";location="/mixin/resource_tpl/mammoth/";title="Mammoth Instance - 8 cores and 32 GB RAM"
-X-OCCI-Attribute: occi.core.id="29ce3084-23b6-44e0-b53e-55a34b924920"
-X-OCCI-Attribute: occi.core.title="fhkgf"
-X-OCCI-Attribute: occi.compute.architecture="x64"
-X-OCCI-Attribute: occi.compute.cores=8
-X-OCCI-Attribute: occi.compute.memory=32
-X-OCCI-Attribute: occi.compute.speed=1
-X-OCCI-Attribute: occi.compute.state="active"
-X-OCCI-Attribute: eu.egi.fedcloud.appdb.uuid="appdb:uuid:sl6golden"
\ No newline at end of file
+++ /dev/null
-X-OCCI-Location: http://rocci-server-1-1-x.herokuapp.com:80/compute/5537b49a-bb2e-4302-bf8b-da38611247ca
+++ /dev/null
-Category: compute;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";location="/compute/";title="compute resource"
-Category: debian6;scheme="http://occi.example.org/occi/infrastructure/os_tpl#";class="mixin";location="/mixin/os_tpl/debian6/";title="debian"
-Category: small;scheme="http://occi.example.org/occi/infrastructure/resource_tpl#";class="mixin";location="/mixin/resource_tpl/small/";title="Small Instance - 1 core and 2 GB RAM"
-X-OCCI-Attribute: occi.core.id="987654321"
-X-OCCI-Attribute: occi.core.title="vm_test02"
-X-OCCI-Attribute: occi.compute.architecture="x86"
-X-OCCI-Attribute: occi.compute.cores=1
-X-OCCI-Attribute: occi.compute.hostname="vm_test02"
-X-OCCI-Attribute: occi.compute.memory=2
-X-OCCI-Attribute: occi.compute.speed=1
-X-OCCI-Attribute: occi.compute.state="active"
-Link: <http://rocci-server-1-1-x.herokuapp.com:80/network/e36ee51c-bfb6-4264-a5bf-2e71b9145b14>;rel="http://schemas.ogf.org/occi/core#link";self="/link/networkinterface/e5f8f7bd-7d84-4c46-9a4e-325cc950f0ed";category="http://schemas.ogf.org/occi/infrastructure#networkinterface";occi.core.id="e5f8f7bd-7d84-4c46-9a4e-325cc950f0ed";occi.core.target="http://rocci-server-1-1-x.herokuapp.com:80/network/e36ee51c-bfb6-4264-a5bf-2e71b9145b14";occi.core.source="http://rocci-server-1-1-x.herokuapp.com:80/compute/987654321"
\ No newline at end of file
+++ /dev/null
-Category: compute;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";location="/compute/";title="compute resource"
-Category: debian6;scheme="http://occi.example.org/occi/infrastructure/os_tpl#";class="mixin";location="/mixin/os_tpl/debian6/";title="debian"
-Category: small;scheme="http://occi.example.org/occi/infrastructure/resource_tpl#";class="mixin";location="/mixin/resource_tpl/small/";title="Small Instance - 1 core and 2 GB RAM"
-X-OCCI-Attribute: occi.core.id="9b36c234-7e4a-400d-bab8-58dead9e0ef8"
-X-OCCI-Attribute: occi.core.title="VMTest"
-X-OCCI-Attribute: occi.compute.architecture="x86"
-X-OCCI-Attribute: occi.compute.cores=1
-X-OCCI-Attribute: occi.compute.hostname="VMTest"
-X-OCCI-Attribute: occi.compute.memory=2
-X-OCCI-Attribute: occi.compute.speed=1
-X-OCCI-Attribute: occi.compute.state="active"
-Link: </network/e36ee51c-bfb6-4264-a5bf-2e71b9145b14>;rel="http://schemas.ogf.org/occi/core#link";self="/link/networkinterface/31f185d5-9379-4479-9809-b4cce6bcfdee";category="http://schemas.ogf.org/occi/infrastructure#networkinterface";occi.core.id="31f185d5-9379-4479-9809-b4cce6bcfdee";occi.core.target="/network/e36ee51c-bfb6-4264-a5bf-2e71b9145b14";occi.core.source="/compute/9b36c234-7e4a-400d-bab8-58dead9e0ef8";occi.networkinterface.interface="eth0";occi.networkinterface.mac="00:11:22:33:44:55";occi.networkinterface.state="active"
\ No newline at end of file
+++ /dev/null
-OK
\ No newline at end of file
+++ /dev/null
-Category: network;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";location="/network/";title="network resource"
-X-OCCI-Attribute: occi.core.id="05940332-7926-4cf5-b1fc-7479b529524a"
-X-OCCI-Attribute: occi.network.state="inactive"
\ No newline at end of file
+++ /dev/null
-Category: network;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";location="/network/";title="network resource"
-X-OCCI-Attribute: occi.core.id="1bdff9e2-7a5d-4e87-b2e3-9a6cfb7b6619"
-X-OCCI-Attribute: occi.network.state="inactive"
\ No newline at end of file
+++ /dev/null
-Category: network;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";location="/network/";title="network resource"
-X-OCCI-Attribute: occi.core.id="24b94558-c46a-41e3-981d-16600f71cddb"
-X-OCCI-Attribute: occi.network.state="inactive"
\ No newline at end of file
+++ /dev/null
-Category: storage;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";location="/storage/";title="storage resource"
-X-OCCI-Attribute: occi.core.id="1902326a-2092-4cb6-b998-6d6e73be6212"
-X-OCCI-Attribute: occi.storage.state="offline"
\ No newline at end of file
+++ /dev/null
-Category: storage;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";location="/storage/";title="storage resource"
-X-OCCI-Attribute: occi.core.id="8f423fd4-0fdb-4422-a01b-fb6594173fbb"
-X-OCCI-Attribute: occi.storage.state="offline"
\ No newline at end of file
+++ /dev/null
-Category: storage;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";location="/storage/";title="storage resource"
-X-OCCI-Attribute: occi.core.id="a7eeebf0-a93f-4187-bd86-dab2725d5bfa"
-X-OCCI-Attribute: occi.storage.state="offline"
\ No newline at end of file
+++ /dev/null
-# Root logger option
-log4j.rootLogger=INFO, stdout
-
-# Redirect log messages to console
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.Target=System.out
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
-
+++ /dev/null
-{
- "request" : {
- "url" : "/",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/occi"
- },
- "Accept" : {
- "equalTo" : "text/occi"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-(root)-E94qA.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Location" : "http://rocci-server-1-1-x.herokuapp.com:80/compute/0054b25a-ddb9-412e-869e-7b800a13aa46,http://rocci-server-1-1-x.herokuapp.com:80/compute/29ce3084-23b6-44e0-b53e-55a34b924920,http://rocci-server-1-1-x.herokuapp.com:80/compute/987654321,http://rocci-server-1-1-x.herokuapp.com:80/compute/9b36c234-7e4a-400d-bab8-58dead9e0ef8,http://rocci-server-1-1-x.herokuapp.com:80/compute/29b814ad-c5b2-4bc4-888b-470f769a2930,http://rocci-server-1-1-x.herokuapp.com:80/compute/123456789,http://rocci-server-1-1-x.herokuapp.com:80/network/05940332-7926-4cf5-b1fc-7479b529524a,http://rocci-server-1-1-x.herokuapp.com:80/network/1bdff9e2-7a5d-4e87-b2e3-9a6cfb7b6619,http://rocci-server-1-1-x.herokuapp.com:80/network/24b94558-c46a-41e3-981d-16600f71cddb,http://rocci-server-1-1-x.herokuapp.com:80/storage/8f423fd4-0fdb-4422-a01b-fb6594173fbb,http://rocci-server-1-1-x.herokuapp.com:80/storage/1902326a-2092-4cb6-b998-6d6e73be6212,http://rocci-server-1-1-x.herokuapp.com:80/storage/a7eeebf0-a93f-4187-bd86-dab2725d5bfa",
- "Content-Type" : "text/occi; charset=utf-8",
- "Cache-Control" : "no-cache",
- "X-Request-Id" : "8a4ba6f1-9bb6-4a1b-89fb-bc52787aae58",
- "X-Runtime" : "0.600644",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 09:05:20 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/plain"
- },
- "Accept" : {
- "equalTo" : "text/plain"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-(root)-Gshly.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/plain; charset=utf-8",
- "Etag" : "\"132f9df32f84af7727f20a929cc4dfb2\"",
- "Cache-Control" : "max-age=0, private, must-revalidate",
- "X-Request-Id" : "5a7a37e1-d179-4e12-a291-59a967e517ef",
- "X-Runtime" : "0.483129",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 08:57:21 GMT",
- "Content-Length" : "1205",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/-/",
- "method" : "HEAD",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/occi"
- },
- "Accept" : {
- "equalTo" : "text/occi"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body---KvCEW.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Category" : "entity;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\";title=\"entity\";location=\"/entity/\";attributes=\"occi.core.id{immutable required} occi.core.title\",resource;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\";title=\"resource\";rel=\"http://schemas.ogf.org/occi/core#entity\";location=\"/resource/\";attributes=\"occi.core.id{immutable required} occi.core.title occi.core.summary\",link;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\";title=\"link\";rel=\"http://schemas.ogf.org/occi/core#entity\";location=\"/link/\";attributes=\"occi.core.id{immutable required} occi.core.title occi.core.target occi.core.source{required}\",compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";title=\"compute resource\";rel=\"http://schemas.ogf.org/occi/core#resource\";location=\"/compute/\";attributes=\"occi.core.id{immutable required} occi.core.title occi.core.summary occi.compute.architecture occi.compute.cores occi.compute.hostname occi.compute.memory occi.compute.speed occi.compute.state{immutable}\";actions=\"http://schemas.ogf.org/occi/infrastructure/compute/action#start http://schemas.ogf.org/occi/infrastructure/compute/action#stop http://schemas.ogf.org/occi/infrastructure/compute/action#restart http://schemas.ogf.org/occi/infrastructure/compute/action#suspend\",storage;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";title=\"storage resource\";rel=\"http://schemas.ogf.org/occi/core#resource\";location=\"/storage/\";attributes=\"occi.core.id{immutable required} occi.core.title occi.core.summary occi.storage.size occi.storage.state\";actions=\"http://schemas.ogf.org/occi/infrastructure/storage/action#online http://schemas.ogf.org/occi/infrastructure/storage/action#offline http://schemas.ogf.org/occi/infrastructure/storage/action#backup http://schemas.ogf.org/occi/infrastructure/storage/action#snapshot http://schemas.ogf.org/occi/infrastructure/storage/action#resize\",network;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";title=\"network resource\";rel=\"http://schemas.ogf.org/occi/core#resource\";location=\"/network/\";attributes=\"occi.core.id{immutable required} occi.core.title occi.core.summary occi.network.vlan occi.network.label occi.network.state{immutable}\";actions=\"http://schemas.ogf.org/occi/infrastructure/network/action#up http://schemas.ogf.org/occi/infrastructure/network/action#down\",networkinterface;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";title=\"networkinterface link\";rel=\"http://schemas.ogf.org/occi/core#link\";location=\"/link/networkinterface/\";attributes=\"occi.core.id{immutable required} occi.core.title occi.core.target occi.core.source{required} occi.networkinterface.interface{immutable} occi.networkinterface.mac occi.networkinterface.state{immutable}\";actions=\"http://schemas.ogf.org/occi/infrastructure/networkinterface/action#up http://schemas.ogf.org/occi/infrastructure/networkinterface/action#down\",storagelink;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";title=\"storage link\";rel=\"http://schemas.ogf.org/occi/core#link\";location=\"/link/storagelink/\";attributes=\"occi.core.id{immutable required} occi.core.title occi.core.target occi.core.source{required} occi.storagelink.deviceid occi.storagelink.mountpoint occi.storagelink.state{immutable}\";actions=\"http://schemas.ogf.org/occi/infrastructure/storagelink/action#online http://schemas.ogf.org/occi/infrastructure/storagelink/action#offline\",resource_tpl;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"mixin\";title=\"resource template\";location=\"/mixin/resource_tpl/\",os_tpl;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"mixin\";title=\"operating system template\";location=\"/mixin/os_tpl/\",ipnetwork;scheme=\"http://schemas.ogf.org/occi/infrastructure/network#\";class=\"mixin\";title=\"IP network mixin\";location=\"/mixin/ipnetwork/\";attributes=\"occi.network.address occi.network.gateway occi.network.allocation\",ipnetworkinterface;scheme=\"http://schemas.ogf.org/occi/infrastructure/networkinterface#\";class=\"mixin\";title=\"IP network interface mixin\";location=\"/mixin/ipnetworkinterface/\";attributes=\"occi.networkinterface.address occi.networkinterface.gateway occi.networkinterface.allocation\",debian6;scheme=\"http://occi.example.org/occi/infrastructure/os_tpl#\";class=\"mixin\";title=\"debian\";rel=\"http://schemas.ogf.org/occi/infrastructure#os_tpl\";location=\"/mixin/os_tpl/debian6/\";attributes=\"eu.egi.fedcloud.appdb.uuid{immutable required}\",sl6golden;scheme=\"http://occi.example.org/occi/infrastructure/os_tpl#\";class=\"mixin\";title=\"monitoring\";rel=\"http://schemas.ogf.org/occi/infrastructure#os_tpl\";location=\"/mixin/os_tpl/sl6golden/\";attributes=\"eu.egi.fedcloud.appdb.uuid{immutable required}\",goliath;scheme=\"http://occi.example.org/occi/infrastructure/resource_tpl#\";class=\"mixin\";title=\"Goliath Instance - 16 cores and 64 GB RAM\";rel=\"http://schemas.ogf.org/occi/infrastructure#resource_tpl\";location=\"/mixin/resource_tpl/goliath/\";attributes=\"occi.compute.architecture{immutable} occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable}\",mammoth;scheme=\"http://occi.example.org/occi/infrastructure/resource_tpl#\";class=\"mixin\";title=\"Mammoth Instance - 8 cores and 32 GB RAM\";rel=\"http://schemas.ogf.org/occi/infrastructure#resource_tpl\";location=\"/mixin/resource_tpl/mammoth/\";attributes=\"occi.compute.architecture{immutable} occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable}\",extra_large;scheme=\"http://occi.example.org/occi/infrastructure/resource_tpl#\";class=\"mixin\";title=\"Extra Large Instance - 4 cores and 16 GB RAM\";rel=\"http://schemas.ogf.org/occi/infrastructure#resource_tpl\";location=\"/mixin/resource_tpl/extra_large/\";attributes=\"occi.compute.architecture{immutable} occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable}\",large;scheme=\"http://occi.example.org/occi/infrastructure/resource_tpl#\";class=\"mixin\";title=\"Large Instance - 4 cores and 8 GB RAM\";rel=\"http://schemas.ogf.org/occi/infrastructure#resource_tpl\";location=\"/mixin/resource_tpl/large/\";attributes=\"occi.compute.architecture{immutable} occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable}\",medium;scheme=\"http://occi.example.org/occi/infrastructure/resource_tpl#\";class=\"mixin\";title=\"Medium Instance - 2 cores and 4 GB RAM\";rel=\"http://schemas.ogf.org/occi/infrastructure#resource_tpl\";location=\"/mixin/resource_tpl/medium/\";attributes=\"occi.compute.architecture occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable}\",small;scheme=\"http://occi.example.org/occi/infrastructure/resource_tpl#\";class=\"mixin\";title=\"Small Instance - 1 core and 2 GB RAM\";rel=\"http://schemas.ogf.org/occi/infrastructure#resource_tpl\";location=\"/mixin/resource_tpl/small/\";attributes=\"occi.compute.architecture occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable}\",start;scheme=\"http://schemas.ogf.org/occi/infrastructure/compute/action#\";class=\"action\";title=\"start compute instance\",stop;scheme=\"http://schemas.ogf.org/occi/infrastructure/compute/action#\";class=\"action\";title=\"stop compute instance\",restart;scheme=\"http://schemas.ogf.org/occi/infrastructure/compute/action#\";class=\"action\";title=\"restart compute instance\",suspend;scheme=\"http://schemas.ogf.org/occi/infrastructure/compute/action#\";class=\"action\";title=\"suspend compute instance\",online;scheme=\"http://schemas.ogf.org/occi/infrastructure/storage/action#\";class=\"action\";title=\"activate storage\",offline;scheme=\"http://schemas.ogf.org/occi/infrastructure/storage/action#\";class=\"action\";title=\"deactivate storage\",backup;scheme=\"http://schemas.ogf.org/occi/infrastructure/storage/action#\";class=\"action\";title=\"backup storage\",snapshot;scheme=\"http://schemas.ogf.org/occi/infrastructure/storage/action#\";class=\"action\";title=\"snapshot storage\",resize;scheme=\"http://schemas.ogf.org/occi/infrastructure/storage/action#\";class=\"action\";title=\"resize storage\",up;scheme=\"http://schemas.ogf.org/occi/infrastructure/network/action#\";class=\"action\";title=\"activate network\",down;scheme=\"http://schemas.ogf.org/occi/infrastructure/network/action#\";class=\"action\";title=\"deactivate network\",up;scheme=\"http://schemas.ogf.org/occi/infrastructure/networkinterface/action#\";class=\"action\";title=\"activate networkinterface\",down;scheme=\"http://schemas.ogf.org/occi/infrastructure/networkinterface/action#\";class=\"action\";title=\"deactivate networkinterface\",online;scheme=\"http://schemas.ogf.org/occi/infrastructure/storagelink/action#\";class=\"action\";title=\"activate storagelink\",offline;scheme=\"http://schemas.ogf.org/occi/infrastructure/storagelink/action#\";class=\"action\";title=\"deactivate storagelink\"",
- "Content-Type" : "text/occi; charset=utf-8",
- "Cache-Control" : "no-cache",
- "X-Request-Id" : "23ac6670-d53f-4e43-8cd2-2ebc1ff5f24e",
- "X-Runtime" : "0.296923",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 09:11:22 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/-/",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/occi"
- },
- "Accept" : {
- "equalTo" : "text/occi"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body---crGY7.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Category" : "entity;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\";title=\"entity\";location=\"/entity/\";attributes=\"occi.core.id{immutable required} occi.core.title\",resource;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\";title=\"resource\";rel=\"http://schemas.ogf.org/occi/core#entity\";location=\"/resource/\";attributes=\"occi.core.id{immutable required} occi.core.title occi.core.summary\",link;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\";title=\"link\";rel=\"http://schemas.ogf.org/occi/core#entity\";location=\"/link/\";attributes=\"occi.core.id{immutable required} occi.core.title occi.core.target occi.core.source{required}\",compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";title=\"compute resource\";rel=\"http://schemas.ogf.org/occi/core#resource\";location=\"/compute/\";attributes=\"occi.core.id{immutable required} occi.core.title occi.core.summary occi.compute.architecture occi.compute.cores occi.compute.hostname occi.compute.memory occi.compute.speed occi.compute.state{immutable}\";actions=\"http://schemas.ogf.org/occi/infrastructure/compute/action#start http://schemas.ogf.org/occi/infrastructure/compute/action#stop http://schemas.ogf.org/occi/infrastructure/compute/action#restart http://schemas.ogf.org/occi/infrastructure/compute/action#suspend\",storage;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";title=\"storage resource\";rel=\"http://schemas.ogf.org/occi/core#resource\";location=\"/storage/\";attributes=\"occi.core.id{immutable required} occi.core.title occi.core.summary occi.storage.size occi.storage.state\";actions=\"http://schemas.ogf.org/occi/infrastructure/storage/action#online http://schemas.ogf.org/occi/infrastructure/storage/action#offline http://schemas.ogf.org/occi/infrastructure/storage/action#backup http://schemas.ogf.org/occi/infrastructure/storage/action#snapshot http://schemas.ogf.org/occi/infrastructure/storage/action#resize\",network;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";title=\"network resource\";rel=\"http://schemas.ogf.org/occi/core#resource\";location=\"/network/\";attributes=\"occi.core.id{immutable required} occi.core.title occi.core.summary occi.network.vlan occi.network.label occi.network.state{immutable}\";actions=\"http://schemas.ogf.org/occi/infrastructure/network/action#up http://schemas.ogf.org/occi/infrastructure/network/action#down\",networkinterface;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";title=\"networkinterface link\";rel=\"http://schemas.ogf.org/occi/core#link\";location=\"/link/networkinterface/\";attributes=\"occi.core.id{immutable required} occi.core.title occi.core.target occi.core.source{required} occi.networkinterface.interface{immutable} occi.networkinterface.mac occi.networkinterface.state{immutable}\";actions=\"http://schemas.ogf.org/occi/infrastructure/networkinterface/action#up http://schemas.ogf.org/occi/infrastructure/networkinterface/action#down\",storagelink;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";title=\"storage link\";rel=\"http://schemas.ogf.org/occi/core#link\";location=\"/link/storagelink/\";attributes=\"occi.core.id{immutable required} occi.core.title occi.core.target occi.core.source{required} occi.storagelink.deviceid occi.storagelink.mountpoint occi.storagelink.state{immutable}\";actions=\"http://schemas.ogf.org/occi/infrastructure/storagelink/action#online http://schemas.ogf.org/occi/infrastructure/storagelink/action#offline\",resource_tpl;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"mixin\";title=\"resource template\";location=\"/mixin/resource_tpl/\",os_tpl;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"mixin\";title=\"operating system template\";location=\"/mixin/os_tpl/\",ipnetwork;scheme=\"http://schemas.ogf.org/occi/infrastructure/network#\";class=\"mixin\";title=\"IP network mixin\";location=\"/mixin/ipnetwork/\";attributes=\"occi.network.address occi.network.gateway occi.network.allocation\",ipnetworkinterface;scheme=\"http://schemas.ogf.org/occi/infrastructure/networkinterface#\";class=\"mixin\";title=\"IP network interface mixin\";location=\"/mixin/ipnetworkinterface/\";attributes=\"occi.networkinterface.address occi.networkinterface.gateway occi.networkinterface.allocation\",debian6;scheme=\"http://occi.example.org/occi/infrastructure/os_tpl#\";class=\"mixin\";title=\"debian\";rel=\"http://schemas.ogf.org/occi/infrastructure#os_tpl\";location=\"/mixin/os_tpl/debian6/\";attributes=\"eu.egi.fedcloud.appdb.uuid{immutable required}\",sl6golden;scheme=\"http://occi.example.org/occi/infrastructure/os_tpl#\";class=\"mixin\";title=\"monitoring\";rel=\"http://schemas.ogf.org/occi/infrastructure#os_tpl\";location=\"/mixin/os_tpl/sl6golden/\";attributes=\"eu.egi.fedcloud.appdb.uuid{immutable required}\",goliath;scheme=\"http://occi.example.org/occi/infrastructure/resource_tpl#\";class=\"mixin\";title=\"Goliath Instance - 16 cores and 64 GB RAM\";rel=\"http://schemas.ogf.org/occi/infrastructure#resource_tpl\";location=\"/mixin/resource_tpl/goliath/\";attributes=\"occi.compute.architecture{immutable} occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable}\",mammoth;scheme=\"http://occi.example.org/occi/infrastructure/resource_tpl#\";class=\"mixin\";title=\"Mammoth Instance - 8 cores and 32 GB RAM\";rel=\"http://schemas.ogf.org/occi/infrastructure#resource_tpl\";location=\"/mixin/resource_tpl/mammoth/\";attributes=\"occi.compute.architecture{immutable} occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable}\",extra_large;scheme=\"http://occi.example.org/occi/infrastructure/resource_tpl#\";class=\"mixin\";title=\"Extra Large Instance - 4 cores and 16 GB RAM\";rel=\"http://schemas.ogf.org/occi/infrastructure#resource_tpl\";location=\"/mixin/resource_tpl/extra_large/\";attributes=\"occi.compute.architecture{immutable} occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable}\",large;scheme=\"http://occi.example.org/occi/infrastructure/resource_tpl#\";class=\"mixin\";title=\"Large Instance - 4 cores and 8 GB RAM\";rel=\"http://schemas.ogf.org/occi/infrastructure#resource_tpl\";location=\"/mixin/resource_tpl/large/\";attributes=\"occi.compute.architecture{immutable} occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable}\",medium;scheme=\"http://occi.example.org/occi/infrastructure/resource_tpl#\";class=\"mixin\";title=\"Medium Instance - 2 cores and 4 GB RAM\";rel=\"http://schemas.ogf.org/occi/infrastructure#resource_tpl\";location=\"/mixin/resource_tpl/medium/\";attributes=\"occi.compute.architecture occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable}\",small;scheme=\"http://occi.example.org/occi/infrastructure/resource_tpl#\";class=\"mixin\";title=\"Small Instance - 1 core and 2 GB RAM\";rel=\"http://schemas.ogf.org/occi/infrastructure#resource_tpl\";location=\"/mixin/resource_tpl/small/\";attributes=\"occi.compute.architecture occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable}\",start;scheme=\"http://schemas.ogf.org/occi/infrastructure/compute/action#\";class=\"action\";title=\"start compute instance\",stop;scheme=\"http://schemas.ogf.org/occi/infrastructure/compute/action#\";class=\"action\";title=\"stop compute instance\",restart;scheme=\"http://schemas.ogf.org/occi/infrastructure/compute/action#\";class=\"action\";title=\"restart compute instance\",suspend;scheme=\"http://schemas.ogf.org/occi/infrastructure/compute/action#\";class=\"action\";title=\"suspend compute instance\",online;scheme=\"http://schemas.ogf.org/occi/infrastructure/storage/action#\";class=\"action\";title=\"activate storage\",offline;scheme=\"http://schemas.ogf.org/occi/infrastructure/storage/action#\";class=\"action\";title=\"deactivate storage\",backup;scheme=\"http://schemas.ogf.org/occi/infrastructure/storage/action#\";class=\"action\";title=\"backup storage\",snapshot;scheme=\"http://schemas.ogf.org/occi/infrastructure/storage/action#\";class=\"action\";title=\"snapshot storage\",resize;scheme=\"http://schemas.ogf.org/occi/infrastructure/storage/action#\";class=\"action\";title=\"resize storage\",up;scheme=\"http://schemas.ogf.org/occi/infrastructure/network/action#\";class=\"action\";title=\"activate network\",down;scheme=\"http://schemas.ogf.org/occi/infrastructure/network/action#\";class=\"action\";title=\"deactivate network\",up;scheme=\"http://schemas.ogf.org/occi/infrastructure/networkinterface/action#\";class=\"action\";title=\"activate networkinterface\",down;scheme=\"http://schemas.ogf.org/occi/infrastructure/networkinterface/action#\";class=\"action\";title=\"deactivate networkinterface\",online;scheme=\"http://schemas.ogf.org/occi/infrastructure/storagelink/action#\";class=\"action\";title=\"activate storagelink\",offline;scheme=\"http://schemas.ogf.org/occi/infrastructure/storagelink/action#\";class=\"action\";title=\"deactivate storagelink\"",
- "Content-Type" : "text/occi; charset=utf-8",
- "Cache-Control" : "no-cache",
- "X-Request-Id" : "23ac6670-d53f-4e43-8cd2-2ebc1ff5f24e",
- "X-Runtime" : "0.296923",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 09:11:22 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
+++ /dev/null
-{
- "request" : {
- "url" : "/-/",
- "method" : "HEAD",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/plain"
- },
- "Accept" : {
- "equalTo" : "text/plain"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body---lLtvH.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/plain; charset=utf-8",
- "Etag" : "\"bc0008dd6f5d47c9920e541d863366a3\"",
- "Cache-Control" : "max-age=0, private, must-revalidate",
- "X-Request-Id" : "5e8d4d72-b137-4879-95f1-cb9f569b978c",
- "X-Runtime" : "0.293953",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 08:57:20 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/-/",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/plain"
- },
- "Accept" : {
- "equalTo" : "text/plain"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body---xaO7k.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/plain; charset=utf-8",
- "Etag" : "\"bc0008dd6f5d47c9920e541d863366a3\"",
- "Cache-Control" : "max-age=0, private, must-revalidate",
- "X-Request-Id" : "25ecea6a-bbf7-4490-97da-026512db6674",
- "X-Runtime" : "0.308337",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 08:57:20 GMT",
- "Content-Length" : "9204",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/compute/0054b25a-ddb9-412e-869e-7b800a13aa46",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/occi"
- },
- "Accept" : {
- "equalTo" : "text/occi"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-compute-0054b25a-ddb9-412e-869e-7b800a13aa46-BzixR.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Category" : "compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\";title=\"compute resource\",debian6;scheme=\"http://occi.example.org/occi/infrastructure/os_tpl#\";class=\"mixin\";location=\"/mixin/os_tpl/debian6/\";title=\"debian\",small;scheme=\"http://occi.example.org/occi/infrastructure/resource_tpl#\";class=\"mixin\";location=\"/mixin/resource_tpl/small/\";title=\"Small Instance - 1 core and 2 GB RAM\"",
- "X-Occi-Attribute" : "occi.core.id=\"0054b25a-ddb9-412e-869e-7b800a13aa46\",occi.core.title=\"test_title\",occi.compute.architecture=\"x86\",occi.compute.cores=1,occi.compute.memory=2,occi.compute.speed=1,occi.compute.state=\"active\",eu.egi.fedcloud.appdb.uuid=\"appdb:uuid:debian6\"",
- "Content-Type" : "text/occi; charset=utf-8",
- "Cache-Control" : "no-cache",
- "X-Request-Id" : "030003f0-6fb6-47a2-8d1f-a4f2aa75a042",
- "X-Runtime" : "0.528609",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 09:05:23 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/compute/0054b25a-ddb9-412e-869e-7b800a13aa46",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/plain"
- },
- "Accept" : {
- "equalTo" : "text/plain"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-compute-0054b25a-ddb9-412e-869e-7b800a13aa46-xAARc.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/plain; charset=utf-8",
- "Etag" : "\"86f5a67710c3bad29b5bbf3640a3eb86\"",
- "Cache-Control" : "max-age=0, private, must-revalidate",
- "X-Request-Id" : "99390bbd-ac0b-4261-8aaa-c81ea3b1b66c",
- "X-Runtime" : "0.543592",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 08:57:24 GMT",
- "Content-Length" : "848",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/compute/",
- "method" : "POST",
- "bodyPatterns" : [ {
- "equalTo" : "Category: compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\"\nCategory: debian6;scheme=\"http://occi.example.org/occi/infrastructure/os_tpl#\";class=\"mixin\"\nCategory: small;scheme=\"http://occi.example.org/occi/infrastructure/resource_tpl#\";class=\"mixin\"\nX-OCCI-Attribute: occi.core.id=\"157754bb-af01-40be-853a-6a1f1b5ac500\""
- } ],
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/plain"
- },
- "Accept" : {
- "equalTo" : "text/plain"
- }
- }
- },
- "response" : {
- "status" : 201,
- "bodyFileName" : "body-compute-04cby.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/plain; charset=utf-8",
- "Etag" : "\"62cb748543771cffda40eefb5da68908\"",
- "Cache-Control" : "max-age=0, private, must-revalidate",
- "X-Request-Id" : "00e62bf2-4969-45ad-9066-f0eba14d7c2d",
- "X-Runtime" : "0.960055",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 08:57:54 GMT",
- "Content-Length" : "104",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/compute/",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/plain"
- },
- "Accept" : {
- "equalTo" : "text/plain"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-compute-0P01F.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/plain; charset=utf-8",
- "Etag" : "\"caa5c2bd701e64535813367c279f3557\"",
- "Cache-Control" : "max-age=0, private, must-revalidate",
- "X-Request-Id" : "cec660f0-0d7d-4063-8ac4-31393da6d5d2",
- "X-Runtime" : "0.524701",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 08:57:22 GMT",
- "Content-Length" : "575",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/compute/123456789",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/occi"
- },
- "Accept" : {
- "equalTo" : "text/occi"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-compute-123456789-9rQpm.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Category" : "compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\";title=\"compute resource\",debian6;scheme=\"http://occi.example.org/occi/infrastructure/os_tpl#\";class=\"mixin\";location=\"/mixin/os_tpl/debian6/\";title=\"debian\",small;scheme=\"http://occi.example.org/occi/infrastructure/resource_tpl#\";class=\"mixin\";location=\"/mixin/resource_tpl/small/\";title=\"Small Instance - 1 core and 2 GB RAM\"",
- "X-Occi-Attribute" : "occi.core.id=\"123456789\",occi.core.title=\"vm_test01\",occi.compute.architecture=\"x86\",occi.compute.cores=1,occi.compute.hostname=\"vm_test01\",occi.compute.memory=2,occi.compute.speed=1,occi.compute.state=\"active\"",
- "Link" : "</network/e36ee51c-bfb6-4264-a5bf-2e71b9145b14>;rel=\"http://schemas.ogf.org/occi/core#link\";self=\"/link/networkinterface/9e9aced1-a2a8-459e-8fc8-690beb3f1533\";category=\"http://schemas.ogf.org/occi/infrastructure#networkinterface\";occi.core.id=\"9e9aced1-a2a8-459e-8fc8-690beb3f1533\";occi.core.target=\"/network/e36ee51c-bfb6-4264-a5bf-2e71b9145b14\";occi.core.source=\"/compute/123456789\";occi.networkinterface.interface=\"eth0\";occi.networkinterface.mac=\"00:11:22:33:44:55\";occi.networkinterface.state=\"active\"",
- "Content-Type" : "text/occi; charset=utf-8",
- "Cache-Control" : "no-cache",
- "X-Request-Id" : "131ded70-d45f-4e25-a787-cb20c2cbdb02",
- "X-Runtime" : "0.471766",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 09:05:27 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/compute/123456789",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/plain"
- },
- "Accept" : {
- "equalTo" : "text/plain"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-compute-123456789-Ibs9H.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/plain; charset=utf-8",
- "Etag" : "\"680ddc890c6f4fad4b1f6f59901a26df\"",
- "Cache-Control" : "max-age=0, private, must-revalidate",
- "X-Request-Id" : "3be70369-52a6-4653-9dd6-9fada62794be",
- "X-Runtime" : "0.367248",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 08:57:27 GMT",
- "Content-Length" : "1319",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/compute/157754bb-af01-40be-853a-6a1f1b5ac500",
- "method" : "PUT",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/plain"
- },
- "Accept" : {
- "equalTo" : "text/plain"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-compute-157754bb-af01-40be-853a-6a1f1b5ac500-vGYhq.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/plain; charset=utf-8",
- "Etag" : "\"62cb748543771cffda40eefb5da68908\"",
- "Cache-Control" : "max-age=0, private, must-revalidate",
- "X-Request-Id" : "00e62bf2-4969-45ad-9066-f0eba14d7c2d",
- "X-Runtime" : "0.960055",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 08:57:54 GMT",
- "Content-Length" : "104",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/compute/157754bb-af01-40be-853a-6a1f1b5ac500",
- "method" : "DELETE",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/plain"
- },
- "Accept" : {
- "equalTo" : "text/plain"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-compute-157754bb-af01-40be-853a-6a1f1b5ac500-vGYhr.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/plain; charset=utf-8",
- "Cache-Control" : "no-cache",
- "X-Request-Id" : "fd30f963-d880-4151-9d89-a01061dcb605",
- "X-Runtime" : "1.058328",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 08:57:56 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/compute/29b814ad-c5b2-4bc4-888b-470f769a2930?action=start",
- "method" : "POST",
- "bodyPatterns" : [ {
- "equalTo" : "Category: start;scheme=\"http://schemas.ogf.org/occi/infrastructure/compute/action#\";class=\"action\";title=\"start compute instance\";"
- } ],
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/plain"
- },
- "Accept" : {
- "equalTo" : "text/plain"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-compute-29b814ad-c5b2-4bc4-888b-470f769a2930-5oA1q.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/plain; charset=utf-8",
- "Cache-Control" : "no-cache",
- "X-Request-Id" : "b72f4e4a-c409-4793-bd82-a41d570f2a46",
- "X-Runtime" : "1.824386",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 08:58:43 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/compute/29b814ad-c5b2-4bc4-888b-470f769a2930?action=start",
- "method" : "POST",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/occi"
- },
- "Accept" : {
- "equalTo" : "text/occi"
- },
- "Category" : {
- "equalTo" : "start;scheme=\"http://schemas.ogf.org/occi/infrastructure/compute/action#\";class=\"action\";title=\"start compute instance\";"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-compute-29b814ad-c5b2-4bc4-888b-470f769a2930-XStRo.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/occi; charset=utf-8",
- "Cache-Control" : "no-cache",
- "X-Request-Id" : "534eeb75-9d4e-45c4-b826-e7a80c606feb",
- "X-Runtime" : "1.583949",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 09:06:52 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/compute/29b814ad-c5b2-4bc4-888b-470f769a2930",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/occi"
- },
- "Accept" : {
- "equalTo" : "text/occi"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-compute-29b814ad-c5b2-4bc4-888b-470f769a2930-puPyB.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Category" : "compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\";title=\"compute resource\",debian6;scheme=\"http://occi.example.org/occi/infrastructure/os_tpl#\";class=\"mixin\";location=\"/mixin/os_tpl/debian6/\";title=\"debian\",small;scheme=\"http://occi.example.org/occi/infrastructure/resource_tpl#\";class=\"mixin\";location=\"/mixin/resource_tpl/small/\";title=\"Small Instance - 1 core and 2 GB RAM\"",
- "X-Occi-Attribute" : "occi.core.id=\"29b814ad-c5b2-4bc4-888b-470f769a2930\",occi.core.title=\"VMTest2\",occi.compute.architecture=\"x86\",occi.compute.cores=1,occi.compute.hostname=\"VMTest2\",occi.compute.memory=2,occi.compute.speed=1,occi.compute.state=\"active\"",
- "Link" : "</network/e36ee51c-bfb6-4264-a5bf-2e71b9145b14>;rel=\"http://schemas.ogf.org/occi/core#link\";self=\"/link/networkinterface/920ad837-1fa3-40a2-8810-fb8f2dc1wrt7\";category=\"http://schemas.ogf.org/occi/infrastructure#networkinterface\";occi.core.id=\"920ad837-1fa3-40a2-8810-fb8f2dc1wrt7\";occi.core.target=\"/network/e36ee51c-bfb6-4264-a5bf-2e71b9145b14\";occi.core.source=\"/compute/29b814ad-c5b2-4bc4-888b-470f769a2930\"",
- "Content-Type" : "text/occi; charset=utf-8",
- "Cache-Control" : "no-cache",
- "X-Request-Id" : "f411697f-2934-42fc-a2bf-812e19647d12",
- "X-Runtime" : "0.567034",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 09:05:27 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/compute/29b814ad-c5b2-4bc4-888b-470f769a2930",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/plain"
- },
- "Accept" : {
- "equalTo" : "text/plain"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-compute-29b814ad-c5b2-4bc4-888b-470f769a2930-uJec6.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/plain; charset=utf-8",
- "Etag" : "\"5c3498edec928219441bdc3bc565c14f\"",
- "Cache-Control" : "max-age=0, private, must-revalidate",
- "X-Request-Id" : "994fe98a-7885-4c4c-9670-692fcb2b2be9",
- "X-Runtime" : "0.436634",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 08:57:26 GMT",
- "Content-Length" : "1247",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/compute/29ce3084-23b6-44e0-b53e-55a34b924920",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/occi"
- },
- "Accept" : {
- "equalTo" : "text/occi"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-compute-29ce3084-23b6-44e0-b53e-55a34b924920-88kQ3.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Category" : "compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\";title=\"compute resource\",sl6golden;scheme=\"http://occi.example.org/occi/infrastructure/os_tpl#\";class=\"mixin\";location=\"/mixin/os_tpl/sl6golden/\";title=\"monitoring\",mammoth;scheme=\"http://occi.example.org/occi/infrastructure/resource_tpl#\";class=\"mixin\";location=\"/mixin/resource_tpl/mammoth/\";title=\"Mammoth Instance - 8 cores and 32 GB RAM\"",
- "X-Occi-Attribute" : "occi.core.id=\"29ce3084-23b6-44e0-b53e-55a34b924920\",occi.core.title=\"fhkgf\",occi.compute.architecture=\"x64\",occi.compute.cores=8,occi.compute.memory=32,occi.compute.speed=1,occi.compute.state=\"active\",eu.egi.fedcloud.appdb.uuid=\"appdb:uuid:sl6golden\"",
- "Content-Type" : "text/occi; charset=utf-8",
- "Cache-Control" : "no-cache",
- "X-Request-Id" : "3dfcfb19-048e-40ec-a1ac-050406ab21fa",
- "X-Runtime" : "0.696259",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 09:05:24 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/compute/29ce3084-23b6-44e0-b53e-55a34b924920",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/plain"
- },
- "Accept" : {
- "equalTo" : "text/plain"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-compute-29ce3084-23b6-44e0-b53e-55a34b924920-NMuFo.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/plain; charset=utf-8",
- "Etag" : "\"27a56e1fb13da66d889e8fc4e050ff04\"",
- "Cache-Control" : "max-age=0, private, must-revalidate",
- "X-Request-Id" : "e7b147bd-bbb0-4b39-a2fa-434b4e347477",
- "X-Runtime" : "0.352273",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 08:57:24 GMT",
- "Content-Length" : "862",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/compute/5537b49a-bb2e-4302-bf8b-da38611247ca",
- "method" : "PUT",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/occi"
- },
- "Accept" : {
- "equalTo" : "text/occi"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-compute-5537b49a-bb2e-4302-bf8b-da38611247ca-dbOPq.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/plain; charset=utf-8",
- "Etag" : "\"62cb748543771cffda40eefb5da68908\"",
- "Cache-Control" : "max-age=0, private, must-revalidate",
- "X-Request-Id" : "00e62bf2-4969-45ad-9066-f0eba14d7c2d",
- "X-Runtime" : "0.960055",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 08:57:54 GMT",
- "Content-Length" : "104",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/compute/5537b49a-bb2e-4302-bf8b-da38611247ca",
- "method" : "DELETE",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/occi"
- },
- "Accept" : {
- "equalTo" : "text/occi"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-compute-5537b49a-bb2e-4302-bf8b-da38611247ca-dbOPy.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/occi; charset=utf-8",
- "Cache-Control" : "no-cache",
- "X-Request-Id" : "72f8dbf8-b3da-424a-b77f-3d8744513470",
- "X-Runtime" : "0.990166",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 09:06:04 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/compute/987654321",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/plain"
- },
- "Accept" : {
- "equalTo" : "text/plain"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-compute-987654321-9r3vy.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/plain; charset=utf-8",
- "Etag" : "\"4e4a7128e211b48263a6aca4b00da476\"",
- "Cache-Control" : "max-age=0, private, must-revalidate",
- "X-Request-Id" : "cc7ae28c-fed1-46fd-9bf6-f6a3a2794f58",
- "X-Runtime" : "0.540705",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 08:57:25 GMT",
- "Content-Length" : "1323",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/compute/987654321",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/occi"
- },
- "Accept" : {
- "equalTo" : "text/occi"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-compute-987654321-i3STU.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Category" : "compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\";title=\"compute resource\",debian6;scheme=\"http://occi.example.org/occi/infrastructure/os_tpl#\";class=\"mixin\";location=\"/mixin/os_tpl/debian6/\";title=\"debian\",small;scheme=\"http://occi.example.org/occi/infrastructure/resource_tpl#\";class=\"mixin\";location=\"/mixin/resource_tpl/small/\";title=\"Small Instance - 1 core and 2 GB RAM\"",
- "X-Occi-Attribute" : "occi.core.id=\"987654321\",occi.core.title=\"vm_test02\",occi.compute.architecture=\"x86\",occi.compute.cores=1,occi.compute.hostname=\"vm_test02\",occi.compute.memory=2,occi.compute.speed=1,occi.compute.state=\"active\"",
- "Link" : "<http://rocci-server-1-1-x.herokuapp.com:80/network/e36ee51c-bfb6-4264-a5bf-2e71b9145b14>;rel=\"http://schemas.ogf.org/occi/core#link\";self=\"/link/networkinterface/e5f8f7bd-7d84-4c46-9a4e-325cc950f0ed\";category=\"http://schemas.ogf.org/occi/infrastructure#networkinterface\";occi.core.id=\"e5f8f7bd-7d84-4c46-9a4e-325cc950f0ed\";occi.core.target=\"http://rocci-server-1-1-x.herokuapp.com:80/network/e36ee51c-bfb6-4264-a5bf-2e71b9145b14\";occi.core.source=\"http://rocci-server-1-1-x.herokuapp.com:80/compute/987654321\"",
- "Content-Type" : "text/occi; charset=utf-8",
- "Cache-Control" : "no-cache",
- "X-Request-Id" : "ac6789cf-a232-4d93-a5b1-83669c1f727b",
- "X-Runtime" : "0.641783",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 09:05:25 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/compute/9b36c234-7e4a-400d-bab8-58dead9e0ef8",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/occi"
- },
- "Accept" : {
- "equalTo" : "text/occi"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-compute-9b36c234-7e4a-400d-bab8-58dead9e0ef8-H43R7.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Category" : "compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\";title=\"compute resource\",debian6;scheme=\"http://occi.example.org/occi/infrastructure/os_tpl#\";class=\"mixin\";location=\"/mixin/os_tpl/debian6/\";title=\"debian\",small;scheme=\"http://occi.example.org/occi/infrastructure/resource_tpl#\";class=\"mixin\";location=\"/mixin/resource_tpl/small/\";title=\"Small Instance - 1 core and 2 GB RAM\"",
- "X-Occi-Attribute" : "occi.core.id=\"9b36c234-7e4a-400d-bab8-58dead9e0ef8\",occi.core.title=\"VMTest\",occi.compute.architecture=\"x86\",occi.compute.cores=1,occi.compute.hostname=\"VMTest\",occi.compute.memory=2,occi.compute.speed=1,occi.compute.state=\"active\"",
- "Link" : "</network/e36ee51c-bfb6-4264-a5bf-2e71b9145b14>;rel=\"http://schemas.ogf.org/occi/core#link\";self=\"/link/networkinterface/31f185d5-9379-4479-9809-b4cce6bcfdee\";category=\"http://schemas.ogf.org/occi/infrastructure#networkinterface\";occi.core.id=\"31f185d5-9379-4479-9809-b4cce6bcfdee\";occi.core.target=\"/network/e36ee51c-bfb6-4264-a5bf-2e71b9145b14\";occi.core.source=\"/compute/9b36c234-7e4a-400d-bab8-58dead9e0ef8\";occi.networkinterface.interface=\"eth0\";occi.networkinterface.mac=\"00:11:22:33:44:55\";occi.networkinterface.state=\"active\"",
- "Content-Type" : "text/occi; charset=utf-8",
- "Cache-Control" : "no-cache",
- "X-Request-Id" : "8174db1f-b4d5-4823-b085-f4227a21b1f2",
- "X-Runtime" : "1.078980",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 09:05:26 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/compute/9b36c234-7e4a-400d-bab8-58dead9e0ef8",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/plain"
- },
- "Accept" : {
- "equalTo" : "text/plain"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-compute-9b36c234-7e4a-400d-bab8-58dead9e0ef8-hCQg9.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/plain; charset=utf-8",
- "Etag" : "\"14850def0bf74261d2b505d7d2812f40\"",
- "Cache-Control" : "max-age=0, private, must-revalidate",
- "X-Request-Id" : "0f3d98e8-1298-4c2f-83b9-cfa713d11a10",
- "X-Runtime" : "0.438533",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 08:57:25 GMT",
- "Content-Length" : "1367",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/compute/?action=start",
- "method" : "POST",
- "bodyPatterns" : [ {
- "equalTo" : "Category: start;scheme=\"http://schemas.ogf.org/occi/infrastructure/compute/action#\";class=\"action\";title=\"start compute instance\";"
- } ],
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/plain"
- },
- "Accept" : {
- "equalTo" : "text/plain"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-compute-NiEMH.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/plain; charset=utf-8",
- "Cache-Control" : "no-cache",
- "X-Request-Id" : "ffc26f39-b019-4984-9fbc-f9cbda3f2963",
- "X-Runtime" : "22.703227",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 08:58:18 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/compute/",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/occi"
- },
- "Accept" : {
- "equalTo" : "text/occi"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-compute-SSKim.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Location" : "http://rocci-server-1-1-x.herokuapp.com:80/compute/0054b25a-ddb9-412e-869e-7b800a13aa46,http://rocci-server-1-1-x.herokuapp.com:80/compute/29ce3084-23b6-44e0-b53e-55a34b924920,http://rocci-server-1-1-x.herokuapp.com:80/compute/987654321,http://rocci-server-1-1-x.herokuapp.com:80/compute/9b36c234-7e4a-400d-bab8-58dead9e0ef8,http://rocci-server-1-1-x.herokuapp.com:80/compute/29b814ad-c5b2-4bc4-888b-470f769a2930,http://rocci-server-1-1-x.herokuapp.com:80/compute/123456789",
- "Content-Type" : "text/occi; charset=utf-8",
- "Cache-Control" : "no-cache",
- "X-Request-Id" : "28b0f1ae-d66b-4cb2-bd43-ba42e9b8069b",
- "X-Runtime" : "0.454154",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 09:05:21 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/compute/?action=start",
- "method" : "POST",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/occi"
- },
- "Accept" : {
- "equalTo" : "text/occi"
- },
- "Category" : {
- "equalTo" : "start;scheme=\"http://schemas.ogf.org/occi/infrastructure/compute/action#\";class=\"action\";title=\"start compute instance\";"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-compute-XyVfC.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/occi; charset=utf-8",
- "Cache-Control" : "no-cache",
- "X-Request-Id" : "485966dc-b448-4503-b638-0d3268d06114",
- "X-Runtime" : "23.324720",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 09:06:27 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/compute/",
- "method" : "POST",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/occi"
- },
- "Accept" : {
- "equalTo" : "text/occi"
- },
- "X-occi-attribute" : {
- "equalTo" : "occi.core.id=\"5537b49a-bb2e-4302-bf8b-da38611247ca\""
- },
- "Category" : {
- "equalTo" : "compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\""
- }
- }
- },
- "response" : {
- "status" : 201,
- "bodyFileName" : "body-compute-sp6h4.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Location" : "http://rocci-server-1-1-x.herokuapp.com/compute/5537b49a-bb2e-4302-bf8b-da38611247ca",
- "Content-Type" : "text/occi; charset=utf-8",
- "Etag" : "\"e0aa021e21dddbd6d8cecec71e9cf564\"",
- "Cache-Control" : "max-age=0, private, must-revalidate",
- "X-Request-Id" : "f852c03f-c126-40cb-a4e1-fcb20014ffb9",
- "X-Runtime" : "1.462187",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 09:06:01 GMT",
- "Content-Length" : "2",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/differentcode/",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/plain"
- },
- "Accept" : {
- "equalTo" : "text/plain"
- }
- }
- },
- "response" : {
- "status" : 202,
- "bodyFileName" : "body-differentcode-setN7.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/plain; charset=utf-8",
- "Etag" : "\"bc0008dd6f5d47c9920e541d863366a3\"",
- "Cache-Control" : "max-age=0, private, must-revalidate",
- "X-Request-Id" : "ac049323-b17b-4f59-a586-364e14174418",
- "X-Runtime" : "0.224121",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Mon, 16 Feb 2015 14:56:54 GMT",
- "Content-Length" : "9204",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/network/05940332-7926-4cf5-b1fc-7479b529524a",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/plain"
- },
- "Accept" : {
- "equalTo" : "text/plain"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-network-05940332-7926-4cf5-b1fc-7479b529524a-Afwh7.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/plain; charset=utf-8",
- "Etag" : "\"6687c39b014cb3f76458a8b9e64c302f\"",
- "Cache-Control" : "max-age=0, private, must-revalidate",
- "X-Request-Id" : "4a0566a6-b1ba-4b67-a67d-4dc32267b55d",
- "X-Runtime" : "0.268990",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 08:57:32 GMT",
- "Content-Length" : "247",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/network/05940332-7926-4cf5-b1fc-7479b529524a",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/occi"
- },
- "Accept" : {
- "equalTo" : "text/occi"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-network-05940332-7926-4cf5-b1fc-7479b529524a-JM2hP.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Category" : "network;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/network/\";title=\"network resource\"",
- "X-Occi-Attribute" : "occi.core.id=\"05940332-7926-4cf5-b1fc-7479b529524a\",occi.network.state=\"inactive\"",
- "Content-Type" : "text/occi; charset=utf-8",
- "Cache-Control" : "no-cache",
- "X-Request-Id" : "f79ce6d1-8495-4d9a-bf39-9fdd2f9531e3",
- "X-Runtime" : "0.336790",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 09:05:34 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/network/",
- "method" : "DELETE",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/occi"
- },
- "Accept" : {
- "equalTo" : "text/occi"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-network-0ZkNd.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/occi; charset=utf-8",
- "Cache-Control" : "no-cache",
- "X-Request-Id" : "837b691a-9c72-4a15-80cb-6d31a53e0632",
- "X-Runtime" : "0.456651",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 09:06:02 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/network/1bdff9e2-7a5d-4e87-b2e3-9a6cfb7b6619",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/plain"
- },
- "Accept" : {
- "equalTo" : "text/plain"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-network-1bdff9e2-7a5d-4e87-b2e3-9a6cfb7b6619-hzqeF.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/plain; charset=utf-8",
- "Etag" : "\"cf86aa8f600c995a492daa317831b324\"",
- "Cache-Control" : "max-age=0, private, must-revalidate",
- "X-Request-Id" : "b3840859-c086-4b4b-a4bb-f95006cd71e3",
- "X-Runtime" : "0.245372",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 08:57:32 GMT",
- "Content-Length" : "247",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/network/1bdff9e2-7a5d-4e87-b2e3-9a6cfb7b6619",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/occi"
- },
- "Accept" : {
- "equalTo" : "text/occi"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-network-1bdff9e2-7a5d-4e87-b2e3-9a6cfb7b6619-qjnCY.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Category" : "network;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/network/\";title=\"network resource\"",
- "X-Occi-Attribute" : "occi.core.id=\"1bdff9e2-7a5d-4e87-b2e3-9a6cfb7b6619\",occi.network.state=\"inactive\"",
- "Content-Type" : "text/occi; charset=utf-8",
- "Cache-Control" : "no-cache",
- "X-Request-Id" : "0b520dc0-e35d-4361-bee3-aadc95fb489c",
- "X-Runtime" : "0.561691",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 09:05:35 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/network/24b94558-c46a-41e3-981d-16600f71cddb",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/occi"
- },
- "Accept" : {
- "equalTo" : "text/occi"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-network-24b94558-c46a-41e3-981d-16600f71cddb-61PLg.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Category" : "network;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/network/\";title=\"network resource\"",
- "X-Occi-Attribute" : "occi.core.id=\"24b94558-c46a-41e3-981d-16600f71cddb\",occi.network.state=\"inactive\"",
- "Content-Type" : "text/occi; charset=utf-8",
- "Cache-Control" : "no-cache",
- "X-Request-Id" : "235dab6c-3c1a-4f0c-ad68-44665b9e85a2",
- "X-Runtime" : "0.462286",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 09:05:34 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/network/24b94558-c46a-41e3-981d-16600f71cddb",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/plain"
- },
- "Accept" : {
- "equalTo" : "text/plain"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-network-24b94558-c46a-41e3-981d-16600f71cddb-OL4Ab.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/plain; charset=utf-8",
- "Etag" : "\"577516f0cba12577bfd1ddc6039b46de\"",
- "Cache-Control" : "max-age=0, private, must-revalidate",
- "X-Request-Id" : "094cab50-6344-439c-8dc6-118b4478e3d5",
- "X-Runtime" : "0.248099",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 08:57:33 GMT",
- "Content-Length" : "247",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/network/",
- "method" : "DELETE",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/plain"
- },
- "Accept" : {
- "equalTo" : "text/plain"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-network-Tkd5S.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/plain; charset=utf-8",
- "Cache-Control" : "no-cache",
- "X-Request-Id" : "87e181ea-6988-4ff5-b115-98db5f0f9895",
- "X-Runtime" : "0.224711",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 08:57:54 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/storage/1902326a-2092-4cb6-b998-6d6e73be6212",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/plain"
- },
- "Accept" : {
- "equalTo" : "text/plain"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-storage-1902326a-2092-4cb6-b998-6d6e73be6212-B8aRd.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/plain; charset=utf-8",
- "Etag" : "\"f2e7f49e58aee5803c0f680c9b9071fb\"",
- "Cache-Control" : "max-age=0, private, must-revalidate",
- "X-Request-Id" : "26884831-fbe1-49ed-8b1e-de46d034724f",
- "X-Runtime" : "0.289782",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 08:57:33 GMT",
- "Content-Length" : "246",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/storage/1902326a-2092-4cb6-b998-6d6e73be6212",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/occi"
- },
- "Accept" : {
- "equalTo" : "text/occi"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-storage-1902326a-2092-4cb6-b998-6d6e73be6212-naAXd.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Category" : "storage;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/storage/\";title=\"storage resource\"",
- "X-Occi-Attribute" : "occi.core.id=\"1902326a-2092-4cb6-b998-6d6e73be6212\",occi.storage.state=\"offline\"",
- "Content-Type" : "text/occi; charset=utf-8",
- "Cache-Control" : "no-cache",
- "X-Request-Id" : "1f4fa81c-3b83-4a24-a2ca-791462d65ae5",
- "X-Runtime" : "0.437640",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 09:05:37 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/storage/",
- "method" : "DELETE",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/plain"
- },
- "Accept" : {
- "equalTo" : "text/plain"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-storage-3DT6z.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/plain; charset=utf-8",
- "Cache-Control" : "no-cache",
- "X-Request-Id" : "8646cdb3-0ee9-47b3-9cab-bfff18ce0ff0",
- "X-Runtime" : "0.254896",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 08:57:54 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/storage/8f423fd4-0fdb-4422-a01b-fb6594173fbb",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/occi"
- },
- "Accept" : {
- "equalTo" : "text/occi"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-storage-8f423fd4-0fdb-4422-a01b-fb6594173fbb-b6DVv.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Category" : "storage;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/storage/\";title=\"storage resource\"",
- "X-Occi-Attribute" : "occi.core.id=\"8f423fd4-0fdb-4422-a01b-fb6594173fbb\",occi.storage.state=\"offline\"",
- "Content-Type" : "text/occi; charset=utf-8",
- "Cache-Control" : "no-cache",
- "X-Request-Id" : "0089a5e0-f57d-4426-9ef8-e008a4e2f4de",
- "X-Runtime" : "0.479163",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 09:05:36 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/storage/8f423fd4-0fdb-4422-a01b-fb6594173fbb",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/plain"
- },
- "Accept" : {
- "equalTo" : "text/plain"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-storage-8f423fd4-0fdb-4422-a01b-fb6594173fbb-uPiUB.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/plain; charset=utf-8",
- "Etag" : "\"8b54581448175d04004acff7b9579b44\"",
- "Cache-Control" : "max-age=0, private, must-revalidate",
- "X-Request-Id" : "6a8a5b9f-39f5-4487-bcaa-e80fe175982c",
- "X-Runtime" : "0.244130",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 08:57:33 GMT",
- "Content-Length" : "246",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/storage/a7eeebf0-a93f-4187-bd86-dab2725d5bfa",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/occi"
- },
- "Accept" : {
- "equalTo" : "text/occi"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-storage-a7eeebf0-a93f-4187-bd86-dab2725d5bfa-M22T3.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Category" : "storage;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/storage/\";title=\"storage resource\"",
- "X-Occi-Attribute" : "occi.core.id=\"a7eeebf0-a93f-4187-bd86-dab2725d5bfa\",occi.storage.state=\"offline\"",
- "Content-Type" : "text/occi; charset=utf-8",
- "Cache-Control" : "no-cache",
- "X-Request-Id" : "c1b3d5a2-a257-4fd8-9197-e00e7584f75e",
- "X-Runtime" : "0.432960",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 09:05:36 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/storage/a7eeebf0-a93f-4187-bd86-dab2725d5bfa",
- "method" : "GET",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/plain"
- },
- "Accept" : {
- "equalTo" : "text/plain"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-storage-a7eeebf0-a93f-4187-bd86-dab2725d5bfa-MGDwo.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/plain; charset=utf-8",
- "Etag" : "\"6845923790f239556c70518d828a1853\"",
- "Cache-Control" : "max-age=0, private, must-revalidate",
- "X-Request-Id" : "a0c35e5f-60af-4d44-bddf-4d1df3581c3a",
- "X-Runtime" : "0.249227",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 08:57:34 GMT",
- "Content-Length" : "246",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "request" : {
- "url" : "/storage/",
- "method" : "DELETE",
- "headers" : {
- "Content-Type" : {
- "equalTo" : "text/occi"
- },
- "Accept" : {
- "equalTo" : "text/occi"
- }
- }
- },
- "response" : {
- "status" : 200,
- "bodyFileName" : "body-storage-dpXcr.json",
- "headers" : {
- "Connection" : "keep-alive",
- "X-Frame-Options" : "SAMEORIGIN",
- "X-Xss-Protection" : "1; mode=block",
- "X-Content-Type-Options" : "nosniff",
- "Content-Type" : "text/occi; charset=utf-8",
- "Cache-Control" : "no-cache",
- "X-Request-Id" : "acc60993-f723-4d90-a1ca-2f9707c902dd",
- "X-Runtime" : "0.484805",
- "Server" : "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)",
- "Date" : "Thu, 19 Feb 2015 09:06:03 GMT",
- "Content-Length" : "0",
- "Via" : "1.1 vegur"
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-build.xml
-/nbproject
-nb-configuration.xml
-/target/
-release.properties
-pom.xml.releaseBackup
-nbactions.xml
+++ /dev/null
-language: java
-
-jdk:
- - openjdk7
- - oraclejdk7
- - oraclejdk8
-
-bracnhes:
- only:
- - master
+++ /dev/null
-The work represented by this source file is partially or entirely funded
-by the EGI-InSPIRE project through the European Commission's 7th Framework
-Programme (contract # INFSO-RI-261323)
-
-Copyright (c) 2014-2015 CESNET
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
+++ /dev/null
-jOCCI-core - A Java OCCI Framework
-==================================
-
-[](http://travis-ci.org/EGI-FCTF/jOCCI-core)
-
-Requirements
-------------
-* JDK 7+
-* Maven
-
-Installation
-------------
-Using Maven:
-```xml
-<dependency>
- <groupId>cz.cesnet.cloud</groupId>
- <artifactId>jocci-core</artifactId>
- <version>0.2.4</version>
-</dependency>
-```
-### Continuous integration
-
-[Continuous integration for jOCCI by Travis-CI](http://travis-ci.org/EGI-FCTF/jOCCI-core/)
-
-### Contribute
-
-1. Fork it.
-2. Create a branch (git checkout -b my_markup)
-3. Commit your changes (git commit -am "My changes")
-4. Push to the branch (git push origin my_markup)
-5. Create an Issue with a link to your branch
--- /dev/null
+version=3
+opts="filenamemangle=s/(?:.*)?jocci-core-?(\d[\d\.]*)\.tar\.gz/jOCCI-core-$1.tar.gz/" \
+ https://github.com/EGI-FCTF/jOCCI-core/tags (?:.*/)?jocci-core-?(\d[\d\.]*)\.tar\.gz
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>cz.cesnet.cloud</groupId>
- <artifactId>jocci-core</artifactId>
- <version>0.2.4</version>
- <packaging>jar</packaging>
- <name>${project.groupId}:${project.artifactId}</name>
- <description>A Java OCCI framework - core library.</description>
- <url>https://github.com/EGI-FCTF/jOCCI-core</url>
- <licenses>
- <license>
- <name>The Apache License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- <developers>
- <developer>
- <name>Michal Kimle</name>
- <email>kimle.michal@gmail.com</email>
- <organization>CESNET</organization>
- <organizationUrl>http://www.cesnet.cz/</organizationUrl>
- </developer>
- </developers>
- <scm>
- <connection>scm:git:git@github.com:EGI-FCTF/jOCCI-core.git</connection>
- <developerConnection>scm:git:git@github.com:EGI-FCTF/jOCCI-core.git</developerConnection>
- <url>https://github.com/EGI-FCTF/jOCCI-core</url>
- <tag>jocci-core-0.2.4</tag>
- </scm>
- <dependencies>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.7.7</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>1.7.7</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.10</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <maven.compiler.source>1.7</maven.compiler.source>
- <maven.compiler.target>1.7</maven.compiler.target>
- <github.global.server>github</github.global.server>
- </properties>
- <distributionManagement>
- <snapshotRepository>
- <id>ossrh</id>
- <url>https://oss.sonatype.org/content/repositories/snapshots</url>
- </snapshotRepository>
- <repository>
- <id>ossrh</id>
- <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
- </repository>
- </distributionManagement>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.9</version>
- <reportSets>
- <reportSet>
- <reports>
- <report>javadoc</report>
- </reports>
- </reportSet>
- <reportSet>
- <id>aggregate</id>
- <inherited>false</inherited>
- <reports>
- <report>aggregate</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- </plugins>
- </reporting>
- <build>
- <plugins>
- <plugin>
- <groupId>org.sonatype.plugins</groupId>
- <artifactId>nexus-staging-maven-plugin</artifactId>
- <version>1.6.3</version>
- <extensions>true</extensions>
- <configuration>
- <serverId>ossrh</serverId>
- <nexusUrl>https://oss.sonatype.org/</nexusUrl>
- <autoReleaseAfterClose>true</autoReleaseAfterClose>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-release-plugin</artifactId>
- <version>2.5</version>
- <configuration>
- <autoVersionSubmodules>true</autoVersionSubmodules>
- <useReleaseProfile>false</useReleaseProfile>
- <releaseProfiles>release</releaseProfiles>
- <goals>deploy</goals>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-site-plugin</artifactId>
- <version>3.4</version>
- </plugin>
- <plugin>
- <groupId>com.github.github</groupId>
- <artifactId>site-maven-plugin</artifactId>
- <version>0.11</version>
- <configuration>
- <message>Creating site for ${project.version}</message>
- <server>github</server>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>site</goal>
- </goals>
- <phase>site</phase>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <profiles>
- <profile>
- <id>release</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <version>2.2.1</version>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar-no-fork</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.9.1</version>
- <executions>
- <execution>
- <id>attach-javadocs</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-gpg-plugin</artifactId>
- <version>1.5</version>
- <executions>
- <execution>
- <id>sign-artifacts</id>
- <phase>verify</phase>
- <goals>
- <goal>sign</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
\ No newline at end of file
+++ /dev/null
-package cz.cesnet.cloud.occi;
-
-import cz.cesnet.cloud.occi.collection.SetCover;
-import cz.cesnet.cloud.occi.core.ActionInstance;
-import cz.cesnet.cloud.occi.core.Link;
-import cz.cesnet.cloud.occi.core.Resource;
-import java.util.Objects;
-import java.util.Set;
-
-/**
- * Class representing a collection of OCCI instances. It can contain instances
- * of classes Resource, Link and ActionInstance. Collection can be assigned a
- * Model instance which will represent a OCCI model structure for all the
- * instances in the collection.
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class Collection {
-
- private final SetCover<Resource> resources = new SetCover<>();
- private final SetCover<Link> links = new SetCover<>();
- private final SetCover<ActionInstance> actions = new SetCover<>();
- private Model model;
-
- /**
- * Creates an empty collection instance.
- */
- public Collection() {
- }
-
- /**
- * Checks whether collection contains the resource.
- *
- * @param resource resource looked up in the collection
- * @return true if collection contains the resource, false otherwise
- */
- public boolean containsResource(Resource resource) {
- return resources.contains(resource);
- }
-
- /**
- * Checks whether collection contains the resource specified by its
- * identifier.
- *
- * @param resourceIdentifier identifier of the resource looked up in the
- * collection
- * @return true if collection contains the resource, false otherwise
- */
- public boolean containsResource(String resourceIdentifier) {
- return resources.contains(resourceIdentifier);
- }
-
- /**
- * Adds resource instance to the collection.
- *
- * @param resource resource to be added to the collection
- * @return true if the addition was successful, false otherwise
- */
- public boolean addResource(Resource resource) {
- return resources.add(resource);
- }
-
- /**
- * Retrieves the resource specified by its identifier from the collection.
- *
- * @param resourceIdentifier identifier of the retrieved resource
- * @return specified resource if in collection, null otherwise
- */
- public Resource getResource(String resourceIdentifier) {
- return resources.get(resourceIdentifier);
- }
-
- /**
- * Removes resource from the collection.
- *
- * @param resource resource instance to remove from the collection
- * @return true if the removal was successful, false otherwise
- */
- public boolean removeResource(Resource resource) {
- return resources.remove(resource);
- }
-
- /**
- * Removes all resources from the collection.
- */
- public void clearResources() {
- resources.clear();
- }
-
- /**
- * Returns all resources in the collection in form of a set.
- *
- * @return set of all resources in the collection
- */
- public Set<Resource> getResources() {
- return resources.getSet();
- }
-
- /**
- * Checks whether collection contains the link.
- *
- * @param link link looked up in the collection
- * @return true if collection contains the link, false otherwise
- */
- public boolean containsLink(Link link) {
- return links.contains(link);
- }
-
- /**
- * Checks whether collection contains the link specified by its identifier.
- *
- * @param linkIdentifier identifier of the link looked up in the collection
- * @return true if collection contains the link, false otherwise
- */
- public boolean containsLink(String linkIdentifier) {
- return links.contains(linkIdentifier);
- }
-
- /**
- * Adds link instance to the collection.
- *
- * @param link link to be added to the collection
- * @return true if the addition was successful, false otherwise
- */
- public boolean addLink(Link link) {
- return links.add(link);
- }
-
- /**
- * Retrieves the link specified by its identifier from the collection.
- *
- * @param linkIdentifier identifier of the retrieved link
- * @return specified link if in collection, null otherwise
- */
- public Link getLink(String linkIdentifier) {
- return links.get(linkIdentifier);
- }
-
- /**
- * Removes link from the collection.
- *
- * @param link link instance to remove from the collection
- * @return true if the removal was successful, false otherwise
- */
- public boolean removeLink(Link link) {
- return links.remove(link);
- }
-
- /**
- * Removes all links from the collection.
- */
- public void clearLinks() {
- links.clear();
- }
-
- /**
- * Returns all links in the collection in form of a set.
- *
- * @return set of all links in the collection
- */
- public Set<Link> getLinks() {
- return links.getSet();
- }
-
- /**
- * Checks whether collection contains the action.
- *
- * @param action action looked up in the collection
- * @return true if collection contains the action, false otherwise
- */
- public boolean containsAction(ActionInstance action) {
- return actions.contains(action);
- }
-
- /**
- * Checks whether collection contains the action specified by its
- * identifier.
- *
- * @param actionIdentifier identifier of the action looked up in the
- * collection
- * @return true if collection contains the action, false otherwise
- */
- public boolean containsAction(String actionIdentifier) {
- return actions.contains(actionIdentifier);
- }
-
- /**
- * Adds action instance to the collection.
- *
- * @param action action to be added to the collection
- * @return true if the addition was successful, false otherwise
- */
- public boolean addAction(ActionInstance action) {
- return actions.add(action);
- }
-
- /**
- * Retrieves the action specified by its identifier from the collection.
- *
- * @param actionIdentifier identifier of the retrieved action
- * @return specified action if in collection, null otherwise
- */
- public ActionInstance getAction(String actionIdentifier) {
- return actions.get(actionIdentifier);
- }
-
- /**
- * Removes action from the collection.
- *
- * @param action action instance to remove from the collection
- * @return true if the removal was successful, false otherwise
- */
- public boolean removeAction(ActionInstance action) {
- return actions.remove(action);
- }
-
- /**
- * Removes all actions from the collection.
- */
- public void clearActions() {
- actions.clear();
- }
-
- /**
- * Returns all actions in the collection in form of a set.
- *
- * @return set of all actions in the collection
- */
- public Set<ActionInstance> getActions() {
- return actions.getSet();
- }
-
- /**
- * Merges collection's content to the current collection.
- *
- * @param collection collection which content should be merged
- */
- public void merge(Collection collection) {
- resources.addAll(collection.getResources());
- links.addAll(collection.getLinks());
- actions.addAll(collection.getActions());
- }
-
- /**
- * Sets model for the whole collection (all the resources, links and actions
- * in the collection)
- *
- * @param model model to be set for this collection
- */
- public void setModel(Model model) {
- this.model = model;
- for (Link link : links.getSet(true)) {
- link.setModel(model);
- }
- for (Resource resource : resources.getSet(true)) {
- resource.setModel(model);
- }
- for (ActionInstance ai : actions.getSet(true)) {
- ai.setModel(model);
- }
- }
-
- /**
- * Returns collection's model.
- *
- * @return collection's model
- */
- public Model getModel() {
- return model;
- }
-
- /**
- * @see Object#hashCode()
- * @return collection's hash code
- */
- @Override
- public int hashCode() {
- int hash = 5;
- hash = 41 * hash + Objects.hashCode(this.resources);
- hash = 41 * hash + Objects.hashCode(this.links);
- return hash;
- }
-
- /**
- * @see Object#equals(java.lang.Object)
- * @param obj object to compare collection with
- * @return true if two collections are equal, false otherwise
- */
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final Collection other = (Collection) obj;
- if (!Objects.equals(this.resources, other.resources)) {
- return false;
- }
- if (!Objects.equals(this.links, other.links)) {
- return false;
- }
- if (!Objects.equals(this.actions, other.actions)) {
- return false;
- }
- return true;
- }
-
- /**
- * Resturns string representation of the collection
- *
- * @see Object#toString()
- * @return string representation of the collection
- */
- @Override
- public String toString() {
- return "Collection{" + "resources=" + resources + ", links=" + links + ", model=" + model + '}';
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi;
-
-import cz.cesnet.cloud.occi.collection.SetCover;
-import cz.cesnet.cloud.occi.core.Action;
-import cz.cesnet.cloud.occi.core.Kind;
-import cz.cesnet.cloud.occi.core.Link;
-import cz.cesnet.cloud.occi.core.Mixin;
-import cz.cesnet.cloud.occi.core.Resource;
-import cz.cesnet.cloud.occi.exception.AmbiguousIdentifierException;
-import cz.cesnet.cloud.occi.parser.CollectionType;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
-
-/**
- * Class representing an OCCI model. Can contain instances of classes Kind,
- * Mixin and Action.
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class Model {
-
- private final SetCover<Kind> kinds = new SetCover<>();
- private final SetCover<Mixin> mixins = new SetCover<>();
- private final SetCover<Action> actions = new SetCover<>();
-
- /**
- * Creates an empty model.
- */
- public Model() {
- }
-
- /**
- * Checks whether model contains a kind
- *
- * @param kind kind looked up in the model
- * @return true if model contains the kind, false otherwise
- */
- public boolean containsKind(Kind kind) {
- return kinds.contains(kind);
- }
-
- /**
- * Checks whether model contains a kind specified by the identifier
- *
- * @param kindIdentifier identifier for the kind looked up in the model
- * @return true if model contains the kind, false otherwise
- */
- public boolean containsKind(String kindIdentifier) {
- return kinds.contains(kindIdentifier);
- }
-
- /**
- * Adds kind to the model.
- *
- * @param kind kind to be added to the model
- * @return true if the addition was successful, false otherwise
- */
- public boolean addKind(Kind kind) {
- return kinds.add(kind);
- }
-
- /**
- * Retrieves a kind from the model.
- *
- * @param kindIdentifier identifier of the kind to be retrieved
- * @return kind instance from the mdoel
- */
- public Kind getKind(String kindIdentifier) {
- return kinds.get(kindIdentifier);
- }
-
- /**
- * Removes kind from model.
- *
- * @param kind kind to be removed from the model
- * @return true if the removal was successful, false otherwise
- */
- public boolean removeKind(Kind kind) {
- return kinds.remove(kind);
- }
-
- /**
- * Remove all kinds from the model.
- */
- public void clearKinds() {
- kinds.clear();
- }
-
- /**
- * Returns all kinds from the model in a form of set.
- *
- * @return set of all kinds from the model
- */
- public Set<Kind> getKinds() {
- return kinds.getSet();
- }
-
- /**
- * Checks whether model contains a mixin
- *
- * @param mixin mixin looked up in the model
- * @return true if model contains the mixin, false otherwise
- */
- public boolean containsMixin(Mixin mixin) {
- return mixins.contains(mixin);
- }
-
- /**
- * Checks whether model contains a mixin specified by the identifier
- *
- * @param mixinIdentifier identifier for the mixin looked up in the model
- * @return true if model contains the mixin, false otherwise
- */
- public boolean containsMixin(String mixinIdentifier) {
- return mixins.contains(mixinIdentifier);
- }
-
- /**
- * Adds mixin to the model.
- *
- * @param mixin mixin to be added to the model
- * @return true if the addition was successful, false otherwise
- */
- public boolean addMixin(Mixin mixin) {
- return mixins.add(mixin);
- }
-
- /**
- * Retrieves a mixin from the model.
- *
- * @param mixinIdentifier identifier of the mixin to be retrieved
- * @return mixin instance from the mdoel
- */
- public Mixin getMixin(String mixinIdentifier) {
- return mixins.get(mixinIdentifier);
- }
-
- /**
- * Removes mixin from model.
- *
- * @param mixin mixin to be removed from the model
- * @return true if the removal was successful, false otherwise
- */
- public boolean removeMixin(Mixin mixin) {
- return mixins.remove(mixin);
- }
-
- /**
- * Remove all mixins from the model.
- */
- public void clearMixins() {
- mixins.clear();
- }
-
- /**
- * Returns all mixins from the model in a form of set.
- *
- * @return set of all mixins from the model
- */
- public Set<Mixin> getMixins() {
- return mixins.getSet();
- }
-
- /**
- * Checks whether model contains a action
- *
- * @param action action looked up in the model
- * @return true if model contains the action, false otherwise
- */
- public boolean containsAction(Action action) {
- return actions.contains(action);
- }
-
- /**
- * Checks whether model contains a action specified by the identifier
- *
- * @param actionIdentifier identifier for the action looked up in the model
- * @return true if model contains the action, false otherwise
- */
- public boolean containsAction(String actionIdentifier) {
- return actions.contains(actionIdentifier);
- }
-
- /**
- * Adds action to the model.
- *
- * @param action action to be added to the model
- * @return true if the addition was successful, false otherwise
- */
- public boolean addAction(Action action) {
- return actions.add(action);
- }
-
- /**
- * Retrieves a action from the model.
- *
- * @param actionIdentifier identifier of the action to be retrieved
- * @return action instance from the mdoel
- */
- public Action getAction(String actionIdentifier) {
- return actions.get(actionIdentifier);
- }
-
- /**
- * Removes action from model.
- *
- * @param action action to be removed from the model
- * @return true if the removal was successful, false otherwise
- */
- public boolean removeAction(Action action) {
- return actions.remove(action);
- }
-
- /**
- * Remove all actions from the model.
- */
- public void clearActions() {
- actions.clear();
- }
-
- /**
- * Returns all actions from the model in a form of set.
- *
- * @return set of all actions from the model
- */
- public Set<Action> getActions() {
- return actions.getSet();
- }
-
- /**
- * Finds kind with given identifier (schema+term) in model.
- *
- * @param identifier
- * @return Kind instance with given identifier if found, null otherwise
- */
- public Kind findKind(URI identifier) {
- if (identifier == null) {
- return null;
- }
-
- String identifierString = identifier.toString();
- for (Kind kind : kinds.getSet()) {
- if (kind.getIdentifier().equals(identifierString)) {
- return kind;
- }
- }
-
- return null;
- }
-
- /**
- * Finds kind with given term in model.
- *
- * @param term
- * @return Kind instance with given term if found, null otherwise
- * @throws AmbiguousIdentifierException if model contains more than one kind
- * with given term
- */
- public Kind findKind(String term) throws AmbiguousIdentifierException {
- Kind foundKind = null;
- for (Kind kind : kinds.getSet()) {
- if (kind.getTerm().equals(term)) {
- if (foundKind != null) {
- throw new AmbiguousIdentifierException("term '" + term + "' is ambiguous");
- }
- foundKind = kind;
- }
- }
-
- return foundKind;
- }
-
- /**
- * Finds kinds related to kind specified by given identifier.
- *
- * @param identifier
- * @return list of Kinds related to the one specified Kind
- */
- public List<Kind> findRelatedKinds(URI identifier) {
- Kind main = findKind(identifier);
- return getRelatedKinds(main);
- }
-
- /**
- * Finds kinds related to kind specified by given term.
- *
- * @param term
- * @return list of Kinds related to the one specified Kind
- * @throws AmbiguousIdentifierException if model contains more than one kind
- * with given term
- */
- public List<Kind> findRelatedKinds(String term) throws AmbiguousIdentifierException {
- Kind main = findKind(term);
- return getRelatedKinds(main);
- }
-
- private List<Kind> getRelatedKinds(Kind main) {
- List<Kind> related = new ArrayList<>();
- if (main == null) {
- return related;
- }
-
- for (Kind kind : kinds.getSet()) {
- if (kind.relatesTo(main)) {
- related.add(kind);
- }
- }
-
- return related;
- }
-
- /**
- * Determines CollectionType for given kind (for parsing purposes).
- *
- * @param kind
- * @return CollectionType instance if determined, null otherwise
- */
- public CollectionType findKindType(Kind kind) {
- while (kind != null) {
- if (kind.getIdentifier().equals(Resource.KIND_IDENTIFIER_DEFAULT)) {
- return CollectionType.RESOURCE;
- }
- if (kind.getIdentifier().equals(Link.KIND_IDENTIFIER_DEFAULT)) {
- return CollectionType.LINK;
- }
- kind = kind.getParentKind();
- }
-
- return null;
- }
-
- /**
- * Determines CollectionType for kind with given location (for parsing
- * purposes).
- *
- * @param location
- * @return CollectionType instance if determined, null otherwise
- */
- public CollectionType findKindType(String location) {
- Kind kind = null;
- for (Kind k : kinds.getSet()) {
- if (k.getLocation().getPath().equals(location)) {
- kind = k;
- break;
- }
- }
-
- return findKindType(kind);
- }
-
- //TODO: refactor findMixin methods
- /**
- * Finds mixin with given identifier (schema+term) in model.
- *
- * @param identifier
- * @return Mixin instance with given identifier if found, null otherwise
- */
- public Mixin findMixin(URI identifier) {
- if (identifier == null) {
- return null;
- }
-
- String identigfierString = identifier.toString();
- for (Mixin mixin : mixins.getSet()) {
- if (mixin.getIdentifier().equals(identigfierString)) {
- return mixin;
- }
- }
-
- return null;
- }
-
- /**
- * Finds mixin with given term in model.
- *
- * @param term
- * @return Mixin instance with given term if found, null otherwise
- * @throws AmbiguousIdentifierException if model contains more than one
- * mixin with given term
- */
- public Mixin findMixin(String term) throws AmbiguousIdentifierException {
- Mixin foundMixin = null;
- for (Mixin mixin : mixins.getSet()) {
- if (mixin.getTerm().equals(term)) {
- if (foundMixin != null) {
- throw new AmbiguousIdentifierException("term '" + term + "' is ambiguous");
- }
- foundMixin = mixin;
- }
- }
-
- return foundMixin;
- }
-
- /**
- * Finds mixin with given term and relation in model.
- *
- * @param term
- * @param rel term of related mixin
- * @return Mixin instance with given term and relation if found, null
- * otherwise
- * @throws AmbiguousIdentifierException if model contains more than one
- * mixin with given term
- */
- public Mixin findMixin(String term, String rel) throws AmbiguousIdentifierException {
- Mixin relMixin = findMixin(rel);
- if (relMixin == null) {
- return null;
- }
-
- Mixin foundMixin = null;
- for (Mixin mixin : mixins.getSet()) {
- if (mixin.getTerm().equals(term) && mixin.relatesTo(relMixin)) {
- if (foundMixin != null) {
- throw new AmbiguousIdentifierException("term '" + term + "' is ambiguous");
- }
- foundMixin = mixin;
- }
- }
-
- return foundMixin;
- }
-
- /**
- * Finds mixin with given term and relation in model.
- *
- * @param term
- * @param rel identifier of related mixin (scheme+term)
- * @return Mixin instance with given term and relation if found, null
- * otherwise
- * @throws AmbiguousIdentifierException if model contains more than one
- * mixin with given term
- */
- public Mixin findMixin(String term, URI rel) throws AmbiguousIdentifierException {
- if (rel == null) {
- return null;
- }
-
- Mixin foundMixin = null;
- for (Mixin mixin : mixins.getSet()) {
- if (mixin.getTerm().equals(term) && mixin.relatesTo(rel.toString())) {
- if (foundMixin != null) {
- throw new AmbiguousIdentifierException("term '" + term + "' is ambiguous");
- }
- foundMixin = mixin;
- }
- }
-
- return foundMixin;
- }
-
- /**
- * Finds mixins related to mixin specified by given identifier.
- *
- * @param identifier
- * @return list of Mixins related to the one specified Mixin
- */
- public List<Mixin> findRelatedMixins(URI identifier) {
- Mixin main = findMixin(identifier);
- return getRelatedMixins(main);
- }
-
- /**
- * Finds mixins related to mixin specified by given term.
- *
- * @param term
- * @return list of Mixins related to the one specified Mixin
- * @throws AmbiguousIdentifierException if model contains more than one
- * mixin with given term
- */
- public List<Mixin> findRelatedMixins(String term) throws AmbiguousIdentifierException {
- Mixin main = findMixin(term);
- return getRelatedMixins(main);
- }
-
- private List<Mixin> getRelatedMixins(Mixin main) {
- List<Mixin> related = new ArrayList<>();
- if (main == null) {
- return related;
- }
-
- for (Mixin mixin : mixins.getSet()) {
- if (mixin.relatesTo(main)) {
- related.add(mixin);
- }
- }
-
- return related;
- }
-
- /**
- * Finds action with given term in model.
- *
- * @param term
- * @return Action instance with given term if found, null otherwise
- * @throws AmbiguousIdentifierException if model contains more than one
- * action with given term
- */
- public Action findAction(String term) throws AmbiguousIdentifierException {
- Action foundAction = null;
- for (Action action : actions.getSet()) {
- if (action.getTerm().equals(term)) {
- if (foundAction != null) {
- throw new AmbiguousIdentifierException("term '" + term + "' is ambiguous");
- }
- foundAction = action;
- }
- }
-
- return foundAction;
- }
-
- /**
- * Finds action with given identifier (schema+term) in model.
- *
- * @param identifier
- * @return Action instance with given identifier if found, null otherwise
- */
- public Action findAction(URI identifier) {
- if (identifier == null) {
- return null;
- }
-
- String identigfierString = identifier.toString();
- for (Action action : actions.getSet()) {
- if (action.getIdentifier().equals(identigfierString)) {
- return action;
- }
- }
-
- return null;
- }
-
- /**
- * @see Object#hashCode()
- * @return model's hash code
- */
- @Override
- public int hashCode() {
- int hash = 3;
- hash = 59 * hash + Objects.hashCode(this.kinds);
- hash = 59 * hash + Objects.hashCode(this.mixins);
- hash = 59 * hash + Objects.hashCode(this.actions);
- return hash;
- }
-
- /**
- * @see Object#equals(java.lang.Object)
- * @param obj object to compare model with
- * @return true if two models are equal, false otherwise
- */
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final Model other = (Model) obj;
- if (!Objects.equals(this.kinds, other.kinds)) {
- return false;
- }
- if (!Objects.equals(this.mixins, other.mixins)) {
- return false;
- }
- if (!Objects.equals(this.actions, other.actions)) {
- return false;
- }
- return true;
- }
-
- /**
- * Resturns string representation of the model
- *
- * @see Object#toString()
- * @return string representation of the model
- */
- @Override
- public String toString() {
- return "Model{" + "kinds=" + kinds + ", mixins=" + mixins + ", actions=" + actions + '}';
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.collection;
-
-import com.sun.net.httpserver.Headers;
-import cz.cesnet.cloud.occi.core.Attribute;
-import cz.cesnet.cloud.occi.parser.TextParser;
-import cz.cesnet.cloud.occi.renderer.TextRenderer;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * Class representing attributes and their values.
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class AttributeMapCover {
-
- private final Map<Attribute, String> attributes = new HashMap<>();
-
- /**
- * Stores attribute and its value.
- *
- * @param attribute attribute to be stored. Cannot be null.
- * @param value value to be stored for the attribute. Cannot be null.
- */
- public void add(Attribute attribute, String value) {
- if (attribute == null) {
- throw new NullPointerException("Cannot add null attribute.");
- }
- if (value == null) {
- throw new NullPointerException("Cannot add null value.");
- }
-
- attributes.put(attribute, value);
- }
-
- /**
- * Removes attribute from the collection.
- *
- * @param attribute attribute to be removed. Cannot be null.
- */
- public void remove(Attribute attribute) {
- if (attribute == null) {
- throw new NullPointerException("Cannot remove null attribute.");
- }
-
- attributes.remove(attribute);
- }
-
- /**
- * Removes attribute from the collection.
- *
- * @param attributeName name of the attribute to be removed. Cannot be null.
- */
- public void remove(String attributeName) {
- Attribute attTmp = new Attribute(attributeName);
- attributes.remove(attTmp);
- }
-
- /**
- * Checks whether collection contains the attribute.
- *
- * @param attribute attribute to be looked up in the collection
- * @return true if collection contains the attribute, false otherwise
- */
- public boolean containsAttribute(Attribute attribute) {
- return attributes.containsKey(attribute);
- }
-
- /**
- * Checks whether collection contains the attribute.
- *
- * @param attributeName name of the attribute to be looked up in the
- * collection. Cannot be null.
- * @return true if collection contains the attribute, false otherwise
- */
- public boolean containsAttribute(String attributeName) {
- Attribute attTmp = new Attribute(attributeName);
- return containsAttribute(attTmp);
- }
-
- /**
- * Returns the value for the given attribute.
- *
- * @param attribute attribute of which value is returned.
- * @return value for the given attribute
- */
- public String getValue(Attribute attribute) {
- return attributes.get(attribute);
- }
-
- /**
- * Returns the value for the given attribute.
- *
- * @param attributeName name of the attribute of which value is returned.
- * Cannot be null.
- * @return value for the given attribute
- */
- public String getValue(String attributeName) {
- Attribute attTmp = new Attribute(attributeName);
- return getValue(attTmp);
- }
-
- /**
- * Returns all the attributes and their values in form of map.
- *
- * @return all the attributes and their values in form of map
- */
- public Map<Attribute, String> getAttributes() {
- return Collections.unmodifiableMap(attributes);
- }
-
- /**
- * Removes all attributes and their values from the collection.
- */
- public void clear() {
- attributes.clear();
- }
-
- /**
- * Returns the number of attributes in the collection.
- *
- * @return the number of attributes in the collection
- */
- public int size() {
- return attributes.size();
- }
-
- /**
- * @see Object#hashCode()
- * @return collection's hash code
- */
- @Override
- public int hashCode() {
- int hash = 5;
- hash = 83 * hash + Objects.hashCode(this.attributes);
- return hash;
- }
-
- /**
- * @see Object#equals(java.lang.Object)
- * @param obj object to compare collection with
- * @return true if two collections are equal, false otherwise
- */
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final AttributeMapCover other = (AttributeMapCover) obj;
- if (!Objects.equals(this.attributes, other.attributes)) {
- return false;
- }
- return true;
- }
-
- /**
- * Resturns string representation of the collection
- *
- * @see Object#toString()
- * @return string representation of the collection
- */
- @Override
- public String toString() {
- return "AttributeMapCover{" + attributes + '}';
- }
-
- /**
- * Generates a list of strings from attributes and their values
- *
- * @return attributes and their values in form of list of strings
- */
- private List<String> toList() {
- List<String> list = new ArrayList<>();
- List<Attribute> attributeList = new ArrayList<>(attributes.keySet());
- Collections.sort(attributeList);
- for (Attribute attribute : attributeList) {
- String name = attribute.getName();
- StringBuilder sb = new StringBuilder(name);
- String value = attributes.get(attribute);
- if (value.matches(TextParser.REGEXP_NUMBER)) {
- sb.append(TextRenderer.surroundString(value, "=", ""));
- } else {
- sb.append(TextRenderer.surroundString(value, "=\"", "\""));
- }
- list.add(sb.toString());
- }
-
- Collections.sort(list);
- return list;
- }
-
- /**
- * Returns a text representation of OCCI attributes with prefix.
- *
- * @return text representation of OCCI attributes with prefix
- */
- public String toPrefixText() {
- String prefix = "X-OCCI-Attribute: ";
- StringBuilder sb = new StringBuilder();
-
- for (String s : toList()) {
- sb.append(prefix);
- sb.append(s);
- sb.append("\n");
- }
-
- if (!sb.toString().isEmpty()) {
- sb.deleteCharAt(sb.length() - 1);
- }
-
- return sb.toString();
- }
-
- /**
- * Returns an occi text representation of OCCI attributes in form of
- * headers.
- *
- * @return occi text representation of OCCI attributes in form of headers
- */
- public Headers toHeaders() {
- Headers headers = new Headers();
-
- for (String s : toList()) {
- headers.add("X-OCCI-Attribute", s);
- }
-
- return headers;
- }
-
- /**
- * Returns text representation of OCCI attributes in one line.
- *
- * @return text representation of OCCI attributes in one line
- */
- public String toOneLineText() {
- StringBuilder sb = new StringBuilder();
-
- for (String s : toList()) {
-
- sb.append(s);
- sb.append(";");
- }
-
- return sb.toString();
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.collection;
-
-import cz.cesnet.cloud.occi.type.Identifiable;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Objects;
-
-/**
- * Collection class serving as a set for all classes identifiable.
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- * @param <E>
- */
-public class SetCover<E extends Identifiable> {
-
- private final Set<E> set = new HashSet<>();
-
- /**
- * Checks whether set contains the element.
- *
- * @param element looked up in the set
- * @return true if set contains the element, false otherwise
- */
- public boolean contains(E element) {
- return set.contains(element);
- }
-
- /**
- * Checks whether set contains an element specified by the identifier.
- *
- * @param elementIdentifier identifier of the element looked up in the set
- * @return true if set contains the element, false otherwise
- */
- public boolean contains(String elementIdentifier) {
- for (E element : set) {
- if (element.getIdentifier().equals(elementIdentifier)) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Adds element to the set.
- *
- * @param element element to be added. Cannot be null.
- * @return true if the addition was successful, false otherwise
- */
- public boolean add(E element) {
- if (element == null) {
- throw new NullPointerException("Cannot add null element.");
- }
-
- return set.add(element);
- }
-
- /**
- * Adds all elements from the collection to the set.
- *
- * @param elements collection of elements to be added. Cannot contain any
- * null elements.
- * @return true if the addition was successful, false otherwise
- */
- public boolean addAll(Collection<E> elements) {
- if (elements.contains(null)) {
- throw new NullPointerException("Cannot add null element.");
- }
-
- return set.addAll(elements);
- }
-
- /**
- * Retrieves element rom the set.
- *
- * @param elementIdentifier identifier of the element to be retrieved
- * @return element specified by its identifier if in set, null otherwise
- */
- public E get(String elementIdentifier) {
- if (!contains(elementIdentifier)) {
- return null;
- }
-
- return find(elementIdentifier);
- }
-
- /**
- * Removes element from the set
- *
- * @param element element to be remoed from the set. Cannot be null.
- * @return true if the deletion was successful, false otherwise
- */
- public boolean remove(E element) {
- if (element == null) {
- throw new NullPointerException("Cannot remove null element.");
- }
-
- return set.remove(element);
- }
-
- private E find(String elementIdentifier) {
- for (E element : set) {
- if (element.getIdentifier().equals(elementIdentifier)) {
- return element;
- }
- }
-
- return null;
- }
-
- /**
- * Removes all the elements from the set.
- */
- public void clear() {
- set.clear();
- }
-
- /**
- * Returns unmodifiable set of elements.
- *
- * @return unmodifiable set of elements
- */
- public Set<E> getSet() {
- return getSet(false);
- }
-
- /**
- * Returns set of elements.
- *
- * @param modifiable specifies if the set will be modifiable or not
- * @return set of elements
- */
- public Set<E> getSet(boolean modifiable) {
- if (modifiable) {
- return set;
- } else {
- return Collections.unmodifiableSet(set);
- }
- }
-
- /**
- * Returns number of elements in the set.
- *
- * @return number of elements in the set
- */
- public int size() {
- return set.size();
- }
-
- /**
- * @see Object#hashCode()
- * @return set's hash code
- */
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 53 * hash + Objects.hashCode(this.set);
- return hash;
- }
-
- /**
- * @see Object#equals(java.lang.Object)
- * @param obj object to compare set with
- * @return true if two sets are equal, false otherwise
- */
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final SetCover<?> other = (SetCover<?>) obj;
- if (!Objects.equals(this.set, other.set)) {
- return false;
- }
- return true;
- }
-
- /**
- * Resturns string representation of the set
- *
- * @see Object#toString()
- * @return string representation of the set
- */
- @Override
- public String toString() {
- return "SetCover{" + set + '}';
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.core;
-
-import com.sun.net.httpserver.Headers;
-import cz.cesnet.cloud.occi.renderer.TextRenderer;
-import cz.cesnet.cloud.occi.type.Identifiable;
-import java.net.URI;
-import java.util.Collection;
-import java.util.Objects;
-import java.util.Set;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Class representing an OCCI Action structure.
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class Action implements Identifiable, Comparable<Action> {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(Action.class);
- private Category category;
-
- /**
- * Constructor. Creates an Action instance with given scheme, term, title
- * and set of attributes.
- *
- * @param scheme action's scheme. Cannot be null.
- * @param term action's term. Cannot be null nor empty.
- * @param title action's title
- * @param attributes set of action's attributes
- */
- public Action(URI scheme, String term, String title, Collection<Attribute> attributes) {
- LOGGER.debug("Creating action: scheme={}, term={}, title={}, attributes={}", scheme, term, title, attributes);
- this.category = new Category(scheme, term, title, null, attributes);
- }
-
- /**
- * Constructor. Creates an Action instance with given scheme and term.
- *
- * @param scheme action's scheme. Cannot be null.
- * @param term action's term. Cannot be null nor empty.
- */
- public Action(URI scheme, String term) {
- this(scheme, term, null, null);
- }
-
- /**
- * Returns action's scheme.
- *
- * @return action's scheme.
- */
- public URI getScheme() {
- return category.getScheme();
- }
-
- /**
- * Sets action's scheme.
- *
- * @param scheme action's scheme. Cannot be null.
- */
- public void setScheme(URI scheme) {
- category.setScheme(scheme);
- }
-
- /**
- * Returns action's term.
- *
- * @return action's term.
- */
- public String getTerm() {
- return category.getTerm();
- }
-
- /**
- * Sets action's term.
- *
- * @param term action's term. Cannot be null nor empty.
- */
- public void setTerm(String term) {
- category.setTerm(term);
- }
-
- /**
- * Returns action's identifier.
- *
- * @return action's identifier
- */
- @Override
- public String getIdentifier() {
- return category.getIdentifier();
- }
-
- /**
- * Returns action's title.
- *
- * @return action's title
- */
- public String getTitle() {
- return category.getTitle();
- }
-
- /**
- * Sets action's title.
- *
- * @param title action's title
- */
- public void setTitle(String title) {
- category.setTitle(title);
- }
-
- /**
- * Checks whether action has the attribute.
- *
- * @param attribute attribute to be looked up
- * @return true if action has the attribute, false otherwise
- */
- public boolean containsAttribute(Attribute attribute) {
- return category.containsAttribute(attribute);
- }
-
- /**
- * Checks whether action has the attribute.
- *
- * @param attributeName name of the attribute to be looked up
- * @return true if action has the attribute, false otherwise
- */
- public boolean containsAttribute(String attributeName) {
- return category.containsAttribute(attributeName);
- }
-
- /**
- * Adds attribute to the action.
- *
- * @param attribute attribute to be added
- * @return true if the addition was successful, false otherwise
- */
- public boolean addAttribute(Attribute attribute) {
- return category.addAttribute(attribute);
- }
-
- /**
- * Retrieves an attribute from the action.
- *
- * @param attributeName name of the attribute to be retrieved
- * @return attribute
- */
- public Attribute getAttribute(String attributeName) {
- return category.getAttribute(attributeName);
- }
-
- /**
- * Removes attribute from the action.
- *
- * @param attribute attribute to be removed
- * @return true if the removal was successful, false otherwise
- */
- public boolean removeAttribute(Attribute attribute) {
- return category.removeAttribute(attribute);
- }
-
- /**
- * Returns all action's attribute in form of set.
- *
- * @return all action's attribute in form of set
- */
- public Set<Attribute> getAttributes() {
- return category.getAttributes();
- }
-
- /**
- * Returns action's default scheme 'http://schemas.ogf.org/occi/core#'
- *
- * @return action's default scheme
- */
- public URI getSchemeDefault() {
- return Category.SCHEME_CORE_DEFAULT;
- }
-
- /**
- * Returns action's default term 'term'
- *
- * @return action's default term
- */
- public String getTermDefault() {
- return "action";
- }
-
- /**
- * @see Object#hashCode()
- * @return action's hash code
- */
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 29 * hash + Objects.hashCode(this.category);
- return hash;
- }
-
- /**
- * @see Object#equals(java.lang.Object)
- * @param obj object to compare action with
- * @return true if two actions are equal, false otherwise
- */
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final Action other = (Action) obj;
- if (!Objects.equals(this.category, other.category)) {
- return false;
- }
- return true;
- }
-
- /**
- * Resturns string representation of the action
- *
- * @see Object#toString()
- * @return string representation of the action
- */
- @Override
- public String toString() {
- return "Action{" + "category=" + category + '}';
- }
-
- /**
- * Returns a text representation of action link as described in OCCI
- * standard.
- *
- * @param resourceLocation
- * @return text representation of action link
- */
- public String toText(String resourceLocation) {
- StringBuilder sb = new StringBuilder("Link: ");
- sb.append(textBody(resourceLocation));
-
- return sb.toString();
- }
-
- /**
- * Returns an occi text representation of action link as described in OCCI
- * standard in form of headers.
- *
- * @param resourceLocation
- * @return text representation of action link
- */
- public Headers toHeaders(String resourceLocation) {
- Headers headers = new Headers();
- headers.add("Link", textBody(resourceLocation));
-
- return headers;
- }
-
- private String textBody(String resourceLocation) {
- StringBuilder sb = new StringBuilder("");
-
- String descriptor = resourceLocation + "?action=" + getTerm();
- sb.append(TextRenderer.surroundString(descriptor, "<", ">;"));
-
- sb.append("rel");
- sb.append(TextRenderer.surroundString(getScheme().toString() + getTerm()));
-
- return sb.toString();
- }
-
- /**
- * Comapres two actions lexicographically based on their identifier.
- *
- * @see Comparable#compareTo(java.lang.Object)
- */
- @Override
- public int compareTo(Action a) {
- return getIdentifier().compareTo(a.getIdentifier());
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.core;
-
-import com.sun.net.httpserver.Headers;
-import cz.cesnet.cloud.occi.Model;
-import cz.cesnet.cloud.occi.collection.AttributeMapCover;
-import cz.cesnet.cloud.occi.renderer.TextRenderer;
-import cz.cesnet.cloud.occi.type.Identifiable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Class representing an instance of Action
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class ActionInstance implements Identifiable, Comparable<ActionInstance> {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ActionInstance.class);
- private final AttributeMapCover attributes = new AttributeMapCover();
- private Action action;
- private Model model;
-
- /**
- * Constructor. Creates an instance of ActionInstance with given Action.
- *
- * @param action action to create instance of. Cannot be null.
- */
- public ActionInstance(Action action) {
- LOGGER.debug("Creating ActionInstance: action={}", action);
-
- if (action == null) {
- throw new NullPointerException("ActionInstance action cannot be null.");
- }
-
- this.action = action;
- }
-
- /**
- * Returns action of this instance.
- *
- * @return action of this instance
- */
- public Action getAction() {
- return action;
- }
-
- /**
- * Sets action for this instance.
- *
- * @param action action for this instance. Cannot be null.
- */
- public void setAction(Action action) {
- if (action == null) {
- throw new NullPointerException("ActionInstance action cannot be null.");
- }
-
- this.action = action;
- }
-
- /**
- * Returns action's identifier.
- *
- * @return action's identifier
- */
- @Override
- public String getIdentifier() {
- return action.getIdentifier();
- }
-
- /**
- * Returns instance's model.
- *
- * @return instance's model
- */
- public Model getModel() {
- return model;
- }
-
- /**
- * Sets model for the instance.
- *
- * @param model model for the instance
- */
- public void setModel(Model model) {
- this.model = model;
- }
-
- /**
- * Adds attribute and its value for the instance.
- *
- * @param attribute attribute to be added
- * @param value value of the attribute to be added
- */
- public void addAttribute(Attribute attribute, String value) {
- attributes.add(attribute, value);
- }
-
- /**
- * Adds all attributes and their values from the given map.
- *
- * @param attributes map of attributes and their values
- */
- public void addAttributes(Map<String, String> attributes) {
- for (String name : attributes.keySet()) {
- addAttribute(new Attribute(name), attributes.get(name));
- }
- }
-
- /**
- * Removes attribute and its value from the instance.
- *
- * @param attribute attribute to be removed
- */
- public void removeAttribute(Attribute attribute) {
- attributes.remove(attribute);
- }
-
- /**
- * Checks whether the instance has an attribute.
- *
- * @param attribute attribute to be looked up
- * @return true if instance has the attribute, false otherwise
- */
- public boolean containsAttribute(Attribute attribute) {
- return attributes.containsAttribute(attribute);
- }
-
- /**
- * Checks whether the instance has an attribute.
- *
- * @param attributeName name of the attribute to be looked up
- * @return true if instance has the attribute, false otherwise
- */
- public boolean containsAttribute(String attributeName) {
- return attributes.containsAttribute(attributeName);
- }
-
- /**
- * Returns value of the given attribute.
- *
- * @param attribute attribute which value is returned
- * @return value of the given attribute
- */
- public String getValue(Attribute attribute) {
- return attributes.getValue(attribute);
- }
-
- /**
- * Returns value of the given attribute.
- *
- * @param attributeName name of the attribute which value is returned
- * @return value of the given attribute
- */
- public String getValue(String attributeName) {
- return attributes.getValue(attributeName);
- }
-
- /**
- * Returns all instance's attributes and their values in form of map.
- *
- * @return all instance's attributes and their values in form of map
- */
- public Map<Attribute, String> getAttributes() {
- return attributes.getAttributes();
- }
-
- /**
- * Removes all attributes with their values from the instance.
- */
- public void clearAttributes() {
- attributes.clear();
- }
-
- /**
- * Returns a plain text representation of action instance as described in
- * OCCI standard.
- *
- * @return text representation of action instance
- */
- public String toText() {
- StringBuilder sb = new StringBuilder("Category: ");
- sb.append(textBody());
-
- String attributesString = attributes.toPrefixText();
- if (!attributesString.isEmpty()) {
- sb.append("\n");
- sb.append(attributesString);
- }
-
- return sb.toString();
- }
-
- /**
- * Returns an occi text representation of action instance as described in
- * OCCI standard in form of headers.
- *
- * @return occi text representation of action instance in form of headers
- */
- public Headers toHeaders() {
- Headers headers = new Headers();
- headers.add("Category", textBody());
-
- Headers attributesHeaders = attributes.toHeaders();
- if (!attributesHeaders.isEmpty()) {
- headers.putAll(attributesHeaders);
- }
-
- return headers;
- }
-
- private String textBody() {
- StringBuilder sb = new StringBuilder(action.getTerm());
- sb.append(";");
- sb.append("scheme");
- sb.append(TextRenderer.surroundString(action.getScheme().toString()));
- sb.append("class");
- sb.append(TextRenderer.surroundString(action.getClass().getSimpleName().toLowerCase()));
-
- String title = action.getTitle();
- if (title != null && !title.isEmpty()) {
- sb.append("title");
- sb.append(TextRenderer.surroundString(title));
- }
-
- Set<Attribute> actionAttributes = action.getAttributes();
- if (actionAttributes != null && !actionAttributes.isEmpty()) {
- sb.append("attributes");
- StringBuilder attrSB = new StringBuilder();
- List<Attribute> attributeList = new ArrayList<>(actionAttributes);
- Collections.sort(attributeList);
- for (Attribute attribute : attributeList) {
- attrSB.append(attribute.toText());
- attrSB.append(" ");
- }
- attrSB.deleteCharAt(attrSB.length() - 1);
- sb.append(TextRenderer.surroundString(attrSB.toString()));
- }
-
- return sb.toString();
- }
-
- /**
- * @see Object#hashCode()
- * @return instance's hash code
- */
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 41 * hash + Objects.hashCode(this.attributes);
- hash = 41 * hash + Objects.hashCode(this.action);
- return hash;
- }
-
- /**
- * @see Object#equals(java.lang.Object)
- * @param obj object to compare instance with
- * @return true if two instances are equal, false otherwise
- */
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final ActionInstance other = (ActionInstance) obj;
- if (!Objects.equals(this.attributes, other.attributes)) {
- return false;
- }
- if (!Objects.equals(this.action, other.action)) {
- return false;
- }
- return true;
- }
-
- /**
- * Resturns string representation of the instance
- *
- * @see Object#toString()
- * @return string representation of the instance
- */
- @Override
- public String toString() {
- return "ActionInstance{" + "attributes=" + attributes + ", action=" + action + '}';
- }
-
- /**
- * Comapres two instances lexicographically based on their actions.
- *
- * @see Comparable#compareTo(java.lang.Object)
- */
- @Override
- public int compareTo(ActionInstance a) {
- return getIdentifier().compareTo(a.getIdentifier());
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.core;
-
-import cz.cesnet.cloud.occi.renderer.TextRenderer;
-import cz.cesnet.cloud.occi.type.Identifiable;
-import java.util.Objects;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Class representing an OCCI attribute. Attributes are used to store properties
- * of OCCI classes.
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class Attribute implements Identifiable, Comparable<Attribute> {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(Attribute.class);
- private String name;
- private boolean required;
- private boolean immutable;
- private String type;
- private String pattern;
- private String defaultValue;
- private String description;
-
- /**
- * Constructor.
- *
- * @param name name of the attribute. Cannot be null nor empty.
- * @param required whether attribute is required or not
- * @param immutable whether attribute is immutable or not
- * @param type attribute's type
- * @param pattern attribute's pattern
- * @param defaultValue attribute's default value
- * @param description attribute's description
- */
- public Attribute(String name, boolean required, boolean immutable, String type, String pattern, String defaultValue, String description) {
- LOGGER.debug("Creating attribute: name={}, required={}, immutable={}, type={}, pattern={}, defaultValue={}, description={}",
- name, required, immutable, type, pattern, defaultValue, description);
-
- if (name == null) {
- throw new NullPointerException("Attribute name cannot be null.");
- }
- if (name.isEmpty()) {
- throw new IllegalArgumentException("Attribute name cannot be empty.");
- }
-
- this.name = name;
- this.required = required;
- this.immutable = immutable;
- this.type = type;
- this.pattern = pattern == null ? ".*" : pattern;
- this.defaultValue = defaultValue;
- this.description = description;
- }
-
- /**
- * Constructor.
- *
- * @param name name of the attribute. Cannot be null nor empty.
- * @param required whether attribute is required or not
- * @param immutable whether attribute is immutable or not
- */
- public Attribute(String name, boolean required, boolean immutable) {
- this(name, required, immutable, null, null, null, null);
- }
-
- /**
- * Constructor.
- *
- * @param name name of the attribute. Cannot be null nor empty.
- */
- public Attribute(String name) {
- this(name, false, false, null, null, null, null);
- }
-
- /**
- * Returns attribute's name.
- *
- * @return attribute's name
- */
- public String getName() {
- return name;
- }
-
- /**
- * Sets attribute's name.
- *
- * @param name attribute's name. Cannot be null nor empty
- */
- public void setName(String name) {
- if (name == null) {
- throw new NullPointerException("Attribute name cannot be null.");
- }
- if (name.isEmpty()) {
- throw new IllegalArgumentException("Attribute name cannot be empty.");
- }
-
- this.name = name;
- }
-
- /**
- * Returns attribute's identifier.
- *
- * @return attribute's identifier
- */
- @Override
- public String getIdentifier() {
- return getName();
- }
-
- /**
- * Returns whether atttribute is required.
- *
- * @return true if attribute is required, false otherwise
- */
- public boolean isRequired() {
- return required;
- }
-
- /**
- * Sets attribute's requiredness.
- *
- * @param required whether the attribute should be required or not
- */
- public void setRequired(boolean required) {
- this.required = required;
- }
-
- /**
- * Returns whether atttribute is immutable.
- *
- * @return true if attribute is immutable, false otherwise
- */
- public boolean isImmutable() {
- return immutable;
- }
-
- /**
- * Sets attribute's immutability.
- *
- * @param immutable whether the attribute should be immutable or not
- */
- public void setImmutable(boolean immutable) {
- this.immutable = immutable;
- }
-
- /**
- * Returns attribute's type.
- *
- * @return attribute's type
- */
- public String getType() {
- return type;
- }
-
- /**
- * Sets attribute's type.
- *
- * @param type attribute's type
- */
- public void setType(String type) {
- this.type = type;
- }
-
- /**
- * Returns attribute's pattern.
- *
- * @return attribute's pattern
- */
- public String getPattern() {
- return pattern;
- }
-
- /**
- * Sets attribute's pattern.
- *
- * @param pattern attribute's pattern
- */
- public void setPattern(String pattern) {
- this.pattern = pattern;
- }
-
- /**
- * Returns attribute's default value.
- *
- * @return attribute's default value
- */
- public String getDefaultValue() {
- return defaultValue;
- }
-
- /**
- * Sets attribute's default value.
- *
- * @param defaultValue attribute's default value
- */
- public void setDefaultValue(String defaultValue) {
- this.defaultValue = defaultValue;
- }
-
- /**
- * Returns attribute's description.
- *
- * @return attribute's description
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * Sets attribute's description.
- *
- * @param description attribute's description
- */
- public void setDescription(String description) {
- this.description = description;
- }
-
- /**
- * @see Object#hashCode()
- * @return attribute's hash code
- */
- @Override
- public int hashCode() {
- int hash = 3;
- hash = 53 * hash + Objects.hashCode(this.name);
- return hash;
- }
-
- /**
- * @see Object#equals(java.lang.Object)
- * @param obj object to compare attribute with
- * @return true if two attributes are equal, false otherwise
- */
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final Attribute other = (Attribute) obj;
- if (!Objects.equals(this.name, other.name)) {
- return false;
- }
- return true;
- }
-
- /**
- * Resturns string representation of the attribute
- *
- * @see Object#toString()
- * @return string representation of the attribute
- */
- @Override
- public String toString() {
- return "Attribute{" + "name=" + name + ", required=" + required + ", immutable=" + immutable + ", type=" + type + ", pattern=" + pattern + ", defaultValue=" + defaultValue + ", description=" + description + '}';
- }
-
- /**
- * Returns plain text representation of the attribute according to OCCI
- * standard.
- *
- * @return plain text representation of the attribute
- */
- public String toText() {
- StringBuilder sb = new StringBuilder(name);
-
- StringBuilder properties = null;
- if (required) {
- properties = new StringBuilder("required");
- }
-
- if (immutable) {
- if (properties == null) {
- properties = new StringBuilder("immutable");
- } else {
- properties.append(" immutable");
- }
- }
-
- if (properties != null) {
- sb.append(TextRenderer.surroundString(properties.toString(), "{", "}"));
- }
-
- return sb.toString();
- }
-
- /**
- * Comapres two attributes lexicographically based on their identifier.
- *
- * @see Comparable#compareTo(java.lang.Object)
- */
- @Override
- public int compareTo(Attribute a) {
- return getIdentifier().compareTo(a.getIdentifier());
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.core;
-
-import com.sun.net.httpserver.Headers;
-import cz.cesnet.cloud.occi.collection.SetCover;
-import cz.cesnet.cloud.occi.renderer.TextRenderer;
-import cz.cesnet.cloud.occi.type.Identifiable;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Class representing an OCCI Category.
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class Category implements Identifiable, Comparable<Category> {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(Category.class);
- public static final URI SCHEME_CORE_DEFAULT = URI.create("http://schemas.ogf.org/occi/core#");
- public static final URI SCHEME_INFRASTRUCTURE_DEFAULT = URI.create("http://schemas.ogf.org/occi/infrastructure#");
-
- private String term;
- private URI scheme;
- private String title;
- private URI location;
- private final SetCover<Attribute> attributes = new SetCover<>();
- private final SetCover<Action> actions = new SetCover<>();
- private final SetCover<Entity> entities = new SetCover<>();
-
- /**
- * Constructor. Creates a category with scheme, term, title, location and
- * attributes.
- *
- * @param scheme category's scheme. Cannot be null.
- * @param term category's term. Cannot be null nor empty.
- * @param title category's title
- * @param location category's location
- * @param attributes category's attributes
- */
- public Category(URI scheme, String term, String title, URI location, Collection<Attribute> attributes) {
- LOGGER.debug("Creating category: scheme={}, term={}, title={}, location={}, attributes={}", scheme, term, title, location, attributes);
-
- if (scheme == null) {
- throw new NullPointerException("Category scheme cannot be null.");
- }
- if (term == null) {
- throw new NullPointerException("Category term cannot be null.");
- }
- if (term.isEmpty()) {
- throw new IllegalArgumentException("Category term cannot be empty.");
- }
-
- this.scheme = scheme;
- this.term = term;
- this.title = title;
- this.location = location;
-
- if (attributes != null) {
- this.attributes.addAll(attributes);
- }
- }
-
- /**
- * Constructor. Creates a category with scheme and term.
- *
- * @param scheme category's scheme. Cannot be null.
- * @param term category's term. Cannot be null nor empty.
- */
- public Category(URI scheme, String term) {
- this(scheme, term, null, null, null);
- }
-
- /**
- * Returns category's term.
- *
- * @return category's term
- */
- public String getTerm() {
- return term;
- }
-
- /**
- * Sets category's term.
- *
- * @param term category's term. Cannot be null nor empty.
- */
- public void setTerm(String term) {
- if (term == null) {
- throw new NullPointerException("Category term cannot be null.");
- }
- if (term.isEmpty()) {
- throw new IllegalArgumentException("Category term cannot be empty.");
- }
-
- this.term = term;
- }
-
- /**
- * Returns category's scheme.
- *
- * @return category's scheme
- */
- public URI getScheme() {
- return scheme;
- }
-
- /**
- * Sets category's scheme.
- *
- * @param scheme category's scheme. Cannot be null.
- */
- public void setScheme(URI scheme) {
- if (scheme == null) {
- throw new NullPointerException("Category scheme cannot be null.");
- }
-
- this.scheme = scheme;
- }
-
- /**
- * Returns category's identifier.
- *
- * @return category's identifier
- */
- @Override
- public String getIdentifier() {
- return getScheme().toString() + getTerm();
- }
-
- /**
- * Returns category's title.
- *
- * @return category's title
- */
- public String getTitle() {
- return title;
- }
-
- /**
- * Sets category's title
- *
- * @param title category's title
- */
- public void setTitle(String title) {
- this.title = title;
- }
-
- /**
- * Returns category's location.
- *
- * @return category's location
- */
- public URI getLocation() {
- return location;
- }
-
- /**
- * Sets category's location
- *
- * @param location category's location
- */
- public void setLocation(URI location) {
- this.location = location;
- }
-
- //attributes
- /**
- * Checks whether category has given attribute.
- *
- * @param attribute attribute to be looked up
- * @return true if category has given attribute, false otherwise
- */
- public boolean containsAttribute(Attribute attribute) {
- return attributes.contains(attribute);
- }
-
- /**
- * Checks whether category has given attribute.
- *
- * @param attributeIdentifier identifier of attribute to be looked up
- * @return true if category has given attribute, false otherwise
- */
- public boolean containsAttribute(String attributeIdentifier) {
- return attributes.contains(attributeIdentifier);
- }
-
- /**
- * Adds given attribute to category.
- *
- * @param attribute attribute to be added
- * @return true if the addition was successful, false otherwise
- */
- public boolean addAttribute(Attribute attribute) {
- return attributes.add(attribute);
- }
-
- /**
- * Returns attribute from category.
- *
- * @param attributeIdentifier identifier of the requested attribute
- * @return attribute from category
- */
- public Attribute getAttribute(String attributeIdentifier) {
- return attributes.get(attributeIdentifier);
- }
-
- /**
- * Removes attribute from category
- *
- * @param attribute to be removed
- * @return true if the removal was successful, false otherwise
- */
- public boolean removeAttribute(Attribute attribute) {
- return attributes.remove(attribute);
- }
-
- /**
- * Removes all attributes from category.
- */
- public void clearAttributes() {
- attributes.clear();
- }
-
- /**
- * Returns all category's attributes in form of set.
- *
- * @return all category's attributes in form of set
- */
- public Set<Attribute> getAttributes() {
- return attributes.getSet();
- }
-
- //actions
- /**
- * Checks whether category has given action.
- *
- * @param action action to be looked up
- * @return true if category has given action, false otherwise
- */
- public boolean containsAction(Action action) {
- return actions.contains(action);
- }
-
- /**
- * Checks whether category has given action.
- *
- * @param actionIdentifier identifier of action to be looked up
- * @return true if category has given action, false otherwise
- */
- public boolean containsAction(String actionIdentifier) {
- return actions.contains(actionIdentifier);
- }
-
- /**
- * Adds given action to category.
- *
- * @param action action to be added
- * @return true if the addition was successful, false otherwise
- */
- public boolean addAction(Action action) {
- return actions.add(action);
- }
-
- /**
- * Returns action from category.
- *
- * @param actionIdentifier identifier of the requested action
- * @return action from category
- */
- public Action getAction(String actionIdentifier) {
- return actions.get(actionIdentifier);
- }
-
- /**
- * Removes action from category
- *
- * @param action to be removed
- * @return true if the removal was successful, false otherwise
- */
- public boolean removeAction(Action action) {
- return actions.remove(action);
- }
-
- /**
- * Removes all actions from category.
- */
- public void clearActions() {
- actions.clear();
- }
-
- /**
- * Returns all category's actions in form of set.
- *
- * @return all category's actions in form of set
- */
- public Set<Action> getActions() {
- return actions.getSet();
- }
-
- //entities
- /**
- * Checks whether category has given entity.
- *
- * @param entity entity to be looked up
- * @return true if category has given entity, false otherwise
- */
- public boolean containsEntity(Entity entity) {
- return entities.contains(entity);
- }
-
- /**
- * Checks whether category has given entity.
- *
- * @param entityIdentifier identifier of entity to be looked up
- * @return true if category has given entity, false otherwise
- */
- public boolean containsEntity(String entityIdentifier) {
- return entities.contains(entityIdentifier);
- }
-
- /**
- * Adds given entity to category.
- *
- * @param entity entity to be added
- * @return true if the addition was successful, false otherwise
- */
- public boolean addEntity(Entity entity) {
- return entities.add(entity);
- }
-
- /**
- * Returns entity from category.
- *
- * @param entityIdentifier identifier of the requested entity
- * @return entity from category
- */
- public Entity getEntity(String entityIdentifier) {
- return entities.get(entityIdentifier);
- }
-
- /**
- * Removes entity from category
- *
- * @param entity to be removed
- * @return true if the removal was successful, false otherwise
- */
- public boolean removeEntity(Entity entity) {
- return entities.remove(entity);
- }
-
- /**
- * Removes all entities from category.
- */
- public void clearEntities() {
- entities.clear();
- }
-
- /**
- * Returns all category's entities in form of set.
- *
- * @return all category's entities in form of set
- */
- public Set<Entity> getEntities() {
- return entities.getSet();
- }
-
- /**
- * @see Object#hashCode()
- * @return category's hash code
- */
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 79 * hash + Objects.hashCode(this.term);
- hash = 79 * hash + Objects.hashCode(this.scheme);
- return hash;
- }
-
- /**
- * @see Object#equals(java.lang.Object)
- * @param obj object to compare category with
- * @return true if two categories are equal, false otherwise
- */
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final Category other = (Category) obj;
- if (!Objects.equals(this.term, other.term)) {
- return false;
- }
- if (!Objects.equals(this.scheme, other.scheme)) {
- return false;
- }
- return true;
- }
-
- /**
- * Resturns string representation of the category
- *
- * @see Object#toString()
- * @return string representation of the category
- */
- @Override
- public String toString() {
- return "Category{" + "term=" + term + ", scheme=" + scheme + ", title=" + title + ", location=" + location + ", attributes=" + attributes + '}';
- }
-
- /**
- * Returns a plain text representation of category and its subtypes (kinds
- * and mixins) according to OCCI standard.
- *
- * @return plain text representation of category
- */
- public String toText() {
- return toText(true);
- }
-
- /**
- * Returns a plain text representation of category and its subtypes (kinds
- * and mixins) according to OCCI standard.
- *
- * @param fullRendering whether to render all the information
- * @return plain text representation of category
- */
- public String toText(boolean fullRendering) {
- StringBuilder sb = new StringBuilder("Category: ");
- sb.append(textBody(fullRendering));
-
- return sb.toString();
- }
-
- /**
- * Returns an occi text representation of category and its subtypes (kinds
- * and mixins) according to OCCI standard in form of headers.
- *
- * @return plain text representation of category
- */
- public Headers toHeaders() {
- return toHeaders(true);
- }
-
- /**
- * Returns an occi text representation of category and its subtypes (kinds
- * and mixins) according to OCCI standard in form of headers.
- *
- * @param fullRendering whether to render all the information
- * @return plain text representation of category
- */
- public Headers toHeaders(boolean fullRendering) {
- Headers headers = new Headers();
- headers.add("Category", textBody(fullRendering));
-
- return headers;
- }
-
- private String textBody(boolean fullRendering) {
- StringBuilder sb = new StringBuilder(term);
- sb.append(";");
- sb.append("scheme");
- sb.append(TextRenderer.surroundString(scheme.toString()));
- sb.append("class");
- sb.append(TextRenderer.surroundString(this.getClass().getSimpleName().toLowerCase()));
-
- if (fullRendering) {
- if (title != null && !title.isEmpty()) {
- sb.append("title");
- sb.append(TextRenderer.surroundString(title));
- }
-
- if (this instanceof Kind) {
- Kind kind = (Kind) this;
- if (kind.getRelations().size() == 1) {
- sb.append("rel");
- for (Kind k : kind.getRelations()) {
- sb.append(TextRenderer.surroundString(k.getIdentifier()));
- }
- }
- }
-
- if (this instanceof Mixin) {
- Mixin mixin = (Mixin) this;
- if (mixin.getRelations().size() == 1) {
- sb.append("rel");
- for (Mixin m : mixin.getRelations()) {
- sb.append(TextRenderer.surroundString(m.getIdentifier()));
- }
- }
- }
-
- if (location != null) {
- sb.append("location");
- sb.append(TextRenderer.surroundString(location.toString()));
- }
-
- if (attributes != null && !attributes.getSet().isEmpty()) {
- sb.append("attributes");
- StringBuilder attrSB = new StringBuilder();
- List<Attribute> attributeList = new ArrayList<>(attributes.getSet());
- Collections.sort(attributeList);
- for (Attribute attribute : attributeList) {
- attrSB.append(attribute.toText());
- attrSB.append(" ");
- }
- attrSB.deleteCharAt(attrSB.length() - 1);
- sb.append(TextRenderer.surroundString(attrSB.toString()));
- }
-
- if (actions != null && !actions.getSet().isEmpty()) {
- sb.append("actions");
- StringBuilder actionsSB = new StringBuilder();
- List<Action> actionList = new ArrayList<>(actions.getSet());
- Collections.sort(actionList);
- for (Action action : actionList) {
- actionsSB.append(action.getIdentifier());
- actionsSB.append(" ");
- }
- actionsSB.deleteCharAt(actionsSB.length() - 1);
- sb.append(TextRenderer.surroundString(actionsSB.toString()));
- }
- }
-
- if (sb.charAt(sb.length() - 1) == ';') {
- sb.deleteCharAt(sb.length() - 1);
- }
-
- return sb.toString();
- }
-
- /**
- * Comapres two cetegories lexicographically based on their identifier.
- *
- * @see Comparable#compareTo(java.lang.Object)
- */
- @Override
- public int compareTo(Category c) {
- return getIdentifier().compareTo(c.getIdentifier());
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.core;
-
-import com.sun.net.httpserver.Headers;
-import cz.cesnet.cloud.occi.Model;
-import cz.cesnet.cloud.occi.collection.AttributeMapCover;
-import cz.cesnet.cloud.occi.type.Identifiable;
-import cz.cesnet.cloud.occi.collection.SetCover;
-import cz.cesnet.cloud.occi.exception.InvalidAttributeValueException;
-import cz.cesnet.cloud.occi.exception.RenderingException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Abstract class representing an OCCI Entity.
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public abstract class Entity implements Identifiable, Comparable<Entity> {
-
- public static final String ID_ATTRIBUTE_NAME = "occi.core.id";
- public static final String TITLE_ATTRIBUTE_NAME = "occi.core.title";
- public static final URI SCHEME_DEFAULT = Category.SCHEME_CORE_DEFAULT;
- public static final String TERM_DEFAULT = "entity";
- public static final String KIND_IDENTIFIER_DEFAULT = SCHEME_DEFAULT + TERM_DEFAULT;
-
- private static final Logger LOGGER = LoggerFactory.getLogger(Entity.class);
- private Kind kind;
- private Model model;
- private final SetCover<Mixin> mixins = new SetCover<>();
- private final AttributeMapCover attributes = new AttributeMapCover();
-
- /**
- * Constructor.
- *
- * @param id occi.core.id attribute. Cannot be null.
- * @param kind entity's kind. Cannot be null.
- * @param title occi.core.title attribute
- * @param model entity's model
- * @throws InvalidAttributeValueException in case of invalid id or title
- * value
- */
- public Entity(String id, Kind kind, String title, Model model) throws InvalidAttributeValueException {
- LOGGER.debug("Creating Entity: class={}, id={}, kind={}, title={}, model={}", getClass().getName(), id, kind, title, model);
-
- if (id == null) {
- throw new NullPointerException("Entity id cannot be null.");
- }
- if (kind == null) {
- throw new NullPointerException("Entity kind cannot be null.");
- }
-
- privateAddAttribute(ID_ATTRIBUTE_NAME, id);
- if (title != null && !title.isEmpty()) {
- privateAddAttribute(TITLE_ATTRIBUTE_NAME, title);
- }
- this.kind = kind;
- this.model = model;
- }
-
- /**
- * Constructor.
- *
- * @param id occi.core.id attribute. Cannot be null.
- * @param kind entity's kind. Cannot be null.
- * @throws InvalidAttributeValueException in case of invalid id or title
- * value
- */
- public Entity(String id, Kind kind) throws InvalidAttributeValueException {
- this(id, kind, null, null);
- }
-
- /**
- * Returns entity's id.
- *
- * @return entity's id
- */
- public String getId() {
- return getValue(ID_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets entity's id.
- *
- * @param id entity's id. Cannot be null.
- * @throws InvalidAttributeValueException in case of invalid id value
- */
- public void setId(String id) throws InvalidAttributeValueException {
- if (id == null) {
- throw new NullPointerException("Entity id cannot be null.");
- }
-
- addAttribute(ID_ATTRIBUTE_NAME, id);
- }
-
- /**
- * Returns entity's kind.
- *
- * @return entity's kind
- */
- public Kind getKind() {
- return kind;
- }
-
- /**
- * Sets entity's kind.
- *
- * @param kind entity's kind. Cannot be null.
- */
- public void setKind(Kind kind) {
- if (kind == null) {
- throw new NullPointerException("Entity kind cannot be null.");
- }
-
- this.kind = kind;
- }
-
- /**
- * Returns entity's identifier.
- *
- * @return entity's identifier
- */
- @Override
- public String getIdentifier() {
- return kind.getIdentifier() + "|" + getId();
- }
-
- /**
- * Returns entity's title.
- *
- * @return entity's title
- */
- public String getTitle() {
- return getValue(TITLE_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets entity's title.
- *
- * @param title entity's title
- * @throws InvalidAttributeValueException in case of invalit tile value
- */
- public void setTitle(String title) throws InvalidAttributeValueException {
- addAttribute(TITLE_ATTRIBUTE_NAME, title);
- }
-
- /**
- * Returns entity's model.
- *
- * @return entity's model
- */
- public Model getModel() {
- return model;
- }
-
- /**
- * Sets entity's model.
- *
- * @param model entity's model
- */
- public void setModel(Model model) {
- this.model = model;
- }
-
- private void privateAddAttribute(String attributeIdentifier, String value) throws InvalidAttributeValueException {
- if (!isValidAttributeValue(attributeIdentifier, value)) {
- Attribute attribute = getAttribute(attributeIdentifier);
- throw new InvalidAttributeValueException("'" + value + "' is not a suitable value for " + attribute);
- }
-
- Attribute attribute = getAttribute(attributeIdentifier);
- if (attribute == null) {
- attribute = new Attribute(attributeIdentifier);
- }
- attributes.add(attribute, value);
- }
-
- /**
- * Adds attribute and its value. If attribute has a content restriction,
- * value is checked.
- *
- * @param attributeIdentifier
- * @param value
- * @throws InvalidAttributeValueException
- */
- public void addAttribute(String attributeIdentifier, String value) throws InvalidAttributeValueException {
- privateAddAttribute(attributeIdentifier, value);
- }
-
- /**
- * Adds attributes and their values. If attributes have a content
- * restriction, values are checked.
- *
- * @param attributes
- * @throws InvalidAttributeValueException
- */
- public void addAttributes(Map<String, String> attributes) throws InvalidAttributeValueException {
- for (String name : attributes.keySet()) {
- privateAddAttribute(name, attributes.get(name));
- }
- }
-
- private boolean isValidAttributeValue(String attributeIdentifier, String value) {
- Attribute attribute = getAttribute(attributeIdentifier);
-
- if (attribute == null) {
- return true;
- }
-
- if (attribute.getPattern() == null || attribute.getPattern().isEmpty()) {
- return true;
- }
-
- return value.matches(attribute.getPattern());
- }
-
- private Attribute getAttribute(String attributeIdentifier) {
- Attribute attribute = getAttributeFromKindsIfExists(kind, attributeIdentifier);
- if (attribute == null) {
- attribute = getAttributeFromMixinsIfExists(getMixins(), attributeIdentifier);
- }
-
- return attribute;
- }
-
- private Attribute getAttributeFromKindsIfExists(Kind kind, String attributeIdentifier) {
- if (kind == null) {
- return null;
- }
-
- if (kind.containsAttribute(attributeIdentifier)) {
- return kind.getAttribute(attributeIdentifier);
- }
-
- Attribute attribute = null;
- for (Kind k : kind.getRelations()) {
- if (attribute != null) {
- return attribute;
- }
-
- attribute = getAttributeFromKindsIfExists(k, attributeIdentifier);
- }
-
- return attribute;
- }
-
- private Attribute getAttributeFromMixinsIfExists(Set<Mixin> mixins, String attributeIdentifier) {
- for (Mixin m : mixins) {
- if (m.containsAttribute(attributeIdentifier)) {
- return m.getAttribute(attributeIdentifier);
- }
- Attribute attribute = getAttributeFromMixinsIfExists(m.getRelations(), attributeIdentifier);
- if (attribute != null) {
- return attribute;
- }
- }
-
- return null;
- }
-
- /**
- * Removes attribute from entity.
- *
- * @param attributeIdentifier identifier of the attribute to be removed
- */
- public void removeAttribute(String attributeIdentifier) {
- attributes.remove(attributeIdentifier);
- }
-
- /**
- * Checks whether entity has given attribute.
- *
- * @param attribute attribute to be looked up
- * @return true if entity has given attribute, false otherwise
- */
- public boolean containsAttribute(Attribute attribute) {
- return attributes.containsAttribute(attribute);
- }
-
- /**
- * Checks whether entity has given attribute.
- *
- * @param attributeName name of the attribute to be looked up
- * @return true if entity has given attribute, false otherwise
- */
- public boolean containsAttribute(String attributeName) {
- return attributes.containsAttribute(attributeName);
- }
-
- /**
- * Returns value of given attribute.
- *
- * @param attribute attribute which value will be returned
- * @return value of given attribute
- */
- public String getValue(Attribute attribute) {
- return attributes.getValue(attribute);
- }
-
- /**
- * Returns value of given attribute.
- *
- * @param attributeName name of the attribute which value will be returned
- * @return value of given attribute
- */
- public String getValue(String attributeName) {
- return attributes.getValue(attributeName);
- }
-
- /**
- * Returns all entity's attributes and their values in form of map.
- *
- * @return all entity's attributes and their values in form of map
- */
- public Map<Attribute, String> getAttributes() {
- return attributes.getAttributes();
- }
-
- /**
- * Removes all entity's attributes.
- */
- public void clearAttributes() {
- attributes.clear();
- }
-
- /**
- * Returns text representation of entity's attributes in one line.
- *
- * @return text representation of entity's attributes in one line
- */
- protected String attributesToOneLineText() {
- return attributes.toOneLineText();
- }
-
- /**
- * Returns a text representation of entity's attributes with prefix.
- *
- * @return text representation of entity's attributes with prefix
- */
- protected String attributesToPrefixText() {
- return attributes.toPrefixText();
- }
-
- /**
- * Returns an occi text representation of entity's attributes in form of
- * headers.
- *
- * @return occi text representation of entity's attributes in form of
- * headers
- */
- protected Headers attributesToHeaders() {
- return attributes.toHeaders();
- }
-
- /**
- * Checks whether the entity has given mixin.
- *
- * @param mixin mixin to be looked up
- * @return true if entity has given mixin, false otherwise
- */
- public boolean containsMixin(Mixin mixin) {
- return mixins.contains(mixin);
- }
-
- /**
- * Checks whether the entity has given mixin.
- *
- * @param mixinIdentifier identifier of mixin to be looked up
- * @return true if entity has given mixin, false otherwise
- */
- public boolean containsMixin(String mixinIdentifier) {
- return mixins.contains(mixinIdentifier);
- }
-
- /**
- * Adds mixin to the entity.
- *
- * @param mixin mixin to be added
- * @return true if the addition was successful, false otherwise
- */
- public boolean addMixin(Mixin mixin) {
- return mixins.add(mixin);
- }
-
- /**
- * Adds all the mixins from given collection to the entity.
- *
- * @param mixins collection of mixins
- * @return true if the addition was successful, false otherwise
- */
- public boolean addMixins(Collection<Mixin> mixins) {
- return this.mixins.addAll(mixins);
- }
-
- /**
- * Returns mixin form entity.
- *
- * @param mixinIdentifier identifier of requested mixin
- * @return mixin form entity
- */
- public Mixin getMixin(String mixinIdentifier) {
- return mixins.get(mixinIdentifier);
- }
-
- /**
- * Removes mixin from entity.
- *
- * @param mixin mixin to be removed
- * @return true if the removal was successful, false otherwise
- */
- public boolean removeMixin(Mixin mixin) {
- return mixins.remove(mixin);
- }
-
- /**
- * Removes all mixins from entity.
- */
- public void clearMixins() {
- mixins.clear();
- }
-
- /**
- * Returns all mixins from entity in form of a set.
- *
- * @return all mixins from entity in form of a set
- */
- public Set<Mixin> getMixins() {
- return mixins.getSet();
- }
-
- /**
- * @see Object#hashCode()
- * @return entity's hash code
- */
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 89 * hash + Objects.hashCode(getId());
- hash = 89 * hash + Objects.hashCode(this.kind);
- return hash;
- }
-
- /**
- * @see Object#equals(java.lang.Object)
- * @param obj object to compare entity with
- * @return true if two entity are equal, false otherwise
- */
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof Entity)) {
- return false;
- }
- final Entity other = (Entity) obj;
- if (!Objects.equals(getId(), other.getId())) {
- return false;
- }
- if (!Objects.equals(this.kind, other.kind)) {
- return false;
- }
- return true;
- }
-
- /**
- * Resturns string representation of the entity
- *
- * @see Object#toString()
- * @return string representation of the entity
- */
- @Override
- public String toString() {
- return "Entity{" + "class=" + getClass().getName() + ", id=" + getId() + ", kind=" + kind + ", title=" + getTitle() + ", mixins=" + mixins + ", attributes=" + attributes + '}';
- }
-
- /**
- * Renders entity to its plain text form as described in OCCI standard.
- *
- * @return plain text form of entity
- * @throws RenderingException
- */
- public abstract String toText() throws RenderingException;
-
- /**
- * Renders entity to its occi text form as described in OCCI standard in
- * form of headers.
- *
- * @return occi text form of entity
- * @throws RenderingException
- */
- public abstract Headers toHeaders() throws RenderingException;
-
- /**
- * Renders entity to its JSON form as described in OCCI standard.
- *
- * @return JSON form of entity
- */
- public abstract String toJSON();
-
- /**
- * Comapres two entities lexicographically based on their identifier.
- *
- * @see Comparable#compareTo(java.lang.Object)
- */
- @Override
- public int compareTo(Entity e) {
- return getIdentifier().compareTo(e.getIdentifier());
- }
-
- /**
- * Returns entity's default kind identifier (scheme+term). For Entity class
- * this equals to 'http://schemas.ogf.org/occi/core#entity'.
- *
- * @return entity's default kind identifier
- */
- public String getDefaultKindIdentifier() {
- return KIND_IDENTIFIER_DEFAULT;
- }
-
- /**
- * Returns entity's default attributes. For Entity class those are
- * attributes occi.core.id and occi.core.title.
- *
- * @return list of entity's default attributes
- */
- public static List<Attribute> getDefaultAttributes() {
- List<Attribute> list = new ArrayList<>();
- list.add(new Attribute(ID_ATTRIBUTE_NAME, true, true));
- list.add(new Attribute(TITLE_ATTRIBUTE_NAME, false, false));
-
- return list;
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.core;
-
-import cz.cesnet.cloud.occi.collection.SetCover;
-import java.net.URI;
-import java.util.Collection;
-import java.util.Set;
-
-/**
- * Class representing an OCCI Kind.
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class Kind extends Category {
-
- private final SetCover<Kind> related = new SetCover<>();
- private String entityType;
- private Kind parentKind = null;
-
- /**
- * Constructor. Creates new kind with scheme, term, title, location and
- * attributes.
- *
- * @param scheme kind's scheme. Cannot be null.
- * @param term kind's term. Cannot be null nor empty.
- * @param title kind's title
- * @param location kind's location
- * @param attributes kind's attributes
- */
- public Kind(URI scheme, String term, String title, URI location, Collection<Attribute> attributes) {
- super(scheme, term, title, location, attributes);
- }
-
- /**
- * Constructor. Creates new kind with scheme and term.
- *
- * @param scheme kind's scheme. Cannot be null.
- * @param term kind's term. Cannot be null nor empty.
- */
- public Kind(URI scheme, String term) {
- this(scheme, term, null, null, null);
- }
-
- /**
- * Returns kind's entity type.
- *
- * @return kind's entity type
- */
- public String getEntityType() {
- return entityType;
- }
-
- /**
- * Sets kind's entity type.
- *
- * @param entityType kind's entity type
- */
- public void setEntityType(String entityType) {
- this.entityType = entityType;
- }
-
- /**
- * Returns kind's parent kind. For example kind
- * 'http://schemas.ogf.org/occi/infrastructure#compute' has parent kind
- * 'http://schemas.ogf.org/occi/core#resource'.
- *
- * @return kind's parent kind
- */
- public Kind getParentKind() {
- return parentKind;
- }
-
- /**
- * Sets kind's parent kind.
- *
- * @param parentKind kind's parent kind
- */
- public void setParentKind(Kind parentKind) {
- this.parentKind = parentKind;
- }
-
- /**
- * Checks whether this kind is in relation with given kind.
- *
- * @param kind kind to chcek relation with
- * @return true if there is relation between kinds, false otherwise
- */
- public boolean relatesTo(Kind kind) {
- return related.contains(kind);
- }
-
- /**
- * Checks whether this kind is in relation with given kind.
- *
- * @param kindIdentifier identifier of kind to chcek relation with
- * @return true if there is relation between kinds, false otherwise
- */
- public boolean relatesTo(String kindIdentifier) {
- return related.contains(kindIdentifier);
- }
-
- /**
- * Creates a relation with given kind.
- *
- * @param kind kind to create a relation with
- * @return true if the relation was created successfully, false otherwise
- */
- public boolean addRelation(Kind kind) {
- return related.add(kind);
- }
-
- /**
- * Creates a relation with given kind.
- *
- * @param kindIdentifier identifier of kind to create a relation with
- * @return true if the relation was created successfully, false otherwise
- */
- public Kind getRelatedKind(String kindIdentifier) {
- return related.get(kindIdentifier);
- }
-
- /**
- * Removes relation with given kind.
- *
- * @param kind kind with which relation will be removed
- * @return true if the relation was removed successfully, false otherwise
- */
- public boolean removeRelation(Kind kind) {
- return related.remove(kind);
- }
-
- /**
- * Remove all relations.
- */
- public void clearRelations() {
- related.clear();
- }
-
- /**
- * Returns all related kinds in form of set.
- *
- * @return all related kinds in form of set
- */
- public Set<Kind> getRelations() {
- return related.getSet();
- }
-
- /**
- * Resturns string representation of kind
- *
- * @see Object#toString()
- * @return string representation of kind
- */
- @Override
- public String toString() {
- return "Kind{" + "term=" + getTerm() + ", scheme=" + getScheme() + ", title=" + getTitle() + ", location=" + getLocation() + ", attributes=" + getAttributes() + ", related=" + related + '}';
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.core;
-
-import com.sun.net.httpserver.Headers;
-import cz.cesnet.cloud.occi.Model;
-import cz.cesnet.cloud.occi.exception.InvalidAttributeValueException;
-import cz.cesnet.cloud.occi.exception.RenderingException;
-import cz.cesnet.cloud.occi.renderer.TextRenderer;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Class representing an OCCI Link.
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class Link extends Entity {
-
- public static final String SOURCE_ATTRIBUTE_NAME = "occi.core.source";
- public static final String TARGET_ATTRIBUTE_NAME = "occi.core.target";
- public static final URI SCHEME_DEFAULT = Category.SCHEME_CORE_DEFAULT;
- public static final String TERM_DEFAULT = "link";
- public static final String KIND_IDENTIFIER_DEFAULT = SCHEME_DEFAULT + TERM_DEFAULT;
- private String relation;
-
- /**
- * Constructor.
- *
- * @param id occi.core.id attribute. Cannot be null.
- * @param kind link's kind. Cannot be null.
- * @param title occi.core.title attribute
- * @param model link's model
- * @throws InvalidAttributeValueException in case of invalid id or title
- * value
- */
- public Link(String id, Kind kind, String title, Model model) throws InvalidAttributeValueException {
- super(id, kind, title, model);
- }
-
- /**
- * Constructor.
- *
- * @param id occi.core.id attribute. Cannot be null.
- * @param kind link's kind. Cannot be null.
- * @throws InvalidAttributeValueException in case of invalid id value
- */
- public Link(String id, Kind kind) throws InvalidAttributeValueException {
- super(id, kind);
- }
-
- /**
- * Returns link's source (value of occi.core.source attribute).
- *
- * @return link's source
- */
- public String getSource() {
- return getValue(SOURCE_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets link's source.
- *
- * @param source link's source. Cannot be null.
- * @throws InvalidAttributeValueException in case source value is invalid
- */
- public void setSource(Resource source) throws InvalidAttributeValueException {
- if (source == null) {
- throw new NullPointerException("source cannot be null");
- }
- addAttribute(SOURCE_ATTRIBUTE_NAME, source.getLocation());
- }
-
- /**
- * Sets link's source.
- *
- * @param sourceLocation location of link's source
- * @throws InvalidAttributeValueException in case source value is invalid
- */
- public void setSource(String sourceLocation) throws InvalidAttributeValueException {
- addAttribute(SOURCE_ATTRIBUTE_NAME, sourceLocation);
- }
-
- /**
- * Returns link's target (value of occi.core.terget attribute).
- *
- * @return link's target
- */
- public String getTarget() {
- return getValue(TARGET_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets link's target.
- *
- * @param target link's target. Cannot be null.
- * @throws InvalidAttributeValueException in case target value is invalid
- */
- public void setTarget(Resource target) throws InvalidAttributeValueException {
- if (target == null) {
- throw new NullPointerException("target cannot be null");
- }
- addAttribute(TARGET_ATTRIBUTE_NAME, target.getLocation());
- }
-
- /**
- * Sets link's target.
- *
- * @param targetLocation location of link's target
- * @throws InvalidAttributeValueException in case target value is invalid
- */
- public void setTarget(String targetLocation) throws InvalidAttributeValueException {
- addAttribute(TARGET_ATTRIBUTE_NAME, targetLocation);
- }
-
- /**
- * Returns link's relation.
- *
- * @return link's relation
- */
- public String getRelation() {
- return relation;
- }
-
- /**
- * Sets link's relation.
- *
- * @param relation
- */
- public void setRelation(String relation) {
- this.relation = relation;
- }
-
- /**
- * Returns link's default identifier 'http://schemas.ogf.org/occi/core#link'
- *
- * @return link's default identifier
- */
- @Override
- public String getDefaultKindIdentifier() {
- return KIND_IDENTIFIER_DEFAULT;
- }
-
- public static List<Attribute> getDefaultAttributes() {
- List<Attribute> list = new ArrayList<>();
- list.addAll(Entity.getDefaultAttributes());
- list.add(new Attribute(SOURCE_ATTRIBUTE_NAME, true, false));
- list.add(new Attribute(TARGET_ATTRIBUTE_NAME, true, false));
-
- return list;
- }
-
- public static Kind getDefaultKind() {
- Kind kind = new Kind(SCHEME_DEFAULT, TERM_DEFAULT, "Link", URI.create("/link/"), Link.getDefaultAttributes());
- return kind;
- }
-
- /**
- * Returns a plain text representation of link instance as described in OCCI
- * standard.
- *
- * @return plain text representation of link instance
- */
- @Override
- public String toText() {
- StringBuilder sb = new StringBuilder();
-
- sb.append(getKind().toText(false));
-
- List<Mixin> mixinList = new ArrayList<>(getMixins());
- Collections.sort(mixinList);
- for (Mixin m : mixinList) {
- sb.append("\n");
- sb.append(m.toText(false));
- }
-
- String attributesString = attributesToPrefixText();
- if (!attributesString.isEmpty()) {
- sb.append("\n");
- sb.append(attributesString);
- }
-
- return sb.toString();
- }
-
- /**
- * Returns an occi text representation of link instance as described in OCCI
- * standard in form of headers.
- *
- * @return plain text representation of link instance
- */
- @Override
- public Headers toHeaders() {
- Headers headers = new Headers();
-
- headers.putAll(getKind().toHeaders(false));
-
- List<Mixin> mixinList = new ArrayList<>(getMixins());
- Collections.sort(mixinList);
- for (Mixin m : mixinList) {
- Headers mixinHeaders = m.toHeaders(false);
- for (String name : mixinHeaders.keySet()) {
- for (String value : mixinHeaders.get(name)) {
- headers.add(name, value);
- }
- }
- }
-
- Headers attributeHeaders = attributesToHeaders();
- if (!attributeHeaders.isEmpty()) {
- headers.putAll(attributeHeaders);
- }
-
- return headers;
- }
-
- /**
- * Returns an inline plain text representation of link instance as described
- * in OCCI standard.
- *
- * @return inline plain text representation of link instance
- * @throws RenderingException
- */
- public String toInlineText() throws RenderingException {
- StringBuilder sb = new StringBuilder("Link: ");
- sb.append(inlineTextBody());
-
- return sb.toString();
- }
-
- /**
- * Returns an inline occi text representation of link instance as described
- * in OCCI standard in form of headers.
- *
- * @return inline occi text representation of link instance in form of
- * headers
- * @throws RenderingException
- */
- public Headers toInlineHeaders() throws RenderingException {
- Headers headers = new Headers();
- headers.add("Link", inlineTextBody());
-
- return headers;
- }
-
- private String inlineTextBody() throws RenderingException {
- StringBuilder sb = new StringBuilder("");
- if (getTarget() == null || getTarget().isEmpty()) {
- throw new RenderingException("Link " + this + " is missing a target attribute.");
- }
- sb.append(TextRenderer.surroundString(getTarget(), "<", ">;"));
-
- if (relation == null || relation.isEmpty()) {
- throw new RenderingException("Link " + this + " is missing a relation.");
- }
- sb.append("rel");
- sb.append(TextRenderer.surroundString(relation));
-
- if (getKind().getLocation() != null && getId() != null && !getId().isEmpty()) {
- sb.append("self");
- sb.append(TextRenderer.surroundString(getKind().getLocation().toString() + getId()));
- }
-
- sb.append("category");
- sb.append("=\"");
- sb.append(getKind().getIdentifier());
- for (Mixin mixin : getMixins()) {
- sb.append(" ");
- sb.append(mixin.getIdentifier());
- }
- sb.append("\";");
-
- sb.append(attributesToOneLineText());
-
- return sb.toString();
- }
-
- /**
- * Returns a JSON representation of link instance as described in OCCI
- * standard. NOT IMPLEMENTED YET!
- *
- * @return JSON representation of link instance
- */
- @Override
- public String toJSON() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.core;
-
-import cz.cesnet.cloud.occi.collection.SetCover;
-import java.net.URI;
-import java.util.Collection;
-import java.util.Set;
-
-/**
- * Class representing an OCCI Mixin.
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class Mixin extends Category {
-
- private final SetCover<Mixin> related = new SetCover<>();
-
- /**
- * Constructor. Creates new mixin with scheme, term, title, location and
- * attributes.
- *
- * @param scheme mixin's scheme. Cannot be null.
- * @param term mixin's term. Cannot be null nor empty.
- * @param title mixin's title
- * @param location mixin's location
- * @param attributes mixin's attributes
- */
- public Mixin(URI scheme, String term, String title, URI location, Collection<Attribute> attributes) {
- super(scheme, term, title, location, attributes);
- }
-
- /**
- * Constructor. Creates new mixin with scheme and term.
- *
- * @param scheme mixin's scheme. Cannot be null.
- * @param term mixin's term. Cannot be null nor empty.
- */
- public Mixin(URI scheme, String term) {
- this(scheme, term, null, null, null);
- }
-
- /**
- * Checks whether this mixin is in relation with given mixin.
- *
- * @param mixin mixin to chcek relation with
- * @return true if there is relation between mixins, false otherwise
- */
- public boolean relatesTo(Mixin mixin) {
- return related.contains(mixin);
- }
-
- /**
- * Checks whether this mixin is in relation with given mixin.
- *
- * @param mixinIdentifier identifier of mixin to chcek relation with
- * @return true if there is relation between mixins, false otherwise
- */
- public boolean relatesTo(String mixinIdentifier) {
- return related.contains(mixinIdentifier);
- }
-
- /**
- * Creates a relation with given mixin.
- *
- * @param mixin mixin to create a relation with
- * @return true if the relation was created successfully, false otherwise
- */
- public boolean addRelation(Mixin mixin) {
- return related.add(mixin);
- }
-
- /**
- * Creates a relation with given mixin.
- *
- * @param mixinIdentifier identifier of mixin to create a relation with
- * @return true if the relation was created successfully, false otherwise
- */
- public Mixin getRelatedMixin(String mixinIdentifier) {
- return related.get(mixinIdentifier);
- }
-
- /**
- * Removes relation with given mixin.
- *
- * @param mixin mixin with which relation will be removed
- * @return true if the relation was removed successfully, false otherwise
- */
- public boolean removeRelation(Mixin mixin) {
- return related.remove(mixin);
- }
-
- /**
- * Remove all relations.
- */
- public void clearRelations() {
- related.clear();
- }
-
- /**
- * Returns all related mixins in form of set.
- *
- * @return all related mixins in form of set
- */
- public Set<Mixin> getRelations() {
- return related.getSet();
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.core;
-
-import com.sun.net.httpserver.Headers;
-import cz.cesnet.cloud.occi.Model;
-import cz.cesnet.cloud.occi.collection.SetCover;
-import cz.cesnet.cloud.occi.exception.InvalidAttributeValueException;
-import cz.cesnet.cloud.occi.exception.RenderingException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import org.slf4j.LoggerFactory;
-
-/**
- * Class representing an OCCI Resource.
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class Resource extends Entity {
-
- public static final String SUMMARY_ATTRIBUTE_NAME = "occi.core.summary";
- public static final URI SCHEME_DEFAULT = Category.SCHEME_CORE_DEFAULT;
- public static final String TERM_DEFAULT = "resource";
- public static final String KIND_IDENTIFIER_DEFAULT = SCHEME_DEFAULT + TERM_DEFAULT;
- private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(Resource.class);
- private final SetCover<Link> links = new SetCover<>();
- private final SetCover<Action> actions = new SetCover<>();
-
- /**
- * Constructor.
- *
- * @param id occi.core.id attribute. Cannot be null.
- * @param kind resource's kind. Cannot be null.
- * @param title occi.core.title attribute
- * @param model resource's model
- * @param summary resource's summary
- * @throws InvalidAttributeValueException in case of invalid id, title or
- * summary value
- */
- public Resource(String id, Kind kind, String title, Model model, String summary) throws InvalidAttributeValueException {
- super(id, kind, title, model);
-
- addAttribute(SUMMARY_ATTRIBUTE_NAME, summary);
- }
-
- /**
- * Constructor.
- *
- * @param id occi.core.id attribute. Cannot be null.
- * @param kind resource's kind. Cannot be null.
- * @throws InvalidAttributeValueException in case of invalid id value
- */
- public Resource(String id, Kind kind) throws InvalidAttributeValueException {
- super(id, kind);
- }
-
- /**
- * Returns resource's summary.
- *
- * @return resource's summary
- */
- public String getSummary() {
- return getValue(SUMMARY_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets resource's summary.
- *
- * @param summary resource's summary
- * @throws InvalidAttributeValueException in case of invalid summary value
- */
- public void setSummary(String summary) throws InvalidAttributeValueException {
- addAttribute(SUMMARY_ATTRIBUTE_NAME, summary);
- }
-
- /**
- * Checks whether resource contains given link.
- *
- * @param link link to be looked up
- * @return true is resource contains given link, false otherwise
- */
- public boolean containsLink(Link link) {
- return links.contains(link);
- }
-
- /**
- * Checks whether resource contains link which kind has given term.
- *
- * @param term term of link's kind
- * @return true is resource contains given link, false otherwise
- */
- public boolean containsLink(String term) {
- for (Link link : links.getSet()) {
- if (link.getKind().getTerm().equals(term)) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Checks whether resource contains link which kind has given identifier.
- *
- * @param identifier identifier of link's kind
- * @return true is resource contains given link, false otherwise
- */
- public boolean containsLink(URI identifier) {
- String identifierString = identifier.toString();
- for (Link link : links.getSet()) {
- if (link.getKind().getIdentifier().equals(identifierString)) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Adds link to the resource and automatically sets link's source to
- * resource.
- *
- * @param link to be added
- * @return true if addition was successful, false otherwise
- */
- public boolean addLink(Link link) {
- if (link.getSource() == null) {
- try {
- link.setSource(this);
- } catch (InvalidAttributeValueException ex) {
- LOGGER.error("This should not be happening!");
- }
- }
- return links.add(link);
- }
-
- /**
- * Adds links to the resource and automatically sets all links' sources to
- * resource.
- *
- * @param links collections of links to be added
- * @return true if addition was successful, false otherwise
- */
- public boolean addLinks(Collection<Link> links) {
- for (Link link : links) {
- if (link.getSource() == null) {
- try {
- link.setSource(this);
- } catch (InvalidAttributeValueException ex) {
- LOGGER.error("This should not be happening!");
- }
- }
- }
- return this.links.addAll(links);
- }
-
- /**
- * Returns resources' links which kind has given term.
- *
- * @param term term of link's kind
- * @return resource's link
- */
- public Set<Link> getLinks(String term) {
- Set<Link> set = new HashSet<>();
- for (Link link : links.getSet()) {
- if (link.getKind().getTerm().equals(term)) {
- set.add(link);
- }
- }
-
- return set;
- }
-
- /**
- * Returns resources' links which kind has given identifier.
- *
- * @param identifier identifier of link's kind
- * @return resource's link
- */
- public Set<Link> getLinks(URI identifier) {
- String identifierString = identifier.toString();
- Set<Link> set = new HashSet<>();
- for (Link link : links.getSet()) {
- if (link.getKind().getIdentifier().equals(identifierString)) {
- set.add(link);
- }
- }
-
- return set;
- }
-
- /**
- * Removes link from resource.
- *
- * @param link link to be removed
- * @return true if the removal was successful, false otherwise
- */
- public boolean removeLink(Link link) {
- return links.remove(link);
- }
-
- /**
- * Removes all links from resource.
- */
- public void clearLinks() {
- links.clear();
- }
-
- /**
- * Returns all resource's links in form of set.
- *
- * @return all resource's links in form of set
- */
- public Set<Link> getLinks() {
- return links.getSet();
- }
-
- /**
- * Checks whether resource contains given action.
- *
- * @param action action to be looked up
- * @return true is resource contains given action, false otherwise
- */
- public boolean containsAction(Action action) {
- return actions.contains(action);
- }
-
- /**
- * Checks whether resource contains given action.
- *
- * @param actionIdentifier identifier of action to be looked up
- * @return true is resource contains given action, false otherwise
- */
- public boolean containsAction(String actionIdentifier) {
- return actions.contains(actionIdentifier);
- }
-
- /**
- * Adds action to the resource.
- *
- * @param action to be added
- * @return true if addition was successful, false otherwise
- */
- public boolean addAction(Action action) {
- return actions.add(action);
- }
-
- /**
- * Adds actions to the resource.
- *
- * @param actions collections of actions to be added
- * @return true if addition was successful, false otherwise
- */
- public boolean addActions(Collection<Action> actions) {
- return this.actions.addAll(actions);
- }
-
- /**
- * Returns resource's action.
- *
- * @param actionIdentifier identifier of requested action
- * @return resource's action
- */
- public Action getAction(String actionIdentifier) {
- return actions.get(actionIdentifier);
- }
-
- /**
- * Removes action from resource.
- *
- * @param action action to be removed
- * @return true if the removal was successful, false otherwise
- */
- public boolean removeAction(Action action) {
- return actions.remove(action);
- }
-
- /**
- * Removes all actions from resource.
- */
- public void clearActions() {
- actions.clear();
- }
-
- /**
- * Returns all resource's actions in form of set.
- *
- * @return all resource's actions in form of set
- */
- public Set<Action> getActions() {
- return actions.getSet();
- }
-
- /**
- * Returns resource's location.
- *
- * @return resource's location
- */
- public String getLocation() {
- return getKind().getLocation().toString() + getId();
- }
-
- /**
- * Returns resource's default identifier
- * 'http://schemas.ogf.org/occi/core#resource'
- *
- * @return resource's default identifier
- */
- @Override
- public String getDefaultKindIdentifier() {
- return KIND_IDENTIFIER_DEFAULT;
- }
-
- public static List<Attribute> getDefaultAttributes() {
- List<Attribute> list = new ArrayList<>();
- list.addAll(Entity.getDefaultAttributes());
- list.add(new Attribute(SUMMARY_ATTRIBUTE_NAME, false, false));
-
- return list;
- }
-
- public static Kind getDefaultKind() {
- Kind kind = new Kind(SCHEME_DEFAULT, TERM_DEFAULT, "Resource", URI.create("/resource/"), Resource.getDefaultAttributes());
- return kind;
- }
-
- /**
- * Resturns string representation of resource
- *
- * @see Object#toString()
- * @return string representation of resource
- */
- @Override
- public String toString() {
- return "Resource{" + "class=" + getClass().getName() + ", id=" + getId() + ", kind=" + getKind() + ", title=" + getTitle() + ", mixins=" + getMixins() + ", attributes=" + getAttributes() + ", links" + links + '}';
- }
-
- /**
- * Returns a plain text representation of resource instance as described in
- * OCCI standard.
- *
- * @return plain text representation of resource instance
- * @throws RenderingException
- */
- @Override
- public String toText() throws RenderingException {
- StringBuilder sb = new StringBuilder();
-
- sb.append(getKind().toText(false));
-
- List<Mixin> mixinList = new ArrayList<>(getMixins());
- Collections.sort(mixinList);
- for (Mixin m : mixinList) {
- sb.append("\n");
- sb.append(m.toText(false));
- }
-
- String attributesString = attributesToPrefixText();
- if (!attributesString.isEmpty()) {
- sb.append("\n");
- sb.append(attributesString);
- }
-
- List<Link> linkList = new ArrayList<>(getLinks());
- Collections.sort(linkList);
- for (Link l : linkList) {
- sb.append("\n");
- sb.append(l.toInlineText());
- }
-
- List<Action> actionList = new ArrayList<>(getActions());
- Collections.sort(actionList);
- for (Action a : actionList) {
- sb.append("\n");
- sb.append(a.toText(getKind().getLocation().toString() + getId()));
- }
-
- return sb.toString();
- }
-
- /**
- * Returns a occi text representation of resource instance as described in
- * OCCI standard in form of headers.
- *
- * @return plain text representation of resource instance
- * @throws RenderingException
- */
- @Override
- public Headers toHeaders() throws RenderingException {
- Headers headers = new Headers();
-
- headers.putAll(getKind().toHeaders(false));
-
- List<Mixin> mixinList = new ArrayList<>(getMixins());
- Collections.sort(mixinList);
- for (Mixin m : mixinList) {
- Headers mixinHeaders = m.toHeaders(false);
- for (String name : mixinHeaders.keySet()) {
- for (String value : mixinHeaders.get(name)) {
- headers.add(name, value);
- }
- }
- }
-
- Headers attributeHeaders = attributesToHeaders();
- if (!attributeHeaders.isEmpty()) {
- headers.putAll(attributeHeaders);
- }
-
- List<Link> linkList = new ArrayList<>(getLinks());
- Collections.sort(linkList);
- for (Link l : linkList) {
- Headers linkHeaders = l.toInlineHeaders();
- for (String name : linkHeaders.keySet()) {
- for (String value : linkHeaders.get(name)) {
- headers.add(name, value);
- }
- }
- }
-
- List<Action> actionList = new ArrayList<>(getActions());
- Collections.sort(actionList);
- for (Action a : actionList) {
- Headers actionHeaders = a.toHeaders(getKind().getLocation().toString() + getId());
- for (String name : actionHeaders.keySet()) {
- for (String value : actionHeaders.get(name)) {
- headers.add(name, value);
- }
- }
- }
-
- return headers;
- }
-
- /**
- * Returns a JSON representation of resource instance as described in OCCI
- * standard. NOT IMPLEMENTED YET!
- *
- * @return JSON representation of resource instance
- */
- @Override
- public String toJSON() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.exception;
-
-/**
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class AmbiguousIdentifierException extends Exception {
-
- public AmbiguousIdentifierException(String message) {
- super(message);
- }
-
- public AmbiguousIdentifierException(String message, Throwable ex) {
- super(message, ex);
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.exception;
-
-/**
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class InvalidAttributeException extends Exception {
-
- public InvalidAttributeException(String message) {
- super(message);
- }
-
- public InvalidAttributeException(String message, Throwable ex) {
- super(message, ex);
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.exception;
-
-/**
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class InvalidAttributeValueException extends Exception {
-
- public InvalidAttributeValueException(String message) {
- super(message);
- }
-
- public InvalidAttributeValueException(String message, Throwable ex) {
- super(message, ex);
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.exception;
-
-/**
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class ParsingException extends Exception {
-
- public ParsingException(String message) {
- super(message);
- }
-
- public ParsingException(String message, Throwable ex) {
- super(message, ex);
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.exception;
-
-/**
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class RenderingException extends Exception {
-
- public RenderingException(String message) {
- super(message);
- }
-
- public RenderingException(String message, Throwable ex) {
- super(message, ex);
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.infrastructure;
-
-import cz.cesnet.cloud.occi.Model;
-import cz.cesnet.cloud.occi.core.Attribute;
-import cz.cesnet.cloud.occi.core.Category;
-import cz.cesnet.cloud.occi.core.Kind;
-import cz.cesnet.cloud.occi.core.Resource;
-import cz.cesnet.cloud.occi.exception.InvalidAttributeValueException;
-import cz.cesnet.cloud.occi.infrastructure.enumeration.ComputeState;
-import cz.cesnet.cloud.occi.infrastructure.enumeration.Architecture;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Class representing an OCCI Compute
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class Compute extends Resource {
-
- public static final String ARCHITECTURE_ATTRIBUTE_NAME = "occi.compute.architecture";
- public static final String CORES_ATTRIBUTE_NAME = "occi.compute.cores";
- public static final String HOSTNAME_ATTRIBUTE_NAME = "occi.compute.hostname";
- public static final String SPEED_ATTRIBUTE_NAME = "occi.compute.speed";
- public static final String MEMORY_ATTRIBUTE_NAME = "occi.compute.memory";
- public static final String STATE_ATTRIBUTE_NAME = "occi.compute.state";
- public static final URI SCHEME_DEFAULT = Category.SCHEME_INFRASTRUCTURE_DEFAULT;
- public static final String TERM_DEFAULT = "compute";
- public static final String KIND_IDENTIFIER_DEFAULT = SCHEME_DEFAULT + TERM_DEFAULT;
-
- /**
- * Constructor.
- *
- * @param id occi.core.id attribute. Cannot be null.
- * @param kind compute's kind. Cannot be null.
- * @param title occi.core.title attribute
- * @param model compute's model
- * @param summary compute's summary
- * @throws InvalidAttributeValueException in case of invalid id, title or
- * summary value
- */
- public Compute(String id, Kind kind, String title, Model model, String summary) throws InvalidAttributeValueException {
- super(id, kind, title, model, summary);
- }
-
- /**
- * Constructor.
- *
- * @param id occi.core.id attribute. Cannot be null.
- * @param kind compute's kind. Cannot be null.
- * @throws InvalidAttributeValueException in case of invalid id value
- */
- public Compute(String id, Kind kind) throws InvalidAttributeValueException {
- super(id, kind);
- }
-
- /**
- * Returns compute's state (attribute occi.compute.state).
- *
- * @return compute's state
- */
- public String getState() {
- return getValue(STATE_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets compute's state.
- *
- * @param state compute's state. Cannot be null.
- * @throws InvalidAttributeValueException in case state's value is invalid
- */
- public void setState(ComputeState state) throws InvalidAttributeValueException {
- if (state == null) {
- throw new NullPointerException("state cannot be null");
- }
- addAttribute(STATE_ATTRIBUTE_NAME, state.toString());
- }
-
- /**
- * Sets compute's state.
- *
- * @param stateName compute's state. Cannot be null.
- * @throws InvalidAttributeValueException in case state's value is invalid
- */
- public void setState(String stateName) throws InvalidAttributeValueException {
- addAttribute(STATE_ATTRIBUTE_NAME, stateName);
- }
-
- /**
- * Returns compute's memory (attribute occi.compute.memory).
- *
- * @return compute's memory
- */
- public String getMemory() {
- return getValue(MEMORY_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets compute's memory.
- *
- * @param memory compute's memory
- * @throws InvalidAttributeValueException in case value of memory is invalid
- */
- public void setMemory(float memory) throws InvalidAttributeValueException {
- addAttribute(MEMORY_ATTRIBUTE_NAME, String.valueOf(memory));
- }
-
- /**
- * Sets compute's memory.
- *
- * @param memory compute's memory
- * @throws InvalidAttributeValueException in case value of memory is invalid
- */
- public void setMemory(String memory) throws InvalidAttributeValueException {
- addAttribute(MEMORY_ATTRIBUTE_NAME, memory);
- }
-
- /**
- * Returns compute's speed (attribute occi.compute.speed).
- *
- * @return compute's speed
- */
- public String getSpeed() {
- return getValue(SPEED_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets compute's speed.
- *
- * @param speed compute's speed
- * @throws InvalidAttributeValueException in case value of speed is invalid
- */
- public void setSpeed(float speed) throws InvalidAttributeValueException {
- addAttribute(SPEED_ATTRIBUTE_NAME, String.valueOf(speed));
- }
-
- /**
- * Sets compute's speed.
- *
- * @param speed compute's speed
- * @throws InvalidAttributeValueException in case value of speed is invalid
- */
- public void setSpeed(String speed) throws InvalidAttributeValueException {
- addAttribute(SPEED_ATTRIBUTE_NAME, speed);
- }
-
- /**
- * Returns compute's hostname (attribute occi.compute.hostname).
- *
- * @return compute's hostname
- */
- public String getHostname() {
- return getValue(HOSTNAME_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets compute's hostname.
- *
- * @param hostname compute's hostname
- * @throws InvalidAttributeValueException in case value of hostname is
- * invalid
- */
- public void setHostname(String hostname) throws InvalidAttributeValueException {
- addAttribute(HOSTNAME_ATTRIBUTE_NAME, hostname);
- }
-
- /**
- * Returns number of compute's cores (attribute occi.compute.cores).
- *
- * @return number of compute's cores
- */
- public String getCores() {
- return getValue(CORES_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets number of compute's cores.
- *
- * @param cores number of compute's cores
- * @throws InvalidAttributeValueException in case value of cores is invalid
- */
- public void setCores(int cores) throws InvalidAttributeValueException {
- addAttribute(CORES_ATTRIBUTE_NAME, String.valueOf(cores));
- }
-
- /**
- * Sets number of compute's cores.
- *
- * @param cores number of compute's cores
- * @throws InvalidAttributeValueException in case value of cores is invalid
- */
- public void setCores(String cores) throws InvalidAttributeValueException {
- addAttribute(CORES_ATTRIBUTE_NAME, cores);
- }
-
- /**
- * Returns compute's architecture (attribute occi.compute.architecture).
- *
- * @return compute's architecture
- */
- public String getArchitecture() {
- return getValue(ARCHITECTURE_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets compute's architecture
- *
- * @param architecture compute's architecture. Cannot be null.
- * @throws InvalidAttributeValueException in case value of architecture is
- * invalid
- */
- public void setArchitecture(Architecture architecture) throws InvalidAttributeValueException {
- if (architecture == null) {
- throw new NullPointerException("architecture cannot be null");
- }
- addAttribute(ARCHITECTURE_ATTRIBUTE_NAME, architecture.toString());
- }
-
- /**
- * Sets compute's architecture
- *
- * @param architectureName compute's architecture
- * @throws InvalidAttributeValueException in case value of architecture is
- * invalid
- */
- public void setArchitecture(String architectureName) throws InvalidAttributeValueException {
- addAttribute(ARCHITECTURE_ATTRIBUTE_NAME, architectureName);
- }
-
- /**
- * Returns compute's default identifier
- * 'http://schemas.ogf.org/occi/infrastructure#compute'
- *
- * @return compute's default identifier
- */
- @Override
- public String getDefaultKindIdentifier() {
- return KIND_IDENTIFIER_DEFAULT;
- }
-
- /**
- * Returns compute's default attributes. For Compute class those are
- * attributes occi.compute.architecture, occi.compute.cores,
- * occi.compute.hostname, occi.compute.speed, occi.compute.memory and
- * occi.compute.state.
- *
- * @return list of compute's default attributes
- */
- public static List<Attribute> getDefaultAttributes() {
- List<Attribute> list = new ArrayList<>();
- list.addAll(Resource.getDefaultAttributes());
- list.add(new Attribute(ARCHITECTURE_ATTRIBUTE_NAME, false, false));
- list.add(new Attribute(CORES_ATTRIBUTE_NAME, false, false));
- list.add(new Attribute(HOSTNAME_ATTRIBUTE_NAME, false, false));
- list.add(new Attribute(SPEED_ATTRIBUTE_NAME, false, false));
- list.add(new Attribute(MEMORY_ATTRIBUTE_NAME, false, false));
- list.add(new Attribute(STATE_ATTRIBUTE_NAME, true, true));
-
- return list;
- }
-
- /**
- * Returns compute's default kind instance.
- *
- * @return compute's default kind
- */
- public static Kind getDefaultKind() {
- Kind kind = new Kind(SCHEME_DEFAULT, TERM_DEFAULT, "Compute Resource", URI.create("/compute/"), Compute.getDefaultAttributes());
- return kind;
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.infrastructure;
-
-import cz.cesnet.cloud.occi.Model;
-import cz.cesnet.cloud.occi.core.Attribute;
-import cz.cesnet.cloud.occi.core.Kind;
-import cz.cesnet.cloud.occi.core.Mixin;
-import cz.cesnet.cloud.occi.exception.InvalidAttributeValueException;
-import cz.cesnet.cloud.occi.infrastructure.enumeration.Allocation;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Class representing an OCCI IPNetwork
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class IPNetwork extends Network {
-
- public static final String ADDRESS_ATTRIBUTE_NAME = "occi.network.address";
- public static final String GATEWAY_ATTRIBUTE_NAME = "occi.network.gateway";
- public static final String ALLOCATION_ATTRIBUTE_NAME = "occi.network.allocation";
- public static final URI SCHEME_DEFAULT = URI.create("http://schemas.ogf.org/occi/infrastructure/network#");
- public static final String TERM_DEFAULT = "ipnetwork";
- public static final String MIXIN_IDENTIFIER_DEFAULT = SCHEME_DEFAULT + TERM_DEFAULT;
-
- /**
- * Constructor.
- *
- * @param id occi.core.id attribute. Cannot be null.
- * @param kind ipnetwork's kind. Cannot be null.
- * @param title occi.core.title attribute
- * @param model ipnetwork's model
- * @param summary ipnetwork's summary
- * @throws InvalidAttributeValueException in case of invalid id, title or
- * summary value
- */
- public IPNetwork(String id, Kind kind, String title, Model model, String summary) throws InvalidAttributeValueException {
- super(id, kind, title, model, summary);
- }
-
- /**
- * Constructor.
- *
- * @param id occi.core.id attribute. Cannot be null.
- * @param kind ipnetwork's kind. Cannot be null.
- * @throws InvalidAttributeValueException in case of invalid id value
- */
- public IPNetwork(String id, Kind kind) throws InvalidAttributeValueException {
- super(id, kind);
- }
-
- /**
- * Returns ipnetwork's address (attribute occi.network.address).
- *
- * @return ipnetwork's address
- */
- public String getAddress() {
- return getValue(ADDRESS_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets ipnetwork's address.
- *
- * @param address ipnetwork's address
- * @throws InvalidAttributeValueException in case value for address is
- * invalid
- */
- public void setAddress(String address) throws InvalidAttributeValueException {
- addAttribute(ADDRESS_ATTRIBUTE_NAME, address);
- }
-
- /**
- * Returns ipnetwork's gateway (attribute occi.network.gateway).
- *
- * @return ipnetwork's gateway
- */
- public String getGateway() {
- return getValue(GATEWAY_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets ipnetwork's gateway
- *
- * @param gateway ipnetwork's gateway
- * @throws InvalidAttributeValueException in case value for gateway is
- * invalid
- */
- public void setGateway(String gateway) throws InvalidAttributeValueException {
- addAttribute(GATEWAY_ATTRIBUTE_NAME, gateway);
- }
-
- /**
- * Returns ipnetwork's allocation (attribute occi.network.allocation).
- *
- * @return ipnetwork's allocation
- */
- public String getAllocation() {
- return getValue(ALLOCATION_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets ipnetwork's allocation.
- *
- * @param allocation ipnetwork's allocation. Cannot be null.
- * @throws InvalidAttributeValueException in case value for allocation is
- * invalid
- */
- public void setAllocation(Allocation allocation) throws InvalidAttributeValueException {
- if (allocation == null) {
- throw new NullPointerException("allocation cannot be null");
- }
- addAttribute(ALLOCATION_ATTRIBUTE_NAME, allocation.toString());
- }
-
- /**
- * Sets ipnetwork's allocation.
- *
- * @param allocationName ipnetwork's allocation. Cannot be null.
- * @throws InvalidAttributeValueException in case value for allocation is
- * invalid
- */
- public void setAllocation(String allocationName) throws InvalidAttributeValueException {
- addAttribute(ALLOCATION_ATTRIBUTE_NAME, allocationName);
- }
-
- /**
- * Returns ipnetwork's default identifier
- * 'http://schemas.ogf.org/occi/infrastructure/network#ipnetworking'
- *
- * @return ipnetwork's default identifier
- */
- @Override
- public String getDefaultKindIdentifier() {
- return MIXIN_IDENTIFIER_DEFAULT;
- }
-
- /**
- * Returns ipnetwork's default attributes. For IPNetwork class those are
- * attributes occi.network.address, occi.network.gateway and
- * occi.network.allocation.
- *
- * @return list of ipnetwork's default attributes
- */
- public static List<Attribute> getDefaultAttributes() {
- List<Attribute> list = new ArrayList<>();
- list.add(new Attribute(ADDRESS_ATTRIBUTE_NAME, false, false));
- list.add(new Attribute(GATEWAY_ATTRIBUTE_NAME, false, false));
- list.add(new Attribute(ALLOCATION_ATTRIBUTE_NAME, false, false));
-
- return list;
- }
-
- /**
- * Returns ipnetwork's default mixin instance.
- *
- * @return ipnetwork's default mixin
- */
- public static Mixin getDefaultMixin() {
- Mixin mixin = new Mixin(SCHEME_DEFAULT, TERM_DEFAULT, "IP Network Mixin", URI.create("/mixins/ipnetwork/"), IPNetwork.getDefaultAttributes());
- return mixin;
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.infrastructure;
-
-import cz.cesnet.cloud.occi.Model;
-import cz.cesnet.cloud.occi.core.Attribute;
-import cz.cesnet.cloud.occi.core.Kind;
-import cz.cesnet.cloud.occi.core.Mixin;
-import cz.cesnet.cloud.occi.exception.InvalidAttributeValueException;
-import cz.cesnet.cloud.occi.infrastructure.enumeration.Allocation;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Class representing an OCCI IPNetworkInterface
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class IPNetworkInterface extends NetworkInterface {
-
- public static final String ADDRESS_ATTRIBUTE_NAME = "occi.networkinterface.address";
- public static final String GATEWAY_ATTRIBUTE_NAME = "occi.networkinterface.gateway";
- public static final String ALLOCATION_ATTRIBUTE_NAME = "occi.networkinterface.allocation";
- public static final URI SCHEME_DEFAULT = URI.create("http://schemas.ogf.org/occi/infrastructure/networkinterface#");
- public static final String TERM_DEFAULT = "ipnetworkinterface";
- public static final String MIXIN_IDENTIFIER_DEFAULT = SCHEME_DEFAULT + TERM_DEFAULT;
-
- /**
- * Constructor.
- *
- * @param id occi.core.id attribute. Cannot be null.
- * @param kind ipnetwork interface's kind. Cannot be null.
- * @param title occi.core.title attribute
- * @param model network interface's model
- * @throws InvalidAttributeValueException in case of invalid id or title
- * value
- */
- public IPNetworkInterface(String id, Kind kind, String title, Model model) throws InvalidAttributeValueException {
- super(id, kind, title, model);
- }
-
- /**
- * Constructor.
- *
- * @param id occi.core.id attribute. Cannot be null.
- * @param kind ipnetwork interface's kind. Cannot be null.
- * @throws InvalidAttributeValueException in case of invalid id value
- */
- public IPNetworkInterface(String id, Kind kind) throws InvalidAttributeValueException {
- super(id, kind);
- }
-
- /**
- * Returns ipnetwork interface's address (attribute
- * occi.networkinterface.address).
- *
- * @return ipnetwork interface's address
- */
- public String getAddress() {
- return getValue(ADDRESS_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets ipnetwork interface's address.
- *
- * @param address ipnetwork interface's address
- * @throws InvalidAttributeValueException in case value for address is
- * invalid
- */
- public void setAddress(String address) throws InvalidAttributeValueException {
- addAttribute(ADDRESS_ATTRIBUTE_NAME, address);
- }
-
- /**
- * Returns ipnetwork interface's gateway (attribute
- * occi.networkinterface.gateway).
- *
- * @return ipnetwork interface's gateway
- */
- public String getGateway() {
- return getValue(GATEWAY_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets ipnetwork interface's gateway
- *
- * @param gateway ipnetwork interface's gateway
- * @throws InvalidAttributeValueException in case value for gateway is
- * invalid
- */
- public void setGateway(String gateway) throws InvalidAttributeValueException {
- addAttribute(GATEWAY_ATTRIBUTE_NAME, gateway);
- }
-
- /**
- * Returns ipnetwork interface's allocation (attribute
- * occi.networkinterface.allocation).
- *
- * @return ipnetwork interface's allocation
- */
- public String getAllocation() {
- return getValue(ALLOCATION_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets ipnetwork interface's allocation.
- *
- * @param allocation ipnetwork interface's allocation. Cannot be null.
- * @throws InvalidAttributeValueException in case value for allocation is
- * invalid
- */
- public void setAllocation(Allocation allocation) throws InvalidAttributeValueException {
- if (allocation == null) {
- throw new NullPointerException("allocation cannot be null");
- }
- addAttribute(ALLOCATION_ATTRIBUTE_NAME, allocation.toString());
- }
-
- /**
- * Sets ipnetwork interface's allocation.
- *
- * @param allocationName ipnetwork interface's allocation. Cannot be null.
- * @throws InvalidAttributeValueException in case value for allocation is
- * invalid
- */
- public void setAllocation(String allocationName) throws InvalidAttributeValueException {
- addAttribute(ALLOCATION_ATTRIBUTE_NAME, allocationName);
- }
-
- /**
- * Returns ipnetworkinterface's default identifier
- * 'http://schemas.ogf.org/occi/infrastructure/networkinterface#ipnetworkinterface'
- *
- * @return ipnetworkinterface's default identifier
- */
- @Override
- public String getDefaultKindIdentifier() {
- return MIXIN_IDENTIFIER_DEFAULT;
- }
-
- /**
- * Returns ipnetworkinterface's default attributes. For IPNetworkInterface
- * class those are attributes occi.networkinterface.address,
- * occi.networkinterface.gateway and occi.networkinterface.allocation.
- *
- * @return list of ipnetworkinterface's default attributes
- */
- public static List<Attribute> getDefaultAttributes() {
- List<Attribute> list = new ArrayList<>();
- list.add(new Attribute(ADDRESS_ATTRIBUTE_NAME, true, false));
- list.add(new Attribute(GATEWAY_ATTRIBUTE_NAME, false, false));
- list.add(new Attribute(ALLOCATION_ATTRIBUTE_NAME, true, false));
-
- return list;
- }
-
- /**
- * Returns ipnetworkinterface's default mixin instance.
- *
- * @return ipnetworkinterface's default mixin
- */
- public static Mixin getDefaultMixin() {
- Mixin mixin = new Mixin(SCHEME_DEFAULT, TERM_DEFAULT, "IP Networkinterface Mixin", URI.create("/mixins/ipnetworkinterface/"), IPNetworkInterface.getDefaultAttributes());
- return mixin;
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.infrastructure;
-
-import cz.cesnet.cloud.occi.Model;
-import cz.cesnet.cloud.occi.core.Attribute;
-import cz.cesnet.cloud.occi.core.Category;
-import cz.cesnet.cloud.occi.core.Kind;
-import cz.cesnet.cloud.occi.core.Resource;
-import cz.cesnet.cloud.occi.exception.InvalidAttributeValueException;
-import cz.cesnet.cloud.occi.infrastructure.enumeration.NetworkState;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Class representing an OCCI Network
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class Network extends Resource {
-
- public static final String VLAN_ATTRIBUTE_NAME = "occi.network.vlan";
- public static final String LABEL_ATTRIBUTE_NAME = "occi.network.label";
- public static final String STATE_ATTRIBUTE_NAME = "occi.network.state";
- public static final URI SCHEME_DEFAULT = Category.SCHEME_INFRASTRUCTURE_DEFAULT;
- public static final String TERM_DEFAULT = "network";
- public static final String KIND_IDENTIFIER_DEFAULT = SCHEME_DEFAULT + TERM_DEFAULT;
-
- /**
- * Constructor.
- *
- * @param id occi.core.id attribute. Cannot be null.
- * @param kind network's kind. Cannot be null.
- * @param title occi.core.title attribute
- * @param model network's model
- * @param summary network's summary
- * @throws InvalidAttributeValueException in case of invalid id, title or
- * summary value
- */
- public Network(String id, Kind kind, String title, Model model, String summary) throws InvalidAttributeValueException {
- super(id, kind, title, model, summary);
- }
-
- /**
- * Constructor.
- *
- * @param id occi.core.id attribute. Cannot be null.
- * @param kind network's kind. Cannot be null.
- * @throws InvalidAttributeValueException in case of invalid id value
- */
- public Network(String id, Kind kind) throws InvalidAttributeValueException {
- super(id, kind);
- }
-
- /**
- * Returns network's vlan number (attribute occi.network.vlan).
- *
- * @return network's vlan number
- */
- public String getVlan() {
- return getValue(VLAN_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets network's vlan number.
- *
- * @param vlan network's vlan number
- * @throws InvalidAttributeValueException in case value for vlan is invalid
- */
- public void setVlan(int vlan) throws InvalidAttributeValueException {
- addAttribute(VLAN_ATTRIBUTE_NAME, String.valueOf(vlan));
- }
-
- /**
- * Sets network's vlan number.
- *
- * @param vlan network's vlan number
- * @throws InvalidAttributeValueException in case value for vlan is invalid
- */
- public void setVlan(String vlan) throws InvalidAttributeValueException {
- addAttribute(VLAN_ATTRIBUTE_NAME, vlan);
- }
-
- /**
- * Returns network's label (attribute occi.network.label).
- *
- * @return network's label
- */
- public String getLabel() {
- return getValue(LABEL_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets network's label.
- *
- * @param label network's label
- * @throws InvalidAttributeValueException in case value for label is invalid
- */
- public void setLabel(String label) throws InvalidAttributeValueException {
- addAttribute(LABEL_ATTRIBUTE_NAME, label);
- }
-
- /**
- * Returns network's state (attribute occi.network.state).
- *
- * @return network's state
- */
- public String getState() {
- return getValue(STATE_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets network's state.
- *
- * @param state network's state. Cannot be null.
- * @throws InvalidAttributeValueException in case value for state is invalid
- */
- public void setState(NetworkState state) throws InvalidAttributeValueException {
- if (state == null) {
- throw new NullPointerException("state cannot be null");
- }
- addAttribute(STATE_ATTRIBUTE_NAME, state.toString());
- }
-
- /**
- * Sets network's state.
- *
- * @param stateName network's state
- * @throws InvalidAttributeValueException in case value for state is invalid
- */
- public void setState(String stateName) throws InvalidAttributeValueException {
- addAttribute(STATE_ATTRIBUTE_NAME, stateName);
- }
-
- /**
- * Returns network's default identifier
- * 'http://schemas.ogf.org/occi/infrastructure#network'
- *
- * @return network's default identifier
- */
- @Override
- public String getDefaultKindIdentifier() {
- return KIND_IDENTIFIER_DEFAULT;
- }
-
- /**
- * Returns network's default attributes. For Network class those are
- * attributes occi.network.vlan, occi.network.label, occi.network.state.
- *
- * @return list of network's default attributes
- */
- public static List<Attribute> getDefaultAttributes() {
- List<Attribute> list = new ArrayList<>();
- list.addAll(Resource.getDefaultAttributes());
- list.add(new Attribute(VLAN_ATTRIBUTE_NAME, false, false));
- list.add(new Attribute(LABEL_ATTRIBUTE_NAME, false, false));
- list.add(new Attribute(STATE_ATTRIBUTE_NAME, true, true));
-
- return list;
- }
-
- /**
- * Returns network's default kind instance.
- *
- * @return network's default kind
- */
- public static Kind getDefaultKind() {
- Kind kind = new Kind(SCHEME_DEFAULT, TERM_DEFAULT, "Network Resource", URI.create("/network/"), Network.getDefaultAttributes());
- return kind;
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.infrastructure;
-
-import cz.cesnet.cloud.occi.Model;
-import cz.cesnet.cloud.occi.core.Attribute;
-import cz.cesnet.cloud.occi.core.Category;
-import cz.cesnet.cloud.occi.core.Kind;
-import cz.cesnet.cloud.occi.core.Link;
-import cz.cesnet.cloud.occi.exception.InvalidAttributeValueException;
-import cz.cesnet.cloud.occi.infrastructure.enumeration.NetworkState;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Class representing an OCCI NetworkInterface
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class NetworkInterface extends Link {
-
- public static final String INTERFACE_ATTRIBUTE_NAME = "occi.networkinterface.interface";
- public static final String MAC_ATTRIBUTE_NAME = "occi.networkinterface.mac";
- public static final String STATE_ATTRIBUTE_NAME = "occi.networkinterface.state";
- public static final URI SCHEME_DEFAULT = Category.SCHEME_INFRASTRUCTURE_DEFAULT;
- public static final String TERM_DEFAULT = "networkinterface";
- public static final String KIND_IDENTIFIER_DEFAULT = SCHEME_DEFAULT + TERM_DEFAULT;
-
- /**
- * Constructor.
- *
- * @param id occi.core.id attribute. Cannot be null.
- * @param kind network interface's kind. Cannot be null.
- * @param title occi.core.title attribute
- * @param model network interface's model
- * @throws InvalidAttributeValueException in case of invalid id or title
- * value
- */
- public NetworkInterface(String id, Kind kind, String title, Model model) throws InvalidAttributeValueException {
- super(id, kind, title, model);
- }
-
- /**
- * Constructor.
- *
- * @param id occi.core.id attribute. Cannot be null.
- * @param kind network interface's kind. Cannot be null.
- * @throws InvalidAttributeValueException in case of invalid id value
- */
- public NetworkInterface(String id, Kind kind) throws InvalidAttributeValueException {
- super(id, kind);
- }
-
- /**
- * Returns network interface's interface (attribute
- * occi.networkinterface.interface).
- *
- * @return network interface's interface
- */
- public String getNetworkInterface() {
- return getValue(INTERFACE_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets network interface's interface
- *
- * @param networkInterface network interface's interface
- * @throws InvalidAttributeValueException in case value for interface is
- * invalid
- */
- public void setNetworkInterface(String networkInterface) throws InvalidAttributeValueException {
- addAttribute(INTERFACE_ATTRIBUTE_NAME, networkInterface);
- }
-
- /**
- * Returns network interface's mac address.
- *
- * @return network interface's mac address
- */
- public String getMac() {
- return getValue(MAC_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets network interface's mac address
- *
- * @param mac network interface's mac address
- * @throws InvalidAttributeValueException in case value for mac address is
- * invalid
- */
- public void setMac(String mac) throws InvalidAttributeValueException {
- addAttribute(MAC_ATTRIBUTE_NAME, mac);
- }
-
- /**
- * Returns network interface's state.
- *
- * @return network interface's state
- */
- public String getState() {
- return getValue(STATE_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets network interface's state.
- *
- * @param state network interface's state. Cannot be null.
- * @throws InvalidAttributeValueException in case value for state is invalid
- */
- public void setState(NetworkState state) throws InvalidAttributeValueException {
- if (state == null) {
- throw new NullPointerException("state cannot be null");
- }
- addAttribute(STATE_ATTRIBUTE_NAME, state.toString());
- }
-
- /**
- * Sets network interface's state.
- *
- * @param stateName network interface's state. Cannot be null.
- * @throws InvalidAttributeValueException in case value for state is invalid
- */
- public void setState(String stateName) throws InvalidAttributeValueException {
- addAttribute(STATE_ATTRIBUTE_NAME, stateName);
- }
-
- /**
- * Returns networkinterface's default identifier
- * 'http://schemas.ogf.org/occi/infrastructure#networkinterface'
- *
- * @return networkinterface's default identifier
- */
- @Override
- public String getDefaultKindIdentifier() {
- return KIND_IDENTIFIER_DEFAULT;
- }
-
- /**
- * Returns networkinterface's default attributes. For NetworkInterface class
- * those are attributes occi.networkinterface.interface,
- * occi.networkinterface.mac and occi.networkinterface.state.
- *
- * @return list of networkinterface's default attributes
- */
- public static List<Attribute> getDefaultAttributes() {
- List<Attribute> list = new ArrayList<>();
- list.addAll(Link.getDefaultAttributes());
- list.add(new Attribute(INTERFACE_ATTRIBUTE_NAME, true, true));
- list.add(new Attribute(MAC_ATTRIBUTE_NAME, true, false));
- list.add(new Attribute(STATE_ATTRIBUTE_NAME, true, true));
-
- return list;
- }
-
- /**
- * Returns networkinterface's default kind instance.
- *
- * @return networkinterface's default kind
- */
- public static Kind getDefaultKind() {
- Kind kind = new Kind(SCHEME_DEFAULT, TERM_DEFAULT, "Networkinterface", URI.create("/networkinterface/"), NetworkInterface.getDefaultAttributes());
- return kind;
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.infrastructure;
-
-import cz.cesnet.cloud.occi.Model;
-import cz.cesnet.cloud.occi.core.Attribute;
-import cz.cesnet.cloud.occi.core.Category;
-import cz.cesnet.cloud.occi.core.Kind;
-import cz.cesnet.cloud.occi.core.Resource;
-import cz.cesnet.cloud.occi.exception.InvalidAttributeValueException;
-import cz.cesnet.cloud.occi.infrastructure.enumeration.StorageState;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Class representing an OCCI Storage.
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class Storage extends Resource {
-
- public static final String SIZE_ATTRIBUTE_NAME = "occi.storage.size";
- public static final String STATE_ATTRIBUTE_NAME = "occi.storage.state";
- public static final URI SCHEME_DEFAULT = Category.SCHEME_INFRASTRUCTURE_DEFAULT;
- public static final String TERM_DEFAULT = "storage";
- public static final String KIND_IDENTIFIER_DEFAULT = SCHEME_DEFAULT + TERM_DEFAULT;
-
- /**
- * Constructor.
- *
- * @param id occi.core.id attribute. Cannot be null.
- * @param kind storage's kind. Cannot be null.
- * @param title occi.core.title attribute
- * @param model storage's model
- * @param summary storage's summary
- * @throws InvalidAttributeValueException in case of invalid id, title or
- * summary value
- */
- public Storage(String id, Kind kind, String title, Model model, String summary) throws InvalidAttributeValueException {
- super(id, kind, title, model, summary);
- }
-
- /**
- * Constructor.
- *
- * @param id occi.core.id attribute. Cannot be null.
- * @param kind storage's kind. Cannot be null.
- * @throws InvalidAttributeValueException in case of invalid id value
- */
- public Storage(String id, Kind kind) throws InvalidAttributeValueException {
- super(id, kind);
- }
-
- /**
- * Returns storage's size (attribute occi.storage.size).
- *
- * @return storage's size
- */
- public String getSize() {
- return getValue(SIZE_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets storage's size.
- *
- * @param size storage's size
- * @throws InvalidAttributeValueException in case value for size is invalid
- */
- public void setSize(float size) throws InvalidAttributeValueException {
- addAttribute(SIZE_ATTRIBUTE_NAME, String.valueOf(size));
- }
-
- /**
- * Sets storage's size.
- *
- * @param size storage's size
- * @throws InvalidAttributeValueException in case value for size is invalid
- */
- public void setSize(String size) throws InvalidAttributeValueException {
- addAttribute(SIZE_ATTRIBUTE_NAME, size);
- }
-
- /**
- * Returns storage's state (attribute occi.storage.state).
- *
- * @return storage's state
- */
- public String getState() {
- return getValue(STATE_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets storage's state.
- *
- * @param state storage's state. Cannot be null.
- * @throws InvalidAttributeValueException in case value for state is invalid
- */
- public void setState(StorageState state) throws InvalidAttributeValueException {
- if (state == null) {
- throw new NullPointerException("state cannot be null");
- }
- addAttribute(STATE_ATTRIBUTE_NAME, state.toString());
- }
-
- /**
- * Sets storage's state.
- *
- * @param stateName storage's state
- * @throws InvalidAttributeValueException in case value for state is invalid
- */
- public void setState(String stateName) throws InvalidAttributeValueException {
- addAttribute(STATE_ATTRIBUTE_NAME, stateName);
- }
-
- /**
- * Returns storage's default scheme
- * 'http://schemas.ogf.org/occi/infrastructure#'
- *
- * @return storage's default scheme
- */
- public static URI getSchemeDefault() {
- return Category.SCHEME_INFRASTRUCTURE_DEFAULT;
- }
-
- /**
- * Returns storage's default term 'storage'.
- *
- * @return storage's default term
- */
- public static String getTermDefault() {
- return "storage";
- }
-
- /**
- * Returns storage's default identifier
- * 'http://schemas.ogf.org/occi/infrastructure#storage'
- *
- * @return storage's default identifier
- */
- @Override
- public String getDefaultKindIdentifier() {
- return KIND_IDENTIFIER_DEFAULT;
- }
-
- /**
- * Returns storage's default attributes. For Storage class those are
- * attributes occi.storage.size and occi.storage.state.
- *
- * @return list of storage's default attributes
- */
- public static List<Attribute> getDefaultAttributes() {
- List<Attribute> list = new ArrayList<>();
- list.addAll(Resource.getDefaultAttributes());
- list.add(new Attribute(SIZE_ATTRIBUTE_NAME, true, false));
- list.add(new Attribute(STATE_ATTRIBUTE_NAME, true, true));
-
- return list;
- }
-
- /**
- * Returns storage's default kind instance.
- *
- * @return storage's default kind
- */
- public static Kind getDefaultKind() {
- Kind kind = new Kind(SCHEME_DEFAULT, TERM_DEFAULT, "Storage Resource", URI.create("/storage/"), Storage.getDefaultAttributes());
- return kind;
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.infrastructure;
-
-import cz.cesnet.cloud.occi.Model;
-import cz.cesnet.cloud.occi.core.Attribute;
-import cz.cesnet.cloud.occi.core.Category;
-import cz.cesnet.cloud.occi.core.Kind;
-import cz.cesnet.cloud.occi.core.Link;
-import cz.cesnet.cloud.occi.exception.InvalidAttributeValueException;
-import cz.cesnet.cloud.occi.infrastructure.enumeration.StorageLinkState;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Class representing an OCCI StorageLink
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class StorageLink extends Link {
-
- public static final String DEVICE_ID_ATTRIBUTE_NAME = "occi.storagelink.deviceid";
- public static final String MOUNTPOINT_ATTRIBUTE_NAME = "occi.storagelink.mountpoint";
- public static final String STATE_ATTRIBUTE_NAME = "occi.storagelink.state";
- public static final URI SCHEME_DEFAULT = Category.SCHEME_INFRASTRUCTURE_DEFAULT;
- public static final String TERM_DEFAULT = "storagelink";
- public static final String KIND_IDENTIFIER_DEFAULT = SCHEME_DEFAULT + TERM_DEFAULT;
-
- /**
- * Constructor.
- *
- * @param id occi.core.id attribute. Cannot be null.
- * @param kind storage link's kind. Cannot be null.
- * @param title occi.core.title attribute
- * @param model storage link's model
- * @throws InvalidAttributeValueException in case of invalid id or title
- * value
- */
- public StorageLink(String id, Kind kind, String title, Model model) throws InvalidAttributeValueException {
- super(id, kind, title, model);
- }
-
- /**
- * Constructor.
- *
- * @param id occi.core.id attribute. Cannot be null.
- * @param kind storage link's kind. Cannot be null.
- * @throws InvalidAttributeValueException in case of invalid id value
- */
- public StorageLink(String id, Kind kind) throws InvalidAttributeValueException {
- super(id, kind);
- }
-
- /**
- * Returns storage link's device id (attribute occi.storagelink.deviceid).
- *
- * @return storage link's device id
- */
- public String getDeviceId() {
- return getValue(DEVICE_ID_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets storage link's device id.
- *
- * @param id storage link's device id
- * @throws InvalidAttributeValueException in case value for devide id is
- * invalid
- */
- public void setDeviceId(String id) throws InvalidAttributeValueException {
- addAttribute(DEVICE_ID_ATTRIBUTE_NAME, id);
- }
-
- /**
- * Returns storage link's mountpoint (attribute
- * occi.storagelink.mountpoint).
- *
- * @return storage link's mountpoint
- */
- public String getMountpoint() {
- return getValue(MOUNTPOINT_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets storage link's mountpoint
- *
- * @param mountpoint storage link's mountpoint
- * @throws InvalidAttributeValueException in case value for moutnpoint is
- * invalid
- */
- public void setMountpoint(String mountpoint) throws InvalidAttributeValueException {
- addAttribute(MOUNTPOINT_ATTRIBUTE_NAME, mountpoint);
- }
-
- /**
- * Returns storage link's state (attribute occi.storagelink.state).
- *
- * @return storage link's state
- */
- public String getState() {
- return getValue(STATE_ATTRIBUTE_NAME);
- }
-
- /**
- * Sets storage link's state.
- *
- * @param state storage link's state. Cannot be null.
- * @throws InvalidAttributeValueException in case value for state is invalid
- */
- public void setState(StorageLinkState state) throws InvalidAttributeValueException {
- if (state == null) {
- throw new NullPointerException("state cannot be null");
- }
- addAttribute(STATE_ATTRIBUTE_NAME, state.toString());
- }
-
- /**
- * Sets storage link's state.
- *
- * @param stateName storage link's state
- * @throws InvalidAttributeValueException in case value for state is invalid
- */
- public void setState(String stateName) throws InvalidAttributeValueException {
- addAttribute(STATE_ATTRIBUTE_NAME, stateName);
- }
-
- /**
- * Returns storagelink's default identifier
- * 'http://schemas.ogf.org/occi/infrastructure#storagelink'
- *
- * @return storagelink's default identifier
- */
- @Override
- public String getDefaultKindIdentifier() {
- return KIND_IDENTIFIER_DEFAULT;
- }
-
- /**
- * Returns storagelink's default attributes. For StorageLink class those are
- * attributes occi.storagelink.deviceid, occi.storagelink.mountpoint and
- * occi.storagelink.state.
- *
- * @return list of storagelink's default attributes
- */
- public static List<Attribute> getDefaultAttributes() {
- List<Attribute> list = new ArrayList<>();
- list.addAll(Storage.getDefaultAttributes());
- list.add(new Attribute(DEVICE_ID_ATTRIBUTE_NAME, true, false));
- list.add(new Attribute(MOUNTPOINT_ATTRIBUTE_NAME, false, false));
- list.add(new Attribute(STATE_ATTRIBUTE_NAME, true, true));
-
- return list;
- }
-
- /**
- * Returns storagelink's default kind instance.
- *
- * @return storagelink's default kind
- */
- public static Kind getDefaultKind() {
- Kind kind = new Kind(SCHEME_DEFAULT, TERM_DEFAULT, "Storage Link", URI.create("/storagelink/"), StorageLink.getDefaultAttributes());
- return kind;
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.infrastructure.enumeration;
-
-/**
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public enum Allocation {
-
- DYNAMIC, STATIC;
-
- @Override
- public String toString() {
- return this.name().toLowerCase();
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.infrastructure.enumeration;
-
-/**
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public enum Architecture {
-
- X_86, X_64;
-
- @Override
- public String toString() {
- return this.name().toLowerCase();
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.infrastructure.enumeration;
-
-/**
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public enum ComputeState {
-
- ACTIVE, INACTIVE, SUSPENDED;
-
- @Override
- public String toString() {
- return this.name().toLowerCase();
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.infrastructure.enumeration;
-
-/**
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public enum NetworkState {
-
- ACTIVE, INACTIVE;
-
- @Override
- public String toString() {
- return this.name().toLowerCase();
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.infrastructure.enumeration;
-
-/**
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public enum StorageLinkState {
-
- ACTIVE, INACTIVE;
-
- @Override
- public String toString() {
- return this.name().toLowerCase();
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.infrastructure.enumeration;
-
-/**
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public enum StorageState {
-
- ONLINE, OFFLINE, BACKUP, SNAPSHOT, RESIZE, DEGRADED;
-
- @Override
- public String toString() {
- return this.name().toLowerCase();
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.parser;
-
-/**
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public enum CollectionType {
-
- RESOURCE, LINK, ACTION;
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.parser;
-
-import com.sun.net.httpserver.Headers;
-import cz.cesnet.cloud.occi.Collection;
-import cz.cesnet.cloud.occi.Model;
-import cz.cesnet.cloud.occi.exception.ParsingException;
-import java.net.URI;
-import java.util.List;
-
-/**
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class JSONParser implements Parser {
-
- @Override
- public Model parseModel(String mediaType, String body, Headers headers) throws ParsingException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public Collection parseCollection(String mediaType, String body, Headers headers, CollectionType collectionType) throws ParsingException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public List<URI> parseLocations(String mediaType, String body, Headers headers) throws ParsingException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.parser;
-
-/**
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class MediaType {
-
- public static final String APPLICATION_JSON = "application/json";
- public static final String TEXT_OCCI = "text/occi";
- public static final String TEXT_PLAIN = "text/plain";
- public static final String TEXT_URI_LIST = "text/uri-list";
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.parser;
-
-import com.sun.net.httpserver.Headers;
-import cz.cesnet.cloud.occi.Collection;
-import cz.cesnet.cloud.occi.Model;
-import cz.cesnet.cloud.occi.exception.ParsingException;
-import java.net.URI;
-import java.util.List;
-
-/**
- * Interface for parser of OCCI messages.
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public interface Parser {
-
- /**
- * Parses an OCCI model either from body or headers depending on mediaType.
- *
- * @param mediaType media type of the parsed server response
- * @param body body of the server response
- * @param headers headers of the server response
- * @return OCCI model
- * @throws ParsingException when error occures during the parsing
- */
- Model parseModel(String mediaType, String body, Headers headers) throws ParsingException;
-
- /**
- * Parses an OCCI entity either from body or headers depending on mediaType
- * and collectionType.
- *
- * @param mediaType media type of the parsed server response
- * @param body body of the server response
- * @param headers headers of the server response
- * @param collectionType collection type representing entities that will be
- * parsed from the response
- * @return collection of parsed entities
- * @throws ParsingException when error occures during the parsing
- */
- Collection parseCollection(String mediaType, String body, Headers headers, CollectionType collectionType) throws ParsingException;
-
- /**
- * Parses a list of locations either from body or headers depending on
- * mediaType.
- *
- * @param mediaType media type of the parsed server response
- * @param body body of the server response
- * @param headers headers of the server response
- * @return list of locations
- * @throws ParsingException when error occures during the parsing
- */
- List<URI> parseLocations(String mediaType, String body, Headers headers) throws ParsingException;
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.parser;
-
-import com.sun.net.httpserver.Headers;
-import cz.cesnet.cloud.occi.Collection;
-import cz.cesnet.cloud.occi.Model;
-import cz.cesnet.cloud.occi.core.Action;
-import cz.cesnet.cloud.occi.core.ActionInstance;
-import cz.cesnet.cloud.occi.core.Attribute;
-import cz.cesnet.cloud.occi.core.Category;
-import cz.cesnet.cloud.occi.core.Entity;
-import cz.cesnet.cloud.occi.core.Kind;
-import cz.cesnet.cloud.occi.core.Link;
-import cz.cesnet.cloud.occi.core.Mixin;
-import cz.cesnet.cloud.occi.core.Resource;
-import cz.cesnet.cloud.occi.exception.InvalidAttributeValueException;
-import cz.cesnet.cloud.occi.exception.ParsingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class TextParser implements Parser {
-
- //regular expression groups
- public static final String GROUP_TERM = "term";
- public static final String GROUP_SCHEME = "scheme";
- public static final String GROUP_CLASS = "class";
- public static final String GROUP_TITLE = "title";
- public static final String GROUP_REL = "rel";
- public static final String GROUP_LOCATION = "location";
- public static final String GROUP_ATTRIBUTES = "attributes";
- public static final String GROUP_ACTIONS = "actions";
- public static final String GROUP_URI = "uri";
- public static final String GROUP_SELF = "self";
- public static final String GROUP_CATEGORY = "category";
-
- //regular expressions
- public static final String REGEXP_LOALPHA = "[a-z]";
- public static final String REGEXP_ALPHA = "[a-zA-Z]";
- public static final String REGEXP_DIGIT = "[0-9]";
- public static final String REGEXP_INT = REGEXP_DIGIT + "+";
- public static final String REGEXP_FLOAT = REGEXP_INT + "\\." + REGEXP_INT;
- public static final String REGEXP_NUMBER = REGEXP_FLOAT + "|" + REGEXP_INT;
- public static final String REGEXP_BOOL = "\\b(?<!\\|)true(?!\\|)\\b|\\b(?<!\\|)false(?!\\|)\\b";
- public static final String REGEXP_QUOTED_STRING = "([^\"\\\\]|\\.)*";
- public static final String REGEXP_URI = "(?x-mi:([a-zA-Z][\\-+.a-zA-Z\\d]*):(?:((?:[\\-_.!~*'()a-zA-Z\\d;?:@&=+$,]|%[a-fA-F\\d]{2})(?:[\\-_.!~*'()a-zA-Z\\d;\\/?:@&=+$,\\[\\]]|%[a-fA-F\\d]{2})*)|(?:(?:\\/\\/(?:(?:(?:((?:[\\-_.!~*'()a-zA-Z\\d;:&=+$,]|%[a-fA-F\\d]{2})*)@)?(?:((?:(?:[a-zA-Z0-9\\-.]|%[0-9a-fA-F][0-9a-fA-F])+|\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|\\[(?:(?:[a-fA-F\\d]{1,4}:)*(?:[a-fA-F\\d]{1,4}|\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})|(?:(?:[a-fA-F\\d]{1,4}:)*[a-fA-F\\d]{1,4})?::(?:(?:[a-fA-F\\d]{1,4}:)*(?:[a-fA-F\\d]{1,4}|\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}))?)\\]))(?::(\\d*))?))?|((?:[\\-_.!~*'()a-zA-Z\\d$,;:@&=+]|%[a-fA-F\\d]{2})+))|(?!\\/\\/))(\\/(?:[\\-_.!~*'()a-zA-Z\\d:@&=+$,]|%[a-fA-F\\d]{2})*(?:;(?:[\\-_.!~*'()a-zA-Z\\d:@&=+$,]|%[a-fA-F\\d]{2})*)*(?:\\/(?:[\\-_.!~*'()a-zA-Z\\d:@&=+$,]|%[a-fA-F\\d]{2})*(?:;(?:[\\-_.!~*'()a-zA-Z\\d:@&=+$,]|%[a-fA-F\\d]{2})*)*)*)?)(?:\\?((?:[\\-_.!~*'()a-zA-Z\\d;\\/?:@&=+$,\\[\\]]|%[a-fA-F\\d]{2})*))?)(?:\\#((?:[\\-_.!~*'()a-zA-Z\\d;\\/?:@&=+$,\\[\\]]|%[a-fA-F\\d]{2})*))?)";
- public static final String REGEXP_URI_REF = "(?:[a-zA-Z][\\-+.a-zA-Z\\d]*:(?:(?:\\/\\/(?:(?:(?:[\\-_.!~*'()a-zA-Z\\d;:&=+$,]|%[a-fA-F\\d]{2})*@)?(?:(?:[a-zA-Z0-9\\-.]|%[0-9a-fA-F][0-9a-fA-F])+|\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|\\[(?:(?:[a-fA-F\\d]{1,4}:)*(?:[a-fA-F\\d]{1,4}|\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})|(?:(?:[a-fA-F\\d]{1,4}:)*[a-fA-F\\d]{1,4})?::(?:(?:[a-fA-F\\d]{1,4}:)*(?:[a-fA-F\\d]{1,4}|\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}))?)\\])(?::\\d*)?|(?:[\\-_.!~*'()a-zA-Z\\d$,;:@&=+]|%[a-fA-F\\d]{2})+)(?:\\/(?:[\\-_.!~*'()a-zA-Z\\d:@&=+$,]|%[a-fA-F\\d]{2})*(?:;(?:[\\-_.!~*'()a-zA-Z\\d:@&=+$,]|%[a-fA-F\\d]{2})*)*(?:\\/(?:[\\-_.!~*'()a-zA-Z\\d:@&=+$,]|%[a-fA-F\\d]{2})*(?:;(?:[\\-_.!~*'()a-zA-Z\\d:@&=+$,]|%[a-fA-F\\d]{2})*)*)*)?|\\/(?:[\\-_.!~*'()a-zA-Z\\d:@&=+$,]|%[a-fA-F\\d]{2})*(?:;(?:[\\-_.!~*'()a-zA-Z\\d:@&=+$,]|%[a-fA-F\\d]{2})*)*(?:\\/(?:[\\-_.!~*'()a-zA-Z\\d:@&=+$,]|%[a-fA-F\\d]{2})*(?:;(?:[\\-_.!~*'()a-zA-Z\\d:@&=+$,]|%[a-fA-F\\d]{2})*)*)*)(?:\\?(?:(?:[\\-_.!~*'()a-zA-Z\\d;\\/?:@&=+$,\\[\\]]|%[a-fA-F\\d]{2})*))?|(?:[\\-_.!~*'()a-zA-Z\\d;?:@&=+$,]|%[a-fA-F\\d]{2})(?:[\\-_.!~*'()a-zA-Z\\d;\\/?:@&=+$,\\[\\]]|%[a-fA-F\\d]{2})*)|(?:\\/\\/(?:(?:(?:[\\-_.!~*'()a-zA-Z\\d;:&=+$,]|%[a-fA-F\\d]{2})*@)?(?:(?:[a-zA-Z0-9\\-.]|%[0-9a-fA-F][0-9a-fA-F])+|\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|\\[(?:(?:[a-fA-F\\d]{1,4}:)*(?:[a-fA-F\\d]{1,4}|\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})|(?:(?:[a-fA-F\\d]{1,4}:)*[a-fA-F\\d]{1,4})?::(?:(?:[a-fA-F\\d]{1,4}:)*(?:[a-fA-F\\d]{1,4}|\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}))?)\\])(?::\\d*)?|(?:[\\-_.!~*'()a-zA-Z\\d$,;:@&=+]|%[a-fA-F\\d]{2})+)(?:\\/(?:[\\-_.!~*'()a-zA-Z\\d:@&=+$,]|%[a-fA-F\\d]{2})*(?:;(?:[\\-_.!~*'()a-zA-Z\\d:@&=+$,]|%[a-fA-F\\d]{2})*)*(?:\\/(?:[\\-_.!~*'()a-zA-Z\\d:@&=+$,]|%[a-fA-F\\d]{2})*(?:;(?:[\\-_.!~*'()a-zA-Z\\d:@&=+$,]|%[a-fA-F\\d]{2})*)*)*)?|\\/(?:[\\-_.!~*'()a-zA-Z\\d:@&=+$,]|%[a-fA-F\\d]{2})*(?:;(?:[\\-_.!~*'()a-zA-Z\\d:@&=+$,]|%[a-fA-F\\d]{2})*)*(?:\\/(?:[\\-_.!~*'()a-zA-Z\\d:@&=+$,]|%[a-fA-F\\d]{2})*(?:;(?:[\\-_.!~*'()a-zA-Z\\d:@&=+$,]|%[a-fA-F\\d]{2})*)*)*|(?:[\\-_.!~*'()a-zA-Z\\d;@&=+$,]|%[a-fA-F\\d]{2})+(?:\\/(?:[\\-_.!~*'()a-zA-Z\\d:@&=+$,]|%[a-fA-F\\d]{2})*(?:;(?:[\\-_.!~*'()a-zA-Z\\d:@&=+$,]|%[a-fA-F\\d]{2})*)*(?:\\/(?:[\\-_.!~*'()a-zA-Z\\d:@&=+$,]|%[a-fA-F\\d]{2})*(?:;(?:[\\-_.!~*'()a-zA-Z\\d:@&=+$,]|%[a-fA-F\\d]{2})*)*)*)?)(?:\\?(?:[\\-_.!~*'()a-zA-Z\\d;\\/?:@&=+$,\\[\\]]|%[a-fA-F\\d]{2})*)?)?(?:#(?:[\\-_.!~*'()a-zA-Z\\d;\\/?:@&=+$,\\[\\]]|%[a-fA-F\\d]{2})*)?";
- public static final String REGEXP_TERM = "(" + REGEXP_ALPHA + "|" + REGEXP_DIGIT + ")(" + REGEXP_LOALPHA + "|" + REGEXP_DIGIT + "|-|_)*";
-
- public static final String REGEXP_SCHEME = REGEXP_URI + "#";
- public static final String REGEXP_TYPE_IDENTIFIER = REGEXP_SCHEME + REGEXP_TERM;
- public static final String REGEXP_CLASS = "\\b(?<!\\|)action(?!\\|)\\b|\\b(?<!\\|)mixin(?!\\|)\\b|\\b(?<!\\|)kind(?!\\|)\\b";
- public static final String REGEXP_TYPE_IDENTIFIER_LIST = REGEXP_TYPE_IDENTIFIER + "(\\s+" + REGEXP_TYPE_IDENTIFIER + ")*";
- public static final String REGEXP_ATTRIBUTE_COMPONENT = REGEXP_LOALPHA + "(" + REGEXP_LOALPHA + "|" + REGEXP_DIGIT + "|-|_)*";
- public static final String REGEXP_ATTRIBUTE_NAME = REGEXP_ATTRIBUTE_COMPONENT + "(\\." + REGEXP_ATTRIBUTE_COMPONENT + ")*";
- public static final String REGEXP_ATTRIBUTE_PROPERTIES = "\\{(?:required immutable|immutable required|required|immutable)\\}";
- public static final String REGEXP_ATTRIBUTE_DEF = "(?:" + REGEXP_ATTRIBUTE_NAME + ")(?:" + REGEXP_ATTRIBUTE_PROPERTIES + ")?";
- public static final String REGEXP_ATTRIBUTE_LIST = REGEXP_ATTRIBUTE_DEF + "(\\s+" + REGEXP_ATTRIBUTE_DEF + ")*";
- public static final String REGEXP_ATTRIBUTE_REPR = REGEXP_ATTRIBUTE_NAME + "=(\"" + REGEXP_QUOTED_STRING + "\"|" + REGEXP_NUMBER + "|" + REGEXP_BOOL + ");?";
- public static final String REGEXP_ACTION = REGEXP_TYPE_IDENTIFIER;
- public static final String REGEXP_ACTION_LIST = REGEXP_ACTION + "(\\s+" + REGEXP_ACTION + ")*";
- public static final String REGEXP_RESOURCE_TYPE = REGEXP_TYPE_IDENTIFIER + "(\\s+" + REGEXP_TYPE_IDENTIFIER + ")*";
- public static final String REGEXP_LINK_INSTANCE = REGEXP_URI_REF;
- public static final String REGEXP_LINK_TYPE = REGEXP_TYPE_IDENTIFIER + "(\\s+" + REGEXP_TYPE_IDENTIFIER + ")*";
-
- public static final String REGEXP_CATEGORY = "(?<" + GROUP_TERM + ">" + REGEXP_TERM + ")" // term (mandatory)
- + ";\\s*scheme=\"(?<" + GROUP_SCHEME + ">" + REGEXP_SCHEME + ")(?:" + REGEXP_TERM + ")?\"" // scheme (mandatory)
- + ";\\s*class=\"?(?<" + GROUP_CLASS + ">" + REGEXP_CLASS + ")\"?" // class (mandatory)
- + "(;\\s*title=\"(?<" + GROUP_TITLE + ">" + REGEXP_QUOTED_STRING + ")\")?" // title (optional)
- + "(;\\s*rel=\"(?<" + GROUP_REL + ">" + REGEXP_TYPE_IDENTIFIER_LIST + ")\")?" // rel (optional)
- + "(;\\s*location=\"(?<" + GROUP_LOCATION + ">" + REGEXP_URI_REF + ")\")?" // location (optional)
- + "(;\\s*attributes=\"(?<" + GROUP_ATTRIBUTES + ">" + REGEXP_ATTRIBUTE_LIST + ")\")?" // attributes (optional)
- + "(;\\s*actions=\"(?<" + GROUP_ACTIONS + ">" + REGEXP_ACTION_LIST + ")\")?" // actions (optional)
- + ";?"; // additional semicolon at the end (not specified, for interoperability)
-
- public static final String REGEXP_ATTRIBUTES = "(" + REGEXP_ATTRIBUTE_DEF + ")";
-
- public static final String REGEXP_LINK = "\\<(?<" + GROUP_URI + ">" + REGEXP_URI_REF + ")\\>" // uri (mandatory)
- + ";\\s*rel=\"(?<" + GROUP_REL + ">" + REGEXP_RESOURCE_TYPE + ")\"" // rel (mandatory)
- + "(;\\s*self=\"(?<" + GROUP_SELF + ">" + REGEXP_LINK_INSTANCE + ")\")?" // self (optional)
- + "(;\\s*category=\"(?<" + GROUP_CATEGORY + ">(;?\\s*(" + REGEXP_LINK_TYPE + "))+)\")?" // category (optional)
- + "(;\\s*(?<" + GROUP_ATTRIBUTES + ">(;?\\s*" + REGEXP_ATTRIBUTE_REPR + ")*))?" // attributes (optional)
- + ";?"; // additional semicolon at the end (not specified, for interoperability)
-
- public static final Pattern PATTERN_CATEGORY = Pattern.compile(REGEXP_CATEGORY);
- public static final Pattern PATTERN_ATTRIBUTES = Pattern.compile(REGEXP_ATTRIBUTES);
- public static final Pattern PATTERN_LINK = Pattern.compile(REGEXP_LINK);
-
- public static final String CATEGORY_HEADER = "category";
- public static final String LINK_HEADER = "link";
- public static final String ATTRIBUTE_HEADER = "x-occi-attribute";
- public static final String LOCATION_HEADER = "location";
-
- private static final Logger LOGGER = LoggerFactory.getLogger(TextParser.class);
-
- /**
- * @see Parser#parseModel(java.lang.String, java.lang.String,
- * com.sun.net.httpserver.Headers)
- */
- @Override
- public Model parseModel(String mediaType, String body, Headers headers) throws ParsingException {
- LOGGER.debug("Parsing model...");
-
- switch (mediaType) {
- case MediaType.TEXT_OCCI:
- return parseModelFromHeaders(headers);
- case MediaType.TEXT_PLAIN:
- return parseModelFromBody(body);
- default:
- throw new ParsingException("Unknown media type '" + mediaType + "'.");
- }
- }
-
- private Model parseModelFromBody(String body) throws ParsingException {
- LOGGER.debug("Reading response body.");
-
- body = body.trim();
- String replaced = Pattern.compile("Category:\\s*", Pattern.CASE_INSENSITIVE).matcher(body).replaceAll("");
-
- String[] lines = replaced.split("[\\r\\n]+");
- return parseModelFromArray(lines);
- }
-
- private Model parseModelFromHeaders(Headers headers) throws ParsingException {
- LOGGER.debug("Reading response headers.");
-
- if (!headers.containsKey(CATEGORY_HEADER)) {
- throw new ParsingException("No header '" + CATEGORY_HEADER + "' among headers.");
- }
-
- String[] categories = headers.getFirst(CATEGORY_HEADER).split(",");
- return parseModelFromArray(categories);
- }
-
- private Model parseModelFromArray(String[] lines) throws ParsingException {
- Model model = new Model();
- Map<String, List<Kind>> kindMapping = new HashMap<>();
- Map<String, List<Mixin>> mixinMapping = new HashMap<>();
-
- for (String line : lines) {
- LOGGER.debug("Matching line '{}' against category pattern.", line);
- Matcher matcher = PATTERN_CATEGORY.matcher(line);
- if (!matcher.find()) {
- throw new ParsingException("Invalid line: " + line);
- }
- String term = matcher.group(GROUP_TERM);
- String scheme = matcher.group(GROUP_SCHEME);
- String categoryClass = matcher.group(GROUP_CLASS);
- String location = matcher.group(GROUP_LOCATION);
- LOGGER.debug("Match: term={}, scheme={}, class={}, title={}, rel={}, location={}, attributes={}, actions={}",
- term, scheme, categoryClass, matcher.group(GROUP_TITLE), matcher.group(GROUP_REL), location, matcher.group(GROUP_ATTRIBUTES), matcher.group(GROUP_ACTIONS));
-
- if (term == null || term.isEmpty()) {
- throw new ParsingException("No term found.");
- }
- if (scheme == null || scheme.isEmpty()) {
- throw new ParsingException("No scheme found.");
- }
- if (categoryClass == null || categoryClass.isEmpty()) {
- throw new ParsingException("No class found.");
- }
-
- switch (categoryClass) {
- case "kind":
- if (location == null || location.isEmpty()) {
- throw new ParsingException("No location found.");
- }
- model = addKind(matcher, kindMapping, model);
- break;
- case "mixin":
- model = addMixin(matcher, mixinMapping, model);
- break;
- case "action":
- model = addAction(matcher, model);
- break;
- default:
- throw new ParsingException("Unknown class type.");
- }
- }
-
- if (!kindMapping.isEmpty()) {
- List<Kind> defaultKinds = createDefaultKinds();
- for (Kind kind : defaultKinds) {
- if (model.containsKind(kind)) {
- continue;
- }
-
- model.addKind(kind);
-
- for (String identifier : kindMapping.keySet()) {
- if (identifier.equals(kind.getIdentifier())) {
- List<Kind> kinds = kindMapping.remove(identifier);
- for (Kind k : kinds) {
- k.setParentKind(kind);
- k.addRelation(kind);
- }
- }
- }
- }
-
- if (!kindMapping.isEmpty()) {
- throw new ParsingException("Unknown kind relations found: " + kindMapping);
- }
- }
-
- if (!mixinMapping.isEmpty()) {
- throw new ParsingException("Unknown mixins relations found: " + mixinMapping);
- }
-
- return model;
- }
-
- private Model addKind(Matcher matcher, Map<String, List<Kind>> mapping, Model model) throws ParsingException {
- LOGGER.debug("Adding kind...");
- String actions = matcher.group(GROUP_ACTIONS);
- String rel = matcher.group(GROUP_REL);
- String term = matcher.group(GROUP_TERM);
-
- Kind kind = createKind(matcher);
- kind = (Kind) connectActions(actions, kind, model);
-
- if (rel != null && !rel.isEmpty()) {
- if (!model.containsKind(rel)) {
- LOGGER.debug("Unexpected relation " + rel + " in kind " + term + ". Storing for later mapping");
- if (mapping.containsKey(rel)) {
- List<Kind> kinds = mapping.get(rel);
- kinds.add(kind);
- } else {
- List<Kind> kinds = new ArrayList<>();
- kinds.add(kind);
- mapping.put(rel, kinds);
- }
- } else {
- Kind k = model.getKind(rel);
- LOGGER.debug("Creating relation between {} and {}.", kind, k);
- kind.setParentKind(k);
- kind.addRelation(k);
- }
- }
-
- String identifier = kind.getIdentifier();
- if (mapping.containsKey(identifier)) {
- List<Kind> kinds = mapping.remove(identifier);
- for (Kind k : kinds) {
- k.setParentKind(kind);
- k.addRelation(kind);
- }
- }
-
- model.addKind(kind);
- return model;
- }
-
- private Model addMixin(Matcher matcher, Map<String, List<Mixin>> mapping, Model model) throws ParsingException {
- LOGGER.debug("Adding mixin...");
- String actions = matcher.group(GROUP_ACTIONS);
- String rel = matcher.group(GROUP_REL);
- String term = matcher.group(GROUP_TERM);
-
- Mixin mixin = createMixin(matcher);
- mixin = (Mixin) connectActions(actions, mixin, model);
-
- if (rel != null && !rel.isEmpty()) {
- if (!model.containsMixin(rel)) {
- LOGGER.debug("Unexpected relation " + rel + " in mixin " + term + ". Storing for later mapping");
- if (mapping.containsKey(rel)) {
- List<Mixin> mixins = mapping.get(rel);
- mixins.add(mixin);
- } else {
- List<Mixin> mixins = new ArrayList<>();
- mixins.add(mixin);
- mapping.put(rel, mixins);
- }
- } else {
- Mixin m = model.getMixin(rel);
- LOGGER.debug("Creating relation between {} and {}.", mixin, m);
- mixin.addRelation(m);
- }
- }
-
- String identifier = mixin.getIdentifier();
- if (mapping.containsKey(identifier)) {
- List<Mixin> mixins = mapping.remove(identifier);
- for (Mixin m : mixins) {
- m.addRelation(mixin);
- }
- }
-
- model.addMixin(mixin);
- return model;
- }
-
- private Model addAction(Matcher matcher, Model model) throws ParsingException {
- LOGGER.debug("Adding action...");
- String term = matcher.group(GROUP_TERM);
- String scheme = matcher.group(GROUP_SCHEME);
- String title = matcher.group(GROUP_TITLE);
- String attributes = matcher.group(GROUP_ATTRIBUTES);
-
- String actionIdentifier = scheme + term;
- if (model.containsAction(actionIdentifier)) {
- Set<Attribute> parsedAttributes = parseAttributes(attributes);
-
- Action action = model.getAction(actionIdentifier);
- action.setTitle(title);
- for (Attribute attribute : parsedAttributes) {
- action.addAttribute(attribute);
- }
- } else {
- Action action = createAction(matcher);
- model.addAction(action);
- }
-
- return model;
- }
-
- private Category connectActions(String actions, Category category, Model model) throws ParsingException {
- LOGGER.debug("Connecting actions...");
- if (actions == null || actions.isEmpty()) {
- return category;
- }
-
- String[] splitedActions = actions.split("\\s+");
- for (String actionIdentifier : splitedActions) {
- LOGGER.debug("Action identifier: {}", actionIdentifier);
- Action action;
- if (model != null && model.containsAction(actionIdentifier)) {
- action = model.getAction(actionIdentifier);
- } else {
- try {
- String[] splitedAction = actionIdentifier.split("#");
- if (splitedAction.length != 2) {
- throw new ParsingException("Invalid action identifier: " + actionIdentifier + ".");
- }
- action = new Action(new URI(splitedAction[0] + "#"), splitedAction[1]);
- } catch (URISyntaxException ex) {
- throw new ParsingException("Invalid category scheme: " + actionIdentifier + ".", ex);
- }
- }
-
- category.addAction(action);
- }
-
- return category;
- }
-
- private Set<Attribute> parseAttributes(String attributes) {
- LOGGER.debug("Parsing attributes: {}", attributes);
- Set<Attribute> attributeSet = new HashSet<>();
- if (attributes == null || attributes.isEmpty()) {
- return attributeSet;
- }
-
- Matcher matcher = PATTERN_ATTRIBUTES.matcher(attributes);
- while (matcher.find()) {
- String attributeString = matcher.group();
- LOGGER.debug("Found attribute represented by string: {}", attributeString);
- Attribute attribute = parseAttribute(attributeString);
- attributeSet.add(attribute);
- }
-
- return attributeSet;
- }
-
- private Attribute parseAttribute(String attributeString) {
- String[] splitedAttribute = attributeString.split("\\{");
- Attribute attribute = new Attribute(splitedAttribute[0]);
- if (splitedAttribute.length == 2) {
- if (splitedAttribute[1].contains("immutable")) {
- attribute.setImmutable(true);
- }
- if (splitedAttribute[1].contains("required")) {
- attribute.setRequired(true);
- }
- }
-
- LOGGER.debug("New attribute: {}", attribute);
- return attribute;
- }
-
- private List<Kind> createDefaultKinds() {
- List<Kind> defaultKinds = new ArrayList<>();
-
- Set<Attribute> attributes = new HashSet<>();
- attributes.add(new Attribute(Entity.ID_ATTRIBUTE_NAME, true, true));
- attributes.add(new Attribute(Entity.TITLE_ATTRIBUTE_NAME, false, false));
- Kind entity = new Kind(Entity.SCHEME_DEFAULT, Entity.TERM_DEFAULT, "Entity", URI.create("/entity/"), attributes);
- defaultKinds.add(entity);
-
- attributes = new HashSet<>();
- attributes.add(new Attribute(Resource.SUMMARY_ATTRIBUTE_NAME, false, false));
- Kind resource = new Kind(Resource.SCHEME_DEFAULT, Resource.TERM_DEFAULT, "Resource", URI.create("/resource/"), attributes);
- resource.setParentKind(entity);
- resource.addRelation(entity);
- defaultKinds.add(resource);
-
- attributes = new HashSet<>();
- attributes.add(new Attribute(Link.SOURCE_ATTRIBUTE_NAME, true, false));
- attributes.add(new Attribute(Link.TARGET_ATTRIBUTE_NAME, true, false));
- Kind link = new Kind(Link.SCHEME_DEFAULT, Link.TERM_DEFAULT, "Link", URI.create("/link/"), attributes);
- link.setParentKind(entity);
- link.addRelation(entity);
- defaultKinds.add(link);
-
- return defaultKinds;
- }
-
- /**
- * @see Parser#parseLocations(java.lang.String, java.lang.String,
- * com.sun.net.httpserver.Headers)
- */
- @Override
- public List<URI> parseLocations(String mediaType, String body, Headers headers) throws ParsingException {
- LOGGER.debug("Parsing location...");
-
- switch (mediaType) {
- case MediaType.TEXT_OCCI:
- return parseLocationsFromHeaders(headers);
- case MediaType.TEXT_URI_LIST:
- case MediaType.TEXT_PLAIN:
- return parseLocationsFromBody(body);
- default:
- throw new ParsingException("Unknown media type '" + mediaType + "'.");
- }
- }
-
- private List<URI> parseLocationsFromHeaders(Headers headers) throws ParsingException {
- LOGGER.debug("Reading response headers.");
-
- if (!headers.containsKey(LOCATION_HEADER)) {
- throw new ParsingException("No header '" + LOCATION_HEADER + "' among headers.");
- }
-
- String[] locations = headers.getFirst(LOCATION_HEADER).split(",");
- return makeURIList(locations);
- }
-
- private List<URI> parseLocationsFromBody(String body) throws ParsingException {
- LOGGER.debug("Reading response body.");
-
- body = body.trim();
- String replaced = Pattern.compile("X-OCCI-Location:\\s*", Pattern.CASE_INSENSITIVE).matcher(body).replaceAll("");
- String[] lines = replaced.split("[\\r\\n]+");
- return makeURIList(lines);
- }
-
- private List<URI> makeURIList(String[] locations) throws ParsingException {
-
- List<URI> locationsURI = new ArrayList<>();
- for (String location : locations) {
- try {
- locationsURI.add(new URI(location));
- } catch (URISyntaxException ex) {
- throw new ParsingException("Invalid location: " + location + ".", ex);
- }
- }
-
- return locationsURI;
- }
-
- /**
- * @see Parser#parseCollection(java.lang.String, java.lang.String,
- * com.sun.net.httpserver.Headers,
- * cz.cesnet.cloud.occi.parser.CollectionType)
- */
- @Override
- public Collection parseCollection(String mediaType, String body, Headers headers, CollectionType collectionType) throws ParsingException {
- LOGGER.debug("Parsing collection...");
-
- switch (mediaType) {
- case MediaType.TEXT_OCCI:
- return parseCollectionFromHeaders(headers, collectionType);
- case MediaType.TEXT_PLAIN:
- return parseCollectionFromBody(body, collectionType);
- default:
- throw new ParsingException("Unknown media type '" + mediaType + "'.");
- }
- }
-
- private Collection parseCollectionFromHeaders(Headers headers, CollectionType collectionType) throws ParsingException {
- LOGGER.debug("Reading headers.");
-
- if (!headers.containsKey(CATEGORY_HEADER)) {
- throw new ParsingException("No '" + CATEGORY_HEADER + "' header.");
- }
-
- List<String> lines = new ArrayList<>();
- lines.addAll(Arrays.asList(headers.getFirst(CATEGORY_HEADER).split(",")));
-
- if (headers.containsKey(ATTRIBUTE_HEADER)) {
- lines.addAll(Arrays.asList(headers.getFirst(ATTRIBUTE_HEADER).split(",")));
- }
-
- if (headers.containsKey(LINK_HEADER)) {
- lines.addAll(Arrays.asList(headers.getFirst(LINK_HEADER).split(",")));
- }
-
- return parseCollectionFromArray(lines.toArray(new String[0]), collectionType);
- }
-
- private Collection parseCollectionFromBody(String body, CollectionType collectionType) throws ParsingException {
- LOGGER.debug("Reading body.");
-
- body = body.trim();
- String replaced = Pattern.compile("Category:\\s*", Pattern.CASE_INSENSITIVE).matcher(body).replaceAll("");
- replaced = Pattern.compile("Link:\\s*", Pattern.CASE_INSENSITIVE).matcher(body).replaceAll("");
- replaced = Pattern.compile("X-OCCI-Attribute:\\s*", Pattern.CASE_INSENSITIVE).matcher(body).replaceAll("");
- String[] lines = replaced.split("[\\r\\n]+");
-
- return parseCollectionFromArray(lines, collectionType);
- }
-
- private Collection parseCollectionFromArray(String[] lines, CollectionType collectionType) throws ParsingException {
- Collection collection = new Collection();
- Kind kind;
- Set<Mixin> mixins = new HashSet<>();
- List<String> rawAttributes = new ArrayList<>();
- Map<String, String> attributesWithValues = null;
-
- switch (collectionType) {
- //expecting resource instance
- case RESOURCE:
- Set<Link> links = new HashSet<>();
- Set<Action> actionLinks = new HashSet<>();
-
- kind = lookForKind(lines[0]);
- lines = Arrays.copyOfRange(lines, 1, lines.length);
-
- for (String line : lines) {
- //looking for mixin lines
- if (lookForMixins(line, mixins)) {
- continue;
- }
- //looking for attribute lines
- if (lookForAttributes(line, rawAttributes)) {
- continue;
- }
- //looking for link lines
- lookForLinks(line, links, actionLinks);
- }
-
- attributesWithValues = parseAttributesWithValues(rawAttributes.toArray(new String[0]));
- if (!attributesWithValues.containsKey(Resource.ID_ATTRIBUTE_NAME)) {
- throw new ParsingException("No id found. Cannot construct a resource.");
- }
-
- Resource resource = null;
- try {
- resource = new Resource(attributesWithValues.get(Entity.ID_ATTRIBUTE_NAME), kind);
-
- attributesWithValues.remove(Entity.ID_ATTRIBUTE_NAME);
- resource.addMixins(mixins);
- resource.addLinks(links);
- resource.addActions(actionLinks);
- resource.addAttributes(attributesWithValues);
- } catch (InvalidAttributeValueException ex) {
- throw new ParsingException("Invalid attribute value found", ex);
- }
- collection.addResource(resource);
-
- break;
- case LINK:
- kind = lookForKind(lines[0]);
- lines = Arrays.copyOfRange(lines, 1, lines.length);
-
- for (String line : lines) {
- //looking for mixin lines
- if (lookForMixins(line, mixins)) {
- continue;
- }
- //looking for attribute lines
- lookForAttributes(line, rawAttributes);
- }
-
- attributesWithValues = parseAttributesWithValues(rawAttributes.toArray(new String[0]));
- if (!attributesWithValues.containsKey(Resource.ID_ATTRIBUTE_NAME)) {
- throw new ParsingException("No id found. Cannot construct a resource.");
- }
-
- Link link = null;
- try {
- link = new Link(attributesWithValues.get(Entity.ID_ATTRIBUTE_NAME), kind);
-
- attributesWithValues.remove(Entity.ID_ATTRIBUTE_NAME);
- link.addMixins(mixins);
- link.addAttributes(attributesWithValues);
- } catch (InvalidAttributeValueException ex) {
- throw new ParsingException("Invalid attribute value found", ex);
- }
- collection.addLink(link);
- break;
- case ACTION:
- ActionInstance actionInstance = lookForActionInstance(lines[0]);
- lines = Arrays.copyOfRange(lines, 1, lines.length);
-
- for (String line : lines) {
- //looking for attribute lines
- lookForAttributes(line, rawAttributes);
- }
-
- attributesWithValues = parseAttributesWithValues(rawAttributes.toArray(new String[0]));
- actionInstance.addAttributes(attributesWithValues);
-
- collection.addAction(actionInstance);
- break;
- default:
- throw new ParsingException("Unknown collection type'" + collectionType + "'.");
- }
-
- return collection;
- }
-
- private Kind lookForKind(String line) throws ParsingException {
- LOGGER.debug("Matching line '{}' against category pattern.", line);
- Matcher matcher = PATTERN_CATEGORY.matcher(line);
-
- if (!matcher.find()) {
- throw new ParsingException("No kind specification found.");
- }
-
- LOGGER.debug("Match: term={}, scheme={}, class={}, title={}, rel={}, location={}, attributes={}, actions={}",
- matcher.group(GROUP_TERM), matcher.group(GROUP_SCHEME),
- matcher.group(GROUP_CLASS), matcher.group(GROUP_TITLE),
- matcher.group(GROUP_REL), matcher.group(GROUP_LOCATION),
- matcher.group(GROUP_ATTRIBUTES), matcher.group(GROUP_ACTIONS));
-
- String actions = matcher.group(GROUP_ACTIONS);
- String categoryClass = matcher.group(GROUP_CLASS);
-
- if (!categoryClass.equals("kind")) {
- throw new ParsingException("No kind specification found.");
- }
-
- Kind kind = createKind(matcher);
- connectActions(actions, kind, null);
-
- return kind;
- }
-
- private boolean lookForMixins(String line, Set<Mixin> mixins) throws ParsingException {
- LOGGER.debug("Matching line '{}' against category pattern.", line);
- Matcher matcher = PATTERN_CATEGORY.matcher(line);
-
- if (matcher.find()) {
- LOGGER.debug("Match: term={}, scheme={}, class={}, title={}, rel={}, location={}, attributes={}, actions={}",
- matcher.group(GROUP_TERM), matcher.group(GROUP_SCHEME),
- matcher.group(GROUP_CLASS), matcher.group(GROUP_TITLE),
- matcher.group(GROUP_REL), matcher.group(GROUP_LOCATION),
- matcher.group(GROUP_ATTRIBUTES), matcher.group(GROUP_ACTIONS));
-
- String categoryClass = matcher.group(GROUP_CLASS);
- String actions = matcher.group(GROUP_ACTIONS);
-
- switch (categoryClass) {
- case "mixin":
- Mixin mixin = createMixin(matcher);
- connectActions(actions, mixin, null);
- mixins.add(mixin);
- break;
- default:
- throw new ParsingException("Unknown category class '" + categoryClass + "'.");
- }
-
- return true;
- }
-
- return false;
- }
-
- private boolean lookForAttributes(String line, List<String> attributes) {
- LOGGER.debug("Matching line '{}' against attribute pattern.", line);
- if (line.matches(REGEXP_ATTRIBUTE_REPR)) {
- attributes.add(line);
- return true;
- }
-
- return false;
- }
-
- private void lookForLinks(String line, Set<Link> links, Set<Action> actionLinks) throws ParsingException {
- LOGGER.debug("Matching line '{}' against link pattern.", line);
- Matcher matcher = PATTERN_LINK.matcher(line);
-
- if (matcher.find()) {
- LOGGER.debug("Match: uri={}, rel={}, self={}, category={}, attributes={}",
- matcher.group(GROUP_URI), matcher.group(GROUP_REL),
- matcher.group(GROUP_SELF), matcher.group(GROUP_CATEGORY),
- matcher.group(GROUP_ATTRIBUTES));
-
- if (matcher.group(GROUP_URI).contains("?action=")) {
- Action action = createAction(matcher.group(GROUP_REL));
- actionLinks.add(action);
- } else {
- Link link = createLink(matcher);
- links.add(link);
- }
- }
- }
-
- private ActionInstance lookForActionInstance(String line) throws ParsingException {
- LOGGER.debug("Matching line '{}' against category pattern.", line);
- Matcher matcher = PATTERN_CATEGORY.matcher(line);
-
- if (!matcher.find()) {
- throw new ParsingException("No action specification found.");
- }
-
- LOGGER.debug("Match: term={}, scheme={}, class={}, title={}, rel={}, location={}, attributes={}, actions={}",
- matcher.group(GROUP_TERM), matcher.group(GROUP_SCHEME),
- matcher.group(GROUP_CLASS), matcher.group(GROUP_TITLE),
- matcher.group(GROUP_REL), matcher.group(GROUP_LOCATION),
- matcher.group(GROUP_ATTRIBUTES), matcher.group(GROUP_ACTIONS));
-
- String categoryClass = matcher.group(GROUP_CLASS);
-
- if (!categoryClass.equals("action")) {
- throw new ParsingException("No action specification found.");
- }
-
- Action action = createAction(matcher);
- ActionInstance actionInstance = new ActionInstance(action);
-
- return actionInstance;
- }
-
- private Map<String, String> parseAttributesWithValues(String[] attributes) throws ParsingException {
- LOGGER.debug("Parsing attributes with values");
- Map<String, String> result = new HashMap<>();
-
- for (String attribute : attributes) {
- String trimmedAttribute = attribute.trim();
- LOGGER.debug("Attribute represented by string: {}", trimmedAttribute);
- String[] parts = trimmedAttribute.split("=", 2);
- if (parts.length != 2) {
- throw new ParsingException("Wrong attribute format.");
- }
-
- String name = parts[0];
- String value = parts[1].replaceAll("\"", "");
- if (value.endsWith(";")) {
- value = value.substring(0, value.length() - 1);
- }
-
- result.put(name, value);
- }
-
- return result;
- }
-
- private Kind createKind(Matcher matcher) throws ParsingException {
- String term = matcher.group(GROUP_TERM);
- String scheme = matcher.group(GROUP_SCHEME);
- String title = matcher.group(GROUP_TITLE);
- String location = matcher.group(GROUP_LOCATION);
- String attributes = matcher.group(GROUP_ATTRIBUTES);
-
- try {
- Set<Attribute> parsedAttributes = parseAttributes(attributes);
- URI locationUri = null;
- if (location != null) {
- locationUri = new URI(location);
- locationUri = new URI(locationUri.getPath());
- }
- Kind kind = new Kind(new URI(scheme), term, title, locationUri, parsedAttributes);
-
- return kind;
- } catch (URISyntaxException ex) {
- throw new ParsingException("Invalid shceme or location.", ex);
- }
- }
-
- private Mixin createMixin(Matcher matcher) throws ParsingException {
- String term = matcher.group(GROUP_TERM);
- String scheme = matcher.group(GROUP_SCHEME);
- String title = matcher.group(GROUP_TITLE);
- String location = matcher.group(GROUP_LOCATION);
- String attributes = matcher.group(GROUP_ATTRIBUTES);
-
- try {
- URI locationUri = null;
- if (location == null || location.isEmpty()) {
- locationUri = new URI("/mixin/" + term);
- locationUri = new URI(locationUri.getPath());
- } else {
- locationUri = new URI(location);
- locationUri = new URI(locationUri.getPath());
- }
- Set<Attribute> parsedAttributes = parseAttributes(attributes);
- Mixin mixin = new Mixin(new URI(scheme), term, title, locationUri, parsedAttributes);
-
- return mixin;
- } catch (URISyntaxException ex) {
- throw new ParsingException("Invalid shceme or location.", ex);
- }
- }
-
- private Link createLink(Matcher matcher) throws ParsingException {
- String uri = matcher.group(GROUP_URI);
- String rel = matcher.group(GROUP_REL);
- String self = matcher.group(GROUP_SELF);
- String category = matcher.group(GROUP_CATEGORY);
- String attributes = matcher.group(GROUP_ATTRIBUTES);
-
- try {
- Kind kind;
- List<Mixin> mixins = new ArrayList<>();
- if (category != null && !category.isEmpty()) {
- String[] categories = category.split(" ");
- String[] kindCategory = categories[0].split("#");
- if (kindCategory.length != 2) {
- throw new ParsingException("Invalid link category: " + category);
- }
- kind = new Kind(new URI(kindCategory[0] + "#"), kindCategory[1]);
-
- if (categories.length > 1) {
- for (int i = 1; i < categories.length; i++) {
- String[] splitedCategory = categories[i].split("#");
- if (splitedCategory.length != 2) {
- throw new ParsingException("Invalid link category: " + category);
- }
- Mixin mixin = new Mixin(new URI(splitedCategory[0] + "#"), splitedCategory[1]);
- mixins.add(mixin);
- }
- }
- } else {
- kind = new Kind(Link.SCHEME_DEFAULT, Link.TERM_DEFAULT);
- }
-
- Link link;
- if (self != null && !self.isEmpty()) {
- String[] splitedSelf = divideUriByLastSegment(self);
- kind.setLocation(new URI(splitedSelf[1]));
- link = new Link(splitedSelf[0], kind);
- } else {
- link = new Link(UUID.randomUUID().toString(), kind);
- }
-
- link.addMixins(mixins);
-
- link.setTarget(uri);
- link.setRelation(rel);
- Map<String, String> attributesWithValues = parseAttributesWithValues(attributes.split(";"));
- for (String name : attributesWithValues.keySet()) {
- link.addAttribute(name, attributesWithValues.get(name));
- // ***********HACK*********
- if (name.equals("occi.core.id")) {
- String value = attributesWithValues.get(name);
- value = value.substring(value.lastIndexOf('/') + 1);
- link.addAttribute(name, value);
- }
- // ***********HACK*********
- }
-
- return link;
- } catch (InvalidAttributeValueException ex) {
- throw new ParsingException("Invalid attribute value found", ex);
- } catch (URISyntaxException ex) {
- throw new ParsingException("Invalid shceme or location.", ex);
- }
- }
-
- private Action createAction(String rel) throws ParsingException {
- if (rel == null || rel.isEmpty()) {
- throw new ParsingException("Link for action is missing 'rel' element.");
- }
-
- String[] splited = rel.split("#");
- if (splited.length != 2) {
- throw new ParsingException("Invalid relation specification: " + rel);
- }
-
- return createAction(splited[0] + "#", splited[1], null, null);
- }
-
- private Action createAction(Matcher matcher) throws ParsingException {
- String term = matcher.group(GROUP_TERM);
- String scheme = matcher.group(GROUP_SCHEME);
- String title = matcher.group(GROUP_TITLE);
- String attributes = matcher.group(GROUP_ATTRIBUTES);
-
- return createAction(scheme, term, title, attributes);
- }
-
- private Action createAction(String scheme, String term, String title, String attributes) throws ParsingException {
- Set<Attribute> parsedAttributes = parseAttributes(attributes);
- Action action = null;
- try {
- action = new Action(new URI(scheme), term, title, parsedAttributes);
- } catch (URISyntaxException ex) {
- throw new ParsingException("Invalid URI.", ex);
- }
- return action;
- }
-
- public static String[] divideUriByLastSegment(String uri) {
- String[] parts = new String[2];
- parts[0] = uri.substring(uri.lastIndexOf('/') + 1);
- parts[1] = uri.substring(0, uri.lastIndexOf('/') + 1);
-
- return parts;
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.renderer;
-
-/**
- * Helper class for rendering specific methods.
- *
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public class TextRenderer {
-
- /**
- * Surrounds given string with prefix '="' and suffix '";'.
- *
- * @param string string to apply prefix and suffix to
- * @return modified string
- */
- public static String surroundString(String string) {
- return surroundString(string, "=\"", "\";");
- }
-
- /**
- * Surround given string with given prefix and suffix.
- *
- * @param string string to apply prefix and suffix to
- * @param prefix prefix to apply
- * @param suffix suffix to apply
- * @return modified string
- */
- public static String surroundString(String string, String prefix, String suffix) {
- StringBuilder sb = new StringBuilder(string);
- sb.append(suffix);
- sb.insert(0, prefix);
-
- return sb.toString();
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.type;
-
-/**
- * @author Michal Kimle <kimle.michal@gmail.com>
- */
-public interface Identifiable {
-
- /**
- * Returns identifier by which the object is recognized.
- *
- * @return object's identifier
- */
- public String getIdentifier();
-}
+++ /dev/null
-package cz.cesnet.cloud.occi;
-
-import cz.cesnet.cloud.occi.core.Action;
-import cz.cesnet.cloud.occi.core.ActionInstance;
-import cz.cesnet.cloud.occi.core.Kind;
-import cz.cesnet.cloud.occi.core.Link;
-import cz.cesnet.cloud.occi.core.Resource;
-import java.net.URI;
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
-
-public class CollectionTest {
-
- public CollectionTest() {
- }
-
- @Test
- public void testSetModel() throws Exception {
- Kind kind = new Kind(new URI("http://dummy.kind"), "term");
- Resource resource = new Resource("resource_id", kind);
- Link link = new Link("link_id", kind);
- ActionInstance ai = new ActionInstance(new Action(new URI("http://dummy.action"), "term"));
-
- Collection collection = new Collection();
- collection.addAction(ai);
- collection.addLink(link);
- collection.addResource(resource);
-
- Model model = new Model();
- model.addKind(kind);
-
- collection.setModel(model);
-
- assertEquals(model, resource.getModel());
- assertEquals(model, link.getModel());
- assertEquals(model, ai.getModel());
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi;
-
-import cz.cesnet.cloud.occi.core.Action;
-import cz.cesnet.cloud.occi.core.ActionInstance;
-import cz.cesnet.cloud.occi.core.Attribute;
-import cz.cesnet.cloud.occi.core.Entity;
-import cz.cesnet.cloud.occi.core.Kind;
-import cz.cesnet.cloud.occi.core.Link;
-import cz.cesnet.cloud.occi.core.Mixin;
-import cz.cesnet.cloud.occi.core.Resource;
-import cz.cesnet.cloud.occi.exception.InvalidAttributeValueException;
-import cz.cesnet.cloud.occi.infrastructure.Compute;
-import cz.cesnet.cloud.occi.infrastructure.NetworkInterface;
-import cz.cesnet.cloud.occi.infrastructure.StorageLink;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-public class DataGenerator {
-
- public static List<Kind> getMinimalKind() throws URISyntaxException {
- List<Kind> kinds = new ArrayList<>();
- Kind kind = new Kind(new URI("http://schemas.ogf.org/occi/core#"), "entity");
- kind.setLocation(new URI("/entity/"));
- kinds.add(kind);
-
- return kinds;
- }
-
- public static List<Kind> getFiveKinds() throws URISyntaxException {
- Set<Attribute> attributes = new HashSet<>();
- List<Kind> kinds = new ArrayList<>();
-
- Attribute a = new Attribute("occi.core.id");
- attributes.add(a);
- a = new Attribute("occi.core.title");
- attributes.add(a);
- Kind entity = new Kind(new URI("http://schemas.ogf.org/occi/core#"), "entity", "Entity", new URI("/entity/"), attributes);
- kinds.add(entity);
-
- attributes.clear();
- a = new Attribute("occi.core.summary");
- attributes.add(a);
- Kind resource = new Kind(new URI("http://schemas.ogf.org/occi/core#"), "resource", "Resource", new URI("/resource/"), attributes);
- resource.addRelation(entity);
- resource.setParentKind(entity);
- kinds.add(resource);
-
- attributes.clear();
- a = new Attribute("occi.core.target");
- attributes.add(a);
- a = new Attribute("occi.core.source");
- attributes.add(a);
- Kind link = new Kind(new URI("http://schemas.ogf.org/occi/core#"), "link", "Link", new URI("/link/"), attributes);
- link.addRelation(entity);
- link.setParentKind(entity);
- kinds.add(link);
-
- attributes.clear();
- a = new Attribute("occi.compute.architecture", false, true);
- attributes.add(a);
- a = new Attribute("occi.compute.cores");
- attributes.add(a);
- a = new Attribute("occi.compute.hostname");
- attributes.add(a);
- a = new Attribute("occi.compute.speed");
- attributes.add(a);
- a = new Attribute("occi.compute.memory");
- attributes.add(a);
- a = new Attribute("occi.compute.state");
- attributes.add(a);
- Kind k = new Kind(new URI("http://schemas.ogf.org/occi/infrastructure#"), "compute", "Compute Resource", new URI("/compute/"), attributes);
- Action ac = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/compute/action#"), "start");
- k.addAction(ac);
- ac = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/compute/action#"), "stop");
- k.addAction(ac);
- ac = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/compute/action#"), "restart");
- k.addAction(ac);
- ac = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/compute/action#"), "suspend");
- k.addAction(ac);
- k.addRelation(resource);
- k.setParentKind(resource);
- kinds.add(k);
-
- attributes.clear();
- a = new Attribute("occi.storagelink.deviceid", true, false);
- attributes.add(a);
- a = new Attribute("occi.storagelink.mountpoint");
- attributes.add(a);
- a = new Attribute("occi.storagelink.state", true, true);
- attributes.add(a);
- k = new Kind(new URI("http://schemas.ogf.org/occi/infrastructure#"), "storagelink", "Storage Link", new URI("/storagelink/"), attributes);
- k.addRelation(link);
- k.setParentKind(link);
- kinds.add(k);
-
- return kinds;
- }
-
- public static List<Mixin> getMinimalMixin() throws URISyntaxException {
- List<Mixin> mixins = new ArrayList<>();
- Mixin ostpl = new Mixin(new URI("http://schemas.ogf.org/occi/infrastructure#"), "os_tpl");
- ostpl.setLocation(new URI("/mixins/os_tpl/"));
- mixins.add(ostpl);
-
- return mixins;
- }
-
- public static List<Mixin> getFiveMixins() throws URISyntaxException {
- Set<Attribute> attributes = new HashSet<>();
- List<Mixin> mixins = new ArrayList<>();
-
- Mixin ostpl = new Mixin(new URI("http://schemas.ogf.org/occi/infrastructure#"), "os_tpl", "Operating System Template", new URI("/mixins/os_tpl/"), attributes);
- mixins.add(ostpl);
-
- attributes.clear();
- Attribute a = new Attribute("occi.network.address", true, false);
- attributes.add(a);
- a = new Attribute("occi.network.gateway");
- attributes.add(a);
- a = new Attribute("occi.network.allocation");
- attributes.add(a);
- a = new Attribute("occi.network.state");
- attributes.add(a);
- Mixin m = new Mixin(new URI("http://schemas.ogf.org/occi/infrastructure/network#"), "ipnetwork", "IP Network Mixin", new URI("/mixins/ipnetwork/"), attributes);
- mixins.add(m);
-
- attributes.clear();
- Mixin resourcetpl = new Mixin(new URI("http://schemas.ogf.org/occi/infrastructure#"), "resource_tpl", "Resource Template", new URI("/mixins/resource_tpl/"), attributes);
- mixins.add(resourcetpl);
-
- attributes.clear();
- a = new Attribute("occi.compute.architecture");
- attributes.add(a);
- a = new Attribute("occi.compute.cores", true, true);
- attributes.add(a);
- a = new Attribute("occi.compute.speed");
- attributes.add(a);
- a = new Attribute("occi.compute.memory", false, true);
- attributes.add(a);
- m = new Mixin(new URI("https://occi.localhost/occi/infrastructure/resource_tpl#"), "larger", "Larger Instance - 4 cores and 10 GB of RAM", new URI("/mixins/larger/"), attributes);
- m.addRelation(resourcetpl);
- mixins.add(m);
-
- attributes.clear();
- m = new Mixin(new URI("https://occi.localhost/occi/infrastructure/os_tpl#"), "debianvm", "debianvm", new URI("/mixins/debianvm/"), attributes);
- m.addRelation(ostpl);
- mixins.add(m);
-
- return mixins;
- }
-
- public static List<Action> getMinimalAction() throws URISyntaxException {
- List<Action> actions = new ArrayList<>();
- Action ac = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/network/action#"), "up");
- actions.add(ac);
-
- return actions;
- }
-
- public static List<Action> getFiveActions() throws URISyntaxException {
- List<Action> actions = new ArrayList<>();
- Set<Attribute> attributes = new HashSet<>();
-
- attributes.clear();
- Attribute a = new Attribute("method");
- attributes.add(a);
- Action ac = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/compute/action#"), "restart", "Restart Compute instance", attributes);
- actions.add(ac);
-
- attributes.clear();
- a = new Attribute("method");
- attributes.add(a);
- ac = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/compute/action#"), "suspend", "Suspend Compute instance", attributes);
- actions.add(ac);
-
- ac = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/network/action#"), "up", "Activate network", null);
- actions.add(ac);
-
- ac = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/network/action#"), "down", "Deactivate network", null);
- actions.add(ac);
-
- ac = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/storage/action#"), "backup", "Backup Storage", null);
- actions.add(ac);
-
- return actions;
- }
-
- public static List<URI> getLocations() throws URISyntaxException {
- List<URI> locations = new ArrayList<>();
- locations.add(new URI("http://rocci-server-1-1-x.herokuapp.com:80/compute/87f3bfc3-42d4-4474-b45c-757e55e093e9"));
- locations.add(new URI("http://rocci-server-1-1-x.herokuapp.com:80/compute/17679ebd-975f-4ea0-b42b-47405178c360"));
- locations.add(new URI("http://rocci-server-1-1-x.herokuapp.com:80/compute/509afbd3-abff-427c-9b25-7913d17e5102"));
-
- return locations;
- }
-
- public static Resource getResource() throws InvalidAttributeValueException, URISyntaxException {
- Kind k = new Kind(new URI("http://schemas.ogf.org/occi/infrastructure#"), "compute", "compute resource", new URI("/compute/"), null);
- Resource r = new Resource("87f3bfc3-42d4-4474-b45c-757e55e093e9", k);
- r.setTitle("compute1");
- r.addAttribute(Compute.ARCHITECTURE_ATTRIBUTE_NAME, "x86");
- r.addAttribute(Compute.HOSTNAME_ATTRIBUTE_NAME, "compute1.example.org");
- r.addAttribute(Compute.MEMORY_ATTRIBUTE_NAME, "1.7");
- r.addAttribute(Compute.SPEED_ATTRIBUTE_NAME, "1.0");
- r.addAttribute(Compute.STATE_ATTRIBUTE_NAME, "active");
-
- List<Mixin> mixins = getFiveMixins();
- for (Mixin mixin : mixins) {
- r.addMixin(mixin);
- }
-
- List<Link> links = getLinks();
- for (Link link : links) {
- link.setSource(r);
- r.addLink(link);
- }
-
- List<Action> actions = getActions();
- for (Action action : actions) {
- r.addAction(action);
- }
-
- return r;
- }
-
- public static List<Action> getActions() throws URISyntaxException {
- List<Action> actions = new ArrayList<>();
- actions.add(new Action(new URI("http://schemas.ogf.org/occi/infrastructure/compute/action#"), "start"));
- actions.add(new Action(new URI("http://schemas.ogf.org/occi/infrastructure/compute/action#"), "stop"));
-
- return actions;
- }
-
- public static List<Link> getLinks() throws URISyntaxException, InvalidAttributeValueException {
- List<Link> links = new ArrayList<>();
-
- Kind k = new Kind(new URI("http://schemas.ogf.org/occi/infrastructure#"), "networkinterface", null, new URI("/link/networkinterface/"), null);
- Link l = new Link("456", k);
- l.addAttribute(NetworkInterface.INTERFACE_ATTRIBUTE_NAME, "eth0");
- l.addAttribute(NetworkInterface.MAC_ATTRIBUTE_NAME, "00:11:22:33:44:55");
- l.addAttribute(NetworkInterface.STATE_ATTRIBUTE_NAME, "active");
- l.setTarget("/network/123");
- l.setRelation("http://schemas.ogf.org/occi/infrastructure#network");
- links.add(l);
-
- k = new Kind(new URI("http://schemas.ogf.org/occi/infrastructure#"), "storagelink", null, new URI("/link/storagelink/"), null);
- l = new Link("789", k);
- l.addAttribute(StorageLink.DEVICE_ID_ATTRIBUTE_NAME, "1234qwerty");
- l.addAttribute(StorageLink.MOUNTPOINT_ATTRIBUTE_NAME, "/mnt/somewhere/");
- l.addAttribute(StorageLink.STATE_ATTRIBUTE_NAME, "active");
- l.setTarget("/storage/852");
- l.setRelation("http://schemas.ogf.org/occi/infrastructure#storage");
-
- Mixin m = new Mixin(new URI("http://opennebula.org/occi/infrastructure#"), "storagelink");
- l.addMixin(m);
-
- links.add(l);
-
- return links;
- }
-
- public static Link getLink() throws InvalidAttributeValueException, URISyntaxException {
- Kind k = new Kind(new URI("http://schemas.ogf.org/occi/infrastructure#"), "networkinterface", null, null, null);
- Link l = new Link("87f3bfc3-42d4-4474-b45c-757e55e093e9", k);
- l.addAttribute(NetworkInterface.INTERFACE_ATTRIBUTE_NAME, "eth0");
- l.addAttribute(NetworkInterface.MAC_ATTRIBUTE_NAME, "00:11:22:33:44:55");
- l.addAttribute(NetworkInterface.STATE_ATTRIBUTE_NAME, "active");
- l.setSource("/vms/foo/vm1");
- l.setTarget("/network/123");
-
- List<Mixin> mixins = getFiveMixins();
- for (Mixin mixin : mixins) {
- l.addMixin(mixin);
- }
-
- return l;
- }
-
- public static ActionInstance getAction() throws InvalidAttributeValueException, URISyntaxException {
- Action a = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/storage/action#"), "backup", "Backup Storage", null);
- ActionInstance ai = new ActionInstance(a);
- ai.addAttribute(new Attribute(Entity.ID_ATTRIBUTE_NAME), "87f3bfc3-42d4-4474-b45c-757e55e093e9");
- ai.addAttribute(new Attribute(NetworkInterface.INTERFACE_ATTRIBUTE_NAME), "eth0");
- ai.addAttribute(new Attribute(NetworkInterface.MAC_ATTRIBUTE_NAME), "00:11:22:33:44:55");
- ai.addAttribute(new Attribute(NetworkInterface.STATE_ATTRIBUTE_NAME), "active");
- ai.addAttribute(new Attribute(Link.SOURCE_ATTRIBUTE_NAME), "/vms/foo/vm1");
- ai.addAttribute(new Attribute(Link.TARGET_ATTRIBUTE_NAME), "/network/123");
-
- return ai;
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi;
-
-import cz.cesnet.cloud.occi.core.Action;
-import cz.cesnet.cloud.occi.core.Kind;
-import cz.cesnet.cloud.occi.core.Mixin;
-import cz.cesnet.cloud.occi.exception.AmbiguousIdentifierException;
-import cz.cesnet.cloud.occi.parser.CollectionType;
-import java.net.URI;
-import static java.util.Collections.list;
-import java.util.HashSet;
-import java.util.Set;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-import org.junit.Before;
-import org.junit.Test;
-
-public class ModelTest {
-
- private Model model;
-
- public ModelTest() {
- }
-
- @Before
- public void setUp() throws Exception {
- model = new Model();
-
- for (Kind kind : DataGenerator.getFiveKinds()) {
- model.addKind(kind);
- }
-
- for (Mixin mixin : DataGenerator.getFiveMixins()) {
- model.addMixin(mixin);
- }
-
- for (Action action : DataGenerator.getFiveActions()) {
- model.addAction(action);
- }
- }
-
- @Test
- public void testFindKindWithURI() throws Exception {
- assertEquals(DataGenerator.getFiveKinds().get(2), model.findKind(URI.create("http://schemas.ogf.org/occi/core#link")));
- assertNull(model.findKind(URI.create("http://nonexisting.abc.org/icco/core#link")));
- }
-
- @Test
- public void testFindKindWithString() throws Exception {
- assertEquals(DataGenerator.getFiveKinds().get(2), model.findKind("link"));
- assertNull(model.findKind("nonexisting"));
- }
-
- @Test
- public void testInvalidFindKindWithString() throws Exception {
- Kind link = new Kind(new URI("http://different.uri.same/term/core#"), "link", "Link", new URI("/link/"), null);
- model.addKind(link);
-
- try {
- model.findKind("link");
- fail();
- } catch (AmbiguousIdentifierException ex) {
- //cool
- }
- }
-
- @Test
- public void testFindRelatedKindsWithURI() throws Exception {
- Set<Kind> set = new HashSet<>();
- set.add(DataGenerator.getFiveKinds().get(1));
- set.add(DataGenerator.getFiveKinds().get(2));
-
- assertEquals(set, new HashSet(model.findRelatedKinds(URI.create("http://schemas.ogf.org/occi/core#entity"))));
- }
-
- @Test
- public void testFindRelatedKindsWithString() throws Exception {
- Set<Kind> set = new HashSet<>();
- set.add(DataGenerator.getFiveKinds().get(1));
- set.add(DataGenerator.getFiveKinds().get(2));
-
- assertEquals(set, new HashSet(model.findRelatedKinds("entity")));
- }
-
- @Test
- public void testInvalidFindRelatedKindsWithString() throws Exception {
- Kind kind = new Kind(new URI("http://different.uri.same/term/core#"), "entity", "Entity", new URI("/entity/"), null);
- model.addKind(kind);
-
- try {
- model.findRelatedKinds("entity");
- fail();
- } catch (AmbiguousIdentifierException ex) {
- //cool
- }
- }
-
- @Test
- public void testFindKindTypeWithKind() throws Exception {
- assertNull(model.findKindType(DataGenerator.getFiveKinds().get(0)));
- assertEquals(CollectionType.RESOURCE, model.findKindType(DataGenerator.getFiveKinds().get(1)));
- assertEquals(CollectionType.LINK, model.findKindType(DataGenerator.getFiveKinds().get(2)));
- assertEquals(CollectionType.RESOURCE, model.findKindType(DataGenerator.getFiveKinds().get(3)));
- assertEquals(CollectionType.LINK, model.findKindType(DataGenerator.getFiveKinds().get(4)));
- }
-
- @Test
- public void testFindKindTypeWithString() throws Exception {
- assertNull(model.findKindType("/entity/"));
- assertEquals(CollectionType.RESOURCE, model.findKindType("/resource/"));
- assertEquals(CollectionType.LINK, model.findKindType("/link/"));
- assertEquals(CollectionType.RESOURCE, model.findKindType("/compute/"));
- assertEquals(CollectionType.LINK, model.findKindType("/storagelink/"));
- }
-
- @Test
- public void testFindMixinWithURI() throws Exception {
- assertEquals(DataGenerator.getFiveMixins().get(2), model.findMixin(URI.create("http://schemas.ogf.org/occi/infrastructure#resource_tpl")));
- assertNull(model.findMixin(URI.create("http://nonexisting.abc.org/icco/core#mixin")));
- }
-
- @Test
- public void testFindMixinWithString() throws Exception {
- assertEquals(DataGenerator.getFiveMixins().get(2), model.findMixin("resource_tpl"));
- assertNull(model.findMixin("nonexisting"));
- }
-
- @Test
- public void testInvalidFindMixinWithString() throws Exception {
- Mixin resourcetpl = new Mixin(new URI("http://different.uri.same/term/core#"), "resource_tpl", "Resource Template", new URI("/mixins/resource_tpl/"), null);
- model.addMixin(resourcetpl);
-
- try {
- model.findMixin("resource_tpl");
- fail();
- } catch (AmbiguousIdentifierException ex) {
- //cool
- }
- }
-
- @Test
- public void testFindMixinWithStringAndString() throws Exception {
- assertEquals(DataGenerator.getFiveMixins().get(3), model.findMixin("larger", "resource_tpl"));
- assertNull(model.findMixin("larger", "nonexisting"));
- assertNull(model.findMixin("nonexisting", "resource_tpl"));
- }
-
- @Test
- public void testInvalidFindMixinWithStringAndString() throws Exception {
- try {
- Mixin m = new Mixin(new URI("http://different.uri.same/term/resource_tpl#"), "larger", "Larger Instance - 4 cores and 10 GB of RAM", new URI("/mixins/larger/"), null);
- m.addRelation(model.findMixin("resource_tpl"));
- model.addMixin(m);
- model.findMixin("larger", "resource_tpl");
- fail();
- } catch (AmbiguousIdentifierException ex) {
- //cool
- }
-
- try {
- setUp();
- Mixin resourcetpl = new Mixin(new URI("http://different.uri.same/term/core#"), "resource_tpl", "Resource Template", new URI("/mixins/resource_tpl/"), null);
- model.addMixin(resourcetpl);
- model.findMixin("larger", "resource_tpl");
- fail();
- } catch (AmbiguousIdentifierException ex) {
- //cool
- }
- }
-
- @Test
- public void testFindMixinWithStringAndURI() throws Exception {
- assertEquals(DataGenerator.getFiveMixins().get(3), model.findMixin("larger", URI.create("http://schemas.ogf.org/occi/infrastructure#resource_tpl")));
- assertNull(model.findMixin("larger", URI.create("http://nonexisting.abc.org/icco/core#mixin")));
- assertNull(model.findMixin("nonexisting", URI.create("http://schemas.ogf.org/occi/infrastructure#resource_tpl")));
- }
-
- @Test
- public void testInvalidFindMixinWithStringAndURI() throws Exception {
- try {
- Mixin m = new Mixin(new URI("http://different.uri.same/term/resource_tpl#"), "larger", "Larger Instance - 4 cores and 10 GB of RAM", new URI("/mixins/larger/"), null);
- m.addRelation(model.findMixin("resource_tpl"));
- model.addMixin(m);
- model.findMixin("larger", "resource_tpl");
- fail();
- } catch (AmbiguousIdentifierException ex) {
- //cool
- }
- }
-
- @Test
- public void testFindRelatedMixinsWithURI() throws Exception {
- Set<Mixin> set = new HashSet<>();
- set.add(DataGenerator.getFiveMixins().get(4));
- Mixin m = new Mixin(new URI("https://occi.localhost/occi/infrastructure/os_tpl#"), "archlinux", "archlinux", new URI("/mixins/archlinux/"), null);
- m.addRelation(model.findMixin("os_tpl"));
- model.addMixin(m);
- set.add(m);
-
- assertEquals(set, new HashSet(model.findRelatedMixins(URI.create("http://schemas.ogf.org/occi/infrastructure#os_tpl"))));
- }
-
- @Test
- public void testFindRelatedMixinsWithString() throws Exception {
- Set<Mixin> set = new HashSet<>();
- set.add(DataGenerator.getFiveMixins().get(4));
- Mixin m = new Mixin(new URI("https://occi.localhost/occi/infrastructure/os_tpl#"), "archlinux", "archlinux", new URI("/mixins/archlinux/"), null);
- m.addRelation(model.findMixin("os_tpl"));
- model.addMixin(m);
- set.add(m);
-
- assertEquals(set, new HashSet(model.findRelatedMixins("os_tpl")));
- }
-
- @Test
- public void testInvalidFindRelatedMixinsWithString() throws Exception {
- Mixin mixin = new Mixin(new URI("http://different.uri.same/term/core#"), "os_tpl", "Operating System Template", new URI("/mixins/os_tpl/"), null);
- model.addMixin(mixin);
-
- try {
- model.findRelatedMixins("os_tpl");
- fail();
- } catch (AmbiguousIdentifierException ex) {
- //cool
- }
- }
-
- @Test
- public void testFindActionWithString() throws Exception {
- assertEquals(DataGenerator.getFiveActions().get(2), model.findAction("up"));
- assertNull(model.findAction("nonexisting"));
- }
-
- @Test
- public void testInvalidFindActionWithString() throws Exception {
- Action ac = new Action(new URI("http://different.uri.same/term/network/action#"), "up", "Activate network", null);
- model.addAction(ac);
-
- try {
- model.findAction("up");
- fail();
- } catch (AmbiguousIdentifierException ex) {
- //cool
- }
- }
-
- @Test
- public void testFindActionWithURI() throws Exception {
- assertEquals(DataGenerator.getFiveActions().get(2), model.findAction(URI.create("http://schemas.ogf.org/occi/infrastructure/network/action#up")));
- assertNull(model.findAction(URI.create("http://nonexisting.abc.org/icco/core#action")));
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-
-public class TestHelper {
-
- public static String readFile(String filename) throws IOException {
- File f = new File(filename);
- String fileContent = new String(Files.readAllBytes(f.toPath()));
- return fileContent;
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.collection;
-
-import com.sun.net.httpserver.Headers;
-import cz.cesnet.cloud.occi.core.Attribute;
-import java.util.HashMap;
-import java.util.Map;
-import org.junit.Test;
-import static org.junit.Assert.*;
-import org.junit.Before;
-
-public class AttributeMapCoverTest {
-
- private final AttributeMapCover attrMap = new AttributeMapCover();
-
- @Before
- public void setUp() {
- attrMap.add(new Attribute("occi.core.id"), "87f3bfc3-42d4-4474-b45c-757e55e093e9");
- attrMap.add(new Attribute("occi.core.title"), "compute1");
- attrMap.add(new Attribute("occi.compute.architecture"), "x86");
- attrMap.add(new Attribute("occi.compute.hostname"), "compute1.example.org");
- attrMap.add(new Attribute("occi.compute.memory"), "1.7");
- attrMap.add(new Attribute("occi.compute.speed"), "1.0");
- }
-
- @Test
- public void testAdd() {
- AttributeMapCover instance = new AttributeMapCover();
- assertEquals(0, instance.size());
- instance.add(new Attribute("name"), "value");
- assertEquals(1, instance.size());
- assertTrue(instance.containsAttribute("name"));
- }
-
- @Test
- public void testInvalidAdd() {
- AttributeMapCover instance = new AttributeMapCover();
- try {
- instance.add(null, "aaa");
- fail();
- } catch (NullPointerException ex) {
- //cool
- }
-
- try {
- instance.add(new Attribute("aaa"), null);
- fail();
- } catch (NullPointerException ex) {
- //cool
- }
- }
-
- @Test
- public void testRemoveWithAttribute() {
- assertEquals(6, attrMap.size());
- attrMap.remove(new Attribute("occi.core.id"));
- assertEquals(5, attrMap.size());
- assertFalse(attrMap.containsAttribute("occi.core.id"));
- }
-
- @Test
- public void testRemoveWithString() {
- assertEquals(6, attrMap.size());
- attrMap.remove("occi.core.id");
- assertEquals(5, attrMap.size());
- assertFalse(attrMap.containsAttribute("occi.core.id"));
- }
-
- @Test
- public void testContainsAttributeWithAttribute() {
- assertTrue(attrMap.containsAttribute(new Attribute("occi.core.id")));
- assertTrue(attrMap.containsAttribute(new Attribute("occi.compute.architecture")));
- assertFalse(attrMap.containsAttribute(new Attribute("nonexisting_attribute")));
- }
-
- @Test
- public void testContainsAttributeWithString() {
- assertTrue(attrMap.containsAttribute("occi.core.id"));
- assertTrue(attrMap.containsAttribute("occi.compute.architecture"));
- assertFalse(attrMap.containsAttribute("nonexisting_attribute"));
- }
-
- @Test
- public void testGetValueWithAttribute() {
- assertEquals("compute1", attrMap.getValue(new Attribute("occi.core.title")));
- assertEquals("x86", attrMap.getValue(new Attribute("occi.compute.architecture")));
- assertNull(attrMap.getValue(new Attribute("nonexisting_attribute")));
- }
-
- @Test
- public void testGetValueWithString() {
- assertEquals("compute1", attrMap.getValue("occi.core.title"));
- assertEquals("x86", attrMap.getValue("occi.compute.architecture"));
- assertNull(attrMap.getValue("nonexisting_attribute"));
- }
-
- @Test
- public void testGetAttributes() {
- Map<Attribute, String> map = new HashMap<>();
- map.put(new Attribute("occi.core.id"), "87f3bfc3-42d4-4474-b45c-757e55e093e9");
- map.put(new Attribute("occi.core.title"), "compute1");
- map.put(new Attribute("occi.compute.architecture"), "x86");
- map.put(new Attribute("occi.compute.hostname"), "compute1.example.org");
- map.put(new Attribute("occi.compute.memory"), "1.7");
- map.put(new Attribute("occi.compute.speed"), "1.0");
-
- assertEquals(map, attrMap.getAttributes());
- }
-
- @Test
- public void testClear() {
- assertEquals(6, attrMap.size());
- attrMap.clear();
- assertEquals(0, attrMap.size());
- }
-
- @Test
- public void testToOneLineText() {
- String line = "occi.compute.architecture=\"x86\";occi.compute.hostname=\"compute1.example.org\";occi.compute.memory=1.7;occi.compute.speed=1.0;occi.core.id=\"87f3bfc3-42d4-4474-b45c-757e55e093e9\";occi.core.title=\"compute1\";";
-
- assertEquals(line, attrMap.toOneLineText());
- }
-
- @Test
- public void testToPrefixText() {
- String line = "X-OCCI-Attribute: occi.compute.architecture=\"x86\"\nX-OCCI-Attribute: occi.compute.hostname=\"compute1.example.org\"\nX-OCCI-Attribute: occi.compute.memory=1.7\nX-OCCI-Attribute: occi.compute.speed=1.0\nX-OCCI-Attribute: occi.core.id=\"87f3bfc3-42d4-4474-b45c-757e55e093e9\"\nX-OCCI-Attribute: occi.core.title=\"compute1\"";
-
- assertEquals(line, attrMap.toPrefixText());
- }
-
- @Test
- public void testToHeaders() {
- Headers headers = new Headers();
- headers.add("X-OCCI-Attribute", "occi.compute.architecture=\"x86\"");
- headers.add("X-OCCI-Attribute", "occi.compute.hostname=\"compute1.example.org\"");
- headers.add("X-OCCI-Attribute", "occi.compute.memory=1.7");
- headers.add("X-OCCI-Attribute", "occi.compute.speed=1.0");
- headers.add("X-OCCI-Attribute", "occi.core.id=\"87f3bfc3-42d4-4474-b45c-757e55e093e9\"");
- headers.add("X-OCCI-Attribute", "occi.core.title=\"compute1\"");
-
- assertEquals(headers, attrMap.toHeaders());
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.collection;
-
-import cz.cesnet.cloud.occi.core.Mixin;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import org.junit.Test;
-import static org.junit.Assert.*;
-import org.junit.Before;
-
-public class SetCoverTest {
-
- private SetCover<Mixin> set = new SetCover<>();
-
- @Before
- public void setUp() throws Exception {
- set.add(new Mixin(new URI("http://dummy.mixin1/"), "term1"));
- set.add(new Mixin(new URI("http://dummy.mixin2/"), "term2"));
- set.add(new Mixin(new URI("http://dummy.mixin3/"), "term3"));
- }
-
- @Test
- public void testContainsWithGenericType() throws Exception {
- assertTrue(set.contains(new Mixin(new URI("http://dummy.mixin1/"), "term1")));
- assertFalse(set.contains(new Mixin(new URI("http://nonexisting.mixin/"), "aaa")));
- }
-
- @Test
- public void testContainsWithString() {
- assertTrue(set.contains("http://dummy.mixin1/term1"));
- assertFalse(set.contains("http://nonexisting.mixin/aaa"));
- }
-
- @Test
- public void testAdd() throws Exception {
- SetCover<Mixin> set = new SetCover<>();
- assertEquals(0, set.size());
- set.add(new Mixin(new URI("http://dummy.mixin1/"), "term1"));
- assertEquals(1, set.size());
- assertTrue(set.contains("http://dummy.mixin1/term1"));
- }
-
- @Test
- public void testInvalidAdd() {
- try {
- set.add(null);
- fail();
- } catch (NullPointerException ex) {
- //cool
- }
- }
-
- @Test
- public void testAddAll() throws Exception {
- List<Mixin> list = new ArrayList<>();
- list.add(new Mixin(new URI("http://dummy.mixin1/"), "term1"));
- list.add(new Mixin(new URI("http://dummy.mixin2/"), "term2"));
- list.add(new Mixin(new URI("http://dummy.mixin3/"), "term3"));
-
- SetCover<Mixin> set = new SetCover<>();
- assertEquals(0, set.size());
- set.addAll(list);
- assertEquals(3, set.size());
- }
-
- @Test
- public void testInvalidAddAll() throws Exception {
- List<Mixin> list = new ArrayList<>();
- list.add(new Mixin(new URI("http://dummy.mixin1/"), "term1"));
- list.add(null);
- list.add(new Mixin(new URI("http://dummy.mixin3/"), "term3"));
-
- try {
- set.addAll(list);
- fail();
- } catch (NullPointerException ex) {
- //cool
- }
- }
-
- @Test
- public void testGet() throws Exception {
- assertEquals(new Mixin(new URI("http://dummy.mixin1/"), "term1"), set.get("http://dummy.mixin1/term1"));
- assertNull(set.get("nonexisting_element"));
- }
-
- @Test
- public void testRemove() throws Exception {
- assertEquals(3, set.size());
- set.remove(new Mixin(new URI("http://dummy.mixin1/"), "term1"));
- assertEquals(2, set.size());
- assertFalse(set.contains("http://dummy.mixin1/term1"));
- }
-
- @Test
- public void testInvalidRemove() {
- try {
- set.remove(null);
- fail();
- } catch (NullPointerException ex) {
- //cool
- }
- }
-
- @Test
- public void testClear() {
- assertEquals(3, set.size());
- set.clear();
- assertEquals(0, set.size());
- }
-
- @Test
- public void testGetSet() throws Exception {
- Set<Mixin> expected = new HashSet<>();
- expected.add(new Mixin(new URI("http://dummy.mixin1/"), "term1"));
- expected.add(new Mixin(new URI("http://dummy.mixin2/"), "term2"));
- expected.add(new Mixin(new URI("http://dummy.mixin3/"), "term3"));
-
- assertEquals(expected, set.getSet());
- }
-
- @Test
- public void testSize() throws Exception {
- assertEquals(3, set.size());
- set.add(new Mixin(new URI("http://dummy.mixin4/"), "term4"));
- assertEquals(4, set.size());
- set.remove(new Mixin(new URI("http://dummy.mixin2/"), "term2"));
- assertEquals(3, set.size());
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.core;
-
-import com.sun.net.httpserver.Headers;
-import cz.cesnet.cloud.occi.DataGenerator;
-import cz.cesnet.cloud.occi.TestHelper;
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.net.URI;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-public class ActionInstanceTest {
-
- private static final String RESOURCE_PATH = "src/test/resources/rendering/text/";
-
- @Test
- public void testConstructor() throws Exception {
- Action action = new Action(new URI("http://dummy.action/"), "term");
- ActionInstance ai = new ActionInstance(action);
- assertEquals(action, ai.getAction());
- }
-
- @Test
- public void testInvalidConstructor() {
- try {
- ActionInstance ai = new ActionInstance(null);
- fail();
- } catch (NullPointerException ex) {
- //cool
- }
- }
-
- @Test
- public void testInvalidSetAction() throws Exception {
- try {
- Action action = new Action(new URI("http://dummy.action/"), "term");
- ActionInstance ai = new ActionInstance(action);
- ai.setAction(null);
- fail();
- } catch (NullPointerException ex) {
- //cool
- }
- }
-
- @Test
- public void testToText() throws Exception {
- String expected = TestHelper.readFile(RESOURCE_PATH + "action_plain.txt");
- ActionInstance ai = DataGenerator.getAction();
-
- assertEquals(expected, ai.toText());
- }
-
- @Test
- public void testToHeaders() throws Exception {
- Headers headers = new Headers();
- ActionInstance ai = DataGenerator.getAction();
-
- headers.add("Category", TestHelper.readFile(RESOURCE_PATH + "action_headers_category.txt"));
-
- try (BufferedReader br = new BufferedReader(new FileReader(RESOURCE_PATH + "action_headers_attributes.txt"))) {
- String line = br.readLine();
- while (line != null) {
- headers.add("X-OCCI-Attribute", line);
- line = br.readLine();
- }
- }
-
- assertEquals(headers, ai.toHeaders());
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.core;
-
-import com.sun.net.httpserver.Headers;
-import cz.cesnet.cloud.occi.infrastructure.Compute;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.HashSet;
-import java.util.Set;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-public class ActionTest {
-
- @Test
- public void testFullConstructor() throws URISyntaxException {
- Set<Attribute> attributes = new HashSet<>();
- attributes.add(new Attribute("aaa"));
- attributes.add(new Attribute("bbb"));
- attributes.add(new Attribute("ccc"));
- Action action = new Action(Compute.SCHEME_DEFAULT, "start", "Start", attributes);
-
- assertEquals(action.getAttributes(), attributes);
- assertEquals(action.getScheme(), Compute.SCHEME_DEFAULT);
- assertEquals(action.getTerm(), "start");
- assertEquals(action.getTitle(), "Start");
- }
-
- @Test
- public void testMinimalConstructor() throws URISyntaxException {
- Action action = new Action(Compute.SCHEME_DEFAULT, "start");
-
- assertEquals(action.getScheme(), Compute.SCHEME_DEFAULT);
- assertEquals(action.getTerm(), "start");
- }
-
- @Test
- public void testInvalidConstructor() throws URISyntaxException {
- try {
- Action action = new Action(null, Entity.TERM_DEFAULT);
- fail();
- } catch (NullPointerException ex) {
- //cool
- }
-
- try {
- Action action = new Action(Category.SCHEME_CORE_DEFAULT, null);
- fail();
- } catch (NullPointerException ex) {
- //cool
- }
-
- try {
- Action action = new Action(Category.SCHEME_CORE_DEFAULT, "");
- fail();
- } catch (IllegalArgumentException ex) {
- //cool
- }
- }
-
- @Test
- public void testToText() throws Exception {
- String expected = "Link: </compute/123?action=start>;rel=\"http://schemas.ogf.org/occi/infrastructure/compute/action#start\";";
- Action action = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/compute/action#"), "start");
-
- assertEquals(expected, action.toText("/compute/123"));
- }
-
- @Test
- public void testToHeaders() throws Exception {
- Headers headers = new Headers();
- headers.add("Link", "</compute/123?action=start>;rel=\"http://schemas.ogf.org/occi/infrastructure/compute/action#start\";");
-
- Action action = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/compute/action#"), "start");
-
- assertEquals(headers, action.toHeaders("/compute/123"));
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.core;
-
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-public class AttributeTest {
-
- @Test
- public void testConstructor() {
- Attribute a = new Attribute("name", true, false, "type", "pattern", "defaultValue", "description");
-
- assertEquals("name", a.getName());
- assertEquals("type", a.getType());
- assertEquals("pattern", a.getPattern());
- assertEquals("defaultValue", a.getDefaultValue());
- assertEquals("description", a.getDescription());
- assertTrue(a.isRequired());
- assertFalse(a.isImmutable());
-
- a = new Attribute("name", true, false, "type", null, "defaultValue", "description");
- assertEquals(".*", a.getPattern());
- }
-
- @Test
- public void testInvalidConstructor() {
- try {
- Attribute a = new Attribute(null);
- fail();
- } catch (NullPointerException ex) {
- //cool
- }
-
- try {
- Attribute a = new Attribute("");
- fail();
- } catch (IllegalArgumentException ex) {
- //cool
- }
- }
-
- @Test
- public void testInvalidSetName() {
- try {
- Attribute a = new Attribute("name");
- a.setName(null);
- fail();
- } catch (NullPointerException ex) {
- //cool
- }
-
- try {
- Attribute a = new Attribute("name");
- a.setName("");
- fail();
- } catch (IllegalArgumentException ex) {
- //cool
- }
- }
-
- @Test
- public void testToText() {
- Attribute a = new Attribute("attribute_name");
- assertEquals(a.toText(), "attribute_name");
-
- a.setRequired(true);
- assertEquals(a.toText(), "attribute_name{required}");
-
- a.setImmutable(true);
- assertEquals(a.toText(), "attribute_name{required immutable}");
-
- a.setRequired(false);
- assertEquals(a.toText(), "attribute_name{immutable}");
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.core;
-
-import static org.junit.Assert.fail;
-import org.junit.Test;
-import org.junit.Before;
-
-public class CategoryTest {
-
- private Category category;
-
- @Before
- public void setUp() {
- category = new Category(Category.SCHEME_CORE_DEFAULT, Entity.TERM_DEFAULT);
- }
-
- @Test
- public void testInvalidSetTerm() {
- try {
- category.setTerm(null);
- fail();
- } catch (NullPointerException ex) {
- //cool
- }
-
- try {
- category.setTerm("");
- fail();
- } catch (IllegalArgumentException ex) {
- //cool
- }
- }
-
- @Test
- public void testInvalidSetScheme() {
- try {
- category.setScheme(null);
- fail();
- } catch (NullPointerException ex) {
- //cool
- }
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.core;
-
-import cz.cesnet.cloud.occi.Model;
-import cz.cesnet.cloud.occi.exception.InvalidAttributeValueException;
-import cz.cesnet.cloud.occi.infrastructure.NetworkInterface;
-import org.junit.Test;
-import static org.junit.Assert.*;
-import org.junit.Before;
-
-public class EntityTest {
-
- private Entity entity;
- private Kind kind;
- private Model model;
- private Mixin mixin;
-
- @Before
- public void setUp() throws Exception {
- kind = new Kind(Entity.SCHEME_DEFAULT, Entity.TERM_DEFAULT);
- mixin = new Mixin(NetworkInterface.SCHEME_DEFAULT, NetworkInterface.TERM_DEFAULT);
- model = new Model();
- model.addKind(kind);
- entity = new Link("link_id", kind);
- }
-
- @Test
- public void testConstructor() throws Exception {
- Entity entity = new Link("entity_id", kind, "title", model);
-
- assertEquals("entity_id", entity.getId());
- assertEquals(kind, entity.getKind());
- assertEquals("title", entity.getTitle());
- assertEquals(model, entity.getModel());
- }
-
- @Test
- public void testInvalidConstructor() throws Exception {
- try {
- Entity entity = new Link(null, kind, "title", model);
- fail();
- } catch (NullPointerException ex) {
- //cool
- }
-
- try {
- Entity entity = new Link("entity_id", null, "title", model);
- fail();
- } catch (NullPointerException ex) {
- //cool
- }
- }
-
- @Test
- public void testInvalidSetId() throws Exception {
- try {
- entity.setId(null);
- fail();
- } catch (NullPointerException ex) {
- //cool
- }
- }
-
- @Test
- public void testInvalidSetKind() throws Exception {
- try {
- entity.setKind(null);
- fail();
- } catch (NullPointerException ex) {
- //cool
- }
- }
-
- @Test
- public void testAddAttribute() throws Exception {
- Attribute attrKind = new Attribute("attrKind");
- attrKind.setPattern("xyz");
- kind.addAttribute(attrKind);
- Attribute attrMixin = new Attribute("attrMixin");
- attrMixin.setPattern("abc");
- mixin.addAttribute(attrMixin);
- entity.addMixin(mixin);
-
- entity.addAttribute("attrKind", "xyz");
- entity.addAttribute("attrMixin", "abc");
- entity.addAttribute("nonexistingAttribute", "value");
-
- assertEquals("xyz", entity.getValue("attrKind"));
- assertEquals("xyz", entity.getValue(attrKind));
- assertEquals("abc", entity.getValue("attrMixin"));
- assertEquals("abc", entity.getValue(attrMixin));
- assertEquals("value", entity.getValue("nonexistingAttribute"));
- }
-
- @Test
- public void testInvalidAddAttribute() {
- Attribute attrKind = new Attribute("attrKind");
- attrKind.setPattern("xyz");
- kind.addAttribute(attrKind);
- Attribute attrMixin = new Attribute("attrMixin");
- attrMixin.setPattern("abc");
- mixin.addAttribute(attrMixin);
- entity.addMixin(mixin);
-
- try {
- entity.addAttribute("attrKind", "abc");
- fail();
- } catch (InvalidAttributeValueException ex) {
- //cool
- }
-
- try {
- entity.addAttribute("attrMixin", "xyz");
- fail();
- } catch (InvalidAttributeValueException ex) {
- //cool
- }
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.core;
-
-import com.sun.net.httpserver.Headers;
-import cz.cesnet.cloud.occi.TestHelper;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.HashSet;
-import java.util.Set;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-public class KindTest {
-
- private static final String RESOURCE_PATH = "src/test/resources/rendering/text/";
-
- @Test
- public void testFullConstructor() throws URISyntaxException {
- Set<Attribute> attributes = new HashSet<>();
- attributes.add(new Attribute("aaa"));
- attributes.add(new Attribute("bbb"));
- attributes.add(new Attribute("ccc"));
- Kind kind = new Kind(Category.SCHEME_CORE_DEFAULT, Entity.TERM_DEFAULT, "title", new URI("/location/"), attributes);
-
- assertEquals(kind.getAttributes(), attributes);
- assertEquals(kind.getLocation(), new URI("/location/"));
- assertEquals(kind.getScheme(), Category.SCHEME_CORE_DEFAULT);
- assertEquals(kind.getTerm(), Entity.TERM_DEFAULT);
- assertEquals(kind.getTitle(), "title");
- }
-
- @Test
- public void testMinimalConstructor() throws URISyntaxException {
- Kind kind = new Kind(Category.SCHEME_CORE_DEFAULT, Entity.TERM_DEFAULT);
-
- assertEquals(kind.getScheme(), Category.SCHEME_CORE_DEFAULT);
- assertEquals(kind.getTerm(), Entity.TERM_DEFAULT);
- }
-
- @Test
- public void testInvalidConstructor() throws URISyntaxException {
- try {
- Kind kind = new Kind(null, Entity.TERM_DEFAULT);
- fail();
- } catch (NullPointerException ex) {
- //cool
- }
-
- try {
- Kind kind = new Kind(Category.SCHEME_CORE_DEFAULT, null);
- fail();
- } catch (NullPointerException ex) {
- //cool
- }
-
- try {
- Kind kind = new Kind(Category.SCHEME_CORE_DEFAULT, "");
- fail();
- } catch (IllegalArgumentException ex) {
- //cool
- }
- }
-
- @Test
- public void testToText() throws Exception {
- String[] lines = TestHelper.readFile(RESOURCE_PATH + "kind_plain.txt").split("\n");
- Attribute at1 = new Attribute(Entity.ID_ATTRIBUTE_NAME);
- Attribute at2 = new Attribute(Entity.TITLE_ATTRIBUTE_NAME);
-
- Action a1 = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/compute/action#"), "start");
- Action a2 = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/compute/action#"), "stop");
-
- Kind kind = new Kind(Category.SCHEME_CORE_DEFAULT, Entity.TERM_DEFAULT);
- assertEquals(lines[0], kind.toText());
-
- kind.setTitle("Entity");
- assertEquals(lines[1], kind.toText());
-
- kind.setTitle(null);
- kind.setLocation(new URI("/entity/"));
- assertEquals(lines[2], kind.toText());
-
- kind.setLocation(null);
- kind.addAttribute(at1);
- kind.addAttribute(at2);
- assertEquals(lines[3], kind.toText());
-
- kind = new Kind(Category.SCHEME_CORE_DEFAULT, Entity.TERM_DEFAULT);
- kind.addAction(a1);
- kind.addAction(a2);
- assertEquals(lines[4], kind.toText());
-
- kind.addAttribute(at1);
- kind.addAttribute(at2);
- kind.setTitle("Entity");
- kind.setLocation(new URI("/entity/"));
- assertEquals(lines[5], kind.toText());
-
- kind.getAttribute(Entity.ID_ATTRIBUTE_NAME).setRequired(true);
- assertEquals(lines[6], kind.toText());
-
- kind.getAttribute(Entity.ID_ATTRIBUTE_NAME).setImmutable(true);
- assertEquals(lines[7], kind.toText());
-
- kind.getAttribute(Entity.TITLE_ATTRIBUTE_NAME).setImmutable(true);
- assertEquals(lines[8], kind.toText());
- }
-
- @Test
- public void testToHeaders() throws Exception {
- String[] lines = TestHelper.readFile(RESOURCE_PATH + "kind_headers.txt").split("\n");
- Attribute at1 = new Attribute(Entity.ID_ATTRIBUTE_NAME);
- Attribute at2 = new Attribute(Entity.TITLE_ATTRIBUTE_NAME);
-
- Action a1 = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/compute/action#"), "start");
- Action a2 = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/compute/action#"), "stop");
-
- Headers headers = new Headers();
-
- Kind kind = new Kind(Category.SCHEME_CORE_DEFAULT, Entity.TERM_DEFAULT);
- headers.add("Category", lines[0]);
- assertEquals(headers, kind.toHeaders());
-
- kind.setTitle("Entity");
- headers.clear();
- headers.add("Category", lines[1]);
- assertEquals(headers, kind.toHeaders());
-
- kind.setTitle(null);
- kind.setLocation(new URI("/entity/"));
- headers.clear();
- headers.add("Category", lines[2]);
- assertEquals(headers, kind.toHeaders());
-
- kind.setLocation(null);
- kind.addAttribute(at1);
- kind.addAttribute(at2);
- headers.clear();
- headers.add("Category", lines[3]);
- assertEquals(headers, kind.toHeaders());
-
- kind = new Kind(Category.SCHEME_CORE_DEFAULT, Entity.TERM_DEFAULT);
- kind.addAction(a1);
- kind.addAction(a2);
- headers.clear();
- headers.add("Category", lines[4]);
- assertEquals(headers, kind.toHeaders());
-
- kind.addAttribute(at1);
- kind.addAttribute(at2);
- kind.setTitle("Entity");
- kind.setLocation(new URI("/entity/"));
- headers.clear();
- headers.add("Category", lines[5]);
- assertEquals(headers, kind.toHeaders());
-
- kind.getAttribute(Entity.ID_ATTRIBUTE_NAME).setRequired(true);
- headers.clear();
- headers.add("Category", lines[6]);
- assertEquals(headers, kind.toHeaders());
-
- kind.getAttribute(Entity.ID_ATTRIBUTE_NAME).setImmutable(true);
- headers.clear();
- headers.add("Category", lines[7]);
- assertEquals(headers, kind.toHeaders());
-
- kind.getAttribute(Entity.TITLE_ATTRIBUTE_NAME).setImmutable(true);
- headers.clear();
- headers.add("Category", lines[8]);
- assertEquals(headers, kind.toHeaders());
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.core;
-
-import com.sun.net.httpserver.Headers;
-import cz.cesnet.cloud.occi.TestHelper;
-import cz.cesnet.cloud.occi.exception.InvalidAttributeValueException;
-import cz.cesnet.cloud.occi.exception.RenderingException;
-import cz.cesnet.cloud.occi.infrastructure.Compute;
-import cz.cesnet.cloud.occi.infrastructure.NetworkInterface;
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-import org.junit.Test;
-
-public class LinkTest {
-
- private static final String RESOURCE_PATH = "src/test/resources/rendering/text/";
-
- @Test
- public void testToText() throws Exception {
- String expected = TestHelper.readFile(RESOURCE_PATH + "link_plain.txt");
- Link link = prepareLink();
-
- assertEquals(expected, link.toText());
- }
-
- @Test
- public void testToHeaders() throws Exception {
- Headers headers = new Headers();
- Link link = prepareLink();
-
- try (BufferedReader br = new BufferedReader(new FileReader(RESOURCE_PATH + "link_headers_categories.txt"))) {
- String line = br.readLine();
- while (line != null) {
- headers.add("Category", line);
- line = br.readLine();
- }
- }
- try (BufferedReader br = new BufferedReader(new FileReader(RESOURCE_PATH + "link_headers_attributes.txt"))) {
- String line = br.readLine();
- while (line != null) {
- headers.add("X-OCCI-Attribute", line);
- line = br.readLine();
- }
- }
-
- assertEquals(headers, link.toHeaders());
- }
-
- private Link prepareLink() throws Exception {
- Kind rel = new Kind(Category.SCHEME_CORE_DEFAULT, Link.TERM_DEFAULT);
- Kind kind = new Kind(new URI("http://schemas.ogf.org/occi/infrastructure/compute#"), "console", "Link to the VM's console", new URI("/console/"), null);
- kind.addRelation(rel);
-
- List<Attribute> attributes = new ArrayList<>();
- attributes.add(new Attribute("occi.network.address"));
- attributes.add(new Attribute("occi.network.gateway"));
- attributes.add(new Attribute("occi.network.allocation"));
- attributes.add(new Attribute("occi.network.state"));
- Mixin m1 = new Mixin(new URI("http://schemas.ogf.org/occi/infrastructure/network#"), "ipnetwork", "IP Network Mixin", new URI("/mixins/ipnetwork/"), attributes);
- Mixin m2 = new Mixin(Category.SCHEME_INFRASTRUCTURE_DEFAULT, "os_tpl", "Operating System Template", new URI("/mixins/os_tpl/"), null);
- Mixin m3 = new Mixin(Category.SCHEME_INFRASTRUCTURE_DEFAULT, "resource_tpl", "Resource Template", new URI("/mixins/resource_tpl/"), null);
-
- Link link = new Link("87f3bfc3-42d4-4474-b45c-757e55e093e9", kind, "compute1", null);
- link.addMixin(m1);
- link.addMixin(m2);
- link.addMixin(m3);
- link.addAttribute(Compute.ARCHITECTURE_ATTRIBUTE_NAME, "x86");
- link.addAttribute(Compute.HOSTNAME_ATTRIBUTE_NAME, "compute1.example.org");
- link.addAttribute(Compute.MEMORY_ATTRIBUTE_NAME, "1.7");
- link.addAttribute(Compute.SPEED_ATTRIBUTE_NAME, "1.0");
- link.addAttribute(Compute.STATE_ATTRIBUTE_NAME, "active");
-
- return link;
- }
-
- @Test
- public void testToInlineText() throws Exception {
- String[] lines = TestHelper.readFile(RESOURCE_PATH + "inline_link_plain.txt").split("\n");
-
- Kind kind = new Kind(NetworkInterface.SCHEME_DEFAULT, NetworkInterface.TERM_DEFAULT);
- Link link = new Link("456", kind);
- link.setRelation("http://schemas.ogf.org/occi/infrastructure#network");
- link.setTarget("/network/123");
- assertEquals(lines[0], link.toInlineText());
-
- link.getKind().setLocation(new URI("/link/networkinterface/"));
- assertEquals(lines[1], link.toInlineText());
-
- link.getKind().setLocation(null);
- link.addAttribute("occi.networkinterface.interface", "eth0");
- link.addAttribute("occi.networkinterface.mac", "00:11:22:33:44:55");
- link.addAttribute("occi.networkinterface.state", "active");
- assertEquals(lines[2], link.toInlineText());
-
- link.getKind().setLocation(new URI("/link/networkinterface/"));
- assertEquals(lines[3], link.toInlineText());
- }
-
- @Test
- public void testToInlineHeaders() throws Exception {
- String[] lines = TestHelper.readFile(RESOURCE_PATH + "inline_link_headers.txt").split("\n");
- Headers headers = new Headers();
-
- Kind kind = new Kind(NetworkInterface.SCHEME_DEFAULT, NetworkInterface.TERM_DEFAULT);
- Link link = new Link("456", kind);
- link.setRelation("http://schemas.ogf.org/occi/infrastructure#network");
- link.setTarget("/network/123");
- headers.add("Link", lines[0]);
- assertEquals(headers, link.toInlineHeaders());
-
- link.getKind().setLocation(new URI("/link/networkinterface/"));
- headers.clear();
- headers.add("Link", lines[1]);
- assertEquals(headers, link.toInlineHeaders());
-
- link.getKind().setLocation(null);
- link.addAttribute("occi.networkinterface.interface", "eth0");
- link.addAttribute("occi.networkinterface.mac", "00:11:22:33:44:55");
- link.addAttribute("occi.networkinterface.state", "active");
- headers.clear();
- headers.add("Link", lines[2]);
- assertEquals(headers, link.toInlineHeaders());
-
- link.getKind().setLocation(new URI("/link/networkinterface/"));
- headers.clear();
- headers.add("Link", lines[3]);
- assertEquals(headers, link.toInlineHeaders());
- }
-
- @Test
- public void testInvalidToInlineText() throws InvalidAttributeValueException {
- try {
- Kind kind = new Kind(NetworkInterface.SCHEME_DEFAULT, NetworkInterface.TERM_DEFAULT);
- Link link = new Link("456", kind);
- link.setRelation("http://schemas.ogf.org/occi/infrastructure#network");
- link.toInlineText();
- fail();
- } catch (RenderingException ex) {
- //cool
- }
-
- try {
- Kind kind = new Kind(NetworkInterface.SCHEME_DEFAULT, NetworkInterface.TERM_DEFAULT);
- Link link = new Link("456", kind);
- link.setTarget("/network/123");
- link.toInlineText();
- fail();
- } catch (RenderingException ex) {
- //cool
- }
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.core;
-
-import com.sun.net.httpserver.Headers;
-import cz.cesnet.cloud.occi.TestHelper;
-import cz.cesnet.cloud.occi.infrastructure.IPNetwork;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.HashSet;
-import java.util.Set;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-public class MixinTest {
-
- private static final String RESOURCE_PATH = "src/test/resources/rendering/text/";
-
- @Test
- public void testFullConstructor() throws URISyntaxException {
- Set<Attribute> attributes = new HashSet<>();
- attributes.add(new Attribute("aaa"));
- attributes.add(new Attribute("bbb"));
- attributes.add(new Attribute("ccc"));
- Mixin mixin = new Mixin(Category.SCHEME_CORE_DEFAULT, Entity.TERM_DEFAULT, "title", new URI("/location/"), attributes);
-
- assertEquals(mixin.getAttributes(), attributes);
- assertEquals(mixin.getLocation(), new URI("/location/"));
- assertEquals(mixin.getScheme(), Category.SCHEME_CORE_DEFAULT);
- assertEquals(mixin.getTerm(), Entity.TERM_DEFAULT);
- assertEquals(mixin.getTitle(), "title");
- }
-
- @Test
- public void testMinimalConstructor() throws URISyntaxException {
- Mixin mixin = new Mixin(Category.SCHEME_CORE_DEFAULT, Entity.TERM_DEFAULT);
-
- assertEquals(mixin.getScheme(), Category.SCHEME_CORE_DEFAULT);
- assertEquals(mixin.getTerm(), Entity.TERM_DEFAULT);
- }
-
- @Test
- public void testInvalidConstructor() throws URISyntaxException {
- try {
- Mixin mixin = new Mixin(null, Entity.TERM_DEFAULT);
- fail();
- } catch (NullPointerException ex) {
- //cool
- }
-
- try {
- Mixin mixin = new Mixin(Category.SCHEME_CORE_DEFAULT, null);
- fail();
- } catch (NullPointerException ex) {
- //cool
- }
-
- try {
- Mixin mixin = new Mixin(Category.SCHEME_CORE_DEFAULT, "");
- fail();
- } catch (IllegalArgumentException ex) {
- //cool
- }
- }
-
- @Test
- public void testToText() throws Exception {
- String[] lines = TestHelper.readFile(RESOURCE_PATH + "mixin_plain.txt").split("\n");
- Attribute at1 = new Attribute(IPNetwork.ADDRESS_ATTRIBUTE_NAME);
- Attribute at2 = new Attribute(IPNetwork.GATEWAY_ATTRIBUTE_NAME);
- Attribute at3 = new Attribute(IPNetwork.ALLOCATION_ATTRIBUTE_NAME);
- Attribute at4 = new Attribute(IPNetwork.STATE_ATTRIBUTE_NAME);
- Action a1 = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/compute/action#"), "start");
- Action a2 = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/compute/action#"), "stop");
-
- Mixin mixin = new Mixin(IPNetwork.SCHEME_DEFAULT, IPNetwork.TERM_DEFAULT);
- assertEquals(mixin.toText(), lines[0]);
-
- mixin.setTitle("IP Network Mixin");
- assertEquals(mixin.toText(), lines[1]);
-
- mixin.setTitle(null);
- mixin.setLocation(new URI("/mixins/ipnetwork/"));
- assertEquals(mixin.toText(), lines[2]);
-
- mixin.setLocation(null);
- mixin.addAttribute(at1);
- mixin.addAttribute(at2);
- mixin.addAttribute(at3);
- mixin.addAttribute(at4);
- assertEquals(mixin.toText(), lines[3]);
-
- mixin = new Mixin(IPNetwork.SCHEME_DEFAULT, IPNetwork.TERM_DEFAULT);
- mixin.addAction(a1);
- mixin.addAction(a2);
- assertEquals(mixin.toText(), lines[4]);
-
- mixin.addAttribute(at1);
- mixin.addAttribute(at2);
- mixin.addAttribute(at3);
- mixin.addAttribute(at4);
- mixin.getAttribute(IPNetwork.ADDRESS_ATTRIBUTE_NAME).setRequired(true);
- mixin.getAttribute(IPNetwork.GATEWAY_ATTRIBUTE_NAME).setImmutable(true);
- mixin.getAttribute(IPNetwork.ALLOCATION_ATTRIBUTE_NAME).setRequired(true);
- mixin.getAttribute(IPNetwork.ALLOCATION_ATTRIBUTE_NAME).setImmutable(true);
- mixin.setTitle("IP Network Mixin");
- mixin.setLocation(new URI("/mixins/ipnetwork/"));
- assertEquals(mixin.toText(), lines[5]);
- }
-
- @Test
- public void testToHeaders() throws Exception {
- String[] lines = TestHelper.readFile(RESOURCE_PATH + "mixin_headers.txt").split("\n");
- Attribute at1 = new Attribute(IPNetwork.ADDRESS_ATTRIBUTE_NAME);
- Attribute at2 = new Attribute(IPNetwork.GATEWAY_ATTRIBUTE_NAME);
- Attribute at3 = new Attribute(IPNetwork.ALLOCATION_ATTRIBUTE_NAME);
- Attribute at4 = new Attribute(IPNetwork.STATE_ATTRIBUTE_NAME);
- Action a1 = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/compute/action#"), "start");
- Action a2 = new Action(new URI("http://schemas.ogf.org/occi/infrastructure/compute/action#"), "stop");
-
- Headers headers = new Headers();
-
- Mixin mixin = new Mixin(IPNetwork.SCHEME_DEFAULT, IPNetwork.TERM_DEFAULT);
- headers.add("Category", lines[0]);
- assertEquals(headers, mixin.toHeaders());
-
- mixin.setTitle("IP Network Mixin");
- headers.clear();
- headers.add("Category", lines[1]);
- assertEquals(headers, mixin.toHeaders());
-
- mixin.setTitle(null);
- mixin.setLocation(new URI("/mixins/ipnetwork/"));
- headers.clear();
- headers.add("Category", lines[2]);
- assertEquals(headers, mixin.toHeaders());
-
- mixin.setLocation(null);
- mixin.addAttribute(at1);
- mixin.addAttribute(at2);
- mixin.addAttribute(at3);
- mixin.addAttribute(at4);
- headers.clear();
- headers.add("Category", lines[3]);
- assertEquals(headers, mixin.toHeaders());
-
- mixin = new Mixin(IPNetwork.SCHEME_DEFAULT, IPNetwork.TERM_DEFAULT);
- mixin.addAction(a1);
- mixin.addAction(a2);
- headers.clear();
- headers.add("Category", lines[4]);
- assertEquals(headers, mixin.toHeaders());
-
- mixin.addAttribute(at1);
- mixin.addAttribute(at2);
- mixin.addAttribute(at3);
- mixin.addAttribute(at4);
- mixin.getAttribute(IPNetwork.ADDRESS_ATTRIBUTE_NAME).setRequired(true);
- mixin.getAttribute(IPNetwork.GATEWAY_ATTRIBUTE_NAME).setImmutable(true);
- mixin.getAttribute(IPNetwork.ALLOCATION_ATTRIBUTE_NAME).setRequired(true);
- mixin.getAttribute(IPNetwork.ALLOCATION_ATTRIBUTE_NAME).setImmutable(true);
- mixin.setTitle("IP Network Mixin");
- mixin.setLocation(new URI("/mixins/ipnetwork/"));
- headers.clear();
- headers.add("Category", lines[5]);
- assertEquals(headers, mixin.toHeaders());
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.core;
-
-import com.sun.net.httpserver.Headers;
-import cz.cesnet.cloud.occi.DataGenerator;
-import cz.cesnet.cloud.occi.TestHelper;
-import java.io.BufferedReader;
-import java.io.FileReader;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-public class ResourceTest {
-
- private static final String RESOURCE_PATH = "src/test/resources/rendering/text/";
-
- @Test
- public void testToText() throws Exception {
- String expected = TestHelper.readFile(RESOURCE_PATH + "resource_plain.txt");
- Resource resource = DataGenerator.getResource();
-
- assertEquals(expected, resource.toText());
- }
-
- @Test
- public void testToHeaders() throws Exception {
- Headers headers = new Headers();
- Resource resource = DataGenerator.getResource();
-
- try (BufferedReader br = new BufferedReader(new FileReader(RESOURCE_PATH + "resource_headers_categories.txt"))) {
- String line = br.readLine();
- while (line != null) {
- headers.add("Category", line);
- line = br.readLine();
- }
- }
- try (BufferedReader br = new BufferedReader(new FileReader(RESOURCE_PATH + "resource_headers_attributes.txt"))) {
- String line = br.readLine();
- while (line != null) {
- headers.add("X-OCCI-Attribute", line);
- line = br.readLine();
- }
- }
- try (BufferedReader br = new BufferedReader(new FileReader(RESOURCE_PATH + "resource_headers_links.txt"))) {
- String line = br.readLine();
- while (line != null) {
- headers.add("Link", line);
- line = br.readLine();
- }
- }
-
- for (String name : headers.keySet()) {
- System.out.println(name);
- System.out.println(headers.get(name));
- }
- for (String name : resource.toHeaders().keySet()) {
- System.out.println(name);
- System.out.println(resource.toHeaders().get(name));
- }
-
- assertEquals(headers, resource.toHeaders());
- }
-}
+++ /dev/null
-package cz.cesnet.cloud.occi.parser;
-
-import com.sun.net.httpserver.Headers;
-import cz.cesnet.cloud.occi.Collection;
-import cz.cesnet.cloud.occi.DataGenerator;
-import cz.cesnet.cloud.occi.Model;
-import cz.cesnet.cloud.occi.TestHelper;
-import cz.cesnet.cloud.occi.core.Action;
-import cz.cesnet.cloud.occi.core.ActionInstance;
-import cz.cesnet.cloud.occi.core.Attribute;
-import cz.cesnet.cloud.occi.core.Kind;
-import cz.cesnet.cloud.occi.core.Link;
-import cz.cesnet.cloud.occi.core.Mixin;
-import cz.cesnet.cloud.occi.core.Resource;
-import cz.cesnet.cloud.occi.exception.ParsingException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-import org.junit.Test;
-
-public class TextParserTest {
-
- private static final String RESOURCE_PATH = "src/test/resources/parser/text/";
-
- private Model populateModelWithKinds(List<Kind> kinds, Model initialModel) {
- Model model;
- if (initialModel == null) {
- model = new Model();
- } else {
- model = initialModel;
- }
-
- for (Kind k : kinds) {
- model.addKind(k);
- }
-
- return model;
- }
-
- private Model populateModelWithMixins(List<Mixin> mixins, Model initialModel) {
- Model model;
- if (initialModel == null) {
- model = new Model();
- } else {
- model = initialModel;
- }
-
- for (Mixin k : mixins) {
- model.addMixin(k);
- }
-
- return model;
- }
-
- private Model populateModelWithActions(List<Action> actions, Model initialModel) {
- Model model;
- if (initialModel == null) {
- model = new Model();
- } else {
- model = initialModel;
- }
-
- for (Action k : actions) {
- model.addAction(k);
- }
-
- return model;
- }
-
- @Test
- public void testParseModelPlainKindsMinimal() throws Exception {
- String body = TestHelper.readFile(RESOURCE_PATH + "model_plain_kinds_minimal.txt");
- Headers headers = null;
- TextParser instance = new TextParser();
- Model expResult = populateModelWithKinds(DataGenerator.getMinimalKind(), null);
- Model result = instance.parseModel(MediaType.TEXT_PLAIN, body, headers);
- assertEquals(expResult, result);
- assertKindsEqual(expResult.getKinds(), result.getKinds());
- }
-
- @Test
- public void testParseModelPlainKindsFull() throws Exception {
- String body = TestHelper.readFile(RESOURCE_PATH + "model_plain_kinds_full.txt");
- Headers headers = null;
- TextParser instance = new TextParser();
- Model expResult = populateModelWithKinds(DataGenerator.getFiveKinds(), null);
- Model result = instance.parseModel(MediaType.TEXT_PLAIN, body, headers);
- assertEquals(expResult, result);
- assertKindsEqual(expResult.getKinds(), result.getKinds());
- }
-
- @Test
- public void testInvalidParseModelPlainKind() {
- TextParser instance = new TextParser();
-
- //kind without location
- try {
- String body = "Category: entity;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\";title=\"Entity\";attributes=\"occi.core.id occi.core.title\"";
- instance.parseModel(MediaType.TEXT_PLAIN, body, null);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //kind with empty location
- try {
- String body = "Category: entity;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\";title=\"Entity\";location=\"\";attributes=\"occi.core.id occi.core.title\"";
- instance.parseModel(MediaType.TEXT_PLAIN, body, null);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //kind with illegal scheme
- try {
- String body = "Category: entity;scheme=\"/\\/_)#@564...,p,pkl\";class=\"kind\";title=\"Entity\";location=\"/entity/\";attributes=\"occi.core.id occi.core.title\"";
- instance.parseModel(MediaType.TEXT_PLAIN, body, null);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //kind with illegal location
- try {
- String body = "Category: entity;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\";title=\"Entity\";location=\"/\\/_)#@564...,p,pkl\";attributes=\"occi.core.id occi.core.title\"";
- instance.parseModel(MediaType.TEXT_PLAIN, body, null);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
- }
-
- @Test
- public void testParseModelPlainMixinsMinimal() throws Exception {
- String body = TestHelper.readFile(RESOURCE_PATH + "model_plain_mixins_minimal.txt");
- Headers headers = null;
- TextParser instance = new TextParser();
- Model expResult = populateModelWithMixins(DataGenerator.getMinimalMixin(), null);
- Model result = instance.parseModel(MediaType.TEXT_PLAIN, body, headers);
- assertEquals(expResult, result);
- assertMixinsEqual(expResult.getMixins(), result.getMixins());
- }
-
- @Test
- public void testParseModelPlainMixinsFull() throws Exception {
- String body = TestHelper.readFile(RESOURCE_PATH + "model_plain_mixins_full.txt");
- Headers headers = null;
- TextParser instance = new TextParser();
- Model expResult = populateModelWithMixins(DataGenerator.getFiveMixins(), null);
- Model result = instance.parseModel(MediaType.TEXT_PLAIN, body, headers);
- assertEquals(expResult, result);
- assertMixinsEqual(expResult.getMixins(), result.getMixins());
- }
-
- @Test
- public void testInvalidParseModelPlainMixin() {
- TextParser instance = new TextParser();
- //mixin with illegal scheme
- try {
- String body = "Category: ipnetwork;scheme=\"/\\/_)#@564...,p,pkl\";class=\"mixin\";title=\"IP Network Mixin\";location=\"/mixins/ipnetwork/\";attributes=\"occi.network.address{required} occi.network.gateway occi.network.allocation occi.network.state\"";
- instance.parseModel(MediaType.TEXT_PLAIN, body, null);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
- }
-
- @Test
- public void testParseModelPlainActionsMinimal() throws Exception {
- String body = TestHelper.readFile(RESOURCE_PATH + "model_plain_actions_minimal.txt");
- Headers headers = null;
- TextParser instance = new TextParser();
- Model expResult = populateModelWithActions(DataGenerator.getMinimalAction(), null);
- Model result = instance.parseModel(MediaType.TEXT_PLAIN, body, headers);
- assertEquals(expResult, result);
- assertActionsEqual(expResult.getActions(), result.getActions());
- }
-
- @Test
- public void testParseModelPlainActionsFull() throws Exception {
- String body = TestHelper.readFile(RESOURCE_PATH + "model_plain_actions_full.txt");
- Headers headers = null;
- TextParser instance = new TextParser();
- Model expResult = populateModelWithActions(DataGenerator.getFiveActions(), null);
- Model result = instance.parseModel(MediaType.TEXT_PLAIN, body, headers);
- assertEquals(expResult, result);
- assertActionsEqual(expResult.getActions(), result.getActions());
- }
-
- @Test
- public void testInvalidParseModelPlainAction() {
- TextParser instance = new TextParser();
-
- //action with illegal scheme
- try {
- String body = "Category: restart;scheme=\"/\\/_)#@564...,p,pkl\";class=\"action\";title=\"Restart Compute instance\";attributes=\"method\"";
- instance.parseModel(MediaType.TEXT_PLAIN, body, null);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
- }
-
- @Test
- public void testParseModelPlainAll() throws Exception {
- String body = TestHelper.readFile(RESOURCE_PATH + "model_plain_all.txt");
- Headers headers = null;
- TextParser instance = new TextParser();
- Model expResult = populateModelWithKinds(DataGenerator.getFiveKinds(), null);
- expResult = populateModelWithMixins(DataGenerator.getFiveMixins(), expResult);
- expResult = populateModelWithActions(DataGenerator.getFiveActions(), expResult);
- Model result = instance.parseModel(MediaType.TEXT_PLAIN, body, headers);
- assertEquals(expResult, result);
- assertKindsEqual(expResult.getKinds(), result.getKinds());
- assertMixinsEqual(expResult.getMixins(), result.getMixins());
- assertActionsEqual(expResult.getActions(), result.getActions());
- }
-
- @Test
- public void testInvalidParseModelPlain() {
- TextParser instance = new TextParser();
-
- try {
- String body = "nonmatching_line";
- instance.parseModel(MediaType.TEXT_PLAIN, body, null);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //without term
- try {
- String body = "Category: ;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\";title=\"Entity\";location=\"/entity/\";attributes=\"occi.core.id occi.core.title\"";
- instance.parseModel(MediaType.TEXT_PLAIN, body, null);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //without scheme
- try {
- String body = "Category: entity;class=\"kind\";title=\"Entity\";location=\"/entity/\";attributes=\"occi.core.id occi.core.title\"";
- instance.parseModel(MediaType.TEXT_PLAIN, body, null);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //with empty scheme
- try {
- String body = "Category: entity;scheme=\"\";class=\"kind\";title=\"Entity\";location=\"/entity/\";attributes=\"occi.core.id occi.core.title\"";
- instance.parseModel(MediaType.TEXT_PLAIN, body, null);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //without class
- try {
- String body = "Category: entity;scheme=\"http://schemas.ogf.org/occi/core#\";title=\"Entity\";location=\"/entity/\";attributes=\"occi.core.id occi.core.title\"";
- instance.parseModel(MediaType.TEXT_PLAIN, body, null);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //with empty class
- try {
- String body = "Category: entity;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"\";title=\"Entity\";location=\"/entity/\";attributes=\"occi.core.id occi.core.title\"";
- instance.parseModel(MediaType.TEXT_PLAIN, body, null);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //with unknown class
- try {
- String body = "Category: entity;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"nonexisting_class\";title=\"Entity\";location=\"/entity/\";attributes=\"occi.core.id occi.core.title\"";
- instance.parseModel(MediaType.TEXT_PLAIN, body, null);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- }
-
- private Headers createDefaultHeaders() {
- Headers headers = new Headers();
- headers.add("Status Code", "200 OK");
- headers.add("Cache-Control", "no-cache");
- headers.add("Connection", "keep-alive");
- headers.add("Content-Length", "0");
- headers.add("Content-Type", "text/occi; charset=utf-8");
- headers.add("Date", "Thu, 06 Nov 2014 19:11:38 GMT");
- headers.add("Server", "WEBrick/1.3.1 (Ruby/2.0.0/2014-09-19)");
- headers.add("Via", "1.1 vegur");
- headers.add("X-Frame-Options", "SAMEORIGIN");
- headers.add("X-Request-Id", "3191d404-a8f5-4bda-97d6-1069e71fc418");
- headers.add("X-Runtime", "0.025947");
- headers.add("X-XSS-Protection", "1; mode=block");
- headers.add("x-content-type-options", "nosniff");
-
- return headers;
- }
-
- @Test
- public void testParseModelOcciKindsMinimal() throws Exception {
- String categoryHeader = TestHelper.readFile(RESOURCE_PATH + "model_occi_kinds_minimal.txt");
- String body = null;
- Headers headers = createDefaultHeaders();
- headers.add("Category", categoryHeader);
- TextParser instance = new TextParser();
- Model expResult = populateModelWithKinds(DataGenerator.getMinimalKind(), null);
- Model result = instance.parseModel(MediaType.TEXT_OCCI, body, headers);
- assertEquals(expResult, result);
- assertKindsEqual(expResult.getKinds(), result.getKinds());
- }
-
- @Test
- public void testParseModelOcciKindsFull() throws Exception {
- String categoryHeader = TestHelper.readFile(RESOURCE_PATH + "model_occi_kinds_full.txt");
- String body = null;
- Headers headers = createDefaultHeaders();
- headers.add("Category", categoryHeader);
- TextParser instance = new TextParser();
- Model expResult = populateModelWithKinds(DataGenerator.getFiveKinds(), null);
- Model result = instance.parseModel(MediaType.TEXT_OCCI, body, headers);
- assertEquals(expResult, result);
- assertKindsEqual(expResult.getKinds(), result.getKinds());
- }
-
- @Test
- public void testInvalidParseModelOcciKind() {
- TextParser instance = new TextParser();
- Headers headers = createDefaultHeaders();
-
- //kind without location
- try {
- headers.add("Category", "Category: entity;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\";title=\"Entity\";attributes=\"occi.core.id occi.core.title\"");
- instance.parseModel(MediaType.TEXT_OCCI, null, headers);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //kind with empty location
- try {
- headers.add("Category", "Category: entity;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\";title=\"Entity\";location=\"\";attributes=\"occi.core.id occi.core.title\"");
- instance.parseModel(MediaType.TEXT_OCCI, null, headers);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //kind with illegal scheme
- try {
- headers.add("Category", "Category: entity;scheme=\"/\\/_)#@564...,p,pkl\";class=\"kind\";title=\"Entity\";location=\"/entity/\";attributes=\"occi.core.id occi.core.title\"");
- instance.parseModel(MediaType.TEXT_OCCI, null, headers);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //kind with illegal location
- try {
- headers.add("Category", "Category: entity;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\";title=\"Entity\";location=\"/\\/_)#@564...,p,pkl\";attributes=\"occi.core.id occi.core.title\"");
- instance.parseModel(MediaType.TEXT_OCCI, null, headers);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
- }
-
- @Test
- public void testParseModelOcciMixinsMinimal() throws Exception {
- String categoryHeader = TestHelper.readFile(RESOURCE_PATH + "model_occi_mixins_minimal.txt");
- String body = null;
- Headers headers = createDefaultHeaders();
- headers.add("Category", categoryHeader);
- TextParser instance = new TextParser();
- Model expResult = populateModelWithMixins(DataGenerator.getMinimalMixin(), null);
- Model result = instance.parseModel(MediaType.TEXT_OCCI, body, headers);
- assertEquals(expResult, result);
- assertMixinsEqual(expResult.getMixins(), result.getMixins());
- }
-
- @Test
- public void testParseModelOcciMixinsFull() throws Exception {
- String categoryHeader = TestHelper.readFile(RESOURCE_PATH + "model_occi_mixins_full.txt");
- String body = null;
- Headers headers = createDefaultHeaders();
- headers.add("Category", categoryHeader);
- TextParser instance = new TextParser();
- Model expResult = populateModelWithMixins(DataGenerator.getFiveMixins(), null);
- Model result = instance.parseModel(MediaType.TEXT_OCCI, body, headers);
- assertEquals(expResult, result);
- assertMixinsEqual(expResult.getMixins(), result.getMixins());
- }
-
- @Test
- public void testInvalidParseModelOcciMixin() {
- TextParser instance = new TextParser();
- Headers headers = createDefaultHeaders();
-
- //mixin with illegal scheme
- try {
- headers.add("Category", "Category: ipnetwork;scheme=\"/\\/_)#@564...,p,pkl\";class=\"mixin\";title=\"IP Network Mixin\";location=\"/mixins/ipnetwork/\";attributes=\"occi.network.address{required} occi.network.gateway occi.network.allocation occi.network.state\"");
- instance.parseModel(MediaType.TEXT_OCCI, null, headers);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //mixin with illegal location
- try {
- headers.add("Category", "Category: ipnetwork;scheme=\"http://schemas.ogf.org/occi/infrastructure/network#\";class=\"mixin\";title=\"IP Network Mixin\";location=\"/\\/_)#@564...,p,pkl\";attributes=\"occi.network.address{required} occi.network.gateway occi.network.allocation occi.network.state\"");
- instance.parseModel(MediaType.TEXT_OCCI, null, headers);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
- }
-
- @Test
- public void testParseModelOcciActionsMinimal() throws Exception {
- String categoryHeader = TestHelper.readFile(RESOURCE_PATH + "model_occi_actions_minimal.txt");
- String body = null;
- Headers headers = createDefaultHeaders();
- headers.add("Category", categoryHeader);
- TextParser instance = new TextParser();
- Model expResult = populateModelWithActions(DataGenerator.getMinimalAction(), null);
- Model result = instance.parseModel(MediaType.TEXT_OCCI, body, headers);
- assertEquals(expResult, result);
- assertActionsEqual(expResult.getActions(), result.getActions());
- }
-
- @Test
- public void testParseModelOcciActionsFull() throws Exception {
- String categoryHeader = TestHelper.readFile(RESOURCE_PATH + "model_occi_actions_full.txt");
- String body = null;
- Headers headers = createDefaultHeaders();
- headers.add("Category", categoryHeader);
- TextParser instance = new TextParser();
- Model expResult = populateModelWithActions(DataGenerator.getFiveActions(), null);
- Model result = instance.parseModel(MediaType.TEXT_OCCI, body, headers);
- assertEquals(expResult, result);
- assertActionsEqual(expResult.getActions(), result.getActions());
- }
-
- @Test
- public void testInvalidParseModelOcciAction() {
- TextParser instance = new TextParser();
- Headers headers = createDefaultHeaders();
-
- //action with illegal scheme
- try {
- headers.add("Category", "Category: restart;scheme=\"/\\/_)#@564...,p,pkl\";class=\"action\";title=\"Restart Compute instance\";attributes=\"method\"");
- instance.parseModel(MediaType.TEXT_OCCI, null, headers);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
- }
-
- @Test
- public void testParseModelOcciAll() throws Exception {
- String categoryHeader = TestHelper.readFile(RESOURCE_PATH + "model_occi_all.txt");
- String body = null;
- Headers headers = createDefaultHeaders();
- headers.add("Category", categoryHeader);
- TextParser instance = new TextParser();
- Model expResult = populateModelWithKinds(DataGenerator.getFiveKinds(), null);
- expResult = populateModelWithMixins(DataGenerator.getFiveMixins(), expResult);
- expResult = populateModelWithActions(DataGenerator.getFiveActions(), expResult);
- Model result = instance.parseModel(MediaType.TEXT_OCCI, body, headers);
- assertEquals(expResult, result);
- assertKindsEqual(expResult.getKinds(), result.getKinds());
- assertMixinsEqual(expResult.getMixins(), result.getMixins());
- assertActionsEqual(expResult.getActions(), result.getActions());
- }
-
- @Test
- public void testInvalidParseModelOcci() {
- TextParser instance = new TextParser();
- Headers headers = createDefaultHeaders();
-
- //missing category header
- try {
- instance.parseModel(MediaType.TEXT_OCCI, null, headers);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- try {
- headers.add("Category", "nonmatching_line");
- instance.parseModel(MediaType.TEXT_OCCI, null, headers);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //without term
- try {
- headers.add("Category", "Category: ;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\";title=\"Entity\";location=\"/entity/\";attributes=\"occi.core.id occi.core.title\"");
- instance.parseModel(MediaType.TEXT_OCCI, null, headers);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //without scheme
- try {
- headers.add("Category", "Category: entity;class=\"kind\";title=\"Entity\";location=\"/entity/\";attributes=\"occi.core.id occi.core.title\"");
- instance.parseModel(MediaType.TEXT_OCCI, null, headers);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //with empty scheme
- try {
- headers.add("Category", "Category: entity;scheme=\"\";class=\"kind\";title=\"Entity\";location=\"/entity/\";attributes=\"occi.core.id occi.core.title\"");
- instance.parseModel(MediaType.TEXT_OCCI, null, headers);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //without class
- try {
- headers.add("Category", "Category: entity;scheme=\"http://schemas.ogf.org/occi/core#\";title=\"Entity\";location=\"/entity/\";attributes=\"occi.core.id occi.core.title\"");
- instance.parseModel(MediaType.TEXT_OCCI, null, headers);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //with empty class
- try {
- headers.add("Category", "Category: entity;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"\";title=\"Entity\";location=\"/entity/\";attributes=\"occi.core.id occi.core.title\"");
- instance.parseModel(MediaType.TEXT_OCCI, null, headers);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //with unknown class
- try {
- headers.add("Category", "Category: entity;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"nonexisting_class\";title=\"Entity\";location=\"/entity/\";attributes=\"occi.core.id occi.core.title\"");
- instance.parseModel(MediaType.TEXT_OCCI, null, headers);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- }
-
- @Test
- public void testParseLocationsPlain() throws Exception {
- String body = TestHelper.readFile(RESOURCE_PATH + "locations_plain.txt");
- Headers headers = null;
- TextParser instance = new TextParser();
- List<URI> expResult = DataGenerator.getLocations();
- List<URI> result = instance.parseLocations(MediaType.TEXT_PLAIN, body, headers);
- assertEquals(expResult, result);
- }
-
- @Test
- public void testInvalidParseLocationsPlain() {
- TextParser instance = new TextParser();
- String body = "X-OCCI-Location: http://rocci-server-1-1-x.herokuapp.com:80/compute/87f3bfc3-42d4-4474-b45c-757e55e093e9\n"
- + "!@#$%^&||}?:{}|\n"
- + "X-OCCI-Location: http://rocci-server-1-1-x.herokuapp.com:80/compute/17679ebd-975f-4ea0-b42b-47405178c360";
-
- try {
- instance.parseLocations(MediaType.TEXT_PLAIN, body, null);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
- }
-
- @Test
- public void testParseLocationsUriList() throws Exception {
- String body = TestHelper.readFile(RESOURCE_PATH + "locations_uri-list.txt");
- Headers headers = null;
- TextParser instance = new TextParser();
- List<URI> expResult = DataGenerator.getLocations();
- List<URI> result = instance.parseLocations(MediaType.TEXT_URI_LIST, body, headers);
- assertEquals(expResult, result);
- }
-
- @Test
- public void testInvalidParseLocationsUriList() {
- TextParser instance = new TextParser();
- String body = "http://rocci-server-1-1-x.herokuapp.com:80/compute/87f3bfc3-42d4-4474-b45c-757e55e093e9\n"
- + "!@#$%^&||}?:{}|\n"
- + "http://rocci-server-1-1-x.herokuapp.com:80/compute/17679ebd-975f-4ea0-b42b-47405178c360";
-
- try {
- instance.parseLocations(MediaType.TEXT_URI_LIST, body, null);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
- }
-
- @Test
- public void testParseLocationsOcci() throws Exception {
- String body = null;
- Headers headers = createDefaultHeaders();
- headers.add("Location", "http://rocci-server-1-1-x.herokuapp.com:80/compute/87f3bfc3-42d4-4474-b45c-757e55e093e9,http://rocci-server-1-1-x.herokuapp.com:80/compute/17679ebd-975f-4ea0-b42b-47405178c360,http://rocci-server-1-1-x.herokuapp.com:80/compute/509afbd3-abff-427c-9b25-7913d17e5102");
- TextParser instance = new TextParser();
- List<URI> expResult = DataGenerator.getLocations();
- List<URI> result = instance.parseLocations(MediaType.TEXT_OCCI, body, headers);
- assertEquals(expResult, result);
- }
-
- @Test
- public void testInvalidParseLocationsOcci() {
- TextParser instance = new TextParser();
- Headers headers = createDefaultHeaders();
-
- try {
- instance.parseLocations(MediaType.TEXT_OCCI, null, headers);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- try {
- headers.add("Location", "http://rocci-server-1-1-x.herokuapp.com:80/compute/87f3bfc3-42d4-4474-b45c-757e55e093e9,!@#$%^&||}?:{}|,http://rocci-server-1-1-x.herokuapp.com:80/compute/509afbd3-abff-427c-9b25-7913d17e5102");
- instance.parseLocations(MediaType.TEXT_OCCI, null, headers);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
- }
-
- @Test
- public void testParseCollectionPlainResource() throws Exception {
- String body = TestHelper.readFile(RESOURCE_PATH + "collection_plain_resource.txt");
- Headers headers = null;
- TextParser instance = new TextParser();
-
- Collection expResult = new Collection();
- expResult.addResource(DataGenerator.getResource());
- Collection result = instance.parseCollection(MediaType.TEXT_PLAIN, body, headers, CollectionType.RESOURCE);
- assertEquals(expResult, result);
- assertResourcesEqual(expResult.getResources(), result.getResources());
- }
-
- @Test
- public void testInvalidParseCollectionPlainRersource() {
- TextParser instance = new TextParser();
- String body;
-
- try {
- body = "no kind specification on the first line";
- instance.parseCollection(MediaType.TEXT_PLAIN, body, null, CollectionType.RESOURCE);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //unknown class
- try {
- body = "Category: compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"unknown_class\";location=\"/compute/\";title=\"compute resource\"";
- instance.parseCollection(MediaType.TEXT_PLAIN, body, null, CollectionType.RESOURCE);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //invalid kind scheme
- try {
- body = "Category: compute;scheme=\"!@#$%^&||}?:{}|\";class=\"kind\";location=\"/compute/\";title=\"compute resource\"";
- instance.parseCollection(MediaType.TEXT_PLAIN, body, null, CollectionType.RESOURCE);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //invalid kind location
- try {
- body = "Category: compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"!@#$%^&||}?:{}|\";title=\"compute resource\"";
- instance.parseCollection(MediaType.TEXT_PLAIN, body, null, CollectionType.RESOURCE);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //unknown class
- try {
- body = "Category: compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\";title=\"compute resource\"\n"
- + "Category: os_tpl;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"unknown_class\";title=\"Operating System Template\";location=\"/mixins/os_tpl/\"";
- instance.parseCollection(MediaType.TEXT_PLAIN, body, null, CollectionType.RESOURCE);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //invalid mixin scheme
- try {
- body = "Category: compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\";title=\"compute resource\"\n"
- + "Category: os_tpl;scheme=\"!@#$%^&||}?:{}|\";class=\"mixin\";title=\"Operating System Template\";location=\"/mixins/os_tpl/\"";
- instance.parseCollection(MediaType.TEXT_PLAIN, body, null, CollectionType.RESOURCE);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //invalid mixin location
- try {
- body = "Category: compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\";title=\"compute resource\"\n"
- + "Category: os_tpl;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"mixin\";title=\"Operating System Template\";location=\"!@#$%^&||}?:{}|\"";
- instance.parseCollection(MediaType.TEXT_PLAIN, body, null, CollectionType.RESOURCE);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //missing action link rel
- try {
- body = "Category: compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\";title=\"compute resource\"\n"
- + "Link: </compute/123?action=start>";
- instance.parseCollection(MediaType.TEXT_PLAIN, body, null, CollectionType.RESOURCE);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //invalid action link relation
- try {
- body = "Category: compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\";title=\"compute resource\"\n"
- + "Link: </compute/123?action=start>;rel=\"!@$%^&||}?:{}|\"";
- instance.parseCollection(MediaType.TEXT_PLAIN, body, null, CollectionType.RESOURCE);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //invalid link category
- try {
- body = "Category: compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\";title=\"compute resource\"\n"
- + "Link: </network/123>;rel=\"http://schemas.ogf.org/occi/infrastructure#network\";self=\"/link/networkinterface/456\";category=\"!@$%^&||}?:{}|\";occi.networkinterface.interface=\"eth0\";occi.networkinterface.mac=\"00:11:22:33:44:55\";occi.networkinterface.state=\"active\";";
- instance.parseCollection(MediaType.TEXT_PLAIN, body, null, CollectionType.RESOURCE);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //invalid link location
- try {
- body = "Category: compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\";title=\"compute resource\"\n"
- + "Link: </network/123>;rel=\"http://schemas.ogf.org/occi/infrastructure#network\";self=\"!@$%^&||}?:{}|\";category=\"http://schemas.ogf.org/occi/infrastructure#networkinterface\";occi.networkinterface.interface=\"eth0\";occi.networkinterface.mac=\"00:11:22:33:44:55\";occi.networkinterface.state=\"active\";";
- instance.parseCollection(MediaType.TEXT_PLAIN, body, null, CollectionType.RESOURCE);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //missing id attribute
- try {
- body = "Category: compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\";title=\"compute resource\"\n"
- + "X-OCCI-Attribute: occi.core.title=\"compute1\"";
- instance.parseCollection(MediaType.TEXT_PLAIN, body, null, CollectionType.RESOURCE);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
- }
-
- @Test
- public void testParseCollectionPlainLink() throws Exception {
- String body = TestHelper.readFile(RESOURCE_PATH + "collection_plain_link.txt");
- Headers headers = null;
- TextParser instance = new TextParser();
-
- Collection expResult = new Collection();
- expResult.addLink(DataGenerator.getLink());
- Collection result = instance.parseCollection(MediaType.TEXT_PLAIN, body, headers, CollectionType.LINK);
- assertEquals(expResult, result);
- assertLinksEqual(expResult.getLinks(), result.getLinks());
- }
-
- @Test
- public void testInvalidParseCollectionPlainLink() {
- TextParser instance = new TextParser();
- String body;
-
- try {
- body = "no kind specification on the first line";
- instance.parseCollection(MediaType.TEXT_PLAIN, body, null, CollectionType.LINK);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //unknown class
- try {
- body = "Category: networkinterface;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"unknown_class\";";
- instance.parseCollection(MediaType.TEXT_PLAIN, body, null, CollectionType.LINK);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //invalid kind scheme
- try {
- body = "Category: networkinterface;scheme=\"!@$%^&||}?:{}|\";class=\"kind\";";
- instance.parseCollection(MediaType.TEXT_PLAIN, body, null, CollectionType.LINK);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //unknown class
- try {
- body = "Category: networkinterface;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";\n"
- + "Category: os_tpl;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"unknown_class\";title=\"Operating System Template\";location=\"/mixins/os_tpl/\"";
- instance.parseCollection(MediaType.TEXT_PLAIN, body, null, CollectionType.LINK);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //invalid mixin scheme
- try {
- body = "Category: networkinterface;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";\n"
- + "Category: os_tpl;scheme=\"!@#$%^&||}?:{}|\";class=\"mixin\";title=\"Operating System Template\";location=\"/mixins/os_tpl/\"";
- instance.parseCollection(MediaType.TEXT_PLAIN, body, null, CollectionType.LINK);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //invalid mixin location
- try {
- body = "Category: networkinterface;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";\n"
- + "Category: os_tpl;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"mixin\";title=\"Operating System Template\";location=\"!@#$%^&||}?:{}|\"";
- instance.parseCollection(MediaType.TEXT_PLAIN, body, null, CollectionType.LINK);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //missing id attribute
- try {
- body = "Category: compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\";title=\"compute resource\"\n"
- + "X-OCCI-Attribute: occi.networkinterface.interface=\"eth0\";";
- instance.parseCollection(MediaType.TEXT_PLAIN, body, null, CollectionType.LINK);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
- }
-
- @Test
- public void testParseCollectionPlainAction() throws Exception {
- String body = TestHelper.readFile(RESOURCE_PATH + "collection_plain_action.txt");
- Headers headers = null;
- TextParser instance = new TextParser();
-
- Collection expResult = new Collection();
- expResult.addAction(DataGenerator.getAction());
- Collection result = instance.parseCollection(MediaType.TEXT_PLAIN, body, headers, CollectionType.ACTION);
- assertEquals(expResult, result);
- assertActionInstancesEqual(expResult.getActions(), result.getActions());
- }
-
- @Test
- public void testInvalidParseCollectionPlainAction() {
- TextParser instance = new TextParser();
- String body;
-
- try {
- body = "no action specification on the first line";
- instance.parseCollection(MediaType.TEXT_PLAIN, body, null, CollectionType.ACTION);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //unknown class
- try {
- body = "Category: backup;scheme=\"http://schemas.ogf.org/occi/infrastructure/storage/action#\";class=\"unknown_class\";title=\"Backup Storage\"";
- instance.parseCollection(MediaType.TEXT_PLAIN, body, null, CollectionType.ACTION);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //invalid action scheme
- try {
- body = "Category: backup;scheme=\"!@#$%^&||}?:{}|\";class=\"action\";title=\"Backup Storage\"";
- instance.parseCollection(MediaType.TEXT_PLAIN, body, null, CollectionType.ACTION);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
- }
-
- @Test
- public void testParseCollectionOcciResource() throws Exception {
- String categoryHeader = TestHelper.readFile(RESOURCE_PATH + "collection_occi_resource_category.txt");
- String attributeHeader = TestHelper.readFile(RESOURCE_PATH + "collection_occi_resource_attribute.txt");
- String linkHeader = TestHelper.readFile(RESOURCE_PATH + "collection_occi_resource_link.txt");
- String body = null;
- Headers headers = createDefaultHeaders();
- headers.add("Category", categoryHeader);
- headers.add("X-Occi-Attribute", attributeHeader);
- headers.add("Link", linkHeader);
- TextParser instance = new TextParser();
- Collection expResult = new Collection();
- expResult.addResource(DataGenerator.getResource());
- Collection result = instance.parseCollection(MediaType.TEXT_OCCI, body, headers, CollectionType.RESOURCE);
- assertEquals(expResult, result);
- assertResourcesEqual(expResult.getResources(), result.getResources());
- }
-
- @Test
- public void testInvalidParseCollectionOcciResource() {
- TextParser instance = new TextParser();
- Headers headers = new Headers();
-
- try {
- headers.add("Category", "no kind specification on the first line");
- instance.parseCollection(MediaType.TEXT_OCCI, null, headers, CollectionType.RESOURCE);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //unknown class
- try {
- headers.add("Category", "compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"unknown_class\";location=\"/compute/\";title=\"compute resource\"");
- instance.parseCollection(MediaType.TEXT_OCCI, null, headers, CollectionType.RESOURCE);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //invalid kind scheme
- try {
- headers.add("Category", "compute;scheme=\"!@#$%^&||}?:{}|\";class=\"kind\";location=\"/compute/\";title=\"compute resource\"");
- instance.parseCollection(MediaType.TEXT_OCCI, null, headers, CollectionType.RESOURCE);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //invalid kind location
- try {
- headers.add("Category", "compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"!@#$%^&||}?:{}|\";title=\"compute resource\"");
- instance.parseCollection(MediaType.TEXT_OCCI, null, headers, CollectionType.RESOURCE);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //unknown class
- try {
- headers.add("Category", "compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\";title=\"compute resource\"\n"
- + "os_tpl;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"unknown_class\";title=\"Operating System Template\";location=\"/mixins/os_tpl/\"");
- instance.parseCollection(MediaType.TEXT_OCCI, null, headers, CollectionType.RESOURCE);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //invalid mixin scheme
- try {
- headers.add("Category", "compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\";title=\"compute resource\"\n"
- + "os_tpl;scheme=\"!@#$%^&||}?:{}|\";class=\"mixin\";title=\"Operating System Template\";location=\"/mixins/os_tpl/\"");
- instance.parseCollection(MediaType.TEXT_OCCI, null, headers, CollectionType.RESOURCE);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //invalid mixin location
- try {
- headers.add("Category", "compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\";title=\"compute resource\""
- + "os_tpl;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"mixin\";title=\"Operating System Template\";location=\"!@#$%^&||}?:{}|\"");
- instance.parseCollection(MediaType.TEXT_OCCI, null, headers, CollectionType.RESOURCE);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //missing action link rel
- try {
- headers.add("Category", "compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\";title=\"compute resource\"");
- headers.add("Link", "</compute/123?action=start>");
- instance.parseCollection(MediaType.TEXT_OCCI, null, headers, CollectionType.RESOURCE);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //invalid action link relation
- try {
- headers.add("Category", "compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\";title=\"compute resource\"");
- headers.add("Link", "</compute/123?action=start>;rel=\"!@$%^&||}?:{}|\"");
- instance.parseCollection(MediaType.TEXT_OCCI, null, headers, CollectionType.RESOURCE);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //invalid link category
- try {
- headers.add("Category", "compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\";title=\"compute resource\"");
- headers.add("Link", "</network/123>;rel=\"http://schemas.ogf.org/occi/infrastructure#network\";self=\"/link/networkinterface/456\";category=\"!@$%^&||}?:{}|\";occi.networkinterface.interface=\"eth0\";occi.networkinterface.mac=\"00:11:22:33:44:55\";occi.networkinterface.state=\"active\";");
- instance.parseCollection(MediaType.TEXT_OCCI, null, headers, CollectionType.RESOURCE);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //invalid link location
- try {
- headers.add("Category", "compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\";title=\"compute resource\"");
- headers.add("Link", "</network/123>;rel=\"http://schemas.ogf.org/occi/infrastructure#network\";self=\"!@$%^&||}?:{}|\";category=\"http://schemas.ogf.org/occi/infrastructure#networkinterface\";occi.networkinterface.interface=\"eth0\";occi.networkinterface.mac=\"00:11:22:33:44:55\";occi.networkinterface.state=\"active\";");
- instance.parseCollection(MediaType.TEXT_OCCI, null, headers, CollectionType.RESOURCE);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //missing id attribute
- try {
- headers.add("Category", "compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\";title=\"compute resource\"");
- headers.add("X-Occi-Attribute", "occi.core.title=\"compute1\"");
- instance.parseCollection(MediaType.TEXT_OCCI, null, headers, CollectionType.RESOURCE);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
- }
-
- @Test
- public void testParseCollectionOcciLink() throws Exception {
- String categoryHeader = TestHelper.readFile(RESOURCE_PATH + "collection_occi_link_category.txt");
- String attributeHeader = TestHelper.readFile(RESOURCE_PATH + "collection_occi_link_attribute.txt");
- String body = null;
- Headers headers = createDefaultHeaders();
- headers.add("Category", categoryHeader);
- headers.add("X-Occi-Attribute", attributeHeader);
- TextParser instance = new TextParser();
- Collection expResult = new Collection();
- expResult.addLink(DataGenerator.getLink());
- Collection result = instance.parseCollection(MediaType.TEXT_OCCI, body, headers, CollectionType.LINK);
- assertEquals(expResult, result);
- assertLinksEqual(expResult.getLinks(), result.getLinks());
- }
-
- @Test
- public void testInvalidParseCollectionOcciLink() {
- TextParser instance = new TextParser();
- Headers headers = new Headers();
-
- try {
- headers.add("Category", "no kind specification on the first line");
- instance.parseCollection(MediaType.TEXT_OCCI, null, headers, CollectionType.LINK);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //unknown class
- try {
- headers.add("Category", "networkinterface;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"unknown_class\";");
- instance.parseCollection(MediaType.TEXT_OCCI, null, headers, CollectionType.LINK);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //invalid kind scheme
- try {
- headers.add("Category", "networkinterface;scheme=\"!@$%^&||}?:{}|\";class=\"kind\";");
- instance.parseCollection(MediaType.TEXT_OCCI, null, headers, CollectionType.LINK);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //unknown class
- try {
- headers.add("Category", "networkinterface;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";\n"
- + "os_tpl;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"unknown_class\";title=\"Operating System Template\";location=\"/mixins/os_tpl/\"");
- instance.parseCollection(MediaType.TEXT_OCCI, null, headers, CollectionType.LINK);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //invalid mixin scheme
- try {
- headers.add("Category", "networkinterface;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";\n"
- + "os_tpl;scheme=\"!@#$%^&||}?:{}|\";class=\"mixin\";title=\"Operating System Template\";location=\"/mixins/os_tpl/\"");
- instance.parseCollection(MediaType.TEXT_OCCI, null, headers, CollectionType.LINK);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //invalid mixin location
- try {
- headers.add("Category", "networkinterface;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";\n"
- + "os_tpl;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"mixin\";title=\"Operating System Template\";location=\"!@#$%^&||}?:{}|\"");
- instance.parseCollection(MediaType.TEXT_OCCI, null, headers, CollectionType.LINK);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //missing id attribute
- try {
- headers.add("Category", "compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\";title=\"compute resource\"");
- headers.add("X-Occi-Attribute", "occi.networkinterface.interface=\"eth0\";");
- instance.parseCollection(MediaType.TEXT_OCCI, null, headers, CollectionType.LINK);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
- }
-
- @Test
- public void testParseCollectionOcciAction() throws Exception {
- String categoryHeader = TestHelper.readFile(RESOURCE_PATH + "collection_occi_action_category.txt");
- String attributeHeader = TestHelper.readFile(RESOURCE_PATH + "collection_occi_action_attribute.txt");
- String body = null;
- Headers headers = createDefaultHeaders();
- headers.add("Category", categoryHeader);
- headers.add("X-Occi-Attribute", attributeHeader);
- TextParser instance = new TextParser();
- Collection expResult = new Collection();
- expResult.addAction(DataGenerator.getAction());
- Collection result = instance.parseCollection(MediaType.TEXT_OCCI, body, headers, CollectionType.ACTION);
- assertEquals(expResult, result);
- assertActionInstancesEqual(expResult.getActions(), result.getActions());
- }
-
- @Test
- public void testInvalidParseCollectionOcciAction() {
- TextParser instance = new TextParser();
- Headers headers = new Headers();
-
- try {
- headers.add("Category", "no action specification on the first line");
- instance.parseCollection(MediaType.TEXT_OCCI, null, headers, CollectionType.ACTION);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //unknown class
- try {
- headers.add("Category", "backup;scheme=\"http://schemas.ogf.org/occi/infrastructure/storage/action#\";class=\"unknown_class\";title=\"Backup Storage\"");
- instance.parseCollection(MediaType.TEXT_OCCI, null, headers, CollectionType.ACTION);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
-
- //invalid action scheme
- try {
- headers.add("Category", "backup;scheme=\"!@#$%^&||}?:{}|\";class=\"action\";title=\"Backup Storage\"");
- instance.parseCollection(MediaType.TEXT_OCCI, null, headers, CollectionType.ACTION);
- fail();
- } catch (ParsingException ex) {
- //cool
- }
- }
-
- private void assertKindsEqual(Set<Kind> expected, Set<Kind> result) {
- assertEquals(expected.size(), result.size());
-
- List<Kind> expectedList = new ArrayList<>();
- expectedList.addAll(expected);
- Collections.sort(expectedList);
- List<Kind> resultList = new ArrayList<>();
- resultList.addAll(result);
- Collections.sort(resultList);
- for (int i = 0; i < expectedList.size(); i++) {
- assertKindDeepEquals(expectedList.get(i), resultList.get(i));
- }
- }
-
- private void assertKindDeepEquals(Kind expected, Kind result) {
- System.out.println("comparing " + expected + " with " + result);
- assertEquals(expected, result);
-
- assertEquals(expected.getTitle(), result.getTitle());
- assertEquals(expected.getLocation(), result.getLocation());
- assertEquals(expected.getRelations(), result.getRelations());
- assertAttributesEqual(expected.getAttributes(), result.getAttributes());
- }
-
- private void assertMixinsEqual(Set<Mixin> expected, Set<Mixin> result) {
- assertEquals(expected.size(), result.size());
-
- List<Mixin> expectedList = new ArrayList<>();
- expectedList.addAll(expected);
- Collections.sort(expectedList);
- List<Mixin> resultList = new ArrayList<>();
- resultList.addAll(result);
- Collections.sort(resultList);
- for (int i = 0; i < expectedList.size(); i++) {
- assertMixinDeepEquals(expectedList.get(i), resultList.get(i));
- }
- }
-
- private void assertMixinDeepEquals(Mixin expected, Mixin result) {
- System.out.println("comparing " + expected + " with " + result);
- assertEquals(expected, result);
-
- assertEquals(expected.getTitle(), result.getTitle());
- assertEquals(expected.getLocation(), result.getLocation());
- assertEquals(expected.getRelations(), result.getRelations());
- assertAttributesEqual(expected.getAttributes(), result.getAttributes());
- }
-
- private void assertActionsEqual(Set<Action> expected, Set<Action> result) {
- assertEquals(expected.size(), result.size());
-
- List<Action> expectedList = new ArrayList<>();
- expectedList.addAll(expected);
- Collections.sort(expectedList);
- List<Action> resultList = new ArrayList<>();
- resultList.addAll(result);
- Collections.sort(resultList);
- for (int i = 0; i < expectedList.size(); i++) {
- assertActionDeepEquals(expectedList.get(i), resultList.get(i));
- }
- }
-
- private void assertActionDeepEquals(Action expected, Action result) {
- System.out.println("comparing " + expected + " with " + result);
- assertEquals(expected, result);
-
- assertEquals(expected.getTitle(), result.getTitle());
- assertAttributesEqual(expected.getAttributes(), result.getAttributes());
- }
-
- private void assertActionInstancesEqual(Set<ActionInstance> expected, Set<ActionInstance> result) {
- assertEquals(expected.size(), result.size());
-
- List<ActionInstance> expectedList = new ArrayList<>();
- expectedList.addAll(expected);
- Collections.sort(expectedList);
- List<ActionInstance> resultList = new ArrayList<>();
- resultList.addAll(result);
- Collections.sort(resultList);
- for (int i = 0; i < expectedList.size(); i++) {
- assertActionInstanceDeepEquals(expectedList.get(i), resultList.get(i));
- }
- }
-
- private void assertActionInstanceDeepEquals(ActionInstance expected, ActionInstance result) {
- System.out.println("comparing " + expected + " with " + result);
- assertEquals(expected, result);
-
- assertActionDeepEquals(expected.getAction(), result.getAction());
- for (Attribute expAttr : expected.getAttributes().keySet()) {
- if (!result.getAttributes().containsKey(expAttr)) {
- fail();
- }
- assertEquals(expected.getAttributes().get(expAttr), result.getAttributes().get(expAttr));
- }
- assertEquals(expected.getAttributes(), result.getAttributes());
- }
-
- private void assertLinksEqual(Set<Link> expected, Set<Link> result) {
- assertEquals(expected.size(), result.size());
-
- List<Link> expectedList = new ArrayList<>();
- expectedList.addAll(expected);
- Collections.sort(expectedList);
- System.out.println("expected links: " + expectedList);
- List<Link> resultList = new ArrayList<>();
- resultList.addAll(result);
- Collections.sort(resultList);
- System.out.println("result links: " + resultList);
- for (int i = 0; i < expectedList.size(); i++) {
- assertLinkDeepEquals(expectedList.get(i), resultList.get(i));
- }
- }
-
- private void assertLinkDeepEquals(Link expected, Link result) {
- System.out.println("comparing " + expected + " with " + result);
- assertEquals(expected, result);
-
- assertEquals(expected.getTitle(), result.getTitle());
- assertEquals(expected.getRelation(), result.getRelation());
- assertEquals(expected.getMixins(), result.getMixins());
- assertEquals(expected.getAttributes(), result.getAttributes());
- }
-
- private void assertResourcesEqual(Set<Resource> expected, Set<Resource> result) {
- assertEquals(expected.size(), result.size());
-
- List<Resource> expectedList = new ArrayList<>();
- expectedList.addAll(expected);
- Collections.sort(expectedList);
- List<Resource> resultList = new ArrayList<>();
- resultList.addAll(result);
- Collections.sort(resultList);
- for (int i = 0; i < expectedList.size(); i++) {
- assertResourceDeepEquals(expectedList.get(i), resultList.get(i));
- }
- }
-
- private void assertResourceDeepEquals(Resource expected, Resource result) {
- System.out.println("comparing " + expected + " with " + result);
- assertEquals(expected, result);
-
- assertEquals(expected.getTitle(), result.getTitle());
- assertEquals(expected.getMixins(), result.getMixins());
- assertEquals(expected.getAttributes(), result.getAttributes());
- assertEquals(expected.getActions(), result.getActions());
- assertLinksEqual(expected.getLinks(), result.getLinks());
- }
-
- private void assertAttributesEqual(Set<Attribute> expected, Set<Attribute> result) {
- assertEquals(expected.size(), result.size());
-
- List<Attribute> expectedList = new ArrayList<>();
- expectedList.addAll(expected);
- Collections.sort(expectedList);
- List<Attribute> resultList = new ArrayList<>();
- resultList.addAll(result);
- Collections.sort(resultList);
- for (int i = 0; i < expectedList.size(); i++) {
- assertAttributeDeepEquals(expectedList.get(i), resultList.get(i));
- }
- }
-
- private void assertAttributeDeepEquals(Attribute expected, Attribute result) {
- assertEquals(expected, result);
-
- assertEquals(expected.isRequired(), result.isRequired());
- assertEquals(expected.isImmutable(), result.isImmutable());
- assertEquals(expected.getType(), result.getType());
- assertEquals(expected.getPattern(), result.getPattern());
- assertEquals(expected.getDefaultValue(), result.getDefaultValue());
- assertEquals(expected.getDescription(), result.getDescription());
- }
-}
+++ /dev/null
-# Root logger option
-log4j.rootLogger=DEBUG, stdout
-
-# Redirect log messages to console
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.Target=System.out
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
\ No newline at end of file
+++ /dev/null
-occi.core.id="87f3bfc3-42d4-4474-b45c-757e55e093e9",occi.networkinterface.interface="eth0";,occi.networkinterface.mac="00:11:22:33:44:55";,occi.networkinterface.state="active";,occi.core.source="/vms/foo/vm1",occi.core.target="/network/123"
\ No newline at end of file
+++ /dev/null
-backup;scheme="http://schemas.ogf.org/occi/infrastructure/storage/action#";class="action";title="Backup Storage"
\ No newline at end of file
+++ /dev/null
-occi.core.id="87f3bfc3-42d4-4474-b45c-757e55e093e9",occi.networkinterface.interface="eth0",occi.networkinterface.mac="00:11:22:33:44:55",occi.networkinterface.state="active",occi.core.source="/vms/foo/vm1",occi.core.target="/network/123"
\ No newline at end of file
+++ /dev/null
-networkinterface;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind",os_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin";title="Operating System Template";location="/mixins/os_tpl/",ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure/network#";class="mixin";title="IP Network Mixin";location="/mixins/ipnetwork/";attributes="occi.network.address{required} occi.network.gateway occi.network.allocation occi.network.state",resource_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin";title="Resource Template";location="/mixins/resource_tpl/",larger;scheme="https://occi.localhost/occi/infrastructure/resource_tpl#";class="mixin";title="Larger Instance - 4 cores and 10 GB of RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl";location="/mixins/larger/";attributes="occi.compute.architecture occi.compute.cores{immutable required} occi.compute.speed occi.compute.memory{immutable}",debianvm;scheme="https://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="debianvm";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl";location="/mixins/debianvm/"
\ No newline at end of file
+++ /dev/null
-occi.core.id="87f3bfc3-42d4-4474-b45c-757e55e093e9",occi.core.title="compute1",occi.compute.architecture="x86",occi.compute.hostname="compute1.example.org",occi.compute.memory=1.7,occi.compute.speed=1.0,occi.compute.state="active"
\ No newline at end of file
+++ /dev/null
-compute;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";location="/compute/";title="compute resource",os_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin";title="Operating System Template";location="/mixins/os_tpl/",ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure/network#";class="mixin";title="IP Network Mixin";location="/mixins/ipnetwork/";attributes="occi.network.address{required} occi.network.gateway occi.network.allocation occi.network.state",resource_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin";title="Resource Template";location="/mixins/resource_tpl/",larger;scheme="https://occi.localhost/occi/infrastructure/resource_tpl#";class="mixin";title="Larger Instance - 4 cores and 10 GB of RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl";location="/mixins/larger/";attributes="occi.compute.architecture occi.compute.cores{immutable required} occi.compute.speed occi.compute.memory{immutable}",debianvm;scheme="https://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="debianvm";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl";location="/mixins/debianvm/"
\ No newline at end of file
+++ /dev/null
-</network/123>;rel="http://schemas.ogf.org/occi/infrastructure#network";self="/link/networkinterface/456";category="http://schemas.ogf.org/occi/infrastructure#networkinterface";occi.networkinterface.interface="eth0";occi.networkinterface.mac="00:11:22:33:44:55";occi.networkinterface.state="active",</storage/852>;rel="http://schemas.ogf.org/occi/infrastructure#storage";self="/link/storagelink/789";category="http://schemas.ogf.org/occi/infrastructure#storagelink http://opennebula.org/occi/infrastructure#storagelink";occi.storagelink.deviceid="1234qwerty"; occi.storagelink.mountpoint="/mnt/somewhere/"; occi.storagelink.state="active",</compute/123?action=start>;rel="http://schemas.ogf.org/occi/infrastructure/compute/action#start",</compute/123?action=stop>;rel="http://schemas.ogf.org/occi/infrastructure/compute/action#stop";
\ No newline at end of file
+++ /dev/null
-CATEGORY: backup;scheme="http://schemas.ogf.org/occi/infrastructure/storage/action#";class="action";title="Backup Storage"
-X-occi-Attribute: occi.core.id="87f3bfc3-42d4-4474-b45c-757e55e093e9"
-X-OCCI-Attribute: occi.networkinterface.interface="eth0";
-X-oCcI-AtTriBute: occi.networkinterface.mac="00:11:22:33:44:55";
-X-OCCI-Attribute: occi.networkinterface.state="active";
-x-occi-attribute: occi.core.source="/vms/foo/vm1"
-X-OCCI-Attribute: occi.core.target="/network/123"
\ No newline at end of file
+++ /dev/null
-Category: networkinterface;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";
-Category: os_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin";title="Operating System Template";location="/mixins/os_tpl/"
-Category: ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure/network#";class="mixin";title="IP Network Mixin";location="/mixins/ipnetwork/";attributes="occi.network.address{required} occi.network.gateway occi.network.allocation occi.network.state"
-Category: resource_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin";title="Resource Template";location="/mixins/resource_tpl/"
-Category: larger;scheme="https://occi.localhost/occi/infrastructure/resource_tpl#";class="mixin";title="Larger Instance - 4 cores and 10 GB of RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl";location="/mixins/larger/";attributes="occi.compute.architecture occi.compute.cores{immutable required} occi.compute.speed occi.compute.memory{immutable}"
-Category: debianvm;scheme="https://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="debianvm";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl";location="/mixins/debianvm/"
-X-OCCI-Attribute: occi.core.id="87f3bfc3-42d4-4474-b45c-757e55e093e9"
-X-OCCI-Attribute: occi.networkinterface.interface="eth0";
-X-OCCI-Attribute: occi.networkinterface.mac="00:11:22:33:44:55";
-X-OCCI-Attribute: occi.networkinterface.state="active";
-X-OCCI-Attribute: occi.core.source="/vms/foo/vm1"
-X-OCCI-Attribute: occi.core.target="/network/123"
+++ /dev/null
-Category: compute;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";location="/compute/";title="compute resource"
-Category: os_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin";title="Operating System Template";location="/mixins/os_tpl/"
-Category: ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure/network#";class="mixin";title="IP Network Mixin";location="/mixins/ipnetwork/";attributes="occi.network.address{required} occi.network.gateway occi.network.allocation occi.network.state"
-CATEGORY: resource_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin";title="Resource Template";location="/mixins/resource_tpl/"
-category: larger;scheme="https://occi.localhost/occi/infrastructure/resource_tpl#";class="mixin";title="Larger Instance - 4 cores and 10 GB of RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl";location="/mixins/larger/";attributes="occi.compute.architecture occi.compute.cores{immutable required} occi.compute.speed occi.compute.memory{immutable}"
-Category: debianvm;scheme="https://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="debianvm";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl";location="/mixins/debianvm/"
-X-OCCI-Attribute: occi.core.id="87f3bfc3-42d4-4474-b45c-757e55e093e9"
-X-OCCI-Attribute: occi.core.title="compute1"
-X-OCCI-Attribute: occi.compute.architecture="x86"
-X-OCCI-Attribute: occi.compute.hostname="compute1.example.org"
-X-OCCI-Attribute: occi.compute.memory=1.7
-X-OCCI-Attribute: occi.compute.speed=1.0
-X-OCCI-Attribute: occi.compute.state="active"
-LINK: </network/123>;rel="http://schemas.ogf.org/occi/infrastructure#network";self="/link/networkinterface/456";category="http://schemas.ogf.org/occi/infrastructure#networkinterface";occi.networkinterface.interface="eth0";occi.networkinterface.mac="00:11:22:33:44:55";occi.networkinterface.state="active";
-link: </storage/852>;rel="http://schemas.ogf.org/occi/infrastructure#storage";self="/link/storagelink/789";category="http://schemas.ogf.org/occi/infrastructure#storagelink http://opennebula.org/occi/infrastructure#storagelink";occi.storagelink.deviceid="1234qwerty"; occi.storagelink.mountpoint="/mnt/somewhere/"; occi.storagelink.state="active";
-Link: </compute/123?action=start>;rel="http://schemas.ogf.org/occi/infrastructure/compute/action#start"
-Link: </compute/123?action=stop>;rel="http://schemas.ogf.org/occi/infrastructure/compute/action#stop"
\ No newline at end of file
+++ /dev/null
-X-OCCI-Location: http://rocci-server-1-1-x.herokuapp.com:80/compute/87f3bfc3-42d4-4474-b45c-757e55e093e9
-X-OCCI-Location: http://rocci-server-1-1-x.herokuapp.com:80/compute/17679ebd-975f-4ea0-b42b-47405178c360
-X-OCCI-Location: http://rocci-server-1-1-x.herokuapp.com:80/compute/509afbd3-abff-427c-9b25-7913d17e5102
\ No newline at end of file
+++ /dev/null
-http://rocci-server-1-1-x.herokuapp.com:80/compute/87f3bfc3-42d4-4474-b45c-757e55e093e9
-http://rocci-server-1-1-x.herokuapp.com:80/compute/17679ebd-975f-4ea0-b42b-47405178c360
-http://rocci-server-1-1-x.herokuapp.com:80/compute/509afbd3-abff-427c-9b25-7913d17e5102
\ No newline at end of file
+++ /dev/null
-restart;scheme="http://schemas.ogf.org/occi/infrastructure/compute/action#";class="action";title="Restart Compute instance";attributes="method",suspend;scheme="http://schemas.ogf.org/occi/infrastructure/compute/action#";class="action";title="Suspend Compute instance";attributes="method",up;scheme="http://schemas.ogf.org/occi/infrastructure/network/action#";class="action";title="Activate network",down;scheme="http://schemas.ogf.org/occi/infrastructure/network/action#up";class="action";title="Deactivate network",backup;scheme="http://schemas.ogf.org/occi/infrastructure/storage/action#";class="action";title="Backup Storage"
\ No newline at end of file
+++ /dev/null
-up;scheme="http://schemas.ogf.org/occi/infrastructure/network/action#";class="action"
\ No newline at end of file
+++ /dev/null
-entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="Entity";location="/entity/";attributes="occi.core.id occi.core.title",resource;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="Resource";rel="http://schemas.ogf.org/occi/core#entity";location="/resource/";attributes="occi.core.summary",link;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="Link";rel="http://schemas.ogf.org/occi/core#entity";location="/link/";attributes="occi.core.target occi.core.source",compute;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";title="Compute Resource";rel="http://schemas.ogf.org/occi/core#resource";location="/compute/";attributes="occi.compute.architecture{immutable} occi.compute.cores occi.compute.hostname occi.compute.speed occi.compute.memory occi.compute.state";actions="http://schemas.ogf.org/occi/infrastructure/compute/action#start http://schemas.ogf.org/occi/infrastructure/compute/action#stop http://schemas.ogf.org/occi/infrastructure/compute/action#restart http://schemas.ogf.org/occi/infrastructure/compute/action#suspend",storagelink;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";title="Storage Link";rel="http://schemas.ogf.org/occi/core#link";location="/storagelink/";attributes="occi.storagelink.deviceid{required} occi.storagelink.mountpoint occi.storagelink.state{required immutable}",os_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin";title="Operating System Template";location="/mixins/os_tpl/",ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure/network#";class="mixin";title="IP Network Mixin";location="/mixins/ipnetwork/";attributes="occi.network.address{required} occi.network.gateway occi.network.allocation occi.network.state",resource_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin";title="Resource Template";location="/mixins/resource_tpl/",larger;scheme="https://occi.localhost/occi/infrastructure/resource_tpl#";class="mixin";title="Larger Instance - 4 cores and 10 GB of RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl";location="/mixins/larger/";attributes="occi.compute.architecture occi.compute.cores{immutable required} occi.compute.speed occi.compute.memory{immutable}",debianvm;scheme="https://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="debianvm";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl";location="/mixins/debianvm/",restart;scheme="http://schemas.ogf.org/occi/infrastructure/compute/action#";class="action";title="Restart Compute instance";attributes="method",suspend;scheme="http://schemas.ogf.org/occi/infrastructure/compute/action#";class="action";title="Suspend Compute instance";attributes="method",up;scheme="http://schemas.ogf.org/occi/infrastructure/network/action#";class="action";title="Activate network",down;scheme="http://schemas.ogf.org/occi/infrastructure/network/action#up";class="action";title="Deactivate network",backup;scheme="http://schemas.ogf.org/occi/infrastructure/storage/action#";class="action";title="Backup Storage"
\ No newline at end of file
+++ /dev/null
-entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="Entity";location="/entity/";attributes="occi.core.id occi.core.title",resource;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="Resource";rel="http://schemas.ogf.org/occi/core#entity";location="/resource/";attributes="occi.core.summary",link;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="Link";rel="http://schemas.ogf.org/occi/core#entity";location="/link/";attributes="occi.core.target occi.core.source",compute;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";title="Compute Resource";rel="http://schemas.ogf.org/occi/core#resource";location="/compute/";attributes="occi.compute.architecture{immutable} occi.compute.cores occi.compute.hostname occi.compute.speed occi.compute.memory occi.compute.state";actions="http://schemas.ogf.org/occi/infrastructure/compute/action#start http://schemas.ogf.org/occi/infrastructure/compute/action#stop http://schemas.ogf.org/occi/infrastructure/compute/action#restart http://schemas.ogf.org/occi/infrastructure/compute/action#suspend",storagelink;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";title="Storage Link";rel="http://schemas.ogf.org/occi/core#link";location="/storagelink/";attributes="occi.storagelink.deviceid{required} occi.storagelink.mountpoint occi.storagelink.state{required immutable}"
\ No newline at end of file
+++ /dev/null
-entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";location="/entity/"
\ No newline at end of file
+++ /dev/null
-os_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin";title="Operating System Template";location="/mixins/os_tpl/",ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure/network#";class="mixin";title="IP Network Mixin";location="/mixins/ipnetwork/";attributes="occi.network.address{required} occi.network.gateway occi.network.allocation occi.network.state",resource_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin";title="Resource Template";location="/mixins/resource_tpl/",larger;scheme="https://occi.localhost/occi/infrastructure/resource_tpl#";class="mixin";title="Larger Instance - 4 cores and 10 GB of RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl";location="/mixins/larger/";attributes="occi.compute.architecture occi.compute.cores{immutable required} occi.compute.speed occi.compute.memory{immutable}",debianvm;scheme="https://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="debianvm";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl";location="/mixins/debianvm/"
\ No newline at end of file
+++ /dev/null
-os_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin";location="/mixins/os_tpl/"
\ No newline at end of file
+++ /dev/null
-Category: restart;scheme="http://schemas.ogf.org/occi/infrastructure/compute/action#";class="action";title="Restart Compute instance";attributes="method"
-Category: suspend;scheme="http://schemas.ogf.org/occi/infrastructure/compute/action#";class="action";title="Suspend Compute instance";attributes="method"
-Category: up;scheme="http://schemas.ogf.org/occi/infrastructure/network/action#";class="action";title="Activate network"
-Category: down;scheme="http://schemas.ogf.org/occi/infrastructure/network/action#up";class="action";title="Deactivate network"
-Category: backup;scheme="http://schemas.ogf.org/occi/infrastructure/storage/action#";class="action";title="Backup Storage"
\ No newline at end of file
+++ /dev/null
-category: up;scheme="http://schemas.ogf.org/occi/infrastructure/network/action#";class="action"
\ No newline at end of file
+++ /dev/null
-Category: entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="Entity";location="/entity/";attributes="occi.core.id occi.core.title"
-Category: resource;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="Resource";rel="http://schemas.ogf.org/occi/core#entity";location="/resource/";attributes="occi.core.summary"
-Category: link;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="Link";rel="http://schemas.ogf.org/occi/core#entity";location="/link/";attributes="occi.core.target occi.core.source"
-Category: compute;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";title="Compute Resource";rel="http://schemas.ogf.org/occi/core#resource";location="/compute/";attributes="occi.compute.architecture{immutable} occi.compute.cores occi.compute.hostname occi.compute.speed occi.compute.memory occi.compute.state";actions="http://schemas.ogf.org/occi/infrastructure/compute/action#start http://schemas.ogf.org/occi/infrastructure/compute/action#stop http://schemas.ogf.org/occi/infrastructure/compute/action#restart http://schemas.ogf.org/occi/infrastructure/compute/action#suspend"
-category: storagelink;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";title="Storage Link";rel="http://schemas.ogf.org/occi/core#link";location="/storagelink/";attributes="occi.storagelink.deviceid{required} occi.storagelink.mountpoint occi.storagelink.state{required immutable}"
-Category: os_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin";title="Operating System Template";location="/mixins/os_tpl/"
-Category: ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure/network#";class="mixin";title="IP Network Mixin";location="/mixins/ipnetwork/";attributes="occi.network.address{required} occi.network.gateway occi.network.allocation occi.network.state"
-Category: resource_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin";title="Resource Template";location="/mixins/resource_tpl/"
-Category: larger;scheme="https://occi.localhost/occi/infrastructure/resource_tpl#";class="mixin";title="Larger Instance - 4 cores and 10 GB of RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl";location="/mixins/larger/";attributes="occi.compute.architecture occi.compute.cores{immutable required} occi.compute.speed occi.compute.memory{immutable}"
-cAtEgOrY: debianvm;scheme="https://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="debianvm";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl";location="/mixins/debianvm/"
-Category: restart;scheme="http://schemas.ogf.org/occi/infrastructure/compute/action#";class="action";title="Restart Compute instance";attributes="method"
-Category: suspend;scheme="http://schemas.ogf.org/occi/infrastructure/compute/action#";class="action";title="Suspend Compute instance";attributes="method"
-Category: up;scheme="http://schemas.ogf.org/occi/infrastructure/network/action#";class="action";title="Activate network"
-Category: down;scheme="http://schemas.ogf.org/occi/infrastructure/network/action#up";class="action";title="Deactivate network"
-Category: backup;scheme="http://schemas.ogf.org/occi/infrastructure/storage/action#";class="action";title="Backup Storage"
\ No newline at end of file
+++ /dev/null
-Category: entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="Entity";location="/entity/";attributes="occi.core.id occi.core.title"
-Category: resource;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="Resource";rel="http://schemas.ogf.org/occi/core#entity";location="/resource/";attributes="occi.core.summary"
-Category: link;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="Link";rel="http://schemas.ogf.org/occi/core#entity";location="/link/";attributes="occi.core.target occi.core.source"
-Category: compute;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";title="Compute Resource";rel="http://schemas.ogf.org/occi/core#resource";location="/compute/";attributes="occi.compute.architecture{immutable} occi.compute.cores occi.compute.hostname occi.compute.speed occi.compute.memory occi.compute.state";actions="http://schemas.ogf.org/occi/infrastructure/compute/action#start http://schemas.ogf.org/occi/infrastructure/compute/action#stop http://schemas.ogf.org/occi/infrastructure/compute/action#restart http://schemas.ogf.org/occi/infrastructure/compute/action#suspend"
-Category: storagelink;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";title="Storage Link";rel="http://schemas.ogf.org/occi/core#link";location="/storagelink/";attributes="occi.storagelink.deviceid{required} occi.storagelink.mountpoint occi.storagelink.state{required immutable}"
\ No newline at end of file
+++ /dev/null
-Category: entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";location="/entity/"
\ No newline at end of file
+++ /dev/null
-Category: os_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin";title="Operating System Template";location="/mixins/os_tpl/"
-Category: ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure/network#";class="mixin";title="IP Network Mixin";location="/mixins/ipnetwork/";attributes="occi.network.address{required} occi.network.gateway occi.network.allocation occi.network.state"
-Category: resource_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin";title="Resource Template";location="/mixins/resource_tpl/"
-Category: larger;scheme="https://occi.localhost/occi/infrastructure/resource_tpl#";class="mixin";title="Larger Instance - 4 cores and 10 GB of RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl";location="/mixins/larger/";attributes="occi.compute.architecture occi.compute.cores{immutable required} occi.compute.speed occi.compute.memory{immutable}"
-Category: debianvm;scheme="https://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="debianvm";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl";location="/mixins/debianvm/"
\ No newline at end of file
+++ /dev/null
-Category: os_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin";location="/mixins/os_tpl/"
\ No newline at end of file
+++ /dev/null
-occi.core.id="87f3bfc3-42d4-4474-b45c-757e55e093e9"
-occi.core.source="/vms/foo/vm1"
-occi.core.target="/network/123"
-occi.networkinterface.interface="eth0"
-occi.networkinterface.mac="00:11:22:33:44:55"
-occi.networkinterface.state="active"
\ No newline at end of file
+++ /dev/null
-backup;scheme="http://schemas.ogf.org/occi/infrastructure/storage/action#";class="action";title="Backup Storage";
\ No newline at end of file
+++ /dev/null
-Category: backup;scheme="http://schemas.ogf.org/occi/infrastructure/storage/action#";class="action";title="Backup Storage";
-X-OCCI-Attribute: occi.core.id="87f3bfc3-42d4-4474-b45c-757e55e093e9"
-X-OCCI-Attribute: occi.core.source="/vms/foo/vm1"
-X-OCCI-Attribute: occi.core.target="/network/123"
-X-OCCI-Attribute: occi.networkinterface.interface="eth0"
-X-OCCI-Attribute: occi.networkinterface.mac="00:11:22:33:44:55"
-X-OCCI-Attribute: occi.networkinterface.state="active"
\ No newline at end of file
+++ /dev/null
-</network/123>;rel="http://schemas.ogf.org/occi/infrastructure#network";category="http://schemas.ogf.org/occi/infrastructure#networkinterface";occi.core.id=456;occi.core.target="/network/123";
-</network/123>;rel="http://schemas.ogf.org/occi/infrastructure#network";self="/link/networkinterface/456";category="http://schemas.ogf.org/occi/infrastructure#networkinterface";occi.core.id=456;occi.core.target="/network/123";
-</network/123>;rel="http://schemas.ogf.org/occi/infrastructure#network";category="http://schemas.ogf.org/occi/infrastructure#networkinterface";occi.core.id=456;occi.core.target="/network/123";occi.networkinterface.interface="eth0";occi.networkinterface.mac="00:11:22:33:44:55";occi.networkinterface.state="active";
-</network/123>;rel="http://schemas.ogf.org/occi/infrastructure#network";self="/link/networkinterface/456";category="http://schemas.ogf.org/occi/infrastructure#networkinterface";occi.core.id=456;occi.core.target="/network/123";occi.networkinterface.interface="eth0";occi.networkinterface.mac="00:11:22:33:44:55";occi.networkinterface.state="active";
+++ /dev/null
-Link: </network/123>;rel="http://schemas.ogf.org/occi/infrastructure#network";category="http://schemas.ogf.org/occi/infrastructure#networkinterface";occi.core.id=456;occi.core.target="/network/123";
-Link: </network/123>;rel="http://schemas.ogf.org/occi/infrastructure#network";self="/link/networkinterface/456";category="http://schemas.ogf.org/occi/infrastructure#networkinterface";occi.core.id=456;occi.core.target="/network/123";
-Link: </network/123>;rel="http://schemas.ogf.org/occi/infrastructure#network";category="http://schemas.ogf.org/occi/infrastructure#networkinterface";occi.core.id=456;occi.core.target="/network/123";occi.networkinterface.interface="eth0";occi.networkinterface.mac="00:11:22:33:44:55";occi.networkinterface.state="active";
-Link: </network/123>;rel="http://schemas.ogf.org/occi/infrastructure#network";self="/link/networkinterface/456";category="http://schemas.ogf.org/occi/infrastructure#networkinterface";occi.core.id=456;occi.core.target="/network/123";occi.networkinterface.interface="eth0";occi.networkinterface.mac="00:11:22:33:44:55";occi.networkinterface.state="active";
+++ /dev/null
-entity;scheme="http://schemas.ogf.org/occi/core#";class="kind"
-entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="Entity"
-entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";location="/entity/"
-entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";attributes="occi.core.id occi.core.title"
-entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";actions="http://schemas.ogf.org/occi/infrastructure/compute/action#start http://schemas.ogf.org/occi/infrastructure/compute/action#stop"
-entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="Entity";location="/entity/";attributes="occi.core.id occi.core.title";actions="http://schemas.ogf.org/occi/infrastructure/compute/action#start http://schemas.ogf.org/occi/infrastructure/compute/action#stop"
-entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="Entity";location="/entity/";attributes="occi.core.id{required} occi.core.title";actions="http://schemas.ogf.org/occi/infrastructure/compute/action#start http://schemas.ogf.org/occi/infrastructure/compute/action#stop"
-entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="Entity";location="/entity/";attributes="occi.core.id{required immutable} occi.core.title";actions="http://schemas.ogf.org/occi/infrastructure/compute/action#start http://schemas.ogf.org/occi/infrastructure/compute/action#stop"
-entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="Entity";location="/entity/";attributes="occi.core.id{required immutable} occi.core.title{immutable}";actions="http://schemas.ogf.org/occi/infrastructure/compute/action#start http://schemas.ogf.org/occi/infrastructure/compute/action#stop"
\ No newline at end of file
+++ /dev/null
-Category: entity;scheme="http://schemas.ogf.org/occi/core#";class="kind"
-Category: entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="Entity"
-Category: entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";location="/entity/"
-Category: entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";attributes="occi.core.id occi.core.title"
-Category: entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";actions="http://schemas.ogf.org/occi/infrastructure/compute/action#start http://schemas.ogf.org/occi/infrastructure/compute/action#stop"
-Category: entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="Entity";location="/entity/";attributes="occi.core.id occi.core.title";actions="http://schemas.ogf.org/occi/infrastructure/compute/action#start http://schemas.ogf.org/occi/infrastructure/compute/action#stop"
-Category: entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="Entity";location="/entity/";attributes="occi.core.id{required} occi.core.title";actions="http://schemas.ogf.org/occi/infrastructure/compute/action#start http://schemas.ogf.org/occi/infrastructure/compute/action#stop"
-Category: entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="Entity";location="/entity/";attributes="occi.core.id{required immutable} occi.core.title";actions="http://schemas.ogf.org/occi/infrastructure/compute/action#start http://schemas.ogf.org/occi/infrastructure/compute/action#stop"
-Category: entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="Entity";location="/entity/";attributes="occi.core.id{required immutable} occi.core.title{immutable}";actions="http://schemas.ogf.org/occi/infrastructure/compute/action#start http://schemas.ogf.org/occi/infrastructure/compute/action#stop"
\ No newline at end of file
+++ /dev/null
-occi.compute.architecture="x86"
-occi.compute.hostname="compute1.example.org"
-occi.compute.memory=1.7
-occi.compute.speed=1.0
-occi.compute.state="active"
-occi.core.id="87f3bfc3-42d4-4474-b45c-757e55e093e9"
-occi.core.title="compute1"
\ No newline at end of file
+++ /dev/null
-console;scheme="http://schemas.ogf.org/occi/infrastructure/compute#";class="kind"
-os_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin"
-resource_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin"
-ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure/network#";class="mixin"
\ No newline at end of file
+++ /dev/null
-Category: console;scheme="http://schemas.ogf.org/occi/infrastructure/compute#";class="kind"
-Category: os_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin"
-Category: resource_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin"
-Category: ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure/network#";class="mixin"
-X-OCCI-Attribute: occi.compute.architecture="x86"
-X-OCCI-Attribute: occi.compute.hostname="compute1.example.org"
-X-OCCI-Attribute: occi.compute.memory=1.7
-X-OCCI-Attribute: occi.compute.speed=1.0
-X-OCCI-Attribute: occi.compute.state="active"
-X-OCCI-Attribute: occi.core.id="87f3bfc3-42d4-4474-b45c-757e55e093e9"
-X-OCCI-Attribute: occi.core.title="compute1"
\ No newline at end of file
+++ /dev/null
-ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure/network#";class="mixin"
-ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure/network#";class="mixin";title="IP Network Mixin"
-ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure/network#";class="mixin";location="/mixins/ipnetwork/"
-ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure/network#";class="mixin";attributes="occi.network.address occi.network.allocation occi.network.gateway occi.network.state"
-ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure/network#";class="mixin";actions="http://schemas.ogf.org/occi/infrastructure/compute/action#start http://schemas.ogf.org/occi/infrastructure/compute/action#stop"
-ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure/network#";class="mixin";title="IP Network Mixin";location="/mixins/ipnetwork/";attributes="occi.network.address{required} occi.network.allocation{required immutable} occi.network.gateway{immutable} occi.network.state";actions="http://schemas.ogf.org/occi/infrastructure/compute/action#start http://schemas.ogf.org/occi/infrastructure/compute/action#stop"
\ No newline at end of file
+++ /dev/null
-Category: ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure/network#";class="mixin"
-Category: ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure/network#";class="mixin";title="IP Network Mixin"
-Category: ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure/network#";class="mixin";location="/mixins/ipnetwork/"
-Category: ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure/network#";class="mixin";attributes="occi.network.address occi.network.allocation occi.network.gateway occi.network.state"
-Category: ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure/network#";class="mixin";actions="http://schemas.ogf.org/occi/infrastructure/compute/action#start http://schemas.ogf.org/occi/infrastructure/compute/action#stop"
-Category: ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure/network#";class="mixin";title="IP Network Mixin";location="/mixins/ipnetwork/";attributes="occi.network.address{required} occi.network.allocation{required immutable} occi.network.gateway{immutable} occi.network.state";actions="http://schemas.ogf.org/occi/infrastructure/compute/action#start http://schemas.ogf.org/occi/infrastructure/compute/action#stop"
\ No newline at end of file
+++ /dev/null
-occi.compute.architecture="x86"
-occi.compute.hostname="compute1.example.org"
-occi.compute.memory=1.7
-occi.compute.speed=1.0
-occi.compute.state="active"
-occi.core.id="87f3bfc3-42d4-4474-b45c-757e55e093e9"
-occi.core.title="compute1"
\ No newline at end of file
+++ /dev/null
-compute;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind"
-os_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin"
-resource_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin"
-ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure/network#";class="mixin"
-debianvm;scheme="https://occi.localhost/occi/infrastructure/os_tpl#";class="mixin"
-larger;scheme="https://occi.localhost/occi/infrastructure/resource_tpl#";class="mixin"
\ No newline at end of file
+++ /dev/null
-</network/123>;rel="http://schemas.ogf.org/occi/infrastructure#network";self="/link/networkinterface/456";category="http://schemas.ogf.org/occi/infrastructure#networkinterface";occi.core.id=456;occi.core.source="/compute/87f3bfc3-42d4-4474-b45c-757e55e093e9";occi.core.target="/network/123";occi.networkinterface.interface="eth0";occi.networkinterface.mac="00:11:22:33:44:55";occi.networkinterface.state="active";
-</storage/852>;rel="http://schemas.ogf.org/occi/infrastructure#storage";self="/link/storagelink/789";category="http://schemas.ogf.org/occi/infrastructure#storagelink http://opennebula.org/occi/infrastructure#storagelink";occi.core.id=789;occi.core.source="/compute/87f3bfc3-42d4-4474-b45c-757e55e093e9";occi.core.target="/storage/852";occi.storagelink.deviceid="1234qwerty";occi.storagelink.mountpoint="/mnt/somewhere/";occi.storagelink.state="active";
-</compute/87f3bfc3-42d4-4474-b45c-757e55e093e9?action=start>;rel="http://schemas.ogf.org/occi/infrastructure/compute/action#start";
-</compute/87f3bfc3-42d4-4474-b45c-757e55e093e9?action=stop>;rel="http://schemas.ogf.org/occi/infrastructure/compute/action#stop";
\ No newline at end of file
+++ /dev/null
-Category: compute;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind"
-Category: os_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin"
-Category: resource_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin"
-Category: ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure/network#";class="mixin"
-Category: debianvm;scheme="https://occi.localhost/occi/infrastructure/os_tpl#";class="mixin"
-Category: larger;scheme="https://occi.localhost/occi/infrastructure/resource_tpl#";class="mixin"
-X-OCCI-Attribute: occi.compute.architecture="x86"
-X-OCCI-Attribute: occi.compute.hostname="compute1.example.org"
-X-OCCI-Attribute: occi.compute.memory=1.7
-X-OCCI-Attribute: occi.compute.speed=1.0
-X-OCCI-Attribute: occi.compute.state="active"
-X-OCCI-Attribute: occi.core.id="87f3bfc3-42d4-4474-b45c-757e55e093e9"
-X-OCCI-Attribute: occi.core.title="compute1"
-Link: </network/123>;rel="http://schemas.ogf.org/occi/infrastructure#network";self="/link/networkinterface/456";category="http://schemas.ogf.org/occi/infrastructure#networkinterface";occi.core.id=456;occi.core.source="/compute/87f3bfc3-42d4-4474-b45c-757e55e093e9";occi.core.target="/network/123";occi.networkinterface.interface="eth0";occi.networkinterface.mac="00:11:22:33:44:55";occi.networkinterface.state="active";
-Link: </storage/852>;rel="http://schemas.ogf.org/occi/infrastructure#storage";self="/link/storagelink/789";category="http://schemas.ogf.org/occi/infrastructure#storagelink http://opennebula.org/occi/infrastructure#storagelink";occi.core.id=789;occi.core.source="/compute/87f3bfc3-42d4-4474-b45c-757e55e093e9";occi.core.target="/storage/852";occi.storagelink.deviceid="1234qwerty";occi.storagelink.mountpoint="/mnt/somewhere/";occi.storagelink.state="active";
-Link: </compute/87f3bfc3-42d4-4474-b45c-757e55e093e9?action=start>;rel="http://schemas.ogf.org/occi/infrastructure/compute/action#start";
-Link: </compute/87f3bfc3-42d4-4474-b45c-757e55e093e9?action=stop>;rel="http://schemas.ogf.org/occi/infrastructure/compute/action#stop";
\ No newline at end of file