cancel
Showing results for 
Search instead for 
Did you mean: 

Reset favourites script

cristianfrog
Champ in-the-making
Champ in-the-making
Hi all,

I'm searching for a solution to manage or better saying RESET specific user's favourites. For this purpose I didn't find a function or maybe webscript, so I tried writing one by myself.

I figured out that to reset someone's favourites from Admin account I need to send this POST content:
{"org":{"alfresco":{"share":{"documents":{"favourites":""}}}}}


to this page:

http://localhost:8080/share/proxy/alfresco/api/people/USERNAME/preferences


It works fine when I do it manually through Live Http Headers, but can't get it work within a script.

Here how my JS script looks:

var simplehttpresult = "no result";
var xmlhttpresult = "no result";
var error = "no error";

// try calling the web script a couple different ways
try {

   //call the web service using SimpleHttpConnection
   simplehttpresult = SimpleHttpConnection
               .getContentAsString("http://localhost:8080/share/proxy/alfresco/api/people/usernametest/preferences");

   //call the web service synchronously via XMLHttpRequest
   XMLHttpRequest
                .open("POST", "http://localhost:8080/share/proxy/alfresco/api/people/usernametest/preferences",
                         false, "user", "pass");
   
   XMLHttpRequest.setRequestHeader("Host", "localhost:8080");
   XMLHttpRequest.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
   XMLHttpRequest.setRequestHeader("Cookie", "_alfTest=_alfTest; JSESSIONID=72F1A690CC001AF5080B86854CA10542; alfLogin=1374511322; alfUsername3=admin");
   
   XMLHttpRequest.send("{\"org\":{\"alfresco\":{\"share\":{\"documents\":{\"favourites\":\"\"}}}}}");
   xmlhttpresult = XMLHttpRequest.getResponseText();
   XMLHttpRequest.close();

}catch(ex){error = String(ex)}


How you can see I've used XMLHttpRequest to send the HTTP POST content, I found and installed the JAR library here:
http://www.unorganizedmachines.com/site/software-and-technology/34-software-development/97-calling-w...

It works well when I'm trying to send a HTTP Request to an external site or page (example: www.google.com) but it doesn't when I'm trying to reset favourites…

Can someone help me about this??
There is not much documentation about managing favourites  Smiley Sad
1 REPLY 1

zladuric
Champ on-the-rise
Champ on-the-rise
Do you get any errors? I bet you get authentication errors. I'm not sure if you can use this same ticket for (technically) another session.

Zlatko

Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.