[Registry-dev] svn commit r14653 - in
trunk/registry/modules/core/src: main/java/org/wso2/registry/app
test/java/org/wso2/registry/app
svn at wso2.org
svn at wso2.org
Mon Mar 10 04:34:43 PDT 2008
Author: deepal
Date: Mon Mar 10 04:34:33 2008
New Revision: 14653
Log:
get the multi valued property working in APP
Added:
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPbasedProertyTest.java
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/AtomRegistry.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/app/AtomRegistry.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/app/AtomRegistry.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/app/AtomRegistry.java Mon Mar 10 04:34:33 2008
@@ -533,7 +533,7 @@
PropertyExtensionFactory.PROPERTY);
//if the resource is deleted then there will be comment saying that the resource is
// deleted
- if (((ResourceImpl)resource).getState() == RegistryConstants.DELETED_STATE) {
+ if (resource.getState() == RegistryConstants.DELETED_STATE) {
feed.addSimpleExtension(new QName(NAMESPACE, "state"), "Deleted");
}
feed.setId("http://wso2.org/jdbcregistry:atom" + ((ResourceImpl)resource).getId());
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java Mon Mar 10 04:34:33 2008
@@ -294,7 +294,12 @@
Property property = (Property)aPropertyList;
PropertyName pn = property.getExtension(PropertyExtensionFactory.PROPERTY_NAME);
PropertyValue pv = property.getExtension(PropertyExtensionFactory.PROPERTY_VALUE);
- resource.setProperty(pn.getText(), pv.getText());
+ String value = pv.getText();
+ List list = decodeMultivaluedProperty(value);
+ for (int i = 0; i < list.size(); i++) {
+ String stringValue = (String)list.get(i);
+ resource.setProperty(pn.getText(), stringValue);
+ }
}
}
}
@@ -327,14 +332,41 @@
pn.setPropertyName(key);
PropertyValue pv = factory.newExtensionElement(
PropertyExtensionFactory.PROPERTY_VALUE);
- pv.setPropertyValue((String)properties.get(key));
- property.setProperty(pn, pv);
- propertyElement.setProperty(property);
+ Object valueList = properties.get(key);
+ String propertyValue ="" ;
+ if (valueList instanceof List) {
+ propertyValue = encodeMultivaluedProperty((List)valueList, propertyValue);
+ pv.setPropertyValue(propertyValue);
+ property.setProperty(pn, pv);
+ propertyElement.setProperty(property);
+ }
}
entry.addExtension(propertyElement);
}
}
+ private static String encodeMultivaluedProperty(List valueList, String propertyValue) {
+ for (int i = 0; i < valueList.size(); i++) {
+ String value = (String) valueList.get(i);
+ if ("".equals(propertyValue)) {
+ propertyValue = value;
+ } else {
+ propertyValue = propertyValue + "|" + value;
+ }
+ }
+ return propertyValue;
+ }
+
+ public static List decodeMultivaluedProperty(String propertyValue) {
+ String values [] = propertyValue.split("\\|");
+ List list = new ArrayList();
+ for (int i = 0; i < values.length; i++) {
+ String value = values[i];
+ list.add(value);
+ }
+ return list;
+ }
+
public String importResource(String suggestedPath, String sourceURL, Resource metadata)
throws RegistryException {
Added: trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPbasedProertyTest.java
==============================================================================
--- (empty file)
+++ trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPbasedProertyTest.java Mon Mar 10 04:34:33 2008
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2006, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * Licensed 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.wso2.registry.app;
+
+import org.wso2.registry.jdbc.PropertiesTest;
+
+import java.net.URL;
+
+public class APPbasedProertyTest extends PropertiesTest {
+
+ RegistryServer server = new RegistryServer();
+
+ public void setUp() {
+ try {
+ if (registry == null) {
+ server.start();
+ registry = new RemoteRegistry(new URL("http://localhost:8081/wso2registry/atom"),
+ "admin", "admin");
+ }
+ } catch (Exception e) {
+ fail("Failed to initialize the registry.");
+ }
+ }
+
+}
More information about the Registry-dev
mailing list