Package org.apache.turbine.util

Examples of org.apache.turbine.util.DynamicURI


        }
        catch (Throwable t)
        {
            t.printStackTrace();
        }
        return new DynamicURI();

    }
View Full Code Here


    {
        String uriPathType = null;
        String uriPathElement = null;
        try
        {
            DynamicURI uri = getRoot();

            // Set Group/Role/User in path
            switch (rootType)
            {
                case JetspeedLink.DEFAULT:
                case JetspeedLink.CURRENT:
                    break;
                case JetspeedLink.GROUP:
                    uriPathType = Profiler.PARAM_GROUP;
                    break;
                case JetspeedLink.ROLE:
                    uriPathType = Profiler.PARAM_ROLE;
                    break;
                case JetspeedLink.USER:
                    uriPathType = Profiler.PARAM_USER;
                    break;
            }

            if (rootType != JetspeedLink.CURRENT)
            {
                // Cleanup URI
                uri.removePathInfo(Profiler.PARAM_GROUP);
                uri.removePathInfo(Profiler.PARAM_ROLE);
                uri.removePathInfo(Profiler.PARAM_USER);

                if ((rootType != JetspeedLink.DEFAULT) && (rootValue != null) && (rootValue.trim().length() > 0))
                {
                    uri.addPathInfo(uriPathType, rootValue);
                }
            }

            // Set Page in path
            if (pageName != null)
            {
                uri.removePathInfo(Profiler.PARAM_PAGE);
                if (pageName.trim().length() > 0)
                {
                    uri.addPathInfo(Profiler.PARAM_PAGE, pageName);
                }
            }

            // Set Portlet/Pane in path
            switch (elementType)
            {
                case JetspeedLink.CURRENT:
                case JetspeedLink.DEFAULT:
                    break;
                case JetspeedLink.PANE_ID:
                    uriPathElement = JetspeedResources.PATH_PANEID_KEY;
                    break;
                case JetspeedLink.PANE_NAME:
                    uriPathElement = JetspeedResources.PATH_PANENAME_KEY;
                    break;
                case JetspeedLink.PORTLET_ID:
                    uriPathElement = JetspeedResources.PATH_PORTLETID_KEY;
                    break;
                case JetspeedLink.PORTLET_NAME:
                    uriPathElement = JetspeedResources.PATH_PORTLET_KEY;
                    break;
                case JetspeedLink.PORTLET_ID_QUERY:
                    if (logger.isDebugEnabled())
                    {
                        logger.debug("BaseJetspeedLink: elementValue = " + elementValue);
                    }
                    uriPathElement = JetspeedResources.PATH_PORTLETID_KEY;
                    ProfileLocator baseLocator = Profiler.createLocator();
                    Profile baseProfile = null;
                    switch (rootType)
                    {
                        case JetspeedLink.DEFAULT:
                            break;
                        case JetspeedLink.CURRENT:
                            baseProfile = rundata.getProfile();
                            break;
                        case JetspeedLink.GROUP:
                            baseLocator.setGroupByName(rootValue);
                            break;
                        case JetspeedLink.ROLE:
                            baseLocator.setRoleByName(rootValue);
                            break;
                        case JetspeedLink.USER:
                            try
                            {
                                if (logger.isDebugEnabled())
                                {
                                    logger.debug("BaseJetspeedLink: rootValue user = " + rootValue);
                                }
                                baseLocator.setUser(org.apache.jetspeed.services.JetspeedSecurity.getUser(rootValue));
                            }
                            catch (Exception se)
                            {
                                logger.error("Exception",  se);
                                return null;
                            }
                            break;
                    }
                   
                    if ((rootType != JetspeedLink.CURRENT) && (rootType != JetspeedLink.DEFAULT))
                    {
                        if (mediaType != null && mediaType.length() > 0)
                        {
                            baseLocator.setMediaType(mediaType);
                        }
                        if (language != null && language.length() > 0)
                        {
                            baseLocator.setLanguage(language);
                        }
                        if (country != null && country.length() > 0)
                        {
                            baseLocator.setCountry(country);
                        }
                        if (pageName != null && pageName.length() > 0)
                        {
                            baseLocator.setName(pageName);
                        }
                        baseProfile = Profiler.getProfile(baseLocator);
                    }
                  
                    if (logger.isDebugEnabled())
                    {
                        logger.debug("BaseJetspeedLink: baseLocator = " + baseLocator.getPath());
                    }

                    if ((baseProfile != null) && (elementValue != null))
                    {
                        if (logger.isDebugEnabled())
                        {
                           logger.debug("BaseJetspeedLink: baseProfile = " + baseProfile.toString());
                        }
                        if (baseProfile.getDocument() != null)
                        {
                            if (logger.isDebugEnabled())
                            {
                                logger.debug("BaseJetspeedLink: baseProfile.getDocment() = " + baseProfile.getDocument());
                            }
                            Entry entry = baseProfile.getDocument().getEntry(elementValue);
                            if (entry != null)
                            {
                                if (logger.isDebugEnabled())
                                {
                                    logger.debug("BaseJetspeedLink: entry id = " + entry.getId());
                                }
                                elementValue = entry.getId();
                            }
                            else
                            {
                                elementValue = null;
                            }
                        }
                    }

                    break;
            }

            if (elementType != JetspeedLink.CURRENT)
            {
                // Remove Group/Role/User in URI
                uri.removePathInfo(JetspeedResources.PATH_PANEID_KEY);
                uri.removePathInfo(JetspeedResources.PATH_PANENAME_KEY);
                uri.removePathInfo(JetspeedResources.PATH_PORTLETID_KEY);
                uri.removePathInfo(JetspeedResources.PATH_PORTLET_KEY);

                if ((elementType != JetspeedLink.DEFAULT) && (elementValue != null) && (elementValue.length() > 0))
                {
                    uri.addPathInfo(uriPathElement, elementValue);
                }
            }

            // Set Template in path
            if (templateName != null)
            {
                uri.removePathInfo(JetspeedResources.PATH_TEMPLATE_KEY);
                if (templateName.length() > 0)
                {
                    uri.addPathInfo(JetspeedResources.PATH_TEMPLATE_KEY, templateName);
                }
            }

            // Set Action in path
            if (actionName != null)
            {
                uri.removeQueryData(JetspeedResources.PATH_ACTION_KEY);
                if (actionName.length() > 0)
                {
                    uri.addQueryData(JetspeedResources.PATH_ACTION_KEY, actionName);
                }
            }

            // Set MediaType in path
            if (mediaType != null)
            {
                uri.removePathInfo(Profiler.PARAM_MEDIA_TYPE);
                if (mediaType.length() > 0)
                {
                    uri.addPathInfo(Profiler.PARAM_MEDIA_TYPE, mediaType);
                }
            }

            // Set Language in path
            if (language != null)
            {
                uri.removePathInfo(Profiler.PARAM_LANGUAGE);
                if (language.length() > 0)
                {
                    uri.addPathInfo(Profiler.PARAM_LANGUAGE, language);
                }
            }

            // Set Country in path
            if (country != null)
            {
                uri.removePathInfo(Profiler.PARAM_COUNTRY);
                if (country.length() > 0)
                {
                    uri.addPathInfo(Profiler.PARAM_COUNTRY, country);
                }
            }

            return uri;
        }
View Full Code Here

     * @throws ProfileException if the profile detects an error
     * @return  URI to the root portlet/pane
     */
    private DynamicURI getRoot() throws ProfileException
    {
        DynamicURI uri = null;
        initLink();
        if (locator != null)
        {
            uri = Profiler.makeDynamicURI(rundata, locator);
        }

        if (uri == null)
        {
            uri = new DynamicURI(rundata);
        }

        // check if we need to force to a secure (https) link
        if (JetspeedResources.getBoolean("force.ssl", false))
        {
            uri.setSecure();
        }

        return uri;
    }
View Full Code Here

     * @param portletName the name of the portlet to link to
     * @return a DynamicURI referencing the named portlet for easy link construction in template
     */
    public DynamicURI setPortletByName(String portletName)
    {
        DynamicURI uri = null;
        try
        {
            uri = getRoot();
        }
        catch (Exception e)
        {
            logger.error("Exception",  e);
            return null;
        }
        if ((portletName != null) && (portletName.length() > 0))
        {
            uri.addPathInfo(JetspeedResources.PATH_PORTLET_KEY, portletName);
        }
        return uri;
    }
View Full Code Here

    private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(SendConfirmationEmail.class.getName());   
   
    public void doPerform( RunData data ) throws Exception
    {
        JetspeedUser user = JetspeedSecurity.getUser(data.getParameters().getString("username", ""));       
        DynamicURI url = new DynamicURI(data)
            .addPathInfo(JetspeedResources.PATH_TEMPLATE_KEY, "ConfirmRegistration")
            .addPathInfo("username", user.getUserName())
            .addPathInfo("secretkey", user.getConfirmed())
            .addPathInfo("password", user.getPassword());
        try
View Full Code Here

            }

            user.setHasLoggedIn( Boolean.FALSE);
            data.setUser(user);
            DynamicURI url = new DynamicURI(data);

            //build body via template
            StringWriter email_body = new StringWriter();

            Context context = TurbineVelocity.getContext(data);
View Full Code Here

        }
        catch( Exception e)
        {
            logger.error("Exception",  e);
        }
        DynamicURI uri = jsLink.getPaneById(portlet.getID());
        JetspeedLinkFactory.putInstance(jsLink);
       
        return uri;
    }
View Full Code Here

            String entryName =
                rundata.getParameters().getString(registryEntryName);

            if (entryName == null || entryName.length() == 0)
            {
                DynamicURI duri =
                    redirect(
                        rundata,
                        SecurityConstants.PARAM_MODE_INSERT,
                        SecurityConstants.MID_INVALID_ENTITY_NAME);
                rundata.setRedirectURI(duri.toString());
                resetForm(rundata);
            }
            else
            {
                //check if profile to be created already exists
                RegistryEntry existingEntry =
                    Registry.getEntry(registry, entryName);
                if (existingEntry != null)
                {
                    throw new EntityExistsException(
                        "RegistryEntry: " + entryName + " Already Exists!");
                }

                RegistryEntry registryEntry = Registry.createEntry(registry);
                registryEntry.setName(entryName);

                updateRegistryEntry(rundata, registryEntry);

                Registry.addEntry(registry, registryEntry);

                clearUserData(rundata);
            }
        }
        catch (EntityExistsException e)
        {
            //
            // dup key found - display error message - bring back to same screen
            //
            DynamicURI duri =
                redirect(
                    rundata,
                    SecurityConstants.PARAM_MODE_INSERT,
                    SecurityConstants.MID_ENTITY_ALREADY_EXISTS);
            rundata.setRedirectURI(duri.toString());
            resetForm(rundata);

            logger.error(
                this.getClass().getName()
                    + ": Trying to create duplicate entry");
        }
        catch (Exception e)
        {
            DynamicURI duri =
                redirect(
                    rundata,
                    SecurityConstants.PARAM_MODE_INSERT,
                    SecurityConstants.MID_UPDATE_FAILED);
            duri = duri.addQueryData(REASON, e.getMessage());
            rundata.setRedirectURI(duri.toString());
            resetForm(rundata);

            logger.error("Exception", e);
        }
    }
View Full Code Here

                Registry.addEntry(registry, registryEntry);
                clearUserData(rundata);
            }
            else
            {
                DynamicURI duri =
                    redirect(
                        rundata,
                        SecurityConstants.PARAM_MODE_UPDATE,
                        SecurityConstants.MID_INVALID_ENTITY_NAME);
                rundata.setRedirectURI(duri.toString());
                resetForm(rundata);

                logger.error(
                    this.getClass().getName()
                        + ": Failed to find registry entry for updating");
            }
        }
        catch (Exception e)
        {
            DynamicURI duri =
                redirect(
                    rundata,
                    SecurityConstants.PARAM_MODE_UPDATE,
                    SecurityConstants.MID_UPDATE_FAILED);
            duri = duri.addQueryData(REASON, e.getMessage());
            rundata.setRedirectURI(duri.toString());
            resetForm(rundata);

            logger.error("Exception", e);
        }
    }
View Full Code Here

            String entryName =
                rundata.getParameters().getString(registryEntryName);

            if (entryName == null || entryName.length() == 0)
            {
                DynamicURI duri =
                    redirect(
                        rundata,
                        SecurityConstants.PARAM_MODE_DELETE,
                        SecurityConstants.MID_INVALID_ENTITY_NAME);
                rundata.setRedirectURI(duri.toString());
                resetForm(rundata);

                logger.error(
                    this.getClass().getName()
                        + ": Failed to find registry entry for deleting");
            }
            else
            {
                Registry.removeEntry(registry, entryName);
                clearUserData(rundata);
            }
        }
        catch (Exception e)
        {
            DynamicURI duri =
                redirect(
                    rundata,
                    SecurityConstants.PARAM_MODE_DELETE,
                    SecurityConstants.MID_DELETE_FAILED);
            duri = duri.addQueryData(REASON, e.getMessage());
            rundata.setRedirectURI(duri.toString());
            resetForm(rundata);

            logger.error("Exception", e);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.turbine.util.DynamicURI

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.