Package org.jasig.portal

Examples of org.jasig.portal.UserProfile


    private IPerson systemUser = new SystemUser(); // We should be getting this from the uPortal

  public UserPreferences getUserPreferences (IPerson person, int profileId) throws Exception {
    UserPreferences up = null;
    UserProfile profile = this.getUserProfileById(person, profileId);
    if (profile != null) {
      up = getUserPreferences(person, profile);
    }
    return  (up);
  }
View Full Code Here


    return  up;
  }

  public void putUserPreferences (IPerson person, UserPreferences up) throws Exception {
    // store profile
    UserProfile profile = up.getProfile();
    this.updateUserProfile(person, profile);
    this.setStructureStylesheetUserPreferences(person, profile.getProfileId(), up.getStructureStylesheetUserPreferences());
    this.setThemeStylesheetUserPreferences(person, profile.getProfileId(), up.getThemeStylesheetUserPreferences());
  }
View Full Code Here

     * @param owner
     * @throws Exception
     */
    private void saveLayout(UserView view, IPerson owner) throws Exception
    {
        IUserProfile profile = new UserProfile();
        profile.setProfileId(view.profileId);
        userLayoutStore.setUserLayout(owner, profile, view.layout, true, false);
    }
View Full Code Here

                        + "," + profile.getThemeStylesheetId() + ",'" + profile.getProfileDescription() + "', "+profile.getLayoutId()+")";
                logger.debug("addUserProfile(): {}", sQuery);
                try {
                    pstmt.executeUpdate();

                    UserProfile newProfile = new UserProfile();
                    newProfile.setProfileId(profileId);
                    newProfile.setLayoutId(layoutId);
                    newProfile.setLocaleManager(profile.getLocaleManager());
                    newProfile.setProfileDescription(profile.getProfileDescription());
                    newProfile.setProfileFname(profile.getProfileFname());
                    newProfile.setProfileName(profile.getProfileName());
                    newProfile.setStructureStylesheetId(profile.getStructureStylesheetId());
                    newProfile.setSystemProfile(false);
                    newProfile.setThemeStylesheetId(profile.getThemeStylesheetId());

                    return newProfile;

                } finally {
                    pstmt.close();
View Full Code Here

                                } else {
                                    String msg = "The system user profile has no theme stylesheet Id.";
                                    throw new IllegalStateException(msg);
                                }
                            }
                            IUserProfile userProfile = new UserProfile(profileId, temp2, temp3,temp4, layoutId, structSsId, themeSsId);
                            final Locale[] userLocales = localeStore.getUserLocales(person);
                            userProfile.setLocaleManager(new LocaleManager(person, userLocales));
                            return userProfile;
                        }
                        else {
                            throw new RuntimeException("Unable to find User Profile for user " + userId + " and profile " + profileId);
                        }
View Full Code Here

    public UserProfile getUserProfileByFname (final IPerson person, final String profileFname) {
        Tuple<String, String> key = null;
        final Cache<Tuple<String, String>, UserProfile> profileCache = getProfileImportExportCache();
        if (profileCache != null) {
            key = new Tuple<String, String>(person.getUserName(), profileFname);
            final UserProfile profile = profileCache.getIfPresent(key);
            if (profile != null) {
                return profile;
            }
        }

        logger.debug("Getting profile {} for user {}", profileFname, person.getID());
        final int userId = person.getID();
        final UserProfile userProfile = jdbcOperations.execute(new ConnectionCallback<UserProfile>() {
            @Override
            public UserProfile doInConnection(Connection con) throws SQLException, DataAccessException {

                String query = "SELECT USER_ID, PROFILE_ID, PROFILE_NAME, DESCRIPTION, " +
                        "LAYOUT_ID, STRUCTURE_SS_ID, THEME_SS_ID FROM UP_USER_PROFILE WHERE " +
                        "USER_ID=? AND PROFILE_FNAME=?";
                PreparedStatement pstmt = con.prepareStatement(query);
                pstmt.setInt(1, userId);
                pstmt.setString(2, profileFname);
                try {
                    logger.debug("getUserProfileByFname(): {} userId: {} profileFname: {}", query, userId, profileFname);
                    ResultSet rs = pstmt.executeQuery();
                    try {
                        if (rs.next()) {
                            int profileId = rs.getInt(2);
                            String profileName = rs.getString(3);
                            String profileDesc = rs.getString(4);
                            int layoutId = rs.getInt(5);
                            if (rs.wasNull()) {
                                layoutId = 0;
                            }
                            int structSsId = rs.getInt(6);
                            if (rs.wasNull()) {
                                // This is probably a data issue and probably an export operation;  defer to the system user...
                                if (!person.equals(getSystemUser())) {
                                    structSsId = getSystemProfileByFname(profileFname).getStructureStylesheetId();
                                } else {
                                    String msg = "The system user profile has no structure stylesheet Id.";
                                    throw new IllegalStateException(msg);
                                }
                            }
                            int themeSsId = rs.getInt(7);
                            if (rs.wasNull()) {
                                // This is probably a data issue and probably an export operation;  defer to the system user...
                                if (!person.equals(getSystemUser())) {
                                    themeSsId = getSystemProfileByFname(profileFname).getThemeStylesheetId();
                                } else {
                                    String msg = "The system user profile has no theme stylesheet Id.";
                                    throw new IllegalStateException(msg);
                                }
                            }
                            UserProfile userProfile = new UserProfile(profileId, profileFname, profileName, profileDesc, layoutId, structSsId, themeSsId);
                            final Locale[] userLocales = localeStore.getUserLocales(person);
                            userProfile.setLocaleManager(new LocaleManager(person, userLocales));
                            return userProfile;
                        }

                        /* Try to copy the template profile. */
                        logger.debug("Copying template profile {} to user {}", profileFname, person.getID());
                        rs.close();
                        pstmt.close();
                        pstmt = con.prepareStatement("SELECT USER_DFLT_USR_ID FROM UP_USER WHERE USER_ID=?");
                        pstmt.setInt(1, person.getID());
                        rs = pstmt.executeQuery();
                        if(rs.next()) {
                            int defaultProfileUser = rs.getInt(1);
                            if (rs.wasNull()) {
                                throw new RuntimeException("Need to clone the '" + profileFname + "' profile from template user for " + person + " but they have no template user");
                            }

                            IPerson defaultProfilePerson = new PersonImpl();
                            defaultProfilePerson.setID(defaultProfileUser);
                            if(defaultProfilePerson.getID() != person.getID()) {
                                UserProfile templateProfile = getUserProfileByFname(defaultProfilePerson,profileFname);
                                if(templateProfile != null) {
                                    UserProfile newUserProfile = new UserProfile(templateProfile);
                                    final Locale[] userLocales = localeStore.getUserLocales(person);
                                    newUserProfile.setLayoutId(0);
                                    newUserProfile = addUserProfile(person,newUserProfile);

                                    newUserProfile.setLocaleManager(new LocaleManager(person, userLocales));
                                    return newUserProfile;
                                }
                            }
                        }

View Full Code Here

                            int themeSsId = rs.getInt(8);
                            if (rs.wasNull()) {
                                themeSsId = 0;
                            }

                            UserProfile upl = new UserProfile(rs.getInt(2), rs.getString(3), rs.getString(4), rs.getString(5),
                                    layoutId, structSsId, themeSsId);
                            pv.put(new Integer(upl.getProfileId()), upl);
                        }
                    } finally {
                        rs.close();
                    }
                } finally {
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.