cancel
Showing results for 
Search instead for 
Did you mean: 

Call a repository webscript from share

eureka
Champ in-the-making
Champ in-the-making
Hi,

my apologies if the question has already been asked (I didn't find it searching the forum) or if it seems a newbie question (I'm one).

So, my question is: I need to call a webscript deployed in Alfresco (Repository) from a bean deployed in share.

I've seen many examples on how to do that in javascript using the root scope object remote.

What is its Java counterpart, if any exist?

How could I emulate its behaviour in Java?

Thanks in advance for any reply.


Angelo
4 REPLIES 4

pmverma
Champ in-the-making
Champ in-the-making
Hi Angelo,
I am not sure what you want to do but I this will be helpful to you from some corner.

there are classes extending BaseScopableProcessorExtension which allow you to use them from js.
for eg,
we do people.createPerson(person) in javascripts, which create person.
Note here, there are two people class, one org.alfresco.repo.jscript.People and another org.alfresco.repo.template.People
you can see them which one extends BaseScopableProcessorExtension .

If you want to use those root scope object from your own java application then I will be not helpful to you.  :wink:

eureka
Champ in-the-making
Champ in-the-making
Hi  pmverma,

thank you for your fast reply.

Unfortunately my goal is to mimic a javascript code like


var connector = remote.connect("alfresco");
var data = connector.get("/sample/docprop.json");

// create json object from data
var result = eval('(' + data + ')');
model.docprop = result["docprop"];


in java.

I would like to know if there is a service or some other wrapper that acts as the remote object in javascript (see for example search object in javascript and SearchService in Foundation Java API), keeping in mind that tha java bean I have to write is going to be deployed in alfresco share app.

Angelo

eureka
Champ in-the-making
Champ in-the-making
I sorted that out.

You need to use code like this


final RequestContext rc = ThreadLocalRequestContext.getRequestContext();
final String userId rc.getUserId();
final Connector conn = rc.getServiceRegistry().getConnectorService().getConnector(ALFRESCO_ENDPOINT_ID, userId, ServletUtil.getSession());
final Response response = conn.call(REPO_WEB_SERVICE_URL);
if (response.getStatus().getCode() == Status.STATUS_OK) {
   //do something
} else {
   //do something else
}

Hope this helps someone else out there.

Angelo

kevinr
Star Contributor
Star Contributor
That's exactly the way to do it, thanks for posting it.

Kev