use of org.forgerock.openam.utils.JsonObject in project OpenAM by OpenRock.
the class RecordReport method globalInformationReport.
/**
* Create the global information report
* * @return
*/
private JsonValue globalInformationReport(Record record) {
JsonObject report = JsonValueBuilder.jsonValue();
synchronized (dateFormat) {
report.put(DATE_LABEL, dateFormat.format(new Date()));
}
report.put(OPENAM_VERSION_LABEL, SystemPropertiesManager.get(Constants.AM_VERSION));
// OpenAM properties contain a part of the OpenAM configuration, we need to have the config export enable
if (record.getRecordProperties().isConfigExportEnabled()) {
JsonObject openAMPropertiesJson = JsonValueBuilder.jsonValue();
Properties sysProps = SystemProperties.getProperties();
for (String propertyName : sysProps.stringPropertyNames()) {
report.put(propertyName, sysProps.getProperty(propertyName));
}
report.put(OPENAM_PROPERTIES_LABEL, openAMPropertiesJson.build().asMap());
}
return report.build();
}
use of org.forgerock.openam.utils.JsonObject in project OpenAM by OpenRock.
the class RecordResource method actionStop.
/**
* Stop action
*
* @return
*/
private Promise<ActionResponse, ResourceException> actionStop() {
try {
Record record = debugRecorder.stopRecording();
if (record == null) {
return new BadRequestException("No record or it's already stopped.").asPromise();
} else {
JsonObject result = JsonValueBuilder.jsonValue();
result.put(STATUS_LABEL, false);
result.put(RECORD_LABEL, record.exportJson().asMap());
return newResultPromise(newActionResponse(result.build()));
}
} catch (RecordException e) {
debug.message("Record can't be stopped.", e);
return new BadRequestException("Record can't be stopped.", e).asPromise();
}
}
use of org.forgerock.openam.utils.JsonObject in project OpenAM by OpenRock.
the class RecordResource method actionStatus.
/**
* Status action
*
* @return
*/
private Promise<ActionResponse, ResourceException> actionStatus() {
Record currentRecord = debugRecorder.getCurrentRecord();
JsonObject jsonValue = JsonValueBuilder.jsonValue();
if (currentRecord != null) {
jsonValue.put(STATUS_LABEL, true);
jsonValue.put(RECORD_LABEL, currentRecord.exportJson().asMap());
} else {
jsonValue.put(STATUS_LABEL, false);
}
return newResultPromise(newActionResponse(jsonValue.build()));
}
use of org.forgerock.openam.utils.JsonObject in project OpenAM by OpenRock.
the class RecordProperties method toJson.
/**
* Export a record properties into json
*
* @param recordProperties
* @return json representing the record properties
*/
public static JsonValue toJson(RecordProperties recordProperties) {
JsonObject jsonProperties = JsonValueBuilder.jsonValue();
// Global
jsonProperties.put(RecordConstants.ISSUE_ID_LABEL, recordProperties.issueID);
jsonProperties.put(RecordConstants.REFERENCE_ID_LABEL, recordProperties.referenceID);
jsonProperties.put(RecordConstants.DESCRIPTION_LABEL, recordProperties.description);
jsonProperties.put(RecordConstants.ZIP_ENABLE_LABEL, recordProperties.zipEnable);
// Sub json
jsonProperties.put(RecordConstants.THREAD_DUMP_LABEL, toThreadDumpJson(recordProperties).asMap());
jsonProperties.put(RecordConstants.CONFIG_EXPORT_LABEL, toConfigExportJson(recordProperties).asMap());
jsonProperties.put(RecordConstants.DEBUG_LOGS_LABEL, toDebugLogsJson(recordProperties).asMap());
return jsonProperties.build();
}
use of org.forgerock.openam.utils.JsonObject in project OpenAM by OpenRock.
the class RecordProperties method toThreadDumpJson.
/**
* Export the thread dump json block
*
* @param recordProperties
* @return the thread dump json block
*/
private static JsonValue toThreadDumpJson(RecordProperties recordProperties) {
JsonObject threadsDumpsProperties = JsonValueBuilder.jsonValue();
threadsDumpsProperties.put(RecordConstants.THREAD_DUMP_ENABLE_LABEL, recordProperties.threadDumpEnable);
if (recordProperties.threadDumpEnable) {
JsonObject threadsDumpsDelayProperties = JsonValueBuilder.jsonValue();
threadsDumpsDelayProperties.put(RecordConstants.THREAD_DUMP_DELAY_TIME_UNIT_LABEL, TimeUnit.SECONDS.toString());
threadsDumpsDelayProperties.put(RecordConstants.THREAD_DUMP_DELAY_VALUE_LABEL, recordProperties.threadDumpDelayInSeconds);
threadsDumpsProperties.put(RecordConstants.THREAD_DUMP_DELAY_LABEL, threadsDumpsDelayProperties.build().asMap());
}
return threadsDumpsProperties.build();
}
Aggregations