Commit 0efab4c8 authored by Noel Alonso's avatar Noel Alonso
Browse files

Mueve método a la base para que sea reutilizado

parent 0c2b289c
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import es.redmic.brokerlib.alert.AlertService;
import es.redmic.brokerlib.avro.common.Event;

public abstract class BaseStreams {

@@ -119,4 +120,18 @@ public abstract class BaseStreams {
			}
		}
	}

	protected boolean isSameSession(Event a, Event b) {

		if (!(a.getSessionId().equals(b.getSessionId()))) {
			String message = "Evento de petición " + b.getType() + " con id de sesión " + b.getSessionId()
					+ ", el cual es diferente al evento de confirmación " + a.getType() + " con id de sesión "
					+ a.getSessionId() + " para item " + b.getAggregateId() + "|" + b.getDate() + " ("
					+ a.getAggregateId() + "|" + a.getDate() + ")";
			logger.error(message);
			alertService.errorAlert(a.getAggregateId(), message);
			return false;
		}
		return true;
	}
}
+0 −14
Original line number Diff line number Diff line
@@ -249,20 +249,6 @@ public abstract class EventSourcingStreams extends BaseStreams {

	protected abstract Event getDeleteCancelledEvent(Event failedEvent, Event lastSuccessEvent);

	protected boolean isSameSession(Event a, Event b) {

		if (!(a.getSessionId().equals(b.getSessionId()))) {
			String message = "Evento de petición " + b.getType() + " con id de sesión " + b.getSessionId()
					+ ", el cual es diferente al evento de confirmación " + a.getType() + " con id de sesión "
					+ a.getSessionId() + " para item " + b.getAggregateId() + "|" + b.getDate() + " ("
					+ a.getAggregateId() + "|" + a.getDate() + ")";
			logger.error(message);
			alertService.errorAlert(a.getAggregateId(), message);
			return false;
		}
		return true;
	}

	@Override
	protected void postProcessStreams() {
	}