2016-05-20 59 views
0

我使用的是Alfresco 4.2,並試圖找到一些用戶的收藏夾,但我正在使用的web腳本僅返回當前用戶的結果。我確信,我正在調查的用戶存在。查找用戶在Alfresco的最愛

我該怎麼辦?我究竟做錯了什麼?

這裏是webscript調用工作:

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

這裏是一個不工作:

domain.com/alfresco/api/-default-/public/alfresco/versions/1/people/[email protected]/favorites 

,並返回如下:

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

BTW, /favorite-sites而不是/favorites適用於所有人。

回答

2

404是一個誤導。嘗試將網址與不存在的用戶一起使用。這也將返回一個404,但錯誤會有點不同。訪問一個退出的用戶提供了

The entity with id: existinguser was not found 

,而一個不存在的用戶給

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

的HTTP響應狀態應該是403,如果你嘗試了讓不同的用戶的最愛。

您不能訪問其他用戶的收藏夾,因爲org.alfresco.rest.api.impl.PeopleImpl類會檢查主叫用戶是否與請求收藏夾的用戶相同。在Alfresco 5.0d相關的代碼是:

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; 
} 
+0

我可以搜索另一個用戶的最喜歡的網站或網站,同時我不能尋找它的最愛。我想知道這背後的原因。也許收藏夾非常私人化:)。 – newzad

+0

問Alfresco工程師:) –