Package org.damour.base.client.utils

Examples of org.damour.base.client.utils.ParameterParser


public class PermaLinkBuilder {

  public static String getLink(PermissibleObject permissibleObject, List<String> ignoredParameters) {
    // build a hashmap of pathInfo parameters, query parameters and history token parameters
    ParameterParser pathParameters = new ParameterParser(ParameterParser.convertRESTtoQueryString(Window.Location.getPath()));
    ParameterParser queryStringParameters = new ParameterParser(Window.Location.getQueryString());
    ParameterParser historyParameters = new ParameterParser(History.getToken());

    List<String> parameterOrder = new ArrayList<String>(historyParameters.getOrderedParameterNames());
    if (StringUtils.isEmpty(History.getToken())) {
      for (String queryStringParam : queryStringParameters.getOrderedParameterNames()) {
        if (!parameterOrder.contains(queryStringParam)) {
          parameterOrder.add(queryStringParam);
        }
      }
      for (String pathParam : pathParameters.getOrderedParameterNames()) {
        if (!parameterOrder.contains(pathParam)) {
          parameterOrder.add(pathParam);
        }
      }
    }
    String permaLinkStr = Window.Location.getProtocol() + "//" + Window.Location.getHostName()
        + ((Window.Location.getPort().equals("80") || Window.Location.getPort().equals("")) ? "" : ":" + Window.Location.getPort());
    for (String parameterName : parameterOrder) {
      if (ignoredParameters != null && ignoredParameters.contains(parameterName)) {
        // skip ignored parameters
        continue;
      }
      if ("name".equalsIgnoreCase(parameterName) && permissibleObject != null && !StringUtils.isEmpty(permissibleObject.getName())) {
        // skip the name parameter until later
        continue;
      }
      if (!StringUtils.isEmpty(historyParameters.getParameter(parameterName))) {
        permaLinkStr += "/" + parameterName + "/" + historyParameters.getParameter(parameterName);
      } else if (!StringUtils.isEmpty(queryStringParameters.getParameter(parameterName))) {
        permaLinkStr += "/" + parameterName + "/" + queryStringParameters.getParameter(parameterName);
      } else if (!StringUtils.isEmpty(pathParameters.getParameter(parameterName))) {
        permaLinkStr += "/" + parameterName + "/" + pathParameters.getParameter(parameterName);
      }
View Full Code Here


        for (Referral referral : referrals) {
          int col = 0;

          String query = "";
          try {
            ParameterParser parser = new ParameterParser(referral.getReferralURL().substring(referral.getReferralURL().indexOf("?")));
            query = URL.decodeQueryString(parser.getParameter("q"));
          } catch (Throwable t) {
          }

         
          String referralUrl = referral.getReferralURL();
View Full Code Here

TOP

Related Classes of org.damour.base.client.utils.ParameterParser

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.