2

I'm writting a custom action button and I want to get in my javascript:

(function() {
    YAHOO.Bubbling.fire("registerAction",
    {
        actionName: "onActionVerify",
        fn: function JSC_onActionVerify(record) {
             var ticket = sessiontickets.getTicket();
        }
    });
})();

the path of the file that I click on the action button like:

/Data Dictionary/Email Templates/activities/activities-email.ftl

And the ticket for authentication.

I'm making this on the share client side.

Any solution for both?

My question is not duplicated because I want the path of the file in the action and my question about the tickets was to pass to the web service... I need more than the question that was on suppose "duplicated"...

PRVS
  • 1,612
  • 4
  • 38
  • 75
  • 1
    Your question is not clear. Do you want to execute a CMIS query from the browser? – Marco Altieri Feb 16 '16 at 19:05
  • I want to Know how can I get the path on javascript because I want to send with a parâmeter to a web service localhost:8080/webapp?path=.. And I want to send a ticket too... Because i'm using CMIS on the webapp to obtain a file from Alfresco but I don't want to give user and pwd in the Java code CMIS. I want to make the authentication with a ticket. @MarcoAltieri – PRVS Feb 16 '16 at 19:50
  • 1
    There are multiple questions about getting a ticket in Alfresco/Share, google or lookup in stack. It's not that good to ask the same question again. – Tahir Malik Feb 16 '16 at 21:54
  • Even though @PRVS asked for a way to get the ticket, I do not think that it is the right solution for this use case. That's why I would not suggest to look the other answers. – Marco Altieri Feb 16 '16 at 22:05
  • 1
    Having said that, I still do not understand for what you are using activities-email.ftl – Marco Altieri Feb 16 '16 at 22:08
  • Because its a example, if I want this file on the web service to validate and return a response to alfresco. I want to call the web service and pass the parâmeters to know in the web service the path of the file (for PDF reader) and ticket for authentication. @MarcoAltieri – PRVS Feb 16 '16 at 22:26
  • @TahirMalik that not works for my problem as I saíd in the question – PRVS Feb 16 '16 at 22:31

1 Answers1

3

As usual, there are different options:

1) Call your external service directly from the browser.

In this case, you can generate the ticket and pass it to the service. The service will use it to access alfresco.

To generate the ticket you can write a webscript. Very simple webscript with the ftl that returns the session.ticket

You will not need to send username and password because you can use share as a proxy: you call /share/proxy/alfresco instead of /alfresco/service and the call is automatically authenticated.

2) The browser calls an Alfresco webscript (using share as a proxy) and the webscript calls your external service. The webscript can get the ticket from the session and pass it to the external service.

The function that receives the event when the action is clicked, as you have written in your code snipped, receives an argument: record.

One of the field of this object is the nodeRef of your file. Why do you think that you need the path? Isn't easier to use this nodeRef directly?

Anyway, if you really need the path then and you chose option 1), when you call the webscript to get the ticket, pass also the nodeRef and make the webscript return the path of the node together with the ticket. So you will call:

/share/proxy/alfresco/your-custom-webscript?nodeRef=workflow://SpaceStore/xxx...

And the webscript will return a json like:

{
    "ticket": "TICKET_121321_...",
    "qnamePath": "...."  
} 

If you chose option 2), call the webscript passing the nodeRef as in the previous example and the webscript will get the information necessary and pass it to the external service.

Marco Altieri
  • 3,726
  • 2
  • 33
  • 47
  • But I don't understand this. The browser calls? I have an external service in the link like: localhost:8080/webapp – PRVS Feb 16 '16 at 22:34
  • With the available javascipt library you can call Alfresco. See how "Alfresco.util.Ajax.request" is used. If you send this ajax call the share/proxy, the request will be forwarded to alfresco adding the necessary authentication. The webscript can then, return the ticket or execute the call to the external service. – Marco Altieri Feb 16 '16 at 23:31
  • But if I need the ticket for connection to CMIS in the webservice instead of make this: `Session session = cmisClient.getSession(connectionName, "admin", "admin");` the request substitute this? And to obtain the path of the file like I put in the question? To pass to the webservice from Alfresco ? You know how can I obtain this? – PRVS Feb 17 '16 at 07:57
  • Go for option 1). I have added more info – Marco Altieri Feb 17 '16 at 08:13
  • Ok I will do that! Thanks! For the path any solution? I make an action that calls the webscript and the webscript calls the webservice right? I need the path of the file of the action like `/Data Dictionary/Email Templates/activities/activities-email.ftl`. – PRVS Feb 17 '16 at 08:16
  • I will write a full answer later today. – Marco Altieri Feb 17 '16 at 08:18
  • Ok thank you so much! I appreciate your help and thank you so much! – PRVS Feb 17 '16 at 08:19
  • I already do it, include the path. Thanks! Now, I only need to see the best solution to send this parameters to the web service. – PRVS Feb 17 '16 at 15:35
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/103776/discussion-between-marco-altieri-and-prvs). – Marco Altieri Feb 17 '16 at 22:52
  • I answer in the chat ;) – PRVS Feb 18 '16 at 08:59