From c01717a0e736dbfc8e80aebaf65b67d2e6e9592f Mon Sep 17 00:00:00 2001 From: Britt Park Date: Fri, 16 Jun 2006 19:18:30 +0000 Subject: [PATCH] Merged up to HEAD. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3129 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repo/webservice/action/deploy.wsdd | 256 +++++++++--------- .../repo/webservice/types/NamedValue.java | 94 ++++++- .../org/alfresco/repo/webservice/CMLUtil.java | 16 +- .../alfresco/repo/webservice/CMLUtilTest.java | 8 +- .../org/alfresco/repo/webservice/Utils.java | 138 +++++++++- .../webservice/action/ActionWebService.java | 6 +- .../AdministrationWebService.java | 7 +- .../repository/AssociatedQuerySession.java | 11 +- .../repository/ChildrenQuerySession.java | 11 +- .../repository/ParentsQuerySession.java | 11 +- .../webservice/repository/QuerySession.java | 8 +- .../repository/RepositoryWebService.java | 24 +- .../repository/ResultSetQuerySession.java | 17 +- .../java/web-services-application-context.xml | 3 + source/wsdl/types.xsd | 2 + 15 files changed, 417 insertions(+), 195 deletions(-) diff --git a/source/generated/org/alfresco/repo/webservice/action/deploy.wsdd b/source/generated/org/alfresco/repo/webservice/action/deploy.wsdd index bb872a6b8b..e56df19168 100644 --- a/source/generated/org/alfresco/repo/webservice/action/deploy.wsdd +++ b/source/generated/org/alfresco/repo/webservice/action/deploy.wsdd @@ -91,22 +91,6 @@ deserializer="org.apache.axis.encoding.ser.EnumDeserializerFactory" encodingStyle="" /> - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - collection = new ArrayList(values.length); + for (String value : values) + { + collection.add((Serializable)DefaultTypeConverter.INSTANCE.convert(propertyType, value)); + } + + if (logger.isDebugEnabled() == true) + { + logger.debug("The collection for the multi-value property has been generated '" + collection.toString()); + } + + result = (Serializable)collection; + } + } + } + else + { + if (logger.isDebugEnabled() == true) + { + logger.debug("No property definition was found for property '" + propertyName.toString() + "'"); + } + } + } + return result; + } + + /** + * Create a named value object from the property name and value informaiton + * + * @param dictionaryService the dictionary service + * @param propertyName the property qname + * @param propertyValue the property value + * @return the namedValue object + */ + public static NamedValue createNamedValue(DictionaryService dictionaryService, QName propertyName, Serializable propertyValue) + { + NamedValue namedValue = new NamedValue(); + namedValue.setName(propertyName.toString()); + + if (logger.isDebugEnabled() == true) + { + logger.debug("Creating named value for property '" + propertyName + "' with value '" + propertyValue + "'"); + } + + if (propertyValue != null) + { + org.alfresco.service.cmr.dictionary.PropertyDefinition propDef = dictionaryService.getProperty(propertyName); + if (propDef != null) + { + if (propDef.isMultiValued() == true) + { + namedValue.setIsMultiValue(true); + if (propertyValue instanceof Collection) + { + if (logger.isDebugEnabled() == true) + { + logger.debug("Converting multivalue for property '" + propertyName + "'"); + } + + Collection collection = (Collection)propertyValue; + String[] values = new String[collection.size()]; + int count = 0; + for (Serializable value : collection) + { + values[count] = DefaultTypeConverter.INSTANCE.convert(String.class, value); + count ++; + } + namedValue.setValues(values); + } + } + else + { + if (logger.isDebugEnabled() == true) + { + logger.debug("Converting single value for property '" + propertyName + "'"); + } + + namedValue.setIsMultiValue(false); + namedValue.setValue(DefaultTypeConverter.INSTANCE.convert(String.class, propertyValue)); + } + } + else + { + if (logger.isDebugEnabled() == true) + { + logger.debug("No property definition found for property '" + propertyName + "'"); + } + + namedValue.setIsMultiValue(false); + namedValue.setValue(propertyValue.toString()); + } + } + + return namedValue; + } /** * Converts the web service Store type to a StoreRef used by the repository @@ -437,7 +573,7 @@ public class Utils { value = entry.getValue().toString(); } - namedValues[iIndex] = new NamedValue(entry.getKey(), value); + namedValues[iIndex] = new NamedValue(entry.getKey(), false, value, null); iIndex++; } webServiceVersion.setCommentaries(namedValues); diff --git a/source/java/org/alfresco/repo/webservice/action/ActionWebService.java b/source/java/org/alfresco/repo/webservice/action/ActionWebService.java index 6c8b86282a..5e3dcea97f 100644 --- a/source/java/org/alfresco/repo/webservice/action/ActionWebService.java +++ b/source/java/org/alfresco/repo/webservice/action/ActionWebService.java @@ -530,7 +530,11 @@ public class ActionWebService extends AbstractWebService implements ActionServic { value = entry.getValue().toString(); } - namedValues[index] = new NamedValue(entry.getKey(), value); + NamedValue namedValue = new NamedValue(); + namedValue.setName(entry.getKey()); + namedValue.setIsMultiValue(false); + namedValue.setValue(value); + namedValues[index] = namedValue; index++; } } diff --git a/source/java/org/alfresco/repo/webservice/administration/AdministrationWebService.java b/source/java/org/alfresco/repo/webservice/administration/AdministrationWebService.java index 96227b4d69..63eccdfd73 100644 --- a/source/java/org/alfresco/repo/webservice/administration/AdministrationWebService.java +++ b/source/java/org/alfresco/repo/webservice/administration/AdministrationWebService.java @@ -34,7 +34,6 @@ import org.alfresco.repo.transaction.TransactionUtil.TransactionWork; import org.alfresco.repo.webservice.AbstractWebService; import org.alfresco.repo.webservice.Utils; import org.alfresco.repo.webservice.action.ActionFault; -import org.alfresco.repo.webservice.repository.QuerySession; import org.alfresco.repo.webservice.types.NamedValue; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; @@ -305,7 +304,11 @@ public class AdministrationWebService extends AbstractWebService implements { value = entry.getValue().toString(); } - namedValues.add(new NamedValue(entry.getKey().toString(), value)); + NamedValue namedValue = new NamedValue(); + namedValue.setName(entry.getKey().toString()); + namedValue.setIsMultiValue(false); + namedValue.setValue(value); + namedValues.add(namedValue); } } userDetails.setProperties((NamedValue[])namedValues.toArray(new NamedValue[namedValues.size()])); diff --git a/source/java/org/alfresco/repo/webservice/repository/AssociatedQuerySession.java b/source/java/org/alfresco/repo/webservice/repository/AssociatedQuerySession.java index 780241c207..b5447770cd 100644 --- a/source/java/org/alfresco/repo/webservice/repository/AssociatedQuerySession.java +++ b/source/java/org/alfresco/repo/webservice/repository/AssociatedQuerySession.java @@ -25,6 +25,7 @@ import org.alfresco.repo.webservice.types.NamedValue; import org.alfresco.repo.webservice.types.Reference; import org.alfresco.repo.webservice.types.ResultSetRow; import org.alfresco.repo.webservice.types.ResultSetRowNode; +import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.repository.AssociationRef; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; @@ -71,7 +72,7 @@ public class AssociatedQuerySession extends AbstractQuerySession * org.alfresco.service.namespace.NamespaceService) */ public QueryResult getNextResultsBatch(SearchService searchService, - NodeService nodeService, NamespaceService namespaceService) + NodeService nodeService, NamespaceService namespaceService, DictionaryService dictionaryService) { QueryResult queryResult = null; @@ -114,13 +115,7 @@ public class AssociatedQuerySession extends AbstractQuerySession int col = 0; for (QName propName : props.keySet()) { - String value = null; - Serializable valueObj = props.get(propName); - if (valueObj != null) - { - value = valueObj.toString(); - } - columns[col] = new NamedValue(propName.toString(), value); + columns[col] = Utils.createNamedValue(dictionaryService, propName, props.get(propName)); col++; } diff --git a/source/java/org/alfresco/repo/webservice/repository/ChildrenQuerySession.java b/source/java/org/alfresco/repo/webservice/repository/ChildrenQuerySession.java index 0c8d1f9484..c8f8d54af7 100644 --- a/source/java/org/alfresco/repo/webservice/repository/ChildrenQuerySession.java +++ b/source/java/org/alfresco/repo/webservice/repository/ChildrenQuerySession.java @@ -25,6 +25,7 @@ import org.alfresco.repo.webservice.types.NamedValue; import org.alfresco.repo.webservice.types.Reference; import org.alfresco.repo.webservice.types.ResultSetRow; import org.alfresco.repo.webservice.types.ResultSetRowNode; +import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; @@ -63,7 +64,7 @@ public class ChildrenQuerySession extends AbstractQuerySession /** * @see org.alfresco.repo.webservice.repository.QuerySession#getNextResultsBatch(org.alfresco.service.cmr.search.SearchService, org.alfresco.service.cmr.repository.NodeService, org.alfresco.service.namespace.NamespaceService) */ - public QueryResult getNextResultsBatch(SearchService searchService, NodeService nodeService, NamespaceService namespaceService) + public QueryResult getNextResultsBatch(SearchService searchService, NodeService nodeService, NamespaceService namespaceService, DictionaryService dictionaryService) { QueryResult queryResult = null; @@ -100,13 +101,7 @@ public class ChildrenQuerySession extends AbstractQuerySession int col = 0; for (QName propName : props.keySet()) { - String value = null; - Serializable valueObj = props.get(propName); - if (valueObj != null) - { - value = valueObj.toString(); - } - columns[col] = new NamedValue(propName.toString(), value); + columns[col] = Utils.createNamedValue(dictionaryService, propName, props.get(propName)); col++; } diff --git a/source/java/org/alfresco/repo/webservice/repository/ParentsQuerySession.java b/source/java/org/alfresco/repo/webservice/repository/ParentsQuerySession.java index 4200198c97..61a29bb5c4 100644 --- a/source/java/org/alfresco/repo/webservice/repository/ParentsQuerySession.java +++ b/source/java/org/alfresco/repo/webservice/repository/ParentsQuerySession.java @@ -25,6 +25,7 @@ import org.alfresco.repo.webservice.types.NamedValue; import org.alfresco.repo.webservice.types.Reference; import org.alfresco.repo.webservice.types.ResultSetRow; import org.alfresco.repo.webservice.types.ResultSetRowNode; +import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; @@ -63,7 +64,7 @@ public class ParentsQuerySession extends AbstractQuerySession /** * @see org.alfresco.repo.webservice.repository.QuerySession#getNextResultsBatch(org.alfresco.service.cmr.search.SearchService, org.alfresco.service.cmr.repository.NodeService, org.alfresco.service.namespace.NamespaceService) */ - public QueryResult getNextResultsBatch(SearchService searchService, NodeService nodeService, NamespaceService namespaceService) + public QueryResult getNextResultsBatch(SearchService searchService, NodeService nodeService, NamespaceService namespaceService, DictionaryService dictionaryService) { QueryResult queryResult = null; @@ -100,13 +101,7 @@ public class ParentsQuerySession extends AbstractQuerySession int col = 0; for (QName propName : props.keySet()) { - String value = null; - Serializable valueObj = props.get(propName); - if (valueObj != null) - { - value = valueObj.toString(); - } - columns[col] = new NamedValue(propName.toString(), value); + columns[col] = Utils.createNamedValue(dictionaryService, propName, props.get(propName)); col++; } diff --git a/source/java/org/alfresco/repo/webservice/repository/QuerySession.java b/source/java/org/alfresco/repo/webservice/repository/QuerySession.java index 18f437ac20..94d50b5d8b 100644 --- a/source/java/org/alfresco/repo/webservice/repository/QuerySession.java +++ b/source/java/org/alfresco/repo/webservice/repository/QuerySession.java @@ -18,6 +18,7 @@ package org.alfresco.repo.webservice.repository; import java.io.Serializable; +import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.namespace.NamespaceService; @@ -51,6 +52,9 @@ public interface QuerySession extends Serializable * @return QueryResult containing the next batch of results or null if there * are no more results */ - public QueryResult getNextResultsBatch(SearchService searchService, NodeService nodeService, - NamespaceService namespaceService); + public QueryResult getNextResultsBatch( + SearchService searchService, + NodeService nodeService, + NamespaceService namespaceService, + DictionaryService dictionaryService); } diff --git a/source/java/org/alfresco/repo/webservice/repository/RepositoryWebService.java b/source/java/org/alfresco/repo/webservice/repository/RepositoryWebService.java index dd6ac17e8d..d7c073f5e7 100644 --- a/source/java/org/alfresco/repo/webservice/repository/RepositoryWebService.java +++ b/source/java/org/alfresco/repo/webservice/repository/RepositoryWebService.java @@ -44,7 +44,6 @@ import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.TypeDefinition; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; import org.alfresco.service.namespace.QName; import org.apache.axis.MessageContext; import org.apache.commons.logging.Log; @@ -199,7 +198,7 @@ public class RepositoryWebService extends AbstractWebService implements .getBatchSize(msgContext), store, query, includeMetaData); QueryResult queryResult = querySession .getNextResultsBatch(this.searchService, this.nodeService, - this.namespaceService); + this.namespaceService, this.dictionaryService); // add the session to the cache if there are more results to come if (queryResult.getQuerySession() != null) @@ -255,7 +254,7 @@ public class RepositoryWebService extends AbstractWebService implements .getBatchSize(MessageContext.getCurrentContext()), node); QueryResult queryResult = querySession .getNextResultsBatch(this.searchService, this.nodeService, - this.namespaceService); + this.namespaceService, this.dictionaryService); // add the session to the cache if there are more results to come if (queryResult.getQuerySession() != null) @@ -314,7 +313,7 @@ public class RepositoryWebService extends AbstractWebService implements .getBatchSize(MessageContext.getCurrentContext()), node); QueryResult queryResult = querySession .getNextResultsBatch(this.searchService, this.nodeService, - this.namespaceService); + this.namespaceService, this.dictionaryService); // add the session to the cache if there are more results to come if (queryResult.getQuerySession() != null) @@ -368,7 +367,7 @@ public class RepositoryWebService extends AbstractWebService implements QuerySession querySession = new AssociatedQuerySession(Utils.getBatchSize(MessageContext.getCurrentContext()), node); QueryResult queryResult = querySession .getNextResultsBatch(this.searchService, this.nodeService, - this.namespaceService); + this.namespaceService, this.dictionaryService); // add the session to the cache if there are more results to come if (queryResult.getQuerySession() != null) @@ -435,7 +434,7 @@ public class RepositoryWebService extends AbstractWebService implements // get the next batch of results queryResult = session.getNextResultsBatch(this.searchService, - this.nodeService, this.namespaceService); + this.nodeService, this.namespaceService, this.dictionaryService); // remove the QuerySession from the cache if there are no more // results to come @@ -647,17 +646,8 @@ public class RepositoryWebService extends AbstractWebService implements NamedValue[] properties = new NamedValue[propertyMap.size()]; int propertyIndex = 0; for (Map.Entry entry : propertyMap.entrySet()) - { - String value = null; - try - { - value = DefaultTypeConverter.INSTANCE.convert(String.class, entry.getValue()); - } - catch (Throwable exception) - { - value = entry.getValue().toString(); - } - properties[propertyIndex] = new NamedValue(entry.getKey().toString(), value); + { + properties[propertyIndex] = Utils.createNamedValue(this.dictionaryService, entry.getKey(), entry.getValue()); propertyIndex++; } diff --git a/source/java/org/alfresco/repo/webservice/repository/ResultSetQuerySession.java b/source/java/org/alfresco/repo/webservice/repository/ResultSetQuerySession.java index 5867c9b7f5..ad4a21824e 100644 --- a/source/java/org/alfresco/repo/webservice/repository/ResultSetQuerySession.java +++ b/source/java/org/alfresco/repo/webservice/repository/ResultSetQuerySession.java @@ -24,14 +24,15 @@ import org.alfresco.repo.webservice.types.NamedValue; import org.alfresco.repo.webservice.types.Query; import org.alfresco.repo.webservice.types.ResultSetRowNode; import org.alfresco.repo.webservice.types.Store; +import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.Path; -import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; import org.alfresco.service.cmr.search.ResultSet; import org.alfresco.service.cmr.search.ResultSetRow; import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -70,7 +71,7 @@ public class ResultSetQuerySession extends AbstractQuerySession /** * @see org.alfresco.repo.webservice.repository.QuerySession#getNextResultsBatch(org.alfresco.service.cmr.search.SearchService, org.alfresco.service.cmr.repository.NodeService, org.alfresco.service.namespace.NamespaceService) */ - public QueryResult getNextResultsBatch(SearchService searchService, NodeService nodeService, NamespaceService namespaceService) + public QueryResult getNextResultsBatch(SearchService searchService, NodeService nodeService, NamespaceService namespaceService, DictionaryService dictionaryService) { QueryResult queryResult = null; @@ -114,16 +115,6 @@ public class ResultSetQuerySession extends AbstractQuerySession int col = 0; for (Path path : values.keySet()) { - String value = null; - try - { - value = DefaultTypeConverter.INSTANCE.convert(String.class, values.get(path)); - } - catch (Throwable exception) - { - value = values.get(path).toString(); - } - // Get the attribute QName from the result path String attributeName = path.last().toString(); if (attributeName.startsWith("@") == true) @@ -131,7 +122,7 @@ public class ResultSetQuerySession extends AbstractQuerySession attributeName = attributeName.substring(1); } - columns[col] = new NamedValue(attributeName, value); + columns[col] = Utils.createNamedValue(dictionaryService, QName.createQName(attributeName), values.get(path)); //new NamedValue(attributeName, value); col++; } diff --git a/source/java/web-services-application-context.xml b/source/java/web-services-application-context.xml index 96ab456779..bd826b1e6e 100644 --- a/source/java/web-services-application-context.xml +++ b/source/java/web-services-application-context.xml @@ -46,6 +46,9 @@ + + + diff --git a/source/wsdl/types.xsd b/source/wsdl/types.xsd index 6fe3d440fc..5eb4d416a5 100644 --- a/source/wsdl/types.xsd +++ b/source/wsdl/types.xsd @@ -208,7 +208,9 @@ + +