You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ao...@apache.org on 2015/02/10 17:56:56 UTC
ambari git commit: AMBARI-9552. Remove deprecated API for /stacks2
(aonishuk)
Repository: ambari
Updated Branches:
refs/heads/trunk 5789a20bb -> 631d913da
AMBARI-9552. Remove deprecated API for /stacks2 (aonishuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/631d913d
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/631d913d
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/631d913d
Branch: refs/heads/trunk
Commit: 631d913da909b3978f772678fdc458ba8ab0456f
Parents: 5789a20
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Tue Feb 10 18:56:49 2015 +0200
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Tue Feb 10 18:56:49 2015 +0200
----------------------------------------------------------------------
.../resources/BaseStacksResourceDefinition.java | 92 ------
.../resources/ClusterResourceDefinition.java | 2 +-
...ComponentStackVersionResourceDefinition.java | 2 +-
.../OperatingSystemResourceDefinition.java | 6 +-
.../resources/RepositoryResourceDefinition.java | 2 +-
.../RepositoryVersionResourceDefinition.java | 2 +-
.../resources/ResourceInstanceFactoryImpl.java | 2 +-
.../StackConfigurationResourceDefinition.java | 2 +-
.../StackDependencyResourceDefinition.java | 2 +-
...ackLevelConfigurationResourceDefinition.java | 2 +-
...StackServiceComponentResourceDefinition.java | 6 +-
.../StackServiceResourceDefinition.java | 6 +-
.../StackVersionResourceDefinition.java | 2 +-
.../server/api/services/Stacks2Service.java | 295 -------------------
.../server/api/services/StacksService.java | 182 ++----------
.../commands/StackAdvisorCommand.java | 3 +-
.../RepositoryVersionResourceProvider.java | 2 +-
.../ambari/server/api/query/QueryImplTest.java | 30 +-
.../BaseStacksResourceDefinitionTest.java | 119 --------
.../StackServiceResourceDefinitionTest.java | 4 +-
.../server/api/services/Stacks2ServiceTest.java | 216 --------------
.../server/api/services/StacksServiceTest.java | 20 --
22 files changed, 54 insertions(+), 945 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/631d913d/ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseStacksResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseStacksResourceDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseStacksResourceDefinition.java
deleted file mode 100644
index 429f779..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseStacksResourceDefinition.java
+++ /dev/null
@@ -1,92 +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.ambari.server.api.resources;
-
-import org.apache.ambari.server.api.services.Request;
-import org.apache.ambari.server.api.util.TreeNode;
-import org.apache.ambari.server.controller.spi.Resource;
-
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Abstract base class for all stacks related resource definitions.
- * Because we cloned /stacks from /stacks2 and changed the endpoint names in stacks,
- * this class is a TEMPORARY mechanism to deviate from the standard /stacks2 endpoint names.
- *
- */
-public abstract class BaseStacksResourceDefinition extends BaseResourceDefinition {
- protected BaseStacksResourceDefinition(Resource.Type resourceType) {
- super(resourceType);
- }
-
- @Override
- public List<PostProcessor> getPostProcessors() {
- return Collections.<PostProcessor>singletonList(new StacksHrefProcessor());
- }
-
- private class StacksHrefProcessor extends BaseHrefPostProcessor {
- @Override
- /**
- * If processing a /stacks or /stack_versions endpoint, replace the endpoint names.
- */
- public void process(Request request, TreeNode<Resource> resultNode, String href) {
- super.process(request, resultNode, href);
-
- String nodeHref = resultNode.getProperty("href");
- if (nodeHref != null && (nodeHref.contains("/stacks/") || nodeHref.contains("/stack_versions/"))) {
- nodeHref = nodeHref.replace("stackServices", "services");
- nodeHref = nodeHref.replace("serviceComponents", "components");
- nodeHref = nodeHref.replace("operatingSystems", "operating_systems");
-
- renameChildren(resultNode);
- }
-
- resultNode.setProperty("href", nodeHref);
- }
-
- /**
- * Rename child nodes.
- *
- * @param resultNode result node
- */
- private void renameChildren(TreeNode<Resource> resultNode) {
- TreeNode<Resource> childNode = resultNode.removeChild("stackServices");
- if (childNode != null) {
- childNode.setName("services");
- resultNode.addChild(childNode);
- renameChildren(childNode);
- }
-
- childNode = resultNode.removeChild("serviceComponents");
- if (childNode != null) {
- childNode.setName("components");
- resultNode.addChild(childNode);
- renameChildren(childNode);
- }
-
- childNode = resultNode.removeChild("operatingSystems");
- if (childNode != null) {
- childNode.setName("operating_systems");
- resultNode.addChild(childNode);
- renameChildren(childNode);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/631d913d/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ClusterResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ClusterResourceDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ClusterResourceDefinition.java
index 980a40f..94f2711 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ClusterResourceDefinition.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ClusterResourceDefinition.java
@@ -29,7 +29,7 @@ import org.apache.ambari.server.controller.spi.Resource;
/**
* Cluster resource definition.
*/
-public class ClusterResourceDefinition extends BaseStacksResourceDefinition {
+public class ClusterResourceDefinition extends BaseResourceDefinition {
/**
* Constructor.
*/
http://git-wip-us.apache.org/repos/asf/ambari/blob/631d913d/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ComponentStackVersionResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ComponentStackVersionResourceDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ComponentStackVersionResourceDefinition.java
index 855ee8c..f3d26be 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ComponentStackVersionResourceDefinition.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ComponentStackVersionResourceDefinition.java
@@ -25,7 +25,7 @@ import org.apache.ambari.server.controller.spi.Resource;
/**
* Stack Version Resource Definition for hosts and clusters.
*/
-public class ComponentStackVersionResourceDefinition extends BaseStacksResourceDefinition {
+public class ComponentStackVersionResourceDefinition extends BaseResourceDefinition {
public ComponentStackVersionResourceDefinition(Resource.Type type) {
super(type);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/631d913d/ambari-server/src/main/java/org/apache/ambari/server/api/resources/OperatingSystemResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/OperatingSystemResourceDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/OperatingSystemResourceDefinition.java
index 6faf6fb..d188ef5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/OperatingSystemResourceDefinition.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/OperatingSystemResourceDefinition.java
@@ -24,7 +24,7 @@ import java.util.Set;
import org.apache.ambari.server.controller.spi.Resource;
import org.apache.ambari.server.controller.spi.Resource.Type;
-public class OperatingSystemResourceDefinition extends BaseStacksResourceDefinition {
+public class OperatingSystemResourceDefinition extends BaseResourceDefinition {
public OperatingSystemResourceDefinition(Type resourceType) {
super(resourceType);
@@ -36,12 +36,12 @@ public class OperatingSystemResourceDefinition extends BaseStacksResourceDefinit
@Override
public String getPluralName() {
- return "operatingSystems";
+ return "operating_systems";
}
@Override
public String getSingularName() {
- return "operatingSystem";
+ return "operating_system";
}
@Override
http://git-wip-us.apache.org/repos/asf/ambari/blob/631d913d/ambari-server/src/main/java/org/apache/ambari/server/api/resources/RepositoryResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/RepositoryResourceDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/RepositoryResourceDefinition.java
index be78136..fb6a284 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/RepositoryResourceDefinition.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/RepositoryResourceDefinition.java
@@ -23,7 +23,7 @@ import org.apache.ambari.server.controller.spi.Resource;
import com.google.common.collect.Sets;
-public class RepositoryResourceDefinition extends BaseStacksResourceDefinition {
+public class RepositoryResourceDefinition extends BaseResourceDefinition {
public static String VALIDATE_ONLY_DIRECTIVE = "validate_only";
http://git-wip-us.apache.org/repos/asf/ambari/blob/631d913d/ambari-server/src/main/java/org/apache/ambari/server/api/resources/RepositoryVersionResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/RepositoryVersionResourceDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/RepositoryVersionResourceDefinition.java
index abc69f6..495de27 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/RepositoryVersionResourceDefinition.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/RepositoryVersionResourceDefinition.java
@@ -22,7 +22,7 @@ import java.util.Set;
import org.apache.ambari.server.controller.spi.Resource;
-public class RepositoryVersionResourceDefinition extends BaseStacksResourceDefinition {
+public class RepositoryVersionResourceDefinition extends BaseResourceDefinition {
public RepositoryVersionResourceDefinition() {
super(Resource.Type.RepositoryVersion);
http://git-wip-us.apache.org/repos/asf/ambari/blob/631d913d/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
index 5da9847..c306281 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
@@ -341,7 +341,7 @@ public class ResourceInstanceFactoryImpl implements ResourceInstanceFactory {
break;
case StackArtifact:
- resourceDefinition = new BaseStacksResourceDefinition(Resource.Type.StackArtifact) {
+ resourceDefinition = new BaseResourceDefinition(Resource.Type.StackArtifact) {
@Override
public String getPluralName() {
return "artifacts";
http://git-wip-us.apache.org/repos/asf/ambari/blob/631d913d/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackConfigurationResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackConfigurationResourceDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackConfigurationResourceDefinition.java
index 53903ba..610f822 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackConfigurationResourceDefinition.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackConfigurationResourceDefinition.java
@@ -22,7 +22,7 @@ package org.apache.ambari.server.api.resources;
import org.apache.ambari.server.controller.spi.Resource;
import org.apache.ambari.server.controller.spi.Resource.Type;
-public class StackConfigurationResourceDefinition extends BaseStacksResourceDefinition {
+public class StackConfigurationResourceDefinition extends BaseResourceDefinition {
public StackConfigurationResourceDefinition(Type resourceType) {
super(resourceType);
http://git-wip-us.apache.org/repos/asf/ambari/blob/631d913d/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackDependencyResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackDependencyResourceDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackDependencyResourceDefinition.java
index 0743a7f..19ac584 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackDependencyResourceDefinition.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackDependencyResourceDefinition.java
@@ -23,7 +23,7 @@ import org.apache.ambari.server.controller.spi.Resource;
/**
* Stack Service Dependency Resource Definition.
*/
-public class StackDependencyResourceDefinition extends BaseStacksResourceDefinition {
+public class StackDependencyResourceDefinition extends BaseResourceDefinition {
/**
* Constructor.
http://git-wip-us.apache.org/repos/asf/ambari/blob/631d913d/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackLevelConfigurationResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackLevelConfigurationResourceDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackLevelConfigurationResourceDefinition.java
index 9265234..ce6a5b3 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackLevelConfigurationResourceDefinition.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackLevelConfigurationResourceDefinition.java
@@ -24,7 +24,7 @@ import java.util.Set;
import org.apache.ambari.server.controller.spi.Resource;
import org.apache.ambari.server.controller.spi.Resource.Type;
-public class StackLevelConfigurationResourceDefinition extends BaseStacksResourceDefinition {
+public class StackLevelConfigurationResourceDefinition extends BaseResourceDefinition {
public StackLevelConfigurationResourceDefinition(Type resourceType) {
super(Resource.Type.StackLevelConfiguration);
http://git-wip-us.apache.org/repos/asf/ambari/blob/631d913d/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackServiceComponentResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackServiceComponentResourceDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackServiceComponentResourceDefinition.java
index cad2a99..ad14d52 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackServiceComponentResourceDefinition.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackServiceComponentResourceDefinition.java
@@ -23,7 +23,7 @@ import org.apache.ambari.server.controller.spi.Resource;
import java.util.Collections;
import java.util.Set;
-public class StackServiceComponentResourceDefinition extends BaseStacksResourceDefinition {
+public class StackServiceComponentResourceDefinition extends BaseResourceDefinition {
public StackServiceComponentResourceDefinition() {
super(Resource.Type.StackServiceComponent);
@@ -31,12 +31,12 @@ public class StackServiceComponentResourceDefinition extends BaseStacksResourceD
@Override
public String getPluralName() {
- return "serviceComponents";
+ return "components";
}
@Override
public String getSingularName() {
- return "serviceComponent";
+ return "component";
}
@Override
http://git-wip-us.apache.org/repos/asf/ambari/blob/631d913d/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackServiceResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackServiceResourceDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackServiceResourceDefinition.java
index ef76694..8a40a65 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackServiceResourceDefinition.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackServiceResourceDefinition.java
@@ -24,7 +24,7 @@ import java.util.Set;
import org.apache.ambari.server.controller.spi.Resource;
import org.apache.ambari.server.controller.spi.Resource.Type;
-public class StackServiceResourceDefinition extends BaseStacksResourceDefinition {
+public class StackServiceResourceDefinition extends BaseResourceDefinition {
public StackServiceResourceDefinition(Type resourceType) {
super(resourceType);
@@ -36,12 +36,12 @@ public class StackServiceResourceDefinition extends BaseStacksResourceDefinition
@Override
public String getPluralName() {
- return "stackServices";
+ return "services";
}
@Override
public String getSingularName() {
- return "stackService";
+ return "service";
}
@Override
http://git-wip-us.apache.org/repos/asf/ambari/blob/631d913d/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackVersionResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackVersionResourceDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackVersionResourceDefinition.java
index 3310f57..0b26308 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackVersionResourceDefinition.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackVersionResourceDefinition.java
@@ -24,7 +24,7 @@ import java.util.Set;
import org.apache.ambari.server.controller.spi.Resource;
import org.apache.ambari.server.controller.spi.Resource.Type;
-public class StackVersionResourceDefinition extends BaseStacksResourceDefinition {
+public class StackVersionResourceDefinition extends BaseResourceDefinition {
public StackVersionResourceDefinition(Type resourceType) {
super(Resource.Type.StackVersion);
http://git-wip-us.apache.org/repos/asf/ambari/blob/631d913d/ambari-server/src/main/java/org/apache/ambari/server/api/services/Stacks2Service.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/Stacks2Service.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/Stacks2Service.java
deleted file mode 100644
index 41ba5ae..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/Stacks2Service.java
+++ /dev/null
@@ -1,295 +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.ambari.server.api.services;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-
-import org.apache.ambari.server.api.resources.ResourceInstance;
-import org.apache.ambari.server.controller.spi.Resource;
-
-/**
- * Service for stacks management.
- */
-@Path("/stacks2/")
-public class Stacks2Service extends BaseService {
-
- @GET
- @Produces("text/plain")
- public Response getStacks(String body, @Context HttpHeaders headers, @Context UriInfo ui) {
-
- return handleRequest(headers, body, ui, Request.Type.GET,
- createStackResource(null));
- }
-
- @GET
- @Path("{stackName}")
- @Produces("text/plain")
- public Response getStack(String body, @Context HttpHeaders headers, @Context UriInfo ui,
- @PathParam("stackName") String stackName) {
-
- return handleRequest(headers, body, ui, Request.Type.GET,
- createStackResource(stackName));
- }
-
- @GET
- @Path("{stackName}/versions")
- @Produces("text/plain")
- public Response getStackVersions(String body, @Context HttpHeaders headers,
- @Context UriInfo ui, @PathParam("stackName") String stackName) {
-
- return handleRequest(headers, body, ui, Request.Type.GET,
- createStackVersionResource(stackName, null));
- }
-
- @GET
- @Path("{stackName}/versions/{stackVersion}")
- @Produces("text/plain")
- public Response getStackVersion(String body, @Context HttpHeaders headers,
- @Context UriInfo ui, @PathParam("stackName") String stackName,
- @PathParam("stackVersion") String stackVersion) {
-
- return handleRequest(headers, body, ui, Request.Type.GET,
- createStackVersionResource(stackName, stackVersion));
- }
-
-
- @GET
- @Path("{stackName}/versions/{stackVersion}/operatingSystems/{osType}/repositories")
- @Produces("text/plain")
- public Response getRepositories(String body, @Context HttpHeaders headers,
- @Context UriInfo ui, @PathParam("stackName") String stackName,
- @PathParam("stackVersion") String stackVersion,
- @PathParam("osType") String osType) {
-
- return handleRequest(headers, body, ui, Request.Type.GET,
- createRepositoryResource(stackName, stackVersion, osType, null));
- }
-
- @GET
- @Path("{stackName}/versions/{stackVersion}/operatingSystems/{osType}/repositories/{repoId}")
- @Produces("text/plain")
- public Response getRepository(String body, @Context HttpHeaders headers,
- @Context UriInfo ui, @PathParam("stackName") String stackName,
- @PathParam("stackVersion") String stackVersion,
- @PathParam("osType") String osType,
- @PathParam("repoId") String repoId) {
-
- return handleRequest(headers, body, ui, Request.Type.GET,
- createRepositoryResource(stackName, stackVersion, osType, repoId));
- }
-
- @PUT
- @Path("{stackName}/versions/{stackVersion}/operatingSystems/{osType}/repositories/{repoId}")
- @Produces("text/plain")
- public Response updateRepository(String body, @Context HttpHeaders headers,
- @Context UriInfo ui, @PathParam("stackName") String stackName,
- @PathParam("stackVersion") String stackVersion,
- @PathParam("osType") String osType,
- @PathParam("repoId") String repoId) {
-
- return handleRequest(headers, body, ui, Request.Type.PUT,
- createRepositoryResource(stackName, stackVersion, osType, repoId));
- }
-
-
- @GET
- @Path("{stackName}/versions/{stackVersion}/stackServices")
- @Produces("text/plain")
- public Response getStackServices(String body, @Context HttpHeaders headers,
- @Context UriInfo ui, @PathParam("stackName") String stackName,
- @PathParam("stackVersion") String stackVersion) {
-
- return handleRequest(headers, body, ui, Request.Type.GET,
- createStackServiceResource(stackName, stackVersion, null));
- }
-
- @GET
- @Path("{stackName}/versions/{stackVersion}/stackServices/{serviceName}")
- @Produces("text/plain")
- public Response getStackService(String body, @Context HttpHeaders headers,
- @Context UriInfo ui, @PathParam("stackName") String stackName,
- @PathParam("stackVersion") String stackVersion,
- @PathParam("serviceName") String serviceName) {
-
- return handleRequest(headers, body, ui, Request.Type.GET,
- createStackServiceResource(stackName, stackVersion, serviceName));
- }
-
-
- @GET
- @Path("{stackName}/versions/{stackVersion}/stackServices/{serviceName}/configurations")
- @Produces("text/plain")
- public Response getStackConfigurations(String body, @Context HttpHeaders headers,
- @Context UriInfo ui, @PathParam("stackName") String stackName,
- @PathParam("stackVersion") String stackVersion,
- @PathParam("serviceName") String serviceName) {
-
- return handleRequest(headers, body, ui, Request.Type.GET,
- createStackConfigurationResource(stackName, stackVersion, serviceName, null));
- }
-
-
- @GET
- @Path("{stackName}/versions/{stackVersion}/stackServices/{serviceName}/configurations/{propertyName}")
- @Produces("text/plain")
- public Response getStackConfiguration(String body, @Context HttpHeaders headers,
- @Context UriInfo ui, @PathParam("stackName") String stackName,
- @PathParam("stackVersion") String stackVersion,
- @PathParam("serviceName") String serviceName,
- @PathParam("propertyName") String propertyName) {
-
- return handleRequest(headers, body, ui, Request.Type.GET,
- createStackConfigurationResource(stackName, stackVersion, serviceName, propertyName));
- }
-
- @GET
- @Path("{stackName}/versions/{stackVersion}/stackServices/{serviceName}/serviceComponents")
- @Produces("text/plain")
- public Response getServiceComponents(String body, @Context HttpHeaders headers,
- @Context UriInfo ui, @PathParam("stackName") String stackName,
- @PathParam("stackVersion") String stackVersion,
- @PathParam("serviceName") String serviceName) {
-
- return handleRequest(headers, body, ui, Request.Type.GET,
- createStackServiceComponentResource(stackName, stackVersion, serviceName, null));
- }
-
- @GET
- @Path("{stackName}/versions/{stackVersion}/stackServices/{serviceName}/serviceComponents/{componentName}")
- @Produces("text/plain")
- public Response getServiceComponent(String body, @Context HttpHeaders headers,
- @Context UriInfo ui, @PathParam("stackName") String stackName,
- @PathParam("stackVersion") String stackVersion,
- @PathParam("serviceName") String serviceName,
- @PathParam("componentName") String componentName) {
-
- return handleRequest(headers, body, ui, Request.Type.GET,
- createStackServiceComponentResource(stackName, stackVersion, serviceName, componentName));
- }
-
-
- @GET
- @Path("{stackName}/versions/{stackVersion}/operatingSystems")
- @Produces("text/plain")
- public Response getOperatingSystems(String body, @Context HttpHeaders headers,
- @Context UriInfo ui, @PathParam("stackName") String stackName,
- @PathParam("stackVersion") String stackVersion) {
-
- return handleRequest(headers, body, ui, Request.Type.GET,
- createOperatingSystemResource(stackName, stackVersion, null));
- }
-
- @GET
- @Path("{stackName}/versions/{stackVersion}/operatingSystems/{osType}")
- @Produces("text/plain")
- public Response getOperatingSystem(String body, @Context HttpHeaders headers,
- @Context UriInfo ui, @PathParam("stackName") String stackName,
- @PathParam("stackVersion") String stackVersion,
- @PathParam("osType") String osType) {
-
- return handleRequest(headers, body, ui, Request.Type.GET,
- createOperatingSystemResource(stackName, stackVersion, osType));
- }
-
-
- ResourceInstance createOperatingSystemResource(String stackName,
- String stackVersion, String osType) {
-
- Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
- mapIds.put(Resource.Type.Stack, stackName);
- mapIds.put(Resource.Type.StackVersion, stackVersion);
- mapIds.put(Resource.Type.OperatingSystem, osType);
-
- return createResource(Resource.Type.OperatingSystem, mapIds);
- }
-
- ResourceInstance createStackServiceComponentResource(
- String stackName, String stackVersion, String serviceName, String componentName) {
-
- Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
- mapIds.put(Resource.Type.Stack, stackName);
- mapIds.put(Resource.Type.StackVersion, stackVersion);
- mapIds.put(Resource.Type.StackService, serviceName);
- mapIds.put(Resource.Type.StackServiceComponent, componentName);
-
- return createResource(Resource.Type.StackServiceComponent, mapIds);
- }
-
- ResourceInstance createStackConfigurationResource(String stackName,
- String stackVersion, String serviceName, String propertyName) {
-
- Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
- mapIds.put(Resource.Type.Stack, stackName);
- mapIds.put(Resource.Type.StackVersion, stackVersion);
- mapIds.put(Resource.Type.StackService, serviceName);
- mapIds.put(Resource.Type.StackConfiguration, propertyName);
-
- return createResource(Resource.Type.StackConfiguration, mapIds);
- }
-
- ResourceInstance createStackServiceResource(String stackName,
- String stackVersion, String serviceName) {
- Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
- mapIds.put(Resource.Type.Stack, stackName);
- mapIds.put(Resource.Type.StackVersion, stackVersion);
- mapIds.put(Resource.Type.StackService, serviceName);
-
- return createResource(Resource.Type.StackService, mapIds);
- }
-
- ResourceInstance createRepositoryResource(String stackName,
- String stackVersion, String osType, String repoId) {
-
- Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
- mapIds.put(Resource.Type.Stack, stackName);
- mapIds.put(Resource.Type.StackVersion, stackVersion);
- mapIds.put(Resource.Type.OperatingSystem, osType);
- mapIds.put(Resource.Type.Repository, repoId);
-
- return createResource(Resource.Type.Repository, mapIds);
- }
-
- ResourceInstance createStackVersionResource(String stackName,
- String stackVersion) {
- Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
- mapIds.put(Resource.Type.Stack, stackName);
- mapIds.put(Resource.Type.StackVersion, stackVersion);
-
- return createResource(Resource.Type.StackVersion, mapIds);
- }
-
- ResourceInstance createStackResource(String stackName) {
-
- return createResource(Resource.Type.Stack,
- Collections.singletonMap(Resource.Type.Stack, stackName));
-
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/631d913d/ambari-server/src/main/java/org/apache/ambari/server/api/services/StacksService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/StacksService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/StacksService.java
index 74c7b57..0624dc1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/StacksService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/StacksService.java
@@ -68,7 +68,7 @@ public class StacksService extends BaseService {
@Context UriInfo ui,
@PathParam("stackName") String stackName) {
- return handleRequest(headers, body, new StackUriInfo(ui), Request.Type.GET,
+ return handleRequest(headers, body, ui, Request.Type.GET,
createStackResource(stackName));
}
@@ -79,7 +79,7 @@ public class StacksService extends BaseService {
@Context HttpHeaders headers,
@Context UriInfo ui, @PathParam("stackName") String stackName) {
- return handleRequest(headers, body, new StackUriInfo(ui), Request.Type.GET,
+ return handleRequest(headers, body, ui, Request.Type.GET,
createStackVersionResource(stackName, null));
}
@@ -91,7 +91,7 @@ public class StacksService extends BaseService {
@Context UriInfo ui, @PathParam("stackName") String stackName,
@PathParam("stackVersion") String stackVersion) {
- return handleRequest(headers, body, new StackUriInfo(ui), Request.Type.GET,
+ return handleRequest(headers, body, ui, Request.Type.GET,
createStackVersionResource(stackName, stackVersion));
}
@@ -102,7 +102,7 @@ public class StacksService extends BaseService {
@Context UriInfo ui, @PathParam("stackName") String stackName,
@PathParam("stackVersion") String stackVersion) {
- return handleRequest(headers, body, new StackUriInfo(ui), Request.Type.GET,
+ return handleRequest(headers, body, ui, Request.Type.GET,
createStackLevelConfigurationsResource(stackName, stackVersion, null));
}
@@ -115,7 +115,7 @@ public class StacksService extends BaseService {
@PathParam("serviceName") String serviceName,
@PathParam("propertyName") String propertyName) {
- return handleRequest(headers, body, new StackUriInfo(ui), Request.Type.GET,
+ return handleRequest(headers, body, ui, Request.Type.GET,
createStackLevelConfigurationsResource(stackName, stackVersion, propertyName));
}
@@ -127,7 +127,7 @@ public class StacksService extends BaseService {
@Context UriInfo ui, @PathParam("stackName") String stackName,
@PathParam("stackVersion") String stackVersion) {
- return handleRequest(headers, body, new StackUriInfo(ui), Request.Type.GET,
+ return handleRequest(headers, body, ui, Request.Type.GET,
createStackServiceResource(stackName, stackVersion, null));
}
@@ -139,7 +139,7 @@ public class StacksService extends BaseService {
@PathParam("stackVersion") String stackVersion,
@PathParam("serviceName") String serviceName) {
- return handleRequest(headers, body, new StackUriInfo(ui), Request.Type.GET,
+ return handleRequest(headers, body, ui, Request.Type.GET,
createStackServiceResource(stackName, stackVersion, serviceName));
}
@@ -150,7 +150,7 @@ public class StacksService extends BaseService {
@Context UriInfo ui, @PathParam("stackName") String stackName,
@PathParam("stackVersion") String stackVersion) {
- return handleRequest(headers, body, new StackUriInfo(ui), Request.Type.GET,
+ return handleRequest(headers, body, ui, Request.Type.GET,
createStackArtifactsResource(stackName, stackVersion, null));
}
@@ -162,7 +162,7 @@ public class StacksService extends BaseService {
@PathParam("stackVersion") String stackVersion,
@PathParam("artifactName") String artifactName) {
- return handleRequest(headers, body, new StackUriInfo(ui), Request.Type.GET,
+ return handleRequest(headers, body, ui, Request.Type.GET,
createStackArtifactsResource(stackName, stackVersion, artifactName));
}
@@ -174,7 +174,7 @@ public class StacksService extends BaseService {
@PathParam("stackVersion") String stackVersion,
@PathParam("serviceName") String serviceName) {
- return handleRequest(headers, body, new StackUriInfo(ui), Request.Type.GET,
+ return handleRequest(headers, body, ui, Request.Type.GET,
createStackServiceArtifactsResource(stackName, stackVersion, serviceName, null));
}
@@ -187,7 +187,7 @@ public class StacksService extends BaseService {
@PathParam("serviceName") String serviceName,
@PathParam("artifactName") String artifactName) {
- return handleRequest(headers, body, new StackUriInfo(ui), Request.Type.GET,
+ return handleRequest(headers, body, ui, Request.Type.GET,
createStackServiceArtifactsResource(stackName, stackVersion, serviceName, artifactName));
}
@@ -200,7 +200,7 @@ public class StacksService extends BaseService {
@PathParam("stackVersion") String stackVersion,
@PathParam("serviceName") String serviceName) {
- return handleRequest(headers, body, new StackUriInfo(ui), Request.Type.GET,
+ return handleRequest(headers, body, ui, Request.Type.GET,
createStackConfigurationResource(stackName, stackVersion, serviceName, null));
}
@@ -214,7 +214,7 @@ public class StacksService extends BaseService {
@PathParam("serviceName") String serviceName,
@PathParam("propertyName") String propertyName) {
- return handleRequest(headers, body, new StackUriInfo(ui), Request.Type.GET,
+ return handleRequest(headers, body, ui, Request.Type.GET,
createStackConfigurationResource(stackName, stackVersion, serviceName, propertyName));
}
@@ -227,7 +227,7 @@ public class StacksService extends BaseService {
@PathParam("stackVersion") String stackVersion,
@PathParam("serviceName") String serviceName) {
- return handleRequest(headers, body, new StackUriInfo(ui), Request.Type.GET,
+ return handleRequest(headers, body, ui, Request.Type.GET,
createStackServiceComponentResource(stackName, stackVersion, serviceName, null));
}
@@ -240,7 +240,7 @@ public class StacksService extends BaseService {
@PathParam("serviceName") String serviceName,
@PathParam("componentName") String componentName) {
- return handleRequest(headers, body, new StackUriInfo(ui), Request.Type.GET,
+ return handleRequest(headers, body, ui, Request.Type.GET,
createStackServiceComponentDependencyResource(stackName, stackVersion, serviceName, componentName, null));
}
@@ -254,7 +254,7 @@ public class StacksService extends BaseService {
@PathParam("componentName") String componentName,
@PathParam("dependencyName") String dependencyName) {
- return handleRequest(headers, body, new StackUriInfo(ui), Request.Type.GET,
+ return handleRequest(headers, body, ui, Request.Type.GET,
createStackServiceComponentDependencyResource(stackName, stackVersion, serviceName, componentName, dependencyName));
}
@@ -267,7 +267,7 @@ public class StacksService extends BaseService {
@PathParam("serviceName") String serviceName,
@PathParam("componentName") String componentName) {
- return handleRequest(headers, body, new StackUriInfo(ui), Request.Type.GET,
+ return handleRequest(headers, body, ui, Request.Type.GET,
createStackServiceComponentResource(stackName, stackVersion, serviceName, componentName));
}
@@ -396,153 +396,5 @@ public class StacksService extends BaseService {
Collections.singletonMap(Resource.Type.Stack, stackName));
}
-
- /**
- * Temporary UriInfo implementation which is used to convert old property names.
- * Because both the /stacks and /stacks2 api use the same underlying classes, we
- * need to convert the new corrected property names to the old names for the back end.
- * This should be removed when /stacks2 is removed and we can change the property names
- * in the resource definitions to the new form.
- */
- public static class StackUriInfo implements UriInfo {
- private UriInfo m_delegate;
-
- public StackUriInfo(UriInfo delegate) {
- m_delegate = delegate;
- }
- @Override
- public String getPath() {
- return m_delegate.getPath();
- }
-
- @Override
- public String getPath(boolean b) {
- return m_delegate.getPath(b);
- }
-
- @Override
- public List<PathSegment> getPathSegments() {
- return m_delegate.getPathSegments();
- }
-
- @Override
- public List<PathSegment> getPathSegments(boolean b) {
- return m_delegate.getPathSegments(b);
- }
-
- /**
- * Converts the new corrected property names to the old names for the backend.
- * Because both the /stacks and /stacks2 api use the same underlying classes, we
- * need to convert the new corrected property names to the old names for the backend.
- * This should be removed when /stacks2 is removed and we can change the property names
- * in the resource definitions to the new form.
- */
- private String normalizeComponentNames(String value) {
- if (value == null) {
- return null;
- }
- value = value.replaceAll("services/", "stackServices/");
- value = value.replaceAll("components/", "serviceComponents/");
- value = value.replaceAll("operating_systems/", "operatingSystems/");
- return value;
- }
-
- @Override
- public URI getRequestUri() {
- String uriPath = m_delegate.getRequestUri().getPath();
- UriBuilder uriBuilder = UriBuilder.fromUri(m_delegate.getRequestUri());
- List<NameValuePair> parametersList = URLEncodedUtils.parse(m_delegate.getRequestUri(), "UTF-8");
- List<NameValuePair> newQuery = new ArrayList<NameValuePair>();
- for (NameValuePair nameValuePair : parametersList) {
- newQuery.add(new BasicNameValuePair(normalizeComponentNames(nameValuePair.getName()),
- normalizeComponentNames(nameValuePair.getValue())));
- }
-
- uriBuilder.replacePath(normalizeComponentNames(uriPath));
- uriBuilder.replaceQuery(URLEncodedUtils.format(newQuery, "UTF-8"));
-
- return uriBuilder.build();
- }
-
- @Override
- public UriBuilder getRequestUriBuilder() {
- return m_delegate.getRequestUriBuilder();
- }
-
- @Override
- public URI getAbsolutePath() {
- return m_delegate.getAbsolutePath();
- }
-
- @Override
- public UriBuilder getAbsolutePathBuilder() {
- return m_delegate.getAbsolutePathBuilder();
- }
-
- @Override
- public URI getBaseUri() {
- return m_delegate.getBaseUri();
- }
-
- @Override
- public UriBuilder getBaseUriBuilder() {
- return m_delegate.getBaseUriBuilder();
- }
-
- @Override
- public MultivaluedMap<String, String> getPathParameters() {
- return m_delegate.getPathParameters();
- }
-
- @Override
- public MultivaluedMap<String, String> getPathParameters(boolean b) {
- return m_delegate.getPathParameters(b);
- }
-
- @Override
- public MultivaluedMap<String, String> getQueryParameters() {
- MultivaluedMap<String, String> queryParams = m_delegate.getQueryParameters();
-
- if (queryParams.containsKey(QueryLexer.QUERY_FIELDS)) {
- String fields = queryParams.getFirst(QueryLexer.QUERY_FIELDS);
- queryParams.putSingle(QueryLexer.QUERY_FIELDS, convertToOldPropertyNames(fields));
- }
-
- if (queryParams.containsKey(QueryLexer.QUERY_SORT)) {
- String sortBy = queryParams.getFirst(QueryLexer.QUERY_SORT);
- queryParams.putSingle(QueryLexer.QUERY_SORT, convertToOldPropertyNames(sortBy));
- }
-
- return queryParams;
- }
-
- @Override
- public MultivaluedMap<String, String> getQueryParameters(boolean b) {
- return m_delegate.getQueryParameters(b);
- }
-
- @Override
- public List<String> getMatchedURIs() {
- return m_delegate.getMatchedURIs();
- }
-
- @Override
- public List<String> getMatchedURIs(boolean b) {
- return m_delegate.getMatchedURIs(b);
- }
-
- @Override
- public List<Object> getMatchedResources() {
- return m_delegate.getMatchedResources();
- }
-
- private String convertToOldPropertyNames(String str) {
- str = str.replaceAll("services", "stackServices");
- str = str.replaceAll("components", "serviceComponents");
- str = str.replaceAll("operating_systems", "operatingSystems");
-
- return str;
- }
- }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/631d913d/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommand.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommand.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommand.java
index 63ec0ed..2e20452 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommand.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommand.java
@@ -39,7 +39,6 @@ import org.apache.ambari.server.api.services.AmbariMetaInfo;
import org.apache.ambari.server.api.services.BaseService;
import org.apache.ambari.server.api.services.LocalUriInfo;
import org.apache.ambari.server.api.services.Request;
-import org.apache.ambari.server.api.services.StacksService.StackUriInfo;
import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorException;
import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorRequest;
import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorResponse;
@@ -322,7 +321,7 @@ public abstract class StackAdvisorCommand<T extends StackAdvisorResponse> extend
String servicesURI = String.format(GET_SERVICES_INFO_URI, stackName, stackVersion,
request.getServicesCommaSeparated());
- Response response = handleRequest(null, null, new StackUriInfo(new LocalUriInfo(servicesURI)),
+ Response response = handleRequest(null, null, new LocalUriInfo(servicesURI),
Request.Type.GET, createStackVersionResource(stackName, stackVersion));
if (response.getStatus() != Status.OK.getStatusCode()) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/631d913d/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProvider.java
index b72f872..3a68d72 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProvider.java
@@ -69,7 +69,7 @@ public class RepositoryVersionResourceProvider extends AbstractResourceProvider
public static final String REPOSITORY_VERSION_REPOSITORY_VERSION_PROPERTY_ID = PropertyHelper.getPropertyId("RepositoryVersions", "repository_version");
public static final String REPOSITORY_VERSION_DISPLAY_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("RepositoryVersions", "display_name");
public static final String REPOSITORY_VERSION_UPGRADE_PACK_PROPERTY_ID = PropertyHelper.getPropertyId("RepositoryVersions", "upgrade_pack");
- public static final String SUBRESOURCE_OPERATING_SYSTEMS_PROPERTY_ID = "operating_systems"; //TODO should be replaced with resource definition when we get rid of Stacks2Service
+ public static final String SUBRESOURCE_OPERATING_SYSTEMS_PROPERTY_ID = PropertyHelper.getPropertyId("RepositoryVersions", "operating_systems");
public static final String SUBRESOURCE_REPOSITORIES_PROPERTY_ID = new RepositoryResourceDefinition().getPluralName();
@SuppressWarnings("serial")
http://git-wip-us.apache.org/repos/asf/ambari/blob/631d913d/ambari-server/src/test/java/org/apache/ambari/server/api/query/QueryImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/query/QueryImplTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/query/QueryImplTest.java
index 863ed96..88e62ff 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/query/QueryImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/query/QueryImplTest.java
@@ -185,14 +185,14 @@ public class QueryImplTest {
QueryImpl instance = new TestQuery(mapIds, resourceDefinition);
instance.addProperty("versions/*", null);
- instance.addProperty("versions/operatingSystems/*", null);
- instance.addProperty("versions/operatingSystems/repositories/*", null);
+ instance.addProperty("versions/operating_systems/*", null);
+ instance.addProperty("versions/operating_systems/repositories/*", null);
instance.execute();
Set<String> propertyIds = new HashSet<String>();
- propertyIds.add("versions/operatingSystems/repositories/Repositories/repo_id");
- propertyIds.add("versions/operatingSystems/OperatingSystems/os_type");
+ propertyIds.add("versions/operating_systems/repositories/Repositories/repo_id");
+ propertyIds.add("versions/operating_systems/OperatingSystems/os_type");
Map<Resource, Set<Map<String, Object>>> resourcePropertiesMap = instance.getJoinedResourceProperties(propertyIds, null, null);
@@ -210,8 +210,8 @@ public class QueryImplTest {
for (Map<String, Object> map : propertyMaps) {
Assert.assertEquals(2, map.size());
- Assert.assertTrue(map.containsKey("versions/operatingSystems/OperatingSystems/os_type"));
- Assert.assertTrue(map.containsKey("versions/operatingSystems/repositories/Repositories/repo_id"));
+ Assert.assertTrue(map.containsKey("versions/operating_systems/OperatingSystems/os_type"));
+ Assert.assertTrue(map.containsKey("versions/operating_systems/repositories/Repositories/repo_id"));
}
}
@@ -226,7 +226,7 @@ public class QueryImplTest {
QueryImpl instance = new TestQuery(mapIds, resourceDefinition);
PredicateBuilder pb = new PredicateBuilder();
- Predicate predicate = pb.property("versions/operatingSystems/OperatingSystems/os_type").equals("centos5").toPredicate();
+ Predicate predicate = pb.property("versions/operating_systems/OperatingSystems/os_type").equals("centos5").toPredicate();
instance.setUserPredicate(predicate);
@@ -247,7 +247,7 @@ public class QueryImplTest {
Assert.assertEquals(Resource.Type.StackVersion, versionNode.getObject().getType());
Assert.assertEquals(1, versionNode.getChildren().size());
- TreeNode<Resource> opSystemsNode = versionNode.getChild("operatingSystems");
+ TreeNode<Resource> opSystemsNode = versionNode.getChild("operating_systems");
Assert.assertEquals(1, opSystemsNode.getChildren().size());
TreeNode<Resource> opSystemNode = opSystemsNode.getChild("OperatingSystem:1");
@@ -362,8 +362,8 @@ public class QueryImplTest {
QueryImpl instance = new TestQuery(mapIds, resourceDefinition);
instance.addProperty("versions/*", null);
- instance.addProperty("versions/operatingSystems/*", null);
- instance.addProperty("versions/operatingSystems/repositories/*", null);
+ instance.addProperty("versions/operating_systems/*", null);
+ instance.addProperty("versions/operating_systems/repositories/*", null);
Result result = instance.execute();
@@ -383,7 +383,7 @@ public class QueryImplTest {
Assert.assertEquals(5, versionNode.getChildren().size());
- TreeNode<Resource> opSystemsNode = versionNode.getChild("operatingSystems");
+ TreeNode<Resource> opSystemsNode = versionNode.getChild("operating_systems");
Assert.assertEquals(3, opSystemsNode.getChildren().size());
TreeNode<Resource> opSystemNode = opSystemsNode.getChild("OperatingSystem:1");
@@ -465,10 +465,10 @@ public class QueryImplTest {
Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
QueryImpl instance = new TestQuery(mapIds, resourceDefinition);
- instance.addProperty("operatingSystems/*", null);
+ instance.addProperty("operating_systems/*", null);
PredicateBuilder pb = new PredicateBuilder();
- Predicate predicate = pb.property("operatingSystems/OperatingSystems/os_type").equals("centos5").toPredicate();
+ Predicate predicate = pb.property("operating_systems/OperatingSystems/os_type").equals("centos5").toPredicate();
instance.setUserPredicate(predicate);
instance.setPageRequest(new PageRequestImpl(PageRequest.StartingPoint.Beginning, 1, 0, null, null));
@@ -484,7 +484,7 @@ public class QueryImplTest {
Assert.assertEquals("1.2.1", stackVersionNode.getObject().getPropertyValue("Versions/stack_version"));
QueryImpl instance2 = new TestQuery(mapIds, resourceDefinition);
- instance2.addProperty("operatingSystems/*", null);
+ instance2.addProperty("operating_systems/*", null);
instance2.setUserPredicate(predicate);
instance2.setPageRequest(new PageRequestImpl(PageRequest.StartingPoint.OffsetStart, 1, 1, null, null));
@@ -500,7 +500,7 @@ public class QueryImplTest {
QueryImpl instance3 = new TestQuery(mapIds, resourceDefinition);
- instance3.addProperty("operatingSystems/*", null);
+ instance3.addProperty("operating_systems/*", null);
instance3.setUserPredicate(predicate);
//page_size = 2, offset = 1
http://git-wip-us.apache.org/repos/asf/ambari/blob/631d913d/ambari-server/src/test/java/org/apache/ambari/server/api/resources/BaseStacksResourceDefinitionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/resources/BaseStacksResourceDefinitionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/resources/BaseStacksResourceDefinitionTest.java
deleted file mode 100644
index 86bffdd..0000000
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/resources/BaseStacksResourceDefinitionTest.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.ambari.server.api.resources;
-
-import org.apache.ambari.server.api.util.TreeNode;
-import org.apache.ambari.server.api.util.TreeNodeImpl;
-import org.apache.ambari.server.controller.spi.Resource;
-import org.junit.Test;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertNull;
-
-
-/**
- * BaseStacksResourceDefinition unit tests
- */
-public class BaseStacksResourceDefinitionTest {
-
- @Test
- public void testHrefCreation() {
- TestResourceDefinition resourceDefinition = new TestResourceDefinition();
- ResourceDefinition.PostProcessor processor = resourceDefinition.getPostProcessors().iterator().next();
-
- TreeNode<Resource> node = new TreeNodeImpl<Resource>(new TreeNodeImpl<Resource>(null, null, null), null, "test");
-
- String href = "/stacks/HDP/versions/1.3.2/stackServices/foo";
- processor.process(null, node, href);
- assertEquals("/stacks/HDP/versions/1.3.2/services/foo", node.getProperty("href"));
-
- href = "/stacks2/HDP/versions/1.3.2/stackServices/foo";
- processor.process(null, node, href);
- assertEquals("/stacks2/HDP/versions/1.3.2/stackServices/foo", node.getProperty("href"));
-
- href = "/stacks/HDP/versions/1.3.2/stackServices/foo/serviceComponents";
- processor.process(null, node, href);
- assertEquals("/stacks/HDP/versions/1.3.2/services/foo/components", node.getProperty("href"));
-
- href = "/stacks2/HDP/versions/1.3.2/stackServices/foo/serviceComponents";
- processor.process(null, node, href);
- assertEquals("/stacks2/HDP/versions/1.3.2/stackServices/foo/serviceComponents", node.getProperty("href"));
-
- href = "/stacks/HDP/versions/1.3.2/operatingSystems";
- processor.process(null, node, href);
- assertEquals("/stacks/HDP/versions/1.3.2/operating_systems", node.getProperty("href"));
-
- href = "/stacks2/HDP/versions/1.3.2/operatingSystems";
- processor.process(null, node, href);
- assertEquals("/stacks2/HDP/versions/1.3.2/operatingSystems", node.getProperty("href"));
- }
-
- @Test
- public void testRenameChildren() {
- TestResourceDefinition resourceDefinition = new TestResourceDefinition();
- ResourceDefinition.PostProcessor processor = resourceDefinition.getPostProcessors().iterator().next();
-
- TreeNode<Resource> node = new TreeNodeImpl<Resource>(new TreeNodeImpl<Resource>(null, null, null), null, "test");
-
- TreeNode<Resource> child = new TreeNodeImpl<Resource>(node, null, "stackServices");
- node.addChild(child);
- child = new TreeNodeImpl<Resource>(node, null, "serviceComponents");
- node.addChild(child);
- child = new TreeNodeImpl<Resource>(node, null, "operatingSystems");
- node.addChild(child);
-
- String href = "/stacks/HDP/versions/1.3.2/stackServices/foo";
-
- assertNotNull(node.getChild("stackServices"));
- assertNotNull(node.getChild("serviceComponents"));
- assertNotNull(node.getChild("operatingSystems"));
-
- assertNull(node.getChild("services"));
- assertNull(node.getChild("components"));
- assertNull(node.getChild("operating_systems"));
-
- processor.process(null, node, href);
-
- assertNull(node.getChild("stackServices"));
- assertNull(node.getChild("serviceComponents"));
- assertNull(node.getChild("operatingSystems"));
-
- assertNotNull(node.getChild("services"));
- assertNotNull(node.getChild("components"));
- assertNotNull(node.getChild("operating_systems"));
- }
-
- private class TestResourceDefinition extends BaseStacksResourceDefinition {
- private TestResourceDefinition() {
- super(Resource.Type.StackServiceComponent);
- }
-
- @Override
- public String getPluralName() {
- return "tests";
- }
-
- @Override
- public String getSingularName() {
- return "test";
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/ambari/blob/631d913d/ambari-server/src/test/java/org/apache/ambari/server/api/resources/StackServiceResourceDefinitionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/resources/StackServiceResourceDefinitionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/resources/StackServiceResourceDefinitionTest.java
index 115e012..1b12738 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/resources/StackServiceResourceDefinitionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/resources/StackServiceResourceDefinitionTest.java
@@ -33,8 +33,8 @@ public class StackServiceResourceDefinitionTest {
@Test
public void testDefinitionNames() {
ResourceDefinition def = new StackServiceResourceDefinition();
- assertEquals("stackService", def.getSingularName());
- assertEquals("stackServices", def.getPluralName());
+ assertEquals("service", def.getSingularName());
+ assertEquals("services", def.getPluralName());
}
@Test
http://git-wip-us.apache.org/repos/asf/ambari/blob/631d913d/ambari-server/src/test/java/org/apache/ambari/server/api/services/Stacks2ServiceTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/Stacks2ServiceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/Stacks2ServiceTest.java
deleted file mode 100644
index 51609cc..0000000
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/Stacks2ServiceTest.java
+++ /dev/null
@@ -1,216 +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.ambari.server.api.services;
-
-import org.apache.ambari.server.api.resources.ResourceInstance;
-import org.apache.ambari.server.api.services.parsers.RequestBodyParser;
-import org.apache.ambari.server.api.services.serializers.ResultSerializer;
-
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.UriInfo;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Unit tests for StacksService.
- */
-public class Stacks2ServiceTest extends BaseServiceTest {
-
- @Override
- public List<ServiceTestInvocation> getTestInvocations() throws Exception {
- List<ServiceTestInvocation> listInvocations = new ArrayList<ServiceTestInvocation>();
-
- //getStack
- Stacks2Service service = new TestStacksService("stackName", null);
- Method m = service.getClass().getMethod("getStack", String.class, HttpHeaders.class, UriInfo.class, String.class);
- Object[] args = new Object[] {null, getHttpHeaders(), getUriInfo(), "stackName"};
- listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
-
- //getStacks
- service = new TestStacksService(null, null);
- m = service.getClass().getMethod("getStacks", String.class, HttpHeaders.class, UriInfo.class);
- args = new Object[] {null, getHttpHeaders(), getUriInfo()};
- listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
-
- //getStackVersion
- service = new TestStacksService("stackName", "stackVersion");
- m = service.getClass().getMethod("getStackVersion", String.class, HttpHeaders.class, UriInfo.class, String.class, String.class);
- args = new Object[] {null, getHttpHeaders(), getUriInfo(), "stackName", "stackVersion"};
- listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
-
- //getStackVersions
- service = new TestStacksService("stackName", null);
- m = service.getClass().getMethod("getStackVersions", String.class, HttpHeaders.class, UriInfo.class, String.class);
- args = new Object[] {null, getHttpHeaders(), getUriInfo(), "stackName"};
- listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
-
- // getRepository
- service = new TestStacksService("stackName", "stackVersion");
- m = service.getClass().getMethod("getRepository", String.class, HttpHeaders.class, UriInfo.class, String.class,
- String.class, String.class, String.class);
- args = new Object[] {null, getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "os", "repo-id"};
- listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
-
- // getRepositories
- service = new TestStacksService("stackName", "stackVersion");
- m = service.getClass().getMethod("getRepositories", String.class, HttpHeaders.class, UriInfo.class, String.class,
- String.class, String.class);
- args = new Object[] {null, getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "os"};
- listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
-
- // updateRepository
- service = new TestStacksService("stackName", "stackVersion");
- m = service.getClass().getMethod("updateRepository", String.class, HttpHeaders.class, UriInfo.class, String.class,
- String.class, String.class, String.class);
- args = new Object[] {"body", getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "os", "repo-id"};
- listInvocations.add(new ServiceTestInvocation(Request.Type.PUT, service, m, args, "body"));
-
- // getStackService
- service = new TestStacksService("stackName", null);
- m = service.getClass().getMethod("getStackService", String.class, HttpHeaders.class, UriInfo.class, String.class,
- String.class, String.class);
- args = new Object[] {null, getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "service-name"};
- listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
-
- // getStackServices
- service = new TestStacksService("stackName", null);
- m = service.getClass().getMethod("getStackServices", String.class, HttpHeaders.class, UriInfo.class, String.class, String.class);
- args = new Object[] {null, getHttpHeaders(), getUriInfo(), "stackName", "stackVersion"};
- listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
-
- // getStackConfiguration
- service = new TestStacksService("stackName", "stackVersion");
- m = service.getClass().getMethod("getStackConfiguration", String.class, HttpHeaders.class, UriInfo.class,
- String.class, String.class, String.class, String.class);
- args = new Object[] {null, getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "service-name", "property-name"};
- listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
-
- // getStackConfigurations
- service = new TestStacksService("stackName", null);
- m = service.getClass().getMethod("getStackConfigurations", String.class, HttpHeaders.class, UriInfo.class,
- String.class, String.class, String.class);
- args = new Object[] {null, getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "service-name"};
- listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
-
- // getServiceComponent
- service = new TestStacksService("stackName", "stackVersion");
- m = service.getClass().getMethod("getServiceComponent", String.class, HttpHeaders.class, UriInfo.class,
- String.class, String.class, String.class, String.class);
- args = new Object[] {null, getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "service-name", "component-name"};
- listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
-
- // getServiceComponents
- service = new TestStacksService("stackName", "stackVersion");
- m = service.getClass().getMethod("getServiceComponents", String.class, HttpHeaders.class, UriInfo.class,
- String.class, String.class, String.class);
- args = new Object[] {null, getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "service-name"};
- listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
-
- // getOperationSystem
- service = new TestStacksService("stackName", "stackVersion");
- m = service.getClass().getMethod("getOperatingSystem", String.class, HttpHeaders.class, UriInfo.class,
- String.class, String.class, String.class);
- args = new Object[] {null, getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "os-type"};
- listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
-
- // getOperationSystems
- service = new TestStacksService("stackName", "stackVersion");
- m = service.getClass().getMethod("getOperatingSystems", String.class, HttpHeaders.class, UriInfo.class,
- String.class, String.class);
- args = new Object[] {null, getHttpHeaders(), getUriInfo(), "stackName", "stackVersion"};
- listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
-
- return listInvocations;
- }
-
- private class TestStacksService extends Stacks2Service {
-
- private String m_stackId;
- private String m_stackVersion;
-
- private TestStacksService(String stackName, String stackVersion) {
- m_stackId = stackName;
- m_stackVersion = stackVersion;
- }
-
- @Override
- ResourceInstance createStackResource(String stackName) {
- assertEquals(m_stackId, stackName);
- return getTestResource();
- }
-
- @Override
- ResourceInstance createStackVersionResource(String stackName, String stackVersion) {
- assertEquals(m_stackId, stackName);
- assertEquals(m_stackVersion, stackVersion);
- return getTestResource();
- }
-
- @Override
- ResourceInstance createRepositoryResource(String stackName,
- String stackVersion, String osType, String repoId) {
-
- return getTestResource();
- }
-
- @Override
- ResourceInstance createStackServiceResource(String stackName,
- String stackVersion, String serviceName) {
-
- return getTestResource();
- }
-
- ResourceInstance createStackConfigurationResource(String stackName,
- String stackVersion, String serviceName, String propertyName) {
-
- return getTestResource();
- }
-
- ResourceInstance createStackServiceComponentResource(String stackName,
- String stackVersion, String serviceName, String componentName) {
-
- return getTestResource();
- }
-
- ResourceInstance createOperatingSystemResource(String stackName, String stackVersion, String osType) {
- return getTestResource();
- }
-
-
- @Override
- RequestFactory getRequestFactory() {
- return getTestRequestFactory();
- }
-
- @Override
- protected RequestBodyParser getBodyParser() {
- return getTestBodyParser();
- }
-
- @Override
- protected ResultSerializer getResultSerializer() {
- return getTestResultSerializer();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/631d913d/ambari-server/src/test/java/org/apache/ambari/server/api/services/StacksServiceTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/StacksServiceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/StacksServiceTest.java
index c36c6d9..dd43ee3 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/StacksServiceTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/StacksServiceTest.java
@@ -212,24 +212,4 @@ public class StacksServiceTest extends BaseServiceTest {
return getTestResultSerializer();
}
}
-
- //todo: this is necessary for temporary changes to service to support both stacks and stacks2 api.
- //todo: when stacks2 is removed and stacks doesn't need to wrap the UriInfo, this should be removed.
- @Override
- protected void assertCreateRequest(ServiceTestInvocation testMethod) {
- expect(requestFactory.createRequest(same(httpHeaders), same(requestBody), (UriInfo) notNull(),
- same(testMethod.getRequestType()), same(resourceInstance))).andReturn(request);
- }
-
- @Test
- public void testStackUriInfo() throws URISyntaxException {
-
- UriInfo delegate = new LocalUriInfo("http://host/services/?fields=*");
- StacksService.StackUriInfo sui = new StacksService.StackUriInfo(delegate);
- assertEquals(new URI("http://host/stackServices/?fields=*"), sui.getRequestUri());
-
- delegate = new LocalUriInfo("http://host/?condition1=true&condition2=true&services/service.matches(A%7CB)");
- sui = new StacksService.StackUriInfo(delegate);
- assertEquals(new URI("http://host/?condition1=true&condition2=true&stackServices%2Fservice.matches%28A%7CB%29"), sui.getRequestUri());
- }
}