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

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


    // Communities
    //
    protected void writeCommunitiesConfig(FacesContext context, UIViewRootEx2 rootEx, UISbtClient ctClient, Endpoint ctServer, String endpointName) throws IOException {
        try {
            // Create the configuration object and the corresponding script
            JsonObject semConfig = createCommunitiesSemConfig(context, ctClient, ctServer, endpointName);
            StringBuilder b = new StringBuilder(256);
            b.append("var SemTagSvcConfig=");
            JsonGenerator.toJson(JsonJavaFactory.instance,b,semConfig,true);
            b.append(";\n");
            String onInitSvcConfig = ctClient.getInitSvcConfigScript();
View Full Code Here


            throw new FacesExceptionEx(ex);
        }
    }
    protected JsonObject createCommunitiesSemConfig(FacesContext context, UISbtClient ctClient, Endpoint ctServer, String endpointName) throws IOException {
        // Get the proxy object in memory
        JsonObject proxyConfig = new JsonJavaObject();
        String baseUrl = PathUtil.concat(ctServer.getUrl(),"communities",'/');
        proxyConfig.putJsonProperty("baseUrl", baseUrl);
        String proxyUrl = getProxyUrl(context, ctClient, ctServer, endpointName); //PathUtil.concat(ctServer.getUrl(),"communities",'/');
        if(StringUtil.isNotEmpty(proxyUrl)) {
            proxyConfig.putJsonProperty("proxyURL", proxyUrl);
        }
        proxyConfig.putJsonProperty("loadCssFiles", ctClient.isLoadCSS());
        return proxyConfig;
    }
View Full Code Here

   
        writeJSSDK(context, component, bean);
    }
 
  protected JsonObject createJSONConfig(OAuthEndpoint bean) throws IOException {
    JsonObject config = new JsonJavaObject();
        try {
            String appId = bean.getConsumerKey();
            config.putJsonProperty("appId", appId);
        } catch (Exception e) {
          IOException ioe = new IOException("Error while accessing the consumer key");
          ioe.initCause(e);
            throw ioe;
        }          
        //http://xxxx/xsp/.ibmxspres/.extlib/sbt/facebook/channel.html
        // Note that the URL must be absolute
        String htmlResource = FacesContext.getCurrentInstance().getExternalContext().encodeResourceURL(SBTResources.FACEBOOK_CHANNEL_HTML);
        String channelURL = FacesUtil.makeUrlAbsolute(FacesContext.getCurrentInstance(), htmlResource);
        config.putJsonProperty("channelURL", channelURL);
       
        // Should we make these client parameters?
    config.putJsonProperty("status", true);
    config.putJsonProperty("cookie", true);
    config.putJsonProperty("xfbml", true);
    // This currently fails
        //config.putJsonProperty("oauth", true);
       
    return config;
  }
View Full Code Here

 
            writer.write("\n");
          writer.startElement("script", component);
          writer.writeAttribute("type", "text/javascript", null);
 
          JsonObject config = createJSONConfig(bean);
          StringBuilder b = new StringBuilder(256);
           
          try {
            JsonGenerator.toJson(JsonJavaFactory.instance,b,config,true);
          }
View Full Code Here

   
    protected void writeProxyConfig(FacesContext context, UIViewRootEx2 rootEx, UISametimeClient stClient, Endpoint stServer, String linkurl) throws IOException {
        // Generate the proxy configuration
        try {
            // Create the proxy object and the corresponding script
            JsonObject proxyConfig = createProxyConfig(context, stClient, stServer, linkurl);
            StringBuilder b = new StringBuilder(256);
            // Sametime FIXME: djConfig!
            b.append("var djConfig = { parseOnLoad: true, isDebug: false };\n" );
            b.append("var stproxyConfig=");
            JsonGenerator.toJson(JsonJavaFactory.instance,b,proxyConfig,true);
View Full Code Here

   
   
   
    protected JsonObject createProxyConfig(FacesContext context, UISametimeClient stClient, Endpoint stServer, String linkurl) throws IOException {
        // Get the proxy object in memory
        JsonObject proxyConfig = new JsonJavaObject();
        proxyConfig.putJsonProperty("server", stServer.getUrl());
        boolean autoTunnel = stClient.isAutoTunnelURI();
        if(autoTunnel) {
            //http://xxxx/xsp/.ibmxspres/.extlib/sbt/sametime/tunnel.html
            // Note that the URL must be absolute
            String htmlResource = FacesContext.getCurrentInstance().getExternalContext().encodeResourceURL(SBTResources.SAMETIME_TUNNEL_HTML);
            String tunnelURI = FacesUtil.makeUrlAbsolute(FacesContext.getCurrentInstance(), htmlResource);
            proxyConfig.putJsonProperty("tunnelURI", tunnelURI);
        }
       
        boolean connectClient = stClient.isConnectClient();
        if(connectClient) {
            proxyConfig.putJsonProperty("isConnectClient", connectClient);
        }
        return proxyConfig;
    }
View Full Code Here

            Object obj = JsonParser.fromJson(JsonJavaFactory.instanceEx, getPostBody(request));
            List<JsonObject> emails = new ArrayList<JsonObject>();
            if(obj instanceof List){
                emails = (List<JsonObject>)obj;
            } else if (obj instanceof JsonObject) {
                JsonObject postBody = (JsonObject)obj;
                emails.add(postBody);
            } else {
                response.sendError(HttpServletResponse.SC_BAD_REQUEST,
                        "Mailer API expects either an array of JSON objects or a single JSON object");
                return;
            }
            JsonObject jsonResponse = send(emails);
            response.setStatus(HttpServletResponse.SC_OK);
            response.setContentType(APPLICATION_JSON);
            writer.write(jsonResponse.toString());
        } catch (Exception e) {
            response.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
            return;
        } finally {
            writer.flush();
View Full Code Here

                }
            } catch (MimeEmailException e) {
                error.add(createErrorResponse(json, e.getMessage()));
            }
        }
        JsonObject response = new JsonJavaObject();
        response.putJsonProperty("successful", successful);
        response.putJsonProperty("error", error);
        return response;
    }
View Full Code Here

     * @param email The JSON representing the email.
     * @param errorMessage The error message describing what went wrong.
     * @return An error JSON object.
     */
    private JsonObject createErrorResponse(JsonObject email, String errorMessage) {
        JsonObject error = new JsonJavaObject();
        error.putJsonProperty("message", errorMessage);
        error.putJsonProperty("email", email);
        return error;
    }
View Full Code Here

   */
  public String generateJavaScript(LibraryRequest request) throws LibraryException {
    try {
      // populate list of endpoint/properties
      Map<String, JsonObject> endpoints = populateEndpoints(request);
      JsonObject properties = populateProperties(request);
      minify = !request.isDebug();
      nl = minify ? "" : NL;

      // concrete library generates the script
      return generateJavaScript(request, endpoints, properties);
View Full Code Here

TOP

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

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.