You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ud...@apache.org on 2014/10/07 14:18:04 UTC
[02/10] git commit: refactor metadata rest api
refactor metadata rest api
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/fc233a05
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/fc233a05
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/fc233a05
Branch: refs/heads/4.0.0-grouping
Commit: fc233a0546ce407425e0a8cdb3c70a8bea12b254
Parents: 45caaf7
Author: Udara Liyanage <ud...@wso2.com>
Authored: Thu Oct 2 17:09:51 2014 +0530
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Thu Oct 2 17:29:11 2014 +0530
----------------------------------------------------------------------
.../registry/CarbonRegistry.java | 178 +------------------
.../metadataservice/registry/DataStore.java | 14 +-
.../metadataservice/registry/GRegRegistry.java | 144 +--------------
.../metadataservice/services/MetaDataAdmin.java | 173 ++----------------
4 files changed, 27 insertions(+), 482 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/fc233a05/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java
index 98377c4..3ae47ce 100644
--- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java
+++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java
@@ -31,7 +31,6 @@ import org.wso2.carbon.core.AbstractAdmin;
import org.wso2.carbon.registry.api.Registry;
import org.wso2.carbon.registry.api.RegistryException;
import org.wso2.carbon.registry.api.Resource;
-import org.wso2.carbon.registry.core.Comment;
import org.wso2.carbon.registry.core.service.RegistryService;
public class CarbonRegistry extends AbstractAdmin implements DataStore {
@@ -48,7 +47,7 @@ public class CarbonRegistry extends AbstractAdmin implements DataStore {
private static final String defaultUsername = "admin@org.com";
private static final String defaultPassword = "admin123";
private static final String serverURL = "https://localhost:9445/services/";
- private static final String mainResource = "/startos/";
+ private static final String mainResource = "/stratos/";
private static final int defaultRank = 3;
private RegistryService registryService;
@@ -56,121 +55,13 @@ public class CarbonRegistry extends AbstractAdmin implements DataStore {
}
- /*
- * Add the meta data to governance registry
- *
- * @see org.apache.stratos.metadataservice.registry.DataStore#
- * addCartridgeMetaDataDetails(java.lang.String, java.lang.String,
- * org.apache.stratos.metadataservice.definition.CartridgeMetaData)
- */
- @Override
- public String addCartridgeMetaDataDetails(String applicationName, String cartridgeType,
- CartridgeMetaData cartridgeMetaData) throws Exception {
- log.debug("Adding meta data details");
-
- Registry tempRegistry = getGovernanceUserRegistry();
- try {
-
- Resource resource = tempRegistry.newResource();
-
- String type = cartridgeMetaData.type;
-
- resource.setContent("Application description :: " + type);
-
- String resourcePath = mainResource + applicationName + "/" + cartridgeType;
-
- resource.addProperty("Application Name", cartridgeMetaData.applicationName);
- resource.addProperty("Display Name", cartridgeMetaData.displayName);
- resource.addProperty("Description", cartridgeMetaData.description);
- resource.addProperty("Cartidge Type", cartridgeMetaData.type);
- resource.addProperty("provider", cartridgeMetaData.provider);
- resource.addProperty("Version", cartridgeMetaData.version);
- resource.addProperty("host", cartridgeMetaData.host);
-
- for (PropertyBean prop : cartridgeMetaData.properties) {
- resource.addProperty("hostname", prop.hostname);
- resource.addProperty("username", prop.username);
- resource.addProperty("password", prop.password);
- }
-
- tempRegistry.put(resourcePath, resource);
-
- if(log.isDebugEnabled()){
- log.debug("A resource added to: " + resourcePath);
- }
-
- Comment comment = new Comment();
- comment.setText("Added the " + applicationName + " " + type + " cartridge");
- // registry.addComment(resourcePath, comment);
-
- } catch (Exception e) {
- if (log.isErrorEnabled()) {
- log.error("addCartridgeMetaDataDetails", e);
- }
- } finally {
- // Close the session
-
- }
-
- return "success";
- }
-
- /*
- * Get the meta data from the registry
- *
- * @see org.apache.stratos.metadataservice.registry.DataStore#
- * getCartridgeMetaDataDetails(java.lang.String, java.lang.String)
- */
- @Override
- public String getCartridgeMetaDataDetails(String applicationName, String cartridgeType)
- throws Exception {
- Registry registry = getGovernanceUserRegistry();
- CartridgeMetaData cartridgeMetaData = new CartridgeMetaData();
- try {
-
- String resourcePath = mainResource + applicationName + "/" + cartridgeType;
- if (registry.resourceExists(resourcePath)) {
-
- Resource getResource = registry.get(resourcePath);
-
- cartridgeMetaData.type = getResource.getProperty("Cartidge Type");
- cartridgeMetaData.applicationName = getResource.getProperty("Application Name");
- cartridgeMetaData.description = getResource.getProperty("Description");
- cartridgeMetaData.displayName = getResource.getProperty("Display Name");
- cartridgeMetaData.host = getResource.getProperty("host");
- cartridgeMetaData.provider = getResource.getProperty("provider");
- cartridgeMetaData.version = getResource.getProperty("Version");
-
- List<PropertyBean> lst = new ArrayList<PropertyBean>();
- PropertyBean prop = new PropertyBean();
- prop.hostname = getResource.getProperty("hostname");
- prop.username = getResource.getProperty("username");
- prop.password = getResource.getProperty("password");
- lst.add(prop);
-
- cartridgeMetaData.properties = lst;
-
- }
-
- } catch (Exception e) {
-
- if (log.isErrorEnabled()) {
- log.error("getCartridgeMetaDataDetails", e);
- }
- } finally {
- // Close the session
-
- }
- return cartridgeMetaData.toString();
- }
-
- /*
- *
- * Remove the meta data from the registry
- *
- * @see org.apache.stratos.metadataservice.registry.DataStore#
- * removeCartridgeMetaDataDetails(java.lang.String, java.lang.String)
- */
+ /*
+ *
+ * Remove the meta data from the registry
+ *
+ * @see org.apache.stratos.metadataservice.registry.DataStore#
+ * removeCartridgeMetaDataDetails(java.lang.String, java.lang.String)
+ */
@Override
public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType)
throws Exception {
@@ -243,59 +134,6 @@ public class CarbonRegistry extends AbstractAdmin implements DataStore {
log.info(String.format("Properties are added to cluster %s of application %s", clusterId, applicationName));
}
- public void addPropertiesToApplication(String applicationId, NewProperty[] properties) throws RegistryException {
- Registry tempRegistry = getGovernanceUserRegistry();
- String resourcePath = mainResource + applicationId;
- Resource regResource = createOrGetResourceforApplication(tempRegistry, resourcePath);
-
- for(NewProperty property : properties){
- regResource.setProperty(property.getKey(), (Arrays.asList(property.getValues())));
-
- }
- tempRegistry.put(resourcePath, regResource);
- log.info(String.format("Properties are added to application %s", applicationId));
- }
-
- public void addPropertyToApplication(String applicationId, NewProperty property) throws RegistryException {
- Registry tempRegistry = getGovernanceUserRegistry();
- String resourcePath = mainResource + applicationId;
- Resource regResource = createOrGetResourceforApplication(tempRegistry, resourcePath);
- regResource.setProperty(property.getKey(), (Arrays.asList(property.getValues())));
- tempRegistry.put(resourcePath, regResource);
- log.info(String.format("Property %s is added to application %s ", property.getKey(), applicationId));
- }
-
- public List<NewProperty> getPropertiesOfApplication(String applicationId) throws RegistryException {
- Registry tempRegistry = getGovernanceUserRegistry();
- String resourcePath = mainResource + applicationId;
- if(!tempRegistry.resourceExists(resourcePath)){
- return null;
- //throw new RegistryException("Cluster does not exist at " + resourcePath);
- }
- Resource regResource = tempRegistry.get(resourcePath);
-
- ArrayList<NewProperty> newProperties = new ArrayList<NewProperty>();
-
- Properties props = regResource.getProperties();
- Enumeration<?> x = props.propertyNames();
- while(x.hasMoreElements())
- {
- String key = (String) x.nextElement();
- List<String> values = regResource.getPropertyValues(key);
- NewProperty property = new NewProperty();
- property.setKey(key);
- String[] valueArr = new String[values.size()];
- property.setValues(values.toArray(valueArr));
-
- newProperties.add(property);
-
- }
- if(newProperties.size() == 0){
- return null;
- }
- return newProperties;
- }
-
private Resource createOrGetResourceforApplication(Registry tempRegistry, String resourcePath) throws RegistryException {
Resource regResource;
http://git-wip-us.apache.org/repos/asf/stratos/blob/fc233a05/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java
index f7cac25..e1b1218 100644
--- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java
+++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java
@@ -18,8 +18,6 @@
*/
package org.apache.stratos.metadataservice.registry;
-import org.apache.stratos.metadataservice.definition.ApplicationBean;
-import org.apache.stratos.metadataservice.definition.CartridgeMetaData;
import org.apache.stratos.metadataservice.definition.NewProperty;
import org.wso2.carbon.registry.api.RegistryException;
@@ -29,13 +27,8 @@ import java.util.List;
* Interface of the Data Store
*/
public interface DataStore {
- public String addCartridgeMetaDataDetails(String applicationName, String cartridgeType,
- CartridgeMetaData cartridgeMetaData) throws Exception;
- public String getCartridgeMetaDataDetails(String applicationName, String cartridgeType)
- throws Exception;
-
- public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType)
+ public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType)
throws Exception;
public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties)
@@ -45,9 +38,4 @@ public interface DataStore {
public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) throws RegistryException;
- void addPropertiesToApplication(String applicationId, NewProperty[] properties) throws RegistryException;
-
- void addPropertyToApplication(String applicationId, NewProperty property) throws RegistryException;
-
- List<NewProperty> getPropertiesOfApplication(String applicationId) throws RegistryException;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/fc233a05/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java
index c454631..1726d10 100644
--- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java
+++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java
@@ -19,7 +19,6 @@
package org.apache.stratos.metadataservice.registry;
import java.io.File;
-import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
@@ -30,15 +29,10 @@ import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.commons.configuration.XMLConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.metadataservice.definition.ApplicationBean;
-import org.apache.stratos.metadataservice.definition.CartridgeMetaData;
import org.apache.stratos.metadataservice.definition.NewProperty;
-import org.apache.stratos.metadataservice.definition.PropertyBean;
import org.apache.stratos.metadataservice.util.ConfUtil;
import org.wso2.carbon.registry.api.Registry;
import org.wso2.carbon.registry.api.RegistryException;
-import org.wso2.carbon.registry.api.Resource;
-import org.wso2.carbon.registry.core.Comment;
import org.wso2.carbon.registry.ws.client.registry.WSRegistryServiceClient;
/**
@@ -94,125 +88,13 @@ public class GRegRegistry implements DataStore {
return new WSRegistryServiceClient(gregServerURL, gregUsername, gregPassword, configContext);
}
- /*
- * Add the meta data to governance registry
- *
- * @see org.apache.stratos.metadataservice.registry.DataStore#
- * addCartridgeMetaDataDetails(java.lang.String, java.lang.String,
- * org.apache.stratos.metadataservice.definition.CartridgeMetaData)
- */
- @Override
- public String addCartridgeMetaDataDetails(String applicationName, String cartridgeType,
- CartridgeMetaData cartridgeMetaData) throws Exception {
-
- Registry registry = setRegistry();
- try {
-
- Resource resource = registry.newResource();
-
- String type = cartridgeMetaData.type;
-
- resource.setContent("Application description :: " + type);
-
- String resourcePath = mainResource + applicationName + "/" + cartridgeType;
-
- resource.addProperty("Application Name", cartridgeMetaData.applicationName);
- resource.addProperty("Display Name", cartridgeMetaData.displayName);
- resource.addProperty("Description", cartridgeMetaData.description);
- resource.addProperty("Cartidge Type", cartridgeMetaData.type);
- resource.addProperty("provider", cartridgeMetaData.provider);
- resource.addProperty("Version", cartridgeMetaData.version);
- resource.addProperty("host", cartridgeMetaData.host);
-
- for (PropertyBean prop : cartridgeMetaData.properties) {
- resource.addProperty("hostname", prop.hostname);
- resource.addProperty("username", prop.username);
- resource.addProperty("password", prop.password);
- }
-
- registry.put(resourcePath, resource);
-
-
- registry.rateResource(resourcePath, defaultRank);
-
- Comment comment = new Comment();
- comment.setText("Added the " + applicationName + " " + type + " cartridge");
- registry.addComment(resourcePath, comment);
-
- } catch (Exception e) {
-
- if (log.isErrorEnabled()) {
- log.error("addCartridgeMetaDataDetails", e);
- }
- } finally {
- // Close the session
- ((WSRegistryServiceClient) registry).logut();
- }
-
- return "success";
- }
-
- /*
- * Get the meta data from the registry
- *
- * @see org.apache.stratos.metadataservice.registry.DataStore#
- * getCartridgeMetaDataDetails(java.lang.String, java.lang.String)
- */
- @Override
- public String getCartridgeMetaDataDetails(String applicationName, String cartridgeType)
- throws Exception {
- Registry registry = setRegistry();
- CartridgeMetaData cartridgeMetaData = new CartridgeMetaData();
- try {
-
- String resourcePath = mainResource + applicationName + "/" + cartridgeType;
- if (registry.resourceExists(resourcePath)) {
-
- Resource getResource = registry.get(resourcePath);
- if(log.isDebugEnabled()){
- log.debug("Resource retrived");
- log.debug("Printing retrieved resource content: " +
- new String((byte[]) getResource.getContent()));
- }
-
- cartridgeMetaData.type = getResource.getProperty("Cartidge Type");
- cartridgeMetaData.applicationName = getResource.getProperty("Application Name");
- cartridgeMetaData.description = getResource.getProperty("Description");
- cartridgeMetaData.displayName = getResource.getProperty("Display Name");
- cartridgeMetaData.host = getResource.getProperty("host");
- cartridgeMetaData.provider = getResource.getProperty("provider");
- cartridgeMetaData.version = getResource.getProperty("Version");
-
- List<PropertyBean> lst = new ArrayList<PropertyBean>();
- PropertyBean prop = new PropertyBean();
- prop.hostname = getResource.getProperty("hostname");
- prop.username = getResource.getProperty("username");
- prop.password = getResource.getProperty("password");
- lst.add(prop);
-
- cartridgeMetaData.properties = lst;
-
- }
-
- } catch (Exception e) {
-
- if (log.isErrorEnabled()) {
- log.error("getCartridgeMetaDataDetails", e);
- }
- } finally {
- // Close the session
- ((WSRegistryServiceClient) registry).logut();
- }
- return cartridgeMetaData.toString();
- }
-
- /*
- *
- * Remove the meta data from the registry
- *
- * @see org.apache.stratos.metadataservice.registry.DataStore#
- * removeCartridgeMetaDataDetails(java.lang.String, java.lang.String)
- */
+ /*
+ *
+ * Remove the meta data from the registry
+ *
+ * @see org.apache.stratos.metadataservice.registry.DataStore#
+ * removeCartridgeMetaDataDetails(java.lang.String, java.lang.String)
+ */
@Override
public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType)
throws Exception {
@@ -234,16 +116,4 @@ public class GRegRegistry implements DataStore {
}
- public void addPropertiesToApplication(String applicationId, NewProperty[] properties) throws RegistryException {
-
- }
-
- public void addPropertyToApplication(String applicationId, NewProperty property) throws RegistryException {
-
- }
-
- public List<NewProperty> getPropertiesOfApplication(String applicationId) throws RegistryException {
- return null;
- }
-
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/fc233a05/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java
index b20f7b3..cc341ec 100644
--- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java
+++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java
@@ -7,6 +7,7 @@ import org.apache.stratos.metadataservice.annotation.AuthorizationAction;
import org.apache.stratos.metadataservice.definition.NewProperty;
import org.apache.stratos.metadataservice.exception.RestAPIException;
import org.apache.stratos.metadataservice.registry.DataRegistryFactory;
+import org.apache.stratos.metadataservice.registry.DataStore;
import org.apache.stratos.metadataservice.util.ConfUtil;
import org.wso2.carbon.registry.api.RegistryException;
@@ -27,14 +28,15 @@ public class MetaDataAdmin {
@Context
HttpServletRequest httpServletRequest;
- private final String defaultRegType = "carbon";
+ private final String DEFAULT_REG_TYPE = "carbon";
private XMLConfiguration conf;
- private String registryType;
+ DataStore registry;
public MetaDataAdmin(){
conf = ConfUtil.getInstance(null).getConfiguration();
- registryType = conf.getString("metadataservice.govenanceregistrytype", defaultRegType);
+ String registryType = conf.getString("metadataservice.govenanceregistrytype", DEFAULT_REG_TYPE);
+ registry = DataRegistryFactory.getDataRegistryFactory(registryType);
}
@POST
@Path("/init")
@@ -48,9 +50,8 @@ public class MetaDataAdmin {
conf = ConfUtil.getInstance(null).getConfiguration();
String registryType =
conf.getString("metadataservice.govenanceregistrytype",
- defaultRegType);
- return DataRegistryFactory.getDataRegistryFactory(registryType)
- .removeCartridgeMetaDataDetails(applicationName, cartridgeType);
+ DEFAULT_REG_TYPE);
+ return registry.removeCartridgeMetaDataDetails(applicationName, cartridgeType);
}
@@ -64,7 +65,7 @@ public class MetaDataAdmin {
List<NewProperty> properties;
NewProperty[] propertiesArr = null;
try {
- properties = DataRegistryFactory.getDataRegistryFactory(registryType)
+ properties = registry
.getPropertiesOfCluster(applicationId, clusterId);
if(properties != null) {
propertiesArr = new NewProperty[properties.size()];
@@ -93,7 +94,7 @@ public class MetaDataAdmin {
NewProperty property = null;
try {
- properties = DataRegistryFactory.getDataRegistryFactory(registryType)
+ properties = registry
.getPropertiesOfCluster(applicationId, clusterId);
if(properties == null){
return Response.status(Response.Status.NOT_FOUND).build();
@@ -117,122 +118,6 @@ public class MetaDataAdmin {
return rb.build();
}
- @GET
- @Path("/application/{application_id}/cluster/{cluster_id}/dependencies")
- @Produces("application/json")
- @Consumes("application/json")
- @AuthorizationAction("/permission/protected/manage/monitor/tenants")
- public Response getClusterDependencies(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId){
- List<NewProperty> properties;
- NewProperty property = null;
-
- try {
- properties = DataRegistryFactory.getDataRegistryFactory(registryType)
- .getPropertiesOfCluster(applicationId, clusterId);
- if(properties == null){
- return Response.status(Response.Status.NOT_FOUND).build();
- }
- for(NewProperty p : properties){
- if("dependencies".equals(p.getKey())){
- property = p;
- break;
- }
- }
- } catch (Exception e) {
- log.error("Error occurred while getting properties ", e);
- }
- Response.ResponseBuilder rb=null;
- if(property == null){
- rb = Response.status(Response.Status.NOT_FOUND);
- }else{
- rb = Response.ok().entity(property);
- }
- return rb.build();
- }
-
- @GET
- @Path("/application/{application_id}/properties")
- @Produces("application/json")
- @Consumes("application/json")
- @AuthorizationAction("/permission/protected/manage/monitor/tenants")
- public Response getApplicationProperties(@PathParam("application_id") String applicationId){
- List<NewProperty> properties;
- NewProperty[] propertiesArr = null;
- try {
- properties = DataRegistryFactory.getDataRegistryFactory(registryType)
- .getPropertiesOfApplication(applicationId);
- if(properties != null) {
- propertiesArr = new NewProperty[properties.size()];
- propertiesArr = properties.toArray(propertiesArr);
- }
- } catch (Exception e) {
- log.error("Error occurred while getting properties ", e);
- }
-
- Response.ResponseBuilder rb=null;
- if(propertiesArr == null){
- rb = Response.status(Response.Status.NOT_FOUND);
- }else{
- rb = Response.ok().entity(propertiesArr);
- }
- return rb.build();
- }
-
- @GET
- @Path("/application/{application_id}/property/{property_name}")
- @Produces("application/json")
- @Consumes("application/json")
- @AuthorizationAction("/permission/protected/manage/monitor/tenants")
- public Response getApplicationProperty(@PathParam("application_id") String applicationId, @PathParam("property_name") String propertyName){
- List<NewProperty> properties;
- NewProperty property = null;
-
- try {
- properties = DataRegistryFactory.getDataRegistryFactory(registryType)
- .getPropertiesOfApplication(applicationId);
- if(properties == null){
- return Response.status(Response.Status.NOT_FOUND).build();
- }
- for(NewProperty p : properties){
- if(propertyName.equals(p.getKey())){
- property = p;
- break;
- }
- }
- } catch (RegistryException e) {
- log.error("Error occurred while getting property", e);
- }
-
- Response.ResponseBuilder rb=null;
- if(property == null){
- rb = Response.status(Response.Status.NOT_FOUND);
- }else{
- rb = Response.ok().entity(property);
- }
- return rb.build();
- }
-
-
- @POST
- @Path("/application/{application_id}/cluster/{cluster_id}/dependencies")
- @Produces("application/json")
- @Consumes("application/json")
- @AuthorizationAction("/permission/protected/manage/monitor/tenants")
- public Response addClusterDependencies(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId, NewProperty property) throws RestAPIException {
-
- if(!property.getKey().equals("dependencies")){
- throw new RestAPIException("Property name should be dependencies");
- }
- URI url = uriInfo.getAbsolutePathBuilder().path(applicationId + "/" + clusterId + "/" + property.getKey()).build();
-
- try {
- DataRegistryFactory.getDataRegistryFactory(registryType).addPropertyToCluster(applicationId, clusterId, property);
- } catch (RegistryException e) {
- log.error("Error occurred while adding dependencies ", e);
- }
- return Response.created(url).build();
- }
-
@POST
@Path("application/{application_id}/cluster/{cluster_id}/property")
@Produces("application/json")
@@ -244,7 +129,7 @@ public class MetaDataAdmin {
URI url = uriInfo.getAbsolutePathBuilder().path(applicationId + "/" + clusterId + "/" + property.getKey()).build();
try {
- DataRegistryFactory.getDataRegistryFactory(registryType).addPropertyToCluster(applicationId, clusterId, property);
+ registry.addPropertyToCluster(applicationId, clusterId, property);
} catch (RegistryException e) {
log.error("Error occurred while adding property", e);
}
@@ -263,7 +148,7 @@ public class MetaDataAdmin {
URI url = uriInfo.getAbsolutePathBuilder().path(applicationId + "/" + clusterId).build();
try {
- DataRegistryFactory.getDataRegistryFactory(registryType).addPropertiesToCluster(applicationId, clusterId, properties);
+ registry.addPropertiesToCluster(applicationId, clusterId, properties);
} catch (Exception e) {
log.error("Error occurred while adding properties ", e);
}
@@ -272,41 +157,5 @@ public class MetaDataAdmin {
return Response.created(url).build();
}
- @POST
- @Path("application/{application_id}/properties")
- @Produces("application/json")
- @Consumes("application/json")
- @AuthorizationAction("/permission/protected/manage/monitor/tenants")
- public Response addPropertiesToApplication(@PathParam("application_id") String applicationId,NewProperty[] properties)
- throws RestAPIException {
- URI url = uriInfo.getAbsolutePathBuilder().path(applicationId).build();
-
- try {
- DataRegistryFactory.getDataRegistryFactory(registryType).addPropertiesToApplication(applicationId, properties);
- } catch (Exception e) {
- log.error("Error occurred while adding properties ", e);
- }
-
-
- return Response.created(url).build();
- }
-
- @POST
- @Path("application/{application_id}/property")
- @Produces("application/json")
- @Consumes("application/json")
- @AuthorizationAction("/permission/protected/manage/monitor/tenants")
- public Response addPropertyToApplication(@PathParam("application_id") String applicationId, NewProperty property)
- throws RestAPIException {
- URI url = uriInfo.getAbsolutePathBuilder().path(applicationId).build();
- try {
- DataRegistryFactory.getDataRegistryFactory(registryType).addPropertyToApplication(applicationId, property);
- } catch (Exception e) {
- log.error("Error occurred while adding property ", e);
- }
-
-
- return Response.created(url).build();
- }
}