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 2015/05/12 19:07:16 UTC
[1/2] stratos git commit: Metadata remove property
Repository: stratos
Updated Branches:
refs/heads/master c29b736b4 -> da776459f
Metadata remove property
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/54de45eb
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/54de45eb
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/54de45eb
Branch: refs/heads/master
Commit: 54de45eb4dd7cc30b2527b71551438eed29f5f5f
Parents: c29b736
Author: Udara Liyanage <ud...@wso2.com>
Authored: Thu Apr 30 10:53:46 2015 +0530
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Tue May 12 22:36:48 2015 +0530
----------------------------------------------------------------------
.../service/registry/CarbonRegistry.java | 83 +++++++++++++++++++-
.../metadata/service/registry/DataStore.java | 2 +
.../service/services/MetaDataAdmin.java | 20 +++++
.../cartridge.agent/mdsclient.py | 12 ++-
.../plugins/WkaMemberConfigurator.yapsy-plugin | 9 +++
5 files changed, 123 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/54de45eb/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/CarbonRegistry.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/CarbonRegistry.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/CarbonRegistry.java
index 559a492..d384e80 100644
--- a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/CarbonRegistry.java
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/CarbonRegistry.java
@@ -145,8 +145,12 @@ public class CarbonRegistry implements DataStore {
log.debug("Registry resource is create at path for application: " + nodeResource.getPath());
}
}
+
+ for(String value : property.getValues()){
+ //log.info(String.format("*** application property value is added to the registry key=%s value=%s", property.getKey(), value));
+ nodeResource.addProperty(property.getKey(), value);
+ }
- nodeResource.setProperty(property.getKey(), Arrays.asList(property.getValues()));
registry.put(resourcePath, nodeResource);
registry.commitTransaction();
@@ -160,6 +164,41 @@ public class CarbonRegistry implements DataStore {
}
}
+ public boolean removePropertyFromApplication(String applicationId, String propertyName, String valueToRemove) throws RegistryException {
+ Registry registry = getRegistry();
+ String resourcePath = mainResource + applicationId;
+
+ try {
+ PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
+ ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
+
+ registry.beginTransaction();
+ Resource nodeResource;
+ if (registry.resourceExists(resourcePath)) {
+ nodeResource = registry.get(resourcePath);
+ } else {
+ log.warn(String.format("Registry [resource] %s not found ", resourcePath));
+ return false;
+ }
+
+ nodeResource.removePropertyValue(propertyName, valueToRemove);
+ registry.put(resourcePath, nodeResource);
+ registry.commitTransaction();
+
+ log.info(String.format("****** Application %s property %s value %s is removed from metadata ", applicationId, propertyName, valueToRemove));
+ } catch (Exception e) {
+ String msg = "Failed to persist properties in registry: " + resourcePath;
+ registry.rollbackTransaction();
+ log.error(msg, e);
+ throw new RegistryException(msg, e);
+ }
+
+ return true;
+ }
+
+
+
/**
* Add property to cluster
*
@@ -204,6 +243,48 @@ public class CarbonRegistry implements DataStore {
}
}
+ public void addPropertyToGroup(String applicationId, String groupId, NewProperty property) throws RegistryException {
+ Registry registry = getRegistry();
+ String resourcePath = mainResource + applicationId + "/groups/" + groupId;
+
+ try {
+ PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
+ ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
+
+ registry.beginTransaction();
+ Resource nodeResource = null;
+ if (registry.resourceExists(resourcePath)) {
+ nodeResource = registry.get(resourcePath);
+ } else {
+ nodeResource = registry.newResource();
+ if (log.isDebugEnabled()) {
+ log.debug("Registry resource is create at path for cluster" + nodeResource.getPath() + " for cluster");
+ }
+ }
+
+ for(String value : property.getValues()){
+ log.info(String.format("*** groups property value is added to the registry key=%s value=%s", property.getKey(), value));
+ nodeResource.addProperty(property.getKey(), value);
+ }
+
+ registry.put(resourcePath, nodeResource);
+
+ registry.commitTransaction();
+
+ log.info(String.format("Registry property is persisted: [resource-path] %s [Property Name] %s [Property Values] %s",
+ resourcePath, property.getKey(), Arrays.asList(property.getValues())));
+
+ } catch (Exception e) {
+ String msg = "Failed to persist properties in registry: " + resourcePath;
+ registry.rollbackTransaction();
+ log.error(msg, e);
+ throw new RegistryException(msg, e);
+ }
+ }
+
+
+
private UserRegistry getRegistry() throws RegistryException {
return org.apache.stratos.common.internal.ServiceReferenceHolder.getInstance().getRegistryService().getGovernanceSystemRegistry();
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/54de45eb/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 3e678ee..80d3427 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
@@ -45,4 +45,6 @@ public interface DataStore {
public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) throws RegistryException;
public boolean deleteApplication(String applicationId) throws RegistryException;
+
+ public boolean removePropertyFromApplication(String applicationId, String propertyName, String valueToRemove) throws RegistryException;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/54de45eb/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/services/MetaDataAdmin.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/services/MetaDataAdmin.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/services/MetaDataAdmin.java
index 72bddd4..123b52f 100644
--- a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/services/MetaDataAdmin.java
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/services/MetaDataAdmin.java
@@ -305,5 +305,25 @@ public class MetaDataAdmin {
return Response.ok().build();
}
+ @DELETE
+ @Path("application/{application_id}/property/{property_name}/value/{value}")
+ @Produces("application/json")
+ @Consumes("application/json")
+ @AuthorizationAction("/permission/protected/manage/monitor/tenants")
+ public Response deleteApplicationPropertValue(@PathParam("application_id") String applicationId, @PathParam("property_name") String propertyName,
+ @PathParam("value") String propertyValue )
+ throws RestAPIException {
+
+ try {
+ log.info("***************************** application/{application_id}/property/{property_name}/value/{value}");
+ registry.removePropertyFromApplication(applicationId, propertyName, propertyValue);
+ } catch (RegistryException e) {
+ String msg = "Resource value deletion failed ";
+ log.error(msg, e);
+ throw new RestAPIException(msg, e);
+ }
+
+ return Response.ok().build();
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/54de45eb/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/mdsclient.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/mdsclient.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/mdsclient.py
index f67eca0..56bbd58 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/mdsclient.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/mdsclient.py
@@ -99,8 +99,16 @@ def update(data):
raise NotImplementedError
-def delete(keys):
- raise NotImplementedError
+def delete_property_value(property_name, value):
+ log.info("*********** removing property %s value %s " % (property_name, value))
+ opener = urllib2.build_opener(urllib2.HTTPHandler)
+ request = urllib2.Request(mds_url + "/metadata/api/application/" + app_id + "/property/" + property_name + "/value/" + value)
+ request.add_header("Authorization", "Bearer %s" % token)
+ request.add_header('Content-Type', 'application/json')
+ request.get_method = lambda: 'DELETE'
+ url = opener.open(request)
+
+ log.info("*********** property value removed %s " % (url))
class MDSPutRequest:
http://git-wip-us.apache.org/repos/asf/stratos/blob/54de45eb/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/plugins/WkaMemberConfigurator.yapsy-plugin
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/plugins/WkaMemberConfigurator.yapsy-plugin b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/plugins/WkaMemberConfigurator.yapsy-plugin
new file mode 100644
index 0000000..d3f5bf5
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/plugins/WkaMemberConfigurator.yapsy-plugin
@@ -0,0 +1,9 @@
+[Core]
+Name = wka_member_configurator to configure wka members for WSO2 Carbon products
+Module = WkaMemberConfigurator
+
+[Documentation]
+Description = CompleteTopologyEvent
+Author = Op1
+Version = 0.1
+Website = stratos.apache.org
[2/2] stratos git commit: removing unsued apis from metadata service
Posted by ud...@apache.org.
removing unsued apis from metadata service
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/da776459
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/da776459
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/da776459
Branch: refs/heads/master
Commit: da776459f23c008e4f0e59d34392d923ecffe970
Parents: 54de45e
Author: Udara Liyanage <ud...@wso2.com>
Authored: Tue May 12 22:17:30 2015 +0530
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Tue May 12 22:36:49 2015 +0530
----------------------------------------------------------------------
.../service/definition/NewProperty.java | 67 --------------
.../metadata/service/definition/Property.java | 67 ++++++++++++++
.../service/registry/CarbonRegistry.java | 81 +++++++++--------
.../metadata/service/registry/DataStore.java | 16 +---
.../service/services/MetaDataAdmin.java | 96 +++++---------------
5 files changed, 137 insertions(+), 190 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/da776459/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/NewProperty.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/NewProperty.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/NewProperty.java
deleted file mode 100644
index d6627c3..0000000
--- a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/NewProperty.java
+++ /dev/null
@@ -1,67 +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.stratos.metadata.service.definition;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-@XmlRootElement(name = "properties")
-public class NewProperty implements Serializable {
-
- private String key;
- private List<String> values = new ArrayList<String>();
-
- public NewProperty() {
- }
-
- public NewProperty(String key, String value) {
- this.key = key;
- this.values.add(value);
- }
-
- public String getKey() {
- return key;
- }
-
- public void setKey(String key) {
- this.key = key;
- }
-
- public String[] getValues() {
- String[] values = new String[this.values.size()];
- values = this.values.toArray(values);
- return values;
- }
-
- public void setValues(String value) {
- this.values.add(value);
- }
-
- public void setValues(String[] values) {
- this.values.addAll(Arrays.asList(values));
- }
-
- public void addValue(String value) {
- this.values.add(value);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/da776459/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/Property.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/Property.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/Property.java
new file mode 100644
index 0000000..3ceb942
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/Property.java
@@ -0,0 +1,67 @@
+/**
+ * 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.stratos.metadata.service.definition;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+@XmlRootElement(name = "properties")
+public class Property implements Serializable {
+
+ private String key;
+ private List<String> values = new ArrayList<String>();
+
+ public Property() {
+ }
+
+ public Property(String key, String value) {
+ this.key = key;
+ this.values.add(value);
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public String[] getValues() {
+ String[] values = new String[this.values.size()];
+ values = this.values.toArray(values);
+ return values;
+ }
+
+ public void setValues(String value) {
+ this.values.add(value);
+ }
+
+ public void setValues(String[] values) {
+ this.values.addAll(Arrays.asList(values));
+ }
+
+ public void addValue(String value) {
+ this.values.add(value);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/da776459/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/CarbonRegistry.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/CarbonRegistry.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/CarbonRegistry.java
index d384e80..d83edf2 100644
--- a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/CarbonRegistry.java
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/CarbonRegistry.java
@@ -21,7 +21,7 @@ package org.apache.stratos.metadata.service.registry;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.metadata.service.definition.NewProperty;
+import org.apache.stratos.metadata.service.definition.Property;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.registry.core.Registry;
import org.wso2.carbon.registry.core.Resource;
@@ -44,11 +44,12 @@ public class CarbonRegistry implements DataStore {
private static Log log = LogFactory.getLog(CarbonRegistry.class);
@Context
HttpServletRequest httpServletRequest;
+ private static int count = 0;
public CarbonRegistry() {
}
- public List<NewProperty> getApplicationProperties(String applicationName) throws RegistryException {
+ public List<Property> getApplicationProperties(String applicationName) throws RegistryException {
Registry tempRegistry = getRegistry();
String resourcePath = mainResource + applicationName;
@@ -61,14 +62,14 @@ public class CarbonRegistry implements DataStore {
ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
Resource regResource = tempRegistry.get(resourcePath);
- ArrayList<NewProperty> newProperties = new ArrayList<NewProperty>();
+ ArrayList<Property> newProperties = new ArrayList<Property>();
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 property = new Property();
property.setKey(key);
String[] valueArr = new String[values.size()];
property.setValues(values.toArray(valueArr));
@@ -86,7 +87,7 @@ public class CarbonRegistry implements DataStore {
* @return
* @throws RegistryException
*/
- public List<NewProperty> getClusterProperties(String applicationName, String clusterId) throws RegistryException {
+ public List<Property> getClusterProperties(String applicationName, String clusterId) throws RegistryException {
Registry tempRegistry = getRegistry();
String resourcePath = mainResource + applicationName + "/" + clusterId;
@@ -102,14 +103,14 @@ public class CarbonRegistry implements DataStore {
Resource regResource = tempRegistry.get(resourcePath);
- ArrayList<NewProperty> newProperties = new ArrayList<NewProperty>();
+ ArrayList<Property> newProperties = new ArrayList<Property>();
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 property = new Property();
property.setKey(key);
String[] valueArr = new String[values.size()];
property.setValues(values.toArray(valueArr));
@@ -120,22 +121,18 @@ public class CarbonRegistry implements DataStore {
return newProperties;
}
- public void addPropertiesToApplication(String applicationId, NewProperty[] properties) throws RegistryException {
- for (NewProperty property : properties) {
- addPropertyToApplication(applicationId, property);
- }
- }
-
- public void addPropertyToApplication(String applicationId, NewProperty property) throws RegistryException {
+ public void addPropertyToApplication(String applicationId, Property property) throws RegistryException {
Registry registry = getRegistry();
String resourcePath = mainResource + applicationId;
+ log.info("**************addPropertyToApplication " + count++ + " property name " + property.getKey() + " values " + Arrays.toString(property.getValues()));
+ //log.info("**** property name " + property.getKey() + " values " + Arrays.toString(property.getValues()));
try {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- registry.beginTransaction();
+ //registry.beginTransaction();
Resource nodeResource = null;
if (registry.resourceExists(resourcePath)) {
nodeResource = registry.get(resourcePath);
@@ -151,19 +148,43 @@ public class CarbonRegistry implements DataStore {
nodeResource.addProperty(property.getKey(), value);
}
- registry.put(resourcePath, nodeResource);
- registry.commitTransaction();
+ boolean updated = false;
+ for(String value : property.getValues()){
+ if(!propertyValueExist(nodeResource, property.getKey(), value)){
+ updated = true;
+ log.info(String.format("Registry property is added: [resource-path] %s [Property Name] %s [Property Value] %s",
+ resourcePath, property.getKey(), value));
+ nodeResource.addProperty(property.getKey(), value);
+ }else{
+ log.info(String.format("Property value already exist property=%s value=%s", property.getKey(), value));
+ }
+ }
+
+ if(updated){
+ registry.put(resourcePath, nodeResource);
+ }
+ //registry.commitTransaction();
+
+
- log.info(String.format("Registry property is persisted: [resource-path] %s [Property Name] %s [Property Values] %s",
- resourcePath, property.getKey(), Arrays.asList(property.getValues())));
} catch (Exception e) {
String msg = "Failed to persist properties in registry: " + resourcePath;
- registry.rollbackTransaction();
+ //registry.rollbackTransaction();
log.error(msg, e);
throw new RegistryException(msg, e);
}
}
+ private boolean propertyValueExist(Resource nodeResource, String key, String value) {
+ List<String> properties = nodeResource.getPropertyValues(key);
+ if(properties == null){
+ return false;
+ }else{
+ return properties.contains(value);
+ }
+
+ }
+
public boolean removePropertyFromApplication(String applicationId, String propertyName, String valueToRemove) throws RegistryException {
Registry registry = getRegistry();
String resourcePath = mainResource + applicationId;
@@ -197,8 +218,6 @@ public class CarbonRegistry implements DataStore {
return true;
}
-
-
/**
* Add property to cluster
*
@@ -207,7 +226,7 @@ public class CarbonRegistry implements DataStore {
* @param property
* @throws RegistryException
*/
- public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) throws RegistryException {
+ public void addPropertyToCluster(String applicationId, String clusterId, Property property) throws RegistryException {
Registry registry = getRegistry();
String resourcePath = mainResource + applicationId + "/" + clusterId;
@@ -243,7 +262,7 @@ public class CarbonRegistry implements DataStore {
}
}
- public void addPropertyToGroup(String applicationId, String groupId, NewProperty property) throws RegistryException {
+ public void addPropertyToGroup(String applicationId, String groupId, Property property) throws RegistryException {
Registry registry = getRegistry();
String resourcePath = mainResource + applicationId + "/groups/" + groupId;
@@ -324,20 +343,6 @@ public class CarbonRegistry implements DataStore {
}
/**
- * Add properties to cluster
- *
- * @param applicationName
- * @param clusterId
- * @param properties
- * @throws RegistryException
- */
- public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) throws RegistryException {
- for (NewProperty property : properties) {
- this.addPropertyToCluster(applicationName, clusterId, property);
- }
- }
-
- /**
* Create or get resource for application
*
* @param tempRegistry
http://git-wip-us.apache.org/repos/asf/stratos/blob/da776459/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 80d3427..dbdd6df 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
@@ -19,7 +19,7 @@
package org.apache.stratos.metadata.service.registry;
-import org.apache.stratos.metadata.service.definition.NewProperty;
+import org.apache.stratos.metadata.service.definition.Property;
import org.wso2.carbon.registry.api.RegistryException;
import java.util.List;
@@ -29,20 +29,14 @@ import java.util.List;
*/
public interface DataStore {
- public void addPropertyToApplication(String applicationId, NewProperty property) throws RegistryException;
+ public void addPropertyToApplication(String applicationId, Property property) throws RegistryException;
- public void addPropertiesToApplication(String applicationName, NewProperty[] properties)
- throws RegistryException;
-
- public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties)
- throws RegistryException;
-
- public List<NewProperty> getApplicationProperties(String applicationName) throws RegistryException;
+ public List<Property> getApplicationProperties(String applicationName) throws RegistryException;
- public List<NewProperty> getClusterProperties(String applicationName, String clusterId)
+ public List<Property> getClusterProperties(String applicationName, String clusterId)
throws RegistryException;
- public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) throws RegistryException;
+ public void addPropertyToCluster(String applicationId, String clusterId, Property property) throws RegistryException;
public boolean deleteApplication(String applicationId) throws RegistryException;
http://git-wip-us.apache.org/repos/asf/stratos/blob/da776459/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/services/MetaDataAdmin.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/services/MetaDataAdmin.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/services/MetaDataAdmin.java
index 123b52f..68b960c 100644
--- a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/services/MetaDataAdmin.java
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/services/MetaDataAdmin.java
@@ -19,11 +19,10 @@
package org.apache.stratos.metadata.service.services;
import org.apache.commons.configuration.XMLConfiguration;
-import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.metadata.service.annotation.AuthorizationAction;
-import org.apache.stratos.metadata.service.definition.NewProperty;
+import org.apache.stratos.metadata.service.definition.Property;
import org.apache.stratos.metadata.service.exception.RestAPIException;
import org.apache.stratos.metadata.service.registry.DataRegistryFactory;
import org.apache.stratos.metadata.service.registry.DataStore;
@@ -62,13 +61,13 @@ public class MetaDataAdmin {
public Response getApplicationProperties(@PathParam("application_id") String applicationId)
throws RestAPIException {
- List<NewProperty> properties;
- NewProperty[] propertiesArr = null;
+ List<Property> properties;
+ Property[] propertiesArr = null;
try {
properties = registry
.getApplicationProperties(applicationId);
if (properties != null) {
- propertiesArr = new NewProperty[properties.size()];
+ propertiesArr = new Property[properties.size()];
propertiesArr = properties.toArray(propertiesArr);
}
} catch (RegistryException e) {
@@ -93,13 +92,13 @@ public class MetaDataAdmin {
@AuthorizationAction("/permission/protected/manage/monitor/tenants")
public Response getClusterProperties(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId) throws RestAPIException {
- List<NewProperty> properties;
- NewProperty[] propertiesArr = null;
+ List<Property> properties;
+ Property[] propertiesArr = null;
try {
properties = registry
.getClusterProperties(applicationId, clusterId);
if (properties != null) {
- propertiesArr = new NewProperty[properties.size()];
+ propertiesArr = new Property[properties.size()];
propertiesArr = properties.toArray(propertiesArr);
}
} catch (RegistryException e) {
@@ -118,23 +117,23 @@ public class MetaDataAdmin {
}
@GET
- @Path("/application/{application_id}/property/{property_name}")
+ @Path("/application/{application_id}/properties/{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)
throws RestAPIException {
- List<NewProperty> properties;
+ List<Property> properties;
- NewProperty property = null;
+ Property property = null;
try {
properties = registry.getApplicationProperties(applicationId);
if (properties == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}
- for (NewProperty p : properties) {
+ for (Property p : properties) {
if (propertyName.equals(p.getKey())) {
property = p;
break;
@@ -156,21 +155,20 @@ public class MetaDataAdmin {
}
@GET
- @Path("/application/{application_id}/cluster/{cluster_id}/property/{property_name}")
+ @Path("/application/{application_id}/cluster/{cluster_id}/properties/{property_name}")
@Produces("application/json")
@Consumes("application/json")
@AuthorizationAction("/permission/protected/manage/monitor/tenants")
public Response getClusterProperty(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId, @PathParam("property_name") String propertyName) throws RestAPIException {
- List<NewProperty> properties;
+ List<Property> properties;
-
- NewProperty property = null;
+ Property property = null;
try {
properties = registry.getClusterProperties(applicationId, clusterId);
if (properties == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}
- for (NewProperty p : properties) {
+ for (Property p : properties) {
if (propertyName.equals(p.getKey())) {
property = p;
break;
@@ -192,66 +190,17 @@ public class MetaDataAdmin {
}
@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 + "/" + property.getKey()).build();
- if (StringUtils.isEmpty(property.getKey())) {
- throw new RestAPIException("Property key can not be empty");
- }
-
- try {
- registry.addPropertyToApplication(applicationId, property);
- } catch (RegistryException e) {
- String msg = "Error occurred while adding property";
- log.error(msg, e);
- throw new RestAPIException(msg, e);
- }
- return Response.created(url).build();
- }
-
- @POST
- @Path("application/{application_id}/cluster/{cluster_id}/property")
- @Produces("application/json")
- @Consumes("application/json")
- @AuthorizationAction("/permission/protected/manage/monitor/tenants")
- public Response addPropertyToCluster(@PathParam("application_id") String applicationId,
- @PathParam("cluster_id") String clusterId, NewProperty property)
- throws RestAPIException {
-
- URI url = uriInfo.getAbsolutePathBuilder().path(applicationId + "/" + clusterId + "/" + property.getKey()).build();
- if (StringUtils.isEmpty(property.getKey())) {
- throw new RestAPIException("Property key can not be empty");
- }
-
- try {
- registry.addPropertyToCluster(applicationId, clusterId, property);
- } catch (RegistryException e) {
- String msg = "Error occurred while adding property";
- log.error(msg, e);
- throw new RestAPIException(msg, e);
- }
-
- 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)
+ public Response addPropertyToApplication(@PathParam("application_id") String applicationId,
+ Property property)
throws RestAPIException {
URI url = uriInfo.getAbsolutePathBuilder().path(applicationId).build();
try {
- registry.addPropertiesToApplication(applicationId, properties);
+ registry.addPropertyToApplication(applicationId, property);
} catch (RegistryException e) {
String msg = "Error occurred while adding properties ";
log.error(msg, e);
@@ -265,13 +214,13 @@ public class MetaDataAdmin {
@Produces("application/json")
@Consumes("application/json")
@AuthorizationAction("/permission/protected/manage/monitor/tenants")
- public Response addPropertiesToCluster(@PathParam("application_id") String applicationId,
- @PathParam("cluster_id") String clusterId, NewProperty[] properties)
+ public Response addPropertyToCluster(@PathParam("application_id") String applicationId,
+ @PathParam("cluster_id") String clusterId, Property property)
throws RestAPIException {
URI url = uriInfo.getAbsolutePathBuilder().path(applicationId + "/" + clusterId).build();
try {
- registry.addPropertiesToCluster(applicationId, clusterId, properties);
+ registry.addPropertyToCluster(applicationId, clusterId, property);
} catch (RegistryException e) {
String msg = "Error occurred while adding properties ";
log.error(msg, e);
@@ -306,7 +255,7 @@ public class MetaDataAdmin {
}
@DELETE
- @Path("application/{application_id}/property/{property_name}/value/{value}")
+ @Path("application/{application_id}/properties/{property_name}/value/{value}")
@Produces("application/json")
@Consumes("application/json")
@AuthorizationAction("/permission/protected/manage/monitor/tenants")
@@ -315,7 +264,6 @@ public class MetaDataAdmin {
throws RestAPIException {
try {
- log.info("***************************** application/{application_id}/property/{property_name}/value/{value}");
registry.removePropertyFromApplication(applicationId, propertyName, propertyValue);
} catch (RegistryException e) {
String msg = "Resource value deletion failed ";