[jboss-user] [JBoss Portal] - Re: Dashboard configuration - drag and drop
diparc
do-not-reply at jboss.com
Sun Feb 22 20:13:54 EST 2009
I was looking at other posts in the forum and figured that I do need to manage hibernate transactions. I modified the code to do that and it is working now.
Hoping this is the right way though, please share your thoughts -
I am leaving the code snippet here -
| private void createUserAndAssignPortalRole(String userName) throws IllegalArgumentException, ServletException {
| Session session = null;
| Transaction transaction = null;
|
| try {
| session = getIdentitySessionFactory().openSession();
| transaction = session.beginTransaction();
| if(!isUserInPortalDB(userName)) {
| this.filterConfig.getServletContext().log("user not found in portal db, creating user: " + userName);
| User user = getUserModule().createUser(userName, ""); //not storing user passwords in database
| getMembershipModule().assignRoles(user, getRequiredRoleSet());
| }
| }
| catch (IdentityException e) {
| this.filterConfig.getServletContext().log("could not assign portal role to user: " + userName);
| throw new ServletException(e);
| }
| finally {
| if (transaction != null) transaction.commit();
| if (session != null) session.close();
| }
| }
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4212106#4212106
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4212106
More information about the jboss-user
mailing list