ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tbeerbo...@apache.org
Subject git commit: AMBARI-5677 - Ambari Views : Ability to handle name + version views and view instances
Date Tue, 06 May 2014 21:03:04 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 32210667d -> 6d33c3240


AMBARI-5677 - Ambari Views : Ability to handle name + version views and view instances


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

Branch: refs/heads/trunk
Commit: 6d33c324070206a188d456d37b4addb1607521ce
Parents: 3221066
Author: tbeerbower <tbeerbower@hortonworks.com>
Authored: Tue May 6 12:24:05 2014 -0400
Committer: tbeerbower <tbeerbower@hortonworks.com>
Committed: Tue May 6 16:50:46 2014 -0400

----------------------------------------------------------------------
 .../resources/ResourceInstanceFactoryImpl.java  |   8 +-
 .../api/resources/ViewResourceDefinition.java   |   2 +-
 .../ViewVersionResourceDefinition.java          |  58 ++++++
 .../ViewExternalSubResourceService.java         |  16 +-
 .../api/services/ViewInstanceService.java       |  39 ++--
 .../ambari/server/api/services/ViewService.java |   8 +-
 .../api/services/ViewSubResourceService.java    |  17 +-
 .../server/api/services/ViewVersionService.java | 185 +++++++++++++++++++
 .../internal/DefaultProviderModule.java         |   2 +
 .../internal/ViewInstanceResourceProvider.java  |  33 +++-
 .../internal/ViewResourceProvider.java          |  21 +--
 .../internal/ViewVersionResourceProvider.java   | 159 ++++++++++++++++
 .../ambari/server/controller/spi/Resource.java  |   2 +
 .../ambari/server/orm/entities/ViewEntity.java  |  41 +++-
 .../server/orm/entities/ViewInstanceEntity.java |   8 +-
 .../ambari/server/view/ViewContextImpl.java     |   2 +-
 .../view/ViewExternalSubResourceProvider.java   |   6 +-
 .../apache/ambari/server/view/ViewRegistry.java |  62 ++++---
 .../server/view/ViewSubResourceProvider.java    |  15 +-
 .../resources/ViewResourceDefinitionTest.java   |   2 +-
 .../ViewVersionResourceDefinitionTest.java      |  51 +++++
 .../server/orm/entities/ViewEntityTest.java     |   8 +-
 .../orm/entities/ViewInstanceEntityTest.java    |   4 +-
 .../ambari/server/view/ViewContextImplTest.java |   2 +-
 .../ambari/server/view/ViewRegistryTest.java    |   6 +-
 .../view/ViewSubResourceDefinitionTest.java     |   6 +-
 26 files changed, 667 insertions(+), 96 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/6d33c324/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 49ed8ab..e1428d8 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
@@ -201,9 +201,15 @@ public class ResourceInstanceFactoryImpl implements ResourceInstanceFactory {
         resourceDefinition = new ViewResourceDefinition();
         break;
 
+      case ViewVersion:
+        resourceDefinition = new ViewVersionResourceDefinition();
+        break;
+
       case ViewInstance:
         Set<SubResourceDefinition> subResourceDefinitions =
-            ViewRegistry.getInstance().getSubResourceDefinitions(mapIds.get(Resource.Type.View));
+            ViewRegistry.getInstance().getSubResourceDefinitions(
+                mapIds.get(Resource.Type.View),
+                mapIds.get(Resource.Type.ViewVersion));
 
         resourceDefinition = new ViewInstanceResourceDefinition(subResourceDefinitions);
         break;

http://git-wip-us.apache.org/repos/asf/ambari/blob/6d33c324/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ViewResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ViewResourceDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ViewResourceDefinition.java
index a068183..4951b03 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ViewResourceDefinition.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ViewResourceDefinition.java
@@ -53,6 +53,6 @@ public class ViewResourceDefinition extends BaseResourceDefinition {
 
   @Override
   public Set<SubResourceDefinition> getSubResourceDefinitions() {
-    return Collections.singleton(new SubResourceDefinition(Resource.Type.ViewInstance));
+    return Collections.singleton(new SubResourceDefinition(Resource.Type.ViewVersion));
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6d33c324/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ViewVersionResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ViewVersionResourceDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ViewVersionResourceDefinition.java
new file mode 100644
index 0000000..e67a50b
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ViewVersionResourceDefinition.java
@@ -0,0 +1,58 @@
+/**
+ * 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.controller.spi.Resource;
+
+import java.util.Collections;
+import java.util.Set;
+
+
+/**
+ * View version resource definition.
+ */
+public class ViewVersionResourceDefinition extends BaseResourceDefinition {
+
+  // ----- Constructors ------------------------------------------------------
+
+  /**
+   * Construct a view version resource definition.
+   */
+  public ViewVersionResourceDefinition() {
+    super(Resource.Type.ViewVersion);
+  }
+
+
+  // ----- ResourceDefinition ------------------------------------------------
+
+  @Override
+  public String getPluralName() {
+    return "versions";
+  }
+
+  @Override
+  public String getSingularName() {
+    return "version";
+  }
+
+  @Override
+  public Set<SubResourceDefinition> getSubResourceDefinitions() {
+    return Collections.singleton(new SubResourceDefinition(Resource.Type.ViewInstance));
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6d33c324/ambari-server/src/main/java/org/apache/ambari/server/api/services/ViewExternalSubResourceService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ViewExternalSubResourceService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ViewExternalSubResourceService.java
index 3617a63..28912f4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ViewExternalSubResourceService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ViewExternalSubResourceService.java
@@ -20,6 +20,7 @@ package org.apache.ambari.server.api.services;
 
 import org.apache.ambari.server.api.resources.ResourceInstance;
 import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.orm.entities.ViewEntity;
 import org.apache.ambari.server.orm.entities.ViewInstanceEntity;
 
 import javax.ws.rs.GET;
@@ -50,6 +51,11 @@ public class ViewExternalSubResourceService  extends BaseService {
   private final String viewName;
 
   /**
+   * The view version.
+   */
+  private final String version;
+
+  /**
    * The instance name.
    */
   private final String instanceName;
@@ -63,8 +69,11 @@ public class ViewExternalSubResourceService  extends BaseService {
   // ----- Constructors ------------------------------------------------------
 
   public ViewExternalSubResourceService(Resource.Type type, ViewInstanceEntity viewInstanceDefinition) {
+    ViewEntity viewEntity = viewInstanceDefinition.getViewEntity();
+
     this.type         = type;
-    this.viewName     = viewInstanceDefinition.getViewName();
+    this.viewName     = viewEntity.getCommonName();
+    this.version      = viewEntity.getVersion();
     this.instanceName = viewInstanceDefinition.getName();
   }
 
@@ -81,7 +90,7 @@ public class ViewExternalSubResourceService  extends BaseService {
   @Produces("text/plain")
   public Response getResources(@Context HttpHeaders headers, @Context UriInfo ui) {
     return handleRequest(headers, null, ui, Request.Type.GET,
-        createServiceResource(viewName, instanceName));
+        createResource(viewName, instanceName));
   }
 
   /**
@@ -126,9 +135,10 @@ public class ViewExternalSubResourceService  extends BaseService {
    *
    * @return a view instance resource
    */
-  private ResourceInstance createServiceResource(String viewName, String instanceName) {
+  private ResourceInstance createResource(String viewName, String instanceName) {
     Map<Resource.Type,String> mapIds = new HashMap<Resource.Type, String>();
     mapIds.put(Resource.Type.View, viewName);
+    mapIds.put(Resource.Type.ViewVersion, version);
     mapIds.put(Resource.Type.ViewInstance, instanceName);
     return createResource(type, mapIds);
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6d33c324/ambari-server/src/main/java/org/apache/ambari/server/api/services/ViewInstanceService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ViewInstanceService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ViewInstanceService.java
index 0b0acad..5d4ae97 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ViewInstanceService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ViewInstanceService.java
@@ -44,7 +44,12 @@ public class ViewInstanceService extends BaseService {
   /**
    * Parent view name.
    */
-  private String m_viewName;
+  private final String viewName;
+
+  /**
+   * The view version.
+   */
+  private final String version;
 
 
   // ----- Constructors ------------------------------------------------------
@@ -53,11 +58,16 @@ public class ViewInstanceService extends BaseService {
    * Construct a view instance service.
    *
    * @param viewName  the view id
+   * @param version   the version
    */
-  public ViewInstanceService(String viewName) {
-    m_viewName = viewName;
+  public ViewInstanceService(String viewName, String version) {
+    this.viewName = viewName;
+    this.version  = version;
   }
 
+
+  // ----- ViewInstanceService -----------------------------------------------
+
   /**
    * Handles URL: /views/{viewID}/instances/{instanceID}
    * Get a specific instance.
@@ -75,7 +85,7 @@ public class ViewInstanceService extends BaseService {
                              @PathParam("instanceName") String instanceName) {
 
     return handleRequest(headers, null, ui, Request.Type.GET,
-        createServiceResource(m_viewName, instanceName));
+        createResource(viewName, version, instanceName));
   }
 
   /**
@@ -91,7 +101,7 @@ public class ViewInstanceService extends BaseService {
   @Produces("text/plain")
   public Response getServices(@Context HttpHeaders headers, @Context UriInfo ui) {
     return handleRequest(headers, null, ui, Request.Type.GET,
-        createServiceResource(m_viewName, null));
+        createResource(viewName, version,  null));
   }
 
   /**
@@ -111,7 +121,7 @@ public class ViewInstanceService extends BaseService {
   public Response createService(String body, @Context HttpHeaders headers, @Context UriInfo ui,
                                 @PathParam("instanceName") String instanceName) {
     return handleRequest(headers, body, ui, Request.Type.POST,
-        createServiceResource(m_viewName, instanceName));
+        createResource(viewName, version,  instanceName));
   }
 
   /**
@@ -129,7 +139,7 @@ public class ViewInstanceService extends BaseService {
   public Response createServices(String body, @Context HttpHeaders headers, @Context UriInfo ui) {
 
     return handleRequest(headers, body, ui, Request.Type.POST,
-        createServiceResource(m_viewName, null));
+        createResource(viewName, version,  null));
   }
 
   /**
@@ -149,7 +159,7 @@ public class ViewInstanceService extends BaseService {
   public Response updateService(String body, @Context HttpHeaders headers, @Context UriInfo ui,
                                 @PathParam("instanceName") String instanceName) {
 
-    return handleRequest(headers, body, ui, Request.Type.PUT, createServiceResource(m_viewName, instanceName));
+    return handleRequest(headers, body, ui, Request.Type.PUT, createResource(viewName, version,  instanceName));
   }
 
   /**
@@ -166,7 +176,7 @@ public class ViewInstanceService extends BaseService {
   @Produces("text/plain")
   public Response updateServices(String body, @Context HttpHeaders headers, @Context UriInfo ui) {
 
-    return handleRequest(headers, body, ui, Request.Type.PUT, createServiceResource(m_viewName, null));
+    return handleRequest(headers, body, ui, Request.Type.PUT, createResource(viewName, version,  null));
   }
 
   /**
@@ -185,7 +195,7 @@ public class ViewInstanceService extends BaseService {
   public Response deleteService(@Context HttpHeaders headers, @Context UriInfo ui,
                                 @PathParam("instanceName") String instanceName) {
 
-    return handleRequest(headers, null, ui, Request.Type.DELETE, createServiceResource(m_viewName, instanceName));
+    return handleRequest(headers, null, ui, Request.Type.DELETE, createResource(viewName, version,  instanceName));
   }
 
   /**
@@ -200,18 +210,18 @@ public class ViewInstanceService extends BaseService {
                                             @PathParam("resources") String resources) {
 
     ViewInstanceEntity instanceDefinition =
-        ViewRegistry.getInstance().getInstanceDefinition(m_viewName, instanceName);
+        ViewRegistry.getInstance().getInstanceDefinition(viewName, version, instanceName);
 
     if (instanceDefinition == null) {
       throw new IllegalArgumentException("A view instance " +
-          m_viewName + "/" + instanceName + " can not be found.");
+          viewName + "/" + instanceName + " can not be found.");
     }
 
     Object service = instanceDefinition.getService(resources);
 
     if (service == null) {
       throw new IllegalArgumentException("A resource type " + resources + " for view instance " +
-          m_viewName + "/" + instanceName + " can not be found.");
+          viewName + "/" + instanceName + " can not be found.");
     }
     return service;
   }
@@ -227,9 +237,10 @@ public class ViewInstanceService extends BaseService {
    *
    * @return a view instance resource
    */
-  private ResourceInstance createServiceResource(String viewName, String instanceName) {
+  private ResourceInstance createResource(String viewName, String viewVersion, String instanceName) {
     Map<Resource.Type,String> mapIds = new HashMap<Resource.Type, String>();
     mapIds.put(Resource.Type.View, viewName);
+    mapIds.put(Resource.Type.ViewVersion, viewVersion);
     mapIds.put(Resource.Type.ViewInstance, instanceName);
     return createResource(Resource.Type.ViewInstance, mapIds);
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6d33c324/ambari-server/src/main/java/org/apache/ambari/server/api/services/ViewService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ViewService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ViewService.java
index 45d7d2f..b177ec9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ViewService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ViewService.java
@@ -137,11 +137,11 @@ public class ViewService extends BaseService {
    *
    * @param viewName  view id
    *
-   * @return the hosts service
+   * @return the versions service
    */
-  @Path("{viewName}/instances")
-  public ViewInstanceService getInstanceHandler(@PathParam("viewName") String viewName) {
-    return new ViewInstanceService(viewName);
+  @Path("{viewName}/versions")
+  public ViewVersionService getInstanceHandler(@PathParam("viewName") String viewName) {
+    return new ViewVersionService(viewName);
   }
 
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/6d33c324/ambari-server/src/main/java/org/apache/ambari/server/api/services/ViewSubResourceService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ViewSubResourceService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ViewSubResourceService.java
index 52dd608..d5434ea 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ViewSubResourceService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ViewSubResourceService.java
@@ -20,6 +20,8 @@ package org.apache.ambari.server.api.services;
 
 import org.apache.ambari.server.api.resources.ResourceInstance;
 import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.orm.entities.ViewEntity;
+import org.apache.ambari.server.orm.entities.ViewInstanceEntity;
 import org.apache.ambari.view.ViewResourceHandler;
 
 import javax.ws.rs.core.HttpHeaders;
@@ -43,6 +45,11 @@ public class ViewSubResourceService extends BaseService implements ViewResourceH
   private final String viewName;
 
   /**
+   * The view version.
+   */
+  private final String version;
+
+  /**
    * The associated view instance name.
    */
   private final String instanceName;
@@ -53,10 +60,13 @@ public class ViewSubResourceService extends BaseService implements ViewResourceH
   /**
    * Construct a view sub-resource service.
    */
-  public ViewSubResourceService(Resource.Type type, String viewName, String instanceName) {
+  public ViewSubResourceService(Resource.Type type, ViewInstanceEntity viewInstanceDefinition) {
+    ViewEntity viewEntity = viewInstanceDefinition.getViewEntity();
+
     this.type         = type;
-    this.viewName     = viewName;
-    this.instanceName = instanceName;
+    this.viewName     = viewEntity.getCommonName();
+    this.version      = viewEntity.getVersion();
+    this.instanceName = viewInstanceDefinition.getName();
   }
 
 
@@ -76,6 +86,7 @@ public class ViewSubResourceService extends BaseService implements ViewResourceH
     Map<Resource.Type,String> mapIds = new HashMap<Resource.Type,String>();
 
     mapIds.put(Resource.Type.View, viewName);
+    mapIds.put(Resource.Type.ViewVersion, version);
     mapIds.put(Resource.Type.ViewInstance, instanceName);
 
     if (resourceId != null) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/6d33c324/ambari-server/src/main/java/org/apache/ambari/server/api/services/ViewVersionService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ViewVersionService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ViewVersionService.java
new file mode 100644
index 0000000..a3bde5e
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ViewVersionService.java
@@ -0,0 +1,185 @@
+/**
+ * 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.controller.spi.Resource;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+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 java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * Service responsible for view version resource requests.
+ */
+public class ViewVersionService extends BaseService {
+
+  /**
+   * Parent view name.
+   */
+  private final String viewName;
+
+
+  // ----- Constructors ------------------------------------------------------
+
+  /**
+   * Construct a view version service.
+   *
+   * @param viewName  the view name
+   */
+  public ViewVersionService(String viewName) {
+    this.viewName = viewName;
+  }
+
+
+  // ----- ViewVersionService ------------------------------------------------
+
+  /**
+   * Handles: GET /versions/{version}
+   * Get a specific view version.
+   *
+   * @param headers  http headers
+   * @param ui       uri info
+   * @param version  version id
+   *
+   * @return view instance representation
+   */
+  @GET
+  @Path("{version}")
+  @Produces("text/plain")
+  public Response getVersions(@Context HttpHeaders headers, @Context UriInfo ui,
+                          @PathParam("version") String version) {
+
+    return handleRequest(headers, null, ui, Request.Type.GET, createResource(viewName, version));
+  }
+
+  /**
+   * Handles: GET  /versions
+   * Get all views versions.
+   *
+   * @param headers  http headers
+   * @param ui       uri info
+   *
+   * @return view collection resource representation
+   */
+  @GET
+  @Produces("text/plain")
+  public Response getVersions(@Context HttpHeaders headers, @Context UriInfo ui) {
+
+    return handleRequest(headers, null, ui, Request.Type.GET, createResource(viewName, null));
+  }
+
+  /**
+   * Handles: POST /versions/{version}
+   * Create a specific view version.
+   *
+   * @param headers    http headers
+   * @param ui         uri info
+   * @param version    the version
+   *
+   * @return information regarding the created view
+   */
+  @POST
+  @Path("{version}")
+  @Produces("text/plain")
+  public Response createVersions(String body, @Context HttpHeaders headers, @Context UriInfo ui,
+                             @PathParam("version") String version) {
+
+    return handleRequest(headers, body, ui, Request.Type.POST, createResource(viewName, version));
+  }
+
+  /**
+   * Handles: PUT /versions/{version}
+   * Update a specific view version.
+   *
+   * @param headers   http headers
+   * @param ui        uri info
+   * @param version   the version
+   *
+   * @return information regarding the updated view
+   */
+  @PUT
+  @Path("{version}")
+  @Produces("text/plain")
+  public Response updateVersions(String body, @Context HttpHeaders headers, @Context UriInfo ui,
+                             @PathParam("version") String version) {
+
+    return handleRequest(headers, body, ui, Request.Type.PUT, createResource(viewName, version));
+  }
+
+  /**
+   * Handles: DELETE /versions/{version}
+   * Delete a specific view version.
+   *
+   * @param headers   http headers
+   * @param ui        uri info
+   * @param version   version id
+   *
+   * @return information regarding the deleted view version
+   */
+  @DELETE
+  @Path("{version}")
+  @Produces("text/plain")
+  public Response deleteVersions(@Context HttpHeaders headers, @Context UriInfo ui,
+                             @PathParam("version") String version) {
+
+    return handleRequest(headers, null, ui, Request.Type.DELETE, createResource(viewName, version));
+  }
+
+  /**
+   * Get the instances sub-resource
+   *
+   * @param version  the version
+   *
+   * @return the instance service
+   */
+  @Path("{version}/instances")
+  public ViewInstanceService getInstanceHandler(@PathParam("version") String version) {
+
+    return new ViewInstanceService(viewName, version);
+  }
+
+
+  // ----- helper methods ----------------------------------------------------
+
+  /**
+   * Create a view resource.
+   *
+   * @param viewName view name
+   *
+   * @return a view resource instance
+   */
+  private ResourceInstance createResource(String viewName, String version) {
+    Map<Resource.Type,String> mapIds = new HashMap<Resource.Type, String>();
+    mapIds.put(Resource.Type.View, viewName);
+    mapIds.put(Resource.Type.ViewVersion, version);
+    return createResource(Resource.Type.ViewVersion, mapIds);
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6d33c324/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 c7e54c6..cdc30d2 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
@@ -63,6 +63,8 @@ public class DefaultProviderModule extends AbstractProviderModule {
         return new TaskAttemptResourceProvider(propertyIds, keyPropertyIds);
       case View:
         return new ViewResourceProvider();
+      case ViewVersion:
+        return new ViewVersionResourceProvider();
       case ViewInstance:
         return new ViewInstanceResourceProvider();
       case Blueprint:

http://git-wip-us.apache.org/repos/asf/ambari/blob/6d33c324/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewInstanceResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewInstanceResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewInstanceResourceProvider.java
index bc93e7b..49298b0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewInstanceResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewInstanceResourceProvider.java
@@ -52,6 +52,7 @@ public class ViewInstanceResourceProvider extends AbstractResourceProvider {
    * View instance property id constants.
    */
   public static final String VIEW_NAME_PROPERTY_ID     = "ViewInstanceInfo/view_name";
+  public static final String VIEW_VERSION_PROPERTY_ID  = "ViewInstanceInfo/version";
   public static final String INSTANCE_NAME_PROPERTY_ID = "ViewInstanceInfo/instance_name";
   public static final String PROPERTIES_PROPERTY_ID    = "ViewInstanceInfo/properties";
   public static final String DATA_PROPERTY_ID          = "ViewInstanceInfo/instance_data";
@@ -69,6 +70,7 @@ public class ViewInstanceResourceProvider extends AbstractResourceProvider {
   private static Map<Resource.Type, String> keyPropertyIds = new HashMap<Resource.Type, String>();
   static {
     keyPropertyIds.put(Resource.Type.View, VIEW_NAME_PROPERTY_ID);
+    keyPropertyIds.put(Resource.Type.ViewVersion, VIEW_VERSION_PROPERTY_ID);
     keyPropertyIds.put(Resource.Type.ViewInstance, INSTANCE_NAME_PROPERTY_ID);
   }
 
@@ -78,6 +80,7 @@ public class ViewInstanceResourceProvider extends AbstractResourceProvider {
   private static Set<String> propertyIds = new HashSet<String>();
   static {
     propertyIds.add(VIEW_NAME_PROPERTY_ID);
+    propertyIds.add(VIEW_VERSION_PROPERTY_ID);
     propertyIds.add(INSTANCE_NAME_PROPERTY_ID);
     propertyIds.add(PROPERTIES_PROPERTY_ID);
     propertyIds.add(DATA_PROPERTY_ID);
@@ -123,15 +126,18 @@ public class ViewInstanceResourceProvider extends AbstractResourceProvider {
 
     for (Map<String, Object> propertyMap : propertyMaps) {
 
-      String viewName = (String) propertyMap.get(VIEW_NAME_PROPERTY_ID);
+      String viewName     = (String) propertyMap.get(VIEW_NAME_PROPERTY_ID);
+      String viewVersion  = (String) propertyMap.get(VIEW_VERSION_PROPERTY_ID);
       String instanceName = (String) propertyMap.get(INSTANCE_NAME_PROPERTY_ID);
 
       for (ViewEntity viewDefinition : viewRegistry.getDefinitions()){
-        if (viewName == null || viewName.equals(viewDefinition.getName())) {
+        if (viewName == null || viewName.equals(viewDefinition.getCommonName())) {
           for (ViewInstanceEntity viewInstanceDefinition : viewRegistry.getInstanceDefinitions(viewDefinition)) {
             if (instanceName == null || instanceName.equals(viewInstanceDefinition.getName())) {
-              Resource resource = toResource(viewInstanceDefinition, requestedIds);
-              resources.add(resource);
+              if (viewVersion == null || viewVersion.equals(viewDefinition.getVersion())) {
+                Resource resource = toResource(viewInstanceDefinition, requestedIds);
+                resources.add(resource);
+              }
             }
           }
         }
@@ -182,12 +188,15 @@ public class ViewInstanceResourceProvider extends AbstractResourceProvider {
 
   // Convert an instance entity to a resource
   private Resource toResource(ViewInstanceEntity viewInstanceEntity, Set<String> requestedIds) {
-    Resource resource = new ResourceImpl(Resource.Type.ViewInstance);
+    Resource   resource   = new ResourceImpl(Resource.Type.ViewInstance);
+    ViewEntity viewEntity = viewInstanceEntity.getViewEntity();
 
-    String viewName = viewInstanceEntity.getViewName();
+    String viewName = viewEntity.getCommonName();
+    String version  = viewEntity.getVersion();
     String name     = viewInstanceEntity.getName();
 
     setResourceProperty(resource, VIEW_NAME_PROPERTY_ID, viewName, requestedIds);
+    setResourceProperty(resource, VIEW_VERSION_PROPERTY_ID, version, requestedIds);
     setResourceProperty(resource, INSTANCE_NAME_PROPERTY_ID, name, requestedIds);
     Map<String, String> properties = new HashMap<String, String>();
 
@@ -204,30 +213,36 @@ public class ViewInstanceResourceProvider extends AbstractResourceProvider {
     setResourceProperty(resource, DATA_PROPERTY_ID,
         applicationData, requestedIds);
     setResourceProperty(resource, CONTEXT_PATH_PROPERTY_ID,
-        ViewInstanceEntity.getContextPath(viewName, name), requestedIds);
+        ViewInstanceEntity.getContextPath(viewName, version, name), requestedIds);
 
     return resource;
   }
 
   // Convert a map of properties to a view instance entity.
   private ViewInstanceEntity toEntity(Map<String, Object> properties) {
-    String name     = (String) properties.get(INSTANCE_NAME_PROPERTY_ID);
+    String name = (String) properties.get(INSTANCE_NAME_PROPERTY_ID);
     if (name == null || name.isEmpty()) {
       throw new IllegalArgumentException("View instance name must be provided");
     }
 
+    String version = (String) properties.get(VIEW_VERSION_PROPERTY_ID);
+    if (version == null || version.isEmpty()) {
+      throw new IllegalArgumentException("View version must be provided");
+    }
+
     String viewName = (String) properties.get(VIEW_NAME_PROPERTY_ID);
     if (viewName == null || viewName.isEmpty()) {
       throw new IllegalArgumentException("View name must be provided");
     }
+    viewName = ViewEntity.getViewName(viewName, version);
 
     ViewInstanceEntity viewInstanceEntity = new ViewInstanceEntity();
     viewInstanceEntity.setName(name);
     viewInstanceEntity.setViewName(viewName);
 
-
     ViewEntity viewEntity = new ViewEntity();
     viewEntity.setName(viewName);
+    viewEntity.setVersion(version);
 
     viewInstanceEntity.setViewEntity(viewEntity);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/6d33c324/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewResourceProvider.java
index a71ab70..b76c8e0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewResourceProvider.java
@@ -44,11 +44,7 @@ public class ViewResourceProvider extends AbstractResourceProvider {
   /**
    * View property id constants.
    */
-  public static final String VIEW_NAME_PROPERTY_ID  = "ViewInfo/view_name";
-  public static final String LABEL_PROPERTY_ID      = "ViewInfo/label";
-  public static final String VERSION_PROPERTY_ID    = "ViewInfo/version";
-  public static final String PARAMETERS_PROPERTY_ID = "ViewInfo/parameters";
-  public static final String ARCHIVE_PROPERTY_ID    = "ViewInfo/archive";
+  public static final String VIEW_NAME_PROPERTY_ID    = "ViewInfo/view_name";
 
 
   /**
@@ -65,10 +61,6 @@ public class ViewResourceProvider extends AbstractResourceProvider {
   private static Set<String> propertyIds = new HashSet<String>();
   static {
     propertyIds.add(VIEW_NAME_PROPERTY_ID);
-    propertyIds.add(LABEL_PROPERTY_ID);
-    propertyIds.add(VERSION_PROPERTY_ID);
-    propertyIds.add(PARAMETERS_PROPERTY_ID);
-    propertyIds.add(ARCHIVE_PROPERTY_ID);
   }
 
   
@@ -106,18 +98,13 @@ public class ViewResourceProvider extends AbstractResourceProvider {
 
     for (Map<String, Object> propertyMap : propertyMaps) {
 
-      String viewName = (String) propertyMap.get(VIEW_NAME_PROPERTY_ID);
+      String viewName    = (String) propertyMap.get(VIEW_NAME_PROPERTY_ID);
 
       for (ViewEntity viewDefinition : viewRegistry.getDefinitions()){
-        if (viewName == null || viewName.equals(viewDefinition.getName())) {
+        if (viewName == null || viewName.equals(viewDefinition.getCommonName())) {
           Resource resource = new ResourceImpl(Resource.Type.View);
 
-          setResourceProperty(resource, VIEW_NAME_PROPERTY_ID, viewDefinition.getName(), requestedIds);
-          setResourceProperty(resource, LABEL_PROPERTY_ID, viewDefinition.getLabel(), requestedIds);
-          setResourceProperty(resource, VERSION_PROPERTY_ID, viewDefinition.getVersion(), requestedIds);
-          setResourceProperty(resource, PARAMETERS_PROPERTY_ID,
-              viewDefinition.getConfiguration().getParameters(), requestedIds);
-          setResourceProperty(resource, ARCHIVE_PROPERTY_ID, viewDefinition.getArchive(), requestedIds);
+          setResourceProperty(resource, VIEW_NAME_PROPERTY_ID, viewDefinition.getCommonName(), requestedIds);
 
           resources.add(resource);
         }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6d33c324/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewVersionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewVersionResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewVersionResourceProvider.java
new file mode 100644
index 0000000..485eb04
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewVersionResourceProvider.java
@@ -0,0 +1,159 @@
+/**
+ * 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.controller.internal;
+
+import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
+import org.apache.ambari.server.controller.spi.NoSuchResourceException;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.RequestStatus;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
+import org.apache.ambari.server.orm.entities.ViewEntity;
+import org.apache.ambari.server.view.ViewRegistry;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Resource provider for view versions.
+ */
+public class ViewVersionResourceProvider extends AbstractResourceProvider {
+
+  /**
+   * View property id constants.
+   */
+  public static final String VIEW_NAME_PROPERTY_ID    = "ViewVersionInfo/view_name";
+  public static final String VIEW_VERSION_PROPERTY_ID = "ViewVersionInfo/version";
+  public static final String LABEL_PROPERTY_ID        = "ViewVersionInfo/label";
+  public static final String VERSION_PROPERTY_ID      = "ViewVersionInfo/version";
+  public static final String PARAMETERS_PROPERTY_ID   = "ViewVersionInfo/parameters";
+  public static final String ARCHIVE_PROPERTY_ID      = "ViewVersionInfo/archive";
+
+  /**
+   * The key property ids for a view resource.
+   */
+  private static Map<Resource.Type, String> keyPropertyIds = new HashMap<Resource.Type, String>();
+  static {
+    keyPropertyIds.put(Resource.Type.View, VIEW_NAME_PROPERTY_ID);
+    keyPropertyIds.put(Resource.Type.ViewVersion, VIEW_VERSION_PROPERTY_ID);
+  }
+
+  /**
+   * The property ids for a view resource.
+   */
+  private static Set<String> propertyIds = new HashSet<String>();
+  static {
+    propertyIds.add(VIEW_NAME_PROPERTY_ID);
+    propertyIds.add(VIEW_VERSION_PROPERTY_ID);
+    propertyIds.add(LABEL_PROPERTY_ID);
+    propertyIds.add(VERSION_PROPERTY_ID);
+    propertyIds.add(PARAMETERS_PROPERTY_ID);
+    propertyIds.add(ARCHIVE_PROPERTY_ID);
+  }
+
+
+  // ----- Constructors ------------------------------------------------------
+
+  /**
+   * Construct a view resource provider.
+   */
+  public ViewVersionResourceProvider() {
+    super(propertyIds, keyPropertyIds);
+  }
+
+
+  // ----- ResourceProvider --------------------------------------------------
+
+  @Override
+  public RequestStatus createResources(Request request)
+      throws SystemException, UnsupportedPropertyException,
+      ResourceAlreadyExistsException, NoSuchParentResourceException {
+    throw new UnsupportedOperationException("Not yet supported.");
+  }
+
+  @Override
+  public Set<Resource> getResources(Request request, Predicate predicate)
+      throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
+    Set<Resource> resources    = new HashSet<Resource>();
+    ViewRegistry  viewRegistry = ViewRegistry.getInstance();
+    Set<String>   requestedIds = getRequestPropertyIds(request, predicate);
+
+    Set<Map<String, Object>> propertyMaps = getPropertyMaps(predicate);
+
+    if (propertyMaps.isEmpty()) {
+      propertyMaps.add(Collections.<String, Object>emptyMap());
+    }
+
+    for (Map<String, Object> propertyMap : propertyMaps) {
+
+      String viewName    = (String) propertyMap.get(VIEW_NAME_PROPERTY_ID);
+      String viewVersion = (String) propertyMap.get(VIEW_VERSION_PROPERTY_ID);
+
+      for (ViewEntity viewDefinition : viewRegistry.getDefinitions()){
+        if (viewName == null || viewName.equals(viewDefinition.getCommonName())) {
+          if (viewVersion == null || viewVersion.equals(viewDefinition.getVersion())) {
+            Resource resource = new ResourceImpl(Resource.Type.ViewVersion);
+
+            setResourceProperty(resource, VIEW_NAME_PROPERTY_ID, viewDefinition.getCommonName(), requestedIds);
+            setResourceProperty(resource, VIEW_VERSION_PROPERTY_ID, viewDefinition.getVersion(), requestedIds);
+            setResourceProperty(resource, LABEL_PROPERTY_ID, viewDefinition.getLabel(), requestedIds);
+            setResourceProperty(resource, VERSION_PROPERTY_ID, viewDefinition.getVersion(), requestedIds);
+            setResourceProperty(resource, PARAMETERS_PROPERTY_ID,
+                viewDefinition.getConfiguration().getParameters(), requestedIds);
+            setResourceProperty(resource, ARCHIVE_PROPERTY_ID, viewDefinition.getArchive(), requestedIds);
+
+            resources.add(resource);
+          }
+        }
+      }
+    }
+    return resources;
+  }
+
+  @Override
+  public RequestStatus updateResources(Request request, Predicate predicate)
+      throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
+    throw new UnsupportedOperationException("Not yet supported.");
+  }
+
+  @Override
+  public RequestStatus deleteResources(Predicate predicate)
+      throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
+    throw new UnsupportedOperationException("Not yet supported.");
+  }
+
+  @Override
+  public Map<Resource.Type, String> getKeyPropertyIds() {
+    return keyPropertyIds;
+  }
+
+
+  // ----- AbstractResourceProvider ------------------------------------------
+
+  @Override
+  protected Set<String> getPKPropertyIds() {
+    return new HashSet<String>(keyPropertyIds.values());
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6d33c324/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
index d47f003..13e7c77 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
@@ -104,6 +104,7 @@ public interface Resource {
     RootServiceComponent,
     RootServiceHostComponent,
     View,
+    ViewVersion,
     ViewInstance,
     Blueprint,
     HostComponentProcess;
@@ -171,6 +172,7 @@ public interface Resource {
     public static final Type RootServiceComponent = InternalType.RootServiceComponent.getType();
     public static final Type RootServiceHostComponent = InternalType.RootServiceHostComponent.getType();
     public static final Type View = InternalType.View.getType();
+    public static final Type ViewVersion = InternalType.ViewVersion.getType();
     public static final Type ViewInstance = InternalType.ViewInstance.getType();
     public static final Type Blueprint = InternalType.Blueprint.getType();
     public static final Type HostComponentProcess = InternalType.HostComponentProcess.getType();

http://git-wip-us.apache.org/repos/asf/ambari/blob/6d33c324/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ViewEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ViewEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ViewEntity.java
index a133ad2..84724c8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ViewEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ViewEntity.java
@@ -140,6 +140,12 @@ public class ViewEntity {
   @Transient
   private final Map<Resource.Type, ResourceConfig> resourceConfigurations = new HashMap<Resource.Type, ResourceConfig>();
 
+  /**
+   * The name of the view shared across versions.
+   */
+  @Transient
+  private String commonName = null;
+
 
   // ----- Constructors ------------------------------------------------------
 
@@ -169,9 +175,11 @@ public class ViewEntity {
     this.classLoader         = classLoader;
     this.archive             = archivePath;
 
-    this.name    = configuration.getName();
+    String version = configuration.getVersion();
+
+    this.name    = getViewName(configuration.getName(), version);
     this.label   = configuration.getLabel();
-    this.version = configuration.getVersion();
+    this.version = version;
 
     this.externalResourceType =
         new Resource.Type(getQualifiedResourceTypeName(ResourceConfig.EXTERNAL_RESOURCE_PLURAL_NAME));
@@ -199,6 +207,20 @@ public class ViewEntity {
   }
 
   /**
+   * Get the common name of the view.
+   * This name is shared across versions of the view.
+   *
+   * @return the common name
+   */
+  public synchronized String getCommonName() {
+    if (commonName == null) {
+      // Strip version from the internal name
+      commonName = name.replaceAll("\\{(.+)\\}", "");
+    }
+    return commonName;
+  }
+
+  /**
    * Get the view label (display name).
    *
    * @return the view label
@@ -479,4 +501,19 @@ public class ViewEntity {
   public ViewConfig getConfiguration() {
     return configuration;
   }
+
+
+  // ----- helper methods ----------------------------------------------------
+
+  /**
+   * Get the internal view name from the given common name and version.
+   *
+   * @param name     the view common name
+   * @param version  the version
+   *
+   * @return the view name
+   */
+  public static String getViewName(String name, String version) {
+    return name + "{" + version + "}";
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6d33c324/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ViewInstanceEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ViewInstanceEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ViewInstanceEntity.java
index c6557f2..7b29098 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ViewInstanceEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ViewInstanceEntity.java
@@ -408,7 +408,7 @@ public class ViewInstanceEntity {
    * @return the resource provider
    */
   public ResourceProvider getResourceProvider(String type) {
-    String typeName = view.getName() + "/" + type;
+    String typeName = view.getQualifiedResourceTypeName(type);
     return resourceProviders.get(Resource.Type.valueOf(typeName));
   }
 
@@ -439,7 +439,7 @@ public class ViewInstanceEntity {
    * @return the context path
    */
   public String getContextPath() {
-    return getContextPath(view.getName(), getName());
+    return getContextPath(view.getCommonName(), view.getVersion(), getName());
   }
 
   /**
@@ -450,7 +450,7 @@ public class ViewInstanceEntity {
    *
    * @return the context path
    */
-  public static String getContextPath(String viewName, String viewInstanceName) {
-    return VIEWS_CONTEXT_PATH_PREFIX + viewName + "/" + viewInstanceName;
+  public static String getContextPath(String viewName, String version, String viewInstanceName) {
+    return VIEWS_CONTEXT_PATH_PREFIX + viewName + "/" + version + "/" + viewInstanceName;
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6d33c324/ambari-server/src/main/java/org/apache/ambari/server/view/ViewContextImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/view/ViewContextImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/view/ViewContextImpl.java
index 862e2e1..1f936e7 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/view/ViewContextImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/view/ViewContextImpl.java
@@ -85,7 +85,7 @@ public class ViewContextImpl implements ViewContext {
 
   @Override
   public String getViewName() {
-    return viewInstanceEntity.getViewName();
+    return viewInstanceEntity.getViewEntity().getCommonName();
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/ambari/blob/6d33c324/ambari-server/src/main/java/org/apache/ambari/server/view/ViewExternalSubResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/view/ViewExternalSubResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/view/ViewExternalSubResourceProvider.java
index e0af2ef..f669e49 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/view/ViewExternalSubResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/view/ViewExternalSubResourceProvider.java
@@ -48,6 +48,7 @@ public class ViewExternalSubResourceProvider extends AbstractResourceProvider {
    * View external sub resource property id constants.
    */
   private static final String VIEW_NAME_PROPERTY_ID     = "view_name";
+  private static final String VIEW_VERSION_PROPERTY_ID  = "version";
   private static final String INSTANCE_NAME_PROPERTY_ID = "instance_name";
   private static final String RESOURCE_NAME_PROPERTY_ID = "name";
 
@@ -125,7 +126,8 @@ public class ViewExternalSubResourceProvider extends AbstractResourceProvider {
     for (ViewInstanceEntity viewInstanceDefinition : instanceDefinitions) {
       for (String resourceName : resourceNames) {
         ResourceImpl resource = new ResourceImpl(type);
-        resource.setProperty(VIEW_NAME_PROPERTY_ID, viewDefinition.getName());
+        resource.setProperty(VIEW_NAME_PROPERTY_ID, viewDefinition.getCommonName());
+        resource.setProperty(VIEW_VERSION_PROPERTY_ID, viewDefinition.getVersion());
         resource.setProperty(INSTANCE_NAME_PROPERTY_ID, viewInstanceDefinition.getName());
         resource.setProperty("name", resourceName);
         resourceSet.add(resource);
@@ -177,6 +179,7 @@ public class ViewExternalSubResourceProvider extends AbstractResourceProvider {
     Map<Resource.Type, String> keyPropertyIds = new HashMap<Resource.Type, String>();
 
     keyPropertyIds.put(Resource.Type.View, VIEW_NAME_PROPERTY_ID);
+    keyPropertyIds.put(Resource.Type.ViewVersion, VIEW_VERSION_PROPERTY_ID);
     keyPropertyIds.put(Resource.Type.ViewInstance, INSTANCE_NAME_PROPERTY_ID);
     keyPropertyIds.put(type, RESOURCE_NAME_PROPERTY_ID);
 
@@ -188,6 +191,7 @@ public class ViewExternalSubResourceProvider extends AbstractResourceProvider {
     Set<String> propertyIds = new HashSet<String>();
     propertyIds.add(INSTANCE_NAME_PROPERTY_ID);
     propertyIds.add(VIEW_NAME_PROPERTY_ID);
+    propertyIds.add(VIEW_VERSION_PROPERTY_ID);
     propertyIds.add(RESOURCE_NAME_PROPERTY_ID);
 
     return propertyIds;

http://git-wip-us.apache.org/repos/asf/ambari/blob/6d33c324/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java b/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
index a45cb39..532259b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
@@ -147,11 +147,12 @@ public class ViewRegistry {
    * Get a view definition for the given name.
    *
    * @param viewName  the view name
+   * @param version   the version
    *
    * @return the view definition for the given name
    */
-  public ViewEntity getDefinition(String viewName) {
-    return viewDefinitions.get(viewName);
+  public ViewEntity getDefinition(String viewName, String version) {
+    return getDefinition(ViewEntity.getViewName(viewName, version));
   }
 
   /**
@@ -184,13 +185,14 @@ public class ViewRegistry {
    * Get the instance definition for the given view nam,e and instance name.
    *
    * @param viewName      the view name
+   * @param version       the version
    * @param instanceName  the instance name
    *
    * @return the view instance definition for the given view and instance name
    */
-  public ViewInstanceEntity getInstanceDefinition(String viewName, String instanceName) {
+  public ViewInstanceEntity getInstanceDefinition(String viewName, String version, String instanceName) {
     Map<String, ViewInstanceEntity> viewInstanceDefinitionMap =
-        viewInstanceDefinitions.get(getDefinition(viewName));
+        viewInstanceDefinitions.get(getDefinition(viewName, version));
 
     return viewInstanceDefinitionMap == null ? null : viewInstanceDefinitionMap.get(instanceName);
   }
@@ -236,12 +238,17 @@ public class ViewRegistry {
    * Get the sub-resource definitions for the given view name.
    *
    * @param viewName  the instance name
+   * @param version   the version
    *
    * @return the set of sub-resource definitions
    */
-  public synchronized Set<SubResourceDefinition> getSubResourceDefinitions(String viewName) {
+  public synchronized Set<SubResourceDefinition> getSubResourceDefinitions(
+      String viewName, String version) {
+
+    viewName = ViewEntity.getViewName(viewName, version);
 
-    Set<SubResourceDefinition> subResourceDefinitions = subResourceDefinitionsMap.get(viewName);
+    Set<SubResourceDefinition> subResourceDefinitions =
+        subResourceDefinitionsMap.get(viewName);
 
     if (subResourceDefinitions == null) {
       subResourceDefinitions = new HashSet<SubResourceDefinition>();
@@ -310,15 +317,17 @@ public class ViewRegistry {
    * @param instanceEntity  the view instance entity
    */
   public void installViewInstance(ViewInstanceEntity instanceEntity){
-    String viewName       = instanceEntity.getViewName();
-    ViewEntity viewEntity = getDefinition(viewName);
+    ViewEntity viewEntity = getDefinition(instanceEntity.getViewName());
 
     if (viewEntity != null) {
       String instanceName = instanceEntity.getName();
+      String viewName     = viewEntity.getCommonName();
+      String version      = viewEntity.getVersion();
 
-      if (getInstanceDefinition(viewName, instanceName) == null) {
+      if (getInstanceDefinition(viewName, version, instanceName) == null) {
         if (LOG.isDebugEnabled()) {
-          LOG.debug("Creating view instance " + viewName + "/" + instanceName);
+          LOG.debug("Creating view instance " + viewName + "/" +
+              version + "/" + instanceName);
         }
         instanceDAO.create(instanceEntity);
         try {
@@ -336,15 +345,19 @@ public class ViewRegistry {
    * @param instanceEntity  the view instance entity
    */
   public void updateViewInstance(ViewInstanceEntity instanceEntity) {
-    String       viewName   = instanceEntity.getViewName();
-    ViewEntity   viewEntity = getDefinition(viewName);
+    ViewEntity viewEntity = getDefinition(instanceEntity.getViewName());
 
     if (viewEntity != null) {
       String instanceName = instanceEntity.getName();
-      ViewInstanceEntity entity = getInstanceDefinition(viewName, instanceName);
+      String viewName     = viewEntity.getCommonName();
+      String version      = viewEntity.getVersion();
+
+      ViewInstanceEntity entity = getInstanceDefinition(viewName, version, instanceName);
+
       if (entity != null) {
         if (LOG.isDebugEnabled()) {
-          LOG.debug("Updating view instance " + viewName + "/" + instanceName);
+          LOG.debug("Updating view instance " + viewName + "/" +
+              version + "/" + instanceName);
         }
 
         entity.setProperties(instanceEntity.getProperties());
@@ -376,16 +389,18 @@ public class ViewRegistry {
    * @param instanceEntity  the view instance entity
    */
   public void uninstallViewInstance(ViewInstanceEntity instanceEntity) {
-
-    String       viewName   = instanceEntity.getViewName();
-    ViewEntity   viewEntity = getDefinition(viewName);
+    ViewEntity viewEntity = getDefinition(instanceEntity.getViewName());
 
     if (viewEntity != null) {
       String instanceName = instanceEntity.getName();
-      if (getInstanceDefinition(viewName, instanceName) != null) {
+      String viewName     = viewEntity.getCommonName();
+      String version      = viewEntity.getVersion();
+
+      if (getInstanceDefinition(viewName, version, instanceName) != null) {
 
         if (LOG.isDebugEnabled()) {
-          LOG.debug("Deleting view instance " + viewName + "/" + instanceName);
+          LOG.debug("Deleting view instance " + viewName + "/" +
+              version + "/" +instanceName);
         }
         instanceDAO.remove(instanceEntity);
         viewEntity.removeInstanceDefinition(instanceName);
@@ -422,6 +437,11 @@ public class ViewRegistry {
     subResourceDefinitionsMap.clear();
   }
 
+  // get a view entity for the given internal view name
+  private ViewEntity getDefinition(String viewName) {
+    return viewDefinitions.get(viewName);
+  }
+
   // install a new view definition
   private ViewEntity installView(ViewConfig viewConfig, Configuration ambariConfig,
                                             ClassLoader cl, String archivePath)
@@ -497,6 +517,7 @@ public class ViewRegistry {
   private void installViewInstance(ViewEntity viewDefinition,
                                    ViewInstanceEntity viewInstanceDefinition)
       throws ClassNotFoundException {
+    viewInstanceDefinition.setViewEntity(viewDefinition);
 
     ViewContext viewInstanceContext = new ViewContextImpl(viewInstanceDefinition, this);
 
@@ -511,8 +532,7 @@ public class ViewRegistry {
       Resource.Type  type           = resourceDefinition.getType();
       ResourceConfig resourceConfig = resourceDefinition.getResourceConfiguration();
 
-      ViewResourceHandler viewResourceService =
-          new ViewSubResourceService(type, viewDefinition.getName(), viewInstanceDefinition.getName());
+      ViewResourceHandler viewResourceService = new ViewSubResourceService(type, viewInstanceDefinition);
 
       ClassLoader cl = viewDefinition.getClassLoader();
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/6d33c324/ambari-server/src/main/java/org/apache/ambari/server/view/ViewSubResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/view/ViewSubResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/view/ViewSubResourceProvider.java
index 08c0c1d..e9d2a4c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/view/ViewSubResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/view/ViewSubResourceProvider.java
@@ -54,7 +54,8 @@ import java.util.Set;
  */
 public class ViewSubResourceProvider extends AbstractResourceProvider {
 
-  private static final String VIEW_NAME_PROPERTY_ID = "view_name";
+  private static final String VIEW_NAME_PROPERTY_ID     = "view_name";
+  private static final String VIEW_VERSION_PROPERTY_ID  = "version";
   private static final String INSTANCE_NAME_PROPERTY_ID = "instance_name";
 
   private final ViewEntity viewDefinition;
@@ -139,7 +140,8 @@ public class ViewSubResourceProvider extends AbstractResourceProvider {
             String resourceId = (String) propertyMap.get(pkField);
             if (resourceId != null) {
               Object bean = getResourceProvider(instanceName).getResource(resourceId, requestedIds);
-              return Collections.singleton(getResource(bean, viewDefinition.getName(), instanceName, requestedIds));
+              return Collections.singleton(getResource(bean, viewDefinition.getCommonName(),
+                  viewDefinition.getVersion(), instanceName, requestedIds));
             }
           }
           if (instanceName == null) {
@@ -161,7 +163,8 @@ public class ViewSubResourceProvider extends AbstractResourceProvider {
         Set<?> beans = instanceDefinition.getResourceProvider(type).getResources(readRequest);
 
         for (Object bean : beans) {
-          Resource resource = getResource(bean, viewDefinition.getName(), instanceDefinition.getName(), requestedIds);
+          Resource resource = getResource(bean, viewDefinition.getCommonName(),
+              viewDefinition.getVersion(), instanceDefinition.getName(), requestedIds);
           if (predicate.evaluate(resource)) {
             results.add(resource);
           }
@@ -235,12 +238,14 @@ public class ViewSubResourceProvider extends AbstractResourceProvider {
   // ----- helper methods ----------------------------------------------------
 
   // get a Resource from the bean
-  private Resource getResource(Object bean, String viewName, String instanceName, Set<String> requestedIds)
+  private Resource getResource(Object bean, String viewName, String viewVersion,
+                               String instanceName, Set<String> requestedIds)
       throws InvocationTargetException, IllegalAccessException {
 
     Resource resource = new ResourceImpl(type);
 
     resource.setProperty(VIEW_NAME_PROPERTY_ID, viewName);
+    resource.setProperty(VIEW_VERSION_PROPERTY_ID, viewVersion);
     resource.setProperty(INSTANCE_NAME_PROPERTY_ID, instanceName);
 
     for (Map.Entry<String, PropertyDescriptor> entry : descriptorMap.entrySet()) {
@@ -267,6 +272,7 @@ public class ViewSubResourceProvider extends AbstractResourceProvider {
     Set<String> propertyIds = new HashSet<String>(getDescriptorMap(clazz).keySet());
     propertyIds.add(INSTANCE_NAME_PROPERTY_ID);
     propertyIds.add(VIEW_NAME_PROPERTY_ID);
+    propertyIds.add(VIEW_VERSION_PROPERTY_ID);
 
     return propertyIds;
   }
@@ -290,6 +296,7 @@ public class ViewSubResourceProvider extends AbstractResourceProvider {
     Map<Resource.Type, String> keyPropertyIds = new HashMap<Resource.Type, String>();
 
     keyPropertyIds.put(Resource.Type.View, VIEW_NAME_PROPERTY_ID);
+    keyPropertyIds.put(Resource.Type.ViewVersion, VIEW_VERSION_PROPERTY_ID);
     keyPropertyIds.put(Resource.Type.ViewInstance, INSTANCE_NAME_PROPERTY_ID);
     keyPropertyIds.put(type, pkField);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/6d33c324/ambari-server/src/test/java/org/apache/ambari/server/api/resources/ViewResourceDefinitionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/resources/ViewResourceDefinitionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/resources/ViewResourceDefinitionTest.java
index 4da48d6..c848bfa 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/resources/ViewResourceDefinitionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/resources/ViewResourceDefinitionTest.java
@@ -46,6 +46,6 @@ public class ViewResourceDefinitionTest {
 
     Assert.assertEquals(1, subResourceDefinitions.size());
 
-    Assert.assertEquals("ViewInstance", subResourceDefinitions.iterator().next().getType().name());
+    Assert.assertEquals("ViewVersion", subResourceDefinitions.iterator().next().getType().name());
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6d33c324/ambari-server/src/test/java/org/apache/ambari/server/api/resources/ViewVersionResourceDefinitionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/resources/ViewVersionResourceDefinitionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/resources/ViewVersionResourceDefinitionTest.java
new file mode 100644
index 0000000..32c13b3
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/resources/ViewVersionResourceDefinitionTest.java
@@ -0,0 +1,51 @@
+/**
+ * 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.junit.Assert;
+import org.junit.Test;
+
+import java.util.Set;
+
+/**
+ * ViewVersionResourceDefinition tests.
+ */
+public class ViewVersionResourceDefinitionTest {
+  @Test
+  public void testGetPluralName() throws Exception {
+    ViewVersionResourceDefinition viewVersionResourceDefinition = new ViewVersionResourceDefinition();
+    Assert.assertEquals("versions", viewVersionResourceDefinition.getPluralName());
+  }
+
+  @Test
+  public void testGetSingularName() throws Exception {
+    ViewVersionResourceDefinition viewVersionResourceDefinition = new ViewVersionResourceDefinition();
+    Assert.assertEquals("version", viewVersionResourceDefinition.getSingularName());
+  }
+
+  @Test
+  public void testGetSubResourceDefinitions() throws Exception {
+    ViewVersionResourceDefinition viewVersionResourceDefinition = new ViewVersionResourceDefinition();
+    Set<SubResourceDefinition> subResourceDefinitions = viewVersionResourceDefinition.getSubResourceDefinitions ();
+
+    Assert.assertEquals(1, subResourceDefinitions.size());
+
+    Assert.assertEquals("ViewInstance", subResourceDefinitions.iterator().next().getType().name());
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6d33c324/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/ViewEntityTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/ViewEntityTest.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/ViewEntityTest.java
index b2dac99..1618b64 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/ViewEntityTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/ViewEntityTest.java
@@ -61,7 +61,13 @@ public class ViewEntityTest {
   @Test
   public void testGetName() throws Exception {
     ViewEntity viewDefinition = getViewEntity();
-    Assert.assertEquals("MY_VIEW", viewDefinition.getName());
+    Assert.assertEquals("MY_VIEW{1.0.0}", viewDefinition.getName());
+  }
+
+  @Test
+  public void testGetCommonName() throws Exception {
+    ViewEntity viewDefinition = getViewEntity();
+    Assert.assertEquals("MY_VIEW", viewDefinition.getCommonName());
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/ambari/blob/6d33c324/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/ViewInstanceEntityTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/ViewInstanceEntityTest.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/ViewInstanceEntityTest.java
index 6029ee5..32b7993 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/ViewInstanceEntityTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/ViewInstanceEntityTest.java
@@ -97,7 +97,7 @@ public class ViewInstanceEntityTest {
     ViewInstanceEntity viewInstanceDefinition = getViewInstanceEntity();
 
     ResourceProvider provider = createNiceMock(ResourceProvider.class);
-    Resource.Type type = new Resource.Type("MY_VIEW/myType");
+    Resource.Type type = new Resource.Type("MY_VIEW{1.0.0}/myType");
 
     viewInstanceDefinition.addResourceProvider(type, provider);
 
@@ -109,7 +109,7 @@ public class ViewInstanceEntityTest {
   public void testContextPath() throws Exception {
     ViewInstanceEntity viewInstanceDefinition = getViewInstanceEntity();
 
-    Assert.assertEquals(ViewInstanceEntity.VIEWS_CONTEXT_PATH_PREFIX + "MY_VIEW/INSTANCE1",
+    Assert.assertEquals(ViewInstanceEntity.VIEWS_CONTEXT_PATH_PREFIX + "MY_VIEW/1.0.0/INSTANCE1",
         viewInstanceDefinition.getContextPath());
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/6d33c324/ambari-server/src/test/java/org/apache/ambari/server/view/ViewContextImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/view/ViewContextImplTest.java b/ambari-server/src/test/java/org/apache/ambari/server/view/ViewContextImplTest.java
index 0003ac8..92608c6 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/view/ViewContextImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/view/ViewContextImplTest.java
@@ -97,7 +97,7 @@ public class ViewContextImplTest {
     ViewRegistry viewRegistry = createNiceMock(ViewRegistry.class);
 
     ResourceProvider provider = createNiceMock(ResourceProvider.class);
-    Resource.Type type = new Resource.Type("MY_VIEW/myType");
+    Resource.Type type = new Resource.Type("MY_VIEW{1.0.0}/myType");
 
     viewInstanceDefinition.addResourceProvider(type, provider);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/6d33c324/ambari-server/src/test/java/org/apache/ambari/server/view/ViewRegistryTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/view/ViewRegistryTest.java b/ambari-server/src/test/java/org/apache/ambari/server/view/ViewRegistryTest.java
index daedbca..37862f0 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/view/ViewRegistryTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/view/ViewRegistryTest.java
@@ -57,7 +57,7 @@ public class ViewRegistryTest {
 
     registry.addDefinition(viewDefinition);
 
-    Assert.assertEquals(viewDefinition, registry.getDefinition("MY_VIEW"));
+    Assert.assertEquals(viewDefinition, registry.getDefinition("MY_VIEW", "1.0.0"));
 
     Collection<ViewEntity> viewDefinitions = registry.getDefinitions();
 
@@ -77,7 +77,7 @@ public class ViewRegistryTest {
 
     registry.addInstanceDefinition(viewDefinition, viewInstanceDefinition);
 
-    Assert.assertEquals(viewInstanceDefinition, registry.getInstanceDefinition("MY_VIEW", "INSTANCE1"));
+    Assert.assertEquals(viewInstanceDefinition, registry.getInstanceDefinition("MY_VIEW", "1.0.0", "INSTANCE1"));
 
     Collection<ViewInstanceEntity> viewInstanceDefinitions = registry.getInstanceDefinitions(viewDefinition);
 
@@ -99,7 +99,7 @@ public class ViewRegistryTest {
 
     viewDefinition.addResourceConfiguration(type1, config);
     registry.addDefinition(viewDefinition);
-    Set<SubResourceDefinition> subResourceDefinitions = registry.getSubResourceDefinitions("MY_VIEW");
+    Set<SubResourceDefinition> subResourceDefinitions = registry.getSubResourceDefinitions("MY_VIEW", "1.0.0");
 
     Assert.assertEquals(1, subResourceDefinitions.size());
     Assert.assertEquals("myType", subResourceDefinitions.iterator().next().getType().name());

http://git-wip-us.apache.org/repos/asf/ambari/blob/6d33c324/ambari-server/src/test/java/org/apache/ambari/server/view/ViewSubResourceDefinitionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/view/ViewSubResourceDefinitionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/view/ViewSubResourceDefinitionTest.java
index befb7fe..b0de66f 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/view/ViewSubResourceDefinitionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/view/ViewSubResourceDefinitionTest.java
@@ -51,14 +51,14 @@ public class ViewSubResourceDefinitionTest {
   public void testGetSubResourceDefinitions() throws Exception {
     ViewSubResourceDefinition viewSubResourceDefinition = getViewSubResourceDefinition();
 
-    new Resource.Type("MY_VIEW/resource");
-    new Resource.Type("MY_VIEW/subresource");
+    new Resource.Type("MY_VIEW{1.0.0}/resource");
+    new Resource.Type("MY_VIEW{1.0.0}/subresource");
 
     Set<SubResourceDefinition> subResourceDefinitions = viewSubResourceDefinition.getSubResourceDefinitions ();
 
     Assert.assertEquals(1, subResourceDefinitions.size());
 
-    Assert.assertEquals("MY_VIEW/subresource", subResourceDefinitions.iterator().next().getType().name());
+    Assert.assertEquals("MY_VIEW{1.0.0}/subresource", subResourceDefinitions.iterator().next().getType().name());
   }
 
   public static ViewSubResourceDefinition getViewSubResourceDefinition() throws Exception {


Mime
View raw message