Loading src/main/java/es/redmic/downloadlib/events/DownloadEventTypes.java 0 → 100644 +31 −0 Original line number Diff line number Diff line package es.redmic.downloadlib.events; public abstract class DownloadEventTypes { public static String // @formatter:off //Download CHECK_DOWNLOAD = "CHECK_DOWNLOAD", DOWNLOAD_CHECKED = "DOWNLOAD_CHECKED", CHECK_DOWLOAD_FAILED = "CHECK_DOWLOAD_FAILED", DOWLOAD_CANCELLED = "DOWLOAD_CANCELLED", PREPARE_DOWNLOAD = "PREPARE_DOWNLOAD", DOWNLOAD_PREPARED = "DOWNLOAD_PREPARED", PREPARE_DOWNLOAD_FAILED = "PREPARE_DOWNLOAD_FAILED", DOWNLOAD = "DOWNLOAD", DOWNLOAD_FAILED = "DOWNLOAD_FAILED", DOWNLOAD_CONFIRMED = "DOWNLOAD_CONFIRMED", DOWNLOADED = "DOWNLOADED"; //@formatter:on public static boolean isLocked(String eventType) { return !(eventType.equals(DOWNLOADED.toString()) || eventType.equals(DOWLOAD_CANCELLED.toString())); } public static boolean isSnapshot(String eventType) { return eventType.equals(DOWNLOADED.toString()); } } src/main/java/es/redmic/downloadlib/events/common/PathEvent.java 0 → 100644 +86 −0 Original line number Diff line number Diff line package es.redmic.downloadlib.events.common; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import com.fasterxml.jackson.annotation.JsonIgnore; import es.redmic.brokerlib.avro.common.Event; public abstract class PathEvent extends Event { private String path; public PathEvent(String type) { super(type); } public String getPath() { return path; } public void setPath(String path) { this.path = path; } @Override public Object get(int field$) { switch (field$) { case 0: return getPath(); case 1: return getAggregateId(); case 2: return getVersion(); case 3: return getType(); case 4: return getDate().getMillis(); case 5: return getSessionId(); case 6: return getUserId(); case 7: return getId(); default: throw new org.apache.avro.AvroRuntimeException("Bad index"); } } @Override public void put(int field$, Object value$) { switch (field$) { case 0: setPath(value$.toString()); break; case 1: setAggregateId(value$.toString()); break; case 2: setVersion((java.lang.Integer) value$); break; case 3: setType(value$.toString()); break; case 4: setDate(new DateTime(value$, DateTimeZone.UTC)); break; case 5: setSessionId(value$.toString()); break; case 6: setUserId(value$.toString()); break; case 7: setId(value$.toString()); break; default: throw new org.apache.avro.AvroRuntimeException("Bad index"); } } @JsonIgnore protected static String getPathEventSchema() { return "{\"name\":\"path\",\"type\":\"string\"}"; } } src/main/java/es/redmic/downloadlib/events/common/QueryEvent.java 0 → 100644 +110 −0 Original line number Diff line number Diff line package es.redmic.downloadlib.events.common; import java.nio.ByteBuffer; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; import es.redmic.brokerlib.avro.common.Event; import es.redmic.exception.common.ExceptionType; import es.redmic.exception.common.InternalException; import es.redmic.models.es.common.query.dto.DataQueryDTO; public abstract class QueryEvent extends Event { @JsonIgnore private ObjectMapper objectMapper = new ObjectMapper(); private ByteBuffer query; public QueryEvent(String type) { super(type); objectMapper.setFilterProvider(new SimpleFilterProvider().setFailOnUnknownId(false).addFilter("DataQueryDTO", SimpleBeanPropertyFilter.serializeAll())); } public ByteBuffer getQuery() { return query; } public void setQuery(ByteBuffer query) { this.query = query; } @JsonIgnore public void setQuery(DataQueryDTO dataQuery) { try { this.query = ByteBuffer.wrap(objectMapper.writeValueAsBytes(dataQuery)); } catch (JsonProcessingException e) { e.printStackTrace(); throw new InternalException(ExceptionType.INTERNAL_EXCEPTION); } } @Override public Object get(int field$) { switch (field$) { case 0: return getQuery(); case 1: return getAggregateId(); case 2: return getVersion(); case 3: return getType(); case 4: return getDate().getMillis(); case 5: return getSessionId(); case 6: return getUserId(); case 7: return getId(); default: throw new org.apache.avro.AvroRuntimeException("Bad index"); } } @Override public void put(int field$, Object value$) { switch (field$) { case 0: query = (ByteBuffer) value$; break; case 1: setAggregateId(value$.toString()); break; case 2: setVersion((java.lang.Integer) value$); break; case 3: setType(value$.toString()); break; case 4: setDate(new DateTime(value$, DateTimeZone.UTC)); break; case 5: setSessionId(value$.toString()); break; case 6: setUserId(value$.toString()); break; case 7: setId(value$.toString()); break; default: throw new org.apache.avro.AvroRuntimeException("Bad index"); } } @JsonIgnore protected static String getQueryEventSchema() { return "{\"name\":\"query\",\"type\":\"bytes\"}"; } } src/main/java/es/redmic/downloadlib/events/common/URLEvent.java 0 → 100644 +86 −0 Original line number Diff line number Diff line package es.redmic.downloadlib.events.common; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import com.fasterxml.jackson.annotation.JsonIgnore; import es.redmic.brokerlib.avro.common.Event; public abstract class URLEvent extends Event { private String url; public URLEvent(String type) { super(type); } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } @Override public Object get(int field$) { switch (field$) { case 0: return getUrl(); case 1: return getAggregateId(); case 2: return getVersion(); case 3: return getType(); case 4: return getDate().getMillis(); case 5: return getSessionId(); case 6: return getUserId(); case 7: return getId(); default: throw new org.apache.avro.AvroRuntimeException("Bad index"); } } @Override public void put(int field$, Object value$) { switch (field$) { case 0: setUrl(value$.toString()); break; case 1: setAggregateId(value$.toString()); break; case 2: setVersion((java.lang.Integer) value$); break; case 3: setType(value$.toString()); break; case 4: setDate(new DateTime(value$, DateTimeZone.UTC)); break; case 5: setSessionId(value$.toString()); break; case 6: setUserId(value$.toString()); break; case 7: setId(value$.toString()); break; default: throw new org.apache.avro.AvroRuntimeException("Bad index"); } } @JsonIgnore protected static String getURLEventSchema() { return "{\"name\":\"url\",\"type\":\"string\"}"; } } src/main/java/es/redmic/downloadlib/events/download/CheckDownloadEvent.java 0 → 100644 +28 −0 Original line number Diff line number Diff line package es.redmic.downloadlib.events.download; import org.apache.avro.Schema; import es.redmic.downloadlib.events.DownloadEventTypes; import es.redmic.downloadlib.events.common.QueryEvent; public class CheckDownloadEvent extends QueryEvent { // @formatter:off public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{" + "\"type\":\"record\",\"name\":\"CheckDownloadEvent\"," + "\"namespace\":\"es.redmic.downloadlib.events.download\",\"fields\":[" + getQueryEventSchema() + "," + getEventBaseSchema() + "]}"); // @formatter:on private static final String type = DownloadEventTypes.CHECK_DOWNLOAD; public CheckDownloadEvent() { super(type); } @Override public Schema getSchema() { return SCHEMA$; } } Loading
src/main/java/es/redmic/downloadlib/events/DownloadEventTypes.java 0 → 100644 +31 −0 Original line number Diff line number Diff line package es.redmic.downloadlib.events; public abstract class DownloadEventTypes { public static String // @formatter:off //Download CHECK_DOWNLOAD = "CHECK_DOWNLOAD", DOWNLOAD_CHECKED = "DOWNLOAD_CHECKED", CHECK_DOWLOAD_FAILED = "CHECK_DOWLOAD_FAILED", DOWLOAD_CANCELLED = "DOWLOAD_CANCELLED", PREPARE_DOWNLOAD = "PREPARE_DOWNLOAD", DOWNLOAD_PREPARED = "DOWNLOAD_PREPARED", PREPARE_DOWNLOAD_FAILED = "PREPARE_DOWNLOAD_FAILED", DOWNLOAD = "DOWNLOAD", DOWNLOAD_FAILED = "DOWNLOAD_FAILED", DOWNLOAD_CONFIRMED = "DOWNLOAD_CONFIRMED", DOWNLOADED = "DOWNLOADED"; //@formatter:on public static boolean isLocked(String eventType) { return !(eventType.equals(DOWNLOADED.toString()) || eventType.equals(DOWLOAD_CANCELLED.toString())); } public static boolean isSnapshot(String eventType) { return eventType.equals(DOWNLOADED.toString()); } }
src/main/java/es/redmic/downloadlib/events/common/PathEvent.java 0 → 100644 +86 −0 Original line number Diff line number Diff line package es.redmic.downloadlib.events.common; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import com.fasterxml.jackson.annotation.JsonIgnore; import es.redmic.brokerlib.avro.common.Event; public abstract class PathEvent extends Event { private String path; public PathEvent(String type) { super(type); } public String getPath() { return path; } public void setPath(String path) { this.path = path; } @Override public Object get(int field$) { switch (field$) { case 0: return getPath(); case 1: return getAggregateId(); case 2: return getVersion(); case 3: return getType(); case 4: return getDate().getMillis(); case 5: return getSessionId(); case 6: return getUserId(); case 7: return getId(); default: throw new org.apache.avro.AvroRuntimeException("Bad index"); } } @Override public void put(int field$, Object value$) { switch (field$) { case 0: setPath(value$.toString()); break; case 1: setAggregateId(value$.toString()); break; case 2: setVersion((java.lang.Integer) value$); break; case 3: setType(value$.toString()); break; case 4: setDate(new DateTime(value$, DateTimeZone.UTC)); break; case 5: setSessionId(value$.toString()); break; case 6: setUserId(value$.toString()); break; case 7: setId(value$.toString()); break; default: throw new org.apache.avro.AvroRuntimeException("Bad index"); } } @JsonIgnore protected static String getPathEventSchema() { return "{\"name\":\"path\",\"type\":\"string\"}"; } }
src/main/java/es/redmic/downloadlib/events/common/QueryEvent.java 0 → 100644 +110 −0 Original line number Diff line number Diff line package es.redmic.downloadlib.events.common; import java.nio.ByteBuffer; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; import es.redmic.brokerlib.avro.common.Event; import es.redmic.exception.common.ExceptionType; import es.redmic.exception.common.InternalException; import es.redmic.models.es.common.query.dto.DataQueryDTO; public abstract class QueryEvent extends Event { @JsonIgnore private ObjectMapper objectMapper = new ObjectMapper(); private ByteBuffer query; public QueryEvent(String type) { super(type); objectMapper.setFilterProvider(new SimpleFilterProvider().setFailOnUnknownId(false).addFilter("DataQueryDTO", SimpleBeanPropertyFilter.serializeAll())); } public ByteBuffer getQuery() { return query; } public void setQuery(ByteBuffer query) { this.query = query; } @JsonIgnore public void setQuery(DataQueryDTO dataQuery) { try { this.query = ByteBuffer.wrap(objectMapper.writeValueAsBytes(dataQuery)); } catch (JsonProcessingException e) { e.printStackTrace(); throw new InternalException(ExceptionType.INTERNAL_EXCEPTION); } } @Override public Object get(int field$) { switch (field$) { case 0: return getQuery(); case 1: return getAggregateId(); case 2: return getVersion(); case 3: return getType(); case 4: return getDate().getMillis(); case 5: return getSessionId(); case 6: return getUserId(); case 7: return getId(); default: throw new org.apache.avro.AvroRuntimeException("Bad index"); } } @Override public void put(int field$, Object value$) { switch (field$) { case 0: query = (ByteBuffer) value$; break; case 1: setAggregateId(value$.toString()); break; case 2: setVersion((java.lang.Integer) value$); break; case 3: setType(value$.toString()); break; case 4: setDate(new DateTime(value$, DateTimeZone.UTC)); break; case 5: setSessionId(value$.toString()); break; case 6: setUserId(value$.toString()); break; case 7: setId(value$.toString()); break; default: throw new org.apache.avro.AvroRuntimeException("Bad index"); } } @JsonIgnore protected static String getQueryEventSchema() { return "{\"name\":\"query\",\"type\":\"bytes\"}"; } }
src/main/java/es/redmic/downloadlib/events/common/URLEvent.java 0 → 100644 +86 −0 Original line number Diff line number Diff line package es.redmic.downloadlib.events.common; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import com.fasterxml.jackson.annotation.JsonIgnore; import es.redmic.brokerlib.avro.common.Event; public abstract class URLEvent extends Event { private String url; public URLEvent(String type) { super(type); } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } @Override public Object get(int field$) { switch (field$) { case 0: return getUrl(); case 1: return getAggregateId(); case 2: return getVersion(); case 3: return getType(); case 4: return getDate().getMillis(); case 5: return getSessionId(); case 6: return getUserId(); case 7: return getId(); default: throw new org.apache.avro.AvroRuntimeException("Bad index"); } } @Override public void put(int field$, Object value$) { switch (field$) { case 0: setUrl(value$.toString()); break; case 1: setAggregateId(value$.toString()); break; case 2: setVersion((java.lang.Integer) value$); break; case 3: setType(value$.toString()); break; case 4: setDate(new DateTime(value$, DateTimeZone.UTC)); break; case 5: setSessionId(value$.toString()); break; case 6: setUserId(value$.toString()); break; case 7: setId(value$.toString()); break; default: throw new org.apache.avro.AvroRuntimeException("Bad index"); } } @JsonIgnore protected static String getURLEventSchema() { return "{\"name\":\"url\",\"type\":\"string\"}"; } }
src/main/java/es/redmic/downloadlib/events/download/CheckDownloadEvent.java 0 → 100644 +28 −0 Original line number Diff line number Diff line package es.redmic.downloadlib.events.download; import org.apache.avro.Schema; import es.redmic.downloadlib.events.DownloadEventTypes; import es.redmic.downloadlib.events.common.QueryEvent; public class CheckDownloadEvent extends QueryEvent { // @formatter:off public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{" + "\"type\":\"record\",\"name\":\"CheckDownloadEvent\"," + "\"namespace\":\"es.redmic.downloadlib.events.download\",\"fields\":[" + getQueryEventSchema() + "," + getEventBaseSchema() + "]}"); // @formatter:on private static final String type = DownloadEventTypes.CHECK_DOWNLOAD; public CheckDownloadEvent() { super(type); } @Override public Schema getSchema() { return SCHEMA$; } }