Package com.dotmarketing.util.json

Examples of com.dotmarketing.util.json.JSONObject$Null


                //Error messages
                JSONArray jsonErrors = new JSONArray( (ArrayList) responseMap.get( "errorMessages" ) );

                //Prepare the Json response
                JSONObject jsonResponse = new JSONObject();
                jsonResponse.put( "errorMessages", jsonErrors.toArray() );
                jsonResponse.put( "errors", responseMap.get( "errors" ) );
                jsonResponse.put( "total", responseMap.get( "total" ) );
                jsonResponse.put( "bundleId", responseMap.get( "bundleId" ) );

                //And send it back to the user
                response.getWriter().println( jsonResponse.toString() );
            }
        } catch ( Exception e ) {
            Logger.error( RemotePublishAjaxAction.class, e.getMessage(), e );
            response.sendError( HttpStatus.SC_INTERNAL_SERVER_ERROR, "Error Publishing Bundle: " + e.getMessage() );
        }
View Full Code Here


                //Error messages
                JSONArray jsonErrors = new JSONArray( (ArrayList) responseMap.get( "errorMessages" ) );

                //Prepare the Json response
                JSONObject jsonResponse = new JSONObject();
                jsonResponse.put( "errorMessages", jsonErrors.toArray() );
                jsonResponse.put( "errors", responseMap.get( "errors" ) );
                jsonResponse.put( "total", responseMap.get( "total" ) );

                //And send it back to the user
                response.getWriter().println( jsonResponse.toString() );
            }
        } catch ( Exception e ) {
            Logger.error( RemotePublishAjaxAction.class, e.getMessage(), e );
            response.sendError( HttpStatus.SC_INTERNAL_SERVER_ERROR, "Error Adding content to Bundle: " + e.getMessage() );
        }
View Full Code Here

      if(specificStructure != null)
        structures.add(specificStructure);
    }
   
    JSONArray jsonStructures = new JSONArray();
    JSONObject jsonStructureObject = new JSONObject();
   
    int structCount = 0;
    for(Structure st: structures)
    {
      if(!inodeFilter.isEmpty() || (!range.isEmpty() && structCount >= beginItem && structCount <= endItem)){
        jsonStructureObject = new JSONObject();
        jsonStructureObject.put("id", st.getInode());
        jsonStructureObject.put("name", st.getName());
      }
      if(inodeFilter.isEmpty()){
        jsonStructures.add(jsonStructureObject);
      }else{
        return responseResource.response(jsonStructureObject.toString());
      }
    }
    if(inodeFilter.isEmpty() && !range.isEmpty()) {
      response.addHeader("Content-Range", "items " + beginItem + "-" + Math.min(endItem, structCount -1) + "/" + structCount);
    }
View Full Code Here

        ResourceResponse responseResource = new ResourceResponse( initData.getParamsMap() );

    User user = WebAPILocator.getUserWebAPI().getLoggedInUser(request);

    //Using JSONObject instead of manually creating the json object
    JSONObject jsonLoggedUserObject = new JSONObject();
   
    if ( user == null ) {
            //return responseResource.response( "{}" );
      return responseResource.response(jsonLoggedUserObject.toString());
        }

    Role myRole  = APILocator.getRoleAPI().getUserRole(user);

    //Adding logged user information to the object
    jsonLoggedUserObject.put("userId", user.getUserId());
    jsonLoggedUserObject.put("firstName", UtilMethods.escapeSingleQuotes(user.getFirstName()));
    jsonLoggedUserObject.put("lastName", UtilMethods.escapeSingleQuotes(user.getLastName()));
    jsonLoggedUserObject.put("roleId", myRole.getId());

        return responseResource.response(jsonLoggedUserObject.toString());
  }
View Full Code Here

  public JSONObject fetch(String url) {
    try {
      String x = acquireString(url);
            x = x.substring(x.indexOf('{'), x.length());
            x = x.substring(0, x.lastIndexOf('}')+1);
      return new JSONObject(x);
    } catch (IOException e) {
      Logger.error(JSONObject.class, e.getMessage(), e);
    } catch (Exception e) {
      Logger.error(JSONObject.class, e.getMessage(), e);
    }
View Full Code Here

   * Returns a JSONObject from a passed in Map
   * @param o
   * @return
   */
  public JSONObject generate(Map map){
    return new JSONObject(map);
  }
View Full Code Here

   * Returns a JSONObject from a passed in Object
   * @param o
   * @return
   */
  public JSONObject generate(Object o){
    return new JSONObject(o);
  }
View Full Code Here

     *
     * @param s The JSON string.
     * @return A JSONObject as parsed from the provided string, null in the event of an error.
     */
    public JSONObject generate(String s) {
        JSONObject result;
        try {
            result = new JSONObject(s);
        }
        catch (Exception e)
        {
            Logger.error(JSONObject.class, e.getMessage(), e);
            result = null;
View Full Code Here

    return true;
  }

  private boolean isValidJSONObject(String json) {
    try {
      new JSONObject(json);
    } catch (JSONException e) {
      Logger.error(this.getClass(), "Not Valid JSON Array");
      return false;
    }
View Full Code Here

    //Execute the call
    URL publishUrl = new URL( completeURL );
    String response = IOUtils.toString( publishUrl.openStream(), "UTF-8" );
    //Validations
    JSONObject jsonResponse = new JSONObject( response );
    assertNotNull( contentlets );
    assertEquals( jsonResponse.getInt( "errors" ), 0 );
    assertEquals( jsonResponse.getInt( "total" ), 1 );
    assertNotNull( jsonResponse.get( "bundleId" ) );

    //Now that we have a bundle id
    String bundleId = jsonResponse.getString( "bundleId" );
    //First we need to verify if this bundle is in the queue job
    List<PublishQueueElement> foundBundles = publisherAPI.getQueueElementsByBundleId( bundleId );
    assertNotNull( foundBundles );
    assertTrue( !foundBundles.isEmpty() );
View Full Code Here

TOP

Related Classes of com.dotmarketing.util.json.JSONObject$Null

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.