cancel
Showing results for 
Search instead for 
Did you mean: 

Remote call to lucene search

rhakaro
Champ in-the-making
Champ in-the-making
Hi there!

I´m trying to make a search in a *.get.js in Share file.

The search I´m seeking for is the next:


var node = search.findNode(nodeRef);

I have read that "search" is only for Alfresco explorer, so now I want to do something like:


var scriptURL= "/cons/search?findNode=" + nodeRef;
var connector = remote.connect("alfresco");
var node = connector.call(scriptURL);

But of course, it doesn´t work.

How can I develop a call to Alfresco explorer "search" to find a node by its nodeRef?? I´m using Share 3.4 Enterprise.

(All of that is for do a "node.removeAspect("cm:versionable");")

Thanks in advance, best regards!
6 REPLIES 6

bchevallereau
Champ in-the-making
Champ in-the-making
Hi,
You can use this webscript if you have the nodeRef :
/slingshot/doclib/node/workspace/SpacesStore/f69e7a3f-fc9c-472e-b7df-d6ba60e6cd43
It's the one used by the document details page.
Ben

rhakaro
Champ in-the-making
Champ in-the-making
Hi bchevallereau, thank you very much for answer!

I´m trying to make work this code, but I can´t remove the aspect to the content. I don´t know where is the problem.

         
var scriptURL= "/slingshot/doclib/node/" + nodeRef.replace(":/", "");
var connector = remote.connect("alfresco");
var result = connector.call(scriptURL);
            
if (result.status == 200){
   var data = eval('(' + result + ')');
   data.removeAspect("cm:versionable");
}

The error tell that removeAspect is not a function.

I have try this too:


if(data.length > 0){
   data[0].removeAspect("cm:versionable");
}

But nothing works.

The nodeRef seems to be rigth, cause I get it from the url (the script I´m modifying is document-actions.get.js)

Where is the problem??

Best regards!

bchevallereau
Champ in-the-making
Champ in-the-making
Hi,
When you execute your code data[0] is a JSONObject and it should be a ScriptNode object.
So you can use the search object like that :

var myAlfrescoNode = search.findNode(data.item.nodeRef);
myAlfrescoNode.removeAspect("cm:versionable");
Ben

rhakaro
Champ in-the-making
Champ in-the-making
Hi again!

I see two problems.

Doing this
var data = eval('(' + result + ')');
Data become a Javascript Object, isn´t it??

And then, I cannot user "search.findNode" because "search" object not exists in share, I´m correct?

Thank you very much.

bchevallereau
Champ in-the-making
Champ in-the-making
Hi
Yes, your variable data is a JSONObject
It depends where you execute your file.

If you want just to remove aspect, you can use this webscript:
/slingshot/doclib/action/aspects/node/workspace/SpacesStore/f69e7a3f-fc9c-472e-b7df-d6ba60e6cd43
using POST and send data :
{"added":[],"removed":["cm:versionable"]}

But if you need a more complex task, you should create your webscript.

Ben

rhakaro
Champ in-the-making
Champ in-the-making
Ok, thank you very much!

That thing is another war, jeje.

Your solution seems to be perfect to me.

Best regards!