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

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


            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

   
   
   
    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

                Map<String,String> parameters = getParameters(index, blockSize);
                //String text = (String)svc.get(parameters, ClientService.FORMAT_TEXT);
                //IValue collection = (IValue)JsonParser.fromJson(JSJson.factory,text);
                Object[] data = null;
                HandlerJson json= new HandlerJson();
                JsonJavaObject result = (JsonJavaObject)svc.get(getServiceUrl(),parameters,json).getData();
                if(result!=null) {
                    if(StringUtil.isNotEmpty(splitPath)) {
                        JsonNavigator nav = new JsonNavigator(result);
                        List<Object> nodes = nav.nodes(splitPath);
                        if(nodes!=null) {
View Full Code Here

    /*
     * Merges template with data
     */
    private JsonJavaObject mergeData(String template, Properties properties) throws JsonException, IOException{
        String filledTemplate = ParameterProcessor.process(template, properties);
        JsonJavaObject templateObj = (JsonJavaObject)JsonParser.fromJson(JsonJavaFactory.instanceEx, filledTemplate);
       
        return templateObj;
    }
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

  @Override
  public void service(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
    String pathInfo = request.getPathInfo();
      Endpoint endpoint = EndpointFactory.getEndpoint(getEndpointName(pathInfo))//remove hardcoded name ..get second token from path info
      PrintWriter writer = new PrintWriter(new OutputStreamWriter(response.getOutputStream(), "utf-8"));
    JsonObject jsonResponse = new JsonJavaObject();
      if(getAuthAction(pathInfo).equals(LOG_OUT)){
        boolean logoutSuccessful = true;
        try {
        endpoint.logout();
      } catch (AuthenticationException e) {
        logoutSuccessful = false;
      }
      try {
        if(endpoint.isAuthenticated()){
          logoutSuccessful = false;
        }
      } catch (ClientServicesException e) {
        logoutSuccessful = false;
      }
      if(logoutSuccessful){
        jsonResponse.putJsonProperty("success", true);
        jsonResponse.putJsonProperty("status", 200);
      }else{
        jsonResponse.putJsonProperty("success", false);
        jsonResponse.putJsonProperty("status", 500);
      }
      }
      if(getAuthAction(pathInfo).equals(IS_AUTHENTICATED)){
        try {
          jsonResponse.putJsonProperty("result", endpoint.isAuthenticated());
          jsonResponse.putJsonProperty("status", 200);
        } catch (ClientServicesException e) {
          jsonResponse.putJsonProperty("result", false);
          jsonResponse.putJsonProperty("status", 500);
        }
      }
      if(getAuthAction(pathInfo).equals(IS_AUTHENTICATION_VALID)){
      try {
        jsonResponse.putJsonProperty("result", endpoint.isAuthenticationValid());
        jsonResponse.putJsonProperty("status", 200);
      } catch (ClientServicesException e) {
        jsonResponse.putJsonProperty("result", false);
        jsonResponse.putJsonProperty("status", 500);
      }
  }
        response.setContentType(APPLICATION_JSON);
        writer.write(jsonResponse.toString());
      writer.flush();
  }
View Full Code Here

    this.entitiesPath = entitiesPath;
  }
 
  @Override
  public T createEntity(Response dataHolder) {
    JsonJavaObject data = (JsonJavaObject)dataHolder.getData();
    return createEntityFromData(data);
  }
View Full Code Here

      Assert.assertNotNull("Unable to retrieve subscription: "+subscriptionId, jsonEntity);
      System.out.println(jsonEntity.toJsonString());
     
      Assert.assertEquals(subscriptionId, subscriptionManagement.getSubscriptionId(jsonEntity.getJsonObject()));

      JsonJavaObject rootObject = jsonEntity.getJsonObject();
      Assert.assertNotNull("Unable to retrieve subscription: "+subscriptionId, rootObject);
     
      subscriptionManagement.suspendSubscription(subscriptionId);
     
      jsonEntity = subscriptionManagement.getSubscriptionById(subscriptionId);
      Assert.assertNotNull("Unable to retrieve subscription: "+subscriptionId, jsonEntity);
      Assert.assertEquals(subscriptionId, subscriptionManagement.getSubscriptionId(jsonEntity.getJsonObject()));
     
      rootObject = jsonEntity.getJsonObject();
      Assert.assertNotNull("Unable to retrieve subscription: "+subscriptionId, rootObject);
     
      System.out.println(rootObject);
      JsonJavaObject subscriptionObject = rootObject.getAsObject("Subscription");
      System.out.println(subscriptionObject);
      Assert.assertEquals("SUSPENDED", subscriptionObject.get("SubscriptionState"));
     
      } catch (BssException be) {
        JsonJavaObject jsonObject = be.getResponseJson();
        System.out.println(jsonObject);
        Assert.fail("Error suspending customer caused by: "+jsonObject);
      } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("Error suspending customer caused by: "+e.getMessage());       
View Full Code Here

TOP

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

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.