Browse Source

AMBARI-9495. Call to save configs of different services together should 400 return code not 500 (aonishuk)

Andrew Onishuk 10 years ago
parent
commit
c52f70bcfd

+ 2 - 2
ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java

@@ -279,7 +279,7 @@ public interface Cluster {
    * @return <code>true</code> if the config was added, or <code>false</code>
    * if the config is already set as the current
    */
-  public ServiceConfigVersionResponse addDesiredConfig(String user, Set<Config> configs) throws AmbariException;
+  public ServiceConfigVersionResponse addDesiredConfig(String user, Set<Config> configs);
 
   /**
    * Adds and sets a DESIRED configuration to be applied to a cluster.  There
@@ -290,7 +290,7 @@ public interface Cluster {
    * @return <code>true</code> if the config was added, or <code>false</code>
    * if the config is already set as the current
    */
-  ServiceConfigVersionResponse addDesiredConfig(String user, Set<Config> configs, String serviceConfigVersionNote) throws AmbariException;
+  ServiceConfigVersionResponse addDesiredConfig(String user, Set<Config> configs, String serviceConfigVersionNote);
 
   ServiceConfigVersionResponse createServiceConfigVersion(String serviceName, String user, String note,
                                                           ConfigGroup configGroup);

+ 4 - 4
ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java

@@ -1753,12 +1753,12 @@ public class ClusterImpl implements Cluster {
   }
 
   @Override
-  public ServiceConfigVersionResponse addDesiredConfig(String user, Set<Config> configs) throws AmbariException {
+  public ServiceConfigVersionResponse addDesiredConfig(String user, Set<Config> configs) {
     return addDesiredConfig(user, configs, null);
   }
 
   @Override
-  public ServiceConfigVersionResponse addDesiredConfig(String user, Set<Config> configs, String serviceConfigVersionNote) throws AmbariException {
+  public ServiceConfigVersionResponse addDesiredConfig(String user, Set<Config> configs, String serviceConfigVersionNote) {
     if (null == user) {
       throw new NullPointerException("User must be specified.");
     }
@@ -2161,7 +2161,7 @@ public class ClusterImpl implements Cluster {
   }
 
   @Transactional
-  ServiceConfigVersionResponse applyConfigs(Set<Config> configs, String user, String serviceConfigVersionNote) throws AmbariException {
+  ServiceConfigVersionResponse applyConfigs(Set<Config> configs, String user, String serviceConfigVersionNote) {
 
     String serviceName = null;
     for (Config config : configs) {
@@ -2173,7 +2173,7 @@ public class ClusterImpl implements Cluster {
           } else if (!serviceName.equals(entry.getKey())) {
             String error = "Updating configs for multiple services by a " +
                 "single API request isn't supported";
-            AmbariException exception = new AmbariException(error);
+            IllegalArgumentException exception = new IllegalArgumentException(error);
             LOG.error(error + ", config version not created");
             throw exception;
           } else {

+ 2 - 2
ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java

@@ -388,7 +388,7 @@ public class ClusterTest {
 
 
   @Test
-  public void testGetAndSetConfigs() throws AmbariException {
+  public void testGetAndSetConfigs() {
 
     Map<String, Map<String, String>> c1PropAttributes = new HashMap<String, Map<String,String>>();
     c1PropAttributes.put("final", new HashMap<String, String>());
@@ -724,7 +724,7 @@ public class ClusterTest {
   }
 
   @Test
-  public void testSingleServiceVersionForMultipleConfigs() throws AmbariException {
+  public void testSingleServiceVersionForMultipleConfigs() {
     Config config1 = configFactory.createNew(c1, "hdfs-site",
       new HashMap<String, String>() {{ put("a", "b"); }}, new HashMap<String, Map<String,String>>());
     config1.setTag("version1");

+ 1 - 1
ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java

@@ -1061,7 +1061,7 @@ public class ServiceComponentHostTest {
    * @param tag the config tag
    * @param values the values for the config
    */
-  private void makeConfig(Cluster cluster, String type, String tag, Map<String, String> values, Map<String, Map<String, String>> attributes) throws AmbariException {
+  private void makeConfig(Cluster cluster, String type, String tag, Map<String, String> values, Map<String, Map<String, String>> attributes) {
     Config config = configFactory.createNew(cluster, type, values, attributes);
     config.setTag(tag);
     config.persist();