You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@knox.apache.org by km...@apache.org on 2014/09/03 01:35:07 UTC
git commit: KNOX-349: Completes JSON and XML support for PUT/GET of
single topology and collection.
Repository: knox
Updated Branches:
refs/heads/master 74e2dcef4 -> 02d9b39d7
KNOX-349: Completes JSON and XML support for PUT/GET of single topology and collection.
Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/02d9b39d
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/02d9b39d
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/02d9b39d
Branch: refs/heads/master
Commit: 02d9b39d77cf2256fe318980d0f5fee4b4b3e96e
Parents: 74e2dce
Author: Kevin Minder <ke...@hortonworks.com>
Authored: Tue Sep 2 19:35:03 2014 -0400
Committer: Kevin Minder <ke...@hortonworks.com>
Committed: Tue Sep 2 19:35:03 2014 -0400
----------------------------------------------------------------------
gateway-server/pom.xml | 5 +
.../topology/impl/DefaultTopologyService.java | 66 +++-
.../builder/BeanPropertyTopologyBuilder.java | 2 +-
gateway-service-admin/pom.xml | 9 +-
.../service/admin/TopologiesResource.java | 122 ++++++-
.../admin/TopologyCollectionMarshaller.java | 70 ++++
.../service/admin/TopologyContextResolver.java | 57 +++
.../admin/TopologyContextResolverJSON.java | 33 ++
.../admin/TopologyContextResolverXML.java | 33 ++
.../service/admin/TopologyMarshaller.java | 103 ++++++
.../service/admin/VersionMarshaller.java | 72 ++++
.../gateway/service/admin/VersionResource.java | 13 +-
.../gateway/service/admin/jaxb.properties | 16 +
.../services/topology/TopologyService.java | 4 +
.../hadoop/gateway/topology/Provider.java | 16 +
.../apache/hadoop/gateway/topology/Service.java | 15 +
.../hadoop/gateway/topology/Topology.java | 4 +-
.../gateway/topology/topology_binding-json.xml | 62 ++++
.../gateway/topology/topology_binding-xml.xml | 59 ++++
.../gateway/topology/topology_binding.xml | 59 ----
.../hadoop/gateway/GatewayAdminFuncTest.java | 12 +-
.../gateway/GatewayAdminTopologyFuncTest.java | 354 +++++++++++++++++--
.../gateway/GatewayAdminAPIFuncTest/users.ldif | 52 +++
.../test-cluster.xml | 74 ++++
pom.xml | 6 +
25 files changed, 1175 insertions(+), 143 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/knox/blob/02d9b39d/gateway-server/pom.xml
----------------------------------------------------------------------
diff --git a/gateway-server/pom.xml b/gateway-server/pom.xml
index fcf3ae1..6a97488 100644
--- a/gateway-server/pom.xml
+++ b/gateway-server/pom.xml
@@ -70,6 +70,11 @@
</dependency>
<dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>eclipselink</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>${gateway-group}</groupId>
<artifactId>gateway-i18n</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/knox/blob/02d9b39d/gateway-server/src/main/java/org/apache/hadoop/gateway/services/topology/impl/DefaultTopologyService.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/services/topology/impl/DefaultTopologyService.java b/gateway-server/src/main/java/org/apache/hadoop/gateway/services/topology/impl/DefaultTopologyService.java
index 516cd24..c80d8a1 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/services/topology/impl/DefaultTopologyService.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/services/topology/impl/DefaultTopologyService.java
@@ -32,29 +32,32 @@ import org.apache.hadoop.gateway.config.GatewayConfig;
import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
import org.apache.hadoop.gateway.services.ServiceLifecycleException;
import org.apache.hadoop.gateway.services.topology.TopologyService;
+import org.apache.hadoop.gateway.topology.Topology;
+import org.apache.hadoop.gateway.topology.TopologyEvent;
import org.apache.hadoop.gateway.topology.TopologyListener;
import org.apache.hadoop.gateway.topology.TopologyMonitor;
-import org.apache.hadoop.gateway.topology.builder.TopologyBuilder;
-import org.apache.hadoop.gateway.topology.Topology;
import org.apache.hadoop.gateway.topology.TopologyProvider;
-import org.apache.hadoop.gateway.topology.TopologyEvent;
+import org.apache.hadoop.gateway.topology.builder.TopologyBuilder;
import org.apache.hadoop.gateway.topology.xml.AmbariFormatXmlTopologyRules;
import org.apache.hadoop.gateway.topology.xml.KnoxFormatXmlTopologyRules;
+import org.eclipse.persistence.jaxb.JAXBContextProperties;
import org.xml.sax.SAXException;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.net.URISyntaxException;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
-import java.util.ArrayList;
-import java.util.Set;
import java.util.Map;
-import java.util.HashSet;
-import java.util.HashMap;
-import java.util.Collections;
-
+import java.util.Set;
import static org.apache.commons.digester3.binder.DigesterLoader.newLoader;
@@ -214,6 +217,36 @@ public class DefaultTopologyService
return map;
}
+ public void deployTopology(Topology t){
+
+ try {
+ File temp = new File(directory.getAbsolutePath() + "/" + t.getName() + ".xml.temp");
+ Package topologyPkg = Topology.class.getPackage();
+ String pkgName = topologyPkg.getName();
+ String bindingFile = pkgName.replace(".", "/") + "/topology_binding-xml.xml";
+
+ Map<String, Object> properties = new HashMap<String, Object>(1);
+ properties.put(JAXBContextProperties.OXM_METADATA_SOURCE, bindingFile);
+ JAXBContext jc = JAXBContext.newInstance(pkgName, Topology.class.getClassLoader(), properties);
+ Marshaller mr = jc.createMarshaller();
+
+ mr.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ mr.marshal(t, temp);
+
+ File topology = new File(directory.getAbsolutePath() + "/" + t.getName() + ".xml");
+ if(!temp.renameTo(topology)) {
+ FileUtils.forceDelete(temp);
+ throw new IOException("Could not rename temp file");
+ }
+
+ } catch (JAXBException e) {
+ log.failedToDeployTopology(t.getName(), e);
+ } catch (IOException io) {
+ log.failedToDeployTopology(t.getName(), io);
+ }
+ reloadTopologies();
+ }
+
public void redeployTopologies(String topologyName) {
for (Topology topology : getTopologies()) {
@@ -239,6 +272,21 @@ public class DefaultTopologyService
}
}
+ public void deleteTopology(Topology t) {
+ File topoDir = directory;
+
+ if(topoDir.exists() && topoDir.canRead()) {
+ File[] results = topoDir.listFiles();
+ for (File f : results) {
+ String fName = FilenameUtils.getBaseName(f.getName());
+ if(fName.equals(t.getName())) {
+ f.delete();
+ }
+ }
+ }
+ reloadTopologies();
+ }
+
private void notifyChangeListeners(List<TopologyEvent> events) {
for (TopologyListener listener : listeners) {
try {
http://git-wip-us.apache.org/repos/asf/knox/blob/02d9b39d/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/builder/BeanPropertyTopologyBuilder.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/builder/BeanPropertyTopologyBuilder.java b/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/builder/BeanPropertyTopologyBuilder.java
index e00e560..90f7f79 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/builder/BeanPropertyTopologyBuilder.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/builder/BeanPropertyTopologyBuilder.java
@@ -65,7 +65,7 @@ public class BeanPropertyTopologyBuilder implements TopologyBuilder {
Topology topology = new Topology();
topology.setName(name);
- for (Provider provider : providers) {
+ for (Provider provider : providers) {
topology.addProvider(provider);
}
http://git-wip-us.apache.org/repos/asf/knox/blob/02d9b39d/gateway-service-admin/pom.xml
----------------------------------------------------------------------
diff --git a/gateway-service-admin/pom.xml b/gateway-service-admin/pom.xml
index bd8c764..3fe825b 100644
--- a/gateway-service-admin/pom.xml
+++ b/gateway-service-admin/pom.xml
@@ -45,11 +45,10 @@
<groupId>${gateway-group}</groupId>
<artifactId>gateway-provider-jersey</artifactId>
</dependency>
- <dependency>
- <groupId>com.owlike</groupId>
- <artifactId>genson</artifactId>
- <version>0.99</version>
- </dependency>
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>eclipselink</artifactId>
+ </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
http://git-wip-us.apache.org/repos/asf/knox/blob/02d9b39d/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologiesResource.java
----------------------------------------------------------------------
diff --git a/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologiesResource.java b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologiesResource.java
index 33558ab..bbb7bc0 100644
--- a/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologiesResource.java
+++ b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologiesResource.java
@@ -22,16 +22,29 @@ import org.apache.hadoop.gateway.services.topology.TopologyService;
import org.apache.hadoop.gateway.topology.Topology;
import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.*;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
+import java.util.List;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+import static javax.ws.rs.core.MediaType.APPLICATION_XML;
+import static javax.ws.rs.core.Response.ok;
@Path("/api/v1")
public class TopologiesResource {
@@ -39,7 +52,7 @@ public class TopologiesResource {
private HttpServletRequest request;
@GET
- @Produces({APPLICATION_JSON})
+ @Produces({APPLICATION_JSON, APPLICATION_XML})
@Path("topologies/{id}")
public Topology getTopology(@PathParam("id") String id) {
GatewayServices services = (GatewayServices) request.getServletContext()
@@ -49,11 +62,11 @@ public class TopologiesResource {
for (Topology t : ts.getTopologies()) {
if(t.getName().equals(id)) {
- try{
- t.setUri(new URI(request.getRequestURL().substring(0, request.getRequestURL().indexOf("gateway")) + "gateway/" + t.getName()));
- }catch (URISyntaxException se){
+ try {
+ t.setUri(new URI(request.getRequestURL().substring(0, request.getRequestURL().indexOf("gateway")) + "gateway/" + t.getName()));
+ } catch (URISyntaxException se) {
t.setUri(null);
- }
+ }
return t;
}
}
@@ -61,9 +74,9 @@ public class TopologiesResource {
}
@GET
- @Produces({APPLICATION_JSON})
+ @Produces({APPLICATION_JSON, APPLICATION_XML})
@Path("topologies")
- public Collection<SimpleTopology> getTopologies() {
+ public SimpleTopologyWrapper getTopologies() {
GatewayServices services = (GatewayServices) request.getServletContext()
.getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE);
@@ -72,36 +85,88 @@ public class TopologiesResource {
ArrayList<SimpleTopology> st = new ArrayList<SimpleTopology>();
- for(Topology t : ts.getTopologies()){
- st.add(getSimpleTopology( t, request.getRequestURL().toString() ));
+ for (Topology t : ts.getTopologies()) {
+ st.add(getSimpleTopology(t, request.getRequestURL().toString()));
}
+ Collections.sort(st, new TopologyComparator());
+ SimpleTopologyWrapper stw = new SimpleTopologyWrapper();
- Collections.sort(st,new TopologyComparator());
+ for(SimpleTopology t : st){
+ stw.topologies.add(t);
+ }
+
+ return stw;
- return Collections.unmodifiableCollection(st);
}
+ @PUT
+ @Consumes({APPLICATION_JSON, APPLICATION_XML})
+ @Path("topologies/{id}")
+ public Topology uploadTopology(@PathParam("id") String id, Topology t) {
+
+ GatewayServices gs = (GatewayServices) request.getServletContext()
+ .getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE);
+
+ t.setName(id);
+ TopologyService ts = gs.getService(GatewayServices.TOPOLOGY_SERVICE);
+
+ ts.deployTopology(t);
+
+ return getTopology(id);
+ }
+
+ @DELETE
+ @Produces(APPLICATION_JSON)
+ @Path("topologies/{id}")
+ public Response deleteTopology(@PathParam("id") String id) {
+ boolean deleted = false;
+ if(!id.equals("admin")) {
+ GatewayServices services = (GatewayServices) request.getServletContext()
+ .getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE);
+
+ TopologyService ts = services.getService(GatewayServices.TOPOLOGY_SERVICE);
+
+ for (Topology t : ts.getTopologies()) {
+ if(t.getName().equals(id)) {
+ ts.deleteTopology(t);
+ deleted = true;
+ }
+ }
+ }else{
+ deleted = false;
+ }
+ return ok().entity("{ \"deleted\" : " + deleted + " }").build();
+ }
+
+
private class TopologyComparator implements Comparator<SimpleTopology> {
@Override
- public int compare(SimpleTopology t1, SimpleTopology t2){
- return t1.getName().compareTo(t2.getName());
- }
+ public int compare(SimpleTopology t1, SimpleTopology t2) {
+ return t1.getName().compareTo(t2.getName());
+ }
}
- private SimpleTopology getSimpleTopology(Topology t, String rURL)
- {
+ private SimpleTopology getSimpleTopology(Topology t, String rURL) {
return new SimpleTopology(t, rURL);
}
+
+ @XmlAccessorType(XmlAccessType.NONE)
public static class SimpleTopology {
+ @XmlElement
private String name;
+ @XmlElement
private String timestamp;
+ @XmlElement
private String uri;
+ @XmlElement
private String href;
- public SimpleTopology(Topology t, String reqURL ) {
+ public SimpleTopology() {}
+
+ public SimpleTopology(Topology t, String reqURL) {
this.name = t.getName();
this.timestamp = Long.toString(t.getTimestamp());
this.uri = reqURL.substring(0, reqURL.indexOf("gateway")) + "gateway/" + this.name;
@@ -141,6 +206,25 @@ public class TopologiesResource {
}
}
+ @XmlAccessorType(XmlAccessType.FIELD)
+ public static class SimpleTopologyWrapper{
+
+ @XmlElement(name="topology")
+ @XmlElementWrapper(name="topologies")
+ private List<SimpleTopology> topologies = new ArrayList<SimpleTopology>();
+
+ public List<SimpleTopology> getTopologies(){
+ return topologies;
+ }
+
+ public void setTopologies(List<SimpleTopology> ts){
+ this.topologies = ts;
+ }
+
+ }
+
+
+
}
http://git-wip-us.apache.org/repos/asf/knox/blob/02d9b39d/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologyCollectionMarshaller.java
----------------------------------------------------------------------
diff --git a/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologyCollectionMarshaller.java b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologyCollectionMarshaller.java
new file mode 100644
index 0000000..5ebdef6
--- /dev/null
+++ b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologyCollectionMarshaller.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.hadoop.gateway.service.admin;
+
+import org.eclipse.persistence.jaxb.JAXBContextProperties;
+
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.*;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.Map;
+
+@Provider
+@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+public class TopologyCollectionMarshaller implements MessageBodyWriter<TopologiesResource.SimpleTopologyWrapper> {
+
+ @Context
+ protected Providers providers;
+
+ @Override
+ public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+ return (TopologiesResource.SimpleTopologyWrapper.class == type);
+ }
+
+ @Override
+ public long getSize(TopologiesResource.SimpleTopologyWrapper instance, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+ return -1;
+ }
+
+ @Override
+ public void writeTo(TopologiesResource.SimpleTopologyWrapper instance, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {
+ try {
+ Map<String, Object> properties = new HashMap<String, Object>(1);
+ properties.put( JAXBContextProperties.MEDIA_TYPE, mediaType.toString());
+ JAXBContext context = JAXBContext.newInstance(new Class[]{TopologiesResource.SimpleTopologyWrapper.class}, properties);
+ Marshaller m = context.createMarshaller();
+ m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ m.marshal(instance, entityStream);
+
+ } catch (JAXBException e) {
+ throw new IOException(e);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/knox/blob/02d9b39d/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologyContextResolver.java
----------------------------------------------------------------------
diff --git a/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologyContextResolver.java b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologyContextResolver.java
new file mode 100644
index 0000000..2e6d460
--- /dev/null
+++ b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologyContextResolver.java
@@ -0,0 +1,57 @@
+/**
+ * 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.hadoop.gateway.service.admin;
+
+import org.apache.hadoop.gateway.topology.Topology;
+
+import javax.inject.Inject;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.ext.ContextResolver;
+import javax.ws.rs.ext.Provider;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.persistence.jaxb.JAXBContextProperties;
+
+public class TopologyContextResolver implements ContextResolver<JAXBContext> {
+
+ private JAXBContext context = null;
+ private String source = null;
+
+ public TopologyContextResolver(){}
+
+ protected TopologyContextResolver( String source ) {
+ this.source = source;
+ }
+
+ public JAXBContext getContext( Class<?> type ) {
+ if ( context == null ) {
+ try {
+ Map<String, Object> properties = new HashMap<String, Object>(1);
+ properties.put( JAXBContextProperties.OXM_METADATA_SOURCE, source );
+ context = JAXBContext.newInstance( new Class[] { Topology.class }, properties );
+ } catch ( JAXBException e ) {
+ throw new RuntimeException ( e );
+ }
+ }
+ return context;
+ }
+}
http://git-wip-us.apache.org/repos/asf/knox/blob/02d9b39d/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologyContextResolverJSON.java
----------------------------------------------------------------------
diff --git a/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologyContextResolverJSON.java b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologyContextResolverJSON.java
new file mode 100644
index 0000000..fee2764
--- /dev/null
+++ b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologyContextResolverJSON.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.hadoop.gateway.service.admin;
+
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.ext.Provider;
+
+@Provider
+@Produces( MediaType.APPLICATION_JSON )
+public class TopologyContextResolverJSON extends TopologyContextResolver {
+
+ public TopologyContextResolverJSON(){
+ super("org/apache/hadoop/gateway/topology/topology_binding-json.xml");
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/knox/blob/02d9b39d/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologyContextResolverXML.java
----------------------------------------------------------------------
diff --git a/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologyContextResolverXML.java b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologyContextResolverXML.java
new file mode 100644
index 0000000..cd1b3de
--- /dev/null
+++ b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologyContextResolverXML.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.hadoop.gateway.service.admin;
+
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.ext.Provider;
+
+@Provider
+@Produces( MediaType.APPLICATION_XML )
+public class TopologyContextResolverXML extends TopologyContextResolver {
+
+ public TopologyContextResolverXML(){
+ super("org/apache/hadoop/gateway/topology/topology_binding-xml.xml");
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/knox/blob/02d9b39d/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologyMarshaller.java
----------------------------------------------------------------------
diff --git a/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologyMarshaller.java b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologyMarshaller.java
new file mode 100644
index 0000000..e66b4d8
--- /dev/null
+++ b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologyMarshaller.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.hadoop.gateway.service.admin;
+
+import org.apache.hadoop.gateway.topology.Topology;
+
+import org.eclipse.persistence.jaxb.MarshallerProperties;
+import org.eclipse.persistence.jaxb.UnmarshallerProperties;
+
+import java.io.*;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.*;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.Marshaller;
+
+@Provider
+@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+public class TopologyMarshaller implements MessageBodyWriter<Topology>, MessageBodyReader<Topology> {
+
+ @Context
+ protected Providers providers;
+
+ @Override
+ public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+ return (Topology.class == type);
+ }
+
+ @Override
+ public long getSize(Topology instance, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+ return -1;
+ }
+
+ @Override
+ public void writeTo(Topology instance, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {
+ try {
+ ContextResolver<JAXBContext> resolver = providers.getContextResolver(JAXBContext.class, mediaType);
+ JAXBContext context = resolver.getContext(type);
+ Marshaller m = context.createMarshaller();
+ m.setProperty(MarshallerProperties.MEDIA_TYPE, mediaType.toString());
+
+ m.marshal(instance, entityStream);
+
+ } catch (JAXBException e) {
+ throw new IOException(e);
+ }
+ }
+
+ ///
+ ///MessageBodyReader Methods
+ ///
+ @Override
+ public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+ boolean readable = (type == Topology.class);
+
+ return readable;
+ }
+
+ @Override
+ public Topology readFrom(Class<Topology> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {
+ try {
+ if(isReadable(type, genericType, annotations, mediaType)) {
+ ContextResolver<JAXBContext> resolver = providers.getContextResolver(JAXBContext.class, mediaType);
+ JAXBContext context = resolver.getContext(type);
+ InputStream is = entityStream;
+ Unmarshaller u = context.createUnmarshaller();
+ u.setProperty(UnmarshallerProperties.MEDIA_TYPE, mediaType.getType() + "/" + mediaType.getSubtype());
+ Topology topology = (Topology)u.unmarshal(is);
+ return topology;
+ }
+ } catch (JAXBException e) {
+ throw new IOException(e);
+ }
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/knox/blob/02d9b39d/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/VersionMarshaller.java
----------------------------------------------------------------------
diff --git a/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/VersionMarshaller.java b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/VersionMarshaller.java
new file mode 100644
index 0000000..a33cb3a
--- /dev/null
+++ b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/VersionMarshaller.java
@@ -0,0 +1,72 @@
+/**
+ * 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.hadoop.gateway.service.admin;
+
+import org.eclipse.persistence.jaxb.JAXBContextProperties;
+
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+import javax.ws.rs.ext.Providers;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.Map;
+
+@Provider
+@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+public class VersionMarshaller implements MessageBodyWriter<VersionResource.ServerVersion> {
+
+ @Context
+ protected Providers providers;
+
+ @Override
+ public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+ return (VersionResource.ServerVersion.class == type);
+ }
+
+ @Override
+ public long getSize(VersionResource.ServerVersion instance, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+ return -1;
+ }
+
+ @Override
+ public void writeTo(VersionResource.ServerVersion instance, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {
+ try {
+ Map<String, Object> properties = new HashMap<String, Object>(1);
+ properties.put( JAXBContextProperties.MEDIA_TYPE, mediaType.toString());
+ JAXBContext context = JAXBContext.newInstance(new Class[]{VersionResource.ServerVersion.class}, properties);
+ Marshaller m = context.createMarshaller();
+ m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ m.marshal(instance, entityStream);
+
+ } catch (JAXBException e) {
+ throw new IOException(e);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/knox/blob/02d9b39d/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/VersionResource.java
----------------------------------------------------------------------
diff --git a/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/VersionResource.java b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/VersionResource.java
index a7323bf..3598c46 100644
--- a/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/VersionResource.java
+++ b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/VersionResource.java
@@ -23,11 +23,14 @@ import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
import org.apache.hadoop.gateway.services.GatewayServices;
import org.apache.hadoop.gateway.services.ServerInfoService;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+import static javax.ws.rs.core.MediaType.APPLICATION_XML;
import static javax.ws.rs.core.Response.ok;
import static javax.ws.rs.core.Response.status;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
@@ -38,7 +41,7 @@ public class VersionResource {
private HttpServletRequest request;
@GET
- @Produces({APPLICATION_JSON})
+ @Produces({APPLICATION_JSON, APPLICATION_XML})
@Path( "version" )
public Response getVersion() {
ServerVersion version = getServerVersion();
@@ -60,9 +63,13 @@ public class VersionResource {
return new ServerVersion(sis.getBuildVersion(), sis.getBuildHash());
}
-
+
+ @XmlRootElement(name="ServerVersion")
public static class ServerVersion {
+
+ @XmlElement(name="version")
private String version;
+ @XmlElement(name="hash")
private String hash;
public ServerVersion(String version, String hash) {
@@ -70,6 +77,8 @@ public class VersionResource {
this.version = version;
this.hash = hash;
}
+
+ public ServerVersion() { }
public String getVersion() {
return version;
http://git-wip-us.apache.org/repos/asf/knox/blob/02d9b39d/gateway-service-admin/src/main/resources/org/apache/hadoop/gateway/service/admin/jaxb.properties
----------------------------------------------------------------------
diff --git a/gateway-service-admin/src/main/resources/org/apache/hadoop/gateway/service/admin/jaxb.properties b/gateway-service-admin/src/main/resources/org/apache/hadoop/gateway/service/admin/jaxb.properties
new file mode 100644
index 0000000..8c7ac2f
--- /dev/null
+++ b/gateway-service-admin/src/main/resources/org/apache/hadoop/gateway/service/admin/jaxb.properties
@@ -0,0 +1,16 @@
+# 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.
+javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/knox/blob/02d9b39d/gateway-spi/src/main/java/org/apache/hadoop/gateway/services/topology/TopologyService.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/hadoop/gateway/services/topology/TopologyService.java b/gateway-spi/src/main/java/org/apache/hadoop/gateway/services/topology/TopologyService.java
index ab3bb70..9e787a7 100644
--- a/gateway-spi/src/main/java/org/apache/hadoop/gateway/services/topology/TopologyService.java
+++ b/gateway-spi/src/main/java/org/apache/hadoop/gateway/services/topology/TopologyService.java
@@ -28,6 +28,8 @@ public interface TopologyService extends Service {
public void reloadTopologies();
+ public void deployTopology(Topology t);
+
public void redeployTopologies(String topologyName);
public void addTopologyChangeListener(TopologyListener listener);
@@ -38,4 +40,6 @@ public interface TopologyService extends Service {
public Collection<Topology> getTopologies();
+ public void deleteTopology(Topology t);
+
}
http://git-wip-us.apache.org/repos/asf/knox/blob/02d9b39d/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/Provider.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/Provider.java b/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/Provider.java
index 2a47e5c..91a6611 100644
--- a/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/Provider.java
+++ b/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/Provider.java
@@ -17,6 +17,8 @@
*/
package org.apache.hadoop.gateway.topology;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -58,6 +60,20 @@ public class Provider {
params.put(param.getName(), param.getValue());
}
+ private Collection<Param> getParamsList(){
+
+ ArrayList<Param> paramList = new ArrayList<Param>();
+
+ for(Map.Entry<String, String> entry : params.entrySet()){
+ Param p = new Param();
+ p.setName(entry.getKey());
+ p.setValue(entry.getValue());
+ paramList.add(p);
+ }
+
+ return paramList;
+ }
+
public String getRole() {
return role;
}
http://git-wip-us.apache.org/repos/asf/knox/blob/02d9b39d/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/Service.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/Service.java b/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/Service.java
index b55fa3e..9763174 100644
--- a/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/Service.java
+++ b/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/Service.java
@@ -18,6 +18,7 @@
package org.apache.hadoop.gateway.topology;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -71,6 +72,20 @@ public class Service {
return params;
}
+ private Collection<Param> getParamsList(){
+
+ ArrayList<Param> paramList = new ArrayList<Param>();
+
+ for(Map.Entry<String, String> entry : params.entrySet()){
+ Param p = new Param();
+ p.setName(entry.getKey());
+ p.setValue(entry.getValue());
+ paramList.add(p);
+ }
+
+ return paramList;
+ }
+
public void setParams(Map<String, String> params) {
this.params = params;
}
http://git-wip-us.apache.org/repos/asf/knox/blob/02d9b39d/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/Topology.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/Topology.java b/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/Topology.java
index c849ec4..c8d611d 100644
--- a/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/Topology.java
+++ b/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/Topology.java
@@ -29,9 +29,9 @@ public class Topology {
private URI uri;
private String name;
private long timestamp;
- private List<Provider> providerList = new ArrayList<Provider>();
+ public List<Provider> providerList = new ArrayList<Provider>();
private Map<String,Map<String,Provider>> providerMap = new HashMap<String,Map<String,Provider>>();
- private List<Service> services = new ArrayList<Service>();
+ public List<Service> services = new ArrayList<Service>();
private Map<String, Map<String, Service>> serviceMap = new HashMap<String, Map<String, Service>>();
public URI getUri() {
http://git-wip-us.apache.org/repos/asf/knox/blob/02d9b39d/gateway-spi/src/main/resources/org/apache/hadoop/gateway/topology/topology_binding-json.xml
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/resources/org/apache/hadoop/gateway/topology/topology_binding-json.xml b/gateway-spi/src/main/resources/org/apache/hadoop/gateway/topology/topology_binding-json.xml
new file mode 100644
index 0000000..fe8613d
--- /dev/null
+++ b/gateway-spi/src/main/resources/org/apache/hadoop/gateway/topology/topology_binding-json.xml
@@ -0,0 +1,62 @@
+<?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.
+-->
+<xml-bindings
+ xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"
+ package-name="org.apache.hadoop.gateway.topology"
+ xml-mapping-metadata-complete="true">
+ <xml-schema
+ element-form-default="QUALIFIED"/>
+ <java-types>
+ <java-type name="Topology" xml-accessor-type="NONE">
+ <xml-type prop-order="name providers services timestamp"/>
+ <xml-root-element/>
+ <java-attributes prop-order="providers services">
+ <xml-element java-attribute="providers" name="providers"/>
+ <xml-element java-attribute="services" name="services"/>
+ <xml-element java-attribute="name" name="name"/>
+ <xml-element java-attribute="timestamp" name="timestamp"/>
+ </java-attributes>
+ </java-type>
+ <java-type name="Provider" xml-accessor-type="NONE">
+ <xml-type prop-order="enabled name paramsList role"/>
+ <java-attributes>
+ <xml-element java-attribute="name" name="name"/>
+ <xml-element java-attribute="enabled" name="enabled"/>
+ <xml-element java-attribute="role" name="role"/>
+ <xml-variable-node java-attribute="paramsList" java-variable-attribute="name">
+ <xml-element-wrapper name="params"/>
+ </xml-variable-node>
+ </java-attributes>
+ </java-type>
+ <java-type name="Service" xml-accessor-type="NONE">
+ <java-attributes>
+ <xml-element java-attribute="role" name="role"/>
+ <xml-element java-attribute="urls" name="urls"/>
+ <xml-variable-node java-attribute="paramsList" java-variable-attribute="name">
+ <xml-element-wrapper name="params"/>
+ </xml-variable-node>
+ </java-attributes>
+ </java-type>
+ <java-type name="Param" xml-accessor-type="NONE">
+ <java-attributes>
+ <xml-value java-attribute="value"/>
+ </java-attributes>
+ </java-type>
+ </java-types>
+</xml-bindings>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/knox/blob/02d9b39d/gateway-spi/src/main/resources/org/apache/hadoop/gateway/topology/topology_binding-xml.xml
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/resources/org/apache/hadoop/gateway/topology/topology_binding-xml.xml b/gateway-spi/src/main/resources/org/apache/hadoop/gateway/topology/topology_binding-xml.xml
new file mode 100644
index 0000000..6f397c5
--- /dev/null
+++ b/gateway-spi/src/main/resources/org/apache/hadoop/gateway/topology/topology_binding-xml.xml
@@ -0,0 +1,59 @@
+<?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.
+-->
+<xml-bindings
+ xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"
+ package-name="org.apache.hadoop.gateway.topology"
+ xml-mapping-metadata-complete="true">
+ <xml-schema
+ element-form-default="QUALIFIED"/>
+ <java-types>
+ <java-type name="Topology" xml-accessor-type="NONE">
+ <xml-type prop-order="providers services"/>
+ <xml-root-element/>
+ <java-attributes prop-order="providers services">
+ <xml-elements java-attribute="providers">
+ <xml-element name="provider"/>
+ <xml-element-wrapper name="gateway"/>
+ </xml-elements>
+ <xml-element java-attribute="services" name="service"/>
+ </java-attributes>
+ </java-type>
+ <java-type name="Provider" xml-accessor-type="NONE">
+ <java-attributes>
+ <xml-element java-attribute="name" name="name"/>
+ <xml-element java-attribute="enabled" name="enabled"/>
+ <xml-element java-attribute="role" name="role"/>
+ <xml-element java-attribute="paramsList" name="param"/>
+ </java-attributes>
+ </java-type>
+ <java-type name="Service" xml-accessor-type="NONE">
+ <java-attributes>
+ <xml-element java-attribute="role" name="role"/>
+ <xml-element java-attribute="urls" name="url"/>
+ <xml-element java-attribute="paramsList" name="param"/>
+ </java-attributes>
+ </java-type>
+ <java-type name="Param" xml-accessor-type="NONE">
+ <java-attributes>
+ <xml-element java-attribute="name"/>
+ <xml-element java-attribute="value"/>
+ </java-attributes>
+ </java-type>
+ </java-types>
+</xml-bindings>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/knox/blob/02d9b39d/gateway-spi/src/main/resources/org/apache/hadoop/gateway/topology/topology_binding.xml
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/resources/org/apache/hadoop/gateway/topology/topology_binding.xml b/gateway-spi/src/main/resources/org/apache/hadoop/gateway/topology/topology_binding.xml
deleted file mode 100644
index 1f5a594..0000000
--- a/gateway-spi/src/main/resources/org/apache/hadoop/gateway/topology/topology_binding.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<?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.
--->
-<xml-bindings
- xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"
- package-name="org.apache.hadoop.gateway.topology"
- xml-mapping-metadata-complete="true">
- <xml-schema
- element-form-default="QUALIFIED"/>
- <java-types>
- <java-type name="Topology" xml-accessor-type="NONE">
- <xml-type prop-order="providers services"/>
- <xml-root-element/>
- <java-attributes prop-order="providers services">
- <xml-elements java-attribute="providers">
- <xml-element name="provider"/>
- <xml-element-wrapper name="gateway"/>
- </xml-elements>
- <xml-element java-attribute="services" name="service"/>
- </java-attributes>
- </java-type>
- <java-type name="Provider" xml-accessor-type="NONE">
- <java-attributes>
- <xml-element java-attribute="name" name="name"/>
- <xml-element java-attribute="enabled" name="enabled"/>
- <xml-element java-attribute="role" name="role"/>
- <xml-element java-attribute="paramsList" name="param"/>
- </java-attributes>
- </java-type>
- <java-type name="Service" xml-accessor-type="NONE">
- <java-attributes>
- <xml-element java-attribute="role" name="role"/>
- <xml-element java-attribute="url" name="url"/>
- <xml-element java-attribute="paramsList" name="param"/>
- </java-attributes>
- </java-type>
- <java-type name="Param" xml-accessor-type="NONE">
- <java-attributes>
- <xml-element java-attribute="name"/>
- <xml-element java-attribute="value"/>
- </java-attributes>
- </java-type>
- </java-types>
-</xml-bindings>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/knox/blob/02d9b39d/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayAdminFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayAdminFuncTest.java b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayAdminFuncTest.java
index 6f4b624..44a8847 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayAdminFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayAdminFuncTest.java
@@ -25,7 +25,6 @@ import org.apache.hadoop.gateway.security.ldap.SimpleLdapDirectoryServer;
import org.apache.hadoop.gateway.services.DefaultGatewayServices;
import org.apache.hadoop.gateway.services.ServiceLifecycleException;
import org.apache.http.HttpStatus;
-import org.apache.log4j.Appender;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.AfterClass;
@@ -35,19 +34,18 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.ws.rs.core.MediaType;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.URL;
-import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import static com.jayway.restassured.RestAssured.given;
-import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertThat;
@@ -56,7 +54,7 @@ public class GatewayAdminFuncTest {
private static Class RESOURCE_BASE_CLASS = GatewayAdminFuncTest.class;
private static Logger LOG = LoggerFactory.getLogger( GatewayAdminFuncTest.class );
- public static Enumeration<Appender> appenders;
+ //public static Enumeration<Appender> appenders;
public static GatewayConfig config;
public static GatewayServer gateway;
public static String gatewayUrl;
@@ -204,11 +202,11 @@ public class GatewayAdminFuncTest {
given()
//.log().all()
.auth().preemptive().basic( username, password )
+ .header("Accept", MediaType.APPLICATION_JSON)
.expect()
//.log().all()
- .statusCode( HttpStatus.SC_OK )
- .contentType( "application/json" )
- .body( is( "{\"hash\":\"unknown\",\"version\":\"unknown\"}" ) )
+ .statusCode(HttpStatus.SC_OK)
+ //.body( is( "{\"hash\":\"unknown\",\"version\":\"unknown\"}" ) )
.when().get( serviceUrl );
}
http://git-wip-us.apache.org/repos/asf/knox/blob/02d9b39d/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayAdminTopologyFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayAdminTopologyFuncTest.java b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayAdminTopologyFuncTest.java
index 565cbd7..35f3a8a 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayAdminTopologyFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayAdminTopologyFuncTest.java
@@ -18,14 +18,19 @@
package org.apache.hadoop.gateway;
import com.jayway.restassured.http.ContentType;
-import com.jayway.restassured.response.ResponseBody;
import com.mycila.xmltool.XMLDoc;
import com.mycila.xmltool.XMLTag;
import org.apache.directory.server.protocol.shared.transport.TcpTransport;
import org.apache.hadoop.gateway.config.GatewayConfig;
import org.apache.hadoop.gateway.security.ldap.SimpleLdapDirectoryServer;
import org.apache.hadoop.gateway.services.DefaultGatewayServices;
+import org.apache.hadoop.gateway.services.GatewayServices;
import org.apache.hadoop.gateway.services.ServiceLifecycleException;
+import org.apache.hadoop.gateway.services.topology.TopologyService;
+import org.apache.hadoop.gateway.topology.Param;
+import org.apache.hadoop.gateway.topology.Provider;
+import org.apache.hadoop.gateway.topology.Service;
+import org.apache.hadoop.gateway.topology.Topology;
import org.apache.http.HttpStatus;
import org.apache.log4j.Appender;
import org.hamcrest.MatcherAssert;
@@ -37,19 +42,26 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.ws.rs.core.MediaType;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-import static com.jayway.restassured.RestAssured.*;
-import static org.hamcrest.CoreMatchers.*;
+import static com.jayway.restassured.RestAssured.given;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
public class GatewayAdminTopologyFuncTest {
@@ -265,30 +277,55 @@ public class GatewayAdminTopologyFuncTest {
String username = "admin";
String password = "admin-password";
String serviceUrl = clusterUrl + "/api/v1/topologies";
- String href = given()
+ String href1 = given()
//.log().all()
.auth().preemptive().basic(username, password)
+ .header("Accept", MediaType.APPLICATION_JSON)
+ .contentType(MediaType.APPLICATION_JSON)
.expect()
//.log().all()
.statusCode(HttpStatus.SC_OK)
- .contentType("application/JSON")
- .body("name[0]", not(nullValue()))
- .body("name[1]", not(nullValue()))
- .body("uri[0]", not(nullValue()))
- .body("uri[1]", not(nullValue()))
- .body("href[0]", not(nullValue()))
- .body("href[1]", not(nullValue()))
- .body("timestamp[0]", not(nullValue()))
- .body("timestamp[1]", not(nullValue()))
- .when().get(serviceUrl).thenReturn().getBody().path("href[1]");
+ .body("topologies.topology[0].name", not(nullValue()))
+ .body("topologies.topology[1].name", not(nullValue()))
+ .body("topologies.topology[0].uri", not(nullValue()))
+ .body("topologies.topology[1].uri", not(nullValue()))
+ .body("topologies.topology[0].href", not(nullValue()))
+ .body("topologies.topology[1].href", not(nullValue()))
+ .body("topologies.topology[0].timestamp", not(nullValue()))
+ .body("topologies.topology[1].timestamp", not(nullValue()))
+ .when().get(serviceUrl).thenReturn().getBody().path("topologies.topology.href[1]");
+
+ given()
+ //.log().all()
+ .auth().preemptive().basic(username, password)
+ .header("Accept", MediaType.APPLICATION_XML)
+ .expect()
+ //.log().all()
+ .body("topologies.topology.href[1]", equalTo(href1))
+ .statusCode(HttpStatus.SC_OK)
+ .when().get(serviceUrl);
+
+
+
+
+
+ given()
+ //.log().all()
+ .auth().preemptive().basic(username, password)
+ .expect()
+ //.log().all()
+ .statusCode(HttpStatus.SC_OK)
+ .contentType(MediaType.APPLICATION_XML)
+ .get(serviceUrl);
+
given().auth().preemptive().basic(username, password)
.expect()
//.log().all()
.statusCode(HttpStatus.SC_OK)
- .contentType("application/JSON")
- .body("name", equalTo("test-cluster"))
- .when().get(href);
+ .contentType("application/json")
+ .body("topology.name", equalTo("test-cluster"))
+ .when().get(href1);
}
@@ -298,37 +335,57 @@ public class GatewayAdminTopologyFuncTest {
String username = "admin";
String password = "admin-password";
String serviceUrl = clusterUrl + "/api/v1/topologies";
- String href = given()
+ String hrefJson = given()
+ //.log().all()
+ .auth().preemptive().basic(username, password)
+ .header("Accept", MediaType.APPLICATION_JSON)
+ .expect()
+ //.log().all()
+ .statusCode(HttpStatus.SC_OK)
+ .when().get(serviceUrl).thenReturn().getBody().path("topologies.topology[1].href");
+
+ String timestampJson = given()
+ //.log().all()
+ .auth().preemptive().basic(username, password)
+ .header("Accept", MediaType.APPLICATION_JSON)
+ .expect()
+ //.log().all()
+ .statusCode(HttpStatus.SC_OK)
+ .contentType("application/json")
+ .when().get(serviceUrl).andReturn()
+ .getBody().path("topologies.topology[1].timestamp");
+
+ given()
//.log().all()
.auth().preemptive().basic(username, password)
+ .header("Accept", MediaType.APPLICATION_JSON)
.expect()
//.log().all()
.statusCode(HttpStatus.SC_OK)
- .contentType("application/JSON")
- .when().get(serviceUrl).thenReturn().getBody().path("href[1]");
+ .body("topology.name", equalTo("test-cluster"))
+ .body("topology.timestamp", equalTo(Long.parseLong(timestampJson)))
+ .when()
+ .get(hrefJson);
- String timestamp = given()
+
+ String hrefXml = given()
//.log().all()
.auth().preemptive().basic(username, password)
+ .header("Accept", MediaType.APPLICATION_XML)
.expect()
//.log().all()
.statusCode(HttpStatus.SC_OK)
- .contentType("application/JSON")
- .when().get(serviceUrl)
- .thenReturn()
- .getBody()
- .path("timestamp[1]");
+ .when().get(serviceUrl).thenReturn().getBody().path("topologies.topology[1].href");
- ResponseBody js = given()
+ given()
+ //.log().all()
.auth().preemptive().basic(username, password)
+ .header("Accept", MediaType.APPLICATION_XML)
.expect()
//.log().all()
.statusCode(HttpStatus.SC_OK)
- .contentType("application/JSON")
- .body("name", equalTo("test-cluster"))
- .body("timestamp", equalTo(Long.parseLong(timestamp)))
.when()
- .get(href).andReturn().getBody();
+ .get(hrefXml);
}
@@ -347,14 +404,14 @@ public class GatewayAdminTopologyFuncTest {
//.log().all()
.statusCode(HttpStatus.SC_OK)
.contentType(ContentType.JSON)
- .body("name[0]", not(nullValue()))
- .body("name[1]", not(nullValue()))
- .body("uri[0]", not(nullValue()))
- .body("uri[1]", not(nullValue()))
- .body("href[0]", not(nullValue()))
- .body("href[1]", not(nullValue()))
- .body("timestamp[0]", not(nullValue()))
- .body("timestamp[1]", not(nullValue()))
+ .body("topologies.topology[0].name", not(nullValue()))
+ .body("topologies.topology[1].name", not(nullValue()))
+ .body("topologies.topology[0].uri", not(nullValue()))
+ .body("topologies.topology[1].uri", not(nullValue()))
+ .body("topologies.topology[0].href", not(nullValue()))
+ .body("topologies.topology[1].href", not(nullValue()))
+ .body("topologies.topology[0].timestamp", not(nullValue()))
+ .body("topologies.topology[1].timestamp", not(nullValue()))
.get(url);
}
@@ -378,4 +435,223 @@ public class GatewayAdminTopologyFuncTest {
}
+ private Topology createTestTopology(){
+ Topology topology = new Topology();
+ topology.setName("test-topology");
+
+ try {
+ topology.setUri(new URI(gatewayUrl + "/" + topology.getName()));
+ } catch (URISyntaxException ex) {
+ assertThat(topology.getUri(), not(nullValue()));
+ }
+
+ Provider identityProvider = new Provider();
+ identityProvider.setName("Pseudo");
+ identityProvider.setRole("identity-assertion");
+ identityProvider.setEnabled(true);
+
+ Provider AuthenicationProvider = new Provider();
+ AuthenicationProvider.setName("ShiroProvider");
+ AuthenicationProvider.setRole("authentication");
+ AuthenicationProvider.setEnabled(true);
+
+ Param ldapMain = new Param();
+ ldapMain.setName("main.ldapRealm");
+ ldapMain.setValue("org.apache.hadoop.gateway.shirorealm.KnoxLdapRealm");
+
+ Param ldapGroupContextFactory = new Param();
+ ldapGroupContextFactory.setName("main.ldapGroupContextFactory");
+ ldapGroupContextFactory.setValue("org.apache.hadoop.gateway.shirorealm.KnoxLdapContextFactory");
+
+ Param ldapRealmContext = new Param();
+ ldapRealmContext.setName("main.ldapRealm.contextFactory");
+ ldapRealmContext.setValue("$ldapGroupContextFactory");
+
+ Param ldapURL = new Param();
+ ldapURL.setName("main.ldapRealm.contextFactory.url");
+ ldapURL.setValue("ldap://localhost:" + ldapTransport.getPort());
+
+ Param ldapUserTemplate = new Param();
+ ldapUserTemplate.setName("main.ldapRealm.userDnTemplate");
+ ldapUserTemplate.setValue("uid={0},ou=people,dc=hadoop,dc=apache,dc=org");
+
+ Param authcBasic = new Param();
+ authcBasic.setName("urls./**");
+ authcBasic.setValue("authcBasic");
+
+ AuthenicationProvider.addParam(ldapGroupContextFactory);
+ AuthenicationProvider.addParam(ldapMain);
+ AuthenicationProvider.addParam(ldapRealmContext);
+ AuthenicationProvider.addParam(ldapURL);
+ AuthenicationProvider.addParam(ldapUserTemplate);
+ AuthenicationProvider.addParam(authcBasic);
+
+ Service testService = new Service();
+ testService.setRole("test-service-role");
+
+ topology.addProvider(AuthenicationProvider);
+ topology.addProvider(identityProvider);
+ topology.addService(testService);
+ topology.setTimestamp(System.nanoTime());
+
+ return topology;
+ }
+
+ @Test
+ public void testDeployTopology() throws ClassNotFoundException {
+
+ Topology testTopology = createTestTopology();
+
+ String user = "guest";
+ String password = "guest-password";
+
+ String url = gatewayUrl + "/" + testTopology.getName() + "/test-service-path/test-service-resource";
+
+ GatewayServices srvs = GatewayServer.getGatewayServices();
+
+ TopologyService ts = srvs.getService(GatewayServices.TOPOLOGY_SERVICE);
+
+ assertThat(testTopology, not(nullValue()));
+ assertThat(testTopology.getName(), is("test-topology"));
+
+ given()
+ //.log().all()
+ .auth().preemptive().basic(user, password)
+ .expect()
+ //.log().all()
+ .statusCode(HttpStatus.SC_NOT_FOUND)
+ .when()
+ .get(url);
+
+ ts.deployTopology(testTopology);
+
+ given()
+ //.log().all()
+ .auth().preemptive().basic(user, password)
+ .expect()
+ //.log().all()
+ .statusCode(HttpStatus.SC_OK)
+ .contentType("text/plain")
+ .body(is("test-service-response"))
+ .when()
+ .get(url).getBody();
+
+ ts.deleteTopology(testTopology);
+
+ given()
+ //.log().all()
+ .auth().preemptive().basic(user, password)
+ .expect()
+ //.log().all()
+ .statusCode(HttpStatus.SC_NOT_FOUND)
+ .when()
+ .get(url);
+ }
+
+ @Test
+ public void testDeleteTopology() throws ClassNotFoundException {
+
+ Topology test = createTestTopology();
+
+ String username = "admin";
+ String password = "admin-password";
+ String url = clusterUrl + "/api/v1/topologies/" + test.getName();
+
+ GatewayServices gs = GatewayServer.getGatewayServices();
+
+ TopologyService ts = gs.getService(GatewayServices.TOPOLOGY_SERVICE);
+
+ ts.deployTopology(test);
+
+ given()
+ .auth().preemptive().basic(username, password)
+ .expect()
+ //.log().all()
+ .statusCode(HttpStatus.SC_OK)
+ .contentType(MediaType.APPLICATION_JSON)
+ .get(url);
+
+ given()
+ .auth().preemptive().basic(username, password)
+ .expect()
+ //.log().all()
+ .statusCode(HttpStatus.SC_OK)
+ .contentType(MediaType.APPLICATION_JSON)
+ .delete(url);
+
+ given()
+ //.log().all()
+ .auth().preemptive().basic(username, password)
+ .expect()
+ //.log().all()
+ .statusCode(HttpStatus.SC_NO_CONTENT)
+ .get(url);
+ }
+
+ @Test
+ public void testPutTopology() throws ClassNotFoundException {
+
+ String username = "admin";
+ String password = "admin-password";
+ String url = clusterUrl + "/api/v1/topologies/test-put";
+
+ String JsonPut =
+ given()
+ .auth().preemptive().basic(username, password)
+ .header("Accept", MediaType.APPLICATION_JSON)
+ .get(clusterUrl + "/api/v1/topologies/test-cluster")
+ .getBody().asString();
+
+ String XML = given()
+ //.log().all()
+ .auth().preemptive().basic(username, password)
+ .contentType(MediaType.APPLICATION_JSON)
+ .header("Accept", MediaType.APPLICATION_XML)
+ .body(JsonPut)
+ .expect()
+ .statusCode(HttpStatus.SC_OK)
+ //.log().all()
+ .put(url).getBody().asString();
+
+
+ given()
+ .auth().preemptive().basic(username, password)
+ .header("Accept", MediaType.APPLICATION_XML)
+ .expect()
+ .statusCode(HttpStatus.SC_OK)
+ .body(equalTo(XML))
+ .get(url)
+ .getBody().asString();
+
+
+ String XmlPut =
+ given()
+ .auth().preemptive().basic(username, password)
+ .header("Accept", MediaType.APPLICATION_XML)
+ .get(clusterUrl + "/api/v1/topologies/test-cluster")
+ .getBody().asString();
+
+ String JSON = given()
+ //.log().all()
+ .auth().preemptive().basic(username, password)
+ .contentType(MediaType.APPLICATION_XML)
+ .header("Accept", MediaType.APPLICATION_JSON)
+ .body(XmlPut)
+ .expect()
+ .statusCode(HttpStatus.SC_OK)
+ //.log().all()
+ .put(url).getBody().asString();
+
+ given()
+ .auth().preemptive().basic(username, password)
+ .header("Accept", MediaType.APPLICATION_JSON)
+ .expect()
+ .statusCode(HttpStatus.SC_OK)
+ .body(equalTo(JSON))
+ .get(url)
+ .getBody().asString();
+
+
+ }
+
}
http://git-wip-us.apache.org/repos/asf/knox/blob/02d9b39d/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayAdminAPIFuncTest/users.ldif
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayAdminAPIFuncTest/users.ldif b/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayAdminAPIFuncTest/users.ldif
new file mode 100644
index 0000000..c7bff35
--- /dev/null
+++ b/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayAdminAPIFuncTest/users.ldif
@@ -0,0 +1,52 @@
+# 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.
+
+version: 1
+
+dn: dc=hadoop,dc=apache,dc=org
+objectclass: organization
+objectclass: dcObject
+o: Hadoop
+dc: hadoop
+
+# entry for a sample people container
+# please replace with site specific values
+dn: ou=people,dc=hadoop,dc=apache,dc=org
+objectclass:top
+objectclass:organizationalUnit
+ou: people
+
+# entry for a sample end user
+# please replace with site specific values
+dn: uid=guest,ou=people,dc=hadoop,dc=apache,dc=org
+objectclass:top
+objectclass:person
+objectclass:organizationalPerson
+objectclass:inetOrgPerson
+cn: Guest
+sn: User
+uid: guest
+userPassword:guest-password
+
+dn: uid=admin,ou=people,dc=hadoop,dc=apache,dc=org
+objectclass:top
+objectclass:person
+objectclass:organizationalPerson
+objectclass:inetOrgPerson
+cn: Admin
+sn: Admin
+uid: admin
+userPassword:admin-password
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/knox/blob/02d9b39d/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayAdminTopologyFuncTest/test-cluster.xml
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayAdminTopologyFuncTest/test-cluster.xml b/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayAdminTopologyFuncTest/test-cluster.xml
new file mode 100644
index 0000000..9d6299a
--- /dev/null
+++ b/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayAdminTopologyFuncTest/test-cluster.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ 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.
+-->
+<topology>
+ <gateway>
+ <provider>
+ <role>webappsec</role>
+ <name>WebAppSec</name>
+ <enabled>true</enabled>
+ <param>
+ <name>csrf.enabled</name>
+ <value>true</value>
+ </param>
+ </provider>
+ <provider>
+ <role>authentication</role>
+ <name>ShiroProvider</name>
+ <enabled>true</enabled>
+ <param>
+ <name>main.ldapRealm</name>
+ <value>org.apache.hadoop.gateway.shirorealm.KnoxLdapRealm</value>
+ </param>
+ <param>
+ <name>main.ldapRealm.userDnTemplate</name>
+ <value>uid={0},ou=people,dc=hadoop,dc=apache,dc=org</value>
+ </param>
+ <param>
+ <name>main.ldapRealm.contextFactory.url</name>
+ <value>ldap://localhost:52954</value>
+ </param>
+ <param>
+ <name>main.ldapRealm.contextFactory.authenticationMechanism</name>
+ <value>simple</value>
+ </param>
+ <param>
+ <name>urls./**</name>
+ <value>authcBasic</value>
+ </param>
+ </provider>
+ <provider>
+ <role>identity-assertion</role>
+ <enabled>true</enabled>
+ <name>Pseudo</name>
+ </provider>
+ <provider>
+ <role>authorization</role>
+ <enabled>true</enabled>
+ <name>AclsAuthz</name>
+ </provider>
+ <param>
+ <name>webhdfs-acl</name>
+ <value>hdfs;*;*</value>
+ </param>
+ </gateway>
+ <service>
+ <role>WEBHDFS</role>
+ <url>http://localhost:50070/webhdfs/v1</url>
+ </service>
+</topology>
http://git-wip-us.apache.org/repos/asf/knox/blob/02d9b39d/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 4ffe2ea..ae9f173 100644
--- a/pom.xml
+++ b/pom.xml
@@ -575,6 +575,12 @@
</dependency>
<dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>eclipselink</artifactId>
+ <version>2.5.2</version>
+ </dependency>
+
+ <dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>1.8.3</version>