Package org.jcoredb.service.http.output

Examples of org.jcoredb.service.http.output.JSONNode


   
    try
    {
      Block block = fs.read(blockId);
     
      JSONNode root = JSONHelper.createSuccessNode();
      JSONAttribute containerId = new JSONAttribute("containerId", ""+blockId.getContainerId(), AttrType.Number);
      JSONAttribute segmentId = new JSONAttribute("segmentId", ""+blockId.getSegmentId(), AttrType.Number);
      JSONAttribute id = new JSONAttribute("blockId", ""+blockId.getId(), AttrType.Number);
      JSONAttribute data = new JSONAttribute("data", Base64.encodeBase64String(block.getBytes()),AttrType.String);
      root.add(containerId);
      root.add(segmentId);
      root.add(id);
      root.add(data);
     
      out.println(root.toJSONString());
    }
    catch (Exception e) {

      out.println(JSONHelper.createErrorNode(e));
    }
View Full Code Here


 
    IFileSystem fs = FileSystemRegistry.get(new FileSystemRegKey(Constants.HOST, Configs.getFSConfig().getRootDir()));
   
    IContainer[] cs = fs.getContainers();
       
    JSONNode root = new JSONNode();
   
    JSONAttribute path = new JSONAttribute("path", fs.getPath(), AttrType.String);
   
    root.add(path);
   
    JSONArray childs = new JSONArray("containers");
   
    for (int i = 0; i < cs.length; i++)
    {
       IContainer c = cs[i];
      
       JSONNode child = new JSONNode();
       JSONAttribute id = new JSONAttribute("id", ""+c.getId(), AttrType.Number);
       child.add(id);
      
       childs.add(child);
    }
   
    root.add(childs);
View Full Code Here

public class JSONOutputTest {

  @Test
  public void test() {
   
    JSONNode node = new JSONNode();
    assertEquals("{}", node.toJSONString());
   
    node.add(new JSONAttribute("id", "0", AttrType.Number));
    node.add(new JSONAttribute("name", "root object", AttrType.String));

   
    JSONArray array = new JSONArray("childs");
   
    for (int i = 0; i < 10; i++) {

      JSONNode node1 = new JSONNode();
     
      node1.add(new JSONAttribute("id", "" + i, AttrType.Number));
      node1.add(new JSONAttribute("name","child node " + i, AttrType.String));
      node1.add(new JSONAttribute("created","01.01.1970", AttrType.Date));
      array.add(node1);
     
    }
       
    node.add(array);
View Full Code Here

    IContainer c = fs.getContainer(id);
   
    if (c!=null)
    {
   
      JSONNode root = JSONHelper.createSuccessNode();
      JSONAttribute id = new JSONAttribute("id", ""+c.getId(), AttrType.Number);
      JSONAttribute parentpath = new JSONAttribute("parentpath", c.getParentPath(), AttrType.String);
      JSONAttribute numberofsegs = new JSONAttribute("numberofsegs", ""+c.getNumOfSegs(), AttrType.Number);
     
      root.add(id);
      root.add(parentpath);
      root.add(numberofsegs);
     
      JSONArray segments = new JSONArray("segments");
     
      for (int i = 0; i < c.getSegments().length; i++)
      {
         ISegment s = c.getSegments()[i];

         JSONNode segementNode = new JSONNode();
         JSONAttribute segId = new JSONAttribute("id", ""+s.getId(), AttrType.Number);
         segementNode.add(segId);
        
         segments.add(segementNode);
     
     
      root.add(segments);
View Full Code Here

   
    try
    {
      blockId = fs.append(block, only);
     
      JSONNode root = JSONHelper.createSuccessNode();
      JSONAttribute containerId = new JSONAttribute("containerId", ""+blockId.getContainerId(), AttrType.Number);
      JSONAttribute segmentId = new JSONAttribute("segmentId", ""+blockId.getSegmentId(), AttrType.Number);
      JSONAttribute id = new JSONAttribute("blockId", ""+blockId.getId(), AttrType.Number);
      root.add(containerId);
      root.add(segmentId);
      root.add(id);
     
      out.println(root.toJSONString());
    }
    catch (Exception e) {
     
      out.println(JSONHelper.createErrorNode(e));
    }
View Full Code Here

TOP

Related Classes of org.jcoredb.service.http.output.JSONNode

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.