comparison src/main/java/de/intevation/lada/rest/InfoService.java @ 293:7c268f742553

Added config to pom to write metadata in the manifest file and send metadata via info service.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 14 Aug 2013 16:12:09 +0200
parents 0ddcc6240d47
children aee36709a8e8
comparison
equal deleted inserted replaced
292:49d0becf3c65 293:7c268f742553
1 package de.intevation.lada.rest; 1 package de.intevation.lada.rest;
2
3 import java.util.List;
2 4
3 import javax.enterprise.context.RequestScoped; 5 import javax.enterprise.context.RequestScoped;
4 import javax.inject.Inject; 6 import javax.inject.Inject;
5 import javax.inject.Named; 7 import javax.inject.Named;
6 import javax.ws.rs.GET; 8 import javax.ws.rs.GET;
10 import javax.ws.rs.core.HttpHeaders; 12 import javax.ws.rs.core.HttpHeaders;
11 import javax.ws.rs.core.UriInfo; 13 import javax.ws.rs.core.UriInfo;
12 14
13 import de.intevation.lada.auth.Authentication; 15 import de.intevation.lada.auth.Authentication;
14 import de.intevation.lada.auth.AuthenticationException; 16 import de.intevation.lada.auth.AuthenticationException;
17 import de.intevation.lada.auth.AuthenticationResponse;
15 18
16 class Info { 19 class Info {
17 String user; 20 String user;
18 String groups; 21 String groups;
19 String version; 22 String version;
76 ) { 79 ) {
77 try { 80 try {
78 if (!authentication.isAuthorizedUser(headers)) { 81 if (!authentication.isAuthorizedUser(headers)) {
79 return new Response(false, 699, null); 82 return new Response(false, 699, null);
80 } 83 }
81 Response response = new Response(true, 200, new Info("-/-", "-/-", "-/-")); 84 String user = authentication.getUserName(headers);
85 AuthenticationResponse ar = authentication.authorizedGroups(headers);
86 List<String> groups = ar.getNetzbetreiber();
87 String gString = "";
88 boolean first = true;
89 for(String g : groups) {
90 if (first) {
91 gString += g;
92 }
93 else {
94 gString += ", " + g;
95 }
96 }
97 //TODO: This is the best way to get the version.
98 // Should read the version from MANIFEST.MF but does not work (returns null).
99 //String version = getClass().getPackage().getImplementationVersion();
100 String version = System.getProperty("de.intevation.lada.server.version");
101
102 Response response = new Response(true, 200, new Info(user, gString, version));
82 return response; 103 return response;
83 } 104 }
84 catch(AuthenticationException ae) { 105 catch(AuthenticationException ae) {
85 return new Response(false, 699, null); 106 return new Response(false, 699, null);
86 } 107 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)