custom object mapper movedl in the model. Minor repackaging
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/social-networking/social-networking-service-model@163385 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
f80d19ffc4
commit
6bc3dc0852
|
@ -0,0 +1,36 @@
|
||||||
|
package org.gcube.portal.social.networking.model.providers;
|
||||||
|
|
||||||
|
import javax.ws.rs.ext.ContextResolver;
|
||||||
|
import javax.ws.rs.ext.Provider;
|
||||||
|
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
|
||||||
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom mapper with property CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES to perform serialization/deserialization
|
||||||
|
* with snake case over camel case for json beans.
|
||||||
|
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||||
|
*/
|
||||||
|
@Provider
|
||||||
|
public class CustomObjectMapper implements ContextResolver<ObjectMapper> {
|
||||||
|
|
||||||
|
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(CustomObjectMapper.class);
|
||||||
|
private final ObjectMapper mapper;
|
||||||
|
|
||||||
|
public CustomObjectMapper() {
|
||||||
|
logger.debug("new ObjectMapperResolver()");
|
||||||
|
mapper = new ObjectMapper();
|
||||||
|
mapper.enable(SerializationFeature.INDENT_OUTPUT);
|
||||||
|
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectMapper getContext(Class<?> type) {
|
||||||
|
logger.debug("ObjectMapperResolver.getContext(...) invoked");
|
||||||
|
return mapper;
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,7 @@ import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
import org.gcube.portal.databook.shared.JobStatusType;
|
import org.gcube.portal.databook.shared.JobStatusType;
|
||||||
import org.gcube.portal.databook.shared.RunningJob;
|
import org.gcube.portal.databook.shared.RunningJob;
|
||||||
import org.gcube.portal.socialnetworking.custom.serializers_deserializers.JobStatusTypeDeserializer;
|
import org.gcube.portal.socialnetworking.model.custom.serializers_deserializers.JobStatusTypeDeserializer;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.gcube.portal.socialnetworking.custom.serializers_deserializers;
|
package org.gcube.portal.socialnetworking.model.custom.serializers_deserializers;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
Loading…
Reference in New Issue