Mercurial > lada > lada-server
view src/main/java/de/intevation/lada/rest/UserService.java @ 1034:61354a9fa58d schema-update
Make dynamic inserts on probe and messung objects to avoid 'not null'-constraint error.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 31 Aug 2016 15:50:54 +0200 |
parents | f5b4784d9173 |
children |
line wrap: on
line source
/* Copyright (C) 2015 by Bundesamt fuer Strahlenschutz * Software engineering by Intevation GmbH * * This file is Free Software under the GNU GPL (v>=3) * and comes with ABSOLUTELY NO WARRANTY! Check out * the documentation coming with IMIS-Labordaten-Application for details. */ package de.intevation.lada.rest; import java.util.Date; import java.util.HashMap; import java.util.Map; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.UriInfo; import de.intevation.lada.util.annotation.AuthorizationConfig; import de.intevation.lada.util.auth.Authorization; import de.intevation.lada.util.auth.AuthorizationType; import de.intevation.lada.util.auth.UserInfo; import de.intevation.lada.util.rest.Response; /** * REST service to get login data for the Lada application. * <p> * This service produces data in the application/json media type. * A typical response holds information about the action performed and the data. * <pre> * <code> * { * "success": [boolean], * "message": [string], * "data":{ * "username": [string], * "servertime": [timestamp], * "roles": [string] * }, * "errors": [object], * "warnings": [object], * "readonly": [boolean], * "totalCount": [number] * } * </code> * </pre> * * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a> */ @Path("rest/user") @RequestScoped public class UserService{ @Inject @AuthorizationConfig(type=AuthorizationType.HEADER) private Authorization authorization; /** * Get login data. * <pre> * <code> * { * "success": [boolean], * "message": [string], * "data": { * "username": [string], * "servertime": [timestamp], * "roles": [string] * }, * "errors": [object], * "warnings": [object], * "readonly": [boolean], * "totalCount": [number] * } * </code> * </pre> * * @return Response object containing login data. */ @GET @Path("/") @Produces("application/json") public Response get( @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest request ) { Map<String, Object> response = new HashMap<String, Object>(); response.put("username", request.getAttribute("lada.user.name")); response.put("roles", request.getAttribute("lada.user.roles")); response.put("servertime", new Date().getTime()); UserInfo userInfo = authorization.getInfo(request); response.put("messstelleLabor", userInfo.getMessLaborId()); response.put("netzbetreiber", userInfo.getNetzbetreiber()); response.put("funktionen", userInfo.getFunktionen()); return new Response(true, 200, response); } }