Package azkaban.util.json

Examples of azkaban.util.json.JSONUtils


*/
public class JSONUtilTest {
    @SuppressWarnings("unchecked")
  @Test
    public void objectFromString() throws Exception {
      JSONUtils utils = new JSONUtils();
     
      String jsonTest = "{\"test\":[1,2,\"tree\"], \"test2\":{\"a\":\"b\"}, \"test4\":\"bye\"}";
      Object obj = null;
      try {
        obj = utils.fromJSONString(jsonTest);
      }
      catch (Exception e) {
        e.printStackTrace();
        throw e;
      }
View Full Code Here


    }
   
    @SuppressWarnings("unchecked")
  @Test
    public void objectFromStream() throws Exception {
      JSONUtils utils = new JSONUtils();
     
      String jsonTest = "{\"test\":[1,2,\"tree\"], \"test2\":{\"a\":\"b\"}, \"test4\":\"bye\"}";
      StringReader reader = new StringReader(jsonTest);
      Object obj = null;
      try {
        obj = utils.fromJSONStream(reader);
      }
      catch (Exception e) {
        e.printStackTrace();
        throw e;
      }
View Full Code Here

    }
   
    @SuppressWarnings("unchecked")
  @Test
    public void backAndForth() throws Exception {
      JSONUtils utils = new JSONUtils();
     
      String jsonTest = "{\"test\":[1,2,\"tree\"], \"test2\":{\"a\":\"b\"}, \"test4\":\"bye\"}";
      Map oldObj = null;
      try {
        oldObj = utils.fromJSONString(jsonTest);
      }
      catch (Exception e) {
        e.printStackTrace();
        throw e;
      }
      System.out.println(oldObj);
      String returnString = utils.toJSONString(oldObj);
      System.out.println(returnString);
      Map obj = null;
      try {
        obj = utils.fromJSONString(returnString);
      }
      catch (Exception e) {
        e.printStackTrace();
        throw e;
      }
View Full Code Here

          // Disable all proper values
          ExecutableFlow executableFlow = holder.getFlow();
          traverseFlow(disabledJobs, executableFlow);
         
        PrintWriter writer = resp.getWriter();
        JSONUtils jsonUtils = new JSONUtils();
        HashMap<String,Object> results = new HashMap<String,Object>();
       
          try {
            this.getApplication().getJobExecutorManager().execute(holder);
            results.put("id", holder.getFlow().getId());
            results.put("success", true);
            results.put("message", String.format("Executing Flow[%s].", id));
          } catch(Exception e) {
            results.put("id", holder.getFlow().getId());
            results.put("error", true);
            results.put("message", String.format("Error running Flow[%s]. " + e.getMessage(), id));
          }
         
          writer.print(jsonUtils.toJSONString(results));
          writer.flush();
        }
        else if (action.equals("run")) {
          String name = getParam(req, "name");
          String value = req.getParameter("disabled");
          String[] disabledValues = value.split(",");
          HashSet<String> disabledJobs = new HashSet<String>();
          for (String disabled : disabledValues) {
            if (!disabled.isEmpty()) {
              disabledJobs.add(disabled);
            }
          }
         
             ExecutableFlow flow = allFlows.createNewExecutableFlow(name);
             if (flow == null) {
            addError(req, "Job " + name + " not found.");
             }
             traverseFlow(disabledJobs, flow);
        PrintWriter writer = resp.getWriter();
        JSONUtils jsonUtils = new JSONUtils();
        HashMap<String,Object> results = new HashMap<String,Object>();
       
          try {
            this.getApplication().getJobExecutorManager().execute(flow);
            results.put("success", true);
            results.put("message", String.format("Executing Flow[%s].", name));
            results.put("id", flow.getId());
             
          } catch(Exception e) {
            results.put("error", true);
            results.put("message", String.format("Error running Flow[%s]. " + e.getMessage(), name));
          }
         
          writer.print(jsonUtils.toJSONString(results));
          writer.flush();
        }
       
      
    }
View Full Code Here

TOP

Related Classes of azkaban.util.json.JSONUtils

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.