Dark Star1
Dark Star1

Reputation: 7393

How to pass a workspace url as a parameter to the repository in alfresco share?

I am trying to pass the string representation of a nodeRef as a parameter to the repository like so:
url: Alfresco.constants.PROXY_URI + "synapture/commande/commande-get/" + new Alfresco.util.NodeRef(commandeObj.commandeNodeRef)

however when I look at the debugger and output the url.templateArgs. on the repository side the first '/' after workspace is stripped.

Upvotes: 0

Views: 898

Answers (2)

Tahir Malik
Tahir Malik

Reputation: 6643

If you look at actions.js (web-client JavaScript file) you'll see the following:

var jsNode = record.jsNode,
            nodeRef = jsNode.isLink ? jsNode.linkedNode.nodeRef : jsNode.nodeRef,
strNodeRef = nodeRef.toString()........

The url is then being used at an action: documentDetailsUrl: fnPageURL("document-details?nodeRef=" + strNodeRef),

The object recordd.jsNode is defined elsewhere:

record.jsNode = new Alfresco.util.Node(response.json.item.node);

So probably you could do the following in your case: 1. just add the toString() to the newly created Alfresco.Util.NodeRef object. 2. If that doesn't work, create a Alfresco.util.Node and do a toString()

Upvotes: 1

alfrescian
alfrescian

Reputation: 4079

Input auf Alfresco.util.NodeRef should be a string in NodeRef-Format, e.g. workspaces://SpacesStore/02f.... return value is a JS object that constains amongst others a property 'uri' So, if commandeObj.commandeNodeRef is a String in NodeRef-Format, then the following code will do the job (add '.uri' to get the NodeRef in URI format):

url: Alfresco.constants.PROXY_URI + "synapture/commande/commande-get/" + new Alfresco.util.NodeRef(commandeObj.commandeNodeRef).uri

Your Backend-Webscript (*desc.xml)should be defined as following (by the way, that's not a nice RESTful URL ;-)):

synapture/commande/commande-get/{store_type}/{store_id}/{id}

Inside your Backend Webscript:

 var storeType = url.templateArgs.store_type,
 storeId = url.templateArgs.store_id,
 id = url.templateArgs.id,
 nodeRef = storeType + "://" + storeId + "/" + id,
 node = utils.getNodeFromString(nodeRef);

Upvotes: 1

Related Questions