Commit bfabe1bd by Tuomas Riihimäki

Fix PMS required api returning ArrayList, which for some reason is not supported

anymore. Most likely this was broken when swagger was updated
1 parent 0e601340
Pipeline #8 passed
in 0 seconds
...@@ -144,6 +144,7 @@ public class HostnameFilter implements Filter { ...@@ -144,6 +144,7 @@ public class HostnameFilter implements Filter {
MDC.remove("req.remoteHost"); MDC.remove("req.remoteHost");
MDC.remove("req.eventhost"); MDC.remove("req.eventhost");
} }
private static final String[] NOAUTH_RESTPATHS = new String[]{"/reader/EventRole/", "/user/auth"}; private static final String[] NOAUTH_RESTPATHS = new String[]{"/reader/EventRole/", "/user/auth"};
/** /**
...@@ -166,8 +167,8 @@ public class HostnameFilter implements Filter { ...@@ -166,8 +167,8 @@ public class HostnameFilter implements Filter {
insertServerLoggingContext(httpRequest, authtype); insertServerLoggingContext(httpRequest, authtype);
parseHostname(httpRequest); parseHostname(httpRequest);
Principal principal = httpRequest.getUserPrincipal();
if (httpRequest.getUserPrincipal() == null) { if (principal == null) {
// Check if we are logging in with rest // Check if we are logging in with rest
if (RestApplicationEntrypoint.REST_PATH.equals(httpRequest.getServletPath())) { if (RestApplicationEntrypoint.REST_PATH.equals(httpRequest.getServletPath())) {
authtype = AuthType.REST; authtype = AuthType.REST;
...@@ -191,7 +192,9 @@ public class HostnameFilter implements Filter { ...@@ -191,7 +192,9 @@ public class HostnameFilter implements Filter {
logger.warn("Error logging in as anonymous... ignoring.. ", t); logger.warn("Error logging in as anonymous... ignoring.. ", t);
} }
} }
} else if (!httpRequest.getUserPrincipal().getName().equals(User.ANONYMOUS_LOGINNAME)) { } else if (principal.getName() == null) {
logger.warn("Principal has a null name", principal.toString());
} else if (!principal.getName().equals(User.ANONYMOUS_LOGINNAME)) {
authtype = AuthType.USER; authtype = AuthType.USER;
sessionmgmt.updateSessionUser(httpRequest.getSession().getId(), httpRequest.getUserPrincipal().getName()); sessionmgmt.updateSessionUser(httpRequest.getSession().getId(), httpRequest.getUserPrincipal().getName());
} }
......
package fi.codecrew.moya.rest;
import fi.codecrew.moya.rest.placemap.v1.PlaceCodePojo;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.ArrayList;
import java.util.List;
@XmlRootElement
public class SimpleCodelistRoot {
public SimpleCodelistRoot() {
}
public SimpleCodelistRoot(ArrayList<PlaceCodePojo> ret) {
this.codes = ret;
}
private List<PlaceCodePojo> codes = new ArrayList<>();
public List<PlaceCodePojo> getCodes() {
return codes;
}
public void setCodes(List<PlaceCodePojo> codes) {
this.codes = codes;
}
}
...@@ -13,10 +13,13 @@ import javax.ws.rs.POST; ...@@ -13,10 +13,13 @@ import javax.ws.rs.POST;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.GenericEntity;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder; import javax.ws.rs.core.Response.ResponseBuilder;
import fi.codecrew.moya.rest.ArrayListWrapper;
import fi.codecrew.moya.rest.SimpleCodelistRoot;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -131,11 +134,11 @@ public class PlacemapRestViewV1 { ...@@ -131,11 +134,11 @@ public class PlacemapRestViewV1 {
public SimplePlacelistRoot getAllPlaces(@PathParam("id") Integer mapId) public SimplePlacelistRoot getAllPlaces(@PathParam("id") Integer mapId)
{ {
EventMap map = placebean.findMap(mapId); EventMap map = placebean.findMap(mapId);
return PojoUtils.parseSimplePlaces(map.getPlaces(), null, permbean.hasPermission(UserPermission.VIEW_ALL)); return PojoUtils.parseSimplePlaces(map.getPlaces(), null, permbean.hasPermission(UserPermission.VIEW_ALL));
} }
@GET @GET
@Path("{id}/places") @Path("{id}/places")
public SimplePlacelistRoot getPlaces(@PathParam("id") Integer mapId) public SimplePlacelistRoot getPlaces(@PathParam("id") Integer mapId)
...@@ -250,8 +253,10 @@ public class PlacemapRestViewV1 { ...@@ -250,8 +253,10 @@ public class PlacemapRestViewV1 {
.entity("No enough permissions!") .entity("No enough permissions!")
.build(); .build();
} }
List<PlaceCodePojo> ret = makePlaceCodePojos(placebean.findAllForEvent()); ArrayList<PlaceCodePojo> ret = makePlaceCodePojos(placebean.findAllForEvent());
return Response.ok(ret).build(); GenericEntity<ArrayList<PlaceCodePojo>> list = new GenericEntity<ArrayList<PlaceCodePojo>>(ret) {
};
return Response.ok(list).build();
} }
...@@ -275,7 +280,7 @@ public class PlacemapRestViewV1 { ...@@ -275,7 +280,7 @@ public class PlacemapRestViewV1 {
ArrayList<PlaceCodePojo> ret = makePlaceCodePojos(map.getPlaces()); ArrayList<PlaceCodePojo> ret = makePlaceCodePojos(map.getPlaces());
return Response.ok(ret).build(); return Response.ok(new ArrayListWrapper<>(ret)).build();
} }
......
...@@ -12,6 +12,7 @@ import javax.ws.rs.POST; ...@@ -12,6 +12,7 @@ import javax.ws.rs.POST;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.GenericEntity;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
...@@ -62,7 +63,10 @@ public class VipRestView { ...@@ -62,7 +63,10 @@ public class VipRestView {
sq.setPagesize(0); sq.setPagesize(0);
SearchResult<Vip> result = vipbean.search(sq); SearchResult<Vip> result = vipbean.search(sq);
ArrayList<VipRestPojo> ret = VipRestPojo.create(result.getResults()); ArrayList<VipRestPojo> ret = VipRestPojo.create(result.getResults());
return Response.ok(ret).build(); GenericEntity<ArrayList<VipRestPojo>> list = new GenericEntity<ArrayList<VipRestPojo>>(ret) {
};
return Response.ok(list).build();
} }
@DELETE @DELETE
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!