vidakovic commented on code in PR #5436:
URL: https://github.com/apache/fineract/pull/5436#discussion_r2765614418
##########
fineract-command/src/main/java/org/apache/fineract/command/persistence/converter/JsonNodeReadingConverter.java:
##########
@@ -16,24 +16,29 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.fineract.command.sample.middleware;
+package org.apache.fineract.command.persistence.converter;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.fineract.command.core.Command;
-import org.apache.fineract.command.core.CommandMiddleware;
-import org.apache.fineract.command.sample.command.DummyCommand;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import lombok.SneakyThrows;
+import org.springframework.core.convert.converter.Converter;
+import org.springframework.data.convert.ReadingConverter;
import org.springframework.stereotype.Component;
-@Slf4j
-@RequiredArgsConstructor
@Component
-public class DummyMiddleware implements CommandMiddleware {
+@ReadingConverter
+public class JsonNodeReadingConverter implements Converter<String, JsonNode> {
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ @SneakyThrows
@Override
- public void invoke(Command<?> command) {
- if (command instanceof DummyCommand c) {
- c.getPayload().setId(command.getId());
+ public JsonNode convert(String source) {
+ if (source != null) {
+ return mapper.readTree(source);
}
+
+ // TODO: throw exception?
Review Comment:
Done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]