Package org.apache.jetspeed.om.profile

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


                                + groupProfile.getGroupName());
                    }
                }

                // Create a new profile for the user
                ProfileLocator locator = createLocator();
                locator.setUser((JetspeedUser) data.getUser());
                locator.setMediaType(mediaType);
                locator.setName("default.psml");
                //locator.setName(this.resourceDefault + this.resourceExt);

                // Regenerate the portlet ids so they are unique
                org.apache.jetspeed.util.PortletUtils.regenerateIds(portlets);
View Full Code Here


           
            if(obj != null)
            {
                if(obj instanceof ProfileLocator)
              {
                  ProfileLocator locator = (ProfileLocator)obj;
                  refresh(locator);
              }
             
              if(obj instanceof PsmlMessage)
              {
View Full Code Here

        RunData rundata)
    {
        try
        {
            List locators = new LinkedList();
            ProfileLocator locator = (ProfileLocator) original.clone();

            locators.add(locator.clone());

            // remove country
            if (null != original.getCountry())
            {
                locator.setCountry(null);
                locators.add(locator.clone());
            }

            // remove language
            if (null != original.getLanguage())
            {
                locator.setLanguage(null);
                locators.add(locator.clone());
            }

            // fallback mediaType
            if (null != original.getMediaType())
            {
                locator.setMediaType(null);
                locators.add(locator.clone());
            }

            if (null != original.getGroup())
            {
                locator.setGroup(null);
                locators.add(locator.clone());
            }
            else if (null != original.getRole())
            {
                locator.setRole(null);
                locators.add(locator.clone());
            }
            else if (null != original.getUser())
            {
                locator.setUser(null);
                locators.add(locator.clone());
            }
            PSMLDocument doc = PsmlManager.getDocument(locators);
            return doc;

        }
View Full Code Here

            // TODO: make this configurable

            try
            {
                ProfileLocator locator = createLocator();
                // If group is not null assume this is a Group we are requesting
                if (profile.getGroup() != null)
                {
                    locator.setGroup(JetspeedSecurity.getGroup(from));
                }
                else
                {
                    locator.setUser(JetspeedSecurity.getUser(from));
                }

                locator.setMediaType(contentType);
                PSMLDocument doc = fallback(locator);

                if (doc != null)
                {
                    PSMLDocument clonedDoc =
View Full Code Here

        return keybuf.toString();
    }

    protected ProfileLocator stringToLocator(String locstr) throws Exception
    {
        ProfileLocator locator = Profiler.createLocator();
        String entity = null;

        if (logger.isDebugEnabled())
            logger.debug("DatabasePsmlManagerService: Creating locator for string: " + locstr);

        StringTokenizer dollarTokens = new StringTokenizer(locstr, "$");
        while (dollarTokens.hasMoreTokens())
        {
            String dollarToken = dollarTokens.nextToken().trim();

            StringTokenizer colonTokens = new StringTokenizer(dollarToken, ":");
            String colonToken = colonTokens.nextToken();
            if (colonToken.equals("User"))
            {
                entity = colonTokens.nextToken().trim();
                locator.setUser(JetspeedSecurity.getUser(entity));
            }
            else if (colonToken.equals("Group"))
            {
                entity = colonTokens.nextToken().trim();
                locator.setGroup(JetspeedSecurity.getGroup(entity));
            }
            else if (colonToken.equals("Role"))
            {
                entity = colonTokens.nextToken().trim();
                locator.setRole(JetspeedSecurity.getRole(entity));
            }
            else if (colonToken.equals("Page"))
            {
                entity = colonTokens.nextToken().trim();
                locator.setName(entity);
            }
            else if (colonToken.equals("MediaType"))
            {
                entity = colonTokens.nextToken().trim();
                locator.setMediaType(entity);
            }
            else if (colonToken.equals("Country"))
            {
                entity = colonTokens.nextToken().trim();
                locator.setCountry(entity);
            }
            else if (colonToken.equals("Language"))
            {
                entity = colonTokens.nextToken().trim();
                locator.setLanguage(entity);
            }
        }
        if (logger.isDebugEnabled())
            logger.debug("DatabasePsmlManagerService: Returning locator for string: " + locatorToString(locator));
View Full Code Here

           
            if(obj != null)
            {
                if(obj instanceof ProfileLocator)
              {
                  ProfileLocator locator = (ProfileLocator)obj;
                  refresh(locator);
              }
             
              if(obj instanceof PsmlMessage)
              {
View Full Code Here

        RunData rundata,
        String path)
    {
        try
        {
            ProfileLocator locator = Profiler.createLocator();
            locator.createFromPath(path);
            Profile profile = Profiler.getProfile(locator);
            if (profile != null)
            {
                PSMLDocument doc = profile.getDocument();
                if (doc != null)
View Full Code Here

     * @param locatorPath ProfileLocator resource path identifier
     * @return a portlets collection from the PSML resource
     */
    public Portlets getReference(String locatorPath)
    {
        ProfileLocator locator = Profiler.createLocator();
        locator.createFromPath(locatorPath);
        String id = locator.getId();

        try
        {
            Profile profile = Profiler.getProfile(locator);
            PSMLDocument doc = profile.getDocument();
View Full Code Here

        if (null == path)
        {
            return new JetspeedClearElement("Path parameter not set");
        }
        ProfileLocator locator = Profiler.createLocator();
        locator.createFromPath(path);
        String id = locator.getId();

        try
        {
            Profile profile = Profiler.getProfile(locator);
            PSMLDocument doc = profile.getDocument();
View Full Code Here

                int id = Integer.parseInt(msgid);
                if (id < SecurityConstants.MESSAGES.length)
                    context.put(SecurityConstants.PARAM_MSG, SecurityConstants.MESSAGES[id]);

                // get the bad entered data and put it back for convenient update
                 ProfileLocator locator = (ProfileLocator)rundata.getUser().getTemp(TEMP_LOCATOR);
                if (locator != null)
                    context.put("profile", Profiler.createProfile(locator));
            }

            String mode = rundata.getParameters().getString(SecurityConstants.PARAM_MODE);
            context.put(SecurityConstants.PARAM_MODE, mode);
            String path = rundata.getParameters().getString(SecurityConstants.PARAM_ENTITY_ID);

            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);
                        }
                        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;
                                }
View Full Code Here

TOP

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

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.