Fix the path being set on the Reference objects as it wasn't a valid XPath. Added some unit tests to clear up AR-1186.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4993 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2007-02-01 11:19:20 +00:00
parent fccfa9fc65
commit fd6e9643b9
9 changed files with 38 additions and 37 deletions

View File

@@ -341,11 +341,11 @@ public class CMLUtil
} }
if (sourceNodeRef != null) if (sourceNodeRef != null)
{ {
result.setSource(Utils.convertToReference(this.nodeService, sourceNodeRef)); result.setSource(Utils.convertToReference(this.nodeService, this.namespaceService, sourceNodeRef));
} }
if (destinationNodeRef != null) if (destinationNodeRef != null)
{ {
result.setDestination(Utils.convertToReference(this.nodeService, destinationNodeRef)); result.setDestination(Utils.convertToReference(this.nodeService, this.namespaceService, destinationNodeRef));
} }
// Sort out the count ??? // Sort out the count ???
return result; return result;

View File

@@ -359,7 +359,7 @@ public class CMLUtilTest extends BaseSpringTest
this.nodeService.addChild(this.folderNodeRef, this.nodeRef, ContentModel.ASSOC_CONTAINS, ContentModel.ASSOC_CONTAINS); this.nodeService.addChild(this.folderNodeRef, this.nodeRef, ContentModel.ASSOC_CONTAINS, ContentModel.ASSOC_CONTAINS);
CMLRemoveChild removeChild = new CMLRemoveChild(); CMLRemoveChild removeChild = new CMLRemoveChild();
removeChild.setFrom(Utils.convertToReference(this.nodeService, this.folderNodeRef)); removeChild.setFrom(Utils.convertToReference(this.nodeService, this.namespaceService, this.folderNodeRef));
removeChild.setWhere(createPredicate(this.nodeRef)); removeChild.setWhere(createPredicate(this.nodeRef));
CML cml = new CML(); CML cml = new CML();
@@ -448,7 +448,7 @@ public class CMLUtilTest extends BaseSpringTest
{ {
Predicate predicate = new Predicate(); Predicate predicate = new Predicate();
predicate.setStore(Utils.convertToStore(nodeRef.getStoreRef())); predicate.setStore(Utils.convertToStore(nodeRef.getStoreRef()));
predicate.setNodes(new Reference[]{Utils.convertToReference(this.nodeService, nodeRef)}); predicate.setNodes(new Reference[]{Utils.convertToReference(this.nodeService, this.namespaceService, nodeRef)});
return predicate; return predicate;
} }

View File

@@ -309,7 +309,7 @@ public class Utils
* The node to create a Reference for * The node to create a Reference for
* @return The Reference * @return The Reference
*/ */
public static Reference convertToReference(NodeService nodeService, NodeRef node) public static Reference convertToReference(NodeService nodeService, NamespaceService namespaceService, NodeRef node)
{ {
Reference ref = new Reference(); Reference ref = new Reference();
Store store = new Store(node.getStoreRef().getProtocol(), node.getStoreRef().getIdentifier()); Store store = new Store(node.getStoreRef().getProtocol(), node.getStoreRef().getIdentifier());
@@ -322,11 +322,11 @@ public class Utils
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{ {
logger.debug("setting path for reference to: " + nodeService.getPath(node).toString()); logger.debug("setting path for reference to: " + nodeService.getPath(node).toPrefixString(namespaceService));
} }
// so clients can get the path too // so clients can get the path too
ref.setPath(nodeService.getPath(node).toString()); ref.setPath(nodeService.getPath(node).toPrefixString(namespaceService));
} }
return ref; return ref;
@@ -560,12 +560,13 @@ public class Utils
*/ */
public static Version convertToVersion( public static Version convertToVersion(
NodeService nodeService, NodeService nodeService,
NamespaceService namespaceService,
org.alfresco.service.cmr.version.Version version) org.alfresco.service.cmr.version.Version version)
{ {
Version webServiceVersion = new Version(); Version webServiceVersion = new Version();
// Set the basic properties // Set the basic properties
webServiceVersion.setId(Utils.convertToReference(nodeService, version webServiceVersion.setId(Utils.convertToReference(nodeService, namespaceService, version
.getFrozenStateNodeRef())); .getFrozenStateNodeRef()));
webServiceVersion.setCreator(version.getCreator()); webServiceVersion.setCreator(version.getCreator());
webServiceVersion.setLabel(version.getVersionLabel()); webServiceVersion.setLabel(version.getVersionLabel());

View File

@@ -128,7 +128,7 @@ public class AccessControlWebService extends AbstractWebService implements Acces
{ {
// Create the acl // Create the acl
ACL acl = new ACL(); ACL acl = new ACL();
acl.setReference(Utils.convertToReference(this.nodeService, node)); acl.setReference(Utils.convertToReference(this.nodeService, this.namespaceService, node));
// Set the inhertied value // Set the inhertied value
boolean inheritPermission = this.permissionService.getInheritParentPermissions(node); boolean inheritPermission = this.permissionService.getInheritParentPermissions(node);
@@ -332,7 +332,7 @@ public class AccessControlWebService extends AbstractWebService implements Acces
// Create the permissions result object // Create the permissions result object
GetPermissionsResult result = new GetPermissionsResult(); GetPermissionsResult result = new GetPermissionsResult();
result.setReference(Utils.convertToReference(this.nodeService, node)); result.setReference(Utils.convertToReference(this.nodeService, this.namespaceService, node));
result.setPermissions((String[])permissions.toArray(new String[permissions.size()])); result.setPermissions((String[])permissions.toArray(new String[permissions.size()]));
// Add result to array // Add result to array
@@ -451,7 +451,7 @@ public class AccessControlWebService extends AbstractWebService implements Acces
} }
// Add to the results list // Add to the results list
results.add(new HasPermissionsResult(Utils.convertToReference(this.nodeService, node), permission, accessState)); results.add(new HasPermissionsResult(Utils.convertToReference(this.nodeService, this.namespaceService, node), permission, accessState));
} }
} }
@@ -556,7 +556,7 @@ public class AccessControlWebService extends AbstractWebService implements Acces
String owner = this.ownableService.getOwner(node); String owner = this.ownableService.getOwner(node);
// Marshal into result // Marshal into result
result[count] = new OwnerResult(Utils.convertToReference(this.nodeService, node), owner); result[count] = new OwnerResult(Utils.convertToReference(this.nodeService, this.namespaceService, node), owner);
count ++; count ++;
} }
@@ -609,7 +609,7 @@ public class AccessControlWebService extends AbstractWebService implements Acces
this.ownableService.setOwner(node, owner); this.ownableService.setOwner(node, owner);
// Marshal into result // Marshal into result
result[count] = new OwnerResult(Utils.convertToReference(this.nodeService, node), owner); result[count] = new OwnerResult(Utils.convertToReference(this.nodeService, this.namespaceService, node), owner);
count ++; count ++;
} }

View File

@@ -483,7 +483,7 @@ public class ActionWebService extends AbstractWebService implements ActionServic
// Create the web service action object // Create the web service action object
org.alfresco.repo.webservice.action.Action webServiceAction = new org.alfresco.repo.webservice.action.Action( org.alfresco.repo.webservice.action.Action webServiceAction = new org.alfresco.repo.webservice.action.Action(
Utils.convertToReference(this.nodeService, action.getNodeRef()), Utils.convertToReference(this.nodeService, this.namespaceService, action.getNodeRef()),
action.getId(), action.getId(),
action.getActionDefinitionName(), action.getActionDefinitionName(),
action.getTitle(), action.getTitle(),
@@ -860,7 +860,7 @@ public class ActionWebService extends AbstractWebService implements ActionServic
{ {
// Create the execution result object and set the action reference // Create the execution result object and set the action reference
ActionExecutionResult executionResult = new ActionExecutionResult(); ActionExecutionResult executionResult = new ActionExecutionResult();
executionResult.setReference(Utils.convertToReference(this.nodeService, nodeRef)); executionResult.setReference(Utils.convertToReference(this.nodeService, this.namespaceService, nodeRef));
// Tyr and execute the actions // Tyr and execute the actions
List<org.alfresco.repo.webservice.action.Action> executedActions = new ArrayList<org.alfresco.repo.webservice.action.Action>(10); List<org.alfresco.repo.webservice.action.Action> executedActions = new ArrayList<org.alfresco.repo.webservice.action.Action>(10);
@@ -946,12 +946,12 @@ public class ActionWebService extends AbstractWebService implements ActionServic
NodeRef owningNodeRef = this.ruleService.getOwningNodeRef(rule); NodeRef owningNodeRef = this.ruleService.getOwningNodeRef(rule);
if (owningNodeRef != null) if (owningNodeRef != null)
{ {
owningReference = Utils.convertToReference(this.nodeService, owningNodeRef); owningReference = Utils.convertToReference(this.nodeService, this.namespaceService, owningNodeRef);
} }
// Create the web service rule object // Create the web service rule object
org.alfresco.repo.webservice.action.Rule webServiceRule = new org.alfresco.repo.webservice.action.Rule( org.alfresco.repo.webservice.action.Rule webServiceRule = new org.alfresco.repo.webservice.action.Rule(
Utils.convertToReference(this.nodeService, rule.getNodeRef()), Utils.convertToReference(this.nodeService, this.namespaceService, rule.getNodeRef()),
owningReference, owningReference,
rule.getRuleTypes().toArray(new String[rule.getRuleTypes().size()]), rule.getRuleTypes().toArray(new String[rule.getRuleTypes().size()]),
rule.getTitle(), rule.getTitle(),

View File

@@ -183,8 +183,8 @@ public class AuthoringWebService extends AbstractWebService implements
} }
// store the results // store the results
originals[x] = Utils.convertToReference(AuthoringWebService.this.nodeService, original); originals[x] = Utils.convertToReference(AuthoringWebService.this.nodeService, AuthoringWebService.this.namespaceService, original);
workingCopies[x] = Utils.convertToReference(AuthoringWebService.this.nodeService, workingCopy); workingCopies[x] = Utils.convertToReference(AuthoringWebService.this.nodeService, AuthoringWebService.this.namespaceService, workingCopy);
} }
// setup the result object // setup the result object
@@ -248,12 +248,12 @@ public class AuthoringWebService extends AbstractWebService implements
NodeRef checkedInNode = AuthoringWebService.this.cociService.checkin(node, mapComments, null, keepCheckedOut); NodeRef checkedInNode = AuthoringWebService.this.cociService.checkin(node, mapComments, null, keepCheckedOut);
// Add the results to the array // Add the results to the array
checkedIn[iIndex] = Utils.convertToReference(AuthoringWebService.this.nodeService, checkedInNode); checkedIn[iIndex] = Utils.convertToReference(AuthoringWebService.this.nodeService, AuthoringWebService.this.namespaceService, checkedInNode);
// Only return the working copies if the node is keep checked out otherwise the working copies have been deleted // Only return the working copies if the node is keep checked out otherwise the working copies have been deleted
if (keepCheckedOut == true) if (keepCheckedOut == true)
{ {
listWorkingCopies.add(Utils.convertToReference(AuthoringWebService.this.nodeService, node)); listWorkingCopies.add(Utils.convertToReference(AuthoringWebService.this.nodeService, AuthoringWebService.this.namespaceService, node));
} }
iIndex++; iIndex++;
} }
@@ -333,7 +333,7 @@ public class AuthoringWebService extends AbstractWebService implements
contentUrl, contentUrl,
keepCheckedOut); keepCheckedOut);
// Return the orig node ref // Return the orig node ref
return Utils.convertToReference(AuthoringWebService.this.nodeService, origNodeRef); return Utils.convertToReference(AuthoringWebService.this.nodeService, AuthoringWebService.this.namespaceService, origNodeRef);
} }
}); });
} }
@@ -380,8 +380,8 @@ public class AuthoringWebService extends AbstractWebService implements
NodeRef origNode = AuthoringWebService.this.cociService.cancelCheckout(node); NodeRef origNode = AuthoringWebService.this.cociService.cancelCheckout(node);
// Set the value in the arrays // Set the value in the arrays
origNodes[iIndex] = Utils.convertToReference(AuthoringWebService.this.nodeService, origNode); origNodes[iIndex] = Utils.convertToReference(AuthoringWebService.this.nodeService, AuthoringWebService.this.namespaceService, origNode);
workingCopies[iIndex] = Utils.convertToReference(AuthoringWebService.this.nodeService, node); workingCopies[iIndex] = Utils.convertToReference(AuthoringWebService.this.nodeService, AuthoringWebService.this.namespaceService, node);
iIndex ++; iIndex ++;
} }
@@ -433,7 +433,7 @@ public class AuthoringWebService extends AbstractWebService implements
{ {
LockType convertedLockType = convertToLockType(lockType); LockType convertedLockType = convertToLockType(lockType);
AuthoringWebService.this.lockService.lock(node, convertedLockType, 0, lockChildren); AuthoringWebService.this.lockService.lock(node, convertedLockType, 0, lockChildren);
result[iIndex] = Utils.convertToReference(AuthoringWebService.this.nodeService, node); result[iIndex] = Utils.convertToReference(AuthoringWebService.this.nodeService, AuthoringWebService.this.namespaceService, node);
iIndex++; iIndex++;
} }
@@ -501,7 +501,7 @@ public class AuthoringWebService extends AbstractWebService implements
{ {
AuthoringWebService.this.lockService.unlock(node, unlockChildren); AuthoringWebService.this.lockService.unlock(node, unlockChildren);
result[iIndex] = Utils.convertToReference(AuthoringWebService.this.nodeService, node); result[iIndex] = Utils.convertToReference(AuthoringWebService.this.nodeService, AuthoringWebService.this.namespaceService, node);
iIndex++; iIndex++;
} }
@@ -555,7 +555,7 @@ public class AuthoringWebService extends AbstractWebService implements
LockStatus lockStatus = new LockStatus(); LockStatus lockStatus = new LockStatus();
lockStatus.setLockOwner(lockOwner); lockStatus.setLockOwner(lockOwner);
lockStatus.setLockType(lockTypeEnum); lockStatus.setLockType(lockTypeEnum);
lockStatus.setNode(Utils.convertToReference(AuthoringWebService.this.nodeService, node)); lockStatus.setNode(Utils.convertToReference(AuthoringWebService.this.nodeService, AuthoringWebService.this.namespaceService, node));
result[iIndex] = lockStatus; result[iIndex] = lockStatus;
iIndex++; iIndex++;
@@ -634,8 +634,8 @@ public class AuthoringWebService extends AbstractWebService implements
Collection<Version> versions = AuthoringWebService.this.versionService.createVersion(node, mapComments, versionChildren); Collection<Version> versions = AuthoringWebService.this.versionService.createVersion(node, mapComments, versionChildren);
for (Version version : versions) for (Version version : versions)
{ {
versionedReferences.add(Utils.convertToReference(AuthoringWebService.this.nodeService, version.getVersionedNodeRef())); versionedReferences.add(Utils.convertToReference(AuthoringWebService.this.nodeService, AuthoringWebService.this.namespaceService, version.getVersionedNodeRef()));
webServiceVersions.add(Utils.convertToVersion(AuthoringWebService.this.nodeService, version)); webServiceVersions.add(Utils.convertToVersion(AuthoringWebService.this.nodeService, AuthoringWebService.this.namespaceService, version));
} }
} }
@@ -689,7 +689,7 @@ public class AuthoringWebService extends AbstractWebService implements
int iIndex = 0; int iIndex = 0;
for (Version version : versions) for (Version version : versions)
{ {
webServiceVersions[iIndex] = Utils.convertToVersion(AuthoringWebService.this.nodeService, version); webServiceVersions[iIndex] = Utils.convertToVersion(AuthoringWebService.this.nodeService, AuthoringWebService.this.namespaceService, version);
iIndex ++; iIndex ++;
} }
webServiceVersionHistory.setVersions(webServiceVersions); webServiceVersionHistory.setVersions(webServiceVersions);

View File

@@ -176,7 +176,7 @@ public class ClassificationWebService extends AbstractWebService implements
} }
Category category = new Category(); Category category = new Category();
category.setId(Utils.convertToReference(this.nodeService, nodeRef)); category.setId(Utils.convertToReference(this.nodeService, this.namespaceService, nodeRef));
category.setTitle(title); category.setTitle(title);
// TODO need to set the description // TODO need to set the description
return category; return category;
@@ -274,7 +274,7 @@ public class ClassificationWebService extends AbstractWebService implements
int iIndex = 0; int iIndex = 0;
for (NodeRef categoryNodeRef : categoryNodeRefs) for (NodeRef categoryNodeRef : categoryNodeRefs)
{ {
categoryReferences[iIndex] = Utils.convertToReference(ClassificationWebService.this.nodeService, categoryNodeRef); categoryReferences[iIndex] = Utils.convertToReference(ClassificationWebService.this.nodeService, ClassificationWebService.this.namespaceService, categoryNodeRef);
iIndex ++; iIndex ++;
} }
@@ -291,7 +291,7 @@ public class ClassificationWebService extends AbstractWebService implements
// Create the category result object // Create the category result object
CategoriesResult categoryResult = new CategoriesResult(); CategoriesResult categoryResult = new CategoriesResult();
categoryResult.setNode(Utils.convertToReference(ClassificationWebService.this.nodeService, nodeRef)); categoryResult.setNode(Utils.convertToReference(ClassificationWebService.this.nodeService, ClassificationWebService.this.namespaceService, nodeRef));
categoryResult.setCategories(appliedCategories.toArray(new AppliedCategory[appliedCategories.size()])); categoryResult.setCategories(appliedCategories.toArray(new AppliedCategory[appliedCategories.size()]));
result.add(categoryResult); result.add(categoryResult);
@@ -400,7 +400,7 @@ public class ClassificationWebService extends AbstractWebService implements
// Create the category result object // Create the category result object
CategoriesResult categoryResult = new CategoriesResult(); CategoriesResult categoryResult = new CategoriesResult();
categoryResult.setNode(Utils.convertToReference(ClassificationWebService.this.nodeService, nodeRef)); categoryResult.setNode(Utils.convertToReference(ClassificationWebService.this.nodeService, ClassificationWebService.this.namespaceService, nodeRef));
categoryResult.setCategories(appliedCategories.toArray(new AppliedCategory[appliedCategories.size()])); categoryResult.setCategories(appliedCategories.toArray(new AppliedCategory[appliedCategories.size()]));
result.add(categoryResult); result.add(categoryResult);

View File

@@ -147,7 +147,7 @@ public class ContentWebService extends AbstractWebService implements
// Create the content object // Create the content object
ContentFormat format = new ContentFormat(contentReader.getMimetype(), contentReader.getEncoding()); ContentFormat format = new ContentFormat(contentReader.getMimetype(), contentReader.getEncoding());
content = new Content(Utils.convertToReference(this.nodeService, nodeRef), property, contentReader.getSize(), format, downloadUrl); content = new Content(Utils.convertToReference(this.nodeService, this.namespaceService, nodeRef), property, contentReader.getSize(), format, downloadUrl);
// Debug // Debug
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
@@ -163,7 +163,7 @@ public class ContentWebService extends AbstractWebService implements
else else
{ {
// Create an empty content object // Create an empty content object
content = new Content(Utils.convertToReference(this.nodeService, nodeRef), property, 0, null, null); content = new Content(Utils.convertToReference(this.nodeService, this.namespaceService, nodeRef), property, 0, null, null);
// Debug // Debug
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())

View File

@@ -614,7 +614,7 @@ public class RepositoryWebService extends AbstractWebService implements
for (NodeRef nodeRef : nodeRefs) for (NodeRef nodeRef : nodeRefs)
{ {
// Get the nodes reference // Get the nodes reference
Reference reference = Utils.convertToReference(this.nodeService, nodeRef); Reference reference = Utils.convertToReference(this.nodeService, this.namespaceService, nodeRef);
// Get the nodes type // Get the nodes type
String type = this.nodeService.getType(nodeRef).toString(); String type = this.nodeService.getType(nodeRef).toString();