changeset 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 49d0becf3c65
children 422e9ea0276f 512addede0ec
files pom.xml src/main/java/de/intevation/lada/rest/InfoService.java
diffstat 2 files changed, 29 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/pom.xml	Wed Aug 14 16:10:05 2013 +0200
+++ b/pom.xml	Wed Aug 14 16:12:09 2013 +0200
@@ -215,6 +215,13 @@
                     <!-- Java EE 6 doesn't require web.xml, Maven needs to 
                         catch up! -->
                     <failOnMissingWebXml>false</failOnMissingWebXml>
+                    <archive>
+                        <manifest>
+                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+                            <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
+                        </manifest>
+                    </archive>
+                    <archiveClasses>true</archiveClasses>
                 </configuration>
             </plugin>
             <!-- The JBoss AS plugin deploys your war to a local JBoss AS 
--- a/src/main/java/de/intevation/lada/rest/InfoService.java	Wed Aug 14 16:10:05 2013 +0200
+++ b/src/main/java/de/intevation/lada/rest/InfoService.java	Wed Aug 14 16:12:09 2013 +0200
@@ -1,5 +1,7 @@
 package de.intevation.lada.rest;
 
+import java.util.List;
+
 import javax.enterprise.context.RequestScoped;
 import javax.inject.Inject;
 import javax.inject.Named;
@@ -12,6 +14,7 @@
 
 import de.intevation.lada.auth.Authentication;
 import de.intevation.lada.auth.AuthenticationException;
+import de.intevation.lada.auth.AuthenticationResponse;
 
 class Info {
     String user;
@@ -78,7 +81,25 @@
             if (!authentication.isAuthorizedUser(headers)) {
                 return new Response(false, 699, null);
             }
-            Response response = new Response(true, 200, new Info("-/-", "-/-", "-/-"));
+            String user = authentication.getUserName(headers);
+            AuthenticationResponse ar = authentication.authorizedGroups(headers);
+            List<String> groups = ar.getNetzbetreiber();
+            String gString = "";
+            boolean first = true;
+            for(String g : groups) {
+                if (first) {
+                    gString += g;
+                }
+                else {
+                    gString += ", " + g;
+                }
+            }
+            //TODO: This is the best way to get the version.
+            //  Should read the version from MANIFEST.MF but does not work (returns null).
+            //String version = getClass().getPackage().getImplementationVersion();
+            String version = System.getProperty("de.intevation.lada.server.version");
+
+            Response response = new Response(true, 200, new Info(user, gString, version));
             return response;
         }
         catch(AuthenticationException ae) {
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)