use of org.forgerock.openam.utils.JsonObject in project OpenAM by OpenRock.
the class RestAuthLanguageCallbackHandler method convertToJson.
/**
* {@inheritDoc}
*/
public JsonValue convertToJson(LanguageCallback callback, int index) {
Locale locale = callback.getLocale();
JsonObject jsonObject = JsonValueBuilder.jsonValue().put("type", CALLBACK_NAME);
if (locale != null) {
jsonObject.array("input").add(createInputField(index, "Language", locale.getLanguage())).addLast(createInputField(index, "Country", locale.getCountry()));
}
return jsonObject.build();
}
use of org.forgerock.openam.utils.JsonObject in project OpenAM by OpenRock.
the class RecordProperties method toConfigExportJson.
/**
* Export the config export json block
*
* @param recordProperties
* @return the config export json block
*/
private static JsonValue toConfigExportJson(RecordProperties recordProperties) {
JsonObject configExportProperties = JsonValueBuilder.jsonValue();
configExportProperties.put(RecordConstants.CONFIG_EXPORT_ENABLE_LABEL, recordProperties.configExportEnable);
if (recordProperties.configExportEnable) {
if (recordProperties.configExportSharePassword) {
configExportProperties.put(RecordConstants.CONFIG_EXPORT_PASSWORD_LABEL, recordProperties.configExportPassword);
} else {
configExportProperties.put(RecordConstants.CONFIG_EXPORT_PASSWORD_LABEL, NOT_SHARED_PASSWORD);
}
configExportProperties.put(RecordConstants.CONFIG_EXPORT_SHARE_PASSWORD_LABEL, recordProperties.configExportSharePassword);
}
return configExportProperties.build();
}
use of org.forgerock.openam.utils.JsonObject in project OpenAM by OpenRock.
the class RecordProperties method toDebugLogsJson.
/**
* Export the debug logs json block
*
* @param recordProperties
* @return the debug logs json block
*/
private static JsonValue toDebugLogsJson(RecordProperties recordProperties) {
JsonObject debugLogsProperties = JsonValueBuilder.jsonValue();
debugLogsProperties.put(RecordConstants.DEBUG_LOGS_DEBUG_LEVEL_LABEL, recordProperties.debugLevel.toString());
if (recordProperties.autoStopEnable) {
JsonObject autoStopProperties = JsonValueBuilder.jsonValue();
if (recordProperties.autoStopTimeEnable) {
JsonObject timeProperties = JsonValueBuilder.jsonValue();
timeProperties.put(RecordConstants.DEBUG_LOGS_AUTOSTOP_TIME_UNIT_LABEL, TimeUnit.MILLISECONDS.toString());
timeProperties.put(RecordConstants.DEBUG_LOGS_AUTOSTOP_TIME_VALUE_LABEL, recordProperties.autoStopTimeInMS);
autoStopProperties.put(RecordConstants.DEBUG_LOGS_AUTOSTOP_TIME_LABEL, timeProperties.build().asMap());
}
if (recordProperties.autoStopFileSizeEnable) {
JsonObject fileSizeProperties = JsonValueBuilder.jsonValue();
fileSizeProperties.put(RecordConstants.DEBUG_LOGS_AUTOSTOP_FILESIZE_SIZEUNIT_LABEL, FileSizeUnit.KB.toString());
fileSizeProperties.put(RecordConstants.DEBUG_LOGS_AUTOSTOP_FILESIZE_VALUE_LABEL, recordProperties.autoStopFileSizedInKB);
autoStopProperties.put(RecordConstants.DEBUG_LOGS_AUTOSTOP_FILESIZE_LABEL, fileSizeProperties.build().asMap());
}
debugLogsProperties.put(RecordConstants.DEBUG_LOGS_AUTOSTOP_LABEL, autoStopProperties.build().asMap());
}
return debugLogsProperties.build();
}
use of org.forgerock.openam.utils.JsonObject in project OpenAM by OpenRock.
the class RecordReport method getJVMInformation.
/**
* Create the JVM information
*
* @return
*/
private JsonValue getJVMInformation() {
JsonObject report = JsonValueBuilder.jsonValue();
//Arguments
List<String> arguments = runtimeMxBean.getInputArguments();
JsonArray argumentsJson = report.array(JVM_ARGUMENTS_LABEL);
for (String argument : arguments) {
argumentsJson.add(argument);
}
// some useful jvm properties
JsonObject propertiesJson = JsonValueBuilder.jsonValue();
propertiesJson.put("java.vm.info", System.getProperty("java.vm.info"));
propertiesJson.put("java.vm.name", System.getProperty("java.vm.info"));
propertiesJson.put("java.vm.specification.name", System.getProperty("java.vm.specification.name"));
propertiesJson.put("java.vm.specification.vendor", System.getProperty("java.vm.specification.vendor"));
propertiesJson.put("java.vm.specification.version", System.getProperty("java.vm.specification.version"));
propertiesJson.put("java.vm.vendor", System.getProperty("java.vm.vendor"));
propertiesJson.put("java.vm.version", System.getProperty("java.vm.version"));
report.put(JVM_PROPERTIES_LABEL, propertiesJson.build().asMap());
report.put(JVM_JAVA_VERSION_LABEL, System.getProperty("java.version"));
//Memory
JsonObject memoryJson = JsonValueBuilder.jsonValue();
memoryJson.put(JVM_UNIT_MEMORY_LABEL, FileSizeUnit.MB);
//Getting the runtime reference from system
Runtime runtime = Runtime.getRuntime();
//Print used memory
memoryJson.put(JVM_USED_MEMORY_LABEL, FileSizeUnit.B.toMB(runtime.totalMemory() - runtime.freeMemory()));
//Print free memory
memoryJson.put(JVM_FREE_MEMORY_LABEL, FileSizeUnit.B.toMB(runtime.freeMemory()));
//Print total available memory
memoryJson.put(JVM_TOTAL_MEMORY_LABEL, FileSizeUnit.B.toMB(runtime.totalMemory()));
//Print Maximum available memory
memoryJson.put(JVM_MAX_MEMORY_LABEL, FileSizeUnit.B.toMB(runtime.maxMemory()));
//GNU systems don't support the "sun.arch.data.model" property, so we print both
memoryJson.put(JVM_BIT_SIZE_GNU_LABEL, System.getProperty("sun.arch.data.model"));
memoryJson.put(JVM_BIT_SIZE_LABEL, System.getProperty("os.arch"));
report.put(JVM_MEMORY_LABEL, memoryJson.build().asMap());
return report.build();
}
use of org.forgerock.openam.utils.JsonObject in project OpenAM by OpenRock.
the class RecordReport method getSystemProperties.
/**
* Get the system properties
*
* @return
*/
private JsonValue getSystemProperties() {
JsonObject report = JsonValueBuilder.jsonValue();
Properties sysProps = System.getProperties();
for (String propertyName : sysProps.stringPropertyNames()) {
report.put(propertyName, sysProps.getProperty(propertyName));
}
return report.build();
}
Aggregations