Source:
protected void writeEntityBody(DirectoryEntry entry, JsonGenerator jg) throws IOException { String directoryName = entry.getDirectoryName(); Directory directory = directoryService.getDirectory(directoryName); String parentDirectoryName = directory.getParentDirectory(); boolean hasParentDirectory = StringUtils.isNotBlank(directory.getParentDirectory()); String schemaName = directory.getSchema(); String passwordField = directory.getPasswordField(); DocumentModel document = entry.getDocumentModel(); jg.writeStringField("directoryName", directoryName); jg.writeStringField("id", document.getId()); Schema schema = schemaManager.getSchema(schemaName); Writer<Property> propertyWriter = registry.getWriter(ctx, Property.class, APPLICATION_JSON_TYPE); jg.writeObjectFieldStart("properties"); Set<String> translated = ctx.getTranslated(ENTITY_TYPE); Set<String> fetched = ctx.getFetched(ENTITY_TYPE); for (Field field : schema.getFields()) { QName fieldName = field.getName(); String key = fieldName.getLocalName(); jg.writeFieldName(key); if (key.equals(passwordField)) { jg.writeString(""); } else { Property property = document.getProperty(fieldName.getPrefixedName()); boolean managed = false; Object value = property.getValue(); if (value instanceof String && StringUtils.isNotEmpty((String) value)) { String valueString = (String) value; String localName = fieldName.getLocalName(); if (fetched.contains(localName)) { try (Closeable resource = ctx.wrap().with(MAX_DEPTH_PARAM, "max").open()) { String dName = PARENT_FIELD_NAME.equals(localName) && hasParentDirectory ? parentDirectoryName : directoryName; managed = writeFetchedValue(jg, dName, localName, valueString); } } else if (translated.contains(localName)) { managed = writeTranslatedValue(jg, localName, valueString); } } if (!managed) { propertyWriter.write(property, Property.class, Property.class, APPLICATION_JSON_TYPE, new OutputStreamWithJsonWriter(jg)); } } } jg.writeEndObject(); }

Target:
protected void writeEntityBody(DirectoryEntry entry, JsonGenerator jg) throws IOException { String directoryName = entry.getDirectoryName(); Directory directory = directoryService.getDirectory(directoryName); String parentDirectoryName = directory.getParentDirectory(); boolean hasParentDirectory = StringUtils.isNotBlank(parentDirectoryName); String schemaName = directory.getSchema(); String passwordField = directory.getPasswordField(); DocumentModel document = entry.getDocumentModel(); jg.writeStringField("directoryName", directoryName); jg.writeStringField("id", document.getId()); Schema schema = schemaManager.getSchema(schemaName); Writer<Property> propertyWriter = registry.getWriter(ctx, Property.class, APPLICATION_JSON_TYPE); jg.writeObjectFieldStart("properties"); Set<String> translated = ctx.getTranslated(ENTITY_TYPE); Set<String> fetched = ctx.getFetched(ENTITY_TYPE); for (Field field : schema.getFields()) { QName fieldName = field.getName(); String key = fieldName.getLocalName(); jg.writeFieldName(key); if (key.equals(passwordField)) { jg.writeString(""); } else { Property property = document.getProperty(fieldName.getPrefixedName()); boolean managed = false; Object value = property.getValue(); if (value instanceof String && StringUtils.isNotEmpty((String) value)) { String valueString = (String) value; String localName = fieldName.getLocalName(); if (fetched.contains(localName)) { try (Closeable resource = ctx.wrap().with(MAX_DEPTH_PARAM, "max").open()) { String dName = PARENT_FIELD_NAME.equals(localName) && hasParentDirectory ? parentDirectoryName : directoryName; managed = writeFetchedValue(jg, dName, localName, valueString); } } else if (translated.contains(localName)) { managed = writeTranslatedValue(jg, localName, valueString); } } if (!managed) { propertyWriter.write(property, Property.class, Property.class, APPLICATION_JSON_TYPE, new OutputStreamWithJsonWriter(jg)); } } } jg.writeEndObject(); }