Commit b85f4f9b authored by Ricco Førgaard's avatar Ricco Førgaard

Merge branch 'master' of prosjekt.nsd.uib.no:nesstar/nesstar-rest-api

Conflicts:
	src/main/java/com/nesstar/rest/NesstarDropService.java
	src/main/java/com/nesstar/rest/common/ETag.java
	src/test/java/com/nesstar/rest/common/ETagTest.java
parents 78777df2 0ba1723d
...@@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; ...@@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.yammer.dropwizard.config.Configuration; import com.yammer.dropwizard.config.Configuration;
import org.hibernate.validator.constraints.NotEmpty; import org.hibernate.validator.constraints.NotEmpty;
public class NesstarDropConfiguration extends Configuration { public final class NesstarDropConfiguration extends Configuration {
@NotEmpty @NotEmpty
@JsonProperty @JsonProperty
private String serverURI; private String serverURI;
......
...@@ -25,8 +25,7 @@ import com.yammer.dropwizard.config.Bootstrap; ...@@ -25,8 +25,7 @@ import com.yammer.dropwizard.config.Bootstrap;
import com.yammer.dropwizard.config.Environment; import com.yammer.dropwizard.config.Environment;
import com.yammer.dropwizard.config.FilterBuilder; import com.yammer.dropwizard.config.FilterBuilder;
public class NesstarDropService extends Service<NesstarDropConfiguration> { public final class NesstarDropService extends Service<NesstarDropConfiguration> {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
new NesstarDropService().run(args); new NesstarDropService().run(args);
} }
......
...@@ -4,7 +4,7 @@ package com.nesstar.rest.common; ...@@ -4,7 +4,7 @@ package com.nesstar.rest.common;
import com.nesstar.api.NesstarObject; import com.nesstar.api.NesstarObject;
import com.nesstar.rest.Version; import com.nesstar.rest.Version;
public class ETag { public final class ETag {
public static final String HEADER_NAME = "ETag"; public static final String HEADER_NAME = "ETag";
private String hash; private String hash;
...@@ -26,12 +26,10 @@ public class ETag { ...@@ -26,12 +26,10 @@ public class ETag {
return false; return false;
} }
public boolean equals(String someEtag) { @Override
if (someEtag != null && !someEtag.isEmpty()) { public int hashCode() {
return someEtag.equalsIgnoreCase(hash); return hash.hashCode();
}
return false;
} }
public static ETag createEtag(String url, NesstarObject object) { public static ETag createEtag(String url, NesstarObject object) {
......
...@@ -4,7 +4,6 @@ import java.io.IOException; ...@@ -4,7 +4,6 @@ import java.io.IOException;
import java.math.BigInteger; import java.math.BigInteger;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import com.nesstar.api.NesstarList; import com.nesstar.api.NesstarList;
...@@ -14,6 +13,7 @@ import com.nesstar.api.NotAuthorizedException; ...@@ -14,6 +13,7 @@ import com.nesstar.api.NotAuthorizedException;
public class ETagGenerator { public class ETagGenerator {
private final String salt; private final String salt;
private final static String ALGORITHM = "MD5"; private final static String ALGORITHM = "MD5";
private static final Date zeroDate = new Date(0l);
public ETagGenerator(String salt) { public ETagGenerator(String salt) {
this.salt = salt; this.salt = salt;
...@@ -46,7 +46,7 @@ public class ETagGenerator { ...@@ -46,7 +46,7 @@ public class ETagGenerator {
} }
private Date getLatestTimestampFromList(NesstarList<NesstarObject> list) throws NotAuthorizedException, IOException { private Date getLatestTimestampFromList(NesstarList<NesstarObject> list) throws NotAuthorizedException, IOException {
Date latest = createDefaultDate(); Date latest = zeroDate;
for (NesstarObject object : list) { for (NesstarObject object : list) {
if (object.getTimeStamp().after(latest)) { if (object.getTimeStamp().after(latest)) {
latest = object.getTimeStamp(); latest = object.getTimeStamp();
...@@ -55,12 +55,6 @@ public class ETagGenerator { ...@@ -55,12 +55,6 @@ public class ETagGenerator {
return latest; return latest;
} }
private Date createDefaultDate() {
Calendar calendar = Calendar.getInstance();
calendar.set(1970, 0, 0, 0, 0);
return calendar.getTime();
}
private String generateChecksum(String id, Date timestamp, String url, String salt) { private String generateChecksum(String id, Date timestamp, String url, String salt) {
String checksum; String checksum;
try { try {
......
...@@ -9,7 +9,7 @@ public abstract class Operation { ...@@ -9,7 +9,7 @@ public abstract class Operation {
public abstract Object run() throws Exception; public abstract Object run() throws Exception;
public boolean tryToRecover(Exception e, ServerHandler serverHandler) { public final boolean tryToRecover(Exception e, ServerHandler serverHandler) {
if (e instanceof NotAuthorizedException) { if (e instanceof NotAuthorizedException) {
try { try {
Server server = serverHandler.getServer(); Server server = serverHandler.getServer();
......
...@@ -10,7 +10,7 @@ public final class OperationRunner { ...@@ -10,7 +10,7 @@ public final class OperationRunner {
private OperationRunner() { private OperationRunner() {
} }
public static Object runWithExceptionHandling(HttpServletRequest request, Operation operation, ServerHandler serverHandler) { public static Object runWithExceptionHandling(Operation operation, ServerHandler serverHandler) {
int attempts = 0; int attempts = 0;
while (true) { while (true) {
try { try {
......
...@@ -23,7 +23,7 @@ import com.nesstar.rest.common.ETag; ...@@ -23,7 +23,7 @@ import com.nesstar.rest.common.ETag;
import com.nesstar.rest.common.ETagGenerator; import com.nesstar.rest.common.ETagGenerator;
import com.nesstar.rest.common.ServerHandler; import com.nesstar.rest.common.ServerHandler;
public class EntityTagFilter implements Filter { public final class EntityTagFilter implements Filter {
private static final String HEADER_NAME = "If-None-Match"; private static final String HEADER_NAME = "If-None-Match";
private ServerHandler serverHandler; private ServerHandler serverHandler;
private ETagGenerator generator = new ETagGenerator(Version.version()); private ETagGenerator generator = new ETagGenerator(Version.version());
...@@ -46,7 +46,7 @@ public class EntityTagFilter implements Filter { ...@@ -46,7 +46,7 @@ public class EntityTagFilter implements Filter {
HttpServletRequest httpRequest = (HttpServletRequest) request; HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpServletResponse httpResponse = (HttpServletResponse) response; HttpServletResponse httpResponse = (HttpServletResponse) response;
if (requestHasETag(httpRequest) && checkForMatchingETag(httpRequest, httpResponse)) { if (requestHasETag(httpRequest) && checkForMatchingETag(httpRequest)) {
return304Header(httpResponse); return304Header(httpResponse);
} else { } else {
chain.doFilter(request, response); chain.doFilter(request, response);
...@@ -58,7 +58,7 @@ public class EntityTagFilter implements Filter { ...@@ -58,7 +58,7 @@ public class EntityTagFilter implements Filter {
return etag != null && !etag.isEmpty(); return etag != null && !etag.isEmpty();
} }
private boolean checkForMatchingETag(HttpServletRequest request, HttpServletResponse response) { private boolean checkForMatchingETag(HttpServletRequest request) {
boolean matches = false; boolean matches = false;
NesstarObject object = getObject(request); NesstarObject object = getObject(request);
...@@ -211,7 +211,7 @@ public class EntityTagFilter implements Filter { ...@@ -211,7 +211,7 @@ public class EntityTagFilter implements Filter {
private boolean etagsMatch(HttpServletRequest request, ETag etag) { private boolean etagsMatch(HttpServletRequest request, ETag etag) {
String etagFromRequest = getEtagFromRequest(request); String etagFromRequest = getEtagFromRequest(request);
return etag.equals(etagFromRequest); return etagFromRequest.equals(etag.getValue());
} }
private String getEtagFromRequest(HttpServletRequest request) { private String getEtagFromRequest(HttpServletRequest request) {
...@@ -232,7 +232,7 @@ public class EntityTagFilter implements Filter { ...@@ -232,7 +232,7 @@ public class EntityTagFilter implements Filter {
} }
private void return304Header(HttpServletResponse response) throws IOException { private void return304Header(HttpServletResponse response) throws IOException {
response.setStatus(304); response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
response.flushBuffer(); response.flushBuffer();
} }
......
...@@ -7,7 +7,7 @@ import javax.servlet.*; ...@@ -7,7 +7,7 @@ import javax.servlet.*;
import java.io.IOException; import java.io.IOException;
import java.util.Locale; import java.util.Locale;
public class LanguageFilter implements Filter { public final class LanguageFilter implements Filter {
@Override @Override
public void init(FilterConfig filterConfig) throws ServletException { public void init(FilterConfig filterConfig) throws ServletException {
......
...@@ -11,7 +11,7 @@ import java.io.IOException; ...@@ -11,7 +11,7 @@ import java.io.IOException;
import static com.yammer.metrics.core.HealthCheck.Result.healthy; import static com.yammer.metrics.core.HealthCheck.Result.healthy;
import static com.yammer.metrics.core.HealthCheck.Result.unhealthy; import static com.yammer.metrics.core.HealthCheck.Result.unhealthy;
public class NesstarHealthCheck extends HealthCheck { public final class NesstarHealthCheck extends HealthCheck {
private ServerHandler serverHandler; private ServerHandler serverHandler;
public NesstarHealthCheck(ServerHandler serverHandler) { public NesstarHealthCheck(ServerHandler serverHandler) {
......
...@@ -8,7 +8,7 @@ import java.io.IOException; ...@@ -8,7 +8,7 @@ import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class CubeRequest { public final class CubeRequest {
private static final Logger LOGGER = LoggerFactory.getLogger(CubeRequest.class); private static final Logger LOGGER = LoggerFactory.getLogger(CubeRequest.class);
private static ObjectMapper objectMapper = new ObjectMapper(); private static ObjectMapper objectMapper = new ObjectMapper();
......
...@@ -7,7 +7,7 @@ import com.nesstar.api.NesstarObject; ...@@ -7,7 +7,7 @@ import com.nesstar.api.NesstarObject;
import com.nesstar.rest.common.ETag; import com.nesstar.rest.common.ETag;
import com.nesstar.rest.common.ServerHandler; import com.nesstar.rest.common.ServerHandler;
public class AbstractResource { class AbstractResource {
protected ServerHandler serverHandler; protected ServerHandler serverHandler;
protected AbstractResource(ServerHandler serverHandler) { protected AbstractResource(ServerHandler serverHandler) {
......
...@@ -28,7 +28,7 @@ import java.util.Map; ...@@ -28,7 +28,7 @@ import java.util.Map;
@Path("study/{studyId}/correlate") @Path("study/{studyId}/correlate")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public class CorrelationResource extends AbstractResource { public final class CorrelationResource extends AbstractResource {
public CorrelationResource(ServerHandler serverHandler) { public CorrelationResource(ServerHandler serverHandler) {
super(serverHandler); super(serverHandler);
...@@ -54,7 +54,7 @@ public class CorrelationResource extends AbstractResource { ...@@ -54,7 +54,7 @@ public class CorrelationResource extends AbstractResource {
final ClassVariables classVariables = new ClassVariables(); final ClassVariables classVariables = new ClassVariables();
return OperationRunner.runWithExceptionHandling(request, new Operation() { return OperationRunner.runWithExceptionHandling(new Operation() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
classVariables.server = serverHandler.getServer(); classVariables.server = serverHandler.getServer();
......
...@@ -38,7 +38,7 @@ import com.yammer.metrics.annotation.Timed; ...@@ -38,7 +38,7 @@ import com.yammer.metrics.annotation.Timed;
@Path("cube/{cubeId}") @Path("cube/{cubeId}")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public class CubeResource extends AbstractResource{ public final class CubeResource extends AbstractResource{
public CubeResource(ServerHandler serverHandler) { public CubeResource(ServerHandler serverHandler) {
super(serverHandler); super(serverHandler);
...@@ -71,7 +71,7 @@ public class CubeResource extends AbstractResource{ ...@@ -71,7 +71,7 @@ public class CubeResource extends AbstractResource{
return ErrorMaker.getBadRequestError("The request must specify at least one break variable or one measure variable."); return ErrorMaker.getBadRequestError("The request must specify at least one break variable or one measure variable.");
} }
return OperationRunner.runWithExceptionHandling(request, new Operation() { return OperationRunner.runWithExceptionHandling(new Operation() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
classVariables.server = serverHandler.getServer(); classVariables.server = serverHandler.getServer();
...@@ -91,7 +91,7 @@ public class CubeResource extends AbstractResource{ ...@@ -91,7 +91,7 @@ public class CubeResource extends AbstractResource{
classVariables.values = null; classVariables.values = null;
classVariables.dimensionMemberList = new LinkedHashMap<Dimension, List<Member>>(); classVariables.dimensionMemberList = new LinkedHashMap<Dimension, List<Member>>();
return OperationRunner.runWithExceptionHandling(request, new Operation() { return OperationRunner.runWithExceptionHandling(new Operation() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
classVariables.server = serverHandler.getServer(); classVariables.server = serverHandler.getServer();
...@@ -140,7 +140,7 @@ public class CubeResource extends AbstractResource{ ...@@ -140,7 +140,7 @@ public class CubeResource extends AbstractResource{
} }
} }
classVariables.dimensionMemberList.put(dimension, members); classVariables.dimensionMemberList.put(dimension, members);
if (members.size() == 0) { if (members.isEmpty()) {
sliceBuilder.addDimension(dimension); sliceBuilder.addDimension(dimension);
} else { } else {
sliceBuilder.addDimension(dimension, members.toArray(new Member[members.size()])); sliceBuilder.addDimension(dimension, members.toArray(new Member[members.size()]));
...@@ -190,7 +190,7 @@ public class CubeResource extends AbstractResource{ ...@@ -190,7 +190,7 @@ public class CubeResource extends AbstractResource{
private double formattedValue(Measure measure, Double value) throws NotAuthorizedException, IOException { private double formattedValue(Measure measure, Double value) throws NotAuthorizedException, IOException {
StringBuilder format = new StringBuilder("%."); StringBuilder format = new StringBuilder("%.");
format.append(getDecimalsForMeasure(measure)).append("f"); format.append(getDecimalsForMeasure(measure)).append("f");
return Double.valueOf(String.format(Locale.US, format.toString(), value)).doubleValue(); return Double.valueOf(String.format(Locale.US, format.toString(), value));
} }
private void setCell(List<Map<String, Object>> dimensionvaluelist, Cell cell, Measure measure) throws IOException, NotAuthorizedException { private void setCell(List<Map<String, Object>> dimensionvaluelist, Cell cell, Measure measure) throws IOException, NotAuthorizedException {
...@@ -212,7 +212,7 @@ public class CubeResource extends AbstractResource{ ...@@ -212,7 +212,7 @@ public class CubeResource extends AbstractResource{
int depth = coords.size(); int depth = coords.size();
Dimension dimension = classVariables.dimensions.get(depth); Dimension dimension = classVariables.dimensions.get(depth);
List<Member> members = classVariables.dimensionMemberList.get(dimension); List<Member> members = classVariables.dimensionMemberList.get(dimension);
if (members == null || members.size() == 0) { if (members == null || members.isEmpty()) {
members = DimensionMaker.getMembersFromDimension(dimension); members = DimensionMaker.getMembersFromDimension(dimension);
} }
for (Member member : members) { for (Member member : members) {
......
...@@ -2,20 +2,17 @@ package com.nesstar.rest.resources; ...@@ -2,20 +2,17 @@ package com.nesstar.rest.resources;
import com.nesstar.api.*; import com.nesstar.api.*;
import com.nesstar.api.subset.CaseSubset; import com.nesstar.api.subset.CaseSubset;
import com.nesstar.api.subset.SubsetSyntaxException;
import com.nesstar.rest.common.*; import com.nesstar.rest.common.*;
import com.yammer.metrics.annotation.Timed; import com.yammer.metrics.annotation.Timed;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.io.IOException;
import java.util.List; import java.util.List;
@Path("study/{studyId}/download") @Path("study/{studyId}/download")
public class DownloadResource extends AbstractResource { public final class DownloadResource extends AbstractResource {
public DownloadResource(ServerHandler serverHandler) { public DownloadResource(ServerHandler serverHandler) {
super(serverHandler); super(serverHandler);
...@@ -23,9 +20,9 @@ public class DownloadResource extends AbstractResource { ...@@ -23,9 +20,9 @@ public class DownloadResource extends AbstractResource {
@GET @GET
@Timed @Timed
public Object download(@QueryParam("var") final List<String> variableIDs, @QueryParam("format") final String fileFormat, @QueryParam("caseSubset") final String caseSubset, @PathParam("studyId") final String studyId, @Context final HttpServletRequest request) throws IOException, MissingResourceException, SubsetSyntaxException, NotAuthorizedException { public Object download(@QueryParam("var") final List<String> variableIDs, @QueryParam("format") final String fileFormat, @QueryParam("caseSubset") final String caseSubset, @PathParam("studyId") final String studyId, @Context final HttpServletRequest request) {
return OperationRunner.runWithExceptionHandling(request, new Operation() { return OperationRunner.runWithExceptionHandling(new Operation() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
Server server = serverHandler.getServer(); Server server = serverHandler.getServer();
......
...@@ -29,7 +29,7 @@ import com.yammer.metrics.annotation.Timed; ...@@ -29,7 +29,7 @@ import com.yammer.metrics.annotation.Timed;
@Path("search") @Path("search")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public class QueryResource extends AbstractResource { public final class QueryResource extends AbstractResource {
private static Map<String, Class<? extends NesstarObject>> supportedReturnTypes; private static Map<String, Class<? extends NesstarObject>> supportedReturnTypes;
public QueryResource(ServerHandler serverHandler) { public QueryResource(ServerHandler serverHandler) {
...@@ -56,7 +56,7 @@ public class QueryResource extends AbstractResource { ...@@ -56,7 +56,7 @@ public class QueryResource extends AbstractResource {
return ErrorMaker.getBadRequestError("The query must specify at least one included term."); return ErrorMaker.getBadRequestError("The query must specify at least one included term.");
} }
return OperationRunner.runWithExceptionHandling(request, new Operation() { return OperationRunner.runWithExceptionHandling(new Operation() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
Server server = serverHandler.getServer(); Server server = serverHandler.getServer();
......
...@@ -29,7 +29,7 @@ import java.util.Map; ...@@ -29,7 +29,7 @@ import java.util.Map;
@Path("study/{studyId}/regress") @Path("study/{studyId}/regress")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public class RegressionResource extends AbstractResource { public final class RegressionResource extends AbstractResource {
public RegressionResource(ServerHandler serverHandler) { public RegressionResource(ServerHandler serverHandler) {
super(serverHandler); super(serverHandler);
...@@ -61,7 +61,7 @@ public class RegressionResource extends AbstractResource { ...@@ -61,7 +61,7 @@ public class RegressionResource extends AbstractResource {
return ErrorMaker.getBadRequestError("The request must specify a dependent variable and at least 1 independent variables."); return ErrorMaker.getBadRequestError("The request must specify a dependent variable and at least 1 independent variables.");
} }
return OperationRunner.runWithExceptionHandling(request, new Operation() { return OperationRunner.runWithExceptionHandling(new Operation() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
classVariables.server = serverHandler.getServer(); classVariables.server = serverHandler.getServer();
......
...@@ -32,7 +32,7 @@ import com.yammer.metrics.annotation.Timed; ...@@ -32,7 +32,7 @@ import com.yammer.metrics.annotation.Timed;
@Path("/studies") @Path("/studies")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public class StudyListResource extends AbstractResource { public final class StudyListResource extends AbstractResource {
public StudyListResource(ServerHandler serverHandler) { public StudyListResource(ServerHandler serverHandler) {
super(serverHandler); super(serverHandler);
...@@ -41,7 +41,7 @@ public class StudyListResource extends AbstractResource { ...@@ -41,7 +41,7 @@ public class StudyListResource extends AbstractResource {
@GET @GET
@Timed @Timed
public Object getStudyList(@Context final HttpServletRequest request, @Context final HttpServletResponse response) { public Object getStudyList(@Context final HttpServletRequest request, @Context final HttpServletResponse response) {
return OperationRunner.runWithExceptionHandling(request, new Operation() { return OperationRunner.runWithExceptionHandling(new Operation() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
Server server = serverHandler.getServer(); Server server = serverHandler.getServer();
......
...@@ -31,15 +31,18 @@ import com.yammer.metrics.annotation.Timed; ...@@ -31,15 +31,18 @@ import com.yammer.metrics.annotation.Timed;
@Path("study/{studyId}") @Path("study/{studyId}")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public class StudyResource extends AbstractResource { public final class StudyResource extends AbstractResource {
public static final String STUDY_ID_PARAM_NAME = "studyId";
public StudyResource(ServerHandler serverHandler) { public StudyResource(ServerHandler serverHandler) {
super(serverHandler); super(serverHandler);
} }
@GET @GET
@Timed @Timed
public Object getMetadata(@PathParam("studyId") final String studyId, @Context final HttpServletRequest request, @Context final HttpServletResponse response) { public Object getMetadata(@PathParam(STUDY_ID_PARAM_NAME) final String studyId, @Context final HttpServletRequest request, @Context final HttpServletResponse response) {
return OperationRunner.runWithExceptionHandling(request, new Operation() { return OperationRunner.runWithExceptionHandling(new Operation() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
com.nesstar.api.Server server = serverHandler.getServer(); com.nesstar.api.Server server = serverHandler.getServer();
...@@ -53,8 +56,8 @@ public class StudyResource extends AbstractResource { ...@@ -53,8 +56,8 @@ public class StudyResource extends AbstractResource {
@Path("all-metadata") @Path("all-metadata")
@GET @GET
@Timed @Timed
public Object getAllMetadata(@PathParam("studyId") final String studyId, @Context final HttpServletRequest request, @Context final HttpServletResponse response) { public Object getAllMetadata(@PathParam(STUDY_ID_PARAM_NAME) final String studyId, @Context final HttpServletRequest request, @Context final HttpServletResponse response) {
return OperationRunner.runWithExceptionHandling(request, new Operation() { return OperationRunner.runWithExceptionHandling(new Operation() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
com.nesstar.api.Server server = serverHandler.getServer(); com.nesstar.api.Server server = serverHandler.getServer();
...@@ -68,10 +71,10 @@ public class StudyResource extends AbstractResource { ...@@ -68,10 +71,10 @@ public class StudyResource extends AbstractResource {
@Path("/variables") @Path("/variables")
@GET @GET
@Timed @Timed
public Object getVariables(@PathParam("studyId") final String studyId, @QueryParam("pageNumber") final int pageNumber, public Object getVariables(@PathParam(STUDY_ID_PARAM_NAME) final String studyId, @QueryParam("pageNumber") final int pageNumber,
@QueryParam("pageSize") final int pageSize, @Context final HttpServletRequest request, @QueryParam("pageSize") final int pageSize, @Context final HttpServletRequest request,
@Context final HttpServletResponse response) { @Context final HttpServletResponse response) {
return OperationRunner.runWithExceptionHandling(request, new Operation() { return OperationRunner.runWithExceptionHandling(new Operation() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
com.nesstar.api.Server server = serverHandler.getServer(); com.nesstar.api.Server server = serverHandler.getServer();
...@@ -86,9 +89,9 @@ public class StudyResource extends AbstractResource { ...@@ -86,9 +89,9 @@ public class StudyResource extends AbstractResource {
@Path("/variable-groups") @Path("/variable-groups")
@GET @GET
@Timed @Timed
public Object getVariableGroups(@PathParam("studyId") final String studyId, @Context final HttpServletRequest request, public Object getVariableGroups(@PathParam(STUDY_ID_PARAM_NAME) final String studyId, @Context final HttpServletRequest request,
@Context final HttpServletResponse response) { @Context final HttpServletResponse response) {
return OperationRunner.runWithExceptionHandling(request, new Operation() { return OperationRunner.runWithExceptionHandling(new Operation() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
Server server = serverHandler.getServer(); Server server = serverHandler.getServer();
...@@ -103,8 +106,8 @@ public class StudyResource extends AbstractResource { ...@@ -103,8 +106,8 @@ public class StudyResource extends AbstractResource {
@Path("/updated-time-stamp") @Path("/updated-time-stamp")
@GET @GET
@Timed @Timed
public Object getUpdatedTimeStamp(@PathParam("studyId") final String studyId, @Context final HttpServletRequest request) { public Object getUpdatedTimeStamp(@PathParam(STUDY_ID_PARAM_NAME) final String studyId, @Context final HttpServletRequest request) {
return OperationRunner.runWithExceptionHandling(request, new Operation() { return OperationRunner.runWithExceptionHandling(new Operation() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
Server server = serverHandler.getServer(); Server server = serverHandler.getServer();
......
...@@ -30,7 +30,7 @@ import com.yammer.metrics.annotation.Timed; ...@@ -30,7 +30,7 @@ import com.yammer.metrics.annotation.Timed;
@Path("study/{studyId}/tabulate") @Path("study/{studyId}/tabulate")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public class TabulateResource extends AbstractResource { public final class TabulateResource extends AbstractResource {
public TabulateResource(ServerHandler serverHandler) { public TabulateResource(ServerHandler serverHandler) {
super(serverHandler); super(serverHandler);
} }
...@@ -63,7 +63,7 @@ public class TabulateResource extends AbstractResource { ...@@ -63,7 +63,7 @@ public class TabulateResource extends AbstractResource {
final ClassVariables classVariables = new ClassVariables(); final ClassVariables classVariables = new ClassVariables();
classVariables.categories = new ArrayList<DdiList<Category>>(); classVariables.categories = new ArrayList<DdiList<Category>>();
return OperationRunner.runWithExceptionHandling(request, new Operation() { return OperationRunner.runWithExceptionHandling(new Operation() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
classVariables.server = serverHandler.getServer(); classVariables.server = serverHandler.getServer();
......
...@@ -19,7 +19,7 @@ import java.util.Scanner; ...@@ -19,7 +19,7 @@ import java.util.Scanner;
@Path("metadata-translation/{languageCode}") @Path("metadata-translation/{languageCode}")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public class TranslationResource extends AbstractResource { public final class TranslationResource extends AbstractResource {
public TranslationResource(ServerHandler serverHandler) { public TranslationResource(ServerHandler serverHandler) {
super(serverHandler); super(serverHandler);
} }
...@@ -27,7 +27,7 @@ public class TranslationResource extends AbstractResource { ...@@ -27,7 +27,7 @@ public class TranslationResource extends AbstractResource {
@GET @GET
@Timed @Timed
public Object getTranslation(@PathParam("languageCode") final String languageCode, @Context final HttpServletRequest request) { public Object getTranslation(@PathParam("languageCode") final String languageCode, @Context final HttpServletRequest request) {