Package org.exoplatform.portal.config.model

Examples of org.exoplatform.portal.config.model.PortalRedirect


    @Override
    protected PortalRedirect readElement(StaxNavigator<Element> navigator) {
        if (navigator.getName() != Element.PORTAL_REDIRECT) {
            throw expectedElement(navigator, Element.PORTAL_REDIRECT);
        }
        PortalRedirect redirect = new PortalRedirect();

        // redirect-site
        String redirectSite = getRequiredContent(child(navigator, Element.REDIRECT_SITE), true);
        redirect.setRedirectSite(redirectSite);

        // name
        String name = getRequiredContent(sibling(navigator, Element.NAME), true);
        redirect.setName(name);

        // enabled
        boolean enabled = parseRequiredContent(sibling(navigator, Element.REDIRECT_ENABLED), ValueType.BOOLEAN);
        redirect.setEnabled(enabled);

        // conditions and node-mapping
        boolean conditions = false;
        boolean mappings = false;
        while (navigator.sibling() != null) {
            switch (navigator.getName()) {
                case CONDITIONS:
                    if (conditions || mappings) {
                        throw unexpectedElement(navigator);
                    }
                    conditions = true;
                    redirect.setConditions((ArrayList<RedirectCondition>) conditionXmlHandler.read(navigator.fork()));
                    break;
                case NODE_MAPPING:
                    if (mappings) {
                        throw unexpectedElement(navigator);
                    }
                    mappings = true;
                    redirect.setMappings(mappingsXmlHandler.read(navigator.fork()));
                    break;
                case UNKNOWN:
                    throw unknownElement(navigator);
                default:
                    throw unexpectedElement(navigator);
View Full Code Here


                // We should not be looping over all the portal redirects to find the right one, but using something
                // like a LinkedHashMap (we need order + mapability) is awkward and more difficult to setup in xml bindings
                // and jcr configuration.
                // NOTE: should be a minor issue, there should only ever really be 2-3 redirects for any portal configuration so
                // looping over all of them should not be a big problem. But its still a bad design which should be fixed.
                PortalRedirect pRedirect = null;
                for (PortalRedirect portalRedirect : pConfig.getPortalRedirects()) {
                    if (portalRedirect.getRedirectSite().equals(redirect)) {
                        pRedirect = portalRedirect;
                        break;
                    }
                }

                if (pRedirect != null) {
                    String redirectPath = mapper.getRedirectPath(origin, redirect, originRequestPath, pRedirect.getMappings());
                    if (redirectPath != null) {
                        if (redirectPath.startsWith("/")) {
                            return redirectPath;
                        } else {
                            return "/" + redirectPath;
View Full Code Here

        redirectName = params.get("rname");
    }

    public void addRedirect(String site) {
        this.siteName = site;
        this.pr = new PortalRedirect();
        this.pr.setName(site + "_" + Long.toHexString(System.currentTimeMillis()));
        this.originalName = pr.getName();
        this.pr.setConditions(new ArrayList<RedirectCondition>());
        RedirectMappings rm = new RedirectMappings();
        rm.setMappings(new ArrayList<NodeMap>());
View Full Code Here

                // We should not be looping over all the portal redirects to find the right one, but using something
                // like a LinkedHashMap (we need order + mapability) is awkward and more difficult to setup in xml bindings
                // and jcr configuration.
                // NOTE: should be a minor issue, there should only ever really be 2-3 redirects for any portal configuration so
                // looping over all of them should not be a big problem. But its still a bad design which should be fixed.
                PortalRedirect pRedirect = null;
                for (PortalRedirect portalRedirect : pConfig.getPortalRedirects()) {
                    if (portalRedirect.getRedirectSite().equals(redirect)) {
                        pRedirect = portalRedirect;
                        break;
                    }
                }

                if (pRedirect != null) {
                    String redirectPath = mapper.getRedirectPath(origin, redirect, originRequestPath, pRedirect.getMappings());
                    if (redirectPath != null && redirectPath.equals("/")) {
                        return "";
                    } else {
                        return redirectPath;
                    }
View Full Code Here

TOP

Related Classes of org.exoplatform.portal.config.model.PortalRedirect

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.