Package com.ibm.commons.util.io.json

Examples of com.ibm.commons.util.io.json.JsonReference


    return jsonEndpoints;
  }
 
  private JsonReference addMakeAbsoluteUrl(String url){
    StringBuilder sb = new StringBuilder("util.makeAbsoluteUrl('").append(url).append("')");
    return new JsonReference(sb.toString());
  }
View Full Code Here


     
      jsonEndpoint.putJsonProperty(PROP_SERVICE_MAPPINGS, endpoint.getServiceMappings());

      // configure endpoint to use proxy
      if (endpoint.isUseProxy()) {
        JsonReference proxyRef = createProxyRef(request, endpoint, endpointName);
        if (proxyRef != null) {
          jsonEndpoint.putJsonProperty(PROP_PROXY, proxyRef);
          String moduleName = getProxy(request, endpoint, endpointName).getModuleName();
          jsonEndpoint.putJsonProperty(PROP_MODULE_PROXY, moduleName);
        }
        String proxyPath = endpoint.getProxyPath(endpointName);
        if (!StringUtil.isEmpty(proxyPath)) {
          jsonEndpoint.putJsonProperty(PROP_PROXY_PATH, proxyPath);
        }
      }

      // configure endpoint to use authenticator
      JsonReference authenticatorRef = createAuthenticatorRef(request, endpoint, endpointName);
      if (authenticatorRef != null) {
        jsonEndpoint.putJsonProperty(PROP_AUTHENTICATOR, authenticatorRef);
        String moduleName = endpoint.getAuthenticator(endpointName, request.getToolkitJsUrl()).getModuleName();
        jsonEndpoint.putJsonProperty(PROP_MODULE_AUTHENTICATOR, moduleName);
      }

      // configure the transport
      JsonReference transportRef = createTransportRef(request, endpoint, endpointName);
      if (transportRef != null) {
        jsonEndpoint.putJsonProperty(PROP_TRANSPORT, transportRef);
        String moduleName = getTransport(request, endpoint, endpointName).getModuleName();
        jsonEndpoint.putJsonProperty(PROP_MODULE_TRANSPORT, moduleName);
      }

      // configure the authentication
      jsonEndpoint.putJsonProperty(PROP_AUTH_TYPE, AuthUtil.INSTANCE.getAuthValue(endpoint));
      if (endpoint.getLoginPage() != null) {
        jsonEndpoint.putJsonProperty(PROP_LOGIN_PAGE, endpoint.getLoginPage());
      }
      if (endpoint.getDialogLoginPage() != null) {
        jsonEndpoint.putJsonProperty(PROP_LOGIN_DIALOG_PAGE, endpoint.getDialogLoginPage());
      }
      if (endpoint.getLoginUi() != null) {
        jsonEndpoint.putJsonProperty(PROP_LOGIN_UI, endpoint.getLoginUi());
      }
      if (endpoint.getAutoAuthenticate() != null) {
        jsonEndpoint.putJsonProperty(PROP_AUTO_AUTHENTICATE, endpoint.getAutoAuthenticate());
      }
      if (endpoint.getPlatform() != null) {
        jsonEndpoint.putJsonProperty(PROP_PLATFORM, endpoint.getPlatform());
      }
      jsonEndpoint.putJsonProperty(PROP_AUTHENTICATION_ERROR_CODE,
          endpoint.getAuthenticationErrorCode());
     
      // configure client properties
      Map<String, Object> params = endpoint.getClientParams();
      Iterator<String> keys = params.keySet().iterator();
      while(keys.hasNext()) {
        String key = keys.next();
        Object value = params.get(key);
        jsonEndpoint.putJsonProperty(key, value);
      }

    } else {
      // set the endpoint url
      jsonEndpoint.putJsonProperty(PROP_INVALID, "true");

      // configure a error transport
      String message = getInvalidEndpointMessage(request, endpoint, endpointName);
      jsonEndpoint.putJsonProperty(PROP_TRANSPORT, new JsonReference("new ErrorTransport('"
          + endpointName + "','" + message + "')"));
    }

    if (logger.isLoggable(Level.FINEST)) {
      logger.exiting(sourceClass, "createJsonForEndpoint", jsonEndpoint);
View Full Code Here

          if (keys.hasNext()) {
            sb.append(",");
          }
        }
        sb.append("})");
        return new JsonReference(sb.toString());
      } catch (Exception e) {
        throw new LibraryException(e);
      }
    }
    return null;
View Full Code Here

    if (transport != null) {
      try {
        String paramValues = JsonGenerator.toJson(JsonJavaFactory.instanceEx,
            transport.getProperties());
        String paramName = getModuleParamName(transport.getModuleName());
        return new JsonReference("new " + paramName + "(" + paramValues + ")");
      } catch (Exception e) {
        throw new LibraryException(e);
      }
    }
    return null;
View Full Code Here

          // Url is relative, append server to it
          proxyUrl = UrlUtil.makeUrlAbsolute(request.getHttpRequest(),proxyUrl);
        }
        proxyUrl = addMakeAbsoluteUrl(proxyUrl).getRef();
        String proxyClass = proxy.getProxyModule();
        return new JsonReference("new "+proxyClass+"({proxyUrl:" + proxyUrl + "})");
      } catch (ProxyConfigException e) {
        if (logger.isLoggable(Level.SEVERE)) {
          logger.entering(sourceClass, "createProxyRef failed", e.getMessage());
        }
      }
     
    }
   
    // define the proxy URL
    if (endpoint.isUseProxy()) {
      String proxyUrl = PathUtil.concat(request.getServiceUrl(), endpoint.getProxyHandlerPath(), '/');
      proxyUrl = addMakeAbsoluteUrl(proxyUrl).getRef();
      return new JsonReference("new Proxy({proxyUrl:" + proxyUrl + "})");
    }
    return null;
  }
View Full Code Here

TOP

Related Classes of com.ibm.commons.util.io.json.JsonReference

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.