Java Code Examples for org.json.JSONObject#toString()

The following examples show how to use org.json.JSONObject#toString() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * This test method attempts to add the same child association twice. This attempt
 * will not succeed, but the test case is to confirm that there is no exception thrown
 * back across the REST API.
 */
public void testAddChildAssocThatAlreadyExists() throws Exception
{
    checkOriginalChildAssocsBeforeChanges();

    // Add an association
    JSONObject jsonPostData = new JSONObject();
    String assocsToAdd = this.childDoc_C.toString();
    jsonPostData.put(ASSOC_SYS_CHILDREN_ADDED, assocsToAdd);
    String jsonPostString = jsonPostData.toString();

    sendRequest(new PostRequest(referencingNodeUpdateUrl, jsonPostString, APPLICATION_JSON), 200);

    // Try to add the same child association again
    sendRequest(new PostRequest(referencingNodeUpdateUrl, jsonPostString, APPLICATION_JSON), 200);
}
 
Example 2
Source Project: braintree_android   File: PaymentMethodBuilder.java    License: MIT License 6 votes vote down vote up
/**
 * @return String representation of {@link PaymentMethodNonce} for API use.
 */
public String build() {
    JSONObject base = new JSONObject();
    JSONObject optionsJson = new JSONObject();
    JSONObject paymentMethodNonceJson = new JSONObject();

    try {
        base.put(MetadataBuilder.META_KEY, new MetadataBuilder()
                .sessionId(mSessionId)
                .source(mSource)
                .integration(mIntegration)
                .build());

        if (mValidateSet) {
            optionsJson.put(VALIDATE_KEY, mValidate);
            paymentMethodNonceJson.put(OPTIONS_KEY, optionsJson);
        }

        build(base, paymentMethodNonceJson);
    } catch (JSONException ignored) {}

    return base.toString();
}
 
Example 3
@POST
@Path("/saveChartTemplate")
@Produces(MediaType.APPLICATION_JSON)
public String saveTemplatePrivate(@Context HttpServletRequest req) {
	String xml = null;
	String docLabel = "";
	try {

		JSONObject requestBodyJSON = RestUtilities.readBodyAsJSONObject(req);

		JSONObject json = new JSONObject(requestBodyJSON.getString("jsonTemplate"));
		docLabel = requestBodyJSON.getString("docLabel");
		xml = json.toString();

	} catch (Exception e) {
		logger.error("Error converting JSON Template to XML...", e);
		throw new SpagoBIServiceException(this.request.getPathInfo(), "An unexpected error occured while executing service", e);

	}

	saveTemplate(docLabel, xml);

	return xml;
}
 
Example 4
@NonNull
@Override
public String serialize(@NonNull PluginDataFormat format) {
    String res;
    switch (format) {
        default:
            JSONObject jsonObject = new JSONObject();
            try {
                HeadsetState hs_state = this.hs_state;
                if (hs_state == HeadsetState.plugged_in)
                    hs_state = HeadsetState.plug_in;
                if (hs_state == HeadsetState.plugged_out)
                    hs_state = HeadsetState.plug_out;
                jsonObject.put(K_HS_STATE, hs_state.name());
                jsonObject.put(K_HS_TYPE, hs_type.name());
            } catch (JSONException e) {
                throw new IllegalStateException(e);
            }
            res = jsonObject.toString();
    }
    return res;
}
 
Example 5
Source Project: FloatWindow   File: L.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 格式化输出JSONObject
 *
 * @param obj
 * @return
 */
private static String format(JSONObject obj) {

    if (obj != null) {
        try {
            return isFormat ? obj.toString(JSON_INDENT) : obj.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return "";
}
 
Example 6
String convertJSON(Bundle bundle) {
    try {
        JSONObject json = convertJSONObject(bundle);
        return json.toString();
    } catch (JSONException e) {
        return null;
    }
}
 
Example 7
Source Project: kognitivo   File: LikeActionController.java    License: Apache License 2.0 5 votes vote down vote up
private static String serializeToJson(LikeActionController controller) {
    JSONObject controllerJson = new JSONObject();
    try {
        controllerJson.put(JSON_INT_VERSION_KEY, LIKE_ACTION_CONTROLLER_VERSION);
        controllerJson.put(JSON_STRING_OBJECT_ID_KEY, controller.objectId);
        controllerJson.put(JSON_INT_OBJECT_TYPE_KEY, controller.objectType.getValue());
        controllerJson.put(
                JSON_STRING_LIKE_COUNT_WITH_LIKE_KEY,
                controller.likeCountStringWithLike);
        controllerJson.put(
                JSON_STRING_LIKE_COUNT_WITHOUT_LIKE_KEY,
                controller.likeCountStringWithoutLike);
        controllerJson.put(
                JSON_STRING_SOCIAL_SENTENCE_WITH_LIKE_KEY,
                controller.socialSentenceWithLike);
        controllerJson.put(
                JSON_STRING_SOCIAL_SENTENCE_WITHOUT_LIKE_KEY,
                controller.socialSentenceWithoutLike);
        controllerJson.put(JSON_BOOL_IS_OBJECT_LIKED_KEY, controller.isObjectLiked);
        controllerJson.put(JSON_STRING_UNLIKE_TOKEN_KEY, controller.unlikeToken);
        if (controller.facebookDialogAnalyticsBundle != null) {
            JSONObject analyticsJSON =
                    BundleJSONConverter.convertToJSON(
                            controller.facebookDialogAnalyticsBundle);
            if (analyticsJSON != null) {
                controllerJson.put(
                        JSON_BUNDLE_FACEBOOK_DIALOG_ANALYTICS_BUNDLE,
                        analyticsJSON);
            }
        }
    } catch (JSONException e) {
        Log.e(TAG, "Unable to serialize controller to JSON", e);
        return null;
    }

    return controllerJson.toString();
}
 
Example 8
@NonNull
private static Weather decodeWeather(JSONObject jroot, JSONObject data) throws JSONException {
    Weather weather = new Weather();
    weather.time = data.getLong("time") * 1000;
    weather.provider = "fio";
    weather.station_id = -1;
    weather.station_type = -1;
    weather.station_name = "-";

    Location station_location = new Location("station");
    station_location.setLatitude(jroot.getDouble("latitude"));
    station_location.setLongitude(jroot.getDouble("longitude"));
    weather.station_location = station_location;

    weather.temperature = (data.has("temperature") ? data.getDouble("temperature") : Double.NaN);
    weather.temperature_min = (data.has("temperatureMin") ? data.getDouble("temperatureMin") : Double.NaN);
    weather.temperature_max = (data.has("temperatureMax") ? data.getDouble("temperatureMax") : Double.NaN);
    weather.humidity = (data.has("humidity") ? data.getDouble("humidity") * 100 : Double.NaN);
    weather.pressure = (data.has("pressure") ? data.getDouble("pressure") : Double.NaN);
    weather.wind_speed = (data.has("windSpeed") ? data.getDouble("windSpeed") : Double.NaN);
    weather.wind_gust = Double.NaN;
    weather.wind_direction = (data.has("windBearing") ? data.getDouble("windBearing") : Double.NaN);
    weather.visibility = (data.has("visibility") ? data.getDouble("visibility") * 1000 : Double.NaN);
    weather.rain_1h = (data.has("precipIntensity") ? data.getDouble("precipIntensity") : Double.NaN);
    weather.rain_today = (data.has("precipAccumulation") ? data.getDouble("precipAccumulation") * 10 : Double.NaN);
    weather.rain_probability = (data.has("precipProbability") ? data.getDouble("precipProbability") * 100 : Double.NaN);
    weather.clouds = (data.has("cloudCover") ? data.getDouble("cloudCover") * 100 : Double.NaN);
    weather.ozone = (data.has("ozone") ? data.getDouble("ozone") : Double.NaN); // Dobson units
    weather.icon = (data.has("icon") ? data.getString("icon") : null);
    // clear-day, clear-night, rain, snow, sleet, wind, fog, cloudy, partly-cloudy-day, or partly-cloudy-night
    weather.summary = (data.has("summary") ? data.getString("summary") : null);
    weather.rawData = data.toString();

    return weather;
}
 
Example 9
Source Project: symphonyx   File: TimelineChannel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Notifies the specified comment message to browsers.
 *
 * @param message the specified message, for example      <pre>
 * {
 *     "commentContent": ""
 * }
 * </pre>
 */
public static void notifyTimeline(final JSONObject message) {
    final String msgStr = message.toString();

    synchronized (SESSIONS) {
        for (final Session session : SESSIONS) {
            if (session.isOpen()) {
                session.getAsyncRemote().sendText(msgStr);
            }
        }
    }
}
 
Example 10
/**
 * Attempt to forcefully shutdown a location provider.
 * Be sure to also check for error events.
 * @return JSONObject that indicates kill request was successful.
 */
public static String killLocationJSON() {
    final JSONObject json = new JSONObject();

    try {
        json.put("success", "true");
    }
    catch( JSONException exc) {
        logJSONException(exc);
    }

    return json.toString();
}
 
Example 11
/**
 * Tries to download the contents of the provided url using commercially validated CA certificate from chosen provider.
 *
 */
private String downloadWithCommercialCA(String stringUrl, Provider provider) {
    String responseString;
    JSONObject errorJson = new JSONObject();

    OkHttpClient okHttpClient = clientGenerator.initCommercialCAHttpClient(errorJson);
    if (okHttpClient == null) {
        return errorJson.toString();
    }

    List<Pair<String, String>> headerArgs = getAuthorizationHeader();

    responseString = sendGetStringToServer(stringUrl, headerArgs, okHttpClient);

    if (responseString != null && responseString.contains(ERRORS)) {
        try {
            // try to download with provider CA on certificate error
            JSONObject responseErrorJson = new JSONObject(responseString);
            if (responseErrorJson.getString(ERRORS).equals(getProviderFormattedString(resources, R.string.certificate_error))) {
                responseString = downloadWithProviderCA(provider.getCaCert(), stringUrl);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    return responseString;
}
 
Example 12
Source Project: marathonv5   File: JavaServer.java    License: Apache License 2.0 4 votes vote down vote up
public String getWindowProperties(JSONObject query, JSONObject uriParams, Session session) {
    JSONObject props = session.getWindowProperties();
    return props.toString();
}
 
Example 13
/**
 * Updates the book to the server
 *
 * @param locationObject The location at which to create the book, if <code>null</code>, uses
 *                       the user's preferred location
 */
private void updateBookOnServer(final JSONObject locationObject) {
    try {

        final JSONObject requestObject = new JSONObject();
        final JSONObject bookJson = new JSONObject();
        bookJson.put(HttpConstants.TITLE, mTitleEditText.getText()
                                                        .toString());
        bookJson.put(HttpConstants.AUTHOR, mAuthorEditText.getText()
                                                          .toString());

        bookJson.put(HttpConstants.DESCRIPTION, mDescriptionEditText
                .getText().toString());
        if (!mSellPriceEditText.getText().toString().equals("")) {
            bookJson.put(HttpConstants.VALUE, mSellPriceEditText.getText()
                                                                .toString());
        }

        bookJson.put(HttpConstants.PUBLICATION_YEAR, mPublicationYear);
        if (mIsbnEditText.getText().toString().length() == 13) {
            bookJson.put(HttpConstants.ISBN_13, mIsbnEditText.getText()
                                                             .toString());
        } else if (mIsbnEditText.getText().toString().length() == 10) {
            bookJson.put(HttpConstants.ISBN_10, mIsbnEditText.getText()
                                                             .toString());
        }
        bookJson.put(HttpConstants.TAG_NAMES, getBarterTagsArray());
        bookJson.put(HttpConstants.EXT_IMAGE_URL, mImage_Url);

        if (locationObject != null) {
            bookJson.put(HttpConstants.LOCATION, locationObject);
        }
        requestObject.put(HttpConstants.BOOK, bookJson);
        requestObject.put(HttpConstants.ID, mId);
        final BlRequest updateBookRequest = new BlRequest(Method.PUT,
                                                          HttpConstants.getApiBaseUrl()
                                                                  + ApiEndpoints.BOOKS,
                                                          requestObject.toString(),
                                                          mVolleyCallbacks
        );
        updateBookRequest.setRequestId(RequestId.UPDATE_BOOK);
        addRequestToQueue(updateBookRequest, true, 0, true);
    } catch (final JSONException e) {
        e.printStackTrace();
    }
}
 
Example 14
@Override
public Set<SimpleBusinessColumn> getReferencedColumns() throws KnowageMetaException {
	Set<SimpleBusinessColumn> columnsReferenced = new HashSet<SimpleBusinessColumn>();
	BusinessColumnSet businessColumnSet = this.getTable();

	// get Expression String
	String id = this.getPropertyType(CALCULATED_COLUMN_EXPRESSION).getId();
	String expression = this.getProperties().get(id).getValue();

	String regularExpression = "(\\,|\\+|\\-|\\*|\\(|\\)|\\|\\||\\/|GG_between_dates|MM_between_dates|AA_between_dates|GG_up_today|MM_up_today|AA_up_today|current_date|current_time|length|substring|concat|year|month|mod|bit_length|upper|lower|trim|current_timestamp|hour|minute|second|day";

	// add custom functions if present
	String customs = "";
	JSONObject json = CustomFunctionsSingleton.getInstance().getCustomizedFunctionsJSON();
	// check there really are some custom functions
	if (json != null && json.toString() != "{}") {
		String dbType = DbTypeThreadLocal.getDbType();
		if (dbType == null) {
			logger.error("DbType not found");
			throw new RuntimeException("DbType could not be found in current Thread Locale, check stack of calls");
		}
		CustomizedFunctionsReader reader = new CustomizedFunctionsReader();
		List<CustomizedFunction> list = reader.getCustomDefinedFunctionListFromJSON(json, dbType);
		if (list != null && list.size() > 0) {
			customs = reader.getStringFromOrderedList(list);
			logger.debug("String to add to regular exression " + customs);
		}
	}

	logger.debug("Customs functions definition " + customs);
	regularExpression += customs;

	regularExpression += ")";

	// retrieve columns objects from string v
	String[] splittedExpr = expression.split(regularExpression);
	for (String operand : splittedExpr) {
		operand = operand.trim();

		if (NumberUtils.isNumber(operand)) {
			continue;
		}

		List<SimpleBusinessColumn> businessColumns = businessColumnSet.getSimpleBusinessColumnsByName(operand);
		if (businessColumns.isEmpty()) {
			// throws exception
			// throw new KnowageMetaException("No columns using the name [" + operand + "] are found in the expression of Calculated Field [" +
			// this.getName()
			// + "]");
		} else {
			if (businessColumns.size() > 1) {
				logger.warn("More columns using the name [" + operand + "] are found in the expression of Calculated Field [" + this.getName() + "]");
			}
		}

		// always get first SimpleBusinessColumn found with that name (operand)
		if (!businessColumns.isEmpty()) {
			SimpleBusinessColumn simpleBusinessColumn = businessColumns.get(0);
			if (simpleBusinessColumn != null) {
				columnsReferenced.add(simpleBusinessColumn);
			}
		}

	}
	return columnsReferenced;
}
 
Example 15
protected String datasetInsert(IDataSet ds, IDataSetDAO dsDao, Locale locale, UserProfile userProfile, JSONObject json, HttpServletRequest req)
		throws JSONException {
	JSONObject attributesResponseSuccessJSON = new JSONObject();
	HashMap<String, String> logParam = new HashMap<>();

	if (ds != null) {
		logParam.put("NAME", ds.getName());
		logParam.put("LABEL", ds.getLabel());
		logParam.put("TYPE", ds.getDsType());
		String id = json.optString(DataSetConstants.ID);
		try {
			IDataSet existingByName = dsDao.loadDataSetByName(ds.getName());
			if (id != null && !id.equals("") && !id.equals("0")) {
				if (existingByName != null && !Integer.valueOf(id).equals(existingByName.getId())) {
					throw new SpagoBIServiceException(SERVICE_NAME, "sbi.ds.nameAlreadyExistent");
				}

				ds.setId(Integer.valueOf(id));
				modifyPersistence(ds, logParam, req);
				dsDao.modifyDataSet(ds);
				logger.debug("Resource " + id + " updated");
				attributesResponseSuccessJSON.put("success", true);
				attributesResponseSuccessJSON.put("responseText", "Operation succeded");
				attributesResponseSuccessJSON.put("id", id);
				attributesResponseSuccessJSON.put("dateIn", ds.getDateIn());
				attributesResponseSuccessJSON.put("userIn", ds.getUserIn());
				attributesResponseSuccessJSON.put("meta", DataSetJSONSerializer.metadataSerializerChooser(ds.getDsMetadata()));
			} else {
				IDataSet existingByLabel = dsDao.loadDataSetByLabel(ds.getLabel());
				if (existingByLabel != null) {
					throw new SpagoBIServiceException(SERVICE_NAME, "sbi.ds.labelAlreadyExistent");
				}

				if (existingByName != null) {
					throw new SpagoBIServiceException(SERVICE_NAME, "sbi.ds.nameAlreadyExistent");
				}

				Integer dsID = dsDao.insertDataSet(ds);
				VersionedDataSet dsSaved = (VersionedDataSet) dsDao.loadDataSetById(dsID);
				auditlogger.info("[Saved dataset without metadata with id: " + dsID + "]");
				logger.debug("New Resource inserted");
				attributesResponseSuccessJSON.put("success", true);
				attributesResponseSuccessJSON.put("responseText", "Operation succeded");
				attributesResponseSuccessJSON.put("id", dsID);
				if (dsSaved != null) {
					attributesResponseSuccessJSON.put("dateIn", dsSaved.getDateIn());
					attributesResponseSuccessJSON.put("userIn", dsSaved.getUserIn());
					attributesResponseSuccessJSON.put("versNum", dsSaved.getVersionNum());
					attributesResponseSuccessJSON.put("meta", DataSetJSONSerializer.metadataSerializerChooser(dsSaved.getDsMetadata()));
				}
			}
			String operation = (id != null && !id.equals("") && !id.equals("0")) ? "DATA_SET.MODIFY" : "DATA_SET.ADD";
			Boolean isFromSaveNoMetadata = json.optBoolean(DataSetConstants.IS_FROM_SAVE_NO_METADATA);
			// handle insert of persistence and scheduling
			if (!isFromSaveNoMetadata) {
				auditlogger.info("[Start persisting metadata for dataset with id " + ds.getId() + "]");
				insertPersistence(ds, logParam, json, userProfile, req);
				auditlogger.info("Metadata saved for dataset with id " + ds.getId() + "]");
				auditlogger.info("[End persisting metadata for dataset with id " + ds.getId() + "]");
			}

			AuditLogUtilities.updateAudit(req, profile, operation, logParam, "OK");
			dsDao.updateDatasetOlderVersion(ds);
			return attributesResponseSuccessJSON.toString();
		} catch (Exception e) {
			AuditLogUtilities.updateAudit(req, profile, "DATA_SET.ADD", logParam, "KO");
			throw new SpagoBIServiceException(SERVICE_NAME, "sbi.ds.saveDsError", e);
		}
	} else {
		AuditLogUtilities.updateAudit(req, profile, "DATA_SET.ADD/MODIFY", logParam, "ERR");
		logger.error("DataSet name, label or type are missing");
		throw new SpagoBIServiceException(SERVICE_NAME, "sbi.ds.fillFieldsError");
	}
}
 
Example 16
Source Project: XERUNG   File: ProfileSetting.java    License: Apache License 2.0 4 votes vote down vote up
private void callWebServiceProcess(JSONObject jbObject) {
    String jsonData = jbObject.toString();
    new Webservice(this, Vars.webMethodName.get(0)).execute(jsonData, Vars.gateKeperHit, Vars.webMethodName.get(0));
    showProgress();
}
 
Example 17
Source Project: bboxdb   File: GeoJsonPolygon.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Return the GEO JSON representation of the polygon
 * @return
 */
public String toGeoJson() {
	final JSONObject featureJson = buildJSON();
	return featureJson.toString();
}
 
Example 18
@GET
  @Path("/listDocument")
  @Produces(MediaType.APPLICATION_JSON + "; charset=UTF-8")
  public String getDocumentSearchAndPaginate(@QueryParam("Page") String pageStr, @QueryParam("ItemPerPage") String itemPerPageStr,
                                             @QueryParam("label") String label, @QueryParam("name") String name, @QueryParam("descr") String descr,
                                             @QueryParam("excludeType") String excludeType, @QueryParam("includeType") String includeType, @QueryParam("scope") String scope,
	@QueryParam("loadObjPar") Boolean loadObjPar, @QueryParam("objLabelIn") String objLabelIn, @QueryParam("objLabelNotIn") String objLabelNotIn,
	@QueryParam("forceVis") @DefaultValue("false") Boolean forceVisibility)
          throws EMFInternalError {
      logger.debug("IN");
      UserProfile profile = getUserProfile();
      IBIObjectDAO documentsDao = null;
      List<BIObject> filterObj = null;
      Integer page = getNumberOrNull(pageStr);
      Integer item_per_page = getNumberOrNull(itemPerPageStr);
      List<CriteriaParameter> disjunctions = new ArrayList<CriteriaParameter>();
      if (label != null && !label.isEmpty()) {
          disjunctions.add(new CriteriaParameter("label", label, Match.ILIKE));
      }
      if (name != null && !name.isEmpty()) {
          disjunctions.add(new CriteriaParameter("name", name, Match.ILIKE));
      }
      if (descr != null && !descr.isEmpty()) {
          disjunctions.add(new CriteriaParameter("descr", descr, Match.ILIKE));
      }

      String UserFilter = profile.getIsSuperadmin() ? null : profile.getUserId().toString();

      // in glossary, the user with admin role and specific authorization can
      // see all document of the organization
      if (scope != null && scope.compareTo("GLOSSARY") == 0) {
          if (UserUtilities.haveRoleAndAuthorization(profile, SpagoBIConstants.ADMIN_ROLE_TYPE,
                  new String[]{SpagoBIConstants.MANAGE_GLOSSARY_TECHNICAL})) {
              UserFilter = null;
          }
      }

      List<CriteriaParameter> restritions = new ArrayList<CriteriaParameter>();

      // filter document if is USER profile
      // Commented out: this kind of logic has to be handled by the
      // "ObjectsAccessVerifier.canSee" utility method
      // (ATHENA-138/SBI-532/SBI-533)
      /*
       * if (UserFilter != null) { restritions.add(new CriteriaParameter("creationUser", UserFilter, Match.EQ)); }
       */

      if (excludeType != null) {
          restritions.add(new CriteriaParameter("objectTypeCode", excludeType, Match.NOT_EQ));
      }
      if (includeType != null) {
          restritions.add(new CriteriaParameter("objectTypeCode", includeType, Match.EQ));
      }
      if (objLabelIn != null) {
          restritions.add(new CriteriaParameter("label", objLabelIn.split(","), Match.IN));
      }
      if (objLabelNotIn != null) {
          restritions.add(new CriteriaParameter("label", objLabelNotIn.split(","), Match.NOT_IN));
      }

      // hide if user is not admin or devel and visible is false
if (!forceVisibility && !profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_ADMIN)
              && !profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_DEV)) {
          restritions.add(new CriteriaParameter("visible", Short.valueOf("1"), Match.EQ));
      }
      try {
          documentsDao = DAOFactory.getBIObjectDAO();

          filterObj = documentsDao.loadPaginatedSearchBIObjects(page, item_per_page, disjunctions, restritions);
          JSONArray jarr = new JSONArray();
          if (filterObj != null) {
              for (BIObject sbiob : filterObj) {
			if (forceVisibility || ObjectsAccessVerifier.canSee(sbiob, profile)) {
                      JSONObject tmp = fromDocumentLight(sbiob);
                      if (loadObjPar != null && loadObjPar == true) {
                          tmp.put("objParameter", fromObjectParameterListLight(sbiob.getDrivers()));
                      }
                      jarr.put(tmp);
                  }
              }
          }
          JSONObject jo = new JSONObject();
          jo.put("item", jarr);
          jo.put("itemCount", documentsDao.countBIObjects(label != null ? label : "", UserFilter));

          return jo.toString();
      } catch (Exception e) {
          logger.error("Error while getting the list of documents", e);
          throw new SpagoBIRuntimeException("Error while getting the list of documents", e);
      } finally {
          logger.debug("OUT");
      }
  }
 
Example 19
Source Project: configuration-as-code-plugin   File: Util.java    License: MIT License 3 votes vote down vote up
/**
 * Retrieves the JSON schema for the running jenkins instance.
 * <p>Example Usage:</p>
 * <pre>{@code
 *      Schema jsonSchema = returnSchema();}
 *      </pre>
 *
 * @return the schema for the current jenkins instance
 */
public static Schema returnSchema() {
    JSONObject schemaObject = generateSchema();
    JSONObject jsonSchema = new JSONObject(
        new JSONTokener(schemaObject.toString()));
    return SchemaLoader.load(jsonSchema);
}
 
Example 20
Source Project: volley_demo   File: JsonArrayRequest.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new request.
 * @param method the HTTP method to use
 * @param url URL to fetch the JSON from
 * @param jsonRequest A {@link JSONObject} to post with the request. Null is allowed and
 *   indicates no parameters will be posted along with request.
 * @param listener Listener to receive the JSON response
 * @param errorListener Error listener, or null to ignore errors.
 */
public JsonArrayRequest(int method, String url, JSONObject jsonRequest,
                        Listener<JSONArray> listener, ErrorListener errorListener) {
    super(method, url, (jsonRequest == null) ? null : jsonRequest.toString(), listener,
            errorListener);
}