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