cancel
Showing results for 
Search instead for 
Did you mean: 

Urgent:How to validate ticket using Alfresco Web Service API

itsard
Champ in-the-making
Champ in-the-making
Hi,
How do I validate ticket using Alfresco Web Service APIs.I can get a ticket after authenticating the user but how do I pass that ticket
to the subsequent api calls as those apis dont have ticket parameter as an argument.
The Rivet apis that I have checked have the ticket parameter as an argument. Is that an advantage of the Rivet api
over the web service api.
24 REPLIES 24

itsard
Champ in-the-making
Champ in-the-making
what I am trying to do is get the reference of the document in the repository.
noderef I think is that reference you talked abt…is it?
Ideally what should I use as a unique key for a document stored in the repository?

itsard
Champ in-the-making
Champ in-the-making
While creating the document i get a org.alfresco.webservice.types.Reference object in return. Do i use this as the unique key for searching and all
operations on the document??…Do i store the uuid of this reference object in my database?… How do i uniquely identify the document for performing further actions.??

cheffilet
Champ in-the-making
Champ in-the-making
If you have the chance you should be in touch with NodeRefs. Thats as far as i can see the securest method to gain access to a repository. So if its possible i would prefer such a way.

How does you know that the path /app:company_home/cm:sample_folder/ points to a particular file? How it is mapped? Do you have a separat-managed file-repository (e.g. other cms-system) and you want to keep synchron both repos? Whats the case?

cheffilet
Champ in-the-making
Champ in-the-making
Searching on a document to test if a particular text is part of the contents you could use following:

@sys\:node-uuid:"4109ffeb-6a1c-4e66-b9ca-467f18e38686" AND TEXT: "guy"
So if you create document using web services you can use the returned reference to obtain the uuid.
You got your uuid following:

org.alfresco.webservice.types.Reference.getUuid()
Why should you store the uuid in another database? It depends on your use-case 😉

itsard
Champ in-the-making
Champ in-the-making
Thanks for ur reply  Smiley Happy
I get the uuid of the doc. now for further operations on that document, i create a new reference object,and set that uuid i have and the store.
Reference r1 = new Reference();
      r1.setUuid("b29cb2e6-1a2b-49c3-8b71-327a34dacc88");
      r1.setStore(STORE);
I pass this newly created reference object to perform actions like read,write,chkin,chkout.Hope this is the correct way.
If  not let me know.
After i have created versions for a document,i use the version history object to get the history.
But in the namedvalue pairs returned i dont get the uuid of all those versions. I do get the frozennoderef i.e. the uuid of the base object but not that of all versions.
My query is how do I read the content of all the versions as my way is setting the uuid in the reference object and calling the read api.

Thanks again.

itsard
Champ in-the-making
Champ in-the-making
Hi,
I am facing a random ticket error.
org.apache.ws.security.WSSecurityException: WSHandler: password callback failed; nested exception is:
        org.alfresco.webservice.util.WebServiceException: Ticket could not be found when calling callback handler.
        at org.apache.ws.security.handler.WSHandler.performCallback(WSHandler.java:709)
        at org.apache.ws.security.handler.WSHandler.readPwViaCallbackClass(WSHandler.java:670)
        at org.apache.ws.security.handler.WSHandler.getPassword(WSHandler.java:625)
        at org.apache.ws.security.action.UsernameTokenAction.execute(UsernameTokenAction.java:31)
        at org.apache.ws.security.handler.WSHandler.doSenderAction(WSHandler.java:192)
        at org.apache.ws.axis.security.WSDoAllSender.invoke(WSDoAllSender.java:170)
        at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
        at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
        at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
        at org.apache.axis.client.AxisClient.invoke(AxisClient.java:127)
        at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
        at org.apache.axis.client.Call.invoke(Call.java:2767)
        at org.apache.axis.client.Call.invoke(Call.java:2443)
        at org.apache.axis.client.Call.invoke(Call.java:2366)
        at org.apache.axis.client.Call.invoke(Call.java:1812)
        at org.alfresco.webservice.content.ContentServiceSoapBindingStub.read(ContentServiceSoapBindingStub.java:467)
Caused by: org.alfresco.webservice.util.WebServiceException: Ticket could not be found when calling callback handler.
        at org.alfresco.webservice.util.AuthenticationUtils.handle(AuthenticationUtils.java:171)
        at org.apache.ws.security.handler.WSHandler.performCallback(WSHandler.java:707)
This code :
                AuthenticationUtils.startSession(lStrLoginName,lStrPassword);
                AuthenticationDetails details1=AuthenticationUtils.getAuthenticationDetails();
                lStrTicket=details1.getTicket();
returns me a ticket but that ticket for some reason is not passed to the api call.
This is a random error and sometimes it works.

cheffilet
Champ in-the-making
Champ in-the-making
Regarding you´re issue regarding versioning: i dont know about a VersionWebService. As far i can see, its not even possible to search for nodes in a VersionStore: please view therefore: https://issues.alfresco.com/jira/browse/ARCHIVE-158

Your last question is confusing me because if you do a succefuly authentication against Alfresco it should be possible to call a Service in the same Thread.

itsard
Champ in-the-making
Champ in-the-making
Its like once I login in alfresco using the startSession(uname,pwd) method, it does return me a ticket.
Now what happens is that a call is made to upload and the authentication works…when i again give the web service call, it says no ticket found.
Then after trying for 3-4 hits, it again finds the ticket in the call without even using startsession() again.
In some calls the ticket gets passed while in some it doesnt and it is random.
I have used the authentication api as mentioned in the previous post.
Can you tell what can the prob be? Why does the ticket not pass in some calls while in next call it passes.
Thanks for ur reply.

cheffilet
Champ in-the-making
Champ in-the-making
Please try following in your code multiple times if this works:




  AuthenticationUtils.startSession(lStrLoginName,lStrPassword);
  RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
  Query query = new Query();

  query.setLanguage(Constants.QUERY_LANG_LUCENE);
  query.setStatement("PATH:\"app:company_home/app:user_homes\" AND TYPE:\\{http\\://www.alfresco.org/model/content/1.0\\}folder");

  QueryResult result = null;
   …
   result = repositoryService.query(store, query, false);
   …
   AuthenticationUtils.endSession();

This  should work multiple times without any issue. Can you commit this?

itsard
Champ in-the-making
Champ in-the-making
I actually dint get this solution.
It first started a session…then queried the repository and then ended the session.
Whats multiple times in this??
Kindly make me understand this solution.