Package de.innovationgate.utils

Examples of de.innovationgate.utils.URLBuilder


                // normal db request
                String requestedDBKey = pathElements[1];
                if (vHost.isHideDefaultDatabaseInURL() && defaultDBKey != null) {
                    if (requestedDBKey.equalsIgnoreCase(defaultDBKey)) {
                        // if default db requested redirect to url without dbkey
                        URLBuilder builder = new URLBuilder(httpRequest, _core.getCharacterEncoding());
                        String path = builder.getPath().substring(httpRequest.getContextPath().length());                                      
                        builder.setPath(httpRequest.getContextPath() + path.substring(defaultDBKey.length() + 1));
                        httpResponse.sendRedirect(builder.rebuild().toString());
                        return;
                    }
                   
                    // we have to check if requestedDBKey is a valid content database - if not we use defaultDatabase
                    if (!_core.getContentdbs().containsKey(requestedDBKey.toLowerCase())) {
View Full Code Here


        @Override
        public StringBuffer getRequestURL() {
            StringBuffer url = super.getRequestURL();          
            try {
                URLBuilder builder = new URLBuilder(new URL(url.toString()));
                String path = builder.getPath().substring(_request.getContextPath().length());
                builder.setPath(_request.getContextPath() + "/" + _dbkey + path);
                return new StringBuffer(builder.rebuild().toString());
            } catch (Exception e) {
                _core.getLog().error("Unable to compute request url.", e);
            }      
            return url;
        }
View Full Code Here

                      setResult("");
                      return;
                    }
                }
                else {
                    URLBuilder requestURL = new URLBuilder(request);
                    param = new String[] {requestURL.getParameter(getName())};
                }
               
                if (param.length == 1) {
                  this.setResult(param[0]);
                }
View Full Code Here

            status.setOption(OPTION_PORTLET_TMLMODULE, pReg.getDesign(), null);
                               
            // create ajaxInfo
            AjaxInfo ajaxInfo = new AjaxInfo(uniquePortletID);
            try {
        URLBuilder builder = new URLBuilder(getTMLContext().getrequest());
        builder.removeParameter("$action");
        java.net.URL url = builder.rebuild();
        ajaxInfo.setQueryString(url.getQuery());
      } catch (Exception e1) {
        getTMLContext().addwarning("Unable to build request querystring for ajax environment.");
      }
            ajaxInfo.setTmlmodule(pReg.getDesign());
View Full Code Here

        }
       
        // Outside we use a simple action link
        else {
            try {
                URLBuilder builder = new URLBuilder(new java.net.URL(tag.getRequestURL()));
                builder.setParameterEncoding(context.getwgacore().getCharacterEncoding());
                builder.setParameter("$action", encodedActionLink);
                return builder.rebuild(false);
            }
            catch (MalformedURLException exc) {
                context.getlog().error("Error building action URL", exc);
                return null;
            }
View Full Code Here

       
        VirtualHost vHost = WGAVirtualHostingFilter.findMatchingHost(core.getWgaConfiguration(), request);
        if (vHost == null) {
            return url;
        } else {
            URLBuilder builder = parseURL(core, request, url);
            if (builder != null) {
                String path = builder.getPath().substring(request.getContextPath().length());
                if (path.startsWith("/")) {
                    path = path.substring(1);
                }
                if (path.indexOf("/") != -1) {
                    String targetDBKey = path.substring(0, path.indexOf("/"));
                   
                    // skip vhosts processing for plugins
                    if (targetDBKey.startsWith("plugin-")) {
                        return url;
                    }
                   
                    // first check if default database is requested and if we have to hide it from url
                    if (vHost.isHideDefaultDatabaseInURL() && vHost.getDefaultDatabase() != null) {
                        String defaultDBKey = WGAVirtualHostingFilter.getDefaultDBKey(core, vHost);
                        if (defaultDBKey != null && targetDBKey.equalsIgnoreCase(defaultDBKey)) {
                            // default db requested - remove from path
                            builder.setPath(path.substring(defaultDBKey.length()));
                            try {
                                return builder.rebuild(false).toString();
                            }
                            catch (UnsupportedEncodingException e) {
                                core.getLog().error("Unable to rewrite url '" + url + "'.");
                            }
                        }
                    }
                   
                    if (!WGAVirtualHostingFilter.isDBKeyAllowed(core.getWgaConfiguration(), vHost, targetDBKey)) {                     
                        // we have to find the best matching host for this db and create an absolute url here                       
                        VirtualHost preferredHost = WGAVirtualHostingFilter.findPreferredHostForDatabase(core.getWgaConfiguration(), targetDBKey);
                        if (preferredHost != null) {
                            builder.setHost(preferredHost.getServername());
                            if (preferredHost.isHideDefaultDatabaseInURL() && preferredHost.getDefaultDatabase() != null) {
                                String defaultDBKey = WGAVirtualHostingFilter.getDefaultDBKey(core, preferredHost);
                                if (defaultDBKey != null && targetDBKey.equalsIgnoreCase(defaultDBKey)) {
                                 // default db requested - remove from path
                                    builder.setPath(path.substring(defaultDBKey.length()));
                                }
                            }
                            try {
                                return builder.rebuild(true).toString();
                            }
                            catch (UnsupportedEncodingException e) {
                                core.getLog().error("Unable to rewrite url '" + url + "'.");
                            }
                        }
View Full Code Here

        }       
        return url;
    }

    private URLBuilder parseURL(WGACore core, HttpServletRequest request, String url) {
        URLBuilder builder = null;
        try {
            if (url.contains("://")) {
                builder = new URLBuilder(new URL(url));
            } else {
                URL urlObj = new URL(request.getRequestURL().toString());
                String path = null;
                String query = null;
                if (url.contains("?")) {
                    String[] tokens = url.split("\\?");
                    path = tokens[0];
                    query = tokens[1];
                } else {
                    path = url;
                }
                builder = new URLBuilder(urlObj.getProtocol(), urlObj.getPort(), urlObj.getHost(), path, null);
                if (query != null) {
                    builder.addQueryString(query, core.getCharacterEncoding());
                }
            }
        }
        catch (Exception e) {
            core.getLog().error("URLBuilder creating failed for url '" + url + "'.", e);
View Full Code Here

       
    HttpServletRequest request = context.getrequest();
    WGPRequestPath path = (WGPRequestPath) request.getAttribute(WGACore.ATTRIB_REQUESTPATH);

    try {
            URLBuilder urlBuilder = new URLBuilder(null, 0, null, langContext.contenturl(path.getMediaKey(), path.getLayoutKey()), context.getrequest().getQueryString());
            if (urlBuilder.hasParameter("$action")) {
                urlBuilder.removeParameter("$action");
            }
           
      context.redirectto(urlBuilder.rebuild(false));
    }
    catch (IOException e) {
      throw new TMLException("Error redirecting to new language", e, true);
    }
        catch (WGAPIException e) {
View Full Code Here

TOP

Related Classes of de.innovationgate.utils.URLBuilder

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.