我正在尝试编写一些将由“管理员”用户运行的代码,这些代码会将文档检出给不同的用户,例如“约翰”。但是,当我在“共享”中查看签出的文档时,它总是说该文档已签出给用户“管理员”。我在 Alfresco 4.0.c 上运行此代码
这是我正在执行的代码
Boolean rtn = AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Boolean>() {
@Override
public Boolean doWork() throws Exception {
// executes the following code as user who had the document previously checked out
CheckOutCheckInService checkOutCheckInService = serviceRegistry.getCheckOutCheckInService();
//this line is debug code to check who the current user is according to the AuthenticationService
//AuthenticationService authService = serviceRegistry.getAuthenticationService();
//if (log.isDebugEnabled()) log.debug("Current UserName in AuthenticationService is '" + authService.getCurrentUserName() + "'.");
NodeRef checkedOutCopy = checkOutCheckInService.checkout(nodeRef);
ContentWriter writer = fileFolderService.getWriter(checkedOutCopy);
writer.putContent(workingCopyContentAndMetadata.getContentFile());
if (log.isDebugEnabled()) log.debug("Have uploaded working copy document as user '" + String.valueOf(workingCopyOwner) + "'.");
return true;
}
}, String.valueOf(workingCopyOwner));
通过查看 Alfresco 源代码,checkOutcheckInService 从 AuthenticationService getCurrentUserName() 方法获取用户名以签出文档。但是,AuthenticationUtil.runAs 代码似乎不会更改 AuthenticationService 中的用户。
我在这里做错了什么或者我该如何正确地做到这一点?
提前致谢。