Add a MassMail Batch Program
[aaf/authz.git] / auth / auth-gui / src / main / java / org / onap / aaf / auth / gui / pages / CMArtiChangeAction.java
index f67f6d5..06db81c 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -32,7 +32,7 @@ import org.onap.aaf.auth.gui.NamedCode;
 import org.onap.aaf.auth.gui.Page;
 import org.onap.aaf.cadi.CadiException;
 import org.onap.aaf.cadi.client.Future;
-import org.onap.aaf.cadi.client.Holder;
+import org.onap.aaf.cadi.util.Holder;
 import org.onap.aaf.cadi.client.Rcli;
 import org.onap.aaf.cadi.client.Retryable;
 import org.onap.aaf.cadi.util.Vars;
@@ -67,13 +67,13 @@ public class CMArtiChangeAction extends Page {
                 final Slot sOther = gui.env.slot(CMArtiChangeForm.NAME+'.'+CMArtiChangeForm.fields[9]);
                 final Slot sType = gui.env.slot(CMArtiChangeForm.NAME+'.'+CMArtiChangeForm.fields[10]);
                 final Slot sSans = gui.env.slot(CMArtiChangeForm.NAME+'.'+CMArtiChangeForm.fields[11]);
-                
+
                 @Override
                 public void code(final Cache<HTMLGen> cache, final HTMLGen hgen) throws APIException, IOException {
                     cache.dynamic(hgen, new DynamicCode<HTMLGen,AAF_GUI, AuthzTrans>() {
                         @Override
                         public void code(final AAF_GUI gui, final AuthzTrans trans,final Cache<HTMLGen> cache, final HTMLGen hgen) throws APIException, IOException {
-                               trans.info().log("Step 1");
+                            trans.info().log("Step 1");
                             final Artifact arti = new Artifact();
                             final String machine = trans.get(sMachine,null);
                             final String ca = trans.get(sCA, null);
@@ -83,31 +83,31 @@ public class CMArtiChangeAction extends Page {
                                     arti.getSans().add(s);
                                 }
                             }
-                            
+
                             // These checks to not apply to deletions
                             if(!CMArtiChangeForm.DELETE.equals(trans.get(sCmd, ""))) {
-                                   // Disallow IP entries, except by special Permission
-                                   if (!trans.fish(getPerm(ca,"ip"))) {
-                                       boolean ok=true;
-                                       if (IPValidator.ip(machine)) {
-                                           ok=false;
-                                       }
-                                       if (ok) {
-                                           for (String s: arti.getSans()) {
-                                               if (IPValidator.ip(s)) {
-                                                   ok=false;
-                                                   break;
-                                               }
-                                           }
-                                       }
-                                       if (!ok) {
-                                           hgen.p("Policy Failure: IPs in certificates are only allowed by Exception.");
-                                           return;
-                                       }
-                                   }
-                                   
+                                // Disallow IP entries, except by special Permission
+                                if (!trans.fish(getPerm(ca,"ip"))) {
+                                    boolean ok=true;
+                                    if (IPValidator.ip(machine)) {
+                                        ok=false;
+                                    }
+                                    if (ok) {
+                                        for (String s: arti.getSans()) {
+                                            if (IPValidator.ip(s)) {
+                                                ok=false;
+                                                break;
+                                            }
+                                        }
+                                    }
+                                    if (!ok) {
+                                        hgen.p("Policy Failure: IPs in certificates are only allowed by Exception.");
+                                        return;
+                                    }
+                                }
+
                             }
-                            
+
                             arti.setMechid((String)trans.get(sID,null));
                             arti.setMachine(machine);
                             arti.setNs((String)trans.get(sNS,null));
@@ -128,11 +128,11 @@ public class CMArtiChangeAction extends Page {
                                 hgen.p("Data Entry Failure: Please enter a valid ID, including domain.");
                             // VALIDATE OTHERS?
                             } else { // everything else is checked by Server
-                                
+
                                 try {
                                     final Artifacts artifacts = new Artifacts();
                                     artifacts.getArtifact().add(arti);
-                                    final Holder<Boolean> ok = new Holder<Boolean>(false); 
+                                    final Holder<Boolean> ok = new Holder<Boolean>(false);
                                     final Holder<Boolean> deleted = new Holder<Boolean>(false);
                                     Future<?> f = gui.cmClientAsUser(trans.getUserPrincipal(), new Retryable<Future<?>>() {
                                         @Override
@@ -149,7 +149,8 @@ public class CMArtiChangeAction extends Page {
                                                     break;
                                                 case CMArtiChangeForm.UPDATE:
                                                     Future<Artifacts> fu = client.update("/cert/artifacts", gui.artifactsDF, artifacts);
-                                                    if ((rv=fu).get(AAFcli.timeout())) {
+                                                    rv=fu;
+                                                    if(rv.get(AAFcli.timeout())) {
                                                         hgen.p("Artifact " + arti.getMechid() + " on " + arti.getMachine() + " is updated");
                                                         ok.set(true);
                                                     }
@@ -192,18 +193,18 @@ public class CMArtiChangeAction extends Page {
                                                 if(f.body().contains("%") ) {
                                                     hgen.p(Vars.convert(err.getText(),err.getVariables()));
                                                 } else {
-                                                       int colon = err.getText().indexOf(':');
-                                                       if(colon>0) {
-                                                               hgen.p(err.getMessageId() + ": " + err.getText().substring(0, colon));
-                                                               Mark bq = new Mark();
-                                                               hgen.incr(bq,"blockquote");
-                                                               for(String em : Split.splitTrim('\n', err.getText().substring(colon+1))) {
-                                                                       hgen.p(em);
-                                                               }
-                                                               hgen.end(bq);
-                                                       } else {
-                                                               hgen.p(err.getMessageId() + ": " + err.getText());
-                                                       }
+                                                    int colon = err.getText().indexOf(':');
+                                                    if(colon>0) {
+                                                        hgen.p(err.getMessageId() + ": " + err.getText().substring(0, colon));
+                                                        Mark bq = new Mark();
+                                                        hgen.incr(bq,"blockquote");
+                                                        for(String em : Split.splitTrim('\n', err.getText().substring(colon+1))) {
+                                                            hgen.p(em);
+                                                        }
+                                                        hgen.end(bq);
+                                                    } else {
+                                                        hgen.p(err.getMessageId() + ": " + err.getText());
+                                                    }
                                                 }
                                             } else {
                                                 hgen.p(arti.getMechid() + " on " + arti.getMachine() + ": " + f.body());
@@ -221,7 +222,7 @@ public class CMArtiChangeAction extends Page {
                                 hgen.p("Unknown Error");
                                 e.printStackTrace();
                             }
-                                
+
                         }
                         hgen.br();
                     }