Class OperationAwarePersistenceHandler

    • Constructor Detail

      • OperationAwarePersistenceHandler

        public OperationAwarePersistenceHandler​(com.fasterxml.jackson.databind.ObjectMapper mapper)
    • Method Detail

      • processStateChange

        public void processStateChange​(com.fasterxml.jackson.databind.JsonNode entityJson)
      • getValidOperationTypeOrThrow

        protected com.broadleafcommerce.data.tracking.core.type.OperationType getValidOperationTypeOrThrow​(com.fasterxml.jackson.databind.JsonNode persistenceMessage)
      • getNonNullField

        protected Optional<com.fasterxml.jackson.databind.JsonNode> getNonNullField​(String fieldName,
                                                                                    com.fasterxml.jackson.databind.JsonNode json)
        Gets the field with the given name from the json and returns an optional containing it if not null.
        Parameters:
        fieldName - the name of the field to get from the json
        json - the json from which the field should be retrieved
        Returns:
        an Optional containing the JsonNode of the field if found and not null, Optional.empty() otherwise
      • getChangeTimestamp

        protected Instant getChangeTimestamp​(com.fasterxml.jackson.databind.JsonNode persistenceMessage)
      • getEntityIdOrThrow

        protected String getEntityIdOrThrow​(com.fasterxml.jackson.databind.JsonNode persistenceMessage)
      • processStateChange

        protected void processStateChange​(@NonNull
                                          @NonNull String entityId,
                                          @NonNull
                                          @NonNull com.broadleafcommerce.data.tracking.core.type.OperationType operationType,
                                          @NonNull
                                          @NonNull Instant changeTimestamp,
                                          @NonNull
                                          @NonNull com.fasterxml.jackson.databind.JsonNode entityJson)
                                   throws IOException
        Throws:
        IOException
      • processCreateOperation

        protected abstract void processCreateOperation​(String entityId,
                                                       Instant changeTimestamp,
                                                       com.fasterxml.jackson.databind.JsonNode entityJson)
                                                throws IOException
        Invoked if the persistence message had an OperationType of OperationType.CREATE.
        Parameters:
        entityId - the ID found on the persistence message. Guaranteed non-empty.
        changeTimestamp - the timestamp found on the persistence message. Guaranteed non-null.
        entityJson - the persistence message json itself. Guaranteed non-null.
        Throws:
        IOException
      • processUpdateOperation

        protected abstract void processUpdateOperation​(String entityId,
                                                       Instant changeTimestamp,
                                                       com.fasterxml.jackson.databind.JsonNode entityJson)
                                                throws IOException
        Invoked if the persistence message had an OperationType of OperationType.UPDATE.
        Parameters:
        entityId - the entity ID found on the persistence message. Guaranteed non-empty.
        changeTimestamp - the timestamp found on the persistence message. Guaranteed non-null.
        entityJson - the persistence message json itself. Guaranteed non-null.
        Throws:
        IOException
      • processDeleteOperation

        protected abstract void processDeleteOperation​(String entityId,
                                                       Instant changeTimestamp,
                                                       com.fasterxml.jackson.databind.JsonNode entityJson)
                                                throws IOException
        Invoked if the persistence message had an OperationType of OperationType.DELETE.
        Parameters:
        entityId - the entity ID found on the persistence message. Guaranteed non-empty.
        changeTimestamp - the timestamp found on the persistence message. Guaranteed non-null.
        entityJson - the persistence message json itself. Guaranteed non-null.
        Throws:
        IOException