0

I am using Alfresco 4.2 and trying to find some user's favorites but the webscript that I'm using returns the results only for the current user. The user that I am investigating exists, I am sure.

What should I do? What am I doing wrong?

Here is the webscript call that works:

domain.com/alfresco/api/-default-/public/alfresco/versions/1/people/-me-/favorites

Here is the one that doesn't work:

domain.com/alfresco/api/-default-/public/alfresco/versions/1/people/user@tenant.com/favorites

and returns the following:

{"error":{"statusCode":404,"briefSummary":"04203980 The entity with id: user@tenant.com was not found","stackTrace":"[org.alfresco.rest.api.impl.PeopleImpl.validatePerson(PeopleImpl.java:155)

BTW, /favorite-sites instead of /favorites works for everyone.

newzad
  • 706
  • 1
  • 14
  • 29

1 Answers1

2

The 404 is a misleading. Try to use the URL with a non-existing user. This will also return a 404 but the error will be a little bit different. Accessing an exiting user gives

The entity with id: existinguser was not found

while a non-existing user gives

The entity with id: personId is null. was not found

The HTTP response status should be 403 if you try got get the favorites of a different user.

You can't access another users favorites because the class org.alfresco.rest.api.impl.PeopleImpl checks that the calling user is the same as the user whose favorites are requested. In Alfresco 5.0d the relvant code is:

public String validatePerson(String personId, boolean validateIsCurrentUser)
{
    if(personId.equalsIgnoreCase(DEFAULT_USER))
    {
        personId = AuthenticationUtil.getFullyAuthenticatedUser();
    }

    personId = personService.getUserIdentifier(personId);
    if(personId == null)
    {
        // "User " + personId + " does not exist"
        throw new EntityNotFoundException("personId is null.");
    }

    if(validateIsCurrentUser)
    {
        String currentUserId = AuthenticationUtil.getFullyAuthenticatedUser();
        if(!currentUserId.equalsIgnoreCase(personId))
        {
            throw new EntityNotFoundException(personId);
        }
    }

    return personId;
}
  • I can search another user's favourite-sites or sites meanwhile I can't look for its favorites. I would like to know the reason behind this. Maybe favorites are very personal :). – newzad May 20 '16 at 12:20
  • Ask the Alfresco engineers :) –  May 20 '16 at 12:20