Package org.apache.jetspeed.om.profile

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


            // retrieve the profiles to export
            //
            Iterator i = Profiler.query(new QueryLocator(QueryLocator.QUERY_ALL));
            while (i.hasNext())
            {
                Profile profile = (Profile) i.next();
                PSMLDocument doc = profile.getDocument();
                if(doc != null)
                {
                    // Build the fully qualified file name
                    StringBuffer copyToFile = new StringBuffer(copyTo);
                    copyToFile.append(File.separator);
                    if (profile.getGroupName() != null)
                    {
                        copyToFile.append("group");
                        copyToFile.append(File.separator);
                        copyToFile.append(profile.getGroupName());
                        copyToFile.append(File.separator);
                    }
                    else if (profile.getRoleName() != null)
                    {
                        copyToFile.append("role");
                        copyToFile.append(File.separator);
                        copyToFile.append(profile.getRoleName());
                        copyToFile.append(File.separator);
                    }
                    else if (profile.getUserName() != null)
                    {
                        copyToFile.append("user");
                        copyToFile.append(File.separator);
                        copyToFile.append(profile.getUserName());
                        copyToFile.append(File.separator);
                    }
                    if (profile.getMediaType() != null)
                    {
                        copyToFile.append(profile.getMediaType());
                        copyToFile.append(File.separator);
                    }
                    if (profile.getLanguage() != null)
                    {
                        copyToFile.append(profile.getLanguage());
                        copyToFile.append(File.separator);
                    }
                    if (profile.getCountry() != null)
                    {
                        copyToFile.append(profile.getCountry());
                        copyToFile.append(File.separator);
                    }
                    copyToFile.append(profile.getName());

                    if (!this.saveDocument(copyToFile.toString(), doc)) {
                        logger.error("Failed to save PSML document for [" + profile.getPath());
                    } else {
                        String msg = "Profile [" + profile.getPath() + "] has been saved to disk in [" + copyToFile.toString() + "]<br>";
                        logger.info(msg);
                        rundata.addMessage(msg);
                    }
                }
            }
View Full Code Here


     * @param context The velocity context for this request.
     */
    public void doImport(RunData rundata, Context context)
        throws Exception
    {
        Profile profile = null;
        ProfileLocator locator = null;
        String categoryName = null;
        String categoryValue = null;
        String copyFrom = null;
        String name = null;
View Full Code Here

        // Retrieve the role profile
        ProfileLocator roleLocator = Profiler.createLocator();
        roleLocator.setRole(role);
        roleLocator.setMediaType(jdata.getCapability().getPreferredMediaType());
        roleLocator.setName("default.psml");
        Profile roleProfile = Profiler.getProfile(roleLocator);
        if (roleProfile != null)
        {
            if (logger.isDebugEnabled())
            {
                logger.debug("UserRoleUpdateAction: retrieved profile for role: " + roleProfile.getPath());
            }
        }

        // Retrieve the user profile
        ProfileLocator userLocator = Profiler.createLocator();
        userLocator.setUser(user);
        userLocator.setMediaType(jdata.getCapability().getPreferredMediaType());
        userLocator.setName("default.psml");
        Profile userProfile = Profiler.getProfile(userLocator);
        if (userProfile != null)
        {
            if (logger.isDebugEnabled())
            {
                logger.debug("UserRoleUpdateAction: retrieved profile for user: " + userProfile.getPath());
            }
        }

        // Append role profile to user profile
        if (roleProfile != null &&
            roleProfile.getDocument() != null &&
            userProfile != null &&
            userProfile.getDocument() != null)
        {
            Profile tmpProfile = (Profile) roleProfile.clone();
            Portlets rolePortlets = tmpProfile.getDocument().getPortlets();
            Portlets userPortlets = userProfile.getDocument().getPortlets();

            // Handle pane based profile
            if (rolePortlets.getPortletsCount() > 0)
            {
View Full Code Here

        try
        {
            while (i.hasNext())
            {
                Profile profile = (Profile) i.next();

                if (PortletUtils.canAccessProfile(rundata, profile))
                {
                    entries.add(profile);               
                }
View Full Code Here

            if (mode != null && mode.equals(SecurityConstants.PARAM_MODE_DELETE))
            {
                ProfileLocator locator = Profiler.createLocator();
                locator.createFromPath(path);
                Profile profile = Profiler.getProfile(locator);
                if (profile != null)
                {
                    rundata.getUser().setTemp(TEMP_LOCATOR, locator);
                    context.put("profile", profile);
                }
                else
                {
                    logger.error("Profile for Path:" + path + " Not Found!");
                }
            }

            if (mode != null && mode.equals(SecurityConstants.PARAM_MODE_INSERT))
            {
                org.apache.jetspeed.om.registry.Registry mediaTypes = Registry.get(Registry.MEDIA_TYPE);
                context.put("mediaTypes", mediaTypes.listEntryNames());
                JetspeedRunData jdata = (JetspeedRunData) rundata;
                context.put("defMediaType", jdata.getCapability().getPreferredMediaType());
                if (msgid == null)
                {
                    if (((String) context.get("can-clone")).equals("false"))
                    {
                        context.put(CATEGORY_NAME, "user");
                        context.put("categoryValue", rundata.getUser().getUserName());
                        context.put("copyFrom", "none");
                        context.put("title", "My Page");
                    }
                    else if (path == null)
                    {
                        context.put(CATEGORY_NAME, "user");
                        context.put("categoryValue", "anon");
                        context.put("copyFrom", "user/anon/media-type/html/page/default.psml");
                    }
                    else
                    {
                        ProfileLocator tmpLocator = Profiler.createLocator();
                        tmpLocator.createFromPath(path);
                        Profile profile = Profiler.getProfile(tmpLocator);
                        if (profile != null)
                        {
                            rundata.getUser().setTemp(TEMP_LOCATOR, tmpLocator);
                            context.put("profile", profile);
                            context.put("title", profile.getRootSet().getTitle());
                        }
                        String categoryName = "group";
                        String categoryValue = tmpLocator.getGroupName();
                        if (categoryValue == null)
                        {
                            categoryName = "role";
                            categoryValue = tmpLocator.getRoleName();
                            if (categoryValue == null)
                            {
                                categoryName = "user";
                                categoryValue = tmpLocator.getUserName();
                                if (categoryValue == null)
                                {
                                    categoryName = "user";
                                    categoryValue = "anon";
                                }
                            }

                        }
                        context.put(CATEGORY_NAME, categoryName);
                        context.put("categoryValue", categoryValue);
                        context.put("copyFrom", path);
                    }
                }
                else
                {
                    context.put(CATEGORY_NAME, rundata.getUser().getTemp(CATEGORY_NAME));
                    context.put(CATEGORY_VALUE, rundata.getUser().getTemp(CATEGORY_VALUE));
                    context.put(COPY_FROM, rundata.getUser().getTemp(COPY_FROM));
                }
            }

            if (mode != null && mode.equals("export"))
            {
                if (msgid == null)
                {
                    String tmpPath = JetspeedResources.getString(JetspeedResources.TEMP_DIRECTORY_KEY, "/tmp");
                    String exportPath = JetspeedResources.getString("psml.export.default.path",
                                                                    TurbineServlet.getRealPath(tmpPath));
                    if (path == null)
                    {
                        context.put(COPY_TO, exportPath);
                        context.put(COPY_FROM,
                                    Profiler.PARAM_USER +
                                    File.separator +
                                    Profiler.PARAM_ANON +
                                    File.separator +
                                    Profiler.PARAM_MEDIA_TYPE +
                                    File.separator +
                                    "html" +
                                    File.separator +
                                    Profiler.PARAM_PAGE +
                                    File.separator +
                                    Profiler.FULL_DEFAULT_PROFILE);
                    }
                    else
                    {
                        ProfileLocator tmpLocator = Profiler.createLocator();
                        tmpLocator.createFromPath(path);
                        Profile profile = Profiler.getProfile(tmpLocator);
                        if (profile != null)
                        {
                            rundata.getUser().setTemp(TEMP_LOCATOR, tmpLocator);
                            context.put("profile", profile);
                        }

                        String categoryName = Profiler.PARAM_GROUP;
                        String categoryValue = tmpLocator.getGroupName();
                        if (categoryValue == null)
                        {
                            categoryName = Profiler.PARAM_ROLE;
                            categoryValue = tmpLocator.getRoleName();
                            if (categoryValue == null)
                            {
                                categoryName = Profiler.PARAM_USER;
                                categoryValue = tmpLocator.getUserName();
                                if (categoryValue == null)
                                {
                                    categoryName = Profiler.PARAM_USER;
                                    categoryValue = Profiler.PARAM_ANON;
                                }
                            }

                        }

                        context.put(COPY_TO, exportPath + File.separator + tmpLocator.getName());
                        context.put(COPY_FROM, path);
                    }
                }
                else
                {
                    context.put(COPY_TO, rundata.getUser().getTemp(COPY_TO));
                    context.put(COPY_FROM, rundata.getUser().getTemp(COPY_FROM));
                }
            }

            if (mode != null && mode.equals("export_all"))
            {
                if (msgid == null)
                {
                    // get the PSML Root Directory
                    ResourceService serviceConf = ((TurbineServices) TurbineServices.getInstance())
                                                  .getResources(PsmlManagerService.SERVICE_NAME);
                    String root = serviceConf.getString("root", "/WEB-INF/psml");
                    context.put(COPY_TO, TurbineServlet.getRealPath(root));
                }
                else
                {
                    context.put(COPY_TO, rundata.getUser().getTemp(COPY_TO));
                }
            }

            if (mode != null && mode.equals("import"))
            {
                org.apache.jetspeed.om.registry.Registry mediaTypes = Registry.get(Registry.MEDIA_TYPE);
                context.put("mediaTypes", mediaTypes.listEntryNames());
                if (msgid == null)
                {
                    // get the PSML Root Directory
                    ResourceService serviceConf = ((TurbineServices) TurbineServices.getInstance())
                                                  .getResources(PsmlManagerService.SERVICE_NAME);
                    String root = serviceConf.getString("root", "/WEB-INF/psml");
                    root = TurbineServlet.getRealPath(root);

                    if (path == null)
                    {
                        context.put(CATEGORY_NAME, Profiler.PARAM_USER);
                        context.put("categoryValue", Profiler.PARAM_ANON);
                        context.put("copyFrom",
                                    root +
                                    File.separator +
                                    Profiler.PARAM_USER +
                                    File.separator +
                                    Profiler.PARAM_ANON +
                                    File.separator +
                                    Profiler.PARAM_MEDIA_TYPE +
                                    File.separator +
                                    "html" +
                                    File.separator +
                                    Profiler.PARAM_PAGE +
                                    File.separator +
                                    Profiler.FULL_DEFAULT_PROFILE);
                    }
                    else
                    {
                        ProfileLocator tmpLocator = Profiler.createLocator();
                        tmpLocator.createFromPath(path);
                        Profile profile = Profiler.getProfile(tmpLocator);
                        if (profile != null)
                        {
                            rundata.getUser().setTemp(TEMP_LOCATOR, tmpLocator);
                            context.put("profile", profile);
                        }
View Full Code Here

     * @param context The velocity context for this request.
     */
    public void doInsert(RunData rundata, Context context)
    throws Exception
    {
        Profile profile = null;
        ProfileLocator locator = null;
        String categoryName = null;
        String categoryValue = null;
        String copyFrom = null;
        String name = null;
        String title = null;

        try
        {
            categoryName = rundata.getParameters().getString("CategoryName");
            categoryValue = rundata.getParameters().getString("CategoryValue");
            copyFrom = rundata.getParameters().getString("CopyFrom");
            name = rundata.getParameters().getString("name");
            title = rundata.getParameters().getString("title");
            //
            //create a new locator and set its values according to users input
            //
            locator = Profiler.createLocator();
            if (categoryName.equalsIgnoreCase(Profiler.PARAM_GROUP))
            {
                locator.setGroupByName(categoryValue);
            }
            else if (categoryName.equalsIgnoreCase(Profiler.PARAM_ROLE))
            {
                locator.setRoleByName(categoryValue);
            }
            else if (categoryName.equalsIgnoreCase(Profiler.PARAM_USER))
            {
                locator.setUser(JetspeedSecurity.getUser(categoryValue));
            }
            else
            {
                locator.setAnonymous(true);
            }

            String tempVar = rundata.getParameters().getString("MediaType");
            if (tempVar != null && tempVar.trim().length() > 0)
            {
                locator.setMediaType(tempVar);
            }

            tempVar = rundata.getParameters().getString("Language");
            if (tempVar != null && tempVar.trim().length() > 0)
            {
                locator.setLanguage(tempVar);
            }

            tempVar = rundata.getParameters().getString("Country");
            if (tempVar != null && tempVar.trim().length() > 0)
            {
                locator.setCountry(tempVar);
            }

            if (!name.endsWith(Profiler.DEFAULT_EXTENSION))
            {
                name = name + Profiler.DEFAULT_EXTENSION;
            }
            locator.setName(name);

            //check if profile to be created already exists
            if (PsmlManager.getDocument(locator) != null)
            {
                throw new EntityExistsException("Profile:"+locator.getPath()+" Already Exists!");           
            }

            //
            // validate that its not an 'blank' profile -- not allowed
            //
            if (name == null || name.trim().length() == 0)
            {
                JetspeedLink link = JetspeedLinkFactory.getInstance(rundata);
                DynamicURI duri = link.addPathInfo(SecurityConstants.PARAM_MODE,
                                                   SecurityConstants.PARAM_MODE_INSERT)
                                  .addPathInfo(SecurityConstants.PARAM_MSGID,
                                               SecurityConstants.MID_INVALID_ENTITY_NAME);
                JetspeedLinkFactory.putInstance(link);
                rundata.setRedirectURI(duri.toString());

                //save user entered values
                if (locator != null)
                    rundata.getUser().setTemp(TEMP_LOCATOR, locator);
                if (categoryName != null)
                    rundata.getUser().setTemp(CATEGORY_NAME, categoryName);
                if (categoryValue != null)
                    rundata.getUser().setTemp(CATEGORY_VALUE, categoryValue);
                if (copyFrom != null)
                    rundata.getUser().setTemp(COPY_FROM, copyFrom);
                return;
            }

            //
            // retrieve the profile to clone
            //
            Profile baseProfile = null;
            if (copyFrom != null && !copyFrom.equals("none"))
            {
                ProfileLocator baseLocator = Profiler.createLocator();
                baseLocator.createFromPath(copyFrom);
                baseProfile = Profiler.getProfile(baseLocator);
            }

            //
            // create a new profile
            //

            // AT THIS POINT "portlet" is null ????
            //Portlet portlet = (Portlet) context.get("portlet");
            //PortletEntry entry = (PortletEntry) Registry.getEntry(Registry.PORTLET, portlet.getName());

            if (copyFrom.equals("none"))
            {
                profile = Profiler.createProfile(locator, null);
                profile.getDocument().getPortlets().setTitle(title);
                profile.store();
                //System.out.println("Profile title: " + profile.getDocument().getPortlets().getTitle() + " for " + profile.getDocument().getPortlets());
                setRefreshPsmlFlag(rundata, TRUE);
            }
            else if (baseProfile != null)
            {
                PSMLDocument doc = baseProfile.getDocument();
                if (doc != null)
                {
                    Portlets portlets = doc.getPortlets();
                   
                    Portlets clonedPortlets = (Portlets) SerializationUtils.clone(portlets);
View Full Code Here

     * @param context The velocity context for this request.
     */
    public void doExport(RunData rundata, Context context)
    throws Exception
    {
        Profile profile = null;
        ProfileLocator locator = null;
        String copyTo = null;
        String copyFrom = null;

        try
        {
            copyFrom = rundata.getParameters().getString("CopyFrom");
            copyTo = rundata.getParameters().getString("CopyTo");

            //
            // retrieve the profile to clone
            //
            ProfileLocator baseLocator = Profiler.createLocator();
            baseLocator.createFromPath(copyFrom);
            Profile baseProfile = Profiler.getProfile(baseLocator);

            //
            // Export profile
            //
            if (baseProfile != null)
            {
                PSMLDocument doc = baseProfile.getDocument();
                if (doc != null)
                {
                    if (!this.saveDocument(copyTo,doc))
                        throw new Exception("Failed to save PSML document");
                    rundata.addMessage("Profile [" + copyFrom + "] has been saved to disk in [" + copyTo + "]<br>");
View Full Code Here

            // retrieve the profiles to export
            //
            Iterator i = Profiler.query(new QueryLocator(QueryLocator.QUERY_ALL));
            while (i.hasNext())
            {
                Profile profile = (Profile) i.next();
                PSMLDocument doc = profile.getDocument();
                if (doc != null)
                {
                    // Build the fully qualified file name
                    StringBuffer copyToFile = new StringBuffer(copyTo);
                    copyToFile.append(File.separator);
                    if (profile.getGroupName() != null)
                    {
                        copyToFile.append("group");
                        copyToFile.append(File.separator);
                        copyToFile.append(profile.getGroupName());
                        copyToFile.append(File.separator);
                    }
                    else if (profile.getRoleName() != null)
                    {
                        copyToFile.append("role");
                        copyToFile.append(File.separator);
                        copyToFile.append(profile.getRoleName());
                        copyToFile.append(File.separator);
                    }
                    else if (profile.getUserName() != null)
                    {
                        copyToFile.append("user");
                        copyToFile.append(File.separator);
                        copyToFile.append(profile.getUserName());
                        copyToFile.append(File.separator);
                    }
                    if (profile.getMediaType() != null)
                    {
                        copyToFile.append(profile.getMediaType());
                        copyToFile.append(File.separator);
                    }
                    if (profile.getLanguage() != null)
                    {
                        copyToFile.append(profile.getLanguage());
                        copyToFile.append(File.separator);
                    }
                    if (profile.getCountry() != null)
                    {
                        copyToFile.append(profile.getCountry());
                        copyToFile.append(File.separator);
                    }
                    copyToFile.append(profile.getName());

                    if (!this.saveDocument(copyToFile.toString(), doc))
                    {
                        logger.error("Failed to save PSML document for [" + profile.getPath());
                    }
                    else
                    {
                        String msg = "Profile [" + profile.getPath() + "] has been saved to disk in [" + copyToFile.toString() + "]<br>";
                        logger.info(msg);
                        rundata.addMessage(msg);
                    }
                }
            }
View Full Code Here

     * @param context The velocity context for this request.
     */
    public void doImport(RunData rundata, Context context)
    throws Exception
    {
        Profile profile = null;
        ProfileLocator locator = null;
        String categoryName = null;
        String categoryValue = null;
        String copyFrom = null;
        String name = null;
View Full Code Here

        // get the customization state for this page
        SessionState customizationState = jdata.getPageSessionState();

        // this will be the profile we are editing
        Profile profile = null;

        // the "reset" parameter's presence signals the start of customization
        if (    (resetStack != null)
            &&  ((resetStack.equalsIgnoreCase("on")) || (resetStack.equalsIgnoreCase("1"))))
        {
            // clear out any prior customization state
            jdata.cleanupFromCustomization();
        }

        // if we have not yet setup for customization, do so now
        if (jdata.getCustomizedProfile() == null)
        {
            ProfileLocator locator = (ProfileLocator)jdata.getProfile().clone();

            if (editMediaType != null)
            {
                locator.setMediaType(editMediaType);
            }

            // get a profile to edit
            profile = (Profile) Profiler.getProfile(locator).clone();
            jdata.setCustomizedProfile(profile);
        }

        // we are continuing an on-going customization
        else
        {
            // get the profile we are working on
            profile = jdata.getCustomizedProfile();
        }

        // Get js_peid parmameter.
        // If it does not exist, we will customize the root of the profile
        if ( peid == null )
        {
            // use the id of the root set of the profile
            peid = profile.getRootSet().getID();
            jdata.setJs_peid(peid);
        }

        // find the portlet within the profile with this peid %%% isn't there a better way to do this? -ggolden
        Portlet found = null;
        Stack sets = new Stack();
        sets.push(profile.getRootSet());

        while ((found==null) && (sets.size() > 0))
        {
            PortletSet set = (PortletSet)sets.pop();
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.