Package org.json

Examples of org.json.JSONObject.opt()


    Collection<JSONObject> userDocs = userDb.getDocuments(docIds);
   
    // Work around for bug in CouchDb 1.4.0
    if( userDocs.size() > 0 ) {
      JSONObject firstUser = userDocs.iterator().next();
      Object returnedId = firstUser.opt("_id");
      if( null == returnedId ){
        // Perform request, one at a time
        List<JSONObject> tempUserDocs = new Vector<JSONObject>();
        for(String id : docIds){
          try {
View Full Code Here


    JSONObject nunaliit_attachments = doc.getJSONObject(UploadConstants.KEY_DOC_ATTACHMENTS);
    JSONObject files = nunaliit_attachments.getJSONObject("files");

    // Verify no collision within nunaliit_attachments.files
    {
      Object obj = files.opt(newAttachmentName);
      if( null != obj ){
        throw new Exception("Can not rename attachment because of name collision");
      }
    }
   
View Full Code Here

            if (binaryData == null) {
               return;
            }
            JSONObject payload = new JSONObject(binaryData.toString(CharsetUtil.UTF_8));
            String opCode = (String) payload.get(OpHandler.OP_CODE);
            String cacheName = (String) payload.opt(OpHandler.CACHE_NAME);
            Cache<Object, Object> cache = getCache(cacheName);
           
            OpHandler handler = operationHandlers.get(opCode);
            if (handler != null) {
               handler.handleOp(payload, cache, ctx);
View Full Code Here

    JSONObject nunaliit_attachments = doc.getJSONObject("nunaliit_attachments");
    JSONObject files = nunaliit_attachments.getJSONObject("files");

    // Verify no collision within nunaliit_attachments.files
    {
      Object obj = files.opt(newAttachmentName);
      if( null != obj ){
        throw new Exception("Can not rename attachment because of name collision");
      }
    }
   
View Full Code Here

    Collection<JSONObject> userDocs = userDb.getDocuments(docIds);
   
    // Work around for bug in CouchDb 1.4.0
    if( userDocs.size() > 0 ) {
      JSONObject firstUser = userDocs.iterator().next();
      Object returnedId = firstUser.opt("_id");
      if( null == returnedId ){
        // Perform request, one at a time
        List<JSONObject> tempUserDocs = new Vector<JSONObject>();
        for(String id : docIds){
          try {
View Full Code Here

      ) throws Exception {
   
    Set<String> agreementContents = new HashSet<String>();
    JSONObject agreementInfo = agreementDoc.optJSONObject("nunaliit_user_agreement");
    if( null != agreementInfo ){
      Object content = agreementInfo.opt("content");
      if( null == content ) {
        // Nothing to do. It is not available
      } else if( content instanceof String ){
        agreementContents.add( (String)content );
      } else if( content instanceof JSONObject ){
View Full Code Here

    JSONObject clone = new JSONObject(base, JSONObject.getNames(base));
    // Walk parameter list for the merged object and merge recursively.
    String[] fields = JSONObject.getNames(merge);
    for (String field : fields) {
      Object existing = clone.opt(field);
      Object update = merge.get(field);
      if (JSONObject.NULL.equals(existing) || JSONObject.NULL.equals(update)) {
        // It's new custom config, not referenced in the prototype, or
        // it's removing a pre-configured value.
        clone.put(field, update);
View Full Code Here

      return null;
    }
    Map<String, Object> map = Maps.newHashMap();
    for (Iterator<?> it = jsonObject.keys(); it.hasNext(); ) {
      String key = (String) it.next();
      map.put(key, jsonObject.opt(key));
    }
    return map;
  }

  private static Object createValue(Object object) {
View Full Code Here

            for (final String[] index : indexes) {
                final org.b3log.latke.repository.Query futureQuery = new org.b3log.latke.repository.Query().setPageCount(1);
                for (int j = 0; j < index.length; j++) {
                    final String propertyName = index[j];

                    futureQuery.setFilter(new PropertyFilter(propertyName, FilterOperator.EQUAL, jsonObject.opt(propertyName)));
                    logMsgBuilder.append(propertyName).append(",");
                }

                if (logMsgBuilder.length() > 0) {
                    logMsgBuilder.deleteCharAt(logMsgBuilder.length() - 1);
View Full Code Here

            for (final String[] index : indexes) {
                final org.b3log.latke.repository.Query futureQuery = new org.b3log.latke.repository.Query().setPageCount(1);
                for (int j = 0; j < index.length; j++) {
                    final String propertyName = index[j];

                    futureQuery.setFilter(new PropertyFilter(propertyName, FilterOperator.EQUAL, jsonObject.opt(propertyName)));
                    logMsgBuilder.append(propertyName).append(",");
                }
                logMsgBuilder.deleteCharAt(logMsgBuilder.length() - 1); // Removes the last comma

                cacheKey = CACHE_KEY_PREFIX + futureQuery.getCacheKey() + "_" + getName();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.