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

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
......@@ -22,7 +22,7 @@ import com.yammer.metrics.annotation.Timed;
@Path("variable-group/{groupId}")
@Produces(MediaType.APPLICATION_JSON)
public class VariableGroupResource extends AbstractResource {
public final class VariableGroupResource extends AbstractResource {
public VariableGroupResource(ServerHandler serverHandler) {
super(serverHandler);
......@@ -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();
......
......@@ -20,7 +20,7 @@ import com.yammer.metrics.annotation.Timed;
@Path("/variable/{variableId}")
@Produces(MediaType.APPLICATION_JSON)
public class VariableResource extends AbstractResource{
public final class VariableResource extends AbstractResource{
public VariableResource(ServerHandler serverHandler) {
super(serverHandler);
}
......@@ -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();
......
......@@ -13,12 +13,15 @@ import java.util.Set;
import com.nesstar.api.NotAuthorizedException;
import com.nesstar.api.cube.*;
public class DimensionMaker {
public final class DimensionMaker {
public static final String DIMENSION_TYPE_PLAIN = "plain";
public static final String DIMENSION_TYPE_TEMPORAL = "temporal";
public static final String DIMENSION_TYPE_SPATIAL = "spatial";
private DimensionMaker() {
}
public static Map<String, Object> getDimensionJsonObject(Dimension dimension) throws NotAuthorizedException, IOException {
Map<String, Object> objectmap = new LinkedHashMap<String, Object>();
objectmap.put("id", dimension.getId());
......@@ -31,7 +34,7 @@ public class DimensionMaker {
private static void addDimensionMembersToObjectMap(Dimension dimension, Map<String, Object> objectmap) throws NotAuthorizedException, IOException {
List<Member> memberList = getMembersFromDimension(dimension);
if (memberList.size() > 0) {
if (!memberList.isEmpty()) {
objectmap.put("members", MemberMaker.getMemberJsonObjectList(dimension, memberList));
}
}
......@@ -55,7 +58,7 @@ public class DimensionMaker {
}
private static void addObject(Map<String, Object> objectmap, String id, Collection<String> objects) {
if(objects.size() > 0) {
if(!objects.isEmpty()) {
objectmap.put(id, objects);
}
}
......
......@@ -2,6 +2,8 @@ package com.nesstar.rest.result_object_makers;
import com.nesstar.api.NotAuthorizedException;
import com.nesstar.rest.common.MissingResourceException;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.core.Response;
import java.util.HashMap;
import java.util.LinkedHashMap;
......@@ -20,10 +22,10 @@ public final class ErrorMaker {
static {
errorTypeToErrorCodeMap = new HashMap<ErrorType, Integer>();
errorTypeToErrorCodeMap.put(ErrorType.PERMISSION_DENIED, 401);
errorTypeToErrorCodeMap.put(ErrorType.MISSING_RESOURCE, 404);
errorTypeToErrorCodeMap.put(ErrorType.BAD_REQUEST, 400);
errorTypeToErrorCodeMap.put(ErrorType.UNEXPECTED_ERROR, 500);
errorTypeToErrorCodeMap.put(ErrorType.PERMISSION_DENIED, HttpServletResponse.SC_UNAUTHORIZED);
errorTypeToErrorCodeMap.put(ErrorType.MISSING_RESOURCE, HttpServletResponse.SC_NOT_FOUND);
errorTypeToErrorCodeMap.put(ErrorType.BAD_REQUEST, HttpServletResponse.SC_BAD_REQUEST);
errorTypeToErrorCodeMap.put(ErrorType.UNEXPECTED_ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
private ErrorMaker() {
......
......@@ -12,7 +12,10 @@ import com.nesstar.api.cube.Dimension;
import com.nesstar.api.cube.Hierarchy;
import com.nesstar.api.cube.Level;
public class HierarchyMaker {
public final class HierarchyMaker {
private HierarchyMaker() {
}
public static Map<String, Object> getHierarchyJsonObject(Dimension dimension, Hierarchy hierarchy) throws NotAuthorizedException, IOException {
Map<String, Object> measuremap = new LinkedHashMap<String, Object>();
measuremap.put("root", hierarchy.getRoot().getId());
......
......@@ -10,7 +10,10 @@ import java.util.Map;
import com.nesstar.api.NotAuthorizedException;
import com.nesstar.api.cube.Measure;
public class MeasureMaker {
public final class MeasureMaker {
private MeasureMaker() {
}
public static Map<String, Object> getMeasureJsonObject(Measure measure) throws NotAuthorizedException, IOException {
Map<String, Object> measuremap = new LinkedHashMap<String, Object>();
measuremap.put("id", measure.getId());
......
......@@ -11,7 +11,9 @@ import com.nesstar.api.NotAuthorizedException;
import com.nesstar.api.cube.Dimension;
import com.nesstar.api.cube.Member;
public class MemberMaker {
public final class MemberMaker {
private MemberMaker() {
}
public static Map<String, Object> getMemberJsonObject(Dimension dimension, Member member) throws NotAuthorizedException, IOException {
Map<String, Object> objectmap = new LinkedHashMap<String, Object>();
......
......@@ -27,7 +27,7 @@ public final class SearchResultMaker {
supportedClassJSONNameList.put(VariableGroup.class, "variableGroups");
supportedClassJSONNameList.put(Category.class, "categories");
supportedClassJSONNameList.put(EGMSResource.class, "EGMSResources");
};
}
private SearchResultMaker() {
......
......@@ -25,13 +25,12 @@ public class ETagTest {
String expectedTagValue = "148c8ef4be39449dc56acbc2e0e0b455";
ETag tag = ETag.createETag(url, study, generator);
assertEquals("Tags don't match", expectedTagValue, tag.getValue());
assertTrue("Tags aren't equal", tag.equals(expectedTagValue));
}
@Test
public void testEmptyInput() {
ETag tag = ETag.createETag(url, study, generator);
assertFalse(tag.equals(""));
assertFalse(tag.getValue().isEmpty());
}
@Test
......
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