14 Replies Latest reply on Feb 23, 2009 3:38 AM by steux jean-sebastien

    Dashboard configuration - drag and drop

    Deepak Bhatia Newbie

      following is what we use -

      JBoss Portal Version: 2.6.7
      AS version: EAP 4.3

      I do not use the admin UI at all to do any configurations. I configure the portal using xml files so that they can be promoted to different environments(from Dev to QA to Production).

      I have used portlet.xml, portal.xml, portal-object.xml, portlet-instances.xml. Also, I have custom layouts and themes defined again using portal-layouts.xml and portal-themes.xml. All works well.

      Next, I would like to have drag and drop functionality on the portal pages. I know that drag n' drop is only available on the dashboard and there is a URL to copy the page to the user's dashboard. however, I would like to do this through xml files/programatically. I do not want to use the admin UI to do this. what i want to do is simple, copy the page to the dashboard the first time he accesses his dashbord and always point user to his dashboard.

      is there a way to do this - through xml files or programmatically?

      thanks,
      D

        • 1. Re: Dashboard configuration - drag and drop
          Thomas Heute Master

           

          what i want to do is simple, copy the page to the dashboard the first time he accesses his dashbord and always point user to his dashboard.


          First time a user access the dashboard he gets a copy of the "template" portal. Which is defined in XML files for feeding.

          To redirect the user directly to the dashboard there is an option in the configuration file (jboss-portal.sar/conf/config.xml iirc). Check the documentation

          • 2. Re: Dashboard configuration - drag and drop
            Deepak Bhatia Newbie

            Thanks for a quick response.

            I modified the jboss-portal.sar/conf/config.xml to change the following property to "dashboard"

            dashboard

            Also, i noticed that the "template" portal is defined in "/jboss-portal.sar/conf/data/default-object.xml"

            but it seems that it copies only the "template" portal defined here

            I have a separate war file for my application and that has all xml files specific to the portal I am building - i.e., it has its own portal-object.xml which is loaded correctly and i can access the pages in this portal -

            I renamed my portal defined in the portal-object.xml to "template" but when I access the dashboard it has the one defined in default-object.xml.

            I am going to try to remove the "template" portal from default-object.xml
            so that it has only one template portal and see if that will work -


            I had another question -

            it seems like there can be many portals running under a portal server but there can only be one dashboard. can there be more than one dashboard ?

            Thanks,
            D

            • 3. Re: Dashboard configuration - drag and drop
              Deepak Bhatia Newbie


              Removing the template portal from default-object.xml did not work. it gives me a http 404 when i try to access the dashboard url
              http://server:port/portal/auth/dashboard

              I have defined my own template portal in portal-object.xml - that file is loaded because i can access the template portal using the portal url but the dashboard url gives me a http 404.


              Also, can i have more than one dashboard in the application ?


              • 4. Re: Dashboard configuration - drag and drop
                vivek saini Newbie

                We have achieved something similar in our project.

                "diparc" wrote:
                Thanks for a quick response.

                I modified the jboss-portal.sar/conf/config.xml to change the following property to "dashboard"

                <entry key="core.login.namespace">dashboard</entry>

                Also, i noticed that the "template" portal is defined in "/jboss-portal.sar/conf/data/default-object.xml"

                but it seems that it copies only the "template" portal defined here


                On dashboard, they always copy "template" for every user. It is hard coded in CustomizationManagerService(check getDashboard() method)). It is a MBean so it is plugable. You can modify it according to your need.
                "diparc" wrote:

                I have a separate war file for my application and that has all xml files specific to the portal I am building - i.e., it has its own portal-object.xml which is loaded correctly and i can access the pages in this portal -

                I renamed my portal defined in the portal-object.xml to "template" but when I access the dashboard it has the one defined in default-object.xml.

                I am going to try to remove the "template" portal from default-object.xml
                so that it has only one template portal and see if that will work -


                I had another question -

                it seems like there can be many portals running under a portal server but there can only be one dashboard. can there be more than one dashboard ?

                Yes you can modify this mbean as you want. In our project we copied the different portal to Dashboard according to group association of user. Every user see's different dashboard according to their group.


                • 5. Re: Dashboard configuration - drag and drop
                  Deepak Bhatia Newbie

                  Thanks vivek_saini07 - luckily i am not alone -

                  I figured out the problem with the dashboard url - my template portal did not have a default page. now it has a default page and it copies the contents of my custom template portal to the dashboard. so i am good so far with a single dashboard and a single portal.

                  in my case I need a different dashboard depending on what the user clicks on - I dont know if i can do this based on some request parameter i.e., depending on some request param, i copy different portal to the dashboard ?

                  even if this is possible, when i am copying the portal to the dashboard, wouldn't the user's preferences/where he placed the windows,etc., be lost when i do this -

                  Thanks,
                  D

                  • 6. Re: Dashboard configuration - drag and drop
                    vivek saini Newbie

                     

                    n my case I need a different dashboard depending on what the user clicks on - I dont know if i can do this based on some request parameter i.e., depending on some request param, i copy different portal to the dashboard ?

                    Yes it is achievable u can get request object in getDashboard() method using PolicyContext.getContext("javax.servlet.http.HttpServletRequest");


                    even if this is possible, when i am copying the portal to the dashboard, wouldn't the user's preferences/where he placed the windows,etc., be lost when i do this -

                    If u use copy(xx,xx,true) of PortalObject it will perform deep copy means portal will be copied along with its page and window with all properties. Otherwise u can use getDeclaredProperty() and setDeclaredProperty() of PortalObject to copy window order/window region/page layout/page theme etc explicitly.

                    • 7. Re: Dashboard configuration - drag and drop
                      Deepak Bhatia Newbie

                      I have set aside the multiple dashboard, will be working on it after sometime.

                      currently, I am configuring authentication for JBoss portal and using the same authentication that is used by my web app -

                      Authentication works fine when i access the portal page.

                      However it gives me a Http 500 No authenticated user when i try to use the dashboard url(http://servername:port/portal/auth/dashboard)

                      I noticed the bug JBPORTAL-2178. I also modified web.xml in portal-server.war by adding /dashboard/* as suggested even though i am not accessing the dashboard like /dashboard.

                      still it did not help. I get the same Http 500 No authenticated user
                      am i missing something ?

                      I have also commented on the bug and started a new topic on this yesterday, but no response so far. hoping someone is watching this post -

                      thanks in advance

                      • 8. Re: Dashboard configuration - drag and drop
                        vivek saini Newbie

                        see user must be authenticated against portal-server.war, means against JBossPortal application.

                        for user authentication we changed in following files
                        login.jsp
                        login-config.xml
                        loginModule defined in login-config.xml

                        • 9. Re: Dashboard configuration - drag and drop
                          Deepak Bhatia Newbie

                          I modifed all those files -

                          we use directory smart and I am using a custom login module for authentication that extends UsernamePasswordLoginModule.
                          I am not using any of the *IdentityLoginModule

                          is it required to use one of the *IdentityLoginModules ?

                          in web.xml of portal-server.war, I have changed the role name from "Authenticated" to "BetaUI". this role is defined in directory smart.
                          However, I only have assigned this role to one user. I intend only to provide this user the portal functionality for now.

                          I read in the docs that all users need to be assigned this role, but I am not absolutely sure if this is required ?

                          I dont know what I am doing wrong - I have the portal pages authenticating correctly, but get this 500 no auth user error just for dashboard

                          Also, if i set a breakpoint in the custom class that extends UsernamePasswordLoginModule, and access the dashboard, i see that the credentials are obtained correctly from directory smart.

                          D

                          • 10. Re: Dashboard configuration - drag and drop
                            vivek saini Newbie

                            what we did is
                            after authentication we created a new user in user module of jboss portal and assigned a role from MembershipModule of jboss portal.


                            userModule = (UserModule)new InitialContext().lookup(userModuleJNDIName);
                            
                            membershipModule = (MembershipModule)new InitialContext().lookup(membershipModuleJNDIName);
                            
                            


                            user = getUserModule().createUser(userName, inputPassword);
                            




                            getMembershipModule().assignRoles(user, roleSet);
                            
                            


                            • 11. Re: Dashboard configuration - drag and drop
                              Sambit Dikshit Newbie

                              Hi,
                              By design, Jboss Portal can be accessed by any user where as dashboard are user specific. That is why you can when accessing portal you can access, http://abc/portal/portal/yourportalname where as for dashboard it is http://abc/portal/auth/dashboard. In Portal-Server.war WEB-INF/web.xml, you might see entries to for the servlet mapping to auth, authsec. These are first level of FORM authentication which is handled through login.jsp. Then internally it checks if the same user under specific role has access to the dashboard or not. What you have achieved so far is authenticating the user against a specific LDAP or DB. Jboss internally maintains it set of roles and users in JBP tables. It needs to be validated against them as well to render the dashboard correctly. To achieve this you need to use the following modules exposed by Jboss. You can make a look up these services through JNDI.
                              java:portal/UserProfileModule, java:portal/RoleModule,java:portal/MembershipModule,java:/TransactionManager.

                              Make sure that you use transaction manager before using the UserProfile, Role or MemberShip modules.

                              What you can do is write a filter and add the filter to web.xml of Portal-Server.war. Inside the filter, check if the user in the request is present in Jboss using UserProfile if not create it and assign to appropriate Role using Membership module.

                              Hope this helps.

                              Regards
                              -Sambit

                              • 12. Re: Dashboard configuration - drag and drop
                                Deepak Bhatia Newbie

                                Thanks Sambit & Vivek!

                                I wrote a servlet filter like you suggested and I am creating the user when the user is not found, also creating the role when not found, and assigning role to user using the membership module -
                                however, I am getting an exception when it tries to create the user in the portal database -


                                org.hibernate.HibernateException: Unable to locate current JTA transaction
                                org.hibernate.context.JTASessionContext.currentSession(JTASessionContext.java:61) org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:544) org.jboss.portal.identity.db.HibernateUserModuleImpl.getCurrentSession(HibernateUserModuleImpl.java:298) org.jboss.portal.identity.db.HibernateUserModuleImpl.createUser(HibernateUserModuleImpl.java:166)
                                JBossPortalAuthorizationFilter.createUserAndAssignPortalRole(JBossPortalAuthorizationFilter.java:83)


                                seems like i need to start and end hibernate transactions -
                                I am using methods in UserModule, RoleModule and MembershipModule only to achieve this-

                                you mentioned about the TransactionManager, I am not using that -
                                can you please advise what i need to do here -

                                here is the code snippet from doFilter() -

                                
                                 ...
                                 ...
                                 //create user and assign roles if user is not defined in portal db
                                 try {
                                 createUserAndAssignPortalRole(userName);
                                 filterChain.doFilter(httpRequest, response);
                                 }
                                 catch (IllegalArgumentException e) {
                                 this.filterConfig.getServletContext().log("Invalid user: " + userName);
                                 e.printStackTrace();
                                 denyAccess(userName, httpResponse);
                                 return;
                                 }
                                 }
                                
                                 private void createUserAndAssignPortalRole(String userName) throws IllegalArgumentException, ServletException {
                                
                                 try {
                                 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);
                                 }
                                 }
                                


                                thanks once again for your help,
                                D

                                • 13. Re: Dashboard configuration - drag and drop
                                  Deepak Bhatia Newbie

                                  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();
                                   }
                                   }
                                  


                                  • 14. Re: Dashboard configuration - drag and drop
                                    steux jean-sebastien Newbie

                                    Hello,

                                    Here is a common way to create a transaction :

                                    import javax.naming.InitialContext;
                                    import javax.naming.NamingException;
                                    import javax.transaction.TransactionManager;
                                    import javax.transaction.UserTransaction;




                                    InitialContext ctx = new InitialContext();
                                    UserTransaction tx;
                                    tx = (UserTransaction) ctx.lookup("UserTransaction");
                                    tx.begin();
                                    ...

                                    tx.commit();

                                    Jean-sébastien Steux