Commit 7056f7f5 authored by Ole Voldsæter's avatar Ole Voldsæter
Browse files

code cleanup

parent 7d0d4408
......@@ -10,7 +10,7 @@ public final class OperationRunner {
private OperationRunner() {
}
public static Object runWithExceptionHandling(HttpServletRequest request, Operation operation, ServerHandler serverHandler) {
public static Object runWithExceptionHandling(Operation operation, ServerHandler serverHandler) {
int attempts = 0;
while (true) {
try {
......
......@@ -39,7 +39,7 @@ public class EntityTagFilter implements Filter {
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpServletResponse httpResponse = (HttpServletResponse) response;
if (requestHasETag(httpRequest) && checkForMatchingETag(httpRequest, httpResponse)) {
if (requestHasETag(httpRequest) && checkForMatchingETag(httpRequest)) {
return304Header(httpResponse);
} else {
chain.doFilter(request, response);
......@@ -51,7 +51,7 @@ public class EntityTagFilter implements Filter {
return etag != null && !etag.isEmpty();
}
private boolean checkForMatchingETag(HttpServletRequest request, HttpServletResponse response) {
private boolean checkForMatchingETag(HttpServletRequest request) {
boolean matches = false;
NesstarObject object = getObject(request);
......
......@@ -54,7 +54,7 @@ public class CorrelationResource extends AbstractResource {
final ClassVariables classVariables = new ClassVariables();
return OperationRunner.runWithExceptionHandling(request, new Operation() {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
classVariables.server = serverHandler.getServer();
......
......@@ -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 OperationRunner.runWithExceptionHandling(request, new Operation() {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
classVariables.server = serverHandler.getServer();
......@@ -91,7 +91,7 @@ public class CubeResource extends AbstractResource{
classVariables.values = null;
classVariables.dimensionMemberList = new LinkedHashMap<Dimension, List<Member>>();
return OperationRunner.runWithExceptionHandling(request, new Operation() {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
classVariables.server = serverHandler.getServer();
......
......@@ -2,16 +2,13 @@ package com.nesstar.rest.resources;
import com.nesstar.api.*;
import com.nesstar.api.subset.CaseSubset;
import com.nesstar.api.subset.SubsetSyntaxException;
import com.nesstar.rest.common.*;
import com.yammer.metrics.annotation.Timed;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.util.List;
@Path("study/{studyId}/download")
......@@ -23,9 +20,9 @@ public class DownloadResource extends AbstractResource {
@GET
@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
public Object run() throws Exception {
Server server = serverHandler.getServer();
......
......@@ -56,7 +56,7 @@ public class QueryResource extends AbstractResource {
return ErrorMaker.getBadRequestError("The query must specify at least one included term.");
}
return OperationRunner.runWithExceptionHandling(request, new Operation() {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
Server server = serverHandler.getServer();
......
......@@ -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 OperationRunner.runWithExceptionHandling(request, new Operation() {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
classVariables.server = serverHandler.getServer();
......
......@@ -41,7 +41,7 @@ public class StudyListResource extends AbstractResource {
@GET
@Timed
public Object getStudyList(@Context final HttpServletRequest request, @Context final HttpServletResponse response) {
return OperationRunner.runWithExceptionHandling(request, new Operation() {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
Server server = serverHandler.getServer();
......
......@@ -42,7 +42,7 @@ public class StudyResource extends AbstractResource {
@GET
@Timed
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
public Object run() throws Exception {
com.nesstar.api.Server server = serverHandler.getServer();
......@@ -57,7 +57,7 @@ public class StudyResource extends AbstractResource {
@GET
@Timed
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
public Object run() throws Exception {
com.nesstar.api.Server server = serverHandler.getServer();
......@@ -74,7 +74,7 @@ public class StudyResource extends AbstractResource {
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,
@Context final HttpServletResponse response) {
return OperationRunner.runWithExceptionHandling(request, new Operation() {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
com.nesstar.api.Server server = serverHandler.getServer();
......@@ -91,7 +91,7 @@ public class StudyResource extends AbstractResource {
@Timed
public Object getVariableGroups(@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
public Object run() throws Exception {
Server server = serverHandler.getServer();
......@@ -107,7 +107,7 @@ public class StudyResource extends AbstractResource {
@GET
@Timed
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
public Object run() throws Exception {
Server server = serverHandler.getServer();
......
......@@ -63,7 +63,7 @@ public class TabulateResource extends AbstractResource {
final ClassVariables classVariables = new ClassVariables();
classVariables.categories = new ArrayList<DdiList<Category>>();
return OperationRunner.runWithExceptionHandling(request, new Operation() {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
classVariables.server = serverHandler.getServer();
......
......@@ -27,7 +27,7 @@ public class TranslationResource extends AbstractResource {
@GET
@Timed
public Object getTranslation(@PathParam("languageCode") final String languageCode, @Context final HttpServletRequest request) {
return OperationRunner.runWithExceptionHandling(request, new Operation() {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
String fileName = "MetadataTranslation_" + languageCode + ".json";
......
......@@ -34,7 +34,7 @@ public class VariableGroupResource extends AbstractResource {
public Object getVariables(@PathParam("groupId") final String groupId, @QueryParam("pageNumber") final int pageNumber,
@QueryParam("pageSize") final int pageSize, @Context final HttpServletRequest request,
@Context final HttpServletResponse response) {
return OperationRunner.runWithExceptionHandling(request, new Operation() {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
com.nesstar.api.Server server = serverHandler.getServer();
......@@ -50,7 +50,7 @@ public class VariableGroupResource extends AbstractResource {
@Timed
public Object getChildGroups(@PathParam("groupId") final String groupId, @Context final HttpServletRequest request,
@Context final HttpServletResponse response) {
return OperationRunner.runWithExceptionHandling(request, new Operation() {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
Server server = serverHandler.getServer();
......
......@@ -29,7 +29,7 @@ public class VariableResource extends AbstractResource{
@Timed
public Object getVariableMetadata(@PathParam("variableId") final String variableId, @Context final HttpServletRequest request,
@Context final HttpServletResponse response) {
return OperationRunner.runWithExceptionHandling(request, new Operation() {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
Server server = serverHandler.getServer();
......
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