http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-brooklyn/src/test/resources/test-referencing-policies.yaml ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-brooklyn/src/test/resources/test-referencing-policies.yaml b/brooklyn-server/camp/camp-brooklyn/src/test/resources/test-referencing-policies.yaml deleted file mode 100644 index ff06f5b..0000000 --- a/brooklyn-server/camp/camp-brooklyn/src/test/resources/test-referencing-policies.yaml +++ /dev/null @@ -1,133 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. -# -# Creates an application with the following structure, with each entity (including the application) having -# a policy with references to all other entities (including itself and the app) via config keys -# -# app -# (app policy) -# | -# -------|------- -# | | -# entity1 entity2 -# (e1 policy) (e2 policy) -# | -# -------|------- -# | | -# child1 child2 -# (c1 policy) (c2 policy) -# | -# -------|------- -# | | -# gchild1 gchild2 -# (g1 policy) (g2 policy) -name: test-referencing-policies -description: Test multi-layer application with each entity having a policy referencing all other entities -origin: https://github.com/apache/incubator-brooklyn -id: app1 -brooklyn.policies: - - policyType: org.apache.brooklyn.camp.brooklyn.TestReferencingPolicy - brooklyn.config: - test.reference.app: $brooklyn:component("app1") - test.reference.entity1: $brooklyn:component("e1") - test.reference.entity2: $brooklyn:component("e2") - test.reference.child1: $brooklyn:component("c1") - test.reference.child2: $brooklyn:component("c2") - test.reference.grandchild1: $brooklyn:component("gc1") - test.reference.grandchild2: $brooklyn:component("gc2") -services: -- serviceType: org.apache.brooklyn.camp.brooklyn.ReferencingYamlTestEntity - id: e1 - name: entity 1 - brooklyn.policies: - - policyType: org.apache.brooklyn.camp.brooklyn.TestReferencingPolicy - brooklyn.config: - test.reference.app: $brooklyn:component("app1") - test.reference.entity1: $brooklyn:component("e1") - test.reference.entity2: $brooklyn:component("e2") - test.reference.child1: $brooklyn:component("c1") - test.reference.child2: $brooklyn:component("c2") - test.reference.grandchild1: $brooklyn:component("gc1") - test.reference.grandchild2: $brooklyn:component("gc2") - brooklyn.children: - - serviceType: org.apache.brooklyn.camp.brooklyn.ReferencingYamlTestEntity - id: c1 - name: child 1 - brooklyn.policies: - - policyType: org.apache.brooklyn.camp.brooklyn.TestReferencingPolicy - brooklyn.config: - test.reference.app: $brooklyn:component("app1") - test.reference.entity1: $brooklyn:component("e1") - test.reference.entity2: $brooklyn:component("e2") - test.reference.child1: $brooklyn:component("c1") - test.reference.child2: $brooklyn:component("c2") - test.reference.grandchild1: $brooklyn:component("gc1") - test.reference.grandchild2: $brooklyn:component("gc2") - brooklyn.children: - - serviceType: org.apache.brooklyn.camp.brooklyn.ReferencingYamlTestEntity - id: gc1 - name: grandchild 1 - brooklyn.policies: - - policyType: org.apache.brooklyn.camp.brooklyn.TestReferencingPolicy - brooklyn.config: - test.reference.app: $brooklyn:component("app1") - test.reference.entity1: $brooklyn:component("e1") - test.reference.entity2: $brooklyn:component("e2") - test.reference.child1: $brooklyn:component("c1") - test.reference.child2: $brooklyn:component("c2") - test.reference.grandchild1: $brooklyn:component("gc1") - test.reference.grandchild2: $brooklyn:component("gc2") - - serviceType: org.apache.brooklyn.camp.brooklyn.ReferencingYamlTestEntity - id: gc2 - name: grandchild 2 - brooklyn.policies: - - policyType: org.apache.brooklyn.camp.brooklyn.TestReferencingPolicy - brooklyn.config: - test.reference.app: $brooklyn:component("app1") - test.reference.entity1: $brooklyn:component("e1") - test.reference.entity2: $brooklyn:component("e2") - test.reference.child1: $brooklyn:component("c1") - test.reference.child2: $brooklyn:component("c2") - test.reference.grandchild1: $brooklyn:component("gc1") - test.reference.grandchild2: $brooklyn:component("gc2") - - serviceType: org.apache.brooklyn.camp.brooklyn.ReferencingYamlTestEntity - id: c2 - name: child 2 - brooklyn.policies: - - policyType: org.apache.brooklyn.camp.brooklyn.TestReferencingPolicy - brooklyn.config: - test.reference.app: $brooklyn:component("app1") - test.reference.entity1: $brooklyn:component("e1") - test.reference.entity2: $brooklyn:component("e2") - test.reference.child1: $brooklyn:component("c1") - test.reference.child2: $brooklyn:component("c2") - test.reference.grandchild1: $brooklyn:component("gc1") - test.reference.grandchild2: $brooklyn:component("gc2") -- serviceType: org.apache.brooklyn.camp.brooklyn.ReferencingYamlTestEntity - id: e2 - name: entity 2 - brooklyn.policies: - - policyType: org.apache.brooklyn.camp.brooklyn.TestReferencingPolicy - brooklyn.config: - test.reference.app: $brooklyn:component("app1") - test.reference.entity1: $brooklyn:component("e1") - test.reference.entity2: $brooklyn:component("e2") - test.reference.child1: $brooklyn:component("c1") - test.reference.child2: $brooklyn:component("c2") - test.reference.grandchild1: $brooklyn:component("gc1") - test.reference.grandchild2: $brooklyn:component("gc2") \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-brooklyn/src/test/resources/test-tomcat-https.yaml ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-brooklyn/src/test/resources/test-tomcat-https.yaml b/brooklyn-server/camp/camp-brooklyn/src/test/resources/test-tomcat-https.yaml deleted file mode 100644 index 83a0fc6..0000000 --- a/brooklyn-server/camp/camp-brooklyn/src/test/resources/test-tomcat-https.yaml +++ /dev/null @@ -1,28 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. -# -name: Test Tomcat HTTPS -location: localhost -services: -- type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer - war: http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war - enabledProtocols: [https] - httpsSsl: - url: classpath://org/apache/brooklyn/entity/webapp/sample-java-keystore.jks - alias: myname - password: mypass http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-brooklyn/src/test/resources/vanilla-bash-netcat-w-client.yaml ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-brooklyn/src/test/resources/vanilla-bash-netcat-w-client.yaml b/brooklyn-server/camp/camp-brooklyn/src/test/resources/vanilla-bash-netcat-w-client.yaml deleted file mode 100644 index 82a6f40..0000000 --- a/brooklyn-server/camp/camp-brooklyn/src/test/resources/vanilla-bash-netcat-w-client.yaml +++ /dev/null @@ -1,96 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. -# -# should be the same as what's in the docs, apart from this line - -name: Simple Netcat with Client - -location: localhost - -services: - -# the netcat server instance, running in listener mode (-l) -- type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess - id: netcat-server - name: Simple Netcat Server - launch.command: | - echo hello | nc -l 4321 >> server-input & - echo $! > $PID_FILE - - # a failure detector and a service restarter work together - brooklyn.enrichers: - - type: org.apache.brooklyn.policy.ha.ServiceFailureDetector - brooklyn.config: - # wait 15s after service fails before propagating failure - serviceFailedStabilizationDelay: 15s - - brooklyn.policies: - - policyType: org.apache.brooklyn.policy.ha.ServiceRestarter - brooklyn.config: - # repeated failures in a time window can cause the restarter to abort, - # propagating the failure; a time window of 0 will mean it always restarts! - failOnRecurringFailuresInThisDuration: 0 - - brooklyn.initializers: - # two sensors, recording the data sent to this netcat server: - - - type: org.apache.brooklyn.core.sensor.ssh.SshCommandSensor - brooklyn.config: - name: output.last - command: tail -1 server-input - period: 100ms - - - type: org.apache.brooklyn.core.sensor.ssh.SshCommandSensor - brooklyn.config: - name: output.all - command: cat server-input - period: 100ms - -# a client to hit netcat -- type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess - name: Simple Pinger - - # set the hostname of the netcat instance as an env var for the scripts - env: - TARGET_HOSTNAME: $brooklyn:component("netcat-server").attributeWhenReady("host.name") - - # start/check/stop are no-op - launch.command: "" - checkRunning.command: "" - stop.command: "" - - brooklyn.initializers: - # but there is a sample effector which runs nc in client mode - - - type: org.apache.brooklyn.core.effector.ssh.SshCommandEffector - brooklyn.config: - name: sayHiNetcat - description: Echo a small hello string to the netcat entity - command: | - echo $message | nc $TARGET_HOSTNAME 4321 - parameters: - message: - description: The string to pass to netcat - defaultValue: hi netcat - -# and add an enricher at the root so all sensors from netcat-server are visible on the root -brooklyn.enrichers: -- enricherType: org.apache.brooklyn.enricher.stock.Propagator - brooklyn.config: - enricher.producer: $brooklyn:component("netcat-server") - enricher.propagating.propagatingAll: true http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-brooklyn/src/test/resources/visitors-creation-script.sql ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-brooklyn/src/test/resources/visitors-creation-script.sql b/brooklyn-server/camp/camp-brooklyn/src/test/resources/visitors-creation-script.sql deleted file mode 100644 index a324d2e..0000000 --- a/brooklyn-server/camp/camp-brooklyn/src/test/resources/visitors-creation-script.sql +++ /dev/null @@ -1,41 +0,0 @@ --- --- Licensed to the Apache Software Foundation (ASF) under one --- or more contributor license agreements. See the NOTICE file --- distributed with this work for additional information --- regarding copyright ownership. The ASF licenses this file --- to you 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. --- -create database visitors; -use visitors; - -# not necessary to create user if we grant (and not supported in some dialects) -create user 'brooklyn' identified by 'br00k11n'; - -grant usage on *.* to 'brooklyn'@'%' identified by 'br00k11n'; - -# ''@localhost is sometimes set up, overriding brooklyn@'%', so do a second explicit grant -grant usage on *.* to 'brooklyn'@'localhost' identified by 'br00k11n'; - -grant all privileges on visitors.* to 'brooklyn'@'%'; - -flush privileges; - -CREATE TABLE MESSAGES ( - id BIGINT NOT NULL AUTO_INCREMENT, - NAME VARCHAR(30) NOT NULL, - MESSAGE VARCHAR(400) NOT NULL, - PRIMARY KEY (ID) - ); - -INSERT INTO MESSAGES values (default, 'Isaac Asimov', 'I grew up in Brooklyn' ); http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-brooklyn/src/test/resources/yaml-ref-app.yaml ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-brooklyn/src/test/resources/yaml-ref-app.yaml b/brooklyn-server/camp/camp-brooklyn/src/test/resources/yaml-ref-app.yaml deleted file mode 100644 index 33da321..0000000 --- a/brooklyn-server/camp/camp-brooklyn/src/test/resources/yaml-ref-app.yaml +++ /dev/null @@ -1,21 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. -# -name: Basic app -services: -- name: service - type: org.apache.brooklyn.entity.stock.BasicApplication http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-brooklyn/src/test/resources/yaml-ref-bundle-without-libraries.yaml ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-brooklyn/src/test/resources/yaml-ref-bundle-without-libraries.yaml b/brooklyn-server/camp/camp-brooklyn/src/test/resources/yaml-ref-bundle-without-libraries.yaml deleted file mode 100644 index b961708..0000000 --- a/brooklyn-server/camp/camp-brooklyn/src/test/resources/yaml-ref-bundle-without-libraries.yaml +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. -# -services: -- type: org.apache.brooklyn.test.osgi.entities.SimpleEntity http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-brooklyn/src/test/resources/yaml-ref-catalog.yaml ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-brooklyn/src/test/resources/yaml-ref-catalog.yaml b/brooklyn-server/camp/camp-brooklyn/src/test/resources/yaml-ref-catalog.yaml deleted file mode 100644 index 545fd1a..0000000 --- a/brooklyn-server/camp/camp-brooklyn/src/test/resources/yaml-ref-catalog.yaml +++ /dev/null @@ -1,21 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. -# -name: Basic app -services: -- name: service - type: yaml.basic:0.1.2 http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-brooklyn/src/test/resources/yaml-ref-entity.yaml ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-brooklyn/src/test/resources/yaml-ref-entity.yaml b/brooklyn-server/camp/camp-brooklyn/src/test/resources/yaml-ref-entity.yaml deleted file mode 100644 index c9b1c55..0000000 --- a/brooklyn-server/camp/camp-brooklyn/src/test/resources/yaml-ref-entity.yaml +++ /dev/null @@ -1,21 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. -# -name: Basic entity -services: -- name: service - type: org.apache.brooklyn.entity.stock.BasicEntity http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-server/pom.xml ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-server/pom.xml b/brooklyn-server/camp/camp-server/pom.xml deleted file mode 100644 index 502c83e..0000000 --- a/brooklyn-server/camp/camp-server/pom.xml +++ /dev/null @@ -1,167 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you 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. ---> - -<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> - <packaging>jar</packaging> - - <artifactId>camp-server</artifactId> - - <name>CAMP Server</name> - <description> - REST Server classes for CAMP server implementation - </description> - - <parent> - <groupId>org.apache.brooklyn.camp</groupId> - <artifactId>camp-parent</artifactId> - <version>0.9.0-SNAPSHOT</version> <!-- BROOKLYN_VERSION --> - <relativePath>../pom.xml</relativePath> - </parent> - - <dependencies> - <dependency> - <groupId>org.apache.brooklyn.camp</groupId> - <artifactId>camp-base</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> - <groupId>org.apache.brooklyn</groupId> - <artifactId>brooklyn-utils-test-support</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.brooklyn.camp</groupId> - <artifactId>camp-base</artifactId> - <version>${project.version}</version> - <classifier>tests</classifier> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.testng</groupId> - <artifactId>testng</artifactId> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-databind</artifactId> - <!-- jackson-core and jackson-annotations are pulled in from this, with the right version --> - </dependency> - <dependency> - <groupId>com.fasterxml.jackson.jaxrs</groupId> - <artifactId>jackson-jaxrs-json-provider</artifactId> - </dependency> - - <dependency> - <groupId>com.sun.jersey</groupId> - <artifactId>jersey-server</artifactId> - </dependency> - <dependency> - <groupId>com.sun.jersey</groupId> - <artifactId>jersey-servlet</artifactId> - </dependency> - <dependency> - <groupId>com.sun.jersey</groupId> - <artifactId>jersey-json</artifactId> - <exclusions> - <exclusion> - <groupId>com.sun.xml.bind</groupId> - <artifactId>jaxb-impl</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>com.sun.jersey.contribs</groupId> - <artifactId>jersey-multipart</artifactId> - </dependency> - <dependency> - <groupId>com.sun.jersey</groupId> - <artifactId>jersey-core</artifactId> - </dependency> - - <dependency> - <groupId>javax.validation</groupId> - <artifactId>validation-api</artifactId> - </dependency> - - <dependency> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-webapp</artifactId> - </dependency> - <dependency> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-server</artifactId> - </dependency> - <dependency> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-servlet</artifactId> - </dependency> - <dependency> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-util</artifactId> - </dependency> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>javax.servlet-api</artifactId> - </dependency> - <dependency> - <groupId>org.apache.brooklyn</groupId> - <artifactId>brooklyn-utils-rest-swagger</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.brooklyn</groupId> - <artifactId>brooklyn-utils-common</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-lang3</artifactId> - </dependency> - <!-- ATTN: this moves the dependency version from 1.9.2 to 1.9.13 --> - <dependency> - <groupId>org.codehaus.jackson</groupId> - <artifactId>jackson-core-asl</artifactId> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - </dependency> - - <!-- TODO have a camp.log / logging module --> - <dependency> - <groupId>org.apache.brooklyn</groupId> - <artifactId>brooklyn-logback-xml</artifactId> - <version>${project.version}</version> - <!-- optional so that this project has logging; dependencies may redeclare or supply their own --> - <optional>true</optional> - </dependency> - - - </dependencies> - -</project> http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/ApiErrorDto.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/ApiErrorDto.java b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/ApiErrorDto.java deleted file mode 100644 index a65dbe1..0000000 --- a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/ApiErrorDto.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ -package org.apache.brooklyn.camp.server.dto; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.codehaus.jackson.annotate.JsonProperty; - -import com.google.common.base.Objects; -import com.google.common.base.Optional; -import com.google.common.base.Throwables; - -/** - * A simple error message that provides a message and optional details. - * - * This class should eventually be replaced with an ErrorMessage object, - * as described in the CAMP spec. - */ -public class ApiErrorDto { - - public static Builder builder() { - return new Builder(); - } - - /** - * @return An {@link ApiErrorDto.Builder} whose message is initialised to either the throwable's - * message or the throwable's class name if the message is null and whose details are - * initialised to the throwable's stack trace. - */ - public static Builder fromThrowable(Throwable t) { - checkNotNull(t, "throwable"); - String message = Optional.fromNullable(t.getMessage()) - .or(t.getClass().getName()); - return builder() - .message(message) - .details(Throwables.getStackTraceAsString(t)); - } - - public static class Builder { - private String message; - private String details; - - public Builder message(String message) { - this.message = checkNotNull(message, "message"); - return this; - } - - public Builder details(String details) { - this.details = checkNotNull(details, "details"); - return this; - } - - public ApiErrorDto build() { - return new ApiErrorDto(message, details); - } - - public Builder fromApiErrorDto(ApiErrorDto error) { - return this - .message(error.message) - .details(error.details); - } - } - - private final String message; - private final String details; - - public ApiErrorDto( - @JsonProperty("message") String message, - @JsonProperty("details") String details) { - this.message = checkNotNull(message, "message"); - this.details = details != null ? details : ""; - } - - public String getMessage() { - return message; - } - - public String getDetails() { - return details; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - if (other == null || getClass() != other.getClass()) return false; - ApiErrorDto that = ApiErrorDto.class.cast(other); - return Objects.equal(this.message, that.message) && - Objects.equal(this.details, that.details); - } - - @Override - public int hashCode() { - return Objects.hashCode(message, details); - } - - @Override - public String toString() { - return Objects.toStringHelper(this) - .add("message", message) - .add("details", details) - .toString(); - } -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/ApplicationComponentDto.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/ApplicationComponentDto.java b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/ApplicationComponentDto.java deleted file mode 100644 index 9a3ddda..0000000 --- a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/ApplicationComponentDto.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ -package org.apache.brooklyn.camp.server.dto; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.brooklyn.camp.server.rest.util.DtoFactory; -import org.apache.brooklyn.camp.spi.ApplicationComponent; -import org.apache.brooklyn.camp.spi.Link; -import org.apache.brooklyn.camp.spi.PlatformComponent; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -public class ApplicationComponentDto extends ResourceDto { - - protected ApplicationComponentDto() {} - protected ApplicationComponentDto(DtoFactory dtoFactory, ApplicationComponent x) { - super(dtoFactory, x); - - platformComponents = new ArrayList<LinkDto>(); - for (Link<PlatformComponent> t: x.getPlatformComponents().links()) { - platformComponents.add(LinkDto.newInstance(dtoFactory, PlatformComponent.class, t)); - } - - applicationComponents = new ArrayList<LinkDto>(); - for (Link<ApplicationComponent> t: x.getApplicationComponents().links()) { - applicationComponents.add(LinkDto.newInstance(dtoFactory, ApplicationComponent.class, t)); - } - } - - private List<LinkDto> platformComponents; - private List<LinkDto> applicationComponents; - - @JsonInclude(Include.NON_EMPTY) - public List<LinkDto> getPlatformComponents() { - return platformComponents; - } - - @JsonInclude(Include.NON_EMPTY) - public List<LinkDto> getApplicationComponents() { - return applicationComponents; - } - - // --- building --- - - public static ApplicationComponentDto newInstance(DtoFactory dtoFactory, ApplicationComponent x) { - return new ApplicationComponentDto(dtoFactory, x); - } - -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/ApplicationComponentTemplateDto.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/ApplicationComponentTemplateDto.java b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/ApplicationComponentTemplateDto.java deleted file mode 100644 index 25ed367..0000000 --- a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/ApplicationComponentTemplateDto.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ -package org.apache.brooklyn.camp.server.dto; - -import org.apache.brooklyn.camp.server.rest.util.DtoFactory; -import org.apache.brooklyn.camp.spi.ApplicationComponentTemplate; - -public class ApplicationComponentTemplateDto extends ResourceDto { - - protected ApplicationComponentTemplateDto() {} - protected ApplicationComponentTemplateDto(DtoFactory dtoFactory, ApplicationComponentTemplate x) { - super(dtoFactory, x); - // TODO set addl ACT fields - } - - // TODO add addl ACT fields - - // --- building --- - - public static ApplicationComponentTemplateDto newInstance(DtoFactory dtoFactory, ApplicationComponentTemplate x) { - return new ApplicationComponentTemplateDto(dtoFactory, x); - } - -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/AssemblyDto.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/AssemblyDto.java b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/AssemblyDto.java deleted file mode 100644 index 25a7989..0000000 --- a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/AssemblyDto.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ -package org.apache.brooklyn.camp.server.dto; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.brooklyn.camp.server.rest.util.DtoFactory; -import org.apache.brooklyn.camp.spi.ApplicationComponent; -import org.apache.brooklyn.camp.spi.Assembly; -import org.apache.brooklyn.camp.spi.Link; -import org.apache.brooklyn.camp.spi.PlatformComponent; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -public class AssemblyDto extends ResourceDto { - - protected AssemblyDto() {} - protected AssemblyDto(DtoFactory dtoFactory, Assembly x) { - super(dtoFactory, x); - - platformComponents = new ArrayList<LinkDto>(); - for (Link<PlatformComponent> t: x.getPlatformComponents().links()) { - platformComponents.add(LinkDto.newInstance(dtoFactory, PlatformComponent.class, t)); - } - - applicationComponents = new ArrayList<LinkDto>(); - for (Link<ApplicationComponent> t: x.getApplicationComponents().links()) { - applicationComponents.add(LinkDto.newInstance(dtoFactory, ApplicationComponent.class, t)); - } - } - - private List<LinkDto> platformComponents; - private List<LinkDto> applicationComponents; - - // TODO addl AssemblyTemplate fields -// "parameterDefinitionUri": URI, -// "pdpUri" : URI ? - - @JsonInclude(Include.NON_EMPTY) - public List<LinkDto> getPlatformComponents() { - return platformComponents; - } - - @JsonInclude(Include.NON_EMPTY) - public List<LinkDto> getApplicationComponents() { - return applicationComponents; - } - - // --- building --- - - public static AssemblyDto newInstance(DtoFactory dtoFactory, Assembly x) { - return new AssemblyDto(dtoFactory, x); - } - -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/AssemblyTemplateDto.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/AssemblyTemplateDto.java b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/AssemblyTemplateDto.java deleted file mode 100644 index 3a7273f..0000000 --- a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/AssemblyTemplateDto.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ -package org.apache.brooklyn.camp.server.dto; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.brooklyn.camp.server.rest.util.DtoFactory; -import org.apache.brooklyn.camp.spi.ApplicationComponentTemplate; -import org.apache.brooklyn.camp.spi.AssemblyTemplate; -import org.apache.brooklyn.camp.spi.Link; -import org.apache.brooklyn.camp.spi.PlatformComponentTemplate; - -public class AssemblyTemplateDto extends ResourceDto { - - protected AssemblyTemplateDto() {} - protected AssemblyTemplateDto(DtoFactory dtoFactory, AssemblyTemplate x) { - super(dtoFactory, x); - - platformComponentTemplates = new ArrayList<LinkDto>(); - for (Link<PlatformComponentTemplate> t: x.getPlatformComponentTemplates().links()) { - platformComponentTemplates.add(LinkDto.newInstance(dtoFactory, PlatformComponentTemplate.class, t)); - } - - applicationComponentTemplates = new ArrayList<LinkDto>(); - for (Link<ApplicationComponentTemplate> t: x.getApplicationComponentTemplates().links()) { - applicationComponentTemplates.add(LinkDto.newInstance(dtoFactory, ApplicationComponentTemplate.class, t)); - } - } - - private List<LinkDto> platformComponentTemplates; - private List<LinkDto> applicationComponentTemplates; - - // TODO addl AssemblyTemplate fields -// "parameterDefinitionUri": URI, -// "pdpUri" : URI ? - - public List<LinkDto> getPlatformComponentTemplates() { - return platformComponentTemplates; - } - - public List<LinkDto> getApplicationComponentTemplates() { - return applicationComponentTemplates; - } - - // --- building --- - - public static AssemblyTemplateDto newInstance(DtoFactory dtoFactory, AssemblyTemplate x) { - return new AssemblyTemplateDto(dtoFactory, x); - } - -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/DtoBase.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/DtoBase.java b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/DtoBase.java deleted file mode 100644 index fbf48ca..0000000 --- a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/DtoBase.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ -package org.apache.brooklyn.camp.server.dto; - -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.apache.commons.lang3.builder.ToStringBuilder; - -public class DtoBase { - - @Override public String toString() { return ToStringBuilder.reflectionToString(this); } - @Override public boolean equals(Object obj) { return EqualsBuilder.reflectionEquals(this, obj); } - @Override public int hashCode() { return HashCodeBuilder.reflectionHashCode(this); } - -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/DtoCustomAttributes.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/DtoCustomAttributes.java b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/DtoCustomAttributes.java deleted file mode 100644 index 0b7e320..0000000 --- a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/DtoCustomAttributes.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ -package org.apache.brooklyn.camp.server.dto; - -import java.util.Map; - -import org.apache.brooklyn.util.collections.MutableMap; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.google.common.collect.ImmutableMap; - -public class DtoCustomAttributes extends DtoBase { - - private Map<String,Object> customAttributes = new MutableMap<String, Object>(); - - protected DtoCustomAttributes() {} - - public DtoCustomAttributes(Map<String,?> customAttributes) { - this.customAttributes = customAttributes==null ? ImmutableMap.<String, Object>of() : ImmutableMap.copyOf(customAttributes); - } - - @JsonIgnore - public Map<String, Object> getCustomAttributes() { - return customAttributes; - } - - // --- json --- - - @JsonInclude(Include.NON_EMPTY) - @JsonAnyGetter - private Map<String,Object> any() { - return customAttributes; - } - @JsonAnySetter - private void set(String name, Object value) { - customAttributes.put(name, value); - } - - // --- building --- - - protected void newInstanceCustomAttributes(Map<String,?> customAttributes) { - if (customAttributes!=null) - this.customAttributes.putAll(customAttributes); - } - -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/LinkDto.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/LinkDto.java b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/LinkDto.java deleted file mode 100644 index d12de65..0000000 --- a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/LinkDto.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ -package org.apache.brooklyn.camp.server.dto; - -import java.util.Map; - -import org.apache.brooklyn.camp.server.rest.util.DtoFactory; -import org.apache.brooklyn.camp.spi.AbstractResource; -import org.apache.brooklyn.camp.spi.Link; - -public class LinkDto extends DtoCustomAttributes { - - // defined as a constant so can be used in Swagger REST API annotations - public static final String CLASS_NAME = "org.apache.brooklyn.camp.server.dto.LinkDto"; - static { assert CLASS_NAME.equals(LinkDto.class.getCanonicalName()); } - - private String href; - private String targetName; - - protected LinkDto() {} - - public String getHref() { - return href; - } - - public String getTargetName() { - return targetName; - } - - // --- building --- - - public static LinkDto newInstance(DtoFactory dtoFactory, Class<? extends AbstractResource> targetType, Link<?> x) { - return new LinkDto().newInstanceInitialization(dtoFactory, targetType, x); - } - - protected LinkDto newInstanceInitialization(DtoFactory dtoFactory, Class<? extends AbstractResource> targetType, Link<?> x) { - targetName = x.getName(); - - href = dtoFactory.uri(targetType, x.getId()); - return this; - } - - public static LinkDto newInstance(String href, String targetName) { - LinkDto x = new LinkDto(); - x.href = href; - x.targetName = targetName; - return x; - } - - public static LinkDto newInstance(String href, String targetName, Map<String,?> customAttributes) { - LinkDto x = newInstance(href, targetName); - x.newInstanceCustomAttributes(customAttributes); - return x; - } - -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/PlatformComponentDto.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/PlatformComponentDto.java b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/PlatformComponentDto.java deleted file mode 100644 index 9e8ef73..0000000 --- a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/PlatformComponentDto.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ -package org.apache.brooklyn.camp.server.dto; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.brooklyn.camp.server.rest.util.DtoFactory; -import org.apache.brooklyn.camp.spi.ApplicationComponent; -import org.apache.brooklyn.camp.spi.Link; -import org.apache.brooklyn.camp.spi.PlatformComponent; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -public class PlatformComponentDto extends ResourceDto { - - protected PlatformComponentDto() {} - protected PlatformComponentDto(DtoFactory dtoFactory, PlatformComponent x) { - super(dtoFactory, x); - setExternalManagementUri(x.getExternalManagementUri()); - platformComponents = new ArrayList<LinkDto>(); - for (Link<PlatformComponent> t: x.getPlatformComponents().links()) { - platformComponents.add(LinkDto.newInstance(dtoFactory, PlatformComponent.class, t)); - } - - applicationComponents = new ArrayList<LinkDto>(); - for (Link<ApplicationComponent> t: x.getApplicationComponents().links()) { - applicationComponents.add(LinkDto.newInstance(dtoFactory, ApplicationComponent.class, t)); - } - } - - private List<LinkDto> platformComponents; - private List<LinkDto> applicationComponents; - - private String externalManagementUri; - - @JsonInclude(Include.NON_EMPTY) - public List<LinkDto> getPlatformComponents() { - return platformComponents; - } - - @JsonInclude(Include.NON_EMPTY) - public List<LinkDto> getApplicationComponents() { - return applicationComponents; - } - - @JsonInclude(Include.NON_EMPTY) - public String getExternalManagementUri() { - return externalManagementUri; - } - private void setExternalManagementUri(String externalManagementUri) { - this.externalManagementUri = externalManagementUri; - } - - // --- building --- - - public static PlatformComponentDto newInstance(DtoFactory dtoFactory, PlatformComponent x) { - return new PlatformComponentDto(dtoFactory, x); - } - -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/PlatformComponentTemplateDto.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/PlatformComponentTemplateDto.java b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/PlatformComponentTemplateDto.java deleted file mode 100644 index f605890..0000000 --- a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/PlatformComponentTemplateDto.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ -package org.apache.brooklyn.camp.server.dto; - -import org.apache.brooklyn.camp.server.rest.util.DtoFactory; -import org.apache.brooklyn.camp.spi.PlatformComponentTemplate; - -public class PlatformComponentTemplateDto extends ResourceDto { - - protected PlatformComponentTemplateDto() {} - protected PlatformComponentTemplateDto(DtoFactory dtoFactory, PlatformComponentTemplate x) { - super(dtoFactory, x); - // TODO set addl PCT fields - } - - // TODO add addl PCT fields - - // --- building --- - - public static PlatformComponentTemplateDto newInstance(DtoFactory dtoFactory, PlatformComponentTemplate x) { - return new PlatformComponentTemplateDto(dtoFactory, x); - } - -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/PlatformDto.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/PlatformDto.java b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/PlatformDto.java deleted file mode 100644 index 62a6aba..0000000 --- a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/PlatformDto.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ -package org.apache.brooklyn.camp.server.dto; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.brooklyn.camp.server.rest.resource.ApidocRestResource; -import org.apache.brooklyn.camp.server.rest.util.DtoFactory; -import org.apache.brooklyn.camp.spi.ApplicationComponent; -import org.apache.brooklyn.camp.spi.ApplicationComponentTemplate; -import org.apache.brooklyn.camp.spi.Assembly; -import org.apache.brooklyn.camp.spi.AssemblyTemplate; -import org.apache.brooklyn.camp.spi.Link; -import org.apache.brooklyn.camp.spi.PlatformComponent; -import org.apache.brooklyn.camp.spi.PlatformComponentTemplate; -import org.apache.brooklyn.camp.spi.PlatformRootSummary; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -public class PlatformDto extends ResourceDto { - - protected PlatformDto() {} - protected PlatformDto(DtoFactory dtoFactory, PlatformRootSummary x) { - super(dtoFactory, x); - platformComponentTemplates = new ArrayList<LinkDto>(); - for (Link<PlatformComponentTemplate> t: dtoFactory.getPlatform().platformComponentTemplates().links()) { - platformComponentTemplates.add(LinkDto.newInstance(dtoFactory, PlatformComponentTemplate.class, t)); - } - - applicationComponentTemplates = new ArrayList<LinkDto>(); - for (Link<ApplicationComponentTemplate> t: dtoFactory.getPlatform().applicationComponentTemplates().links()) { - applicationComponentTemplates.add(LinkDto.newInstance(dtoFactory, ApplicationComponentTemplate.class, t)); - } - - assemblyTemplates = new ArrayList<LinkDto>(); - for (Link<AssemblyTemplate> t: dtoFactory.getPlatform().assemblyTemplates().links()) { - assemblyTemplates.add(LinkDto.newInstance(dtoFactory, AssemblyTemplate.class, t)); - } - - platformComponents = new ArrayList<LinkDto>(); - for (Link<PlatformComponent> t: dtoFactory.getPlatform().platformComponents().links()) { - platformComponents.add(LinkDto.newInstance(dtoFactory, PlatformComponent.class, t)); - } - - applicationComponents = new ArrayList<LinkDto>(); - for (Link<ApplicationComponent> t: dtoFactory.getPlatform().applicationComponents().links()) { - applicationComponents.add(LinkDto.newInstance(dtoFactory, ApplicationComponent.class, t)); - } - - assemblies = new ArrayList<LinkDto>(); - for (Link<Assembly> t: dtoFactory.getPlatform().assemblies().links()) { - assemblies.add(LinkDto.newInstance(dtoFactory, Assembly.class, t)); - } - - // TODO set custom fields - - apidoc = LinkDto.newInstance( - dtoFactory.getUriFactory().uriOfRestResource(ApidocRestResource.class), - "API documentation"); - } - - // TODO add custom fields - private List<LinkDto> assemblyTemplates; - private List<LinkDto> platformComponentTemplates; - private List<LinkDto> applicationComponentTemplates; - private List<LinkDto> assemblies; - private List<LinkDto> platformComponents; - private List<LinkDto> applicationComponents; - - // non-CAMP, but useful - private LinkDto apidoc; - - public List<LinkDto> getAssemblyTemplates() { - return assemblyTemplates; - } - - public List<LinkDto> getPlatformComponentTemplates() { - return platformComponentTemplates; - } - - public List<LinkDto> getApplicationComponentTemplates() { - return applicationComponentTemplates; - } - - public List<LinkDto> getAssemblies() { - return assemblies; - } - - @JsonInclude(Include.NON_EMPTY) - public List<LinkDto> getPlatformComponents() { - return platformComponents; - } - - @JsonInclude(Include.NON_EMPTY) - public List<LinkDto> getApplicationComponents() { - return applicationComponents; - } - - public LinkDto getApidoc() { - return apidoc; - } - - // --- building --- - - public static PlatformDto newInstance(DtoFactory dtoFactory, PlatformRootSummary x) { - return new PlatformDto(dtoFactory, x); - } - -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/ResourceDto.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/ResourceDto.java b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/ResourceDto.java deleted file mode 100644 index cf5ca25..0000000 --- a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/dto/ResourceDto.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ -package org.apache.brooklyn.camp.server.dto; - -import java.util.Date; -import java.util.List; - -import org.apache.brooklyn.camp.commontypes.RepresentationSkew; -import org.apache.brooklyn.camp.server.rest.util.DtoFactory; -import org.apache.brooklyn.camp.spi.AbstractResource; -import org.apache.brooklyn.util.time.Time; - -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.util.ISO8601Utils; - -public class ResourceDto extends DtoCustomAttributes { - - protected ResourceDto() {} - protected ResourceDto(DtoFactory dtoFactory, AbstractResource x) { - type = x.getType(); - name = x.getName(); - - description = x.getDescription(); - setCreated(x.getCreated()); - tags = x.getTags(); - representationSkew = x.getRepresentationSkew(); - - if (x.getCustomAttributes()!=null && !x.getCustomAttributes().isEmpty()) - newInstanceCustomAttributes(x.getCustomAttributes()); - - uri = dtoFactory.uri(x); - } - - private String uri; - private String type; - - private String name; - private String description; - private Date created; - private List<String> tags; - private RepresentationSkew representationSkew; - - public String getUri() { - return uri; - } - - public String getName() { - return name; - } - - @JsonInclude(Include.NON_NULL) - public String getDescription() { - return description; - } - - @JsonGetter("created") - public String getCreatedAsString() { - return created==null ? null : ISO8601Utils.format(created); - } - - @JsonSetter - private void setCreated(Date created) { - this.created = Time.dropMilliseconds(created); - } - - @JsonIgnore - public Date getCreated() { - return created; - } - - @JsonInclude(Include.NON_EMPTY) - public List<String> getTags() { - return tags; - } - - public String getType() { - return type; - } - - @JsonInclude(Include.NON_NULL) - public RepresentationSkew getRepresentationSkew() { - return representationSkew; - } - - // --- building --- - - public static ResourceDto newInstance(DtoFactory dtoFactory, AbstractResource x) { - return new ResourceDto(dtoFactory, x); - } - -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/CampRestResources.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/CampRestResources.java b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/CampRestResources.java deleted file mode 100644 index 0c99377..0000000 --- a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/CampRestResources.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ -package org.apache.brooklyn.camp.server.rest; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.brooklyn.camp.server.rest.resource.AbstractCampRestResource; -import org.apache.brooklyn.camp.server.rest.resource.ApidocRestResource; -import org.apache.brooklyn.camp.server.rest.resource.ApplicationComponentRestResource; -import org.apache.brooklyn.camp.server.rest.resource.ApplicationComponentTemplateRestResource; -import org.apache.brooklyn.camp.server.rest.resource.AssemblyRestResource; -import org.apache.brooklyn.camp.server.rest.resource.AssemblyTemplateRestResource; -import org.apache.brooklyn.camp.server.rest.resource.PlatformComponentRestResource; -import org.apache.brooklyn.camp.server.rest.resource.PlatformComponentTemplateRestResource; -import org.apache.brooklyn.camp.server.rest.resource.PlatformRestResource; - -import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; -import com.google.common.collect.Iterables; -import io.swagger.jaxrs.listing.SwaggerSerializers; - -public class CampRestResources { - - public static Iterable<AbstractCampRestResource> getCampRestResources() { - List<AbstractCampRestResource> resources = new ArrayList<>(); - resources.add(new PlatformRestResource()); - resources.add(new AssemblyTemplateRestResource()); - resources.add(new PlatformComponentTemplateRestResource()); - resources.add(new ApplicationComponentTemplateRestResource()); - resources.add(new AssemblyRestResource()); - resources.add(new PlatformComponentRestResource()); - resources.add(new ApplicationComponentRestResource()); - return resources; - } - - public static Iterable<Object> getApidocResources() { - List<Object> resources = new ArrayList<>(); - resources.add(new ApidocRestResource()); - return resources; - } - - public static Iterable<Object> getMiscResources() { - List<Object> resources = new ArrayList<>(); - resources.add(new SwaggerSerializers()); - resources.add(new JacksonJsonProvider()); - return resources; - } - - public static Iterable<Object> getAllResources() { - return Iterables.concat(getCampRestResources(), getApidocResources(), getMiscResources()); - } - -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/CampServer.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/CampServer.java b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/CampServer.java deleted file mode 100644 index 0ad6bc2..0000000 --- a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/CampServer.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ -package org.apache.brooklyn.camp.server.rest; - -import java.io.File; -import java.io.IOException; -import java.util.EnumSet; - -import javax.servlet.DispatcherType; - -import org.apache.brooklyn.camp.CampPlatform; -import org.apache.brooklyn.camp.server.rest.resource.PlatformRestResource; -import org.apache.brooklyn.camp.server.rest.util.DtoFactory; -import org.apache.brooklyn.util.exceptions.Exceptions; -import org.apache.brooklyn.util.net.Networking; -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.handler.ContextHandler; -import org.eclipse.jetty.servlet.FilterHolder; -import org.eclipse.jetty.servlet.ServletContextHandler; -import org.eclipse.jetty.util.thread.QueuedThreadPool; -import org.eclipse.jetty.webapp.WebAppContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.Charsets; -import com.google.common.io.Files; -import com.sun.jersey.api.core.DefaultResourceConfig; -import com.sun.jersey.api.core.ResourceConfig; -import com.sun.jersey.spi.container.servlet.ServletContainer; -import org.eclipse.jetty.server.NetworkConnector; -import org.eclipse.jetty.server.ServerConnector; - -public class CampServer { - - private static final Logger log = LoggerFactory.getLogger(CampServer.class); - - public static final String CAMP_PLATFORM_ATTRIBUTE = CampPlatform.class.getCanonicalName(); - public static final String DTO_FACTORY = DtoFactory.class.getCanonicalName(); - - private final CampPlatform platform; - private final String uriBase; - private DtoFactory dtoFactory; - - WebAppContext webAppContext; - Server server; - - public CampServer(CampPlatform platform, String uriBase) { - this.platform = platform; - this.uriBase = uriBase; - } - - public CampPlatform getPlatform() { - return platform; - } - - public String getUriBase() { - return uriBase; - } - - public WebAppContext getWebAppContext() { - return webAppContext; - } - - public synchronized DtoFactory getDtoFactory() { - if (dtoFactory!=null) return dtoFactory; - dtoFactory = createDtoFactory(); - return dtoFactory; - } - - protected DtoFactory createDtoFactory() { - return new DtoFactory(getPlatform(), getUriBase()); - } - - public synchronized CampServer start() { - if (webAppContext!=null) - throw new IllegalStateException("Already started"); - - webAppContext = new WebAppContext(); - webAppContext.setContextPath("/"); - webAppContext.setAttribute(CAMP_PLATFORM_ATTRIBUTE, getPlatform()); - webAppContext.setAttribute(DTO_FACTORY, getDtoFactory()); - webAppContext.setWar( - // TODO if there is a GUI or other war... - //findJsguiWebapp()!=null ? findJsguiWebapp() : - CampServerUtils.createTempWebDirWithIndexHtml("CAMP REST API <p> (no gui available - " + - "rest endpoint at <a href=\""+PlatformRestResource.CAMP_URI_PATH+"\">"+PlatformRestResource.CAMP_URI_PATH+"</a>)")); - CampServerUtils.installAsServletFilter(webAppContext); - - server = CampServerUtils.startServer(webAppContext, "CAMP server"); - - return this; - } - - public synchronized void stop() { - try { - server.stop(); - server = null; - webAppContext.stop(); - webAppContext = null; - } catch (Exception e) { - throw Exceptions.propagate(e); - } - } - - public Integer getPort() { - if (server==null) return null; - NetworkConnector networkConnector = (NetworkConnector) server.getConnectors()[0]; - return networkConnector.getLocalPort(); - } - - public static class CampServerUtils { - - public static void installAsServletFilter(ServletContextHandler context) { - // TODO security - // installBrooklynPropertiesSecurityFilter(context); - - // now set up the REST servlet resources - ResourceConfig config = new DefaultResourceConfig(); - // load all our REST API modules, JSON, and Swagger - for (Object r: CampRestResources.getAllResources()) - config.getSingletons().add(r); - - // configure to match empty path, or any thing which looks like a file path with /assets/ and extension html, css, js, or png - // and treat that as static content - config.getProperties().put(ServletContainer.PROPERTY_WEB_PAGE_CONTENT_REGEX, "(/?|[^?]*/assets/[^?]+\\.[A-Za-z0-9_]+)"); - - // and anything which is not matched as a servlet also falls through (but more expensive than a regex check?) - config.getFeatures().put(ServletContainer.FEATURE_FILTER_FORWARD_ON_404, true); - - // finally create this as a _filter_ which falls through to a web app or something (optionally) - FilterHolder filterHolder = new FilterHolder(new ServletContainer(config)); - context.addFilter(filterHolder, "/*", EnumSet.allOf(DispatcherType.class)); - } - - public static Server startServer(ContextHandler context, String summary) { - // FIXME port hardcoded - int port = Networking.nextAvailablePort(8080); - - // use a nice name in the thread pool (otherwise this is exactly the same as Server defaults) - QueuedThreadPool threadPool = new QueuedThreadPool(); - threadPool.setName("camp-jetty-server-"+port+"-"+threadPool.getName()); - - Server server = new Server(threadPool); - - ServerConnector httpConnector = new ServerConnector(server); - httpConnector.setPort(port); - server.addConnector(httpConnector); - - server.setHandler(context); - - try { - server.start(); - } catch (Exception e) { - throw Exceptions.propagate(e); - } - log.info("CAMP REST server started ("+summary+") on"); - log.info(" http://localhost:"+httpConnector.getLocalPort()+"/"); - - return server; - } - - /** create a directory with a simple index.html so we have some content being served up */ - public static String createTempWebDirWithIndexHtml(String indexHtmlContent) { - File dir = Files.createTempDir(); - dir.deleteOnExit(); - try { - Files.write(indexHtmlContent, new File(dir, "index.html"), Charsets.UTF_8); - } catch (IOException e) { - Exceptions.propagate(e); - } - return dir.getAbsolutePath(); - } - - } - -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/resource/AbstractCampRestResource.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/resource/AbstractCampRestResource.java b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/resource/AbstractCampRestResource.java deleted file mode 100644 index ed8a09c..0000000 --- a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/resource/AbstractCampRestResource.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ -package org.apache.brooklyn.camp.server.rest.resource; - -import javax.servlet.ServletContext; -import javax.ws.rs.core.Context; - -import org.apache.brooklyn.camp.CampPlatform; -import org.apache.brooklyn.camp.server.rest.util.CampRestContext; -import org.apache.brooklyn.camp.server.rest.util.DtoFactory; -import org.apache.brooklyn.camp.server.rest.util.WebResourceUtils; -import org.apache.brooklyn.camp.spi.AbstractResource; -import org.apache.brooklyn.camp.spi.collection.ResourceLookup; - -public abstract class AbstractCampRestResource { - - // can be injected by jersey when not injected manually - // (seems there is no way to make this optional so note it _must_ be injected; if needed - // see notes on workarounds for test frameworks in original AbstractBrooklynRestResource) - @Context ServletContext servletContext; - - private CampRestContext campRestContext; - - public synchronized CampRestContext context() { - if (campRestContext!=null) return campRestContext; - campRestContext = new CampRestContext(servletContext); - return campRestContext; - } - - public CampPlatform camp() { return context().camp(); } - public DtoFactory dto() { return context().dto(); } - - public static <T extends AbstractResource> T lookup(ResourceLookup<T> list, String id) { - T result = list.get(id); - if (result==null) - throw WebResourceUtils.notFound("No such element: %s", id); - return result; - } - -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApidocRestResource.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApidocRestResource.java b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApidocRestResource.java deleted file mode 100644 index 3c5f96d..0000000 --- a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApidocRestResource.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ -package org.apache.brooklyn.camp.server.rest.resource; - -import io.swagger.annotations.Api; -import javax.ws.rs.Path; - - -@Path(ApidocRestResource.API_URI_PATH) -@Api("Web API Documentation") -public class ApidocRestResource extends org.apache.brooklyn.rest.apidoc.ApiListingResource { - - public static final String API_URI_PATH = PlatformRestResource.CAMP_URI_PATH + "/apidoc"; - -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApplicationComponentRestResource.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApplicationComponentRestResource.java b/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApplicationComponentRestResource.java deleted file mode 100644 index 5b2df5b..0000000 --- a/brooklyn-server/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApplicationComponentRestResource.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ -package org.apache.brooklyn.camp.server.rest.resource; - -import io.swagger.annotations.Api; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; - -import org.apache.brooklyn.camp.server.dto.ApplicationComponentDto; - -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; - -@Path(ApplicationComponentRestResource.URI_PATH) -@Api("Application Component resources") -@Produces("application/json") -public class ApplicationComponentRestResource extends AbstractCampRestResource { - - public static final String URI_PATH = PlatformRestResource.CAMP_URI_PATH + "/application-components"; - - @Path("/{id}") - @ApiOperation(value = "Get a specific application component", - response = ApplicationComponentDto.class) - @GET - public ApplicationComponentDto get( - @ApiParam(value = "ID of item being retrieved", required = true) - @PathParam("id") String id) { - return dto().adapt(lookup(camp().applicationComponents(), id)); - } - -}
