Package org.jasig.portal

Examples of org.jasig.portal.UserProfile


          // fill out user-defined profiles
          Element uEl = doc.createElement("user");
          Hashtable upList=this.getUserProfileList();

          for(Enumeration upe = this.getUserProfileList().elements(); upe.hasMoreElements();) {
              UserProfile p = (UserProfile)upe.nextElement();
              Element pEl = doc.createElement("profile");
              Boolean expState=(Boolean) userExpandStates.get(Integer.toString(p.getProfileId()));
              if(expState!=null && expState.booleanValue()) {
                  pEl.setAttribute("view","expanded");
              } else {
                  pEl.setAttribute("view","condensed");
              }
              pEl.setAttribute("id", Integer.toString(p.getProfileId()));
              pEl.setAttribute("name", p.getProfileName());
              Element dEl = doc.createElement("description");
              dEl.appendChild(doc.createTextNode(p.getProfileDescription()));
              pEl.appendChild(dEl);
              uEl.appendChild(pEl);
          }
          edEl.appendChild(uEl);
      }
      // fill out system-defined profiles
      Element sEl = doc.createElement("system");
      for (Enumeration spe = this.getSystemProfileList().elements(); spe.hasMoreElements();) {
        UserProfile p = (UserProfile)spe.nextElement();
        Element pEl = doc.createElement("profile");

        Boolean expState=(Boolean)systemExpandStates.get(Integer.toString(p.getProfileId()));
        if(expState!=null && expState.booleanValue()) {
            pEl.setAttribute("view","expanded");
        } else {
            pEl.setAttribute("view","condensed");
        }
        pEl.setAttribute("id", Integer.toString(p.getProfileId()));
        pEl.setAttribute("name", p.getProfileName());
        Element dEl = doc.createElement("description");
        dEl.appendChild(doc.createTextNode(p.getProfileDescription()));
        pEl.appendChild(dEl);
        sEl.appendChild(pEl);
      }
      edEl.appendChild(sEl);
      /*  try {
       log.debug(org.jasig.portal.utils.XML.serializeNode(doc));
       } catch (Exception e) {
       log.error(e, e);
       }
       */
      // debug printout of the document sent to the XSLT
      /*
      StringWriter dbwr1 = new StringWriter();
      org.apache.xml.serialize.OutputFormat outputFormat = new org.apache.xml.serialize.OutputFormat();
      outputFormat.setIndenting(true);
      org.apache.xml.serialize.XMLSerializer dbser1 = new org.apache.xml.serialize.XMLSerializer(dbwr1, outputFormat);
      try {
          dbser1.serialize(doc);
      log.debug("ManageProfilesState::renderXML() : XML incoming to the XSLT :\n\n" + dbwr1.toString() + "\n\n");
      } catch (Exception e) {
          log.debug("ManageProfilesState::renderXML() : problems serializing incoming XML");
      }
      */

      // find the stylesheet and transform
      StylesheetSet set = context.getStylesheetSet();
      if (set == null)
        throw  new GeneralRenderingException("Unable to determine the stylesheet list");
      String xslURI = set.getStylesheetURI("profileList", runtimeData.getBrowserInfo());
      UserProfile currentProfile = context.getCurrentUserPreferences().getProfile();
      Hashtable params = new Hashtable();

      params.put("allowNewProfile",new Boolean(ALLOW_NEW_PROFILE_BUTTON));
      params.put("allowSystemProfileMapping",new Boolean(ALLOW_SYSTEM_BROWSER_MAPPING));


      params.put("baseActionURL", runtimeData.getBaseActionURL());
      params.put("profileId", Integer.toString(currentProfile.getProfileId()));
      if (currentProfile.isSystemProfile()) {
          params.put("profileType", "system");
      } else {
          params.put("profileType", "user");
      }

View Full Code Here


        assertEquals(0, this.countRowsInTable("STATS_FOLDER"));
        assertEquals(0, this.countRowsInTable("STATS_RENDER_TIME"));
       
       
       
        final UserProfile userProfile = new UserProfile();
        userProfile.setProfileId(1);
       
        final IUserLayoutChannelDescription channelDescription = EasyMock.createMock(IUserLayoutChannelDescription.class);
        EasyMock.expect(channelDescription.getName()).andReturn("chanPub1").anyTimes();
        EasyMock.expect(channelDescription.getChannelPublishId()).andReturn("chanPub1").anyTimes();
        EasyMock.expect(channelDescription.getChannelSubscribeId()).andReturn("chanSub1").anyTimes();
View Full Code Here

        p = PersonFactory.createPerson();

        assertTrue(sampleUserLayout!=null);
        uls=new SingleDocumentUserLayoutStoreMock(sampleUserLayout);
        man=new SimpleUserLayoutManager(p,new UserProfile(),uls);

        // clear event-related markers
        nodeAdded=nodeDeleted=nodeMoved=nodeUpdated=layoutSaved=layoutLoaded=false;
        lastEvent=null;
        man.addLayoutEventListener(this);
View Full Code Here

    Element edEl = doc.createElement("profiles");
    doc.appendChild(edEl);
    // fill out system-defined profiles
    Element sEl = doc.createElement("system");
    for (Enumeration spe = this.getSystemProfileList().elements(); spe.hasMoreElements();) {
      UserProfile p = (UserProfile)spe.nextElement();
      Element pEl = doc.createElement("profile");
      pEl.setAttribute("id", Integer.toString(p.getProfileId()));
      pEl.setAttribute("name", p.getProfileName());
      Element dEl = doc.createElement("description");
      dEl.appendChild(doc.createTextNode(p.getProfileDescription()));
      pEl.appendChild(dEl);
      sEl.appendChild(pEl);
    }
    edEl.appendChild(sEl);
View Full Code Here

                    userProfileList = systemProfileList = null;
                    epstate.setRuntimeData(rd);
                    internalState = epstate;
                } else if (action.equals("copy")) {
                    // retrieve a profile from the database
                    UserProfile p=null;
                    if(systemProfile) {
                        p=(UserProfile)systemProfileList.get(new Integer(profileId));
                    } else {
                        p=(UserProfile)userProfileList.get(new Integer(profileId));
                    }
                   
                    if(p!=null) {
                        // create a new layout
                        try {
                          p=this.getUserLayoutStore().addUserProfile(context.getUserPreferencesManager().getPerson(),p);
                        } catch (Exception e) {
                          throw new PortalException(e);
                        }
                        // reset user profile listing
                        userProfileList=null;
                    }
                } else if (action.equals("delete")) {
                    // delete a profile
                    if (systemProfile) {
                        // need to check permissions here
                        // context.getUserPreferencesStore().deleteSystemProfile(Integer.parseInt(profileId));
                        // systemProfileList=null;
                    } else {
                      try {
                        this.getUserLayoutStore().deleteUserProfile(context.getUserPreferencesManager().getPerson(), Integer.parseInt(profileId));
                      } catch (Exception e) {
                        throw new PortalException(e);
                      }

                      userProfileList = null;
                    }
                } else if (action.equals("map")) {
                  try {
                    this.getUserLayoutStore().setUserBrowserMapping(context.getUserPreferencesManager().getPerson(), this.runtimeData.getBrowserInfo().getUserAgent(), Integer.parseInt(profileId));
                  } catch (Exception e) {
                    throw new PortalException(e);
                  }
                  // let userPreferencesManager know that the current profile has changed : everything must be reloaded
                } else if (action.equals("changeView")) {
                    String view=runtimeData.getParameter("view");
                    boolean expand=false;
                    if(view.equals("expanded")) expand=true;
                    if(systemProfile) {
                        systemExpandStates.put(profileId,new Boolean(expand));
                    } else {
                        userExpandStates.put(profileId,new Boolean(expand));
                    }
                }
            }

            if(action.equals("newProfile")) {
                // get a copy of a current layout to copy the values from
                UserProfile cp=context.getCurrentUserPreferences().getProfile();
                if(cp!=null) {
                    // create a new profile
                    UserProfile p=new UserProfile(0,"new profile","please edit the profile",cp.getLayoutId(),cp.getStructureStylesheetId(),cp.getThemeStylesheetId());
                    try {
                      p=this.getUserLayoutStore().addUserProfile(context.getUserPreferencesManager().getPerson(),p);
                    } catch (Exception e) {
                      throw new PortalException(e);
                    }

                    // reset user profile listing
                    userProfileList=null;
                }
            } else if(action.equals("condenseAll")) {
                String profileType = runtimeData.getParameter("profileType");
                if (profileType != null && profileType.equals("system")) {
                    // system profiles
                    systemExpandStates.clear();
                } else {
                    // user profiles
                    userExpandStates.clear();
                }
            } else if(action.equals("expandAll")) {
                String profileType = runtimeData.getParameter("profileType");
                if (profileType != null && profileType.equals("system")) {
                    // system profiles
                    systemExpandStates.clear();
                    Boolean expState=new Boolean(true);
                    for (Enumeration upe = this.getSystemProfileList().elements(); upe.hasMoreElements();) {
                        UserProfile p = (UserProfile)upe.nextElement();
                        systemExpandStates.put(Integer.toString(p.getProfileId()),expState);
                    }
                } else {
                    // user profiles
                    userExpandStates.clear();
                    Boolean expState=new Boolean(true);
                    for (Enumeration upe = this.getUserProfileList().elements(); upe.hasMoreElements();) {
                        UserProfile p = (UserProfile)upe.nextElement();
                        userExpandStates.put(Integer.toString(p.getProfileId()),expState);
                    }
                }
            }
        }
        if (internalState != null)
View Full Code Here

          // fill out user-defined profiles
          Element uEl = doc.createElement("user");
          Hashtable upList=this.getUserProfileList();

          for(Enumeration upe = this.getUserProfileList().elements(); upe.hasMoreElements();) {
              UserProfile p = (UserProfile)upe.nextElement();
              Element pEl = doc.createElement("profile");
              Boolean expState=(Boolean) userExpandStates.get(Integer.toString(p.getProfileId()));
              if(expState!=null && expState.booleanValue()) {
                  pEl.setAttribute("view","expanded");
              } else {
                  pEl.setAttribute("view","condensed");
              }
              pEl.setAttribute("id", Integer.toString(p.getProfileId()));
              pEl.setAttribute("name", p.getProfileName());
              Element dEl = doc.createElement("description");
              dEl.appendChild(doc.createTextNode(p.getProfileDescription()));
              pEl.appendChild(dEl);
              uEl.appendChild(pEl);
          }
          edEl.appendChild(uEl);
      }
      // fill out system-defined profiles
      Element sEl = doc.createElement("system");
      for (Enumeration spe = this.getSystemProfileList().elements(); spe.hasMoreElements();) {
        UserProfile p = (UserProfile)spe.nextElement();
        Element pEl = doc.createElement("profile");

        Boolean expState=(Boolean)systemExpandStates.get(Integer.toString(p.getProfileId()));
        if(expState!=null && expState.booleanValue()) {
            pEl.setAttribute("view","expanded");
        } else {
            pEl.setAttribute("view","condensed");
        }
        pEl.setAttribute("id", Integer.toString(p.getProfileId()));
        pEl.setAttribute("name", p.getProfileName());
        Element dEl = doc.createElement("description");
        dEl.appendChild(doc.createTextNode(p.getProfileDescription()));
        pEl.appendChild(dEl);
        sEl.appendChild(pEl);
      }
      edEl.appendChild(sEl);
      /*  try {
       log.debug(org.jasig.portal.utils.XML.serializeNode(doc));
       } catch (Exception e) {
       log.error(e, e);
       }
       */
      // debug printout of the document sent to the XSLT
      /*
      StringWriter dbwr1 = new StringWriter();
      org.apache.xml.serialize.OutputFormat outputFormat = new org.apache.xml.serialize.OutputFormat();
      outputFormat.setIndenting(true);
      org.apache.xml.serialize.XMLSerializer dbser1 = new org.apache.xml.serialize.XMLSerializer(dbwr1, outputFormat);
      try {
          dbser1.serialize(doc);
      log.debug("ManageProfilesState::renderXML() : XML incoming to the XSLT :\n\n" + dbwr1.toString() + "\n\n");
      } catch (Exception e) {
          log.debug("ManageProfilesState::renderXML() : problems serializing incoming XML");
      }
      */

      // find the stylesheet and transform
      StylesheetSet set = context.getStylesheetSet();
      if (set == null)
        throw  new GeneralRenderingException("Unable to determine the stylesheet list");

      String xslURI = set.getStylesheetURI("profileList", runtimeData.getBrowserInfo());
      UserProfile currentProfile = context.getCurrentUserPreferences().getProfile();
      Hashtable params = new Hashtable();

      params.put("allowNewProfile",new Boolean(ALLOW_NEW_PROFILE_BUTTON));
      params.put("allowSystemProfileMapping",new Boolean(ALLOW_SYSTEM_BROWSER_MAPPING));


      params.put("baseActionURL", runtimeData.getBaseActionURL());
      params.put("profileId", Integer.toString(currentProfile.getProfileId()));
      if (currentProfile.isSystemProfile()) {
          params.put("profileType", "system");
      } else {
          params.put("profileType", "user");
      }

View Full Code Here

    }

    public void convertLayout(int uid, int simpleProfileId) {
      
        final int NEW_LAYOUT_ID =1/* id to use when creating new layout */
        UserProfile simpleProfile = null;
        UserProfile ALProfile = null;
        IUserLayoutStore uls = null;
        int structSsId = 0, themeSsId = 0;
        int ALProfileId = 0;
        Connection con = null;
        Statement qstmt = null;
        ResultSet rs = null;

        IPerson user = PersonFactory.createPerson();
        user.setID(uid);

        try {
            // read in the simple layout
            uls = new RDBMUserLayoutStore();
            simpleProfile = uls.getUserProfileById(user,simpleProfileId);
            Document ul = uls.getUserLayout(user,simpleProfile);
            // wow - that was easy.   Now need to get rid of initial letters in IDs.
            stripNodes(ul.getChildNodes().item(0));
     
            // create a profile for the new layout
     
            try {
                con = RDBMServices.getConnection();
                qstmt = con.createStatement();

                rs = qstmt.executeQuery(
                    "select ss_id from up_ss_struct where ss_uri like " +
                    "'%org/jasig/portal/layout/AL_TabColumn/AL_TabColumn.xsl'");
                if (rs.next()) {
                    structSsId = rs.getInt(1);
                } else {
                    System.out.println("No AL structure stylesheet found. \n Layout for user "+uid+" not converted.");
                    con.rollback();
                    return;
                }
                rs.close();
                rs = qstmt.executeQuery(
                    "select ss_id from up_ss_theme where ss_uri like " +
                    "'%org/jasig/portal/layout/AL_TabColumn/integratedModes/integratedModes.xsl'");
                if (rs.next()) {
                    themeSsId = rs.getInt(1);
                } else {
                    System.out.println("No IM theme stylesheet found. \n Layout for user "+uid+" not converted.");
                    con.rollback();
                    return;
                }
                rs.close();

                // create a new profile id
                //rs = qstmt.executeQuery("select max(profile_id) from UP_USER_PROFILE where user_ID ="+ uid);
                //if (rs.next()) ALProfileId = rs.getInt(1)+1;

                ALProfile = new UserProfile(ALProfileId, "AL", "AL Profile", NEW_LAYOUT_ID, structSsId, themeSsId);

            } catch (SQLException se) {
                System.err.println("Error creating new profile for user "+uid);
                se.printStackTrace();
            } finally {
                RDBMServices.closeResultSet(rs);
                RDBMServices.closeStatement(qstmt);
                RDBMServices.releaseConnection(con);
            }

            // new AggregatedLayoutManager to save layout
            AggregatedLayoutManager alm = new AggregatedLayoutManager(user, ALProfile);
            // new AggregatedLayout with root node only to get started
            AggregatedLayout al = new AggregatedLayout("userLayoutRootNode",alm);
            // Give it to the layout manager
            alm.setUserLayout(al);
            // Initialize the layout store
            AggregatedUserLayoutStore als = new AggregatedUserLayoutStore();
            // Set the layout manager to use the new store
            alm.setLayoutStore(als);
            // set the layout to the DOM created from the old simple manager
            alm.setUserLayoutDOM(ul);
            // persist the new layout to the store
            // creates new layout with id 1
            alm.saveUserLayout();
            // add the new profile
            als.addUserProfile(user,ALProfile);
        catch (Exception e) {
            System.out.println("Error saving aggregated layout for user_id "+uid);
            e.printStackTrace();
        }
        System.out.println("Saved aggregated layout for user_id "+uid+
            " and new profile with id="+ALProfile.getProfileId());
        return
    }
View Full Code Here

      System.out.print("converting profiles for ID "+id+"...");
      IPerson person = PersonFactory.createPerson();
      person.setID(id);
      Hashtable list = uls.getUserProfileList(person);
      for (Enumeration e = list.keys(); e.hasMoreElements(); ) {
         UserProfile profile = (UserProfile)list.get(e.nextElement());
         if (profile.getStructureStylesheetId() == simpleSsId) {
            profile.setStructureStylesheetId(alSsId);
            profile.setThemeStylesheetId(imSsId);
            uls.updateUserProfile(person, profile);
         }
      }
      System.out.println("done");
   }
View Full Code Here

      } else if (action.equals("managePreferences")) {
          if (profileId != null) {
              // find the profile mapping
            try {
              if (systemProfile) {
                  UserProfile newProfile = ulsdb.getSystemProfileById(profileId.intValue());
                  if(newProfile!=null && (!(editedProfile.isSystemProfile() && editedProfile.getProfileId()==newProfile.getProfileId()))) {
                      // new profile has been selected
                      editedProfile=newProfile;
                      instantiateManagePreferencesState(editedProfile);
                  }
              } else {
                  UserProfile newProfile = ulsdb.getUserProfileById(upm.getPerson(), profileId.intValue());
                  if(newProfile!=null && (editedProfile.isSystemProfile() || (editedProfile.getProfileId()!=newProfile.getProfileId()))) {
                      // new profile has been selected
                      editedProfile=newProfile;
                      instantiateManagePreferencesState(editedProfile);
                  }
              }
View Full Code Here

                    userProfileList = systemProfileList = null;
                    epstate.setRuntimeData(rd);
                    internalState = epstate;
                } else if (action.equals("copy")) {
                    // retrieve a profile from the database
                    UserProfile p=null;
                    if(systemProfile) {
                        p=(UserProfile)systemProfileList.get(new Integer(profileId));
                    } else {
                        p=(UserProfile)userProfileList.get(new Integer(profileId));
                    }
                   
                    if(p!=null) {
                        // create a new layout
                        try {
                          p=this.getUserLayoutStore().addUserProfile(context.getUserPreferencesManager().getPerson(),p);
                        } catch (Exception e) {
                          throw new PortalException(e);
                        }
                        // reset user profile listing
                        userProfileList=null;
                    }
                } else if (action.equals("delete")) {
                    // delete a profile
                    if (systemProfile) {
                        // need to check permissions here
                        //      context.getUserPreferencesStore().deleteSystemProfile(Integer.parseInt(profileId));
                        //      systemProfileList=null;
                    } else {
                      try {
                        this.getUserLayoutStore().deleteUserProfile(context.getUserPreferencesManager().getPerson(), Integer.parseInt(profileId));
                      } catch (Exception e) {
                        throw new PortalException(e);
                      }

                      userProfileList = null;
                    }
                } else if (action.equals("map")) {
                  try {
                    this.getUserLayoutStore().setUserBrowserMapping(context.getUserPreferencesManager().getPerson(), this.runtimeData.getBrowserInfo().getUserAgent(), Integer.parseInt(profileId));
                  } catch (Exception e) {
                    throw new PortalException(e);
                  }
                  // let userPreferencesManager know that the current profile has changed : everything must be reloaded
                } else if (action.equals("changeView")) {
                    String view=runtimeData.getParameter("view");
                    boolean expand=false;
                    if(view.equals("expanded")) expand=true;
                    if(systemProfile) {
                        systemExpandStates.put(profileId,new Boolean(expand));
                    } else {
                        userExpandStates.put(profileId,new Boolean(expand));
                    }
                }
            }

            if(action.equals("newProfile")) {
                // get a copy of a current layout to copy the values from
                UserProfile cp=context.getCurrentUserPreferences().getProfile();
                if(cp!=null) {
                    // create a new profile
                    UserProfile p=new UserProfile(0,"new profile","please edit the profile",cp.getLayoutId(),cp.getStructureStylesheetId(),cp.getThemeStylesheetId());
                    try {
                      p=this.getUserLayoutStore().addUserProfile(context.getUserPreferencesManager().getPerson(),p);
                    } catch (Exception e) {
                      throw new PortalException(e);
                    }

                    // reset user profile listing
                    userProfileList=null;
                }
            } else if(action.equals("condenseAll")) {
                String profileType = runtimeData.getParameter("profileType");
                if (profileType != null && profileType.equals("system")) {
                    // system profiles
                    systemExpandStates.clear();
                } else {
                    // user profiles
                    userExpandStates.clear();
                }
            } else if(action.equals("expandAll")) {
                String profileType = runtimeData.getParameter("profileType");
                if (profileType != null && profileType.equals("system")) {
                    // system profiles
                    systemExpandStates.clear();
                    Boolean expState=new Boolean(true);
                    for (Enumeration upe = this.getSystemProfileList().elements(); upe.hasMoreElements();) {
                        UserProfile p = (UserProfile)upe.nextElement();
                        systemExpandStates.put(Integer.toString(p.getProfileId()),expState);
                    }
                } else {
                    // user profiles
                    userExpandStates.clear();
                    Boolean expState=new Boolean(true);
                    for (Enumeration upe = this.getUserProfileList().elements(); upe.hasMoreElements();) {
                        UserProfile p = (UserProfile)upe.nextElement();
                        userExpandStates.put(Integer.toString(p.getProfileId()),expState);
                    }
                }
            }
        }
        if (internalState != null)
View Full Code Here

TOP

Related Classes of org.jasig.portal.UserProfile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.