+ private void writeIdentityValuesDTOToJson(JsonWriter writer, IdentityValuesDTO valueDTO) throws IOException {
+ StringBuilder result = new StringBuilder();
+ for (IdentityValue identityValue : valueDTO.getValuesWithNamespaces()) {
+ result.append("/");
+
+ writeModuleNameAndIdentifier(result, identityValue);
+ if (identityValue.getPredicates() != null) {
+ for (Predicate predicate : identityValue.getPredicates()) {
+ IdentityValue identityValuePredicate = predicate.getName();
+ result.append("[");
+ writeModuleNameAndIdentifier(result, identityValuePredicate);
+ result.append("=\"");
+ result.append(predicate.getValue());
+ result.append("\"");
+ result.append("]");
+ }
+ }
+ }
+
+ writer.value(result.toString());
+ }
+
+ private void writeModuleNameAndIdentifier(StringBuilder result, IdentityValue identityValue) {
+ String moduleName = ControllerContext.getInstance().findModuleNameByNamespace(
+ URI.create(identityValue.getNamespace()));
+ if (moduleName != null && !moduleName.isEmpty()) {
+ result.append(moduleName);
+ result.append(":");
+ }
+ result.append(identityValue.getValue());
+ }
+
+ private void writeStringRepresentation(JsonWriter writer, SimpleNode<?> node, TypeDefinition<?> baseType,
+ Class<?> requiredType) throws IOException {
+ Object value = node.getValue();
+ logger.debug("Value of " + baseType.getQName().getNamespace() + ":" + baseType.getQName().getLocalName()
+ + " is not instance of " + requiredType.getClass() + " but is " + node.getValue().getClass());
+ if (value == null) {
+ writer.value("");
+ } else {
+ writer.value(String.valueOf(value));
+ }
+ }
+