Skip to content

Instantly share code, notes, and snippets.

@bsenduran
Last active August 29, 2015 14:15

Revisions

  1. bsenduran revised this gist Mar 5, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion registry_resource_content.js
    Original file line number Diff line number Diff line change
    @@ -37,7 +37,7 @@ try {
    }
    };
    resource = {
    content: stringify(reg_initial_js)
    content: JSON.stringify(reg_initial_js)
    };
    dataStore.put(path, resource);
    }
  2. bsenduran renamed this gist Feb 10, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. bsenduran created this gist Feb 10, 2015.
    50 changes: 50 additions & 0 deletions registry_resource_content
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    <%
    var carbon = require('carbon');
    var server = new carbon.server.Server();
    var options = {system: true, domain: carbon.server.tenantDomain() , tenantId: carbon.server.tenantId()};
    var dataStore = new carbon.registry.Registry(server, options);
    var res;
    var mycontent;
    var path = "/_system/governance/sen/hello";
    try {
    res = dataStore.get(path);
    mycontent = res.content;
    var log = new Log();
    mycontent = JSON.parse(mycontent);
    log.info(mycontent);
    log.info(mycontent.a);
    print(typeof mycontent);
    mycontent["c"] = {c1:"1", c2:"2"};
    mycontent["d"] = {d1:"1", d2:"2"};
    //delete mycontent['d'];
    var content = JSON.stringify(mycontent);
    log.info("content is " + content);
    res.content = content;
    dataStore.put(path, res);
    } catch (error) {
    print(error);
    print("<br/>");
    print('Adding new hello file');

    var reg_initial_js = {
    a: {
    a1: "1",
    a2: "2"
    },
    b: {
    b1: "1",
    b2: "2"
    }
    };
    resource = {
    content: stringify(reg_initial_js)
    };
    dataStore.put(path, resource);
    }
    var regResource = dataStore.get(path);
    print("==============");
    print("<br/>");
    print(regResource.content);
    print("<br/>");
    print("==============");
    %>