Package com.fourspaces.couchdb

Examples of com.fourspaces.couchdb.Database


    RequestContext request) {
      Target target = request.getTarget();
      String feed = target.getParameter("feed");
      String entry = target.getParameter("entry");
      Session session = new Session(host,port);
      Database db = session.getDatabase(feed);
      Document doc = null;
      try {
        doc = db.getDocument(entry);
      } catch (Exception e) {
        // error if the doc isn't found, we deal with the null result below
      }
      if (doc != null)
        return new JsonObjectResponseContext(
View Full Code Here


  public ResponseContext putEntry(
    RequestContext request) {
      Target target = request.getTarget();
      String feed = target.getParameter("feed");
      Session session = new Session(host,port);
      Database db = session.getDatabase(feed);
      try {
        CharArrayWriter cwriter = new CharArrayWriter();
        setEditDetail(request);
        request.getDocument().getRoot().writeTo("json", cwriter);
        String json = new String(cwriter.toCharArray());
        JSONObject obj = JSONObject.fromObject(json);
        String key = target.getParameter("entry");
        Document doc = null;
        try {
          doc = db.getDocument(key);
        } catch (Exception e) {
          // error if the doc isn't found, we deal with the null result below
        }
        if (doc == null) {
          return ProviderHelper.notfound(request);
        } else {
          db.deleteDocument(doc);
          doc = new Document(obj);
          doc.setId(key);
          db.saveDocument(doc);
          doc = db.getDocument(key);
          if (doc != null)
            return new JsonObjectResponseContext(
              request.getAbdera(),
              config,
              doc)
View Full Code Here

TOP

Related Classes of com.fourspaces.couchdb.Database

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.