Package org.jasig.portal

Examples of org.jasig.portal.IUserProfile


        if (ownerId == -1) {
            throw new RuntimeException("Unrecognized user " + person.getUserName() + "; you must import users before their layouts or set org.jasig.portal.io.layout.errorOnMissingUser to false.");
        }
        person.setID(ownerId);

        IUserProfile profile = null;
        try {
            person.setSecurityContext(new BrokenSecurityContext());
            profile = this.getUserProfileByFname(person, "default");
        }
        catch (final Throwable t) {
            throw new RuntimeException("Failed to load profile for " + person.getUserName()
                    + "; This user must have a profile for import to continue.", t);
        }

        // (6) Add database Ids & (5) Add dlm:plfID ...
        int nextId = 1;
        for (final Iterator<org.dom4j.Element> it = (Iterator<org.dom4j.Element>) layout
                .selectNodes("folder | dlm:* | channel").iterator(); it.hasNext();) {
            nextId = this.addIdAttributesIfNecessary(it.next(), nextId);
        }
        // Now update UP_USER...
        this.jdbcOperations.update("UPDATE up_user SET next_struct_id = ? WHERE user_id = ?", nextId, person.getID());

        // (4) Convert external DLM pathrefs to internal form (noderefs)...
        for (final Iterator<org.dom4j.Attribute> itr = (Iterator<org.dom4j.Attribute>) layout
                .selectNodes("//@dlm:origin").iterator(); itr.hasNext();) {
            final org.dom4j.Attribute a = itr.next();
            final Noderef dlmNoderef = nodeReferenceFactory.getNoderefFromPathref(ownerUsername, a.getValue(), null, true, layout);
            if (dlmNoderef != null) {
                // Change the value only if we have a valid pathref...
                a.setValue(dlmNoderef.toString());
                // For dlm:origin only, also use the noderef as the ID attribute...
                a.getParent().addAttribute("ID", dlmNoderef.toString());
            } else {
                // At least insure the value is between 1 and 35 characters
                a.setValue(BAD_PATHREF_MESSAGE);
            }
        }
        for (final Iterator<org.dom4j.Attribute> itr = (Iterator<org.dom4j.Attribute>) layout
                .selectNodes("//@dlm:target").iterator(); itr.hasNext();) {
            final org.dom4j.Attribute a = itr.next();
            final Noderef dlmNoderef = nodeReferenceFactory.getNoderefFromPathref(ownerUsername, a.getValue(), null, true, layout);
            // Put in the correct value, or at least insure the value is between 1 and 35 characters
            a.setValue(dlmNoderef != null ? dlmNoderef.toString() : BAD_PATHREF_MESSAGE);
        }
        for (final Iterator<org.dom4j.Attribute> names = (Iterator<org.dom4j.Attribute>) layout
                .selectNodes("//dlm:*/@name").iterator(); names.hasNext();) {
            final org.dom4j.Attribute a = names.next();
            final String value = a.getValue().trim();
            if (!VALID_PATHREF_PATTERN.matcher(value).matches()) {
                /* Don't send it to getDlmNoderef if we know in advance it's not
                 * going to work;  saves annoying/misleading log messages and
                 * possibly some processing.  NOTE this is _only_ a problem with
                 * the name attribute of some dlm:* elements, which seems to go
                 * unused intentionally in some circumstances
                 */
                continue;
            }
            final org.dom4j.Attribute fname = a.getParent().attribute("fname");
            Noderef dlmNoderef = null;
            if (fname != null) {
                dlmNoderef = nodeReferenceFactory.getNoderefFromPathref(ownerUsername, value, fname.getValue(), false, layout);
                // Remove the fname attribute now that we're done w/ it...
                fname.getParent().remove(fname);
            }
            else {
                dlmNoderef = nodeReferenceFactory.getNoderefFromPathref(ownerUsername, value, null, true, layout);
            }
            // Put in the correct value, or at least insure the value is between 1 and 35 characters
            a.setValue(dlmNoderef != null ? dlmNoderef.toString() : BAD_PATHREF_MESSAGE);
        }

        // (3) Restore chanID attributes on <channel> elements...
        for (final Iterator<org.dom4j.Element> it = (Iterator<org.dom4j.Element>) layout.selectNodes("//channel")
                .iterator(); it.hasNext();) {
            final org.dom4j.Element c = it.next();
            final String fname = c.valueOf("@fname");
            final IPortletDefinition cd = this.portletDefinitionRegistry.getPortletDefinitionByFname(fname);
            if (cd == null) {
                final String msg = "No portlet with fname=" + fname + " exists referenced by node " + c.valueOf("@ID") + " from layout for " + ownerUsername;
                if (errorOnMissingPortlet) {
                    throw new IllegalArgumentException(msg);
                }
                else {
                    logger.warn(msg);
                    //Remove the bad channel node
                    c.getParent().remove(c);
                }
            }
            else {
                c.addAttribute("chanID", String.valueOf(cd.getPortletDefinitionId().getStringId()));
            }
        }

        // (2) Restore locale info...
        // (This step doesn't appear to be needed for imports)

        // (1) Process structure & theme attributes...
        Document layoutDom = null;
        try {

            final int structureStylesheetId = profile.getStructureStylesheetId();
            this.loadStylesheetUserPreferencesAttributes(person, profile, layout, structureStylesheetId, "structure");

            final int themeStylesheetId = profile.getThemeStylesheetId();
            this.loadStylesheetUserPreferencesAttributes(person, profile, layout, themeStylesheetId, "theme");

            // From this point forward we need the user's PLF set as DLM expects it...
            for (final Iterator<org.dom4j.Text> it = (Iterator<org.dom4j.Text>) layout
                    .selectNodes("descendant::text()").iterator(); it.hasNext();) {
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 IUserProfile getSystemProfile (String userAgent) {
        String profileFname = getSystemBrowserMapping(userAgent);
        if (profileFname == null)
            return  null;
        IUserProfile up = this.getUserProfileByFname(this.getSystemUser(), profileFname);
        up.setSystemProfile(true);
        return  up;
    }
View Full Code Here

        up.setSystemProfile(true);
        return  up;
    }

    public IUserProfile getSystemProfileById (int profileId) {
        IUserProfile up = this.getUserProfileById(this.getSystemUser(), profileId);
        up.setSystemProfile(true);
        return  up;
    }
View Full Code Here

        up.setSystemProfile(true);
        return  up;
    }

    public IUserProfile getSystemProfileByFname (String profileFname) {
        IUserProfile up = this.getUserProfileByFname(this.getSystemUser(), profileFname);
        up.setSystemProfile(true);
        return  up;
    }
View Full Code Here

    }

    public Hashtable getSystemProfileList () {
        Hashtable pl = this.getUserProfileList(this.getSystemUser());
        for (Enumeration e = pl.elements(); e.hasMoreElements();) {
            IUserProfile up = (IUserProfile)e.nextElement();
            up.setSystemProfile(true);
        }
        return  pl;
    }
View Full Code Here

        final PersonImpl person = new PersonImpl();
        person.setUserName(userName);
        person.setID(userId);
        person.setSecurityContext(new BrokenSecurityContext());

        final IUserProfile profile = layoutStore.getUserProfileByFname(person, UserProfile.DEFAULT_PROFILE_FNAME);
        final DistributedUserLayout userLayout = layoutStore.getUserLayout(person, (UserProfile) profile);

        return new Tuple<String, DistributedUserLayout>(userName, userLayout);
    }
View Full Code Here

    }

    public IStylesheetDescriptor getStylesheetDescriptor(HttpServletRequest request) {
        final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
        final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
        final IUserProfile userProfile = preferencesManager.getUserProfile();
       
        final PreferencesScope stylesheetPreferencesScope = this.getStylesheetPreferencesScope(request);
        final int stylesheetId = stylesheetPreferencesScope.getStylesheetId(userProfile);
       
        return this.stylesheetDescriptorDao.getStylesheetDescriptor(stylesheetId);
View Full Code Here

        }

        // Create either a UserInstance or a GuestUserInstance
        final LocaleManager localeManager = this.getLocaleManager(request, person);
        final String userAgent = this.getUserAgent(request);
        final IUserProfile userProfile = this.getUserProfile(request, person, localeManager, userAgent);

        //Create the user layout manager and user instance object
        IUserLayoutManager userLayoutManager = userLayoutManagerFactory.getUserLayoutManager(person, userProfile);
        if (person.isGuest()) {
            userLayoutManager = userLayoutManagerFactory.immutableUserLayoutManager(userLayoutManager);
View Full Code Here

        return userInstance;
    }

    protected IUserProfile getUserProfile(HttpServletRequest request, IPerson person, LocaleManager localeManager, String userAgent) {
        final String profileFname = profileMapper.getProfileFname(person, request);
        IUserProfile userProfile = userLayoutStore.getUserProfileByFname(person, profileFname);

        if (userProfile == null) {
            userProfile = userLayoutStore.getSystemProfileByFname(profileFname);
        }
       
        if (localeManager != null && LocaleManager.isLocaleAware()) {
            userProfile.setLocaleManager(localeManager);
        }
       
        return userProfile;
    }
View Full Code Here

TOP

Related Classes of org.jasig.portal.IUserProfile

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.