You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@knox.apache.org by su...@apache.org on 2016/12/20 17:09:53 UTC

knox git commit: KNOX-818 created new jaxb beans for REST API

Repository: knox
Updated Branches:
  refs/heads/master d4ae9ae52 -> f31e46f5c


KNOX-818 created new jaxb beans for REST API


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

Branch: refs/heads/master
Commit: f31e46f5c25b882f3904648907ba1c94dcab794c
Parents: d4ae9ae
Author: Sumit Gupta <su...@apache.org>
Authored: Tue Dec 20 12:09:00 2016 -0500
Committer: Sumit Gupta <su...@apache.org>
Committed: Tue Dec 20 12:09:48 2016 -0500

----------------------------------------------------------------------
 .../service/admin/TopologiesResource.java       |  25 ++-
 .../service/admin/TopologyContextResolver.java  |  57 -------
 .../admin/TopologyContextResolverJSON.java      |  33 ----
 .../admin/TopologyContextResolverXML.java       |  33 ----
 .../service/admin/TopologyMarshaller.java       |  25 ++-
 .../service/admin/beans/Application.java        |  34 ++++
 .../service/admin/beans/BeanConverter.java      | 164 +++++++++++++++++++
 .../gateway/service/admin/beans/Param.java      |  57 +++++++
 .../gateway/service/admin/beans/Provider.java   |  75 +++++++++
 .../gateway/service/admin/beans/Service.java    |  87 ++++++++++
 .../gateway/service/admin/beans/Topology.java   | 108 ++++++++++++
 .../gateway/service/admin/beans/jaxb.properties |  16 ++
 .../apache/hadoop/gateway/topology/Param.java   |  10 +-
 .../hadoop/gateway/topology/Provider.java       |   2 +-
 .../gateway/GatewayAdminTopologyFuncTest.java   |  24 ++-
 15 files changed, 594 insertions(+), 156 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/f31e46f5/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 52198ee..f3ce0f3 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
@@ -17,10 +17,11 @@
  */
 package org.apache.hadoop.gateway.service.admin;
 
+import org.apache.hadoop.gateway.service.admin.beans.BeanConverter;
+import org.apache.hadoop.gateway.service.admin.beans.Topology;
 import org.apache.hadoop.gateway.services.GatewayServices;
 import org.apache.hadoop.gateway.config.GatewayConfig;
 import org.apache.hadoop.gateway.services.topology.TopologyService;
-import org.apache.hadoop.gateway.topology.Topology;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.Consumes;
@@ -62,14 +63,14 @@ public class TopologiesResource {
 
     TopologyService ts = services.getService(GatewayServices.TOPOLOGY_SERVICE);
 
-    for (Topology t : ts.getTopologies()) {
+    for (org.apache.hadoop.gateway.topology.Topology t : ts.getTopologies()) {
       if(t.getName().equals(id)) {
         try {
           t.setUri(new URI( buildURI(t, config, request) ));
         } catch (URISyntaxException se) {
           t.setUri(null);
         }
-        return t;
+        return BeanConverter.getTopology(t);
       }
     }
     return null;
@@ -88,7 +89,7 @@ public class TopologiesResource {
     ArrayList<SimpleTopology> st = new ArrayList<SimpleTopology>();
     GatewayConfig conf = (GatewayConfig) request.getServletContext().getAttribute(GatewayConfig.GATEWAY_CONFIG_ATTRIBUTE);
 
-    for (Topology t : ts.getTopologies()) {
+    for (org.apache.hadoop.gateway.topology.Topology t : ts.getTopologies()) {
       st.add(getSimpleTopology(t, conf));
     }
 
@@ -114,7 +115,7 @@ public class TopologiesResource {
     t.setName(id);
     TopologyService ts = gs.getService(GatewayServices.TOPOLOGY_SERVICE);
 
-    ts.deployTopology(t);
+    ts.deployTopology(BeanConverter.getTopology(t));
 
     return getTopology(id);
   }
@@ -130,7 +131,7 @@ public class TopologiesResource {
 
       TopologyService ts = services.getService(GatewayServices.TOPOLOGY_SERVICE);
 
-      for (Topology t : ts.getTopologies()) {
+      for (org.apache.hadoop.gateway.topology.Topology t : ts.getTopologies()) {
         if(t.getName().equals(id)) {
           ts.deleteTopology(t);
           deleted = true;
@@ -150,7 +151,7 @@ public class TopologiesResource {
     }
   }
 
-   String buildURI(Topology topology, GatewayConfig config, HttpServletRequest req){
+   String buildURI(org.apache.hadoop.gateway.topology.Topology topology, GatewayConfig config, HttpServletRequest req){
     String uri = buildXForwardBaseURL(req);
 
 //    Strip extra context
@@ -169,7 +170,7 @@ public class TopologiesResource {
     return uri;
   }
 
-   String buildHref(Topology t, HttpServletRequest req) {
+   String buildHref(org.apache.hadoop.gateway.topology.Topology t, HttpServletRequest req) {
     String href = buildXForwardBaseURL(req);
 //    Make sure that the pathInfo doesn't have any '/' chars at the end.
     String pathInfo = req.getPathInfo();
@@ -183,7 +184,7 @@ public class TopologiesResource {
     return href;
   }
 
-  private SimpleTopology getSimpleTopology(Topology t, GatewayConfig config) {
+  private SimpleTopology getSimpleTopology(org.apache.hadoop.gateway.topology.Topology t, GatewayConfig config) {
     String uri = buildURI(t, config, request);
     String href = buildHref(t, request);
     return new SimpleTopology(t, uri, href);
@@ -250,7 +251,7 @@ public class TopologiesResource {
 
     public SimpleTopology() {}
 
-    public SimpleTopology(Topology t, String uri, String href) {
+    public SimpleTopology(org.apache.hadoop.gateway.topology.Topology t, String uri, String href) {
       this.name = t.getName();
       this.timestamp = Long.toString(t.getTimestamp());
       this.uri = uri;
@@ -306,9 +307,5 @@ public class TopologiesResource {
     }
 
   }
-
-
-
-
 }
 

http://git-wip-us.apache.org/repos/asf/knox/blob/f31e46f5/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
deleted file mode 100644
index 2e6d460..0000000
--- a/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologyContextResolver.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.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/f31e46f5/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
deleted file mode 100644
index fee2764..0000000
--- a/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologyContextResolverJSON.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.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/f31e46f5/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
deleted file mode 100644
index cd1b3de..0000000
--- a/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologyContextResolverXML.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.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/f31e46f5/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
index e66b4d8..3eb9384 100644
--- 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
@@ -18,19 +18,21 @@
 
 package org.apache.hadoop.gateway.service.admin;
 
-import org.apache.hadoop.gateway.topology.Topology;
+import org.apache.hadoop.gateway.service.admin.beans.Topology;
 
-import org.eclipse.persistence.jaxb.MarshallerProperties;
+import org.eclipse.persistence.jaxb.JAXBContextProperties;
 import org.eclipse.persistence.jaxb.UnmarshallerProperties;
 
 import java.io.*;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
 
 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.*;
@@ -44,9 +46,6 @@ import javax.xml.bind.Marshaller;
 @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);
@@ -60,13 +59,12 @@ public class TopologyMarshaller implements MessageBodyWriter<Topology>, MessageB
   @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);
+      Map<String, Object> properties = new HashMap<String, Object>(1);
+      properties.put( JAXBContextProperties.MEDIA_TYPE, mediaType.toString());
+      JAXBContext context = JAXBContext.newInstance(new Class[]{Topology.class}, properties);
       Marshaller m = context.createMarshaller();
-      m.setProperty(MarshallerProperties.MEDIA_TYPE, mediaType.toString());
-
+      m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
       m.marshal(instance, entityStream);
-
     } catch (JAXBException e) {
       throw new IOException(e);
     }
@@ -78,7 +76,6 @@ public class TopologyMarshaller implements MessageBodyWriter<Topology>, MessageB
   @Override
   public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
     boolean readable = (type == Topology.class);
-
     return readable;
   }
 
@@ -86,8 +83,8 @@ public class TopologyMarshaller implements MessageBodyWriter<Topology>, MessageB
   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);
+        Map<String, Object> properties = Collections.EMPTY_MAP;
+        JAXBContext context = JAXBContext.newInstance(new Class[]{Topology.class}, properties);
         InputStream is = entityStream;
         Unmarshaller u = context.createUnmarshaller();
         u.setProperty(UnmarshallerProperties.MEDIA_TYPE, mediaType.getType() + "/" + mediaType.getSubtype());

http://git-wip-us.apache.org/repos/asf/knox/blob/f31e46f5/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/beans/Application.java
----------------------------------------------------------------------
diff --git a/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/beans/Application.java b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/beans/Application.java
new file mode 100644
index 0000000..7d51c29
--- /dev/null
+++ b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/beans/Application.java
@@ -0,0 +1,34 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.beans;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+
+@XmlAccessorType(XmlAccessType.NONE)
+public class Application extends Service {
+
+  public String getRole() {
+    return getName();
+  }
+
+  public void setRole( String role ) {
+    setName( role );
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/f31e46f5/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/beans/BeanConverter.java
----------------------------------------------------------------------
diff --git a/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/beans/BeanConverter.java b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/beans/BeanConverter.java
new file mode 100644
index 0000000..e0c9d06
--- /dev/null
+++ b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/beans/BeanConverter.java
@@ -0,0 +1,164 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.beans;
+
+import org.apache.hadoop.gateway.topology.Version;
+
+import java.util.Collection;
+
+public class BeanConverter {
+
+  public static Topology getTopology(org.apache.hadoop.gateway.topology.Topology topology) {
+    Topology topologyResource = new Topology();
+    topologyResource.setName(topology.getName());
+    topologyResource.setTimestamp(topology.getTimestamp());
+    topologyResource.setUri(topology.getUri());
+    for ( org.apache.hadoop.gateway.topology.Provider provider : topology.getProviders() ) {
+      topologyResource.getProviders().add( getProvider(provider) );
+    }
+    for ( org.apache.hadoop.gateway.topology.Service service : topology.getServices() ) {
+      topologyResource.getServices().add( getService(service) );
+    }
+    for ( org.apache.hadoop.gateway.topology.Application application : topology.getApplications() ) {
+      topologyResource.getApplications().add( getApplication(application) );
+    }
+    return topologyResource;
+  }
+
+  public static org.apache.hadoop.gateway.topology.Topology getTopology(Topology topology) {
+    org.apache.hadoop.gateway.topology.Topology deploymentTopology = new org.apache.hadoop.gateway.topology.Topology();
+    deploymentTopology.setName(topology.getName());
+    deploymentTopology.setTimestamp(topology.getTimestamp());
+    deploymentTopology.setUri(topology.getUri());
+    for ( Provider provider : topology.getProviders() ) {
+      deploymentTopology.addProvider( getProvider(provider) );
+    }
+    for ( Service service : topology.getServices() ) {
+      deploymentTopology.addService( getService(service) );
+    }
+    for ( Application application : topology.getApplications() ) {
+      deploymentTopology.addApplication( getApplication(application) );
+    }
+    return deploymentTopology;
+  }
+
+  private static Provider getProvider(org.apache.hadoop.gateway.topology.Provider provider) {
+    Provider providerResource = new Provider();
+    providerResource.setName(provider.getName());
+    providerResource.setEnabled(provider.isEnabled());
+    providerResource.setRole(provider.getRole());
+    Collection<org.apache.hadoop.gateway.topology.Param> paramsList = provider.getParamsList();
+    if (paramsList != null && !paramsList.isEmpty()) {
+      for ( org.apache.hadoop.gateway.topology.Param param : paramsList ) {
+        providerResource.getParams().add(getParam(param));
+      }
+    }
+    return providerResource;
+  }
+
+  private static org.apache.hadoop.gateway.topology.Provider getProvider(Provider provider) {
+    org.apache.hadoop.gateway.topology.Provider deploymentProvider = new org.apache.hadoop.gateway.topology.Provider();
+    deploymentProvider.setName(provider.getName());
+    deploymentProvider.setEnabled(provider.isEnabled());
+    deploymentProvider.setRole(provider.getRole());
+    for ( Param param : provider.getParams() ) {
+      deploymentProvider.addParam( getParam(param) );
+    }
+    return deploymentProvider;
+  }
+
+  private static Service getService(org.apache.hadoop.gateway.topology.Service service) {
+    Service serviceResource = new Service();
+    serviceResource.setRole(service.getRole());
+    serviceResource.setName(service.getName());
+    Version version = service.getVersion();
+    if (version != null) {
+      serviceResource.setVersion(version.toString());
+    }
+    Collection<org.apache.hadoop.gateway.topology.Param> paramsList = service.getParamsList();
+    if (paramsList != null && !paramsList.isEmpty()) {
+      for ( org.apache.hadoop.gateway.topology.Param param : paramsList ) {
+        serviceResource.getParams().add(getParam(param));
+      }
+    }
+    for ( String url : service.getUrls() ) {
+      serviceResource.getUrls().add( url );
+    }
+    return serviceResource;
+  }
+
+  private static org.apache.hadoop.gateway.topology.Service getService(Service service) {
+    org.apache.hadoop.gateway.topology.Service deploymentService = new org.apache.hadoop.gateway.topology.Service();
+    deploymentService.setRole(service.getRole());
+    deploymentService.setName(service.getName());
+    if (service.getVersion() != null) {
+      deploymentService.setVersion(new Version(service.getVersion()));
+    }
+    for ( Param param : service.getParams() ) {
+      deploymentService.addParam( getParam(param) );
+    }
+    for ( String url : service.getUrls() ) {
+      deploymentService.addUrl( url );
+    }
+    return deploymentService;
+  }
+
+  private static Application getApplication(org.apache.hadoop.gateway.topology.Application application) {
+    Application applicationResource = new Application();
+    applicationResource.setRole(application.getRole());
+    applicationResource.setName(application.getName());
+    Version version = application.getVersion();
+    if (version != null) {
+      applicationResource.setVersion(version.toString());
+    }
+    Collection<org.apache.hadoop.gateway.topology.Param> paramsList = application.getParamsList();
+    if (paramsList != null && !paramsList.isEmpty()) {
+      for ( org.apache.hadoop.gateway.topology.Param param : paramsList ) {
+        applicationResource.getParams().add(getParam(param));
+      }
+    }
+    for ( String url : application.getUrls() ) {
+      applicationResource.getUrls().add( url );
+    }
+    return applicationResource;
+  }
+
+  private static org.apache.hadoop.gateway.topology.Application getApplication(Application application) {
+    org.apache.hadoop.gateway.topology.Application applicationResource = new org.apache.hadoop.gateway.topology.Application();
+    applicationResource.setRole(application.getRole());
+    applicationResource.setName(application.getName());
+    if (application.getVersion() != null) {
+      applicationResource.setVersion(new Version(application.getVersion()));
+    }
+    for ( Param param : application.getParams() ) {
+      applicationResource.addParam( getParam(param) );
+    }
+    for ( String url : application.getUrls() ) {
+      applicationResource.getUrls().add( url );
+    }
+    return applicationResource;
+  }
+
+  private static Param getParam(org.apache.hadoop.gateway.topology.Param param) {
+    return new Param(param.getName(), param.getValue());
+  }
+
+  private static org.apache.hadoop.gateway.topology.Param getParam(Param param) {
+    return new org.apache.hadoop.gateway.topology.Param(param.getName(), param.getValue());
+  }
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/f31e46f5/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/beans/Param.java
----------------------------------------------------------------------
diff --git a/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/beans/Param.java b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/beans/Param.java
new file mode 100644
index 0000000..ca349d4
--- /dev/null
+++ b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/beans/Param.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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.beans;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+
+@XmlAccessorType(XmlAccessType.NONE)
+public class Param {
+
+  @XmlElement
+  private String name;
+  @XmlElement
+  private String value;
+
+  public Param() {
+  }
+
+  public Param(String name, String value) {
+    this.name = name;
+    this.value = value;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public String getValue() {
+    return value;
+  }
+
+  public void setValue(String value) {
+    this.value = value;
+  }
+
+
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/f31e46f5/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/beans/Provider.java
----------------------------------------------------------------------
diff --git a/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/beans/Provider.java b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/beans/Provider.java
new file mode 100644
index 0000000..86339af
--- /dev/null
+++ b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/beans/Provider.java
@@ -0,0 +1,75 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.beans;
+
+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.util.ArrayList;
+import java.util.List;
+
+@XmlAccessorType(XmlAccessType.NONE)
+public class Provider {
+  @XmlElement
+  private String role;
+  @XmlElement
+  private String name;
+  @XmlElement
+  private boolean enabled;
+  @XmlElement(name="param")
+  private List<Param> params;
+
+  public Provider() {
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public boolean isEnabled() {
+    return enabled;
+  }
+
+  public void setEnabled(boolean enabled) {
+    this.enabled = enabled;
+  }
+
+  public String getRole() {
+    return role;
+  }
+
+  public void setRole( String role ) {
+    this.role = role;
+  }
+
+  public List<Param> getParams() {
+    if (params == null) {
+      params = new ArrayList<>();
+    }
+    return params;
+  }
+
+  public void setParams(List<Param> params) {
+    this.params = params;
+  }
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/f31e46f5/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/beans/Service.java
----------------------------------------------------------------------
diff --git a/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/beans/Service.java b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/beans/Service.java
new file mode 100644
index 0000000..f015cac
--- /dev/null
+++ b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/beans/Service.java
@@ -0,0 +1,87 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.beans;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import java.util.ArrayList;
+import java.util.List;
+
+@XmlAccessorType(XmlAccessType.NONE)
+public class Service {
+  @XmlElement
+  private String role;
+  @XmlElement
+  private String name;
+  @XmlElement
+  private String version;
+  @XmlElement(name="param")
+  private List<Param> params;
+  @XmlElement(name="url")
+  private List<String> urls;
+
+  public Service() {
+  }
+
+  public String getRole() {
+    return role;
+  }
+
+  public void setRole( String role ) {
+    this.role = role;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName( String name ) {
+    this.name = name;
+  }
+
+  public String getVersion() {
+    return version;
+  }
+
+  public void setVersion(String version) {
+    this.version = version;
+  }
+
+  public List<String> getUrls() {
+    if (urls == null) {
+      urls = new ArrayList<>();
+    }
+    return urls;
+  }
+
+  public void setUrls( List<String> urls ) {
+    this.urls = urls;
+  }
+
+  public List<Param> getParams() {
+    if (params == null) {
+      params = new ArrayList<>();
+    }
+    return params;
+  }
+
+  public void setParams(List<Param> params) {
+    this.params = params;
+  }
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/f31e46f5/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/beans/Topology.java
----------------------------------------------------------------------
diff --git a/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/beans/Topology.java b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/beans/Topology.java
new file mode 100644
index 0000000..6e85b7a
--- /dev/null
+++ b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/beans/Topology.java
@@ -0,0 +1,108 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.beans;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+@XmlRootElement(name="topology")
+public class Topology {
+
+  @XmlElement
+  private URI uri;
+
+  @XmlElement
+  private String name;
+
+  @XmlElement
+  private long timestamp;
+
+  @XmlElement(name="provider")
+  @XmlElementWrapper(name="gateway")
+  public List<Provider> providers;
+
+  @XmlElement(name="service")
+  public List<Service> services;
+
+  @XmlElement(name="application")
+  private List<Application> applications;
+
+  public Topology() {
+  }
+
+  public URI getUri() {
+    return uri;
+  }
+
+  public void setUri( URI uri ) {
+    this.uri = uri;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName( String name ) {
+    this.name = name;
+  }
+
+  public long getTimestamp() {
+    return timestamp;
+  }
+
+  public void setTimestamp( long timestamp ) {
+    this.timestamp = timestamp;
+  }
+
+  public List<Service> getServices() {
+    if (services == null) {
+      services = new ArrayList<>();
+    }
+    return services;
+  }
+
+  public List<Application> getApplications() {
+    if (applications == null) {
+      applications = new ArrayList<>();
+    }
+    return applications;
+  }
+
+  public List<Provider> getProviders() {
+    if (providers == null) {
+      providers = new ArrayList<>();
+    }
+    return providers;
+  }
+
+  public void setProviders(List<Provider> providers) {
+    this.providers = providers;
+  }
+
+  public void setServices(List<Service> services) {
+    this.services = services;
+  }
+
+  public void setApplications(List<Application> applications) {
+    this.applications = applications;
+  }
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/f31e46f5/gateway-service-admin/src/main/resources/org/apache/hadoop/gateway/service/admin/beans/jaxb.properties
----------------------------------------------------------------------
diff --git a/gateway-service-admin/src/main/resources/org/apache/hadoop/gateway/service/admin/beans/jaxb.properties b/gateway-service-admin/src/main/resources/org/apache/hadoop/gateway/service/admin/beans/jaxb.properties
new file mode 100644
index 0000000..8c7ac2f
--- /dev/null
+++ b/gateway-service-admin/src/main/resources/org/apache/hadoop/gateway/service/admin/beans/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/f31e46f5/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/Param.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/Param.java b/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/Param.java
index 704b0bb..0ff3c3b 100644
--- a/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/Param.java
+++ b/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/Param.java
@@ -21,7 +21,15 @@ public class Param {
 
   private String name;
   private String value;
-  
+
+  public Param() {
+  }
+
+  public Param(String name, String value) {
+    this.name = name;
+    this.value = value;
+  }
+
   public String getName() {
     return name;
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/f31e46f5/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 91a6611..41bfab1 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
@@ -60,7 +60,7 @@ public class Provider {
     params.put(param.getName(), param.getValue());
   }
 
-  private Collection<Param> getParamsList(){
+  public Collection<Param> getParamsList(){
 
     ArrayList<Param> paramList = new ArrayList<Param>();
 

http://git-wip-us.apache.org/repos/asf/knox/blob/f31e46f5/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 51064e0..ed85562 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
@@ -21,6 +21,7 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.StringReader;
 import java.net.ServerSocket;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -30,6 +31,9 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 import javax.ws.rs.core.MediaType;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
 
 import com.jayway.restassured.http.ContentType;
 import com.mycila.xmltool.XMLDoc;
@@ -55,6 +59,9 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
 
 import static com.jayway.restassured.RestAssured.given;
 import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
@@ -65,6 +72,7 @@ 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.hamcrest.xml.HasXPath.hasXPath;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;
 
@@ -589,7 +597,7 @@ public class GatewayAdminTopologyFuncTest {
   }
 
   @Test( timeout = TestUtils.LONG_TIMEOUT )
-  public void testPutTopology() throws ClassNotFoundException {
+  public void testPutTopology() throws Exception {
     LOG_ENTER() ;
 
     String username = "admin";
@@ -614,8 +622,12 @@ public class GatewayAdminTopologyFuncTest {
         //.log().all()
         .put(url).getBody().asString();
 
+    Document doc = parse( XML );
 
-        given()
+    assertThat( doc, hasXPath( "/topology/gateway/provider[1]/name", containsString( "WebAppSec" ) ) );
+    assertThat( doc, hasXPath( "/topology/gateway/provider[1]/param/name", containsString( "csrf.enabled" ) ) );
+
+    given()
             .auth().preemptive().basic(username, password)
             .header("Accept", MediaType.APPLICATION_XML)
             .expect()
@@ -624,7 +636,6 @@ public class GatewayAdminTopologyFuncTest {
             .get(url)
             .getBody().asString();
 
-
     String XmlPut =
         given()
             .auth().preemptive().basic(username, password)
@@ -817,6 +828,13 @@ public class GatewayAdminTopologyFuncTest {
     LOG_EXIT();
   }
 
+  private Document parse(String xml ) throws IOException, SAXException, ParserConfigurationException {
+    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+    DocumentBuilder builder = factory.newDocumentBuilder();
+    InputSource source = new InputSource( new StringReader( xml ) );
+    return builder.parse( source );
+  }
+
   private static final String CLASS = GatewayAdminTopologyFuncTest.class.getCanonicalName();
 
 }