knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmin...@apache.org
Subject git commit: KNOX-315: Add support for service params in topology file
Date Thu, 20 Mar 2014 04:30:58 GMT
Repository: knox
Updated Branches:
  refs/heads/master 367e849f3 -> edcba96ca


KNOX-315: Add support for service params in topology file


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

Branch: refs/heads/master
Commit: edcba96ca5be22c9253280550bf127aa5b8b7358
Parents: 367e849
Author: Kevin Minder <kevin.minder@hortonworks.com>
Authored: Thu Mar 20 00:30:37 2014 -0400
Committer: Kevin Minder <kevin.minder@hortonworks.com>
Committed: Thu Mar 20 00:30:37 2014 -0400

----------------------------------------------------------------------
 .../apache/hadoop/gateway/GatewayResources.java |  6 ++
 .../ProviderParameterPropertyInterpreter.java   | 10 +--
 .../ServiceParameterPropertyInterpreter.java    | 50 ++++++++++++++
 .../interpreter/ServicePropertyInterpreter.java | 13 ++++
 .../xml/KnoxFormatXmlTopologyRules.java         | 27 +++++++-
 .../gateway/deploy/DeploymentFactoryTest.java   |  5 --
 .../topology/file/FileTopologyProviderTest.java |  6 +-
 .../topology/xml/TopologyRulesModuleTest.java   | 68 ++++++++++++++++++++
 .../service-param-topology-ambari-format.conf   | 51 +++++++++++++++
 .../xml/service-param-topology-knox-format.xml  | 41 ++++++++++++
 .../hadoop/gateway/topology/Provider.java       |  4 +-
 .../hadoop/gateway/topology/ProviderParam.java  | 38 -----------
 .../apache/hadoop/gateway/topology/Service.java | 16 +++++
 .../apache/hadoop/gateway/topology/param.java   | 42 ++++++++++++
 .../deploy/DeploymentFactoryFuncTest.java       | 18 ++----
 pom.xml                                         |  4 +-
 16 files changed, 331 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/edcba96c/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayResources.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayResources.java
b/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayResources.java
index 0f19b2d..558776e 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayResources.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayResources.java
@@ -68,6 +68,12 @@ public interface GatewayResources {
   @Resource( text="Provider parameter value is required." )
   String providerParameterValueIsRequiredError();
 
+  @Resource( text="Service parameter name is required." )
+  String serviceParameterNameIsRequiredError();
+
+  @Resource( text="Service parameter value is required." )
+  String serviceParameterValueIsRequiredError();
+
   @Resource( text="Failed to create keystore directory: {0}" )
   String failedToCreateKeyStoreDirectory( String name );
 

http://git-wip-us.apache.org/repos/asf/knox/blob/edcba96c/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/builder/property/interpreter/ProviderParameterPropertyInterpreter.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/builder/property/interpreter/ProviderParameterPropertyInterpreter.java
b/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/builder/property/interpreter/ProviderParameterPropertyInterpreter.java
index be58b0d..2928a59 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/builder/property/interpreter/ProviderParameterPropertyInterpreter.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/builder/property/interpreter/ProviderParameterPropertyInterpreter.java
@@ -18,8 +18,8 @@ package org.apache.hadoop.gateway.topology.builder.property.interpreter;
 
 import org.apache.hadoop.gateway.GatewayResources;
 import org.apache.hadoop.gateway.i18n.resources.ResourcesFactory;
+import org.apache.hadoop.gateway.topology.Param;
 import org.apache.hadoop.gateway.topology.Provider;
-import org.apache.hadoop.gateway.topology.ProviderParam;
 
 public class ProviderParameterPropertyInterpreter extends AbstractInterpreter {
 
@@ -42,9 +42,9 @@ public class ProviderParameterPropertyInterpreter extends AbstractInterpreter
{
         if (value == null || value.isEmpty()) {
             throw new InterpretException(gatewayResources.providerParameterValueIsRequiredError());
         }
-        ProviderParam providerParam = new ProviderParam();
-        providerParam.setName(token);
-        providerParam.setValue(value);
-        provider.addParam(providerParam);
+        Param param = new Param();
+        param.setName(token);
+        param.setValue(value);
+        provider.addParam( param );
     }
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/edcba96c/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/builder/property/interpreter/ServiceParameterPropertyInterpreter.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/builder/property/interpreter/ServiceParameterPropertyInterpreter.java
b/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/builder/property/interpreter/ServiceParameterPropertyInterpreter.java
new file mode 100644
index 0000000..635fbe7
--- /dev/null
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/builder/property/interpreter/ServiceParameterPropertyInterpreter.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.gateway.topology.builder.property.interpreter;
+
+import org.apache.hadoop.gateway.GatewayResources;
+import org.apache.hadoop.gateway.i18n.resources.ResourcesFactory;
+import org.apache.hadoop.gateway.topology.Param;
+import org.apache.hadoop.gateway.topology.Service;
+
+public class ServiceParameterPropertyInterpreter extends AbstractInterpreter {
+
+    private static GatewayResources gatewayResources = ResourcesFactory.get(GatewayResources.class);
+
+    private Service service;
+
+    public ServiceParameterPropertyInterpreter( Service service ) {
+        if ( service == null) {
+            throw new IllegalArgumentException(gatewayResources.providerIsRequiredError());
+        }
+        this.service = service;
+    }
+
+    @Override
+    public void interpret(String token, String value) throws InterpretException {
+        if (token == null || token.isEmpty()) {
+            throw new InterpretException(gatewayResources.serviceParameterNameIsRequiredError());
+        }
+        if (value == null || value.isEmpty()) {
+            throw new InterpretException(gatewayResources.serviceParameterValueIsRequiredError());
+        }
+        Param param = new Param();
+        param.setName(token);
+        param.setValue(value);
+        service.addParam( param );
+    }
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/edcba96c/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/builder/property/interpreter/ServicePropertyInterpreter.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/builder/property/interpreter/ServicePropertyInterpreter.java
b/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/builder/property/interpreter/ServicePropertyInterpreter.java
index 4175bf4..2c7a88e 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/builder/property/interpreter/ServicePropertyInterpreter.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/builder/property/interpreter/ServicePropertyInterpreter.java
@@ -24,6 +24,7 @@ import org.apache.hadoop.gateway.topology.Topology;
 public class ServicePropertyInterpreter extends AbstractInterpreter {
 
     private static final String SERVICE_URL = "url";
+    private static final String AGGREGATOR_PARAM = "param";
 
     private static GatewayResources gatewayResources = ResourcesFactory.get(GatewayResources.class);
 
@@ -68,7 +69,19 @@ public class ServicePropertyInterpreter extends AbstractInterpreter {
         if (SERVICE_URL.equalsIgnoreCase(nextToken)) {
             service.setUrl( value );
         } else {
+          dotPosition = nextToken.indexOf(DOT);
+          if (dotPosition != -1) {
+            String aggregator = nextToken.substring(0, dotPosition);
+            nextToken = nextToken.substring(dotPosition + 1);
+
+            if (AGGREGATOR_PARAM.equalsIgnoreCase(aggregator)) {
+              new ServiceParameterPropertyInterpreter(service).interpret(nextToken, value);
+            } else {
+              throw new InterpretException(gatewayResources.unsupportedPropertyTokenError(token));
+            }
+          } else {
             throw new InterpretException(gatewayResources.unsupportedPropertyTokenError(token));
+          }
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/edcba96c/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/xml/KnoxFormatXmlTopologyRules.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/xml/KnoxFormatXmlTopologyRules.java
b/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/xml/KnoxFormatXmlTopologyRules.java
index 63a35be..7992e0f 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/xml/KnoxFormatXmlTopologyRules.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/xml/KnoxFormatXmlTopologyRules.java
@@ -17,11 +17,13 @@
  */
 package org.apache.hadoop.gateway.topology.xml;
 
+import org.apache.commons.digester3.Rule;
 import org.apache.commons.digester3.binder.AbstractRulesModule;
+import org.apache.hadoop.gateway.topology.Param;
 import org.apache.hadoop.gateway.topology.Provider;
-import org.apache.hadoop.gateway.topology.ProviderParam;
 import org.apache.hadoop.gateway.topology.Service;
 import org.apache.hadoop.gateway.topology.builder.BeanPropertyTopologyBuilder;
+import org.xml.sax.Attributes;
 
 public class KnoxFormatXmlTopologyRules extends AbstractRulesModule {
 
@@ -36,21 +38,42 @@ public class KnoxFormatXmlTopologyRules extends AbstractRulesModule {
   private static final String PARAM_TAG = "param";
   private static final String VALUE_TAG = "value";
 
+  private static final Rule paramRule = new ParamRule();
   @Override
   protected void configure() {
     forPattern( ROOT_TAG ).createObject().ofType( BeanPropertyTopologyBuilder.class );
     forPattern( ROOT_TAG + "/" + NAME_TAG ).callMethod("name").usingElementBodyAsArgument();
     forPattern( ROOT_TAG + "/" + VERSION_TAG ).callMethod("version").usingElementBodyAsArgument();
+
     forPattern( ROOT_TAG + "/" + SERVICE_TAG ).createObject().ofType( Service.class ).then().setNext(
"addService" );
     forPattern( ROOT_TAG + "/" + SERVICE_TAG + "/" + ROLE_TAG ).setBeanProperty();
+    forPattern( ROOT_TAG + "/" + SERVICE_TAG + "/" + NAME_TAG ).setBeanProperty();
     forPattern( ROOT_TAG + "/" + SERVICE_TAG + "/" + URL_TAG ).setBeanProperty();
+    forPattern( ROOT_TAG + "/" + SERVICE_TAG + "/" + PARAM_TAG ).createObject().ofType( Param.class
).then().addRule( paramRule ).then().setNext( "addParam" );
+    forPattern( ROOT_TAG + "/" + SERVICE_TAG + "/" + PARAM_TAG + "/" + NAME_TAG ).setBeanProperty();
+    forPattern( ROOT_TAG + "/" + SERVICE_TAG + "/" + PARAM_TAG + "/" + VALUE_TAG ).setBeanProperty();
+
     forPattern( ROOT_TAG + "/" + PROVIDER_TAG ).createObject().ofType( Provider.class ).then().setNext(
"addProvider" );
     forPattern( ROOT_TAG + "/" + PROVIDER_TAG + "/" + ROLE_TAG ).setBeanProperty();
     forPattern( ROOT_TAG + "/" + PROVIDER_TAG + "/" + ENABLED_TAG ).setBeanProperty();
     forPattern( ROOT_TAG + "/" + PROVIDER_TAG + "/" + NAME_TAG ).setBeanProperty();
-    forPattern( ROOT_TAG + "/" + PROVIDER_TAG + "/" + PARAM_TAG ).createObject().ofType(
ProviderParam.class ).then().setNext( "addParam" );
+    forPattern( ROOT_TAG + "/" + PROVIDER_TAG + "/" + PARAM_TAG ).createObject().ofType(
Param.class ).then().addRule( paramRule ).then().setNext( "addParam" );
     forPattern( ROOT_TAG + "/" + PROVIDER_TAG + "/" + PARAM_TAG + "/" + NAME_TAG ).setBeanProperty();
     forPattern( ROOT_TAG + "/" + PROVIDER_TAG + "/" + PARAM_TAG + "/" + VALUE_TAG ).setBeanProperty();
   }
 
+  private static class ParamRule extends Rule {
+
+    @Override
+    public void begin( String namespace, String name, Attributes attributes ) {
+      Param param = getDigester().peek();
+      String paramName = attributes.getValue( "name" );
+      if( paramName != null ) {
+        param.setName( paramName );
+        param.setValue( attributes.getValue( "value" ) );
+      }
+    }
+
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/edcba96c/gateway-server/src/test/java/org/apache/hadoop/gateway/deploy/DeploymentFactoryTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/hadoop/gateway/deploy/DeploymentFactoryTest.java
b/gateway-server/src/test/java/org/apache/hadoop/gateway/deploy/DeploymentFactoryTest.java
index 08d5c4b..8669b2e 100644
--- a/gateway-server/src/test/java/org/apache/hadoop/gateway/deploy/DeploymentFactoryTest.java
+++ b/gateway-server/src/test/java/org/apache/hadoop/gateway/deploy/DeploymentFactoryTest.java
@@ -19,12 +19,8 @@ package org.apache.hadoop.gateway.deploy;
 
 import org.apache.hadoop.gateway.config.GatewayConfig;
 import org.apache.hadoop.gateway.config.impl.GatewayConfigImpl;
-import org.apache.hadoop.gateway.topology.Provider;
-import org.apache.hadoop.gateway.topology.ProviderParam;
-import org.apache.hadoop.gateway.topology.Service;
 import org.apache.hadoop.gateway.topology.Topology;
 import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
@@ -35,7 +31,6 @@ import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.URL;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.IsEqual.equalTo;

http://git-wip-us.apache.org/repos/asf/knox/blob/edcba96c/gateway-server/src/test/java/org/apache/hadoop/gateway/topology/file/FileTopologyProviderTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/hadoop/gateway/topology/file/FileTopologyProviderTest.java
b/gateway-server/src/test/java/org/apache/hadoop/gateway/topology/file/FileTopologyProviderTest.java
index 5accbcd..2e20376 100644
--- a/gateway-server/src/test/java/org/apache/hadoop/gateway/topology/file/FileTopologyProviderTest.java
+++ b/gateway-server/src/test/java/org/apache/hadoop/gateway/topology/file/FileTopologyProviderTest.java
@@ -40,8 +40,8 @@ import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.monitor.FileAlterationMonitor;
 import org.apache.commons.io.monitor.FileAlterationObserver;
+import org.apache.hadoop.gateway.topology.Param;
 import org.apache.hadoop.gateway.topology.Provider;
-import org.apache.hadoop.gateway.topology.ProviderParam;
 import org.apache.hadoop.gateway.topology.Topology;
 import org.apache.hadoop.gateway.topology.TopologyEvent;
 import org.apache.hadoop.gateway.topology.TopologyListener;
@@ -173,9 +173,9 @@ public class FileTopologyProviderTest {
         "ldapGroupRealm.contextFactory.systemAuthenticationMechanism"
     };
     
-    ProviderParam param = null;
+    Param param = null;
     for (String name : names) {
-      param = new ProviderParam();
+      param = new Param();
       param.setName(name);
       param.setValue(name);
       provider.addParam(param);

http://git-wip-us.apache.org/repos/asf/knox/blob/edcba96c/gateway-server/src/test/java/org/apache/hadoop/gateway/topology/xml/TopologyRulesModuleTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/hadoop/gateway/topology/xml/TopologyRulesModuleTest.java
b/gateway-server/src/test/java/org/apache/hadoop/gateway/topology/xml/TopologyRulesModuleTest.java
index ee9643d..b32a338 100644
--- a/gateway-server/src/test/java/org/apache/hadoop/gateway/topology/xml/TopologyRulesModuleTest.java
+++ b/gateway-server/src/test/java/org/apache/hadoop/gateway/topology/xml/TopologyRulesModuleTest.java
@@ -34,6 +34,7 @@ import java.net.URISyntaxException;
 import java.net.URL;
 
 import static org.apache.commons.digester3.binder.DigesterLoader.newLoader;
+import static org.hamcrest.collection.IsMapContaining.hasEntry;
 import static org.hamcrest.core.Is.is;
 import static org.hamcrest.core.IsNull.notNullValue;
 import static org.hamcrest.core.IsNull.nullValue;
@@ -81,6 +82,39 @@ public class TopologyRulesModuleTest {
   }
 
   @Test
+  public void testParseServiceParamsInKnoxFormat() throws IOException, SAXException {
+    Digester digester = loader.newDigester();
+    String name = "org/apache/hadoop/gateway/topology/xml/service-param-topology-knox-format.xml";
+    URL url = ClassLoader.getSystemResource( name );
+    assertThat( "Failed to find URL for resource " + name, url, notNullValue() );
+    File file = new File( url.getFile() );
+    TopologyBuilder topologyBuilder = digester.parse( url );
+    Topology topology = topologyBuilder.build();
+    assertThat( "Failed to parse resource " + name, topology, notNullValue() );
+    topology.setTimestamp( file.lastModified() );
+
+    assertThat( topology.getName(), is( "test-topology-name" ) );
+    assertThat( topology.getTimestamp(), is( file.lastModified() ) );
+    assertThat( topology.getServices().size(), is( 1 ) );
+
+    Provider provider = topology.getProviders().iterator().next();
+    assertThat( provider, notNullValue() );
+    assertThat( provider.getRole(), is( "test-provider-role" ) );
+    assertThat( provider.getName(), is( "test-provider-name" ) );
+    assertThat( provider.getParams(), hasEntry( is( "test-provider-param-name-1" ), is( "test-provider-param-value-1"
) ) );
+    assertThat( provider.getParams(), hasEntry( is( "test-provider-param-name-2" ), is( "test-provider-param-value-2"
) ) );
+
+    Service service = topology.getServices().iterator().next();
+    assertThat( service, notNullValue() );
+    assertThat( service.getRole(), is( "test-service-role" ) );
+    assertThat( service.getUrl(), is( "test-service-scheme://test-service-host:42/test-service-path"
) );
+    assertThat( service.getName(), is( "test-service-name" ) );
+    assertThat( service.getParams(), hasEntry( is( "test-service-param-name-1" ), is( "test-service-param-value-1"
) ) );
+    assertThat( service.getParams(), hasEntry( is( "test-service-param-name-2" ), is( "test-service-param-value-2"
) ) );
+  }
+
+
+  @Test
   public void testParseSimpleTopologyXmlInHadoopFormat() throws IOException, SAXException,
URISyntaxException {
     Digester digester = loader.newDigester();
     String name = "org/apache/hadoop/gateway/topology/xml/simple-topology-ambari-format.conf";
@@ -138,4 +172,38 @@ public class TopologyRulesModuleTest {
     assertThat( identityAssertionProvider.getParams().get("name"), is( "user.name" ) );
   }
 
+  @Test
+  public void testParseServiceParamsInAmbariFormat() throws IOException, SAXException {
+    Digester digester = loader.newDigester();
+    String name = "org/apache/hadoop/gateway/topology/xml/service-param-topology-ambari-format.conf";
+    URL url = ClassLoader.getSystemResource( name );
+    assertThat( "Failed to find URL for resource " + name, url, notNullValue() );
+    File file = new File( url.getFile() );
+    TopologyBuilder topologyBuilder = digester.parse( url );
+    Topology topology = topologyBuilder.build();
+    assertThat( "Failed to parse resource " + name, topology, notNullValue() );
+    topology.setTimestamp( file.lastModified() );
+
+    assertThat( topology.getName(), is( "test-topology-name" ) );
+    assertThat( topology.getTimestamp(), is( file.lastModified() ) );
+
+    assertThat( topology.getProviders().size(), is( 1 ) );
+    Provider provider = topology.getProviders().iterator().next();
+    assertThat( provider, notNullValue() );
+    assertThat( provider.getRole(), is( "test-provider-role" ) );
+    assertThat( provider.getName(), is( "test-provider-name" ) );
+    assertThat( provider.isEnabled(), is( true ) );
+    assertThat( provider.getParams(), hasEntry( is( "test-provider-param-name-1" ), is( "test-provider-param-value-1"
) ) );
+    assertThat( provider.getParams(), hasEntry( is( "test-provider-param-name-2" ), is( "test-provider-param-value-2"
) ) );
+
+    assertThat( topology.getServices().size(), is( 1 ) );
+    Service service = topology.getServices().iterator().next();
+    assertThat( service, notNullValue() );
+    assertThat( service.getRole(), is( "test-service-role" ) );
+    assertThat( service.getUrl(), is( "test-service-scheme://test-service-host:42/test-service-path"
) );
+    assertThat( service.getName(), is( "test-service-name" ) );
+    assertThat( service.getParams(), hasEntry( is( "test-service-param-name-1" ), is( "test-service-param-value-1"
) ) );
+    assertThat( service.getParams(), hasEntry( is( "test-service-param-name-2" ), is( "test-service-param-value-2"
) ) );
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/edcba96c/gateway-server/src/test/resources/org/apache/hadoop/gateway/topology/xml/service-param-topology-ambari-format.conf
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/resources/org/apache/hadoop/gateway/topology/xml/service-param-topology-ambari-format.conf
b/gateway-server/src/test/resources/org/apache/hadoop/gateway/topology/xml/service-param-topology-ambari-format.conf
new file mode 100644
index 0000000..e1622c9
--- /dev/null
+++ b/gateway-server/src/test/resources/org/apache/hadoop/gateway/topology/xml/service-param-topology-ambari-format.conf
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  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.
+-->
+<configuration>
+
+    <property>
+        <name>topology.name</name>
+        <value>test-topology-name</value>
+    </property>
+
+    <property>
+        <name>topology.gateway.provider.test-provider-role.test-provider-name.enabled</name>
+        <value>true</value>
+    </property>
+    <property>
+        <name>topology.gateway.provider.test-provider-role.test-provider-name.param.test-provider-param-name-1</name>
+        <value>test-provider-param-value-1</value>
+    </property>
+    <property>
+        <name>topology.gateway.provider.test-provider-role.test-provider-name.param.test-provider-param-name-2</name>
+        <value>test-provider-param-value-2</value>
+    </property>
+
+    <property>
+        <name>topology.service.test-service-role.test-service-name.url</name>
+        <value>test-service-scheme://test-service-host:42/test-service-path</value>
+    </property>
+    <property>
+        <name>topology.service.test-service-role.test-service-name.param.test-service-param-name-1</name>
+        <value>test-service-param-value-1</value>
+    </property>
+    <property>
+        <name>topology.service.test-service-role.test-service-name.param.test-service-param-name-2</name>
+        <value>test-service-param-value-2</value>
+    </property>
+
+</configuration>

http://git-wip-us.apache.org/repos/asf/knox/blob/edcba96c/gateway-server/src/test/resources/org/apache/hadoop/gateway/topology/xml/service-param-topology-knox-format.xml
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/resources/org/apache/hadoop/gateway/topology/xml/service-param-topology-knox-format.xml
b/gateway-server/src/test/resources/org/apache/hadoop/gateway/topology/xml/service-param-topology-knox-format.xml
new file mode 100644
index 0000000..9443811
--- /dev/null
+++ b/gateway-server/src/test/resources/org/apache/hadoop/gateway/topology/xml/service-param-topology-knox-format.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  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>
+    <name>test-topology-name</name>
+    <gateway>
+        <provider>
+            <role>test-provider-role</role>
+            <name>test-provider-name</name>
+            <param>
+                <name>test-provider-param-name-1</name>
+                <value>test-provider-param-value-1</value>
+            </param>
+            <param name="test-provider-param-name-2" value="test-provider-param-value-2"/>
+        </provider>
+    </gateway>
+    <service>
+        <role>test-service-role</role>
+        <name>test-service-name</name>
+        <url>test-service-scheme://test-service-host:42/test-service-path</url>
+        <param>
+            <name>test-service-param-name-1</name>
+            <value>test-service-param-value-1</value>
+        </param>
+        <param name="test-service-param-name-2" value="test-service-param-value-2"/>
+    </service>
+</topology>

http://git-wip-us.apache.org/repos/asf/knox/blob/edcba96c/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 0a771ea..2a47e5c 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
@@ -21,6 +21,7 @@ import java.util.LinkedHashMap;
 import java.util.Map;
 
 public class Provider {
+
   private String role;
   private String name;
   private boolean enabled;
@@ -53,7 +54,7 @@ public class Provider {
     this.params = params;
   }
 
-  public void addParam(ProviderParam param) {
+  public void addParam(Param param) {
     params.put(param.getName(), param.getValue());
   }
 
@@ -64,4 +65,5 @@ public class Provider {
   public void setRole( String role ) {
     this.role = role;
   }
+
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/edcba96c/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/ProviderParam.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/ProviderParam.java
b/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/ProviderParam.java
deleted file mode 100644
index 61872f2..0000000
--- a/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/ProviderParam.java
+++ /dev/null
@@ -1,38 +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.topology;
-
-public class ProviderParam {
-  private String name;
-  private String 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/edcba96c/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 24bba52..7d3dcb6 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
@@ -17,10 +17,14 @@
  */
 package org.apache.hadoop.gateway.topology;
 
+import java.util.LinkedHashMap;
+import java.util.Map;
+
 public class Service {
 
   private String role;
   private String name;
+  private Map<String, String> params = new LinkedHashMap<String, String>();
 
   public String getRole() {
     return role;
@@ -48,4 +52,16 @@ public class Service {
     this.url = url;
   }
 
+  public Map<String, String> getParams() {
+    return params;
+  }
+
+  public void setParams(Map<String, String> params) {
+    this.params = params;
+  }
+
+  public void addParam( Param param ) {
+    params.put(param.getName(), param.getValue());
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/edcba96c/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
new file mode 100644
index 0000000..704b0bb
--- /dev/null
+++ b/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/param.java
@@ -0,0 +1,42 @@
+/**
+ * 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.topology;
+
+public class Param {
+
+  private String name;
+  private String 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/edcba96c/gateway-test/src/test/java/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest.java
b/gateway-test/src/test/java/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest.java
index 56862db..c0fe416 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest.java
@@ -21,8 +21,8 @@ import org.apache.hadoop.gateway.GatewayTestConfig;
 import org.apache.hadoop.gateway.config.GatewayConfig;
 import org.apache.hadoop.gateway.services.DefaultGatewayServices;
 import org.apache.hadoop.gateway.services.ServiceLifecycleException;
+import org.apache.hadoop.gateway.topology.Param;
 import org.apache.hadoop.gateway.topology.Provider;
-import org.apache.hadoop.gateway.topology.ProviderParam;
 import org.apache.hadoop.gateway.topology.Service;
 import org.apache.hadoop.gateway.topology.Topology;
 import org.apache.hadoop.test.log.NoOpAppender;
@@ -36,16 +36,10 @@ import org.xml.sax.SAXException;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.StringWriter;
 import java.net.URISyntaxException;
 import java.util.Enumeration;
 import java.util.HashMap;
@@ -95,11 +89,11 @@ public class DeploymentFactoryFuncTest {
     provider.setRole( "authentication" );
     provider.setName( "generic" );
     provider.setEnabled( true );
-    ProviderParam param = new ProviderParam();
+    Param param = new Param();
     param.setName( "filter" );
     param.setValue( "org.opensource.ExistingFilter" );
     provider.addParam( param );
-    param = new ProviderParam();
+    param = new Param();
     param.setName( "test-param-name" );
     param.setValue( "test-param-value" );
     provider.addParam( param );
@@ -149,12 +143,12 @@ public class DeploymentFactoryFuncTest {
     provider.setRole( "authentication" );
     provider.setName( "generic" );
     provider.setEnabled( true );
-    ProviderParam param; // = new ProviderParam();
+    Param param; // = new ProviderParam();
     // Missing filter param.
     //param.setName( "filter" );
     //param.setValue( "org.opensource.ExistingFilter" );
     //provider.addParam( param );
-    param = new ProviderParam();
+    param = new Param();
     param.setName( "test-param-name" );
     param.setValue( "test-param-value" );
     provider.addParam( param );
@@ -201,7 +195,7 @@ public class DeploymentFactoryFuncTest {
     Provider provider = new Provider();
     provider.setRole( "authentication" );
     provider.setEnabled( true );
-    ProviderParam param = new ProviderParam();
+    Param param = new Param();
     param.setName( "contextConfigLocation" );
     param.setValue( "classpath:app-context-security.xml" );
     provider.addParam( param );

http://git-wip-us.apache.org/repos/asf/knox/blob/edcba96c/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 8da63c1..d99c952 100644
--- a/pom.xml
+++ b/pom.xml
@@ -871,13 +871,13 @@
             <dependency>
                 <groupId>org.hamcrest</groupId>
                 <artifactId>hamcrest-core</artifactId>
-                <version>1.2.1</version>
+                <version>1.3</version>
                 <scope>test</scope>
             </dependency>
             <dependency>
                 <groupId>org.hamcrest</groupId>
                 <artifactId>hamcrest-library</artifactId>
-                <version>1.2.1</version>
+                <version>1.3</version>
                 <scope>test</scope>
             </dependency>
             <dependency>


Mime
View raw message