You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by tb...@apache.org on 2014/01/28 11:12:06 UTC
[2/2] git commit: AMBARI-4406 - Create module for Ambari View
interfaces
AMBARI-4406 - Create module for Ambari View interfaces
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/89af4f19
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/89af4f19
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/89af4f19
Branch: refs/heads/trunk
Commit: 89af4f19005c2a87561e2279fed8745a6f8a9645
Parents: 682ef99
Author: tbeerbower <tb...@hortonworks.com>
Authored: Thu Jan 23 21:04:52 2014 -0500
Committer: tbeerbower <tb...@hortonworks.com>
Committed: Tue Jan 28 05:06:59 2014 -0500
----------------------------------------------------------------------
ambari-server/pom.xml | 5 +
ambari-views/pom.xml | 130 +++++++++++++++++++
ambari-views/src/main/assemblies/views.xml | 22 ++++
.../ambari/view/NoSuchResourceException.java | 50 +++++++
.../org/apache/ambari/view/ReadRequest.java | 39 ++++++
.../view/ResourceAlreadyExistsException.java | 48 +++++++
.../apache/ambari/view/ResourceProvider.java | 103 +++++++++++++++
.../org/apache/ambari/view/SystemException.java | 33 +++++
.../view/UnsupportedPropertyException.java | 70 ++++++++++
.../org/apache/ambari/view/ViewContext.java | 65 ++++++++++
.../apache/ambari/view/ViewResourceHandler.java | 41 ++++++
.../view/NoSuchResourceExceptionTest.java | 32 +++++
.../ResourceAlreadyExistsExceptionTest.java | 33 +++++
.../view/UnsupportedPropertyExceptionTest.java | 47 +++++++
pom.xml | 1 +
15 files changed, 719 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/89af4f19/ambari-server/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-server/pom.xml b/ambari-server/pom.xml
index f7ca909..1d6b427 100644
--- a/ambari-server/pom.xml
+++ b/ambari-server/pom.xml
@@ -583,6 +583,11 @@
</profiles>
<dependencies>
<dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>ambari-views</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/ambari/blob/89af4f19/ambari-views/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-views/pom.xml b/ambari-views/pom.xml
new file mode 100644
index 0000000..5adc775
--- /dev/null
+++ b/ambari-views/pom.xml
@@ -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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <parent>
+ <groupId>org.apache.ambari</groupId>
+ <artifactId>ambari-project</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ <relativePath>../ambari-project</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.ambari</groupId>
+ <artifactId>ambari-views</artifactId>
+ <packaging>jar</packaging>
+ <name>Ambari Views</name>
+ <version>1.3.0-SNAPSHOT</version>
+ <description>Ambari View interfaces.</description>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>3.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-core</artifactId>
+ <version>1.8</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.8</version>
+ <executions>
+ <execution>
+ <id>parse-version</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>parse-version</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>regex-property</id>
+ <goals>
+ <goal>regex-property</goal>
+ </goals>
+ <configuration>
+ <name>ambariVersion</name>
+ <value>${project.version}</value>
+ <regex>-SNAPSHOT</regex>
+ <failIfNoMatch>false</failIfNoMatch>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.0</version>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <tarLongFileMode>gnu</tarLongFileMode>
+ <descriptors>
+ <descriptor>src/main/assemblies/views.xml</descriptor>
+ </descriptors>
+ </configuration>
+ <executions>
+ <execution>
+ <id>build-tarball</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>**/*.json</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>rpm-maven-plugin</artifactId>
+ <version>2.0.1</version>
+ <executions>
+ <execution>
+ <phase>none</phase>
+ <goals>
+ <goal>rpm</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
+
+
http://git-wip-us.apache.org/repos/asf/ambari/blob/89af4f19/ambari-views/src/main/assemblies/views.xml
----------------------------------------------------------------------
diff --git a/ambari-views/src/main/assemblies/views.xml b/ambari-views/src/main/assemblies/views.xml
new file mode 100644
index 0000000..7b895df
--- /dev/null
+++ b/ambari-views/src/main/assemblies/views.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<assembly>
+</assembly>
+
+
http://git-wip-us.apache.org/repos/asf/ambari/blob/89af4f19/ambari-views/src/main/java/org/apache/ambari/view/NoSuchResourceException.java
----------------------------------------------------------------------
diff --git a/ambari-views/src/main/java/org/apache/ambari/view/NoSuchResourceException.java b/ambari-views/src/main/java/org/apache/ambari/view/NoSuchResourceException.java
new file mode 100644
index 0000000..e1ab8ab
--- /dev/null
+++ b/ambari-views/src/main/java/org/apache/ambari/view/NoSuchResourceException.java
@@ -0,0 +1,50 @@
+/**
+ * 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.view;
+
+/**
+ * Indicates that a resource doesn't exist.
+ */
+public class NoSuchResourceException extends Exception {
+
+ /**
+ * The resource id.
+ */
+ private final String resourceId;
+
+ /**
+ * Constructor.
+ *
+ * @param resourceId the resource id
+ */
+ public NoSuchResourceException(String resourceId) {
+ super("The resource " + resourceId +
+ " specified in the request does not exist.");
+ this.resourceId = resourceId;
+ }
+
+ /**
+ * Get the id of the non-existent resource.
+ *
+ * @return the resource id
+ */
+ public String getResourceId() {
+ return resourceId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/89af4f19/ambari-views/src/main/java/org/apache/ambari/view/ReadRequest.java
----------------------------------------------------------------------
diff --git a/ambari-views/src/main/java/org/apache/ambari/view/ReadRequest.java b/ambari-views/src/main/java/org/apache/ambari/view/ReadRequest.java
new file mode 100644
index 0000000..ddadd42
--- /dev/null
+++ b/ambari-views/src/main/java/org/apache/ambari/view/ReadRequest.java
@@ -0,0 +1,39 @@
+/**
+ * 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.view;
+
+import java.util.Set;
+
+/**
+ * Information passed to a read request.
+ */
+public interface ReadRequest {
+ /**
+ * Get the requested property ids.
+ *
+ * @return the property ids
+ */
+ public Set<String> getPropertyIds();
+
+ /**
+ * Get the predicate.
+ *
+ * @return the predicate; may be null
+ */
+ public String getPredicate();
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/89af4f19/ambari-views/src/main/java/org/apache/ambari/view/ResourceAlreadyExistsException.java
----------------------------------------------------------------------
diff --git a/ambari-views/src/main/java/org/apache/ambari/view/ResourceAlreadyExistsException.java b/ambari-views/src/main/java/org/apache/ambari/view/ResourceAlreadyExistsException.java
new file mode 100644
index 0000000..1f53248
--- /dev/null
+++ b/ambari-views/src/main/java/org/apache/ambari/view/ResourceAlreadyExistsException.java
@@ -0,0 +1,48 @@
+/**
+ * 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.view;
+
+/**
+ * Indicates that a resource already exists.
+ */
+public class ResourceAlreadyExistsException extends Exception{
+ /**
+ * The resource id.
+ */
+ private final String resourceId;
+
+ /**
+ * Constructor.
+ *
+ * @param resourceId the resource id
+ */
+ public ResourceAlreadyExistsException(String resourceId) {
+ super("The resource " + resourceId +
+ " specified in the request already exists.");
+ this.resourceId = resourceId;
+ }
+
+ /**
+ * Get the id of the non-existent resource.
+ *
+ * @return the resource id
+ */
+ public String getResourceId() {
+ return resourceId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/89af4f19/ambari-views/src/main/java/org/apache/ambari/view/ResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-views/src/main/java/org/apache/ambari/view/ResourceProvider.java b/ambari-views/src/main/java/org/apache/ambari/view/ResourceProvider.java
new file mode 100644
index 0000000..5ce989f
--- /dev/null
+++ b/ambari-views/src/main/java/org/apache/ambari/view/ResourceProvider.java
@@ -0,0 +1,103 @@
+/**
+ * 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.view;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Class used to access view sub-resources.
+ *
+ * @param <T> the type of the resource class provided by this ResourceProvider object.
+ */
+public interface ResourceProvider<T> {
+ /**
+ * Get a single resource from the given id. The resource should be
+ * populated with the given properties.
+ *
+ * @param resourceId the id of the requested resource
+ * @param properties the set of requested property ids
+ *
+ * @throws SystemException an internal system exception occurred
+ * @throws NoSuchResourceException a requested resource doesn't exist
+ * @throws UnsupportedPropertyException the request contains unsupported property ids
+ *
+ * @return the resource
+ */
+ public T getResource(String resourceId, Set<String> properties) throws
+ SystemException, NoSuchResourceException, UnsupportedPropertyException;
+
+ /**
+ * Get all of the resources. The resources should be populated with
+ * the given resources.
+ *
+ * @param request the read request
+ *
+ * @throws SystemException an internal system exception occurred
+ * @throws NoSuchResourceException a requested resource doesn't exist
+ * @throws UnsupportedPropertyException the request contains unsupported property ids
+ *
+ * @return a set containing all the resources
+ */
+ public Set<T> getResources(ReadRequest request) throws
+ SystemException, NoSuchResourceException, UnsupportedPropertyException;
+
+ /**
+ * Create a resource with the given id and given property values.
+ *
+ * @param resourceId the id of the requested resource
+ * @param properties the map of property values to set on the new resource
+ *
+ * @throws SystemException an internal system exception occurred
+ * @throws ResourceAlreadyExistsException attempted to create a resource which already exists
+ * @throws NoSuchResourceException a parent resource doesn't exist
+ * @throws UnsupportedPropertyException the request contains unsupported property ids
+ */
+ public void createResource(String resourceId, Map<String, Object> properties) throws
+ SystemException, ResourceAlreadyExistsException, NoSuchResourceException, UnsupportedPropertyException;
+
+ /**
+ * Update the resource identified by given resource id with the given property values.
+ *
+ * @param resourceId the id of the requested resource
+ * @param properties the map of property values to update on the resource
+ *
+ * @throws SystemException an internal system exception occurred
+ * @throws NoSuchResourceException a requested resource doesn't exist
+ * @throws UnsupportedPropertyException the request contains unsupported property ids
+ *
+ * @return true if the resource was successfully updated
+ */
+ public boolean updateResource(String resourceId, Map<String, Object> properties) throws
+ SystemException, NoSuchResourceException, UnsupportedPropertyException;
+
+ /**
+ * Delete the resource identified by the given resource id.
+ *
+ * @param resourceId the id of the requested resource
+ *
+ * @throws SystemException an internal system exception occurred
+ * @throws NoSuchResourceException the resource instance to be deleted doesn't exist
+ * @throws UnsupportedPropertyException the request contains unsupported property ids
+ *
+ * @return true if the resource was successfully deleted
+ */
+ public boolean deleteResource(String resourceId) throws
+ SystemException, NoSuchResourceException, UnsupportedPropertyException;
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/89af4f19/ambari-views/src/main/java/org/apache/ambari/view/SystemException.java
----------------------------------------------------------------------
diff --git a/ambari-views/src/main/java/org/apache/ambari/view/SystemException.java b/ambari-views/src/main/java/org/apache/ambari/view/SystemException.java
new file mode 100644
index 0000000..4a38ef0
--- /dev/null
+++ b/ambari-views/src/main/java/org/apache/ambari/view/SystemException.java
@@ -0,0 +1,33 @@
+/**
+ * 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.view;
+
+/**
+ * Indicates that a system exception occurred.
+ */
+public class SystemException extends Exception {
+ /**
+ * Constructor.
+ *
+ * @param msg message
+ * @param throwable root exception
+ */
+ public SystemException(String msg, Throwable throwable) {
+ super(msg, throwable);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/89af4f19/ambari-views/src/main/java/org/apache/ambari/view/UnsupportedPropertyException.java
----------------------------------------------------------------------
diff --git a/ambari-views/src/main/java/org/apache/ambari/view/UnsupportedPropertyException.java b/ambari-views/src/main/java/org/apache/ambari/view/UnsupportedPropertyException.java
new file mode 100644
index 0000000..7db90eb
--- /dev/null
+++ b/ambari-views/src/main/java/org/apache/ambari/view/UnsupportedPropertyException.java
@@ -0,0 +1,70 @@
+/**
+ * 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.view;
+
+
+import java.util.Set;
+
+/**
+ * Thrown to indicate that the requested properties are not supported for the
+ * associated resource type.
+ */
+public class UnsupportedPropertyException extends Exception {
+ /**
+ * The resource type.
+ */
+ private final String type;
+
+ /**
+ * The unsupported property ids.
+ */
+ private final Set<String> propertyIds;
+
+ /**
+ * Construct an UnsupportedPropertyException.
+ *
+ * @param type the resource type
+ * @param propertyIds the unsupported property ids
+ */
+ public UnsupportedPropertyException(String type, Set<String> propertyIds) {
+ super("The properties " + propertyIds +
+ " specified in the request or predicate are not supported for the resource type " +
+ type + ".");
+ this.type = type;
+ this.propertyIds = propertyIds;
+ }
+
+ /**
+ * Get the resource type.
+ *
+ * @return the resource type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Get the unsupported property ids.
+ *
+ * @return the unsupported property ids
+ */
+ public Set<String> getPropertyIds() {
+ return propertyIds;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/89af4f19/ambari-views/src/main/java/org/apache/ambari/view/ViewContext.java
----------------------------------------------------------------------
diff --git a/ambari-views/src/main/java/org/apache/ambari/view/ViewContext.java b/ambari-views/src/main/java/org/apache/ambari/view/ViewContext.java
new file mode 100644
index 0000000..87f9a96
--- /dev/null
+++ b/ambari-views/src/main/java/org/apache/ambari/view/ViewContext.java
@@ -0,0 +1,65 @@
+/**
+ * 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.view;
+
+import java.util.Map;
+
+/**
+ * Context object available to the view components to provide access to
+ * the view and instance attributes as well as run time information about
+ * the current execution context.
+ */
+public interface ViewContext {
+ /**
+ * Get the current user name.
+ *
+ * @return the current user name
+ */
+ public String getUsername();
+
+ /**
+ * Get the view name.
+ *
+ * @return the view name
+ */
+ public String getViewName();
+
+ /**
+ * Get the view instance name.
+ *
+ * @return the view instance name
+ */
+ public String getInstanceName();
+
+ /**
+ * Get the property values specified to create the view instance.
+ *
+ * @return the view instance property values
+ */
+ public Map<String, String> getProperties();
+
+ /**
+ * Get the view resource provider for the given resource type.
+ *
+ * @param type the resource type
+ *
+ * @return the resource provider
+ */
+ public ResourceProvider<?> getResourceProvider(String type);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/89af4f19/ambari-views/src/main/java/org/apache/ambari/view/ViewResourceHandler.java
----------------------------------------------------------------------
diff --git a/ambari-views/src/main/java/org/apache/ambari/view/ViewResourceHandler.java b/ambari-views/src/main/java/org/apache/ambari/view/ViewResourceHandler.java
new file mode 100644
index 0000000..22ed0f1
--- /dev/null
+++ b/ambari-views/src/main/java/org/apache/ambari/view/ViewResourceHandler.java
@@ -0,0 +1,41 @@
+/**
+ * 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.view;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+/**
+ * Handler object available to the view components used to allow
+ * the API framework to handle the request.
+ */
+public interface ViewResourceHandler {
+
+ /**
+ * Handle the API request.
+ *
+ * @param headers the headers
+ * @param ui the URI info
+ * @param resourceId the resource id; may be null for collection resources
+ *
+ * @return the response
+ */
+ public Response handleRequest(HttpHeaders headers, UriInfo ui, String resourceId);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/89af4f19/ambari-views/src/test/java/org/apache/ambari/view/NoSuchResourceExceptionTest.java
----------------------------------------------------------------------
diff --git a/ambari-views/src/test/java/org/apache/ambari/view/NoSuchResourceExceptionTest.java b/ambari-views/src/test/java/org/apache/ambari/view/NoSuchResourceExceptionTest.java
new file mode 100644
index 0000000..fc76282
--- /dev/null
+++ b/ambari-views/src/test/java/org/apache/ambari/view/NoSuchResourceExceptionTest.java
@@ -0,0 +1,32 @@
+/**
+ * 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.view;
+
+import org.junit.Assert;
+
+/**
+ * NoSuchResourceException tests.
+ */
+public class NoSuchResourceExceptionTest {
+ @org.junit.Test
+ public void testGetResourceId() throws Exception {
+ NoSuchResourceException exception = new NoSuchResourceException("id");
+ Assert.assertEquals("id", exception.getResourceId());
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/89af4f19/ambari-views/src/test/java/org/apache/ambari/view/ResourceAlreadyExistsExceptionTest.java
----------------------------------------------------------------------
diff --git a/ambari-views/src/test/java/org/apache/ambari/view/ResourceAlreadyExistsExceptionTest.java b/ambari-views/src/test/java/org/apache/ambari/view/ResourceAlreadyExistsExceptionTest.java
new file mode 100644
index 0000000..f7f8dfd
--- /dev/null
+++ b/ambari-views/src/test/java/org/apache/ambari/view/ResourceAlreadyExistsExceptionTest.java
@@ -0,0 +1,33 @@
+/**
+ * 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.view;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * ResourceAlreadyExistsException tests.
+ */
+public class ResourceAlreadyExistsExceptionTest {
+ @Test
+ public void testGetResourceId() throws Exception {
+ ResourceAlreadyExistsException exception = new ResourceAlreadyExistsException("id");
+ Assert.assertEquals("id", exception.getResourceId());
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/89af4f19/ambari-views/src/test/java/org/apache/ambari/view/UnsupportedPropertyExceptionTest.java
----------------------------------------------------------------------
diff --git a/ambari-views/src/test/java/org/apache/ambari/view/UnsupportedPropertyExceptionTest.java b/ambari-views/src/test/java/org/apache/ambari/view/UnsupportedPropertyExceptionTest.java
new file mode 100644
index 0000000..961ebe7
--- /dev/null
+++ b/ambari-views/src/test/java/org/apache/ambari/view/UnsupportedPropertyExceptionTest.java
@@ -0,0 +1,47 @@
+/**
+ * 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.view;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * UnsupportedPropertyException tests.
+ */
+public class UnsupportedPropertyExceptionTest {
+ @Test
+ public void testGetType() throws Exception {
+ UnsupportedPropertyException exception = new UnsupportedPropertyException("type", Collections.singleton("p1"));
+ Assert.assertEquals("type", exception.getType());
+ }
+
+ @Test
+ public void testGetPropertyIds() throws Exception {
+ Set<String> ids = new HashSet<String>();
+ ids.add("p1");
+ ids.add("p2");
+
+ UnsupportedPropertyException exception = new UnsupportedPropertyException("type", ids);
+ Assert.assertEquals(ids, exception.getPropertyIds());
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/89af4f19/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 811f129..33948b2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -50,6 +50,7 @@
<modules>
<module>ambari-web</module>
<module>ambari-project</module>
+ <module>ambari-views</module>
<module>ambari-server</module>
<module>ambari-agent</module>
<module>ambari-client</module>