ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [3/3] ambari git commit: AMBARI-8510. Repository Version Management > Refactor API (Yurii Shylov via ncole)
Date Tue, 02 Dec 2014 21:41:52 GMT
AMBARI-8510. Repository Version Management > Refactor API (Yurii Shylov via ncole)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7ed98d53
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7ed98d53
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7ed98d53

Branch: refs/heads/trunk
Commit: 7ed98d53c1f1c24dc841baef54e02d2664f6a381
Parents: a930a74
Author: Nate Cole <ncole@hortonworks.com>
Authored: Tue Dec 2 11:14:44 2014 -0800
Committer: Nate Cole <ncole@hortonworks.com>
Committed: Tue Dec 2 13:23:51 2014 -0800

----------------------------------------------------------------------
 LICENSE.txt                                     |  11 -
 ambari-server/pom.xml                           |   5 -
 .../resources/BaseStacksResourceDefinition.java |   4 +-
 .../resources/ClusterResourceDefinition.java    |   2 +-
 ...ComponentStackVersionResourceDefinition.java |  12 +-
 .../resources/RepositoryResourceDefinition.java |   5 -
 .../RepositoryVersionResourceDefinition.java    |  10 +-
 .../StackVersionResourceDefinition.java         |   3 +-
 .../services/ClusterStackVersionService.java    |  29 ++-
 .../api/services/HostStackVersionService.java   |  20 +-
 .../api/services/OperatingSystemService.java    | 127 ++++++++++
 .../server/api/services/RepositoryService.java  | 130 ++++++++++
 .../api/services/RepositoryVersionService.java  |  45 +++-
 .../server/api/services/StacksService.java      | 121 +++++----
 .../controller/AmbariManagementController.java  |   2 +-
 .../AmbariManagementControllerImpl.java         | 114 ++++++---
 .../controller/OperatingSystemRequest.java      |  13 +-
 .../controller/OperatingSystemResponse.java     |   9 +
 .../server/controller/RepositoryRequest.java    |  18 +-
 .../server/controller/RepositoryResponse.java   |  18 +-
 .../AbstractControllerResourceProvider.java     |   4 -
 .../ClusterStackVersionResourceProvider.java    |  41 ++-
 .../internal/DefaultProviderModule.java         |   4 +
 .../HostStackVersionResourceProvider.java       |  18 +-
 .../OperatingSystemResourceProvider.java        |  79 ++++--
 .../internal/RepositoryResourceProvider.java    | 169 +++++++------
 .../RepositoryVersionResourceProvider.java      | 247 +++++++++++--------
 .../internal/StackVersionResourceProvider.java  |  32 +--
 .../server/orm/dao/RepositoryVersionDAO.java    |  17 +-
 .../orm/entities/OperatingSystemEntity.java     |  65 +++++
 .../server/orm/entities/RepositoryEntity.java   |  75 ++++++
 .../orm/entities/RepositoryVersionEntity.java   |  46 +++-
 .../server/state/RepositoryVersionState.java    |  27 +-
 .../src/main/resources/key_properties.json      |  11 -
 .../src/main/resources/properties.json          |  19 --
 .../ambari/server/api/query/QueryImplTest.java  |  30 ++-
 ...onentStackVersionResourceDefinitionTest.java |   2 +-
 ...RepositoryVersionResourceDefinitionTest.java |  13 +-
 .../services/RepositoryVersionServiceTest.java  | 100 --------
 .../server/api/services/StacksServiceTest.java  |  42 +---
 .../AmbariManagementControllerTest.java         |   6 +-
 .../RepositoryResourceProviderTest.java         |  72 +++---
 .../RepositoryVersionResourceProviderTest.java  |  98 ++++----
 .../controller/internal/RequestImplTest.java    |   2 +
 .../internal/UpgradeResourceProviderTest.java   |   2 +-
 .../ambari/server/orm/dao/CrudDAOTest.java      |   2 +-
 .../orm/dao/RepositoryVersionDAOTest.java       |   9 +-
 47 files changed, 1200 insertions(+), 730 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/7ed98d53/LICENSE.txt
----------------------------------------------------------------------
diff --git a/LICENSE.txt b/LICENSE.txt
index 5bb5cde..25b8233 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -279,17 +279,6 @@ A "contributor" is any person that distributes its contribution under this licen
 (D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.
 (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
 
-For fge/json-schema, used to validate json structures:
-http://github.com/fge/json-schema-validator/blob/master/LICENSE
-
-This software is dual-licensed under:
-the Lesser General Public License (LGPL) version 3.0 or, at your option, any later version;
-the Apache Software License (ASL) version 2.0.
-
-LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
-ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
-Apache Software License version 2.0 selected.
-
 For Kokki, resource management library derived from:
 
 Copyright (c) 2009 Samuel Stauffer <samuel@descolada.com>

http://git-wip-us.apache.org/repos/asf/ambari/blob/7ed98d53/ambari-server/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-server/pom.xml b/ambari-server/pom.xml
index e03b626..4076d73 100644
--- a/ambari-server/pom.xml
+++ b/ambari-server/pom.xml
@@ -1676,11 +1676,6 @@
       <artifactId>smtp</artifactId>
       <version>1.5.2</version>
     </dependency>
-    <dependency>
-      <groupId>com.github.fge</groupId>
-      <artifactId>json-schema-validator</artifactId>
-      <version>2.2.6</version>
-    </dependency>
   </dependencies>
 
   <pluginRepositories>

http://git-wip-us.apache.org/repos/asf/ambari/blob/7ed98d53/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
index 2177513..a3a8261 100644
--- 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
@@ -44,13 +44,13 @@ public abstract class BaseStacksResourceDefinition extends BaseResourceDefinitio
   private class StacksHrefProcessor extends BaseHrefPostProcessor {
     @Override
     /**
-     * If processing a /stacks endpoint, replace the endpoint names.
+     * 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/")) {
+      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");

http://git-wip-us.apache.org/repos/asf/ambari/blob/7ed98d53/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 44a06c5..422cf1c 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
@@ -28,7 +28,7 @@ import org.apache.ambari.server.controller.spi.Resource;
 /**
  * Cluster resource definition.
  */
-public class ClusterResourceDefinition extends BaseResourceDefinition {
+public class ClusterResourceDefinition extends BaseStacksResourceDefinition {
   /**
    * Constructor.
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/7ed98d53/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 3d00c82..855ee8c 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
@@ -17,12 +17,15 @@
  */
 package org.apache.ambari.server.api.resources;
 
+import java.util.HashSet;
+import java.util.Set;
+
 import org.apache.ambari.server.controller.spi.Resource;
 
 /**
  * Stack Version Resource Definition for hosts and clusters.
  */
-public class ComponentStackVersionResourceDefinition extends BaseResourceDefinition {
+public class ComponentStackVersionResourceDefinition extends BaseStacksResourceDefinition {
   public ComponentStackVersionResourceDefinition(Resource.Type type) {
     super(type);
   }
@@ -36,4 +39,11 @@ public class ComponentStackVersionResourceDefinition extends BaseResourceDefinit
   public String getSingularName() {
     return "stack_version";
   }
+
+  @Override
+  public Set<SubResourceDefinition> getSubResourceDefinitions() {
+    final Set<SubResourceDefinition> subResourceDefintions = new HashSet<SubResourceDefinition>();
+    subResourceDefintions.add(new SubResourceDefinition(Resource.Type.RepositoryVersion));
+    return subResourceDefintions;
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/7ed98d53/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 b045e69..85ac5bb 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
@@ -18,14 +18,9 @@
 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 RepositoryResourceDefinition extends BaseStacksResourceDefinition {
 
-  public RepositoryResourceDefinition(Type resourceType) {
-    super(Resource.Type.Repository);
-  }
-
   public RepositoryResourceDefinition() {
     super(Resource.Type.Repository);
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/7ed98d53/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 34e9561..abc69f6 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
@@ -17,9 +17,12 @@
  */
 package org.apache.ambari.server.api.resources;
 
+import java.util.Collections;
+import java.util.Set;
+
 import org.apache.ambari.server.controller.spi.Resource;
 
-public class RepositoryVersionResourceDefinition extends BaseResourceDefinition {
+public class RepositoryVersionResourceDefinition extends BaseStacksResourceDefinition {
 
   public RepositoryVersionResourceDefinition() {
     super(Resource.Type.RepositoryVersion);
@@ -35,4 +38,9 @@ public class RepositoryVersionResourceDefinition extends BaseResourceDefinition
     return "repository_version";
   }
 
+  @Override
+  public Set<SubResourceDefinition> getSubResourceDefinitions() {
+    return Collections.singleton(new SubResourceDefinition(Resource.Type.OperatingSystem));
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/7ed98d53/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 5bf3bac..e8d4bd5 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
@@ -48,10 +48,11 @@ public class StackVersionResourceDefinition extends BaseStacksResourceDefinition
   public Set<SubResourceDefinition> getSubResourceDefinitions() {
 
     Set<SubResourceDefinition> setChildren = new HashSet<SubResourceDefinition>();
-    
+
     setChildren.add(new SubResourceDefinition(Resource.Type.OperatingSystem));
     setChildren.add(new SubResourceDefinition(Resource.Type.StackService));
     setChildren.add(new SubResourceDefinition(Resource.Type.StackLevelConfiguration));
+    setChildren.add(new SubResourceDefinition(Resource.Type.RepositoryVersion));
 
     return setChildren;
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/7ed98d53/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterStackVersionService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterStackVersionService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterStackVersionService.java
index ed94877..6a706ff 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterStackVersionService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterStackVersionService.java
@@ -51,7 +51,7 @@ public class ClusterStackVersionService extends BaseService {
   }
 
   /**
-   * Gets all cluster stack version.
+   * Gets all cluster stack versions.
    * Handles: GET /clusters/{clustername}/stack_versions requests.
    *
    * @param headers http headers
@@ -62,12 +62,12 @@ public class ClusterStackVersionService extends BaseService {
   @GET
   @Produces("text/plain")
   public Response getClusterStackVersions(@Context HttpHeaders headers, @Context UriInfo ui) {
-    return handleRequest(headers, null, ui, Request.Type.GET, createResource(clusterName, null));
+    return handleRequest(headers, null, ui, Request.Type.GET, createResource(null));
   }
 
   /**
    * Gets a single cluster stack version.
-   * Handles: GET /clusters/{clustername}/stack_versions/{stackversionid} requests.
+   * Handles: GET /clusters/{clustername}/stack_versions/{stackVersionId} requests.
    *
    * @param headers        http headers
    * @param ui             uri info
@@ -76,22 +76,35 @@ public class ClusterStackVersionService extends BaseService {
    * @return information regarding the specific cluster stack version
    */
   @GET
-  @Path("{stackversionid}")
+  @Path("{stackVersionId}")
   @Produces("text/plain")
   public Response getClusterStackVersion(@Context HttpHeaders headers, @Context UriInfo ui,
-      @PathParam("stackversionid") String stackVersionId) {
-    return handleRequest(headers, null, ui, Request.Type.GET, createResource(clusterName, stackVersionId));
+      @PathParam("stackVersionId") String stackVersionId) {
+    return handleRequest(headers, null, ui, Request.Type.GET, createResource(stackVersionId));
+  }
+
+  /**
+   * Handles ANY /{stackVersionId}/repository_versions requests.
+   *
+   * @param stackVersionId cluster stack version id
+   * @return repository version service
+   */
+  @Path("{stackVersionId}/repository_versions")
+  public RepositoryVersionService getRepositoryVersionHanlder(@PathParam("stackVersionId") String stackVersionId) {
+    final Map<Resource.Type, String> stackVersionProperties = new HashMap<Resource.Type, String>();
+    stackVersionProperties.put(Resource.Type.Cluster, clusterName);
+    stackVersionProperties.put(Resource.Type.ClusterStackVersion, stackVersionId);
+    return new RepositoryVersionService(stackVersionProperties);
   }
 
   /**
    * Create a cluster stack version resource instance.
    *
-   * @param clusterName    cluster name
    * @param stackVersionId cluster stack version id
    *
    * @return a cluster stack version resource instance
    */
-  private ResourceInstance createResource(String clusterName, String stackVersionId) {
+  private ResourceInstance createResource(String stackVersionId) {
     final Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
     mapIds.put(Resource.Type.Cluster, clusterName);
     mapIds.put(Resource.Type.ClusterStackVersion, stackVersionId);

http://git-wip-us.apache.org/repos/asf/ambari/blob/7ed98d53/ambari-server/src/main/java/org/apache/ambari/server/api/services/HostStackVersionService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/HostStackVersionService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/HostStackVersionService.java
index 86a00a8..af8ee78 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/HostStackVersionService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/HostStackVersionService.java
@@ -71,19 +71,33 @@ public class HostStackVersionService extends BaseService {
    *
    * @param headers        http headers
    * @param ui             uri info
-   * @param stackversionid host stack version id
+   * @param stackVersionId host stack version id
    *
    * @return information regarding the specific host stack version
    */
   @GET
-  @Path("{stackversionid}")
+  @Path("{stackVersionId}")
   @Produces("text/plain")
   public Response getHostStackVersion(@Context HttpHeaders headers, @Context UriInfo ui,
-      @PathParam("stackversionid") String stackVersionId) {
+      @PathParam("stackVersionId") String stackVersionId) {
     return handleRequest(headers, null, ui, Request.Type.GET, createResource(hostName, stackVersionId));
   }
 
   /**
+   * Handles ANY /{stackVersionId}/repository_versions requests.
+   *
+   * @param stackVersionId host stack version id
+   * @return repository version service
+   */
+  @Path("{stackVersionId}/repository_versions")
+  public RepositoryVersionService getRepositoryVersionHanlder(@PathParam("stackVersionId") String stackVersionId) {
+    final Map<Resource.Type, String> stackVersionProperties = new HashMap<Resource.Type, String>();
+    stackVersionProperties.put(Resource.Type.Host, hostName);
+    stackVersionProperties.put(Resource.Type.HostStackVersion, stackVersionId);
+    return new RepositoryVersionService(stackVersionProperties);
+  }
+
+  /**
    * Create a host stack version resource instance.
    *
    * @param hostName host name

http://git-wip-us.apache.org/repos/asf/ambari/blob/7ed98d53/ambari-server/src/main/java/org/apache/ambari/server/api/services/OperatingSystemService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/OperatingSystemService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/OperatingSystemService.java
new file mode 100644
index 0000000..531f964
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/OperatingSystemService.java
@@ -0,0 +1,127 @@
+/**
+ * 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.
+ */
+/**
+ * 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.HashMap;
+import java.util.Map;
+
+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.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 responsible for operating systems requests.
+ */
+public class OperatingSystemService extends BaseService {
+
+  /**
+   * Extra properties to be inserted into created resource.
+   */
+  private Map<Resource.Type, String> parentKeyProperties;
+
+  /**
+   * Constructor.
+   *
+   * @param parentKeyProperties extra properties to be inserted into created resource
+   */
+  public OperatingSystemService(Map<Resource.Type, String> parentKeyProperties) {
+    this.parentKeyProperties = parentKeyProperties;
+  }
+
+  /**
+   * Gets all operating systems.
+   * Handles: GET /operating_systems requests.
+   *
+   * @param headers http headers
+   * @param ui      uri info
+   */
+  @GET
+  @Produces("text/plain")
+  public Response getOperatingSystems(@Context HttpHeaders headers, @Context UriInfo ui) {
+    return handleRequest(headers, null, ui, Request.Type.GET, createResource(null));
+  }
+
+  /**
+   * Gets a single operating system.
+   * Handles: GET /operating_systems/{osType} requests.
+   *
+   * @param headers http headers
+   * @param ui      uri info
+   * @param osType  os type
+   * @return information regarding the specified operating system
+   */
+  @GET
+  @Path("{osType}")
+  @Produces("text/plain")
+  public Response getOperatingSystem(@Context HttpHeaders headers, @Context UriInfo ui, @PathParam("osType") String osType) {
+    return handleRequest(headers, null, ui, Request.Type.GET, createResource(osType));
+  }
+
+  /**
+   * Handles ANY /{osType}/repositories requests.
+   *
+   * @param osType the os type
+   * @return repositories service
+   */
+  @Path("{osType}/repositories")
+  public RepositoryService getOperatingSystemsHandler(@PathParam("osType") String osType) {
+    final Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
+    mapIds.putAll(parentKeyProperties);
+    mapIds.put(Resource.Type.OperatingSystem, osType);
+    return new RepositoryService(mapIds);
+  }
+
+  /**
+   * Create an operating system resource instance.
+   *
+   * @param osType os type
+   *
+   * @return an operating system instance
+   */
+  private ResourceInstance createResource(String osType) {
+    final Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
+    mapIds.putAll(parentKeyProperties);
+    mapIds.put(Resource.Type.OperatingSystem, osType);
+    return createResource(Resource.Type.OperatingSystem, mapIds);
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/7ed98d53/ambari-server/src/main/java/org/apache/ambari/server/api/services/RepositoryService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/RepositoryService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/RepositoryService.java
new file mode 100644
index 0000000..166f700
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/RepositoryService.java
@@ -0,0 +1,130 @@
+/**
+ * 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.
+ */
+/**
+ * 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.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 responsible for repository requests.
+ */
+public class RepositoryService extends BaseService {
+
+  /**
+   * Extra properties to be inserted into created resource.
+   */
+  private Map<Resource.Type, String> parentKeyProperties;
+
+  /**
+   * Constructor.
+   *
+   * @param parentKeyProperties extra properties to be inserted into created resource
+   */
+  public RepositoryService(Map<Resource.Type, String> parentKeyProperties) {
+    this.parentKeyProperties = parentKeyProperties;
+  }
+
+  /**
+   * Gets all repositories.
+   * Handles: GET /repositories requests.
+   *
+   * @param headers http headers
+   * @param ui      uri info
+   */
+  @GET
+  @Produces("text/plain")
+  public Response getRepositories(@Context HttpHeaders headers, @Context UriInfo ui) {
+    return handleRequest(headers, null, ui, Request.Type.GET, createResource(null));
+  }
+
+  /**
+   * Gets a single repository.
+   * Handles: GET /repositories/{repoId} requests.
+   *
+   * @param headers http headers
+   * @param ui      uri info
+   * @param repoId  repository id
+   * @return information regarding the specified repository
+   */
+  @GET
+  @Path("{repoId}")
+  @Produces("text/plain")
+  public Response getRepository(@Context HttpHeaders headers, @Context UriInfo ui, @PathParam("repoId") String repoId) {
+    return handleRequest(headers, null, ui, Request.Type.GET, createResource(repoId));
+  }
+
+  /**
+   * Updates a single repository.
+   * Handles: PUT /repositories/{repoId} requests.
+   *
+   * @param headers http headers
+   * @param ui      uri info
+   * @param repoId  repository id
+   * @return information regarding the specified repository
+   */
+  @PUT
+  @Path("{repoId}")
+  @Produces("text/plain")
+  public Response updateRepository(String body, @Context HttpHeaders headers, @Context UriInfo ui, @PathParam("repoId") String repoId) {
+    return handleRequest(headers, body, ui, Request.Type.PUT, createResource(repoId));
+  }
+
+  /**
+   * Create a repository resource instance.
+   *
+   * @param repoId repository id
+   *
+   * @return a repository instance
+   */
+  private ResourceInstance createResource(String repoId) {
+    final Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
+    mapIds.putAll(parentKeyProperties);
+    mapIds.put(Resource.Type.Repository, repoId);
+    return createResource(Resource.Type.Repository, mapIds);
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/7ed98d53/ambari-server/src/main/java/org/apache/ambari/server/api/services/RepositoryVersionService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/RepositoryVersionService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/RepositoryVersionService.java
index 2c40788..0a21762 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/RepositoryVersionService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/RepositoryVersionService.java
@@ -17,6 +17,9 @@
  */
 package org.apache.ambari.server.api.services;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
@@ -32,13 +35,25 @@ import javax.ws.rs.core.UriInfo;
 import org.apache.ambari.server.api.resources.ResourceInstance;
 import org.apache.ambari.server.controller.spi.Resource;
 
-import java.util.Collections;
-
 /**
  * Service responsible for repository versions requests.
  */
-@Path("/repository_versions/")
 public class RepositoryVersionService extends BaseService {
+
+  /**
+   * Extra properties to be inserted into created resource.
+   */
+  private Map<Resource.Type, String> parentKeyProperties;
+
+  /**
+   * Constructor.
+   *
+   * @param parentKeyProperties extra properties to be inserted into created resource
+   */
+  public RepositoryVersionService(Map<Resource.Type, String> parentKeyProperties) {
+    this.parentKeyProperties = parentKeyProperties;
+  }
+
   /**
    * Gets all repository versions.
    * Handles: GET /repository_versions requests.
@@ -84,7 +99,7 @@ public class RepositoryVersionService extends BaseService {
   }
 
   /**
-   * Deletes a repository version. Handles: DELETE /repository_version/{repositoryVersionId} requests.
+   * Deletes a repository version. Handles: DELETE /repository_versions/{repositoryVersionId} requests.
    *
    * @param headers               http headers
    * @param ui                    uri info
@@ -100,7 +115,7 @@ public class RepositoryVersionService extends BaseService {
   }
 
   /**
-   * Updates a specific repository version. Handles: PUT /repository_version/{repositoryVersionId} requests.
+   * Updates a specific repository version. Handles: PUT /repository_versions/{repositoryVersionId} requests.
    *
    * @param headers               http headers
    * @param ui                    uri info
@@ -116,6 +131,20 @@ public class RepositoryVersionService extends BaseService {
   }
 
   /**
+   * Handles ANY /{repositoryVersionId}/operating_systems requests.
+   *
+   * @param repositoryVersionId the repository version id
+   * @return operating systems service
+   */
+  @Path("{repositoryVersionId}/operating_systems")
+  public OperatingSystemService getOperatingSystemsHandler(@PathParam("repositoryVersionId") String repositoryVersionId) {
+    final Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
+    mapIds.putAll(parentKeyProperties);
+    mapIds.put(Resource.Type.RepositoryVersion, repositoryVersionId);
+    return new OperatingSystemService(mapIds);
+  }
+
+  /**
    * Create a repository version resource instance.
    *
    * @param repositoryVersionId repository version id
@@ -123,7 +152,9 @@ public class RepositoryVersionService extends BaseService {
    * @return a repository resource instance
    */
   private ResourceInstance createResource(String repositoryVersionId) {
-    return createResource(Resource.Type.RepositoryVersion,
-        Collections.singletonMap(Resource.Type.RepositoryVersion, repositoryVersionId));
+    final Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
+    mapIds.putAll(parentKeyProperties);
+    mapIds.put(Resource.Type.RepositoryVersion, repositoryVersionId);
+    return createResource(Resource.Type.RepositoryVersion, mapIds);
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/7ed98d53/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 3df1eaf..c34ee3d 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
@@ -28,7 +28,6 @@ import java.util.List;
 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;
@@ -93,46 +92,6 @@ public class StacksService extends BaseService {
   }
 
   @GET
-  @Path("{stackName}/versions/{stackVersion}/operating_systems/{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, new StackUriInfo(ui), Request.Type.GET,
-        createRepositoryResource(stackName, stackVersion, osType, null));
-  }
-
-  @GET
-  @Path("{stackName}/versions/{stackVersion}/operating_systems/{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, new StackUriInfo(ui), Request.Type.GET,
-        createRepositoryResource(stackName, stackVersion, osType, repoId));
-  }
-
-  @PUT
-  @Path("{stackName}/versions/{stackVersion}/operating_systems/{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, new StackUriInfo(ui), Request.Type.PUT,
-        createRepositoryResource(stackName, stackVersion, osType, repoId));
-  }
-  
-  @GET
   @Path("{stackName}/versions/{stackVersion}/configurations")
   @Produces("text/plain")
   public Response getStackLevelConfigurations(String body, @Context HttpHeaders headers,
@@ -142,7 +101,7 @@ public class StacksService extends BaseService {
     return handleRequest(headers, body, new StackUriInfo(ui), Request.Type.GET,
         createStackLevelConfigurationsResource(stackName, stackVersion, null));
   }
-  
+
   @GET
   @Path("{stackName}/versions/{stackVersion}/configurations/{propertyName}")
   @Produces("text/plain")
@@ -248,8 +207,6 @@ public class StacksService extends BaseService {
         createStackServiceComponentDependencyResource(stackName, stackVersion, serviceName, componentName, dependencyName));
   }
 
-
-
   @GET
   @Path("{stackName}/versions/{stackVersion}/services/{serviceName}/components/{componentName}")
   @Produces("text/plain")
@@ -263,38 +220,72 @@ public class StacksService extends BaseService {
         createStackServiceComponentResource(stackName, stackVersion, serviceName, componentName));
   }
 
+  /**
+   * Handles ANY /{stackName}/versions/{stackVersion}/operating_systems.
+   *
+   * @param stackName stack name
+   * @param stackVersion stack version
+   * @return operating system service
+   */
+  @Path("{stackName}/versions/{stackVersion}/operating_systems")
+  public OperatingSystemService getOperatingSystemsHandler(@PathParam("stackName") String stackName, @PathParam("stackVersion") String stackVersion) {
+    final Map<Resource.Type, String> stackProperties = new HashMap<Resource.Type, String>();
+    stackProperties.put(Resource.Type.Stack, stackName);
+    stackProperties.put(Resource.Type.StackVersion, stackVersion);
+    return new OperatingSystemService(stackProperties);
+  }
+
+  /**
+   * Handles ANY /{stackName}/versions/{stackVersion}/repository_versions.
+   *
+   * @param stackName stack name
+   * @param stackVersion stack version
+   * @return repository version service
+   */
+  @Path("{stackName}/versions/{stackVersion}/repository_versions")
+  public RepositoryVersionService getRepositoryVersionHanlder(@PathParam("stackName") String stackName, @PathParam("stackVersion") String stackVersion) {
+    final Map<Resource.Type, String> stackProperties = new HashMap<Resource.Type, String>();
+    stackProperties.put(Resource.Type.Stack, stackName);
+    stackProperties.put(Resource.Type.StackVersion, stackVersion);
+    return new RepositoryVersionService(stackProperties);
+  }
 
   @GET
-  @Path("{stackName}/versions/{stackVersion}/operating_systems")
+  @Path("{stackName}/versions/{stackVersion}/repository_versions/{repositoryVersionId}/operating_systems/{osType}/repositories")
   @Produces("text/plain")
-  public Response getOperatingSystems(String body, @Context HttpHeaders headers,
-                                      @Context UriInfo ui, @PathParam("stackName") String stackName,
-                                      @PathParam("stackVersion") String stackVersion) {
+  public Response getRepositories(String body, @Context HttpHeaders headers, @Context UriInfo ui, @PathParam("stackName") String stackName,
+      @PathParam("stackVersion") String stackVersion, @PathParam("repositoryVersionId") String repositoryVersionId, @PathParam("osType") String osType) {
 
-    return handleRequest(headers, body, new StackUriInfo(ui), Request.Type.GET,
-        createOperatingSystemResource(stackName, stackVersion, null));
+    return handleRequest(headers, body, new StackUriInfo(ui), Request.Type.GET, createRepositoryResource(stackName, stackVersion, repositoryVersionId, osType, null));
   }
 
   @GET
-  @Path("{stackName}/versions/{stackVersion}/operating_systems/{osType}")
+  @Path("{stackName}/versions/{stackVersion}/repository_versions/{repositoryVersionId}/operating_systems/{osType}/repositories/{repoId}")
   @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) {
+  public Response getRepository(String body, @Context HttpHeaders headers, @Context UriInfo ui, @PathParam("stackName") String stackName,
+      @PathParam("stackVersion") String stackVersion, @PathParam("repositoryVersionId") String repositoryVersionId, @PathParam("osType") String osType, @PathParam("repoId") String repoId) {
 
-    return handleRequest(headers, body, new StackUriInfo(ui), Request.Type.GET,
-        createOperatingSystemResource(stackName, stackVersion, osType));
+    return handleRequest(headers, body, new StackUriInfo(ui), Request.Type.GET, createRepositoryResource(stackName, stackVersion, repositoryVersionId, osType, repoId));
   }
 
+  ResourceInstance createRepositoryVersionResource(String stackName, String stackVersion,
+                                                   String repositoryVersionId) {
+    final 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.RepositoryVersion, repositoryVersionId);
 
-  ResourceInstance createOperatingSystemResource(String stackName,
-                                                 String stackVersion, String osType) {
+    return createResource(Resource.Type.RepositoryVersion, mapIds);
+  }
+
+  ResourceInstance createOperatingSystemResource(String stackName, String stackVersion, String repositoryVersion, String osType) {
+    final Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
 
-    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.RepositoryVersion, repositoryVersion);
 
     return createResource(Resource.Type.OperatingSystem, mapIds);
   }
@@ -346,15 +337,13 @@ public class StacksService extends BaseService {
     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>();
+  ResourceInstance createRepositoryResource(String stackName, String stackVersion, String repositoryVersion, String osType, String repoId) {
+    final 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);
-
+    mapIds.put(Resource.Type.RepositoryVersion, repositoryVersion);
     return createResource(Resource.Type.Repository, mapIds);
   }
 
@@ -366,7 +355,7 @@ public class StacksService extends BaseService {
 
     return createResource(Resource.Type.StackVersion, mapIds);
   }
-  
+
   ResourceInstance createStackLevelConfigurationsResource(String stackName,
       String stackVersion, String propertyName) {
     Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();

http://git-wip-us.apache.org/repos/asf/ambari/blob/7ed98d53/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
index a1ece2c..9abbf36 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
@@ -421,7 +421,7 @@ public interface AmbariManagementController {
    *
    * @throws  AmbariException if the resources cannot be read
    */
-  public Set<OperatingSystemResponse> getStackOperatingSystems(Set<OperatingSystemRequest> requests) throws AmbariException;
+  public Set<OperatingSystemResponse> getOperatingSystems(Set<OperatingSystemRequest> requests) throws AmbariException;
 
   /**
    * Get all top-level services of Ambari, not related to certain cluster.

http://git-wip-us.apache.org/repos/asf/ambari/blob/7ed98d53/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
index 0e65a1d..ce1a2c2 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
@@ -82,6 +82,10 @@ import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.customactions.ActionDefinition;
 import org.apache.ambari.server.metadata.ActionMetadata;
 import org.apache.ambari.server.metadata.RoleCommandOrder;
+import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
+import org.apache.ambari.server.orm.entities.OperatingSystemEntity;
+import org.apache.ambari.server.orm.entities.RepositoryEntity;
+import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.scheduler.ExecutionScheduleManager;
 import org.apache.ambari.server.security.authorization.AuthorizationHelper;
 import org.apache.ambari.server.security.authorization.Group;
@@ -198,6 +202,8 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
   private ExecutionScheduleManager executionScheduleManager;
   @Inject
   private AmbariLdapDataPopulator ldapDataPopulator;
+  @Inject
+  private RepositoryVersionDAO repositoryVersionDAO;
 
   private MaintenanceStateHelper maintenanceStateHelper;
 
@@ -2301,8 +2307,8 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
         State slaveState = componentHost.getState();
         //Delete hostcomponents
         entry.getKey().deleteServiceComponentHosts(componentHost.getHostName());
-        // If deleted hostcomponents support decomission and were decommited and stopped 
-        if (AmbariCustomCommandExecutionHelper.masterToSlaveMappingForDecom.containsValue(slave_component_name) 
+        // If deleted hostcomponents support decomission and were decommited and stopped
+        if (AmbariCustomCommandExecutionHelper.masterToSlaveMappingForDecom.containsValue(slave_component_name)
                 && desiredAdminState.equals(HostComponentAdminState.DECOMMISSIONED)
                 && slaveState.equals(State.INSTALLED)) {
 
@@ -2314,7 +2320,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
           //Clear exclud file or draining list except HBASE
           if (!serviceName.equals(Service.Type.HBASE.toString())) {
             HashMap<String, String> requestProperties = new HashMap<String, String>();
-            requestProperties.put("context", "Remove host " + 
+            requestProperties.put("context", "Remove host " +
                     included_hostname + " from exclude file");
             requestProperties.put("exclusive", "true");
             HashMap<String, String> params = new HashMap<String, String>();
@@ -2332,7 +2338,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
             //Send request
             createAction(actionRequest, requestProperties);
           }
-         
+
           //Mark master component as needed to restart for remove host info from components UI
           Cluster cluster = clusters.getCluster(entry.getKey().getClusterName());
           Service service = cluster.getService(serviceName);
@@ -2865,8 +2871,12 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
         Set<RepositoryResponse> repositories = getRepositories(request);
 
         for (RepositoryResponse repositoryResponse : repositories) {
-          repositoryResponse.setStackName(stackName);
-          repositoryResponse.setStackVersion(stackVersion);
+          if (repositoryResponse.getStackName() == null) {
+            repositoryResponse.setStackName(stackName);
+          }
+          if (repositoryResponse.getStackVersion() == null) {
+            repositoryResponse.setStackVersion(stackVersion);
+          }
         }
         response.addAll(repositories);
       } catch (StackAccessException e) {
@@ -2886,23 +2896,41 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     String stackVersion = request.getStackVersion();
     String osType = request.getOsType();
     String repoId = request.getRepoId();
+    Long repositoryVersionId = request.getRepositoryVersionId();
+
+    Set<RepositoryResponse> responses = new HashSet<RepositoryResponse>();
+
+    if (repositoryVersionId != null) {
+      final RepositoryVersionEntity repositoryVersion = repositoryVersionDAO.findByPK(repositoryVersionId);
+      if (repositoryVersion != null) {
+        for (OperatingSystemEntity operatingSystem: repositoryVersion.getOperatingSystems()) {
+          if (operatingSystem.getOsType().equals(osType)) {
+            for (RepositoryEntity repository: operatingSystem.getRepositories()) {
+              final RepositoryResponse response = new RepositoryResponse(repository.getBaseUrl(), osType, repository.getRepositoryId(), repository.getName(), "", "", "");
+              response.setRepositoryVersionId(repositoryVersionId);
+              response.setStackName(repositoryVersion.getStackName());
+              response.setStackVersion(repositoryVersion.getStackVersion());
+              responses.add(response);
+            }
+            break;
+          }
+        }
+      }
+    } else {
+      if (repoId == null) {
+        List<RepositoryInfo> repositories = ambariMetaInfo.getRepositories(stackName, stackVersion, osType);
 
-    Set<RepositoryResponse> response;
-
-    if (repoId == null) {
-      List<RepositoryInfo> repositories = ambariMetaInfo.getRepositories(stackName, stackVersion, osType);
-      response = new HashSet<RepositoryResponse>();
+        for (RepositoryInfo repository: repositories) {
+          responses.add(repository.convertToResponse());
+        }
 
-      for (RepositoryInfo repository: repositories) {
-        response.add(repository.convertToResponse());
+      } else {
+        RepositoryInfo repository = ambariMetaInfo.getRepository(stackName, stackVersion, osType, repoId);
+        responses = Collections.singleton(repository.convertToResponse());
       }
-
-    } else {
-      RepositoryInfo repository = ambariMetaInfo.getRepository(stackName, stackVersion, osType, repoId);
-      response = Collections.singleton(repository.convertToResponse());
     }
 
-    return response;
+    return responses;
   }
 
   @Override
@@ -2926,6 +2954,9 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
 
       if (null != rr.getBaseUrl()) {
         if (!rr.isVerifyBaseUrl()) {
+          if (rr.getRepositoryVersionId() != null) {
+            throw new AmbariException("Can't directly update repositories in repository_version, update the repository_version instead");
+          }
           ambariMetaInfo.updateRepoBaseURL(rr.getStackName(),
               rr.getStackVersion(), rr.getOsType(), rr.getRepoId(),
               rr.getBaseUrl());
@@ -3227,7 +3258,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
   }
 
   @Override
-  public Set<OperatingSystemResponse> getStackOperatingSystems(
+  public Set<OperatingSystemResponse> getOperatingSystems(
       Set<OperatingSystemRequest> requests) throws AmbariException {
     Set<OperatingSystemResponse> response = new HashSet<OperatingSystemResponse>();
     for (OperatingSystemRequest request : requests) {
@@ -3235,11 +3266,15 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
         String stackName    = request.getStackName();
         String stackVersion = request.getStackVersion();
 
-        Set<OperatingSystemResponse> stackOperatingSystems = getStackOperatingSystems(request);
+        Set<OperatingSystemResponse> stackOperatingSystems = getOperatingSystems(request);
 
         for (OperatingSystemResponse operatingSystemResponse : stackOperatingSystems) {
-          operatingSystemResponse.setStackName(stackName);
-          operatingSystemResponse.setStackVersion(stackVersion);
+          if (operatingSystemResponse.getStackName() == null) {
+            operatingSystemResponse.setStackName(stackName);
+          }
+          if (operatingSystemResponse.getStackVersion() == null) {
+            operatingSystemResponse.setStackVersion(stackVersion);
+          }
         }
         response.addAll(stackOperatingSystems);
       } catch (StackAccessException e) {
@@ -3253,27 +3288,40 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     return response;
   }
 
-  private Set<OperatingSystemResponse> getStackOperatingSystems(
+  private Set<OperatingSystemResponse> getOperatingSystems(
       OperatingSystemRequest request) throws AmbariException {
 
-    Set<OperatingSystemResponse> response;
+    Set<OperatingSystemResponse> responses = new HashSet<OperatingSystemResponse>();;
 
     String stackName = request.getStackName();
     String stackVersion = request.getStackVersion();
     String osType = request.getOsType();
-
-    if (osType != null) {
-      OperatingSystemInfo operatingSystem = ambariMetaInfo.getOperatingSystem(stackName, stackVersion, osType);
-      response = Collections.singleton(operatingSystem.convertToResponse());
+    Long repositoryVersionId = request.getRepositoryVersionId();
+
+    if (repositoryVersionId != null) {
+      final RepositoryVersionEntity repositoryVersion = repositoryVersionDAO.findByPK(repositoryVersionId);
+      if (repositoryVersion != null) {
+        for (OperatingSystemEntity operatingSystem: repositoryVersion.getOperatingSystems()) {
+          final OperatingSystemResponse response = new OperatingSystemResponse(operatingSystem.getOsType());
+          response.setRepositoryVersionId(repositoryVersionId);
+          response.setStackName(repositoryVersion.getStackName());
+          response.setStackVersion(repositoryVersion.getStackVersion());
+          responses.add(response);
+        }
+      }
     } else {
-      Set<OperatingSystemInfo> operatingSystems = ambariMetaInfo.getOperatingSystems(stackName, stackVersion);
-      response = new HashSet<OperatingSystemResponse>();
-      for (OperatingSystemInfo operatingSystem : operatingSystems) {
-        response.add(operatingSystem.convertToResponse());
+      if (osType != null) {
+        OperatingSystemInfo operatingSystem = ambariMetaInfo.getOperatingSystem(stackName, stackVersion, osType);
+        responses = Collections.singleton(operatingSystem.convertToResponse());
+      } else {
+        Set<OperatingSystemInfo> operatingSystems = ambariMetaInfo.getOperatingSystems(stackName, stackVersion);
+        for (OperatingSystemInfo operatingSystem : operatingSystems) {
+          responses.add(operatingSystem.convertToResponse());
+        }
       }
     }
 
-    return response;
+    return responses;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/ambari/blob/7ed98d53/ambari-server/src/main/java/org/apache/ambari/server/controller/OperatingSystemRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/OperatingSystemRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/OperatingSystemRequest.java
index 92f1dfd..16136db 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/OperatingSystemRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/OperatingSystemRequest.java
@@ -16,15 +16,14 @@
  * limitations under the License.
  */
 
-
 package org.apache.ambari.server.controller;
 
 public class OperatingSystemRequest extends StackVersionRequest {
 
   private String osType;
+  private Long repositoryVersionId;
 
-  public OperatingSystemRequest(String stackName, String stackVersion,
-      String osType) {
+  public OperatingSystemRequest(String stackName, String stackVersion, String osType) {
     super(stackName, stackVersion);
     setOsType(osType);
   }
@@ -37,4 +36,12 @@ public class OperatingSystemRequest extends StackVersionRequest {
     this.osType = osType;
   }
 
+  public Long getRepositoryVersionId() {
+    return repositoryVersionId;
+  }
+
+  public void setRepositoryVersionId(Long repositoryVersionId) {
+    this.repositoryVersionId = repositoryVersionId;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/7ed98d53/ambari-server/src/main/java/org/apache/ambari/server/controller/OperatingSystemResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/OperatingSystemResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/OperatingSystemResponse.java
index 0ff2832..cc9bb70 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/OperatingSystemResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/OperatingSystemResponse.java
@@ -23,6 +23,7 @@ public class OperatingSystemResponse {
   private String stackName;
   private String stackVersion;
   private String osType;
+  private Long repositoryVersionId;
 
   public OperatingSystemResponse(String osType) {
     setOsType(osType);
@@ -51,4 +52,12 @@ public class OperatingSystemResponse {
   public void setOsType(String osType) {
     this.osType = osType;
   }
+
+  public Long getRepositoryVersionId() {
+    return repositoryVersionId;
+  }
+
+  public void setRepositoryVersionId(Long repositoryVersionId) {
+    this.repositoryVersionId = repositoryVersionId;
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/7ed98d53/ambari-server/src/main/java/org/apache/ambari/server/controller/RepositoryRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/RepositoryRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/RepositoryRequest.java
index 0e1e81f..853623f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/RepositoryRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/RepositoryRequest.java
@@ -18,12 +18,12 @@
 
 package org.apache.ambari.server.controller;
 
-public class RepositoryRequest extends OperatingSystemRequest{
+public class RepositoryRequest extends OperatingSystemRequest {
 
   private String repoId;
   private String baseUrl;
   private boolean verify = true;
-  
+
   public RepositoryRequest(String stackName, String stackVersion, String osType, String repoId) {
     super(stackName, stackVersion, osType);
     setRepoId(repoId);
@@ -36,39 +36,37 @@ public class RepositoryRequest extends OperatingSystemRequest{
   public void setRepoId(String repoId) {
     this.repoId = repoId;
   }
-  
+
   /**
    * Gets the base URL for the repo.
-   * 
+   *
    * @return the url
    */
   public String getBaseUrl() {
     return baseUrl;
   }
-  
+
   /**
    * Sets the base URL for the repo.
-   * 
+   *
    * @param url the base URL.
    */
   public void setBaseUrl(String url) {
     baseUrl = url;
   }
-  
+
   /**
    * @return <code>true</code> if the base url should be verified.  Default is <code>true</code>.
    */
   public boolean isVerifyBaseUrl() {
     return verify;
   }
-  
+
   /**
    * @param verifyUrl <code>true</code> to verify  the base url
    */
   public void setVerifyBaseUrl(boolean verifyUrl) {
     verify = verifyUrl;
   }
-  
-  
 
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/7ed98d53/ambari-server/src/main/java/org/apache/ambari/server/controller/RepositoryResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/RepositoryResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/RepositoryResponse.java
index 9adeb07..63f6b60 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/RepositoryResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/RepositoryResponse.java
@@ -29,8 +29,8 @@ public class RepositoryResponse {
   private String mirrorsList;
   private String defaultBaseUrl;
   private String latestBaseUrl;
-  
-  
+  private Long repositoryVersionId;
+
   public RepositoryResponse(String baseUrl, String osType, String repoId,
       String repoName, String mirrorsList, String defaultBaseUrl, String latestBaseUrl) {
     setBaseUrl(baseUrl);
@@ -103,23 +103,29 @@ public class RepositoryResponse {
   public void setMirrorsList(String mirrorsList) {
     this.mirrorsList = mirrorsList;
   }
-  
+
   public String getDefaultBaseUrl() {
     return defaultBaseUrl;
   }
-  
+
   public void setDefaultBaseUrl(String url) {
     this.defaultBaseUrl = url;
   }
-  
+
   public String getLatestBaseUrl() {
     return latestBaseUrl;
   }
-  
+
   public void setLatestBaseUrl(String url) {
     latestBaseUrl = url;
   }
 
+  public Long getRepositoryVersionId() {
+    return repositoryVersionId;
+  }
 
+  public void setRepositoryVersionId(Long repositoryVersionId) {
+    this.repositoryVersionId = repositoryVersionId;
+  }
 
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/7ed98d53/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
index da05edf..ea3b4b1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
@@ -125,12 +125,8 @@ public abstract class AbstractControllerResourceProvider extends AbstractResourc
         return new StackServiceComponentResourceProvider(propertyIds, keyPropertyIds, managementController);
       case StackConfiguration:
         return new StackConfigurationResourceProvider(propertyIds, keyPropertyIds, managementController);
-      case OperatingSystem:
-        return new OperatingSystemResourceProvider(propertyIds, keyPropertyIds, managementController);
       case StackLevelConfiguration:
         return new StackLevelConfigurationResourceProvider(propertyIds, keyPropertyIds, managementController);
-      case Repository:
-        return new RepositoryResourceProvider(propertyIds, keyPropertyIds, managementController);
       case RootService:
         return new RootServiceResourceProvider(propertyIds, keyPropertyIds, managementController);
       case RootServiceComponent:

http://git-wip-us.apache.org/repos/asf/ambari/blob/7ed98d53/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
index 0fc590e..1e0e735 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
@@ -38,10 +38,8 @@ import org.apache.ambari.server.controller.spi.Resource.Type;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
 import org.apache.ambari.server.orm.dao.ClusterVersionDAO;
 import org.apache.ambari.server.orm.dao.HostVersionDAO;
-import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
 import org.apache.ambari.server.orm.entities.ClusterVersionEntity;
 import org.apache.ambari.server.orm.entities.HostVersionEntity;
-import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.state.RepositoryVersionState;
 
 import com.google.inject.Inject;
@@ -54,20 +52,20 @@ public class ClusterStackVersionResourceProvider extends AbstractResourceProvide
 
   // ----- Property ID constants ---------------------------------------------
 
-  protected static final String CLUSTER_STACK_VERSION_ID_PROPERTY_ID              = PropertyHelper.getPropertyId("ClusterStackVersions", "id");
-  protected static final String CLUSTER_STACK_VERSION_CLUSTER_NAME_PROPERTY_ID    = PropertyHelper.getPropertyId("ClusterStackVersions", "cluster_name");
-  protected static final String CLUSTER_STACK_VERSION_STACK_PROPERTY_ID           = PropertyHelper.getPropertyId("ClusterStackVersions", "stack");
-  protected static final String CLUSTER_STACK_VERSION_VERSION_PROPERTY_ID         = PropertyHelper.getPropertyId("ClusterStackVersions", "version");
-  protected static final String CLUSTER_STACK_VERSION_STATE_PROPERTY_ID           = PropertyHelper.getPropertyId("ClusterStackVersions", "state");
-  protected static final String CLUSTER_STACK_VERSION_INSTALLED_HOSTS_PROPERTY_ID = PropertyHelper.getPropertyId("ClusterStackVersions", "installed_hosts");
-  protected static final String CLUSTER_STACK_VERSION_CURRENT_HOSTS_PROPERTY_ID   = PropertyHelper.getPropertyId("ClusterStackVersions", "current_hosts");
-  protected static final String CLUSTER_STACK_VERSION_REPOSITORIES_PROPERTY_ID    = PropertyHelper.getPropertyId("ClusterStackVersions", "repositories");
+  protected static final String CLUSTER_STACK_VERSION_ID_PROPERTY_ID                   = PropertyHelper.getPropertyId("ClusterStackVersions", "id");
+  protected static final String CLUSTER_STACK_VERSION_CLUSTER_NAME_PROPERTY_ID         = PropertyHelper.getPropertyId("ClusterStackVersions", "cluster_name");
+  protected static final String CLUSTER_STACK_VERSION_STACK_PROPERTY_ID                = PropertyHelper.getPropertyId("ClusterStackVersions", "stack");
+  protected static final String CLUSTER_STACK_VERSION_VERSION_PROPERTY_ID              = PropertyHelper.getPropertyId("ClusterStackVersions", "version");
+  protected static final String CLUSTER_STACK_VERSION_STATE_PROPERTY_ID                = PropertyHelper.getPropertyId("ClusterStackVersions", "state");
+  protected static final String CLUSTER_STACK_VERSION_HOST_STATES_PROPERTY_ID          = PropertyHelper.getPropertyId("ClusterStackVersions", "host_states");
 
   @SuppressWarnings("serial")
   private static Set<String> pkPropertyIds = new HashSet<String>() {
     {
       add(CLUSTER_STACK_VERSION_CLUSTER_NAME_PROPERTY_ID);
       add(CLUSTER_STACK_VERSION_ID_PROPERTY_ID);
+      add(CLUSTER_STACK_VERSION_STACK_PROPERTY_ID);
+      add(CLUSTER_STACK_VERSION_VERSION_PROPERTY_ID);
     }
   };
 
@@ -79,9 +77,7 @@ public class ClusterStackVersionResourceProvider extends AbstractResourceProvide
       add(CLUSTER_STACK_VERSION_STACK_PROPERTY_ID);
       add(CLUSTER_STACK_VERSION_VERSION_PROPERTY_ID);
       add(CLUSTER_STACK_VERSION_STATE_PROPERTY_ID);
-      add(CLUSTER_STACK_VERSION_INSTALLED_HOSTS_PROPERTY_ID);
-      add(CLUSTER_STACK_VERSION_CURRENT_HOSTS_PROPERTY_ID);
-      add(CLUSTER_STACK_VERSION_REPOSITORIES_PROPERTY_ID);
+      add(CLUSTER_STACK_VERSION_HOST_STATES_PROPERTY_ID);
     }
   };
 
@@ -90,6 +86,8 @@ public class ClusterStackVersionResourceProvider extends AbstractResourceProvide
     {
       put(Resource.Type.Cluster, CLUSTER_STACK_VERSION_CLUSTER_NAME_PROPERTY_ID);
       put(Resource.Type.ClusterStackVersion, CLUSTER_STACK_VERSION_ID_PROPERTY_ID);
+      put(Resource.Type.Stack, CLUSTER_STACK_VERSION_STACK_PROPERTY_ID);
+      put(Resource.Type.StackVersion, CLUSTER_STACK_VERSION_VERSION_PROPERTY_ID);
     }
   };
 
@@ -99,9 +97,6 @@ public class ClusterStackVersionResourceProvider extends AbstractResourceProvide
   @Inject
   private static HostVersionDAO hostVersionDAO;
 
-  @Inject
-  private static RepositoryVersionDAO repositoryVersionDAO;
-
   /**
    * Constructor.
    */
@@ -139,24 +134,18 @@ public class ClusterStackVersionResourceProvider extends AbstractResourceProvide
 
     for (ClusterVersionEntity entity: requestedEntities) {
       final Resource resource = new ResourceImpl(Resource.Type.ClusterStackVersion);
-      final RepositoryVersionEntity repositoryVersionEntity = repositoryVersionDAO.findByStackAndVersion(entity.getStack(), entity.getVersion());
 
-      final Map<RepositoryVersionState, List<String>> hosts = new HashMap<RepositoryVersionState, List<String>>();
+      final Map<String, List<String>> hostStates = new HashMap<String, List<String>>();
       for (RepositoryVersionState state: RepositoryVersionState.values()) {
-        hosts.put(state, new ArrayList<String>());
+        hostStates.put(state.name(), new ArrayList<String>());
       }
       for (HostVersionEntity hostVersionEntity: hostVersionDAO.findByClusterStackAndVersion(entity.getClusterEntity().getClusterName(), entity.getStack(), entity.getVersion())) {
-        hosts.get(hostVersionEntity.getState()).add(hostVersionEntity.getHostName());
+        hostStates.get(hostVersionEntity.getState().name()).add(hostVersionEntity.getHostName());
       }
 
       setResourceProperty(resource, CLUSTER_STACK_VERSION_CLUSTER_NAME_PROPERTY_ID, entity.getClusterEntity().getClusterName(), requestedIds);
-
-      setResourceProperty(resource, CLUSTER_STACK_VERSION_CURRENT_HOSTS_PROPERTY_ID, hosts.get(RepositoryVersionState.CURRENT), requestedIds);
+      setResourceProperty(resource, CLUSTER_STACK_VERSION_HOST_STATES_PROPERTY_ID, hostStates, requestedIds);
       setResourceProperty(resource, CLUSTER_STACK_VERSION_ID_PROPERTY_ID, entity.getId(), requestedIds);
-      setResourceProperty(resource, CLUSTER_STACK_VERSION_INSTALLED_HOSTS_PROPERTY_ID, hosts.get(RepositoryVersionState.INSTALLED), requestedIds);
-      if (repositoryVersionEntity != null) {
-        setResourceProperty(resource, CLUSTER_STACK_VERSION_REPOSITORIES_PROPERTY_ID, repositoryVersionEntity.getRepositories(), requestedIds);
-      }
       setResourceProperty(resource, CLUSTER_STACK_VERSION_STACK_PROPERTY_ID, entity.getStack(), requestedIds);
       setResourceProperty(resource, CLUSTER_STACK_VERSION_STATE_PROPERTY_ID, entity.getState().name(), requestedIds);
       setResourceProperty(resource, CLUSTER_STACK_VERSION_VERSION_PROPERTY_ID, entity.getVersion(), requestedIds);

http://git-wip-us.apache.org/repos/asf/ambari/blob/7ed98d53/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java
index 698737b..1e3c329 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java
@@ -108,6 +108,10 @@ public class DefaultProviderModule extends AbstractProviderModule {
         return new HostStackVersionResourceProvider();
       case Stage:
         return new StageResourceProvider();
+      case OperatingSystem:
+        return new OperatingSystemResourceProvider(managementController);
+      case Repository:
+        return new RepositoryResourceProvider(managementController);
 
       default:
         return AbstractControllerResourceProvider.getResourceProvider(type, propertyIds,

http://git-wip-us.apache.org/repos/asf/ambari/blob/7ed98d53/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java
index 67e62d7..3caf62a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java
@@ -37,10 +37,7 @@ import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
 import org.apache.ambari.server.controller.spi.Resource.Type;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
 import org.apache.ambari.server.orm.dao.HostVersionDAO;
-import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
 import org.apache.ambari.server.orm.entities.HostVersionEntity;
-import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
-
 import com.google.inject.Inject;
 
 /**
@@ -63,6 +60,8 @@ public class HostStackVersionResourceProvider extends AbstractResourceProvider {
     {
       add(HOST_STACK_VERSION_HOST_NAME_PROPERTY_ID);
       add(HOST_STACK_VERSION_ID_PROPERTY_ID);
+      add(HOST_STACK_VERSION_STACK_PROPERTY_ID);
+      add(HOST_STACK_VERSION_VERSION_PROPERTY_ID);
     }
   };
 
@@ -83,15 +82,14 @@ public class HostStackVersionResourceProvider extends AbstractResourceProvider {
     {
       put(Resource.Type.Host, HOST_STACK_VERSION_HOST_NAME_PROPERTY_ID);
       put(Resource.Type.HostStackVersion, HOST_STACK_VERSION_ID_PROPERTY_ID);
+      put(Resource.Type.Stack, HOST_STACK_VERSION_STACK_PROPERTY_ID);
+      put(Resource.Type.StackVersion, HOST_STACK_VERSION_VERSION_PROPERTY_ID);
     }
   };
 
   @Inject
   private static HostVersionDAO hostVersionDAO;
 
-  @Inject
-  private static RepositoryVersionDAO repositoryVersionDAO;
-
   /**
    * Constructor.
    */
@@ -129,20 +127,14 @@ public class HostStackVersionResourceProvider extends AbstractResourceProvider {
 
     for (HostVersionEntity entity: requestedEntities) {
       final Resource resource = new ResourceImpl(Resource.Type.HostStackVersion);
-      final RepositoryVersionEntity repositoryVersionEntity = repositoryVersionDAO.findByStackAndVersion(entity.getStack(), entity.getVersion());
 
       setResourceProperty(resource, HOST_STACK_VERSION_HOST_NAME_PROPERTY_ID, entity.getHostName(), requestedIds);
       setResourceProperty(resource, HOST_STACK_VERSION_ID_PROPERTY_ID, entity.getId(), requestedIds);
       setResourceProperty(resource, HOST_STACK_VERSION_STACK_PROPERTY_ID, entity.getStack(), requestedIds);
       setResourceProperty(resource, HOST_STACK_VERSION_VERSION_PROPERTY_ID, entity.getVersion(), requestedIds);
-      if (repositoryVersionEntity != null) {
-        setResourceProperty(resource, HOST_STACK_VERSION_REPOSITORIES_PROPERTY_ID, repositoryVersionEntity.getRepositories(), requestedIds);
-      }
       setResourceProperty(resource, HOST_STACK_VERSION_STATE_PROPERTY_ID, entity.getState().name(), requestedIds);
 
-      if (predicate == null || predicate.evaluate(resource)) {
-        resources.add(resource);
-      }
+      resources.add(resource);
     }
     return resources;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/7ed98d53/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/OperatingSystemResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/OperatingSystemResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/OperatingSystemResourceProvider.java
index cc1998f..682d8bd 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/OperatingSystemResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/OperatingSystemResourceProvider.java
@@ -18,8 +18,8 @@
 
 package org.apache.ambari.server.controller.internal;
 
-import java.util.Arrays;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
@@ -40,22 +40,41 @@ import org.apache.ambari.server.controller.utilities.PropertyHelper;
 
 public class OperatingSystemResourceProvider extends ReadOnlyResourceProvider {
 
-  public static final String STACK_NAME_PROPERTY_ID = PropertyHelper
-      .getPropertyId("OperatingSystems", "stack_name");
-
-  private static final String STACK_VERSION_PROPERTY_ID = PropertyHelper
-      .getPropertyId("OperatingSystems", "stack_version");
-
-  private static final String OS_TYPE_PROPERTY_ID = PropertyHelper
-      .getPropertyId("OperatingSystems", "os_type");
-
-  private static Set<String> pkPropertyIds = new HashSet<String>(
-      Arrays.asList(new String[] { STACK_NAME_PROPERTY_ID,
-          STACK_VERSION_PROPERTY_ID, OS_TYPE_PROPERTY_ID }));
+  public static final String OPERATING_SYSTEM_STACK_NAME_PROPERTY_ID            = PropertyHelper.getPropertyId("OperatingSystems", "stack_name");
+  public static final String OPERATING_SYSTEM_STACK_VERSION_PROPERTY_ID         = PropertyHelper.getPropertyId("OperatingSystems", "stack_version");
+  public static final String OPERATING_SYSTEM_OS_TYPE_PROPERTY_ID               = PropertyHelper.getPropertyId("OperatingSystems", "os_type");
+  public static final String OPERATING_SYSTEM_REPOSITORY_VERSION_ID_PROPERTY_ID = PropertyHelper.getPropertyId("OperatingSystems", "repository_version_id");
+
+  @SuppressWarnings("serial")
+  private static Set<String> pkPropertyIds = new HashSet<String>() {
+    {
+      add(OPERATING_SYSTEM_OS_TYPE_PROPERTY_ID);
+      add(OPERATING_SYSTEM_STACK_NAME_PROPERTY_ID);
+      add(OPERATING_SYSTEM_STACK_VERSION_PROPERTY_ID);
+    }
+  };
+
+  @SuppressWarnings("serial")
+  private static Set<String> propertyIds = new HashSet<String>() {
+    {
+      add(OPERATING_SYSTEM_OS_TYPE_PROPERTY_ID);
+      add(OPERATING_SYSTEM_STACK_NAME_PROPERTY_ID);
+      add(OPERATING_SYSTEM_STACK_VERSION_PROPERTY_ID);
+      add(OPERATING_SYSTEM_REPOSITORY_VERSION_ID_PROPERTY_ID);
+    }
+  };
+
+  @SuppressWarnings("serial")
+  private static Map<Type, String> keyPropertyIds = new HashMap<Type, String>() {
+    {
+      put(Resource.Type.OperatingSystem, OPERATING_SYSTEM_OS_TYPE_PROPERTY_ID);
+      put(Resource.Type.Stack, OPERATING_SYSTEM_STACK_NAME_PROPERTY_ID);
+      put(Resource.Type.StackVersion, OPERATING_SYSTEM_STACK_VERSION_PROPERTY_ID);
+      put(Resource.Type.RepositoryVersion, OPERATING_SYSTEM_REPOSITORY_VERSION_ID_PROPERTY_ID);
+    }
+  };
 
-  protected OperatingSystemResourceProvider(Set<String> propertyIds,
-      Map<Type, String> keyPropertyIds,
-      AmbariManagementController managementController) {
+  protected OperatingSystemResourceProvider(AmbariManagementController managementController) {
     super(propertyIds, keyPropertyIds, managementController);
   }
 
@@ -79,7 +98,7 @@ public class OperatingSystemResourceProvider extends ReadOnlyResourceProvider {
     Set<OperatingSystemResponse> responses = getResources(new Command<Set<OperatingSystemResponse>>() {
       @Override
       public Set<OperatingSystemResponse> invoke() throws AmbariException {
-        return getManagementController().getStackOperatingSystems(requests);
+        return getManagementController().getOperatingSystems(requests);
       }
     });
 
@@ -88,15 +107,20 @@ public class OperatingSystemResourceProvider extends ReadOnlyResourceProvider {
     for (OperatingSystemResponse response : responses) {
       Resource resource = new ResourceImpl(Resource.Type.OperatingSystem);
 
-      setResourceProperty(resource, STACK_NAME_PROPERTY_ID,
+      setResourceProperty(resource, OPERATING_SYSTEM_STACK_NAME_PROPERTY_ID,
           response.getStackName(), requestedIds);
-      
-      setResourceProperty(resource, STACK_VERSION_PROPERTY_ID,
+
+      setResourceProperty(resource, OPERATING_SYSTEM_STACK_VERSION_PROPERTY_ID,
           response.getStackVersion(), requestedIds);
-      
-      setResourceProperty(resource, OS_TYPE_PROPERTY_ID,
+
+      setResourceProperty(resource, OPERATING_SYSTEM_OS_TYPE_PROPERTY_ID,
           response.getOsType(), requestedIds);
 
+      if (response.getRepositoryVersionId() != null) {
+        setResourceProperty(resource, OPERATING_SYSTEM_REPOSITORY_VERSION_ID_PROPERTY_ID,
+            response.getRepositoryVersionId(), requestedIds);
+      }
+
       resources.add(resource);
     }
 
@@ -104,9 +128,14 @@ public class OperatingSystemResourceProvider extends ReadOnlyResourceProvider {
   }
 
   private OperatingSystemRequest getRequest(Map<String, Object> properties) {
-    return new OperatingSystemRequest((String) properties.get(STACK_NAME_PROPERTY_ID),
-        (String) properties.get(STACK_VERSION_PROPERTY_ID),
-        (String) properties.get(OS_TYPE_PROPERTY_ID));
+    final OperatingSystemRequest request = new OperatingSystemRequest(
+        (String) properties.get(OPERATING_SYSTEM_STACK_NAME_PROPERTY_ID),
+        (String) properties.get(OPERATING_SYSTEM_STACK_VERSION_PROPERTY_ID),
+        (String) properties.get(OPERATING_SYSTEM_OS_TYPE_PROPERTY_ID));
+    if (properties.containsKey(OPERATING_SYSTEM_REPOSITORY_VERSION_ID_PROPERTY_ID)) {
+      request.setRepositoryVersionId(Long.parseLong(properties.get(OPERATING_SYSTEM_REPOSITORY_VERSION_ID_PROPERTY_ID).toString()));
+    }
+    return request;
   }
 
   @Override


Mime
View raw message