Package org.apache.jetspeed.om.profile

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


        ConcreteElement result = null;
        String msg = "";
       
        if (null != rundata)
        {
            Profile profile = rundata.getProfile();
            try
            {
                if (null == profile)
                {
                    profile = Profiler.getProfile(rundata);
                    if (profile == null)
                    {
                        throw new ProfileException("Profile not found.");
                    }
                    rundata.setProfile(profile);
                }
           
                if ((name == null) ||  Profiler.DEFAULT_PROFILE.equals(name) || "".equals(name))
                    ;
                else
                    profile.setName(name);
    
                PSMLDocument doc = profile.getDocument();
                if (null != doc)
                {
                    result = PortalToolkit.getSet(doc.getPortlets()).getContent(rundata);
                }
            }
View Full Code Here


         try {
             if (null != data)
             {
                 JetspeedRunData jdata = (JetspeedRunData)data;
                 Profile profile = jdata.getProfile();
                 if (null == profile)
                 {
                     logger.warn("JetspeedTool: profile is null");
                     profile = Profiler.getProfile(jdata);
View Full Code Here

    {
        ConcreteElement result = null;
       
        if (null != rundata)
        {
            Profile profile = rundata.getProfile();
            try
            {
                if (null == profile)
                {
                    System.out.println("profile is null");
                    profile = Profiler.getProfile(rundata);
                    rundata.setProfile(profile);
                }
                PSMLDocument doc = profile.getDocument();
                if (null != doc)
                {               
                    Entry entry = doc.getEntryById(id);
                    if (null == entry)
                    {
View Full Code Here

     * "js_peid" parameter
     */
    public Entry getEntryFromRequest() throws Exception
    {
        String jsPeid = rundata.getParameters().getString("js_peid");
        Profile profile = Profiler.getProfile(rundata);
        PSMLDocument doc = profile.getDocument();
        return doc.getEntryById(jsPeid);
    }
View Full Code Here

        if (runDataService != null)
        {
            JetspeedRunData rundata = runDataService.getCurrentRunData();
            if (rundata != null)
            {
                Profile profile = rundata.getProfile();
                if (profile != null)
                {
                    pc.setPageId(profile.getId());
                }
            }
        }
        pc.setPortletId(id);
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

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

        try
        {
            Profile profile = Profiler.getProfile(locator);
            PSMLDocument doc = profile.getDocument();

            if (doc == null)
            {
                return null;
            }
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());
                if (msgid == null)
                {
                    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);
                        }
                        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;

        try
        {
            categoryName = rundata.getParameters().getString("CategoryName");
            categoryValue = rundata.getParameters().getString("CategoryValue");
            copyFrom = rundata.getParameters().getString("CopyFrom");
            name = rundata.getParameters().getString("name");
            //
            //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("psml_mediatype");
            if (tempVar != null && tempVar.trim().length() > 0)
            {
                locator.setMediaType(tempVar);
            }

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

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

            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.getPaneByName(PSML_UPDATE_PANE)
                                      .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
            //
            ProfileLocator baseLocator = Profiler.createLocator();
            baseLocator.createFromPath(copyFrom);
            Profile baseProfile = Profiler.getProfile(baseLocator);

            //
            // create a new profile
            //
            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

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.