Remove Tabs, per Jococo
[aaf/authz.git] / auth / auth-gui / src / main / java / org / onap / aaf / auth / gui / AAF_GUI.java
index 064a8a5..e1870e9 100644 (file)
@@ -26,6 +26,9 @@ import static org.onap.aaf.auth.rserv.HttpMethods.POST;
 import static org.onap.aaf.auth.rserv.HttpMethods.PUT;
 
 import javax.servlet.Filter;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 
 import org.onap.aaf.auth.cmd.Cmd;
 import org.onap.aaf.auth.cui.CUI;
@@ -40,6 +43,7 @@ import org.onap.aaf.auth.gui.pages.CMArtiChangeAction;
 import org.onap.aaf.auth.gui.pages.CMArtiChangeForm;
 import org.onap.aaf.auth.gui.pages.CMArtifactShow;
 import org.onap.aaf.auth.gui.pages.CredDetail;
+import org.onap.aaf.auth.gui.pages.CredHistory;
 import org.onap.aaf.auth.gui.pages.Home;
 import org.onap.aaf.auth.gui.pages.LoginLanding;
 import org.onap.aaf.auth.gui.pages.LoginLandingAction;
@@ -66,6 +70,7 @@ import org.onap.aaf.auth.gui.pages.UserRoleExtend;
 import org.onap.aaf.auth.gui.pages.UserRoleRemove;
 import org.onap.aaf.auth.gui.pages.WebCommand;
 import org.onap.aaf.auth.rserv.CachingFileAccess;
+import org.onap.aaf.auth.rserv.HttpCode;
 import org.onap.aaf.auth.server.AbsService;
 import org.onap.aaf.auth.server.JettyServiceStarter;
 import org.onap.aaf.auth.server.Log4JLogIt;
@@ -94,7 +99,7 @@ import certman.v1_0.Artifacts;
 import certman.v1_0.CertInfo;
 
 public class AAF_GUI extends AbsService<AuthzEnv, AuthzTrans> implements State<Env>{
-    private static final String AAF_GUI_THEME = "aaf_gui_theme";
+    public static final String AAF_GUI_THEME = "aaf_gui_theme";
     public static final String AAF_GUI_COPYRIGHT = "aaf_gui_copyright";
     public static final String HTTP_SERVLET_REQUEST = "HTTP_SERVLET_REQUEST";
     public static final int TIMEOUT = 60000;
@@ -113,22 +118,26 @@ public class AAF_GUI extends AbsService<AuthzEnv, AuthzTrans> implements State<E
     public final Slot slot_httpServletRequest;
     protected final String deployedVersion;
     private StaticSlot sThemeWebPath;
-    public final String theme;
+    private StaticSlot sDefaultTheme;
 
 
     public AAF_GUI(final AuthzEnv env) throws Exception {
         super(env.access(), env);
-        theme = env.getProperty(AAF_GUI_THEME,"theme/onap");
+        sDefaultTheme = env.staticSlot(AAF_GUI_THEME);
+        String defTheme = env.getProperty(AAF_GUI_THEME,"onap");
+        env.put(sDefaultTheme, defTheme);
+        
         sThemeWebPath = env.staticSlot(CachingFileAccess.CFA_WEB_PATH);
         if(env.get(sThemeWebPath)==null) {
-               env.put(sThemeWebPath,theme);
+            env.put(sThemeWebPath,"theme");
         }
-
+        
         slot_httpServletRequest = env.slot(HTTP_SERVLET_REQUEST);
-        deployedVersion = access.getProperty(Config.AAF_RELEASE, "N/A:2.x");
+        deployedVersion = app_version;
 
         // Certificate Manager
-        cmCon =  new AAFConHttp(env.access(),Config.AAF_URL_CM);
+        String aaf_url_cm = env.getProperty(Config.AAF_URL_CM,Config.AAF_URL_CM_DEF);
+        cmCon =  new AAFConHttp(env.access(),aaf_url_cm);
         artifactsDF = env.newDataFactory(Artifacts.class);
         certInfoDF  = env.newDataFactory(CertInfo.class);
         
@@ -153,8 +162,9 @@ public class AAF_GUI extends AbsService<AuthzEnv, AuthzTrans> implements State<E
         // MyNameSpace
         final Page myNamespaces = new Display(this, GET, new NssShow(this, start)).page();
         Page nsDetail  = new Display(this, GET, new NsDetail(this, start, myNamespaces)).page();
-                              new Display(this, GET, new NsHistory(this, start,myNamespaces,nsDetail));
+                         new Display(this, GET, new NsHistory(this, start,myNamespaces,nsDetail));
         Page crdDetail = new Display(this, GET, new CredDetail(this, start, myNamespaces, nsDetail)).page();
+                         new Display(this, GET, new CredHistory(this,start,myNamespaces,nsDetail,crdDetail));
         Page artiShow  = new Display(this, GET, new CMArtifactShow(this, start, myNamespaces, nsDetail, crdDetail)).page();
         Page artiCForm = new Display(this, GET, new CMArtiChangeForm(this, start, myNamespaces, nsDetail, crdDetail,artiShow)).page();
                          new Display(this, POST, new CMArtiChangeAction(this, start,artiShow,artiCForm));
@@ -200,10 +210,29 @@ public class AAF_GUI extends AbsService<AuthzEnv, AuthzTrans> implements State<E
         // Command line Mechanism
         route(env, PUT, "/gui/cui", new CUI(this),"text/plain;charset=utf-8","*/*");
         
+        route(env, GET, "/gui/clear", new HttpCode<AuthzTrans, Void>(null, "Clear"){
+            @Override
+            public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
+                trans.clearCache();
+                Cookie cookies[] = req.getCookies();
+                if(cookies!=null) {
+                    for(Cookie c : cookies) {
+                        if(c.getName().startsWith("aaf.gui.")) {
+                            c.setMaxAge(0);
+                            resp.addCookie(c);
+                        }
+                    }
+                }
+                resp.sendRedirect("/gui/home");
+            }
+        }, "text/plain;charset=utf-8","*/*");
+        
         ///////////////////////  
         // WebContent Handler
         ///////////////////////
-        route(env,GET,"/"+env.get(sThemeWebPath)+"/:key", new CachingFileAccess<AuthzTrans>(env));
+        CachingFileAccess<AuthzTrans> cfa = new CachingFileAccess<AuthzTrans>(env);
+        //route(env,GET,"/"+env.get(sThemeWebPath)+"/:key*", cfa);
+        route(env,GET,"/theme/:key*", cfa);
         ///////////////////////
         aafCon = aafCon();
         lur = aafCon.newLur();
@@ -256,9 +285,13 @@ public class AAF_GUI extends AbsService<AuthzEnv, AuthzTrans> implements State<E
             Log4JLogIt logIt = new Log4JLogIt(args, "gui");
             PropAccess propAccess = new PropAccess(logIt,args);
 
-            AAF_GUI service = new AAF_GUI(new AuthzEnv(propAccess));
-            JettyServiceStarter<AuthzEnv,AuthzTrans> jss = new JettyServiceStarter<AuthzEnv,AuthzTrans>(service);
-            jss.start();
+            try {
+                new JettyServiceStarter<AuthzEnv,AuthzTrans>(
+                    new AAF_GUI(new AuthzEnv(propAccess)),true)
+                        .start();
+            } catch (Exception e) {
+                propAccess.log(e);
+            }
         } catch (Exception e) {
             e.printStackTrace();
         }