Merged V2.2 to HEAD

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8386 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2008-02-26 19:02:20 +00:00
parent 218cb33e75
commit bbc2156235
3 changed files with 33 additions and 7 deletions

View File

@@ -27,11 +27,13 @@ package org.alfresco.repo.web.scripts.portlet;
import javax.portlet.PortletSession;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.transaction.UserTransaction;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.web.scripts.Repository;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.web.app.servlet.AuthenticationHelper;
import org.alfresco.web.bean.repository.User;
import org.alfresco.web.scripts.Authenticator;
@@ -54,6 +56,7 @@ public class WebClientPortletAuthenticatorFactory implements PortletAuthenticato
// dependencies
private AuthenticationService authenticationService;
private TransactionService transactionService;
private Repository repository;
/**
@@ -71,6 +74,14 @@ public class WebClientPortletAuthenticatorFactory implements PortletAuthenticato
{
this.repository = repository;
}
/**
* @param transactionService
*/
public void setTransactionService(TransactionService transactionService)
{
this.transactionService = transactionService;
}
/* (non-Javadoc)
* @see org.alfresco.web.scripts.portlet.PortletAuthenticatorFactory#create(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
@@ -173,14 +184,28 @@ public class WebClientPortletAuthenticatorFactory implements PortletAuthenticato
*/
private void createWebClientUser(PortletSession session)
{
NodeRef personRef = repository.getPerson();
User user = new User(authenticationService.getCurrentUserName(), authenticationService.getCurrentTicket(), personRef);
NodeRef homeRef = repository.getUserHome(personRef);
if (homeRef != null)
UserTransaction tx = null;
try
{
user.setHomeSpaceId(homeRef.getId());
// start a txn as this method interacts with public services
tx = transactionService.getUserTransaction();
tx.begin();
NodeRef personRef = repository.getPerson();
User user = new User(authenticationService.getCurrentUserName(), authenticationService.getCurrentTicket(), personRef);
NodeRef homeRef = repository.getUserHome(personRef);
if (homeRef != null)
{
user.setHomeSpaceId(homeRef.getId());
}
session.setAttribute(AuthenticationHelper.AUTHENTICATION_USER, user, PortletSession.APPLICATION_SCOPE);
tx.commit();
}
catch (Throwable e)
{
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
}
session.setAttribute(AuthenticationHelper.AUTHENTICATION_USER, user, PortletSession.APPLICATION_SCOPE);
}
/**