Commit 5280e7c4 authored by Tom Käsler's avatar Tom Käsler

STASH: Filter applies now

parent 6ff49666
Pipeline #30032 failed with stages
in 50 seconds
package de.thm.arsnova.event;
import com.fasterxml.jackson.annotation.JsonFilter;
import com.fasterxml.jackson.annotation.JsonIgnoreType;
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 de.thm.arsnova.model.Entity;
import de.thm.arsnova.model.serialization.AmqpFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
......@@ -26,8 +27,14 @@ import java.util.Set;
*
*/
@Component
public class EventToTopicPublisher {
@JsonFilter("ampqFilter")
public class AmqpFilter {
}
@JsonIgnoreType
public class MyMixInForIgnoreType {}
private static final Logger logger = LoggerFactory.getLogger(EventToTopicPublisher.class);
......@@ -50,6 +57,7 @@ public class EventToTopicPublisher {
c.applicationEventType = "AfterCreationEvent";
c.attributes.add("id");
c.attributes.add("ownerId");
config.add(c);
}
@EventListener
......@@ -62,15 +70,20 @@ public class EventToTopicPublisher {
if (c.applicationEventType.equals(eventType)) {
String exchangeName = "backend." + entityType.toLowerCase() + "." + eventType.toLowerCase();
ObjectMapper mapper = new ObjectMapper().addMixIn(Object.class, AmqpFilter.class);
ObjectMapper mapper = new ObjectMapper();
mapper.addMixIn(Object.class, AmqpFilter.class);
mapper.addMixIn(org.springframework.core.ResolvableType.class, MyMixInForIgnoreType.class);
SimpleFilterProvider filterProvider = new SimpleFilterProvider();
filterProvider.addFilter("amqpFilter", SimpleBeanPropertyFilter.serializeAllExcept(c.attributes));
filterProvider.addFilter("ampqFilter", SimpleBeanPropertyFilter.serializeAllExcept(c.attributes));
mapper.setFilterProvider(filterProvider);
try {
String t = mapper.writeValueAsString(event);
logger.error("#################");
logger.error(t);
logger.error("#################");
} catch (JsonProcessingException e) {
System.out.println("adsfjklajskdlf lkasdjfkl asdjökfj aölsdj fklas döf");
logger.error(e.getMessage());
}
}
......
......@@ -2,6 +2,6 @@ package de.thm.arsnova.model.serialization;
import com.fasterxml.jackson.annotation.JsonFilter;
@JsonFilter("ampqFilter")
/*@JsonFilter("ampqFilter")
public class AmqpFilter {
}
}*/
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment