Commit 92926de3 authored by Michael Ritter's avatar Michael Ritter
Browse files

Merge branch 'rest-so' into 'develop'

Rest stackoverflow

This fixes a stackoverflow which was occurring when displaying json for Collections which also had connected PeerCollections. 

It also folds in updates for jackson and jersey.

See merge request !4
parents 8aca7fa3 8a71f3a5
...@@ -117,9 +117,9 @@ ...@@ -117,9 +117,9 @@
<!-- for json --> <!-- for json -->
<dependency> <dependency>
<groupId>org.codehaus.jackson</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-mapper-asl</artifactId> <artifactId>jackson-core</artifactId>
<version>1.8.1</version> <version>2.8.1</version>
</dependency> </dependency>
<dependency> <dependency>
...@@ -243,7 +243,7 @@ ...@@ -243,7 +243,7 @@
</exclusions> </exclusions>
</dependency> --> </dependency> -->
<!-- web services --> <!-- web services
<dependency> <dependency>
<groupId>com.sun.jersey</groupId> <groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId> <artifactId>jersey-server</artifactId>
...@@ -254,6 +254,17 @@ ...@@ -254,6 +254,17 @@
<artifactId>jersey-json</artifactId> <artifactId>jersey-json</artifactId>
<version>1.6</version> <version>1.6</version>
</dependency> </dependency>
-->
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.24</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.24</version>
</dependency>
<dependency> <dependency>
<groupId>edu.umiacs.ace</groupId> <groupId>edu.umiacs.ace</groupId>
<artifactId>ace-ims-ws</artifactId> <artifactId>ace-ims-ws</artifactId>
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
package edu.umiacs.ace.monitor.core; package edu.umiacs.ace.monitor.core;
import com.fasterxml.jackson.annotation.JsonIgnore;
import edu.umiacs.ace.monitor.peers.PeerCollection; import edu.umiacs.ace.monitor.peers.PeerCollection;
import edu.umiacs.util.Argument; import edu.umiacs.util.Argument;
...@@ -50,7 +51,6 @@ import javax.persistence.OneToMany; ...@@ -50,7 +51,6 @@ import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal; import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -79,11 +79,11 @@ import java.util.Map; ...@@ -79,11 +79,11 @@ import java.util.Map;
@NamedQuery(name = "Collection.getCollectionsInGroup", query = @NamedQuery(name = "Collection.getCollectionsInGroup", query =
"SELECT c FROM Collection c WHERE c.group = :group") "SELECT c FROM Collection c WHERE c.group = :group")
}) })
@XmlRootElement
public class Collection implements Serializable { public class Collection implements Serializable {
@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL) @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
private List<PeerCollection> peerCollections; private List<PeerCollection> peerCollections;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @Id
...@@ -134,6 +134,7 @@ public class Collection implements Serializable { ...@@ -134,6 +134,7 @@ public class Collection implements Serializable {
this.peerCollections = peerCollections; this.peerCollections = peerCollections;
} }
@JsonIgnore
public List<PeerCollection> getPeerCollections() { public List<PeerCollection> getPeerCollections() {
return peerCollections; return peerCollections;
} }
......
...@@ -31,15 +31,9 @@ ...@@ -31,15 +31,9 @@
package edu.umiacs.ace.monitor.reporting; package edu.umiacs.ace.monitor.reporting;
import com.sun.jersey.api.MessageException;
import edu.umiacs.ace.monitor.log.LogEnum; import edu.umiacs.ace.monitor.log.LogEnum;
import edu.umiacs.ace.monitor.log.LogEventManager; import edu.umiacs.ace.monitor.log.LogEventManager;
import edu.umiacs.ace.util.PersistUtil; import edu.umiacs.ace.util.PersistUtil;
import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.persistence.EntityManager;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.log4j.NDC; import org.apache.log4j.NDC;
import org.quartz.CronExpression; import org.quartz.CronExpression;
...@@ -48,6 +42,13 @@ import org.quartz.Job; ...@@ -48,6 +42,13 @@ import org.quartz.Job;
import org.quartz.JobExecutionContext; import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException; import org.quartz.JobExecutionException;
import javax.mail.MessagingException;
import javax.persistence.EntityManager;
import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
/** /**
* Report Generation job for quartz * Report Generation job for quartz
* @author toaster * @author toaster
...@@ -90,7 +91,7 @@ public class ReportJob implements Job { ...@@ -90,7 +91,7 @@ public class ReportJob implements Job {
} catch ( ParseException ex ) { } catch ( ParseException ex ) {
LOG.error("Unknown parse exception", ex); LOG.error("Unknown parse exception", ex);
throw new JobExecutionException(ex); throw new JobExecutionException(ex);
} catch ( MessageException ex) { } catch (MessagingException ex) {
EntityManager em = PersistUtil.getEntityManager(); EntityManager em = PersistUtil.getEntityManager();
logManager.persistCollectionEvent(LogEnum.SMTP_ERROR, logManager.persistCollectionEvent(LogEnum.SMTP_ERROR,
ex.getMessage(), em); ex.getMessage(), em);
......
...@@ -31,10 +31,11 @@ ...@@ -31,10 +31,11 @@
package edu.umiacs.ace.remote; package edu.umiacs.ace.remote;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import edu.umiacs.util.Argument; import edu.umiacs.util.Argument;
import java.util.Date; import java.util.Date;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonDeserialize;
@JsonIgnoreProperties(ignoreUnknown=true) @JsonIgnoreProperties(ignoreUnknown=true)
public class AceItem { public class AceItem {
......
...@@ -31,12 +31,13 @@ ...@@ -31,12 +31,13 @@
package edu.umiacs.ace.remote; package edu.umiacs.ace.remote;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import edu.umiacs.util.Strings; import edu.umiacs.util.Strings;
import java.io.IOException; import java.io.IOException;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.DeserializationContext;
import org.codehaus.jackson.map.JsonDeserializer;
/** /**
* *
...@@ -45,7 +46,7 @@ import org.codehaus.jackson.map.JsonDeserializer; ...@@ -45,7 +46,7 @@ import org.codehaus.jackson.map.JsonDeserializer;
public class CustomBooleanDeserializer extends JsonDeserializer<Boolean> { public class CustomBooleanDeserializer extends JsonDeserializer<Boolean> {
@Override @Override
public Boolean deserialize( JsonParser arg0, DeserializationContext arg1 ) public Boolean deserialize(JsonParser arg0, DeserializationContext arg1 )
throws IOException, throws IOException,
JsonProcessingException { JsonProcessingException {
......
...@@ -31,12 +31,13 @@ ...@@ -31,12 +31,13 @@
package edu.umiacs.ace.remote; package edu.umiacs.ace.remote;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import edu.umiacs.util.Strings; import edu.umiacs.util.Strings;
import java.io.IOException; import java.io.IOException;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.DeserializationContext;
import org.codehaus.jackson.map.JsonDeserializer;
/** /**
* *
...@@ -45,7 +46,7 @@ import org.codehaus.jackson.map.JsonDeserializer; ...@@ -45,7 +46,7 @@ import org.codehaus.jackson.map.JsonDeserializer;
public class CustomCharDeserializer extends JsonDeserializer<Character> { public class CustomCharDeserializer extends JsonDeserializer<Character> {
@Override @Override
public Character deserialize( JsonParser arg0, DeserializationContext arg1 ) public Character deserialize(JsonParser arg0, DeserializationContext arg1 )
throws IOException, throws IOException,
JsonProcessingException { JsonProcessingException {
......
...@@ -31,12 +31,13 @@ ...@@ -31,12 +31,13 @@
package edu.umiacs.ace.remote; package edu.umiacs.ace.remote;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import java.io.IOException; import java.io.IOException;
import java.util.Date; import java.util.Date;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.DeserializationContext;
import org.codehaus.jackson.map.JsonDeserializer;
/** /**
* *
...@@ -45,7 +46,7 @@ import org.codehaus.jackson.map.JsonDeserializer; ...@@ -45,7 +46,7 @@ import org.codehaus.jackson.map.JsonDeserializer;
public class CustomDateDeserializer extends JsonDeserializer<Date> { public class CustomDateDeserializer extends JsonDeserializer<Date> {
@Override @Override
public Date deserialize( JsonParser arg0, DeserializationContext arg1 ) throws IOException, public Date deserialize(JsonParser arg0, DeserializationContext arg1 ) throws IOException,
JsonProcessingException { JsonProcessingException {
try { try {
return arg1.parseDate(arg0.getText()); return arg1.parseDate(arg0.getText());
......
...@@ -31,12 +31,13 @@ ...@@ -31,12 +31,13 @@
package edu.umiacs.ace.remote; package edu.umiacs.ace.remote;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import edu.umiacs.util.Strings; import edu.umiacs.util.Strings;
import java.io.IOException; import java.io.IOException;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.DeserializationContext;
import org.codehaus.jackson.map.JsonDeserializer;
/** /**
* *
...@@ -45,7 +46,7 @@ import org.codehaus.jackson.map.JsonDeserializer; ...@@ -45,7 +46,7 @@ import org.codehaus.jackson.map.JsonDeserializer;
public class CustomLongDeserializer extends JsonDeserializer<Long> { public class CustomLongDeserializer extends JsonDeserializer<Long> {
@Override @Override
public Long deserialize( JsonParser arg0, DeserializationContext arg1 ) throws IOException, public Long deserialize(JsonParser arg0, DeserializationContext arg1 ) throws IOException,
JsonProcessingException { JsonProcessingException {
try { try {
if ( Strings.isEmpty(arg1) ) { if ( Strings.isEmpty(arg1) ) {
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
package edu.umiacs.ace.remote; package edu.umiacs.ace.remote;
import com.fasterxml.jackson.databind.DeserializationConfig;
import com.fasterxml.jackson.databind.ObjectMapper;
import edu.umiacs.ace.monitor.peers.PartnerSite; import edu.umiacs.ace.monitor.peers.PartnerSite;
import edu.umiacs.util.Strings; import edu.umiacs.util.Strings;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
...@@ -42,8 +44,6 @@ import org.apache.http.client.methods.HttpGet; ...@@ -42,8 +44,6 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.client.HttpClients;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
...@@ -78,7 +78,7 @@ public class JsonGateway { ...@@ -78,7 +78,7 @@ public class JsonGateway {
mapper = new ObjectMapper(); mapper = new ObjectMapper();
DeserializationConfig cfg = mapper.getDeserializationConfig(); DeserializationConfig cfg = mapper.getDeserializationConfig();
cfg.setDateFormat(new SimpleDateFormat("EEE MMM dd hh:mm:ss zzz yyyy")); cfg.with(new SimpleDateFormat("EEE MMM dd hh:mm:ss zzz yyyy"));
} }
public static final JsonGateway getGateway() { public static final JsonGateway getGateway() {
......
...@@ -31,8 +31,9 @@ ...@@ -31,8 +31,9 @@
package edu.umiacs.ace.remote; package edu.umiacs.ace.remote;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.List; import java.util.List;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
/** /**
* *
......
...@@ -31,10 +31,11 @@ ...@@ -31,10 +31,11 @@
package edu.umiacs.ace.remote; package edu.umiacs.ace.remote;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonDeserialize;
/** /**
* representation of ace report json * representation of ace report json
......
...@@ -30,12 +30,13 @@ ...@@ -30,12 +30,13 @@
// $Id$ // $Id$
package edu.umiacs.ace.remote; package edu.umiacs.ace.remote;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import edu.umiacs.util.Argument; import edu.umiacs.util.Argument;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonDeserialize;
/** /**
* *
......
...@@ -30,15 +30,16 @@ ...@@ -30,15 +30,16 @@
// $Id$ // $Id$
package edu.umiacs.ace.remote; package edu.umiacs.ace.remote;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import edu.umiacs.util.Argument; import edu.umiacs.util.Argument;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.codehaus.jackson.annotate.JsonAnySetter;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonDeserialize;
/** /**
* *
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
package edu.umiacs.ace.rest; package edu.umiacs.ace.rest;
import atg.taglib.json.util.JSONException;
import atg.taglib.json.util.JSONObject;
import edu.umiacs.ace.driver.StorageDriver; import edu.umiacs.ace.driver.StorageDriver;
import edu.umiacs.ace.driver.StorageDriverFactory; import edu.umiacs.ace.driver.StorageDriverFactory;
import edu.umiacs.ace.monitor.access.CollectionCountContext; import edu.umiacs.ace.monitor.access.CollectionCountContext;
...@@ -13,8 +15,6 @@ import edu.umiacs.ace.monitor.core.Collection; ...@@ -13,8 +15,6 @@ import edu.umiacs.ace.monitor.core.Collection;
import edu.umiacs.ace.monitor.core.MonitoredItem; import edu.umiacs.ace.monitor.core.MonitoredItem;
import edu.umiacs.ace.util.PersistUtil; import edu.umiacs.ace.util.PersistUtil;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import javax.annotation.security.RolesAllowed; import javax.annotation.security.RolesAllowed;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
......
...@@ -2,7 +2,6 @@ package edu.umiacs.ace.rest; ...@@ -2,7 +2,6 @@ package edu.umiacs.ace.rest;
import edu.umiacs.ace.monitor.core.Collection; import edu.umiacs.ace.monitor.core.Collection;
import edu.umiacs.ace.util.PersistUtil; import edu.umiacs.ace.util.PersistUtil;
import org.codehaus.jettison.json.JSONArray;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.Query; import javax.persistence.Query;
...@@ -28,11 +27,10 @@ public class ListController { ...@@ -28,11 +27,10 @@ public class ListController {
@GET @GET
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Path("groups") @Path("groups")
public JSONArray getGroups() { public List<String> getGroups() {
EntityManager em = PersistUtil.getEntityManager(); EntityManager em = PersistUtil.getEntityManager();
Query q = em.createNamedQuery("Collection.listGroups"); Query q = em.createNamedQuery("Collection.listGroups");
List<String> groups = q.getResultList(); return q.getResultList();
return new JSONArray(q.getResultList());
} }
/** /**
......
...@@ -82,9 +82,9 @@ ...@@ -82,9 +82,9 @@
</listener> </listener>
<servlet> <servlet>
<servlet-name>ServletAdaptor</servlet-name> <servlet-name>ServletAdaptor</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param> <init-param>
<param-name>com.sun.jersey.config.property.packages</param-name> <param-name>jersey.config.server.provider.packages</param-name>
<param-value>edu.umiacs.ace.rest</param-value> <param-value>edu.umiacs.ace.rest</param-value>
</init-param> </init-param>
<load-on-startup>1</load-on-startup> <load-on-startup>1</load-on-startup>
......
Supports Markdown
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