Package org.apache.jetspeed.om.profile

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


     * @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


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

     * @param portlets The PSML blob.
     * @return A new profile object representing the locator and PSML blob.
     */
    public Profile createRoleProfile(JetspeedRoleProfile entity, Portlets portlets)
    {
        Profile profile = Profiler.createProfile();
        try
        {
            Role role = JetspeedSecurity.getRole(entity.getRoleName());
            if (null == role)
            {
                role = JetspeedRoleFactory.getInstance();
                role.setName(entity.getRoleName());
            }
            profile.setRole(role);
            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

    public void doDelete(RunData data, Context context) throws Exception
    {
      JetspeedRunData jdata = (JetspeedRunData)data;
      PortletSet customizedSet = (PortletSet)jdata.getCustomized();
      int position = data.getParameters().getInt("position",-1);
      Profile profile = jdata.getCustomizedProfile();

      // ADDED for WML
      //boolean isWML = (profile.getMediaType().equalsIgnoreCase("wml"));


        if (customizedSet == null) return;

        if (position > -1)
        {
            Portlets set = profile.getDocument()
                                  .getPortletsById(customizedSet.getID());
            if (set != null)
            {
                // first try explicit portlets position
                for(int i=0; i < set.getPortletsCount(); i++)
View Full Code Here

    public void doMove(RunData data, Context context, boolean moveUp) throws Exception
    {
        JetspeedRunData jdata = (JetspeedRunData)data;
        PortletSet customizedSet = (PortletSet)jdata.getCustomized();
        int position = data.getParameters().getInt("position",-1);
        Profile profile = jdata.getCustomizedProfile();

        // ADDED for WML
        //boolean isWML = (profile.getMediaType().equalsIgnoreCase("wml"));


        if (customizedSet == null) return;

        if (position > -1)
        {
            int target = -1;

            Portlets set = profile.getDocument()
                                  .getPortletsById(customizedSet.getID());
            Layout targetLayout = null;
            Layout baseLayout = null;

            if (set != null)
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

        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);

            context.put("parents", PortletFilter.buildParentList(allPortlets));
            addFiltersToContext(rundata, context);

            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))
        {
            //String filterType = rundata.getParameters().getString("filter_type");
            //String filterValue = rundata.getParameters().getString("filter_value");
            String filterType =
                (String) PortletSessionState.getAttributeWithFallback(
                    portlet,
                    rundata,
                    FILTER_TYPE);
            String filterValue =
                (String) PortletSessionState.getAttributeWithFallback(
                    portlet,
                    rundata,
                    FILTER_VALUE);

            Iterator psmlIterator = null;
            if (StringUtils.isEmpty(filterType)
                || StringUtils.isEmpty(filterValue))
            {
                psmlIterator =
                    Profiler.query(new QueryLocator(QueryLocator.QUERY_ALL));
            }
            else
            {
                PortletSessionState.setAttribute(
                    portlet,
                    rundata,
                    FILTER_TYPE,
                    filterType);
        PortletSessionState.setAttribute(
          portlet,
          rundata,
          FILTER_VALUE,
          filterValue);
        context.put(FILTER_TYPE, filterType);
        context.put(FILTER_VALUE, filterValue);
       
                QueryLocator ql = null;
                if (filterType.equalsIgnoreCase("filter_type_user"))
                {
                    try
                    {
                        JetspeedUser user =
                            JetspeedSecurity.getUser(filterValue);
                        ql = new QueryLocator(QueryLocator.QUERY_USER);
                        ql.setUser(user);
                        psmlIterator = Profiler.query(ql);
                    }
                    catch (Exception e)
                    {
                    }
                }
                else if (filterType.equalsIgnoreCase("filter_type_role"))
                {
                    try
                    {
                        Role role = JetspeedSecurity.getRole(filterValue);
                        ql = new QueryLocator(QueryLocator.QUERY_ROLE);
                        ql.setRole(role);
                        psmlIterator = Profiler.query(ql);
                    }
                    catch (Exception e)
                    {
                    }
                }
                else if (filterType.equalsIgnoreCase("filter_type_group"))
                {
                    try
                    {
                        Group group = JetspeedSecurity.getGroup(filterValue);
                        ql = new QueryLocator(QueryLocator.QUERY_GROUP);
                        ql.setGroup(group);
                        psmlIterator = Profiler.query(ql);
                    }
                    catch (Exception e)
                    {
                    }
                }
            }

            // 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
        {
            ProfileLocator locator = Profiler.createLocator();
            locator.createFromPath(path);
            Profile profile = Profiler.getProfile(locator);
            if (profile != null)
            {
                PSMLDocument doc = profile.getDocument();
                if (doc != null)
                {
                    Portlets rootSet = doc.getPortlets();
                    /*
                    There is no way to do a check on a Portlets element, only a Entry element.
View Full Code Here

        {
            String controller = rundata.getParameters().getString("controller");

            if (controller != null)
            {
                Profile profile =
                    ((JetspeedRunData) rundata).getCustomizedProfile();
                PortletController pc = PortalToolkit.getController(controller);

                if (pc != null)
                {
                    set.setController(pc);

                    Portlets portlets =
                        profile.getDocument().getPortletsById(set.getID());

                    Controller c = portlets.getController();
                    if (c == null)
                    {
                        c = new PsmlController();
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.