Package org.apache.jetspeed.om.profile

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


    */
    public static void save(RunData data)
    {
        try
        {
            Profile profile = ((JetspeedRunData) data).getCustomizedProfile();
            profile.store();
        }
        catch (Exception e)
        {
            logger.error("Error while saving profile", e);
        }
View Full Code Here


        JetspeedRunData data = (JetspeedRunData) pageContext.getAttribute(JspService.RUNDATA, PageContext.REQUEST_SCOPE);
       
        try
        {
            ConcreteElement result = null;
            Profile baseProfile = null;
            ProfileLocator baseLocator = Profiler.createLocator();
            int rootType = JetspeedLink.DEFAULT;
            String rootValue = null;
            int elementType = JetspeedLink.DEFAULT;
            String elementValue = null;

            // Create locator to retrieve profile settings
            if (this.psml != null)
            {
               baseLocator.createFromPath(this.psml);
               if (baseLocator.getUser() != null)
               {
                   rootType = JetspeedLink.USER;
                   rootValue = baseLocator.getUserName();
               }
               else if (baseLocator.getRole() != null)
               {
                   rootType = JetspeedLink.ROLE;
                   rootValue = baseLocator.getRoleName();
               }
               else if (baseLocator.getGroup() != null)
               {
                   rootType = JetspeedLink.GROUP;
                   rootValue = baseLocator.getGroupName();
               }
            }
            else
            {
               rootType = JetspeedLink.CURRENT;
               rootValue = "";
               baseProfile = data.getProfile();
               baseLocator.createFromPath(baseProfile.getPath());
            }

            //  Determine search method
            if (baseLocator != null)
            {               
View Full Code Here

            logger.error("The RunData object does not implement the expected interface, "
                       + "please verify the RunData factory settings", e);
            return;
        }

        Profile newProfile = null;
        Profile currentProfile = null;

        try
        {
            // get the profile and store it in the RunData
            newProfile = Profiler.getProfile(jdata);
            currentProfile = jdata.getProfile();
        }
        catch (Throwable other)
        {
            data.setScreenTemplate(JetspeedResources.getString(TurbineConstants.TEMPLATE_ERROR));
            String message = other.getMessage() != null ? other.getMessage() : other.toString();
            data.setMessage(message);
            data.setStackTrace(org.apache.turbine.util.StringUtils.stackTrace(other), other);

            if (currentProfile == null)
            {
                currentProfile = Profiler.createProfile();
            }
            if (newProfile == null)
            {
                newProfile = Profiler.createProfile();
            }
            if (data.getUser() == null)
            {
                JetspeedUser juser = new FakeJetspeedUser(JetspeedSecurity.getAnonymousUserName(), false);
                data.setUser(juser);
            }
        }


        if ((currentProfile == null)
         || (!currentProfile.equals(newProfile)))
        {
            // the profile changed due to the request parameters,
            // change it in the RunData
            jdata.setProfile(newProfile);
        }
View Full Code Here

        {
            JetspeedRunDataService runDataService =
               (JetspeedRunDataService)TurbineServices.getInstance()
                   .getService(RunDataService.SERVICE_NAME);
            JetspeedRunData rundata = runDataService.getCurrentRunData();
            Profile profile = Profiler.createProfile();
            profile.setGroup(group);
            profile.setMediaType("html");
            Profiler.createProfile(rundata, profile);
        }
        catch (ProfileException e)
        {
            try
View Full Code Here

                                      Context context,
                                      RunData rundata) throws Exception
    {
        JetspeedRunData jdata = (JetspeedRunData) rundata;
        SessionState customizationState = jdata.getPageSessionState();
        Profile profile = jdata.getCustomizedProfile();
        String mediaType = profile.getMediaType ();

        // set velocity variable of mediatype (displayed in the customizer menu)
        context.put("mtype", profile.getMediaType());

        // make the list of already used panes/portlets available through the 'runs' reference
        context.put("runs", AutoProfile.getPortletList(rundata));
       
        // we should first retrieve the portlet to customize
        PortletSet set = (PortletSet) (jdata).getCustomized();

        //identify the portlet submode and build the appropriate subt-template path
        String mode = rundata.getParameters().getString("mode");
        if (mode == null)
        {
          mode = (String) customizationState.getAttribute("customize-mode");
          if ((mode == null) || (mode.equalsIgnoreCase("addset")) || (mode.equalsIgnoreCase("general")))
          {
            mode = "layout";
          }
         
        }
        else
        {
          if ((mediaType.equalsIgnoreCase("wml")) && (!mode.equalsIgnoreCase("add")))
          {
            mode = "layout";
          }

          customizationState.setAttribute("customize-mode", mode);
        }

        String template = (String) context.get("template");

        if (template != null)
        {
            int idx = template.lastIndexOf(".");
           
            if (idx > 0)
            {
                template = template.substring(0, idx);
            }
           
            StringBuffer buffer = new StringBuffer(template);
            buffer.append("-").append(mode).append(".vm");
           
            template = TemplateLocator.locatePortletTemplate(rundata, buffer.toString());
            context.put("feature", template);

        }
   
        if (set == null)
        {
            return;
        }

        // get the customization state for this page
        String customizedPaneName = (String) customizationState.getAttribute("customize-paneName");
        if (customizedPaneName == null)
        {
            customizedPaneName = "*";
        }

        // generic context stuff
        context.put("panename", customizedPaneName);
        context.put("skin", set.getPortletConfig().getPortletSkin());
        context.put("set", set);
        context.put("action", "portlets.CustomizeSetAction");       
        context.put("controllers", buildInfoList(rundata, Registry.PORTLET_CONTROLLER, mediaType));
        //context.put("skins", buildList(rundata, Registry.SKIN));
        //context.put("securitys", buildList(rundata, Registry.SECURITY));
        context.put("customizer", portlet);
   
        String controllerName = set.getController().getConfig().getName();
        context.put("currentController", controllerName);

        context.put("currentSecurityRef", set.getPortletConfig().getSecurityRef());

       /**
        * Special handling for wml profiles
        * no skins, no properties menuentry, no panes
        * --------------------------------------------------------------------------
        * last modified: 12/10/01
        * Andreas Kempf, Siemens ICM S CP OP, Munich
        * mailto: A.Kempf@web.de
        */

        if (mediaType.equalsIgnoreCase("wml"))
        {
          context.put("currentSkin", "Not for wml!");
          context.put("allowproperties", "false");
        }
        else
        {
          if (set.getPortletConfig().getSkin() != null)
          {
            context.put("currentSkin", set.getPortletConfig().getPortletSkin().getName());
          }
          context.put("allowproperties", "true");
        }


        context.put("allowpane", "false");
       
        // do not allow panes for wml profiles
        if ((!mediaType.equalsIgnoreCase("wml")) && (set.getController() instanceof PortletSetController))
        {
          if (customizedPaneName != null)
          {
            context.put("allowpane", "true");
          }
        }
        else
        {
            context.put("allowportlet", "true");
        }
        // --------------------------------------------------------------------------
           


        if ("add".equals(mode)) // build context for add mode
        {
            int start = rundata.getParameters().getInt("start", -1);
            if (start < 0)
            {
                //System.out.println("Clearing session variables");
                start = 0;
                PortletSessionState.clearAttribute(rundata, USER_SELECTIONS);
                PortletSessionState.clearAttribute(rundata, PORTLET_LIST);
            }
           
            ArrayList allPortlets = new ArrayList();
            List portlets  = buildPortletList(rundata, set, mediaType, allPortlets);
            Map userSelections = getUserSelections(rundata);
            // Build a list of categories from the available portlets
            List categories = buildCategoryList(rundata, mediaType, allPortlets);
            context.put("categories", categories);
           
            int size = getSize(portlet);              
            int end = Math.min(start + size, portlets.size());
               
            if (start > 0)
            {
                context.put("prev", String.valueOf(Math.max(start - size, 0)));
            }
               
            if (start + size < portlets.size())
            {
                context.put("next", String.valueOf(start + size));
            }
               
            context.put("browser", portlets.subList(start, end));
            context.put("size", new Integer(size));
            context.put(UI_PORTLETS_SELECTED, userSelections);
           
      context.put("portlets", portlets);
        }
        else if ("addref".equals(mode))
        {
            Iterator psmlIterator = null;
            psmlIterator = Profiler.query(new QueryLocator(QueryLocator.QUERY_ALL));
           
            // Set Start and End
            int start = rundata.getParameters().getInt("start", 0);               
            int size = getSize(portlet);

            // Only include entries in compatibale with the Media-type/Country/Language
            List psmlList = new LinkedList();
            Profile refProfile = null;
            int profileCounter = 0;
            while (psmlIterator.hasNext())
            {
                refProfile = (Profile) psmlIterator.next();
               
                if (refProfile.getMediaType() != null)
                {
                    if (profile.getMediaType().equals(refProfile.getMediaType()) == false)
                    {
                        continue;
                    }
                }
               
                if (profile.getLanguage() != null)
                {
                    if (refProfile.getLanguage() != null)
                    {
                        if (profile.getLanguage().equals(refProfile.getLanguage()) == true)
                        {
                            if (profile.getCountry() != null)
                            {
                                if (refProfile.getCountry() != null)
                                {
                                    if (profile.getCountry().equals(refProfile.getCountry()) == false)
                                    {
                                        // Profile and Ref are different countries
                                        continue;
                                    }
                                }
                            }
                            else
                            {
                                if (refProfile.getCountry() != null)
                                {
                                    // Profile has no country and Ref has a country
                                    continue;
                                }
                            }
                        }
                        else
                        {
                            // Profile and Ref are different languages
                            continue;
                        }
                    }
                }
                else
                {
                    if (refProfile.getLanguage() != null)
                    {
                        // Profile has no Language and Ref has a country
                        continue;
                    }
                }
               
                if (profile.getPath().equals(refProfile.getPath()) == true)
                {
                    // Do not allow Profile to reference it self
                    continue;
                }
               
View Full Code Here

        doMetainfo(rundata, context);
        doSkin(rundata, context);
        doLayout(rundata, context);
        doSecurity(rundata, context);
       
        Profile profile = ((JetspeedRunData) rundata).getCustomizedProfile();
        try
        {
            String mtype = rundata.getParameters().getString("mtype");

            if (mtype != null)
            {
                profile.setMediaType(mtype);
            }
            profile.store();
        }
        catch (Exception e)
        {
            logger.error("Exception occured while saving PSML", e);
        }
View Full Code Here

        try
        {
            JetspeedRunData rundata = getRunData();
            if (rundata != null)
            {
                Profile profile = Profiler.createProfile();
                profile.setUser(user);
                profile.setMediaType("html");
                Profiler.createProfile(getRunData(), profile);
            }
        }
        catch (Exception e)
        {
View Full Code Here

            if (this.psml != null)
            {
                ProfileLocator baseLocator = Profiler.createLocator();
                baseLocator.createFromPath(this.psml);
                Profile baseProfile = Profiler.getProfile(baseLocator);
                if (baseProfile != null)
                {
                    entry = baseProfile.getDocument().getEntry(name);
                    if ( logger.isDebugEnabled() )
                    {
                        logger.debug("JetspeedPortletTag: retrieved [" + entry + "] from psml [" + this.psml);
                    }
                }
View Full Code Here

     * mailto: A.Kempf@web.de
     */
    public Profile createProfile(RunData data, Profile profile)
            throws ProfileException
    {
        Profile current = null;
        CapabilityMap map;

        if (data == null)
        {
            map = CapabilityMapFactory.getDefaultCapabilityMap();
        }
        else
        {
            map = ((JetspeedRunData)data).getCapability();
        }
        String mediaType = getMediaType(data, map);

        // if template is null then use role-based psml
        if (newUserTemplate == null)
            return current;

        if (mediaTypes != null)
        {
            Profile dummy;
            for (int ix=0; ix < mediaTypes.length; ix++)
            {
                dummy = createProfile(data, profile, mediaTypes[ix], newUserTemplate);
                if (mediaTypes[ix].equalsIgnoreCase(mediaType))
                    current = dummy;
View Full Code Here

     */
    public Profile getProfile(RunData data, CapabilityMap cm)
        throws ProfileException
    {
        JetspeedRunData rundata = (JetspeedRunData)data;
        Profile profile = fallbackProfile(rundata, cm);
        if (null == profile && useRoleFallback)
        {
            Vector profiles = new Vector();
            JetspeedUser user = rundata.getJetspeedUser();
            if (user != null)
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.