Package org.apache.jetspeed.om.profile

Examples of org.apache.jetspeed.om.profile.Profile


     * @exception Exception
     */
    private Profile mergeRoleProfiles(RunData data, Vector profiles)
        throws Exception
    {
        Profile result = null;
        // If merge feature is not turned on, return
        // profile for the first role (if any)
        if (!this.useRoleMerge)
        {
            if (profiles.size() > 0)
            {
                result = (Profile) profiles.get(0);
            }
        }
        // Proceed with merging all profiles
        else if (profiles.size() > 0)
        {
            try
            {
                // Create an empty portlet container
                Portlets portlets = new PsmlPortlets();
                Control control = new PsmlControl();
                control.setName(this.rolemergeControl);
                portlets.setControl(control);
                Controller controller = new PsmlController();
                controller.setName(this.rolemergeController);
                portlets.setController(controller);

                // Set the skin
                Skin skin = new PsmlSkin();
                skin.setName(PortalToolkit.getSkin((String) null).getName());
                portlets.setSkin(skin);

                String mediaType = null;

                // Process each role profile
                int paneCount = 0;
                for (Iterator it = profiles.iterator(); it.hasNext(); )
                {
                    Profile roleProfile = (Profile)it.next();
                    mediaType = mediaType == null ? roleProfile.getMediaType() : mediaType;
                    Profile tmpProfile = (Profile) roleProfile.clone();
                    Portlets tmpPortlets = tmpProfile.getDocument().getPortlets();

                    // If topmost control is a tab control, then add each tab to the container
                    Control paneControl = tmpPortlets.getControl();
                    if (paneControl != null && paneControl.getName().equals(this.rolemergeControl))
                    {
View Full Code Here


        throws ProfileException
    {
        try
        {
            JetspeedRunData rundata = (JetspeedRunData)data;
            Profile profile = createProfile();
            JetspeedUser user = rundata.getJetspeedUser();

            // get the media type from the capability map or rundata
            profile.setMediaType(getMediaType(rundata, cm));

            //  Is it a group, role, or user resource?
            //  It can only be one
            String param = rundata.getParameters().getString( Profiler.PARAM_GROUP );

            if (null != param)
            {
                // GROUP Resource
                profile.setGroup( JetspeedSecurity.getGroup(param) );
            }
            else
            {
                param = rundata.getParameters().getString( Profiler.PARAM_ROLE );
                if (null != param)
                {
                    // ROLE Resource
                    if (user.hasLoggedIn())  // disallow role access for anonymous user
                    {
                        profile.setRole( JetspeedSecurity.getRole(param) );
                    }
                    else
                    {
                        profile.setAnonymous(true);
                        profile.setUser( user );
                    }
                }
                else  // it must be a user resource or anonymous resource
                {
                    // accessing another user's resource
                    param = rundata.getParameters().getString( Profiler.PARAM_USER );
                    if (null != param)
                    {

                        if (param.equals(JetspeedSecurity.getAnonymousUserName()))
                        {
                            profile.setAnonymous(true);
                        }
                        if (user.getUserName().equals(param))
                        {
                            profile.setUser( user );
                        }
                        else
                        {
                            profile.setUser( JetspeedSecurity.getUser(param) );
                        }
                    }
                    else
                    {
                        profile.setAnonymous(user.getUserName().equals(JetspeedSecurity.getAnonymousUserName()));
                        profile.setUser( user );
                    }
                }
            }

            // get resource name
            StringBuffer resource = new StringBuffer();
            param = rundata.getParameters().getString( Profiler.PARAM_PAGE );
            if (null == param)
            {
               // the default resource
                resource.append( resourceDefault );
                resource.append( resourceExt );
            }
            else
            {   // a specific resource
                resource.append( param );
                if ( -1 == param.indexOf( PATH_EXTENSION_DELIMITER ) )
                    resource.append( resourceExt );
            }
            profile.setName( resource.toString() );

            // LANGUAGE
            getLanguageSettings(profile, rundata);

            PSMLDocument doc = fallback( profile );
            if (null != doc)
            {
                profile.setDocument( doc );
                return profile;
            }
        }
        catch (Exception e)
        {
View Full Code Here

                    {
                        logger.debug("BaseJetspeedLink: elementValue = " + elementValue);
                    }
                    uriPathElement = JetspeedResources.PATH_PORTLETID_KEY;
                    ProfileLocator baseLocator = Profiler.createLocator();
                    Profile baseProfile = null;
                    switch (rootType)
                    {
                        case JetspeedLink.DEFAULT:
                            break;
                        case JetspeedLink.CURRENT:
                            baseProfile = rundata.getProfile();
                            break;
                        case JetspeedLink.GROUP:
                            baseLocator.setGroupByName(rootValue);
                            break;
                        case JetspeedLink.ROLE:
                            baseLocator.setRoleByName(rootValue);
                            break;
                        case JetspeedLink.USER:
                            try
                            {
                                if (logger.isDebugEnabled())
                                {
                                    logger.debug("BaseJetspeedLink: rootValue user = " + rootValue);
                                }
                                baseLocator.setUser(org.apache.jetspeed.services.JetspeedSecurity.getUser(rootValue));
                            }
                            catch (Exception se)
                            {
                                logger.error("Exception",  se);
                                return null;
                            }
                            break;
                    }
                   
                    if ((rootType != JetspeedLink.CURRENT) && (rootType != JetspeedLink.DEFAULT))
                    {
                        if (mediaType != null && mediaType.length() > 0)
                        {
                            baseLocator.setMediaType(mediaType);
                        }
                        if (language != null && language.length() > 0)
                        {
                            baseLocator.setLanguage(language);
                        }
                        if (country != null && country.length() > 0)
                        {
                            baseLocator.setCountry(country);
                        }
                        if (pageName != null && pageName.length() > 0)
                        {
                            baseLocator.setName(pageName);
                        }
                        baseProfile = Profiler.getProfile(baseLocator);
                    }
                  
                    if (logger.isDebugEnabled())
                    {
                        logger.debug("BaseJetspeedLink: baseLocator = " + baseLocator.getPath());
                    }

                    if ((baseProfile != null) && (elementValue != null))
                    {
                        if (logger.isDebugEnabled())
                        {
                           logger.debug("BaseJetspeedLink: baseProfile = " + baseProfile.toString());
                        }
                        if (baseProfile.getDocument() != null)
                        {
                            if (logger.isDebugEnabled())
                            {
                                logger.debug("BaseJetspeedLink: baseProfile.getDocment() = " + baseProfile.getDocument());
                            }
                            Entry entry = baseProfile.getDocument().getEntry(elementValue);
                            if (entry != null)
                            {
                                if (logger.isDebugEnabled())
                                {
                                    logger.debug("BaseJetspeedLink: entry id = " + entry.getId());
View Full Code Here

     */
    public Profile getProfile(ProfileLocator locator)
        throws ProfileException
    {
        PSMLDocument doc =  fallback(locator);
        Profile profile = createProfile(locator);
        profile.setDocument(doc);
        return profile;
    }
View Full Code Here

        if (portlets == null)
        {
            portlets = new PsmlPortlets();
        }
       
        Profile profile = createProfile(locator);
        PSMLDocument doc = new BasePSMLDocument(null, portlets);
        profile.setDocument(doc);
        doc = PsmlManager.createDocument(profile);
        profile.setDocument(doc);
        return profile;
    }
View Full Code Here

        try
        {
            profile.setMediaType(contentType);

            PSMLDocument doc = PsmlManager.createDocument(profile);
            Profile newProfile = (Profile)profile.clone();
            newProfile.setDocument(doc);

            return newProfile;
        }
        catch (CloneNotSupportedException e)
        {
View Full Code Here

        locator.createFromPath(locatorPath);
        String id = locator.getId();

        try
        {
            Profile profile = Profiler.getProfile(locator);
            PSMLDocument doc = profile.getDocument();
            if (doc == null)
            {
                return null;
            }
            Portlets portlets = doc.getPortlets();
View Full Code Here

            this.consumer = consumer;
            profiles = query(locator);

            while (profiles.hasNext() )
            {
                Profile profile = (Profile)profiles.next();
                //dumpProfile(profile);
                try
                {
                    consumer.createDocument(profile);
                    count++;
View Full Code Here

     * @param portlets The PSML blob.
     * @return A new profile object representing the locator and PSML blob.
     */
    public Profile createUserProfile(JetspeedUserProfile entity, Portlets portlets)
    {
        Profile profile = Profiler.createProfile();
        try
        {
            JetspeedUser user = JetspeedSecurity.getUser(entity.getUserName());
            if (null == user)
            {
                user = JetspeedUserFactory.getInstance();
                user.setUserName(entity.getUserName());
            }
            profile.setUser(user);

            profile.setMediaType(entity.getMediaType());
            profile.setLanguage(entity.getLanguage());
            profile.setCountry(entity.getCountry());
            profile.setName(entity.getPage());
            profile.setDocument(getPSMLDocument(entity.getPage(), portlets));
        }
        catch (JetspeedSecurityException e)
        {
        }
        return profile;
View Full Code Here

     * @param portlets The PSML blob.
     * @return A new profile object representing the locator and PSML blob.
     */
    public Profile createGroupProfile(JetspeedGroupProfile entity, Portlets portlets)
    {
        Profile profile = Profiler.createProfile();
        try
        {
            Group group = JetspeedSecurity.getGroup(entity.getGroupName());
            if (null == group)
            {
                group = JetspeedGroupFactory.getInstance();
                group.setName(entity.getGroupName());
            }
            profile.setGroup(group);
            profile.setMediaType(entity.getMediaType());
            profile.setLanguage(entity.getLanguage());
            profile.setCountry(entity.getCountry());
            profile.setName(entity.getPage());
            profile.setDocument(getPSMLDocument(entity.getPage(), portlets));
        }
        catch (JetspeedSecurityException e)
        {
        }
        return profile;
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.om.profile.Profile

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.