cancel
Showing results for 
Search instead for 
Did you mean: 

[urgent] How to get content after searching?

llin
Champ in-the-making
Champ in-the-making
Hello,

I am working on an application with searching inside Alfresco using Web Services. The most important thing is that people can click the link after searching to download/view a content without login.

Here are what I have in my application using Web Services until now, but have trouble with access content:

1. Start session
2. Searching Alfresco
3. results forwarded to a JSP page
4. End session

There are URLs on JSP for example <a href="
http://127.0.0.1/alfresco/download/direct/workspace/SpacesStore/4757f43b-67b5-11dc-b2b0-73f3497f8dfd...">  linking to a content node inside Alfresco. If I didn't end session as above, I could open the content. Otherwise, I would get error "java.lang.IllegalStateException: Cannot create a session after the response has been committed".

How can I deal with that? Keep the session all the time? What is the best practice with Web Services authentication?

Thanks in advance. I really need to solve it.

Ally
14 REPLIES 14

unknown-user
Champ on-the-rise
Champ on-the-rise
Hi llin

Long time back, you raised this issue. Now I am facing the same problem.
Can you please help me to solve this issue.
I want to open a file from alfresco without authentication.
To bypass this authentication screen, I am passing ticket id in the end of the URL.
But I am not able to open the file directly from Alfresco.
It's showing again Alfresco authentication screen.
Now if try to pass "admin" as a username and password as a "admin" then also it's not taking.

Kindly help me

Regards
Nishant

vsuarez
Champ in-the-making
Champ in-the-making
Try appending the next URL parameter: guest=true

vsuarez
Champ in-the-making
Champ in-the-making
And of course: the accessed content must have granted read permission to guest user.

unknown-user
Champ on-the-rise
Champ on-the-rise
Hi vsuarez

I have checked with guest=true also.
Actualy when i append ticket id or guest=true after the URL.then also it is showing login screen.
If i enter admin (username) and admin(password) in login screen, then it is not taking these username and password.

If i use URL without ticket or guest, then it is taking admin as a username and password.
Then i am able to see the file content.that means permission is there.

Kindly help me.

Regards
Nishant

vsuarez
Champ in-the-making
Champ in-the-making
I've just tested with the content URL without session data (?ticket=[ticket_value]) but with "?guest=true" and it is working.

Remember to grant with read permission to "Guest" user over the content you are trying to access.

unknown-user
Champ on-the-rise
Champ on-the-rise
Hi vsuarez

Thanks for your response.
Actuly my files are under company home like following—-
company home—> NEB —> a1234—-> OfferLetter.pdf

And i can see this tree structure after login as "admin".
You are right if file is under guest user then we can see the file without authentication.

But i want to see this file by adding ticket id in the url.
when i add ticket id in URL then also it is showing login screen and then if i enter admin (username & password), it is not taking. I think problem with the ticket id only.

Regards
Nishant

vsuarez
Champ in-the-making
Champ in-the-making
The content service returns a Content object with a "getUrl()" method. This content service has a "read" method that accepts a Predicate parameter which will contain your "fileRef" variable; the second parameter must be the "{http://www.alfresco.org/model/content/1.0}content" string value.

Then you must use content.getUrl() + "?ticket=[TIKECT]" to access your data. With this procedure it is not necessary to grant special permission to anybody nor the building of the URL by yourself.

unknown-user
Champ on-the-rise
Champ on-the-rise
Hi vsuarez

Still I am facing the same problem.
when i append ticket id after the URL, it is showing the login screen and it's not taking admin (Username & password) also.

As you suggest i updated my code.
Regards
Nishant

vsuarez
Champ in-the-making
Champ in-the-making
What amount of time do you give to your ticket?

I guess you have used a WsSecurityHandler where you specify the expiration time of your request. Is this time too short?