You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by sj...@apache.org on 2016/04/07 13:14:13 UTC
[7/9] brooklyn-server git commit: Remove jersey compatibility
Remove jersey compatibility
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/3be4fe11
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/3be4fe11
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/3be4fe11
Branch: refs/heads/master
Commit: 3be4fe11e74b01a85234fe5d0c96d043d3cb44e1
Parents: 36a2918
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Thu Mar 31 11:37:30 2016 +0300
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Fri Apr 1 09:31:08 2016 +0300
----------------------------------------------------------------------
camp/camp-server-jersey/pom.xml | 225 ------
.../brooklyn/camp/server/RestApiSetup.java | 53 --
.../rest/resource/ApiListingResource.java | 260 -------
.../rest/resource/ApidocRestResource.java | 32 -
.../src/main/webapp/WEB-INF/web.xml | 142 ----
camp/pom.xml | 1 -
karaf/features/src/main/feature/feature.xml | 3 -
launcher/pom.xml | 25 +-
parent/pom.xml | 59 --
pom.xml | 3 -
rest/rest-client/pom.xml | 13 -
rest/rest-server-jersey/pom.xml | 351 ----------
.../org/apache/brooklyn/rest/RestApiSetup.java | 113 ---
.../rest/filter/EntitlementContextFilter.java | 63 --
.../rest/filter/HaHotCheckResourceFilter.java | 196 ------
.../brooklyn/rest/filter/NoCacheFilter.java | 42 --
.../rest/filter/RequestTaggingRsFilter.java | 76 --
.../brooklyn/rest/filter/SwaggerFilter.java | 76 --
.../rest/resources/ApiListingResource.java | 260 -------
.../brooklyn/rest/resources/ApidocResource.java | 33 -
.../brooklyn/rest/util/FormMapProvider.java | 81 ---
.../main/resources/build-metadata.properties | 18 -
.../src/main/webapp/WEB-INF/web.xml | 149 ----
.../BrooklynPropertiesSecurityFilterTest.java | 151 ----
.../brooklyn/rest/BrooklynRestApiLauncher.java | 498 -------------
.../rest/BrooklynRestApiLauncherTest.java | 77 --
.../BrooklynRestApiLauncherTestFixture.java | 109 ---
.../apache/brooklyn/rest/HaHotCheckTest.java | 160 -----
.../brooklyn/rest/HaMasterCheckFilterTest.java | 218 ------
.../rest/domain/AbstractDomainTest.java | 44 --
.../brooklyn/rest/domain/ApiErrorTest.java | 71 --
.../rest/domain/ApplicationSpecTest.java | 40 --
.../brooklyn/rest/domain/ApplicationTest.java | 87 ---
.../rest/domain/EffectorSummaryTest.java | 44 --
.../brooklyn/rest/domain/EntitySpecTest.java | 48 --
.../brooklyn/rest/domain/EntitySummaryTest.java | 48 --
.../brooklyn/rest/domain/LocationSpecTest.java | 58 --
.../rest/domain/LocationSummaryTest.java | 41 --
.../brooklyn/rest/domain/SensorSummaryTest.java | 103 ---
.../rest/domain/VersionSummaryTest.java | 49 --
.../AbstractRestApiEntitlementsTest.java | 111 ---
.../ActivityApiEntitlementsTest.java | 122 ----
.../AuthenticateAnyoneSecurityProvider.java | 41 --
.../EntityConfigApiEntitlementsTest.java | 103 ---
.../entitlement/SensorApiEntitlementsTest.java | 108 ---
.../entitlement/ServerApiEntitlementsTest.java | 34 -
.../StaticDelegatingEntitlementManager.java | 37 -
.../rest/resources/AccessResourceTest.java | 68 --
.../rest/resources/ApidocResourceTest.java | 173 -----
.../ApplicationResourceIntegrationTest.java | 133 ----
.../rest/resources/ApplicationResourceTest.java | 701 -------------------
.../rest/resources/CatalogResetTest.java | 113 ---
.../rest/resources/CatalogResourceTest.java | 515 --------------
.../rest/resources/DelegatingPrintStream.java | 183 -----
.../rest/resources/DescendantsTest.java | 130 ----
.../resources/EntityConfigResourceTest.java | 172 -----
.../rest/resources/EntityResourceTest.java | 189 -----
.../rest/resources/ErrorResponseTest.java | 98 ---
.../rest/resources/LocationResourceTest.java | 188 -----
.../rest/resources/PolicyResourceTest.java | 145 ----
.../rest/resources/ScriptResourceTest.java | 54 --
.../SensorResourceIntegrationTest.java | 82 ---
.../rest/resources/SensorResourceTest.java | 271 -------
.../ServerResourceIntegrationTest.java | 125 ----
.../rest/resources/ServerResourceTest.java | 168 -----
.../rest/resources/ServerShutdownTest.java | 185 -----
.../rest/resources/UsageResourceTest.java | 443 ------------
.../rest/resources/VersionResourceTest.java | 52 --
.../rest/security/PasswordHasherTest.java | 37 -
.../security/provider/TestSecurityProvider.java | 46 --
.../test/config/render/TestRendererHints.java | 36 -
.../brooklynnode/DeployBlueprintTest.java | 89 ---
.../rest/testing/BrooklynRestApiTest.java | 223 ------
.../rest/testing/BrooklynRestResourceTest.java | 154 ----
.../rest/testing/mocks/CapitalizePolicy.java | 33 -
.../rest/testing/mocks/EverythingGroup.java | 27 -
.../rest/testing/mocks/EverythingGroupImpl.java | 32 -
.../rest/testing/mocks/NameMatcherGroup.java | 30 -
.../testing/mocks/NameMatcherGroupImpl.java | 33 -
.../rest/testing/mocks/RestMockApp.java | 24 -
.../rest/testing/mocks/RestMockAppBuilder.java | 39 --
.../testing/mocks/RestMockSimpleEntity.java | 103 ---
.../testing/mocks/RestMockSimplePolicy.java | 64 --
.../util/BrooklynRestResourceUtilsTest.java | 213 ------
.../rest/util/EntityLocationUtilsTest.java | 72 --
.../rest/util/NoOpRecordingShutdownHandler.java | 39 --
.../util/NullHttpServletRequestProvider.java | 46 --
.../rest/util/NullServletConfigProvider.java | 51 --
.../brooklyn/rest/util/RestApiTestUtils.java | 58 --
.../util/ServerStoppingShutdownHandler.java | 75 --
.../TestingHaHotStateCheckClassResource.java | 38 -
.../util/TestingHaHotStateCheckResource.java | 44 --
.../rest/util/TestingHaMasterCheckResource.java | 41 --
.../json/BrooklynJacksonSerializerTest.java | 399 -----------
.../resources/brooklyn/scanning.catalog.bom | 19 -
.../resources/fixtures/api-error-basic.json | 4 -
.../fixtures/api-error-no-details.json | 3 -
.../resources/fixtures/application-list.json | 44 --
.../resources/fixtures/application-spec.json | 16 -
.../resources/fixtures/application-tree.json | 43 --
.../test/resources/fixtures/application.json | 22 -
.../fixtures/catalog-application-list.json | 29 -
.../resources/fixtures/catalog-application.json | 9 -
.../fixtures/effector-summary-list.json | 47 --
.../resources/fixtures/effector-summary.json | 9 -
.../resources/fixtures/entity-only-type.json | 3 -
.../resources/fixtures/entity-summary-list.json | 14 -
.../test/resources/fixtures/entity-summary.json | 13 -
.../src/test/resources/fixtures/entity.json | 7 -
.../src/test/resources/fixtures/ha-summary.json | 19 -
.../test/resources/fixtures/location-list.json | 10 -
.../resources/fixtures/location-summary.json | 8 -
.../fixtures/location-without-credential.json | 5 -
.../src/test/resources/fixtures/location.json | 4 -
.../fixtures/sensor-current-state.json | 6 -
.../resources/fixtures/sensor-summary-list.json | 42 --
.../test/resources/fixtures/sensor-summary.json | 8 -
.../test/resources/fixtures/server-version.json | 14 -
.../test/resources/fixtures/service-state.json | 1 -
.../resources/fixtures/task-summary-list.json | 15 -
rest/rest-server/pom.xml | 5 +-
121 files changed, 4 insertions(+), 11325 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3be4fe11/camp/camp-server-jersey/pom.xml
----------------------------------------------------------------------
diff --git a/camp/camp-server-jersey/pom.xml b/camp/camp-server-jersey/pom.xml
deleted file mode 100644
index 8854b7b..0000000
--- a/camp/camp-server-jersey/pom.xml
+++ /dev/null
@@ -1,225 +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>
- <artifactId>camp-server-jersey</artifactId>
- <packaging>jar</packaging>
- <name>CAMP Server Jersey</name>
- <description>
- REST Server classes for CAMP server implementation, using Jersey dependencies
- </description>
-
- <parent>
- <groupId>org.apache.brooklyn.camp</groupId>
- <artifactId>camp-parent</artifactId>
- <version>0.10.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</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>
- <exclusions>
- <exclusion>
- <groupId>javax.ws.rs</groupId>
- <artifactId>javax.ws.rs-api</artifactId>
- </exclusion>
- </exclusions>
- </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>
- <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>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-rest-sources</id>
- <phase>generate-sources</phase>
- <goals><goal>copy-resources</goal></goals>
- <configuration>
- <outputDirectory>target/generated-sources/rest-deps</outputDirectory>
- <resources>
- <resource>
- <directory>../camp-server/src/main/java</directory>
- <excludes>
- <exclude>**/RestApiSetup.java</exclude>
- <exclude>**/ApidocRestResource.java</exclude>
- </excludes>
- </resource>
- </resources>
- </configuration>
- </execution>
- <execution>
- <id>copy-test-rest-sources</id>
- <phase>generate-sources</phase>
- <goals><goal>copy-resources</goal></goals>
- <configuration>
- <outputDirectory>target/generated-sources/test-rest-deps</outputDirectory>
- <resources>
- <resource>
- <directory>../camp-server/src/test/java</directory>
- </resource>
- </resources>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>rest-sources</id>
- <phase>generate-sources</phase>
- <goals><goal>add-source</goal></goals>
- <configuration>
- <sources>
- <source>target/generated-sources/rest-deps</source>
- </sources>
- </configuration>
- </execution>
- <execution>
- <id>test-rest-sources</id>
- <phase>generate-sources</phase>
- <goals><goal>add-test-source</goal></goals>
- <configuration>
- <sources>
- <source>target/generated-sources/test-rest-deps</source>
- </sources>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3be4fe11/camp/camp-server-jersey/src/main/java/org/apache/brooklyn/camp/server/RestApiSetup.java
----------------------------------------------------------------------
diff --git a/camp/camp-server-jersey/src/main/java/org/apache/brooklyn/camp/server/RestApiSetup.java b/camp/camp-server-jersey/src/main/java/org/apache/brooklyn/camp/server/RestApiSetup.java
deleted file mode 100644
index 60a44e0..0000000
--- a/camp/camp-server-jersey/src/main/java/org/apache/brooklyn/camp/server/RestApiSetup.java
+++ /dev/null
@@ -1,53 +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;
-
-import java.util.EnumSet;
-
-import javax.servlet.DispatcherType;
-
-import org.apache.brooklyn.camp.server.rest.CampRestResources;
-import org.eclipse.jetty.servlet.FilterHolder;
-import org.eclipse.jetty.servlet.ServletContextHandler;
-
-import com.sun.jersey.api.core.DefaultResourceConfig;
-import com.sun.jersey.api.core.ResourceConfig;
-import com.sun.jersey.spi.container.servlet.ServletContainer;
-
-public class RestApiSetup {
-
- public static void install(ServletContextHandler context) {
- 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));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3be4fe11/camp/camp-server-jersey/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApiListingResource.java
----------------------------------------------------------------------
diff --git a/camp/camp-server-jersey/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApiListingResource.java b/camp/camp-server-jersey/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApiListingResource.java
deleted file mode 100644
index af656cc..0000000
--- a/camp/camp-server-jersey/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApiListingResource.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * Copyright 2015 The Apache Software Foundation.
- *
- * 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.
- */
-package org.apache.brooklyn.camp.server.rest.resource;
-
-import com.sun.jersey.spi.container.servlet.WebConfig;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.config.FilterFactory;
-import io.swagger.config.Scanner;
-import io.swagger.config.ScannerFactory;
-import io.swagger.config.SwaggerConfig;
-import io.swagger.core.filter.SpecFilter;
-import io.swagger.core.filter.SwaggerSpecFilter;
-import io.swagger.jaxrs.Reader;
-import io.swagger.jaxrs.config.JaxrsScanner;
-import io.swagger.jaxrs.config.ReaderConfigUtils;
-import io.swagger.jaxrs.listing.SwaggerSerializers;
-import io.swagger.models.Swagger;
-import io.swagger.util.Yaml;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Application;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Cookie;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-
-import org.apache.brooklyn.util.text.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * ApiListingResource usable within a jersey servlet filter.
- *
- * Taken from io.swagger:swagger-jaxrs, class
- * io.swagger.jaxrs.listing.ApiListingResource, which can only be used within a
- * servlet context. We are here using a filter, but jersey has a WebConfig class
- * that can substitute ServletConfig and FilterConfig.
- *
- * @todo Remove when the rest-server is no longer running within a filter (e.g.
- * as a standalone OSGi http service)
- *
- * @author Ciprian Ciubotariu <ch...@gmx.net>
- */
-public class ApiListingResource {
-
- static Logger LOGGER = LoggerFactory.getLogger(ApiListingResource.class);
-
- @Context
- ServletContext context;
-
- boolean initialized = false;
-
- private static class ServletConfigAdapter implements ServletConfig {
-
- private final WebConfig webConfig;
-
- private ServletConfigAdapter(WebConfig webConfig) {
- this.webConfig = webConfig;
- }
-
- @Override
- public String getServletName() {
- return webConfig.getName();
- }
-
- @Override
- public ServletContext getServletContext() {
- return webConfig.getServletContext();
- }
-
- @Override
- public String getInitParameter(String name) {
- return webConfig.getInitParameter(name);
- }
-
- @Override
- public Enumeration<String> getInitParameterNames() {
- return webConfig.getInitParameterNames();
- }
-
- }
-
- protected synchronized Swagger scan(Application app, WebConfig sc) {
- Swagger swagger = null;
- Scanner scanner = ScannerFactory.getScanner();
- LOGGER.debug("using scanner " + scanner);
-
- if (scanner != null) {
- SwaggerSerializers.setPrettyPrint(scanner.getPrettyPrint());
- swagger = (Swagger) context.getAttribute("swagger");
-
- Set<Class<?>> classes;
- if (scanner instanceof JaxrsScanner) {
- JaxrsScanner jaxrsScanner = (JaxrsScanner) scanner;
- classes = jaxrsScanner.classesFromContext(app, new ServletConfigAdapter(sc));
- } else {
- classes = scanner.classes();
- }
- if (classes != null) {
- Reader reader = new Reader(swagger, ReaderConfigUtils.getReaderConfig(context));
- swagger = reader.read(classes);
- if (scanner instanceof SwaggerConfig) {
- swagger = ((SwaggerConfig) scanner).configure(swagger);
- } else {
- SwaggerConfig configurator = (SwaggerConfig) context.getAttribute("reader");
- if (configurator != null) {
- LOGGER.debug("configuring swagger with " + configurator);
- configurator.configure(swagger);
- } else {
- LOGGER.debug("no configurator");
- }
- }
- context.setAttribute("swagger", swagger);
- }
- }
- initialized = true;
- return swagger;
- }
-
- private Swagger process(
- Application app,
- WebConfig sc,
- HttpHeaders headers,
- UriInfo uriInfo) {
- Swagger swagger = (Swagger) context.getAttribute("swagger");
- if (!initialized) {
- swagger = scan(app, sc);
- }
- if (swagger != null) {
- SwaggerSpecFilter filterImpl = FilterFactory.getFilter();
- if (filterImpl != null) {
- SpecFilter f = new SpecFilter();
- swagger = f.filter(swagger, filterImpl, getQueryParams(uriInfo.getQueryParameters()), getCookies(headers),
- getHeaders(headers));
- }
- }
- return swagger;
- }
-
- @GET
- @Produces({MediaType.APPLICATION_JSON, "application/yaml"})
- @ApiOperation(value = "The swagger definition in either JSON or YAML", hidden = true)
- @Path("/swagger.{type:json|yaml}")
- public Response getListing(
- @Context Application app,
- @Context WebConfig sc,
- @Context HttpHeaders headers,
- @Context UriInfo uriInfo,
- @PathParam("type") String type) {
- if (Strings.isNonBlank(type) && type.trim().equalsIgnoreCase("yaml")) {
- return getListingYaml(app, sc, headers, uriInfo);
- } else {
- return getListingJson(app, sc, headers, uriInfo);
- }
- }
-
- @GET
- @Produces({MediaType.APPLICATION_JSON})
- @Path("/swagger")
- @ApiOperation(value = "The swagger definition in JSON", hidden = true)
- public Response getListingJson(
- @Context Application app,
- @Context WebConfig sc,
- @Context HttpHeaders headers,
- @Context UriInfo uriInfo) {
- Swagger swagger = process(app, sc, headers, uriInfo);
-
- if (swagger != null) {
- return Response.ok().entity(swagger).build();
- } else {
- return Response.status(404).build();
- }
- }
-
- @GET
- @Produces("application/yaml")
- @Path("/swagger")
- @ApiOperation(value = "The swagger definition in YAML", hidden = true)
- public Response getListingYaml(
- @Context Application app,
- @Context WebConfig sc,
- @Context HttpHeaders headers,
- @Context UriInfo uriInfo) {
- Swagger swagger = process(app, sc, headers, uriInfo);
- try {
- if (swagger != null) {
- String yaml = Yaml.mapper().writeValueAsString(swagger);
- StringBuilder b = new StringBuilder();
- String[] parts = yaml.split("\n");
- for (String part : parts) {
- b.append(part);
- b.append("\n");
- }
- return Response.ok().entity(b.toString()).type("application/yaml").build();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return Response.status(404).build();
- }
-
- protected Map<String, List<String>> getQueryParams(MultivaluedMap<String, String> params) {
- Map<String, List<String>> output = new HashMap<>();
- if (params != null) {
- for (String key : params.keySet()) {
- List<String> values = params.get(key);
- output.put(key, values);
- }
- }
- return output;
- }
-
- protected Map<String, String> getCookies(HttpHeaders headers) {
- Map<String, String> output = new HashMap<>();
- if (headers != null) {
- for (String key : headers.getCookies().keySet()) {
- Cookie cookie = headers.getCookies().get(key);
- output.put(key, cookie.getValue());
- }
- }
- return output;
- }
-
- protected Map<String, List<String>> getHeaders(HttpHeaders headers) {
- Map<String, List<String>> output = new HashMap<>();
- if (headers != null) {
- for (String key : headers.getRequestHeaders().keySet()) {
- List<String> values = headers.getRequestHeaders().get(key);
- output.put(key, values);
- }
- }
- return output;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3be4fe11/camp/camp-server-jersey/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApidocRestResource.java
----------------------------------------------------------------------
diff --git a/camp/camp-server-jersey/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApidocRestResource.java b/camp/camp-server-jersey/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApidocRestResource.java
deleted file mode 100644
index 1696855..0000000
--- a/camp/camp-server-jersey/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApidocRestResource.java
+++ /dev/null
@@ -1,32 +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.ws.rs.Path;
-
-import io.swagger.annotations.Api;
-
-
-@Path(ApidocRestResource.API_URI_PATH)
-@Api("Web API Documentation")
-public class ApidocRestResource extends ApiListingResource {
-
- public static final String API_URI_PATH = PlatformRestResource.CAMP_URI_PATH + "/apidoc";
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3be4fe11/camp/camp-server-jersey/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/camp/camp-server-jersey/src/main/webapp/WEB-INF/web.xml b/camp/camp-server-jersey/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index 0ea4373..0000000
--- a/camp/camp-server-jersey/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,142 +0,0 @@
-<!DOCTYPE web-app PUBLIC
- "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd" >
-<!--
- 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.
--->
-<web-app>
- <display-name>Brooklyn REST API v1</display-name>
-
- <filter>
- <filter-name>Brooklyn Request Tagging Filter</filter-name>
- <filter-class>org.apache.brooklyn.rest.filter.RequestTaggingFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>Brooklyn Request Tagging Filter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
- <filter>
- <filter-name>Brooklyn Properties Authentication Filter</filter-name>
- <filter-class>org.apache.brooklyn.rest.filter.BrooklynPropertiesSecurityFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>Brooklyn Properties Authentication Filter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
- <filter>
- <filter-name>Brooklyn Logging Filter</filter-name>
- <filter-class>org.apache.brooklyn.rest.filter.LoggingFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>Brooklyn Logging Filter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
- <filter>
- <filter-name>Brooklyn HA Master Filter</filter-name>
- <filter-class>org.apache.brooklyn.rest.filter.HaMasterCheckFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>Brooklyn HA Master Filter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
- <filter>
- <filter-name>Brooklyn Swagger Bootstrap</filter-name>
- <filter-class>org.apache.brooklyn.rest.filter.SwaggerFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>Brooklyn Swagger Bootstrap</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
- <!-- Brooklyn REST is usually run as a filter so static content can be placed in a webapp
- to which this is added; to run as a servlet directly, replace the filter tags
- below (after the comment) with the servlet tags (commented out immediately below),
- (and do the same for the matching tags at the bottom)
- <servlet>
- <servlet-name>Brooklyn REST API v1 Servlet</servlet-name>
- <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
- -->
- <filter>
- <filter-name>Brooklyn REST API v1 Filter</filter-name>
- <filter-class>com.sun.jersey.spi.container.servlet.ServletContainer</filter-class>
-
- <!-- load our REST API jersey resources explicitly
- (the package scanner will only pick up classes with @Path annotations - doesn't look at implemented interfaces)
- -->
- <init-param>
- <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
- <param-value>com.sun.jersey.api.core.ClassNamesResourceConfig</param-value>
- </init-param>
- <init-param>
- <param-name>com.sun.jersey.config.property.classnames</param-name>
- <param-value>
- io.swagger.jaxrs.listing.SwaggerSerializers;
- org.apache.brooklyn.rest.util.FormMapProvider;
- org.codehaus.jackson.jaxrs.JacksonJsonProvider;
- org.apache.brooklyn.rest.resources.ActivityResource;
- org.apache.brooklyn.rest.resources.ApidocResource;
- org.apache.brooklyn.rest.resources.ApplicationResource;
- org.apache.brooklyn.rest.resources.CatalogResource;
- org.apache.brooklyn.rest.resources.EffectorResource;
- org.apache.brooklyn.rest.resources.EntityConfigResource;
- org.apache.brooklyn.rest.resources.EntityResource;
- org.apache.brooklyn.rest.resources.LocationResource;
- org.apache.brooklyn.rest.resources.PolicyConfigResource;
- org.apache.brooklyn.rest.resources.PolicyResource;
- org.apache.brooklyn.rest.resources.ScriptResource;
- org.apache.brooklyn.rest.resources.SensorResource;
- org.apache.brooklyn.rest.resources.UsageResource;
- org.apache.brooklyn.rest.resources.VersionResource;
- </param-value>
- </init-param>
-
- <init-param>
- <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
- <param-value>true</param-value>
- </init-param>
-
- <!-- no need for WADL. of course you can turn it back on it you want. -->
- <init-param>
- <param-name>com.sun.jersey.config.feature.DisableWADL</param-name>
- <param-value>true</param-value>
- </init-param>
-
- <init-param>
- <param-name>com.sun.jersey.config.feature.FilterContextPath</param-name>
- <param-value>/v1</param-value>
- </init-param>
-
- </filter>
- <filter-mapping>
- <filter-name>Brooklyn REST API v1 Filter</filter-name>
- <url-pattern>/v1/*</url-pattern>
- </filter-mapping>
- <!-- Brooklyn REST as a filter above; replace above 5 lines with those commented out below,
- to run it as a servlet (see note above)
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>Brooklyn REST API v1 Servlet</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
- -->
-</web-app>
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3be4fe11/camp/pom.xml
----------------------------------------------------------------------
diff --git a/camp/pom.xml b/camp/pom.xml
index 441d0dd..4038247 100644
--- a/camp/pom.xml
+++ b/camp/pom.xml
@@ -39,7 +39,6 @@
<modules>
<module>camp-base</module>
<module>camp-server</module>
- <module>camp-server-jersey</module>
<module>camp-brooklyn</module>
</modules>
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3be4fe11/karaf/features/src/main/feature/feature.xml
----------------------------------------------------------------------
diff --git a/karaf/features/src/main/feature/feature.xml b/karaf/features/src/main/feature/feature.xml
index 6200b88..5de0241 100644
--- a/karaf/features/src/main/feature/feature.xml
+++ b/karaf/features/src/main/feature/feature.xml
@@ -88,15 +88,12 @@
<bundle>mvn:org.apache.brooklyn/brooklyn-rest-api/${project.version}</bundle>
- <bundle dependency="true">mvn:com.sun.jersey.contribs/jersey-multipart/${jersey.version}</bundle>
<bundle dependency="true">mvn:org.jvnet.mimepull/mimepull/1.9.3</bundle>
<bundle dependency="true">mvn:commons-lang/commons-lang/${commons-lang.version}</bundle>
<!-- TODO: version 1.1.0.Final has OSGi manifest; check if upgrade doesn't get rid of wrap -->
<bundle dependency="true">wrap:mvn:javax.validation/validation-api/${validation-api.version}</bundle>
- <!--<feature>jersey</feature>-->
- <bundle dependency="true">mvn:com.sun.jersey/jersey-servlet/${jersey.version}</bundle>
<bundle dependency="true">mvn:org.apache.commons/commons-lang3/${commons-lang3.version}</bundle>
<bundle dependency="true">mvn:com.fasterxml.jackson.core/jackson-annotations/${fasterxml.jackson.version}</bundle>
<bundle dependency="true">mvn:com.fasterxml.jackson.core/jackson-databind/${fasterxml.jackson.version}</bundle>
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3be4fe11/launcher/pom.xml
----------------------------------------------------------------------
diff --git a/launcher/pom.xml b/launcher/pom.xml
index b5a3575..2ecb2f8 100644
--- a/launcher/pom.xml
+++ b/launcher/pom.xml
@@ -53,7 +53,7 @@
</dependency>
<dependency>
<groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-rest-server${rest-server-classifier}</artifactId>
+ <artifactId>brooklyn-rest-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@@ -68,7 +68,7 @@
</dependency>
<dependency>
<groupId>org.apache.brooklyn.camp</groupId>
- <artifactId>camp-server${rest-server-classifier}</artifactId>
+ <artifactId>camp-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@@ -187,7 +187,7 @@
</dependency>
<dependency>
<groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-rest-server${rest-server-classifier}</artifactId>
+ <artifactId>brooklyn-rest-server</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
@@ -267,23 +267,4 @@
</plugin>
</plugins>
</build>
- <profiles>
- <profile>
- <id>jax-rs-jersey</id>
- <activation>
- <property>
- <name>!jar-rs</name>
- </property>
- </activation>
- <dependencies>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-rest-resources</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
- </dependencies>
- </profile>
- </profiles>
</project>
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3be4fe11/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index b2e2e8e..4efc785 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -52,10 +52,6 @@
http://stackoverflow.com/questions/5309379/how-to-keep-maven-profiles-which-are-activebydefault-active-even-if-another-prof )
-->
- <properties>
- <rest-server-classifier />
- </properties>
-
<dependencyManagement>
<dependencies>
<dependency>
@@ -469,12 +465,6 @@
</dependency>
<!-- JAX-RS dependencies-->
- <!-- JAX-RS 1.1 API -->
- <dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>jsr311-api</artifactId>
- <version>${jsr311-api.version}</version>
- </dependency>
<!-- JAX-RS 2.0 API -->
<dependency>
<groupId>javax.ws.rs</groupId>
@@ -502,42 +492,6 @@
<artifactId>cxf-rt-rs-client</artifactId>
<version>${cxf.version}</version>
</dependency>
- <!-- JAX-RS 1.1 Jersey Implementation -->
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-core</artifactId>
- <version>${jersey.version}</version>
- </dependency>
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-client</artifactId>
- <version>${jersey.version}</version>
- </dependency>
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-server</artifactId>
- <version>${jersey.version}</version>
- </dependency>
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-servlet</artifactId>
- <version>${jersey.version}</version>
- </dependency>
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-json</artifactId>
- <version>${jersey.version}</version>
- </dependency>
- <dependency>
- <groupId>com.sun.jersey.jersey-test-framework</groupId>
- <artifactId>jersey-test-framework-inmemory</artifactId>
- <version>${jersey.version}</version>
- </dependency>
- <dependency>
- <groupId>com.sun.jersey.jersey-test-framework</groupId>
- <artifactId>jersey-test-framework-grizzly2</artifactId>
- <version>${jersey.version}</version>
- </dependency>
<!-- JAX-RS 2.0 RESTEasy Implementation -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
@@ -1787,18 +1741,5 @@
</pluginManagement>
</build>
</profile>
-
- <profile>
- <id>jersey-deps</id>
- <activation>
- <property>
- <name>jax-rs</name>
- <value>jersey</value>
- </property>
- </activation>
- <properties>
- <rest-server-classifier>-jersey</rest-server-classifier>
- </properties>
- </profile>
</profiles>
</project>
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3be4fe11/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 433e912..cff3d4f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -102,7 +102,6 @@
<!-- double-check downstream projects before changing jackson and resteasy versions -->
<fasterxml.jackson.version>2.4.5</fasterxml.jackson.version>
<resteasy.version>3.0.8.Final</resteasy.version>
- <jersey.version>1.19</jersey.version>
<cxf.version>3.1.4</cxf.version>
<httpclient.version>4.4.1</httpclient.version>
<commons-lang3.version>3.3.2</commons-lang3.version>
@@ -150,7 +149,6 @@
<commons-configuration.version>1.7</commons-configuration.version>
<commons-lang.version>2.4</commons-lang.version>
<hamcrest.version>1.1</hamcrest.version>
- <jsr311-api.version>1.1.1</jsr311-api.version>
<jax-rs-api.version>2.0.1</jax-rs-api.version>
<maxmind.version>0.8.1</maxmind.version>
<maxmind-db.version>0.3.4</maxmind-db.version>
@@ -216,7 +214,6 @@
<module>rest/rest-client</module>
<module>rest/rest-resources</module>
<module>rest/rest-server</module>
- <module>rest/rest-server-jersey</module>
<module>test-framework</module>
<module>test-support</module>
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3be4fe11/rest/rest-client/pom.xml
----------------------------------------------------------------------
diff --git a/rest/rest-client/pom.xml b/rest/rest-client/pom.xml
index 1828f8f..069bce5 100644
--- a/rest/rest-client/pom.xml
+++ b/rest/rest-client/pom.xml
@@ -89,19 +89,6 @@
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
- <!--
- mvn dependency:analyze complains that these dependencies are unused when present but
- used and undeclared when removed!
- -->
- <!--dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>jaxrs-api</artifactId>
- </dependency-->
-
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3be4fe11/rest/rest-server-jersey/pom.xml
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/pom.xml b/rest/rest-server-jersey/pom.xml
deleted file mode 100644
index b4fabd8..0000000
--- a/rest/rest-server-jersey/pom.xml
+++ /dev/null
@@ -1,351 +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>
- <artifactId>brooklyn-rest-server-jersey</artifactId>
- <packaging>jar</packaging>
- <name>Brooklyn REST Server with Jersey dependencies</name>
- <description>
- Brooklyn REST Endpoint, using Jersey as the JAR-RS implementation
- </description>
-
- <parent>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-parent</artifactId>
- <version>0.10.0-SNAPSHOT</version><!-- BROOKLYN_VERSION -->
- <relativePath>../../parent/pom.xml</relativePath>
- </parent>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.validation</groupId>
- <artifactId>validation-api</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.code.findbugs</groupId>
- <artifactId>jsr305</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- </dependency>
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-utils-common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>io.swagger</groupId>
- <artifactId>swagger-annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-test-support</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
-
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-camp</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn.camp</groupId>
- <artifactId>camp-base</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-software-base</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-utils-rest-swagger</artifactId>
- <version>${project.version}</version>
- <exclusions>
- <exclusion>
- <groupId>javax.ws.rs</groupId>
- <artifactId>javax.ws.rs-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.yaml</groupId>
- <artifactId>snakeyaml</artifactId>
- </dependency>
- <dependency>
- <groupId>org.reflections</groupId>
- <artifactId>reflections</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>jsr311-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </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>org.eclipse.jetty</groupId>
- <artifactId>jetty-webapp</artifactId>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-jaas</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.apache.brooklyn</groupId>
- <artifactId>brooklyn-policy</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-core</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-software-base</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-locations-jclouds</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-all</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-client</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.sun.jersey.jersey-test-framework</groupId>
- <artifactId>jersey-test-framework-inmemory</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.sun.jersey.jersey-test-framework</groupId>
- <artifactId>jersey-test-framework-grizzly2</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-utils-common</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <resources>
- <resource>
- <directory>../rest-server/src/main/resources</directory>
- <!-- Required to set values in build-metadata.properties -->
- <filtering>true</filtering>
- </resource>
- <resource>
- <directory>src/main/webapp</directory>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-rest-sources</id>
- <phase>generate-sources</phase>
- <goals><goal>copy-resources</goal></goals>
- <configuration>
- <outputDirectory>target/generated-sources/rest-deps</outputDirectory>
- <resources>
- <resource>
- <directory>../rest-api/src/main/java</directory>
- </resource>
- <resource>
- <directory>../rest-resources/src/main/java</directory>
- <excludes>
- <exclude>**/NoCacheFilter.java</exclude>
- <exclude>**/HaHotCheckResourceFilter.java</exclude>
- <exclude>**/FormMapProvider.java</exclude>
- <exclude>**/ApidocResource.java</exclude>
- <exclude>**/RequestTaggingFilter.java</exclude>
- <exclude>**/EntitlementContextFilter.java</exclude>
- <exclude>**/RequestTaggingRsFilter.java</exclude>
- <exclude>**/ScannerInjectHelper.java</exclude>
- </excludes>
- </resource>
- <resource>
- <directory>../rest-server/src/main/java</directory>
- <excludes>
- <exclude>**/RestApiSetup.java</exclude>
- </excludes>
- </resource>
- </resources>
- </configuration>
- </execution>
- <execution>
- <id>copy-rest-resources</id>
- <phase>generate-resources</phase>
- <goals><goal>copy-resources</goal></goals>
- <configuration>
- <outputDirectory>target/generated-resources/rest-deps</outputDirectory>
- <resources>
- <resource>
- <directory>../rest-resources/src/main/resources</directory>
- <includes>
- <include>**/jaas.conf</include>
- </includes>
- </resource>
- </resources>
- </configuration>
- </execution>
- <execution>
- <id>copy-rest-test-resources</id>
- <phase>generate-test-resources</phase>
- <goals><goal>copy-resources</goal></goals>
- <configuration>
- <outputDirectory>target/generated-test-resources/rest-deps</outputDirectory>
- <resources>
- <resource>
- <directory>../rest-resources/src/test/resources</directory>
- </resource>
- <resource>
- <directory>../rest-server/src/test/resources</directory>
- </resource>
- </resources>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>rest-sources</id>
- <phase>generate-sources</phase>
- <goals><goal>add-source</goal></goals>
- <configuration>
- <sources>
- <source>target/generated-sources/rest-deps</source>
- </sources>
- </configuration>
- </execution>
- <execution>
- <id>rest-resources</id>
- <phase>generate-resources</phase>
- <goals><goal>add-resource</goal></goals>
- <configuration>
- <resources>
- <resource>
- <directory>target/generated-resources/rest-deps</directory>
- </resource>
- </resources>
- </configuration>
- </execution>
- <execution>
- <id>rest-test-resources</id>
- <phase>generate-test-resources</phase>
- <goals><goal>add-test-resource</goal></goals>
- <configuration>
- <resources>
- <resource>
- <directory>target/generated-test-resources/rest-deps</directory>
- </resource>
- </resources>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3be4fe11/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/RestApiSetup.java
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/RestApiSetup.java b/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/RestApiSetup.java
deleted file mode 100644
index 1cb4d5d..0000000
--- a/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/RestApiSetup.java
+++ /dev/null
@@ -1,113 +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.rest;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.EnumSet;
-import java.util.List;
-
-import javax.servlet.DispatcherType;
-import javax.servlet.Filter;
-import javax.ws.rs.ext.ContextResolver;
-
-import org.apache.brooklyn.rest.filter.HaHotCheckResourceFilter;
-import org.apache.brooklyn.rest.filter.SwaggerFilter;
-import org.apache.brooklyn.rest.util.ManagementContextProvider;
-import org.apache.brooklyn.util.collections.MutableList;
-import org.eclipse.jetty.servlet.FilterHolder;
-import org.eclipse.jetty.servlet.ServletContextHandler;
-
-import com.sun.jersey.api.container.filter.GZIPContentEncodingFilter;
-import com.sun.jersey.api.core.DefaultResourceConfig;
-import com.sun.jersey.api.core.ResourceConfig;
-import com.sun.jersey.spi.container.ContainerRequestFilter;
-import com.sun.jersey.spi.container.ContainerResponseFilter;
-import com.sun.jersey.spi.container.ResourceFilterFactory;
-import com.sun.jersey.spi.container.servlet.ServletContainer;
-
-public class RestApiSetup {
-
- public static void installRest(ServletContextHandler context, Object... providers) {
- List<Object> providerList = MutableList.copyOf(Arrays.asList(providers))
- .append(new GZIPContentEncodingFilter());
-
- injectHa(providers);
-
- ResourceConfig config = new DefaultResourceConfig();
- // load all our REST API modules, JSON, and Swagger
- for (Object r: BrooklynRestApi.getAllResources())
- config.getSingletons().add(r);
- for (Object o: getProvidersOfType(providerList, ContextResolver.class))
- config.getSingletons().add(o);
-
- config.getProperties().put(ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS, getProvidersOfType(providerList, ContainerRequestFilter.class));
- config.getProperties().put(ResourceConfig.PROPERTY_CONTAINER_RESPONSE_FILTERS, getProvidersOfType(providerList, ContainerResponseFilter.class));
- config.getProperties().put(ResourceConfig.PROPERTY_RESOURCE_FILTER_FACTORIES, getProvidersOfType(providerList, ResourceFilterFactory.class));
-
- // 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));
-
- filterHolder.setInitParameter(ServletContainer.PROPERTY_FILTER_CONTEXT_PATH, "/v1");
- context.addFilter(filterHolder, "/v1/*", EnumSet.allOf(DispatcherType.class));
-
- installServletFilters(context, SwaggerFilter.class);
- }
-
- // An ugly hack to work around injection missing for HaHotCheckProvider
- private static void injectHa(Object[] providers) {
- HaHotCheckResourceFilter haFilter = null;
- ManagementContextProvider mgmtProvider = null;
- for (Object o : providers) {
- if (o instanceof HaHotCheckResourceFilter) {
- haFilter = (HaHotCheckResourceFilter) o;
- } else if (o instanceof ManagementContextProvider) {
- mgmtProvider = (ManagementContextProvider) o;
- }
- }
- haFilter.setManagementContext(mgmtProvider);
- }
-
- private static List<Object> getProvidersOfType(List<Object> providers, Class<?> type) {
- List<Object> ret = new ArrayList<>();
- for (Object o : providers) {
- if (type.isInstance(o)) {
- ret.add(o);
- }
- }
- return ret;
- }
-
- @SafeVarargs
- public static void installServletFilters(ServletContextHandler context, Class<? extends Filter>... filters) {
- installServletFilters(context, Arrays.asList(filters));
- }
-
- public static void installServletFilters(ServletContextHandler context, Collection<Class<? extends Filter>> filters) {
- for (Class<? extends Filter> filter : filters) {
- context.addFilter(filter, "/*", EnumSet.allOf(DispatcherType.class));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3be4fe11/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/filter/EntitlementContextFilter.java
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/filter/EntitlementContextFilter.java b/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/filter/EntitlementContextFilter.java
deleted file mode 100644
index 2c3e200..0000000
--- a/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/filter/EntitlementContextFilter.java
+++ /dev/null
@@ -1,63 +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.rest.filter;
-
-import java.security.Principal;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.SecurityContext;
-
-import org.apache.brooklyn.core.mgmt.entitlement.Entitlements;
-import org.apache.brooklyn.core.mgmt.entitlement.WebEntitlementContext;
-
-import com.sun.jersey.core.util.Priority;
-import com.sun.jersey.spi.container.ContainerRequest;
-import com.sun.jersey.spi.container.ContainerRequestFilter;
-import com.sun.jersey.spi.container.ContainerResponse;
-import com.sun.jersey.spi.container.ContainerResponseFilter;
-
-@Priority(400)
-public class EntitlementContextFilter implements ContainerRequestFilter, ContainerResponseFilter {
- @Context
- private HttpServletRequest servletRequest;
-
- @Override
- public ContainerRequest filter(ContainerRequest request) {
- SecurityContext securityContext = request.getSecurityContext();
- Principal user = securityContext.getUserPrincipal();
-
- if (user != null) {
- String uri = servletRequest.getRequestURI();
- String remoteAddr = servletRequest.getRemoteAddr();
-
- String uid = RequestTaggingFilter.getTag();
- WebEntitlementContext entitlementContext = new WebEntitlementContext(user.getName(), remoteAddr, uri, uid);
- Entitlements.setEntitlementContext(entitlementContext);
- }
- return request;
- }
-
- @Override
- public ContainerResponse filter(ContainerRequest request, ContainerResponse response) {
- Entitlements.clearEntitlementContext();
- return response;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3be4fe11/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/filter/HaHotCheckResourceFilter.java
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/filter/HaHotCheckResourceFilter.java b/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/filter/HaHotCheckResourceFilter.java
deleted file mode 100644
index 920b982..0000000
--- a/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/filter/HaHotCheckResourceFilter.java
+++ /dev/null
@@ -1,196 +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.rest.filter;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.ext.ContextResolver;
-
-import org.apache.brooklyn.api.mgmt.ManagementContext;
-import org.apache.brooklyn.api.mgmt.ha.ManagementNodeState;
-import org.apache.brooklyn.rest.domain.ApiError;
-import org.apache.brooklyn.util.text.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.ImmutableSet;
-import com.sun.jersey.api.model.AbstractMethod;
-import com.sun.jersey.core.util.Priority;
-import com.sun.jersey.spi.container.ContainerRequest;
-import com.sun.jersey.spi.container.ContainerRequestFilter;
-import com.sun.jersey.spi.container.ContainerResponseFilter;
-import com.sun.jersey.spi.container.ResourceFilter;
-import com.sun.jersey.spi.container.ResourceFilterFactory;
-
-/**
- * Checks that if the method or resource class corresponding to a request
- * has a {@link HaHotStateRequired} annotation,
- * that the server is in that state (and up).
- * Requests with {@link #SKIP_CHECK_HEADER} set as a header skip this check.
- * <p>
- * This follows a different pattern to {@link HaMasterCheckFilter}
- * as this needs to know the method being invoked.
- */
-@Priority(300)
-public class HaHotCheckResourceFilter implements ResourceFilterFactory {
- private static final Set<String> SAFE_STANDBY_METHODS = ImmutableSet.of("GET", "HEAD");
- public static final String SKIP_CHECK_HEADER = "Brooklyn-Allow-Non-Master-Access";
-
- private static final Logger log = LoggerFactory.getLogger(HaHotCheckResourceFilter.class);
-
- private static final Set<ManagementNodeState> HOT_STATES = ImmutableSet.of(
- ManagementNodeState.MASTER, ManagementNodeState.HOT_STANDBY, ManagementNodeState.HOT_BACKUP);
-
- @Context
- private ContextResolver<ManagementContext> mgmt;
-
- public HaHotCheckResourceFilter() {}
-
- @VisibleForTesting
- public HaHotCheckResourceFilter(ContextResolver<ManagementContext> mgmt) {
- this.mgmt = mgmt;
- }
-
- // mgmt doesn't get injected for some reason, instead of looking for the cause just pass it at init time
- public void setManagementContext(ContextResolver<ManagementContext> mgmt) {
- this.mgmt = mgmt;
- }
-
- private ManagementContext mgmt() {
- return mgmt.getContext(ManagementContext.class);
- }
-
- private static class MethodFilter implements ResourceFilter, ContainerRequestFilter {
-
- private AbstractMethod am;
- private ManagementContext mgmt;
-
- public MethodFilter(AbstractMethod am, ManagementContext mgmt) {
- this.am = am;
- this.mgmt = mgmt;
- }
-
- @Override
- public ContainerRequestFilter getRequestFilter() {
- return this;
- }
-
- @Override
- public ContainerResponseFilter getResponseFilter() {
- return null;
- }
-
- private String lookForProblem(ContainerRequest request) {
- if (isSkipCheckHeaderSet(request))
- return null;
-
- if (isMasterRequiredForRequest(request) && !isMaster()) {
- return "server not in required HA master state";
- }
-
- if (!isHaHotStateRequired(request))
- return null;
-
- String problem = lookForProblemIfServerNotRunning(mgmt);
- if (Strings.isNonBlank(problem))
- return problem;
-
- if (!isHaHotStatus())
- return "server not in required HA hot state";
- if (isStateNotYetValid())
- return "server not yet completed loading data for required HA hot state";
-
- return null;
- }
-
- @Override
- public ContainerRequest filter(ContainerRequest request) {
- String problem = lookForProblem(request);
- if (Strings.isNonBlank(problem)) {
- log.warn("Disallowing web request as "+problem+": "+request.getRequestUri()+"/"+am+" (caller should set '"+SKIP_CHECK_HEADER+"' to force)");
- throw new WebApplicationException(ApiError.builder()
- .message("This request is only permitted against an active hot Brooklyn server")
- .errorCode(Response.Status.FORBIDDEN).build().asJsonResponse());
- }
- return request;
- }
-
- // Maybe there should be a separate state to indicate that we have switched state
- // but still haven't finished rebinding. (Previously there was a time delay and an
- // isRebinding check, but introducing RebindManager#isAwaitingInitialRebind() seems cleaner.)
- private boolean isStateNotYetValid() {
- return mgmt.getRebindManager().isAwaitingInitialRebind();
- }
-
- private boolean isMaster() {
- return ManagementNodeState.MASTER.equals(
- mgmt.getHighAvailabilityManager()
- .getNodeState());
- }
-
- private boolean isMasterRequiredForRequest(ContainerRequest requestContext) {
- // gets usually okay
- if (SAFE_STANDBY_METHODS.contains(requestContext.getMethod())) return false;
-
- String uri = requestContext.getRequestUri().toString();
- // explicitly allow calls to shutdown
- // (if stopAllApps is specified, the method itself will fail; but we do not want to consume parameters here, that breaks things!)
- // TODO use an annotation HaAnyStateAllowed or HaHotCheckRequired(false) or similar
- if ("server/shutdown".equals(uri) ||
- // Jersey compat
- "/v1/server/shutdown".equals(uri)) return false;
-
- return true;
- }
-
- private boolean isHaHotStateRequired(ContainerRequest request) {
- return (am.getAnnotation(HaHotStateRequired.class) != null ||
- am.getResource().getAnnotation(HaHotStateRequired.class) != null);
- }
-
- private boolean isSkipCheckHeaderSet(ContainerRequest request) {
- return "true".equalsIgnoreCase(request.getHeaderValue(SKIP_CHECK_HEADER));
- }
-
- private boolean isHaHotStatus() {
- ManagementNodeState state = mgmt.getHighAvailabilityManager().getNodeState();
- return HOT_STATES.contains(state);
- }
-
- }
-
- public static String lookForProblemIfServerNotRunning(ManagementContext mgmt) {
- if (mgmt==null) return "no management context available";
- if (!mgmt.isRunning()) return "server no longer running";
- if (!mgmt.isStartupComplete()) return "server not in required startup-completed state";
- return null;
- }
-
- @Override
- public List<ResourceFilter> create(AbstractMethod am) {
- return Collections.<ResourceFilter>singletonList(new MethodFilter(am, mgmt()));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3be4fe11/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/filter/NoCacheFilter.java
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/filter/NoCacheFilter.java b/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/filter/NoCacheFilter.java
deleted file mode 100644
index b66b3dc..0000000
--- a/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/filter/NoCacheFilter.java
+++ /dev/null
@@ -1,42 +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.rest.filter;
-
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MultivaluedMap;
-
-import com.sun.jersey.core.util.Priority;
-import com.sun.jersey.spi.container.ContainerRequest;
-import com.sun.jersey.spi.container.ContainerResponse;
-import com.sun.jersey.spi.container.ContainerResponseFilter;
-
-@Priority(200)
-public class NoCacheFilter implements ContainerResponseFilter {
-
- @Override
- public ContainerResponse filter(ContainerRequest request, ContainerResponse response) {
- //https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching_FAQ
- MultivaluedMap<String, Object> headers = response.getHttpHeaders();
- headers.putSingle(HttpHeaders.CACHE_CONTROL, "no-cache, no-store");
- headers.putSingle("Pragma", "no-cache");
- headers.putSingle(HttpHeaders.EXPIRES, "0");
- return response;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3be4fe11/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/filter/RequestTaggingRsFilter.java
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/filter/RequestTaggingRsFilter.java b/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/filter/RequestTaggingRsFilter.java
deleted file mode 100644
index 588c5c1..0000000
--- a/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/filter/RequestTaggingRsFilter.java
+++ /dev/null
@@ -1,76 +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.rest.filter;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.Context;
-
-import org.apache.brooklyn.util.text.Identifiers;
-
-import com.sun.jersey.core.util.Priority;
-import com.sun.jersey.spi.container.ContainerRequest;
-import com.sun.jersey.spi.container.ContainerRequestFilter;
-import com.sun.jersey.spi.container.ContainerResponse;
-import com.sun.jersey.spi.container.ContainerResponseFilter;
-
-/**
- * Tags each request with a probabilistically unique id. Should be included before other
- * filters to make sense.
- */
-@Priority(100)
-public class RequestTaggingRsFilter implements ContainerRequestFilter, ContainerResponseFilter {
- public static final String ATT_REQUEST_ID = RequestTaggingRsFilter.class.getName() + ".id";
-
- @Context
- private HttpServletRequest req;
-
- private static ThreadLocal<String> tag = new ThreadLocal<String>();
-
- protected static String getTag() {
- // Alternatively could use
- // PhaseInterceptorChain.getCurrentMessage().getId()
-
- return checkNotNull(tag.get());
- }
-
- @Override
- public ContainerRequest filter(ContainerRequest request) {
- String requestId = getRequestId();
- tag.set(requestId);
- return request;
- }
-
- private String getRequestId() {
- Object id = req.getAttribute(ATT_REQUEST_ID);
- if (id != null) {
- return id.toString();
- } else {
- return Identifiers.makeRandomId(6);
- }
- }
-
- @Override
- public ContainerResponse filter(ContainerRequest request, ContainerResponse response) {
- tag.remove();
- return response;
- }
-
-}