You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ga...@apache.org on 2015/12/07 11:19:48 UTC

[19/50] [abbrv] stratos git commit: Throw MetadataException on failures in MetadataApiRegistry (instead of RegistryException coming from Carbon)

Throw MetadataException on failures in MetadataApiRegistry (instead of RegistryException coming from Carbon)


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

Branch: refs/heads/release-4.1.5
Commit: 8c615acbaed06b6f489f9660f144960da2d4663f
Parents: 3a31c1c
Author: Akila Perera <ra...@gmail.com>
Authored: Mon Nov 30 00:22:40 2015 +0530
Committer: gayangunarathne <ga...@wso2.com>
Committed: Mon Dec 7 10:16:26 2015 +0000

----------------------------------------------------------------------
 .../metadata/service/registry/DataStore.java    | 21 ++++++-----
 .../service/registry/MetadataApiRegistry.java   | 37 ++++++++++----------
 2 files changed, 31 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/8c615acb/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/DataStore.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/DataStore.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/DataStore.java
index a71c745..20ae1ac 100644
--- a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/DataStore.java
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/DataStore.java
@@ -18,8 +18,8 @@
  */
 package org.apache.stratos.metadata.service.registry;
 
-
 import org.apache.stratos.metadata.service.definition.Property;
+import org.apache.stratos.metadata.service.exception.MetadataException;
 import org.wso2.carbon.registry.api.RegistryException;
 
 import java.util.List;
@@ -29,18 +29,21 @@ import java.util.List;
  */
 public interface DataStore {
 
-    public void addPropertyToApplication(String applicationId, Property property) throws RegistryException;
+    public void addPropertyToApplication(String applicationId, Property property)
+            throws RegistryException, MetadataException;
 
-    public List<Property> getApplicationProperties(String applicationId) throws RegistryException;
+    public List<Property> getApplicationProperties(String applicationId) throws MetadataException;
 
-    public List<Property> getClusterProperties(String applicationId, String clusterId)
-            throws RegistryException;
+    public List<Property> getClusterProperties(String applicationId, String clusterId) throws MetadataException;
 
-    public void addPropertyToCluster(String applicationId, String clusterId, Property property) throws RegistryException;
+    public void addPropertyToCluster(String applicationId, String clusterId, Property property)
+            throws RegistryException, MetadataException;
 
-    public boolean deleteApplicationProperties(String applicationId) throws RegistryException;
+    public boolean deleteApplicationProperties(String applicationId) throws RegistryException, MetadataException;
 
-    public boolean removePropertyFromApplication(String applicationId, String propertyName) throws RegistryException;
+    public boolean removePropertyFromApplication(String applicationId, String propertyName)
+            throws RegistryException, MetadataException;
 
-    public boolean removePropertyValueFromApplication(String applicationId, String propertyName, String valueToRemove) throws RegistryException;
+    public boolean removePropertyValueFromApplication(String applicationId, String propertyName, String valueToRemove)
+            throws RegistryException, MetadataException;
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/8c615acb/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/MetadataApiRegistry.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/MetadataApiRegistry.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/MetadataApiRegistry.java
index 11d1468..75ddbc7 100644
--- a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/MetadataApiRegistry.java
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/MetadataApiRegistry.java
@@ -67,9 +67,9 @@ public class MetadataApiRegistry implements DataStore {
      *
      * @param applicationId Application ID under which properties should be retrieved
      * @return List of properties
-     * @throws RegistryException
+     * @throws MetadataException
      */
-    public List<Property> getApplicationProperties(String applicationId) throws RegistryException {
+    public List<Property> getApplicationProperties(String applicationId) throws MetadataException {
         String resourcePath = mainResource + applicationId;
         try {
             acquireReadLock(applicationId);
@@ -79,7 +79,7 @@ public class MetadataApiRegistry implements DataStore {
                     .format("Failed to get properties from registry [resource-path] %s for " + "[application-id] %s",
                             resourcePath, applicationId);
             log.error(msg, e);
-            throw new RegistryException(msg, e);
+            throw new MetadataException(msg, e);
         } finally {
             try {
                 releaseReadLock(applicationId);
@@ -94,9 +94,9 @@ public class MetadataApiRegistry implements DataStore {
      * @param applicationId Application ID under which properties should be retrieved
      * @param clusterId     Cluster ID under which properties should be retrieved
      * @return List of properties
-     * @throws RegistryException
+     * @throws MetadataException
      */
-    public List<Property> getClusterProperties(String applicationId, String clusterId) throws RegistryException {
+    public List<Property> getClusterProperties(String applicationId, String clusterId) throws MetadataException {
         String resourcePath = mainResource + applicationId + "/" + clusterId;
         try {
             acquireReadLock(applicationId);
@@ -105,7 +105,7 @@ public class MetadataApiRegistry implements DataStore {
             String msg = String.format("Failed to get properties from registry [resource-path] %s for [application-id] "
                     + "%s, [cluster-id] %s", resourcePath, applicationId, clusterId);
             log.error(msg, e);
-            throw new RegistryException(msg, e);
+            throw new MetadataException(msg, e);
         } finally {
             try {
                 releaseReadLock(applicationId);
@@ -143,7 +143,8 @@ public class MetadataApiRegistry implements DataStore {
         return newProperties;
     }
 
-    public void addPropertyToApplication(String applicationId, Property property) throws RegistryException {
+    public void addPropertyToApplication(String applicationId, Property property)
+            throws RegistryException, MetadataException {
         Registry registry = getRegistry();
         String resourcePath = mainResource + applicationId;
 
@@ -192,7 +193,7 @@ public class MetadataApiRegistry implements DataStore {
                     .format("Failed to persist properties in registry: [resource-path] %s, [key] %s, [values] %s",
                             resourcePath, property.getKey(), Arrays.asList(property.getValues()));
             log.error(msg, e);
-            throw new RegistryException(msg, e);
+            throw new MetadataException(msg, e);
         } finally {
             try {
                 releaseWriteLock(applicationId);
@@ -208,7 +209,7 @@ public class MetadataApiRegistry implements DataStore {
     }
 
     public boolean removePropertyValueFromApplication(String applicationId, String propertyKey, String valueToRemove)
-            throws RegistryException {
+            throws RegistryException, MetadataException {
         Registry registry = getRegistry();
         String resourcePath = mainResource + applicationId;
 
@@ -233,7 +234,7 @@ public class MetadataApiRegistry implements DataStore {
                             propertyKey, valueToRemove));
             return true;
         } catch (Exception e) {
-            throw new RegistryException(
+            throw new MetadataException(
                     String.format("Could not remove registry resource: [resource-path] %s, [key] %s, [value] %s",
                             resourcePath, propertyKey, valueToRemove), e);
         } finally {
@@ -250,10 +251,10 @@ public class MetadataApiRegistry implements DataStore {
      * @param applicationId Application ID against which added property will be stored
      * @param clusterId     Cluster ID against which added property will be stored
      * @param property      Property to be stored in the registry
-     * @throws RegistryException
+     * @throws RegistryException, MetadataException
      */
     public void addPropertyToCluster(String applicationId, String clusterId, Property property)
-            throws RegistryException {
+            throws RegistryException, MetadataException {
         Registry registry = getRegistry();
         String resourcePath = mainResource + applicationId + "/" + clusterId;
 
@@ -278,7 +279,7 @@ public class MetadataApiRegistry implements DataStore {
                     "Registry property persisted: [resource-path] %s [Property Name] %s [Property Values] %s",
                     resourcePath, property.getKey(), Arrays.asList(property.getValues())));
         } catch (Exception e) {
-            throw new RegistryException(
+            throw new MetadataException(
                     String.format("Could not add registry resource: [resource-path] %s, [key] %s, [value] %s",
                             resourcePath, property.getKey(), Arrays.asList(property.getValues())), e);
 
@@ -299,9 +300,9 @@ public class MetadataApiRegistry implements DataStore {
      *
      * @param applicationId ID of the application.
      * @return True if resource exist and able to delete, else false.
-     * @throws RegistryException
+     * @throws RegistryException, MetadataException
      */
-    public boolean deleteApplicationProperties(String applicationId) throws RegistryException {
+    public boolean deleteApplicationProperties(String applicationId) throws RegistryException, MetadataException {
         if (StringUtils.isBlank(applicationId)) {
             throw new IllegalArgumentException("Application ID can not be null");
         }
@@ -320,7 +321,7 @@ public class MetadataApiRegistry implements DataStore {
             }
             return true;
         } catch (Exception e) {
-            throw new RegistryException(
+            throw new MetadataException(
                     String.format("Could not remove registry resource: [resource-path] %s", resourcePath), e);
         } finally {
             try {
@@ -331,7 +332,7 @@ public class MetadataApiRegistry implements DataStore {
     }
 
     public boolean removePropertyFromApplication(String applicationId, String propertyKey)
-            throws org.wso2.carbon.registry.api.RegistryException {
+            throws RegistryException, MetadataException {
         Registry registry = getRegistry();
         String resourcePath = mainResource + applicationId;
         Resource nodeResource;
@@ -361,7 +362,7 @@ public class MetadataApiRegistry implements DataStore {
                     propertyKey));
             return true;
         } catch (Exception e) {
-            throw new RegistryException(
+            throw new MetadataException(
                     String.format("Could not remove registry resource: [resource-path] %s, [key] %s", resourcePath,
                             propertyKey), e);
         } finally {