Fix Proxy DELETE 40/72140/1
authorInstrumental <jonathan.gathman@att.com>
Wed, 7 Nov 2018 23:36:15 +0000 (17:36 -0600)
committerInstrumental <jonathan.gathman@att.com>
Wed, 7 Nov 2018 23:40:55 +0000 (17:40 -0600)
Issue-ID: AAF-617
Change-Id: I9c9380480eada84cf91effab9330eb0c81770b70
Signed-off-by: Instrumental <jonathan.gathman@att.com>
auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Question.java
auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/CachingFileAccess.java
auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Route.java
auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Routes.java
cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/ArtifactDir.java

index 18b57d8..f55e1c1 100644 (file)
@@ -401,7 +401,13 @@ public class Question {
                     }
                 }
             } else {
-                return Result.err(Status.ERR_NsNotFound,"There is no valid Company Namespace for %s",str);
+                int dot = str.lastIndexOf('.');
+                
+                if (dot < 0) {
+                    return Result.err(Status.ERR_NsNotFound,"There is no valid Company Namespace for %s",str);
+                } else {
+                    return deriveFirstNsForType(trans, str.substring(0, dot),type);
+                }
             }
         }
         return Result.err(Status.ERR_NotFound, str + " does not contain type " + type.name());
index ce87533..fa17f04 100644 (file)
@@ -24,15 +24,12 @@ package org.onap.aaf.auth.rserv;
 
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
 import java.io.FileReader;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
 import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -52,11 +49,9 @@ import java.util.regex.Pattern;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.onap.aaf.misc.env.Env;
 import org.onap.aaf.misc.env.EnvJAXB;
 import org.onap.aaf.misc.env.LogTarget;
 import org.onap.aaf.misc.env.Store;
-import org.onap.aaf.misc.env.TimeTaken;
 import org.onap.aaf.misc.env.Trans;
 /*
  * CachingFileAccess
index b11916e..46a3a95 100644 (file)
@@ -40,13 +40,13 @@ public class Route<TRANS extends Trans> {
     private Match match;
     // package on purpose
     private final TypedCode<TRANS> content;
-    private final boolean isGet;
+    private final boolean isContentType;
     
     public Route(HttpMethods meth, String path) {
         this.path = path;
         auditText = meth.name() + ' ' + path;
         this.meth = meth; // Note: Using Spark def for now.
-        isGet = meth.compareTo(HttpMethods.GET) == 0;
+        isContentType = meth.compareTo(HttpMethods.GET) == 0 || meth.compareTo(HttpMethods.DELETE)==0;
         match = new Match(path);
         content = new TypedCode<TRANS>();
     }
@@ -56,18 +56,12 @@ public class Route<TRANS extends Trans> {
         content.add(code, others);
     }
     
-//    public void add(HttpCode<TRANS,?> code, Class<?> cls, String version, String ... others) {
-//        code.match = match;
-//        content.add(code, cls, version, others);
-//    }
-//
     public HttpCode<TRANS,?> getCode(TRANS trans, HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
         // Type is associated with Accept for GET (since it is what is being returned
         // We associate the rest with ContentType.
         // FYI, thought about this a long time before implementing this way.
         String compare;
-//        String special[]; // todo, expose Charset (in special) to outside
-        if (isGet) {
+        if (isContentType) {
             compare = req.getHeader("Accept"); // Accept is used for read, as we want to agree on what caller is ready to handle
         } else {
             compare = req.getContentType(); // Content type used to declare what data is being created, updated or deleted (might be used for key)
@@ -77,7 +71,7 @@ public class Route<TRANS extends Trans> {
         if (hl==null) {
             resp.setStatus(406); // NOT_ACCEPTABLE
         } else {
-            if (isGet) { // Set Content Type to expected content
+            if (isContentType) { // Set Content Type to expected content
                 if ("*".equals(hl.x) || "*/*".equals(hl.x)) {// if wild-card, then choose first kind of type
                     resp.setContentType(content.first());
                 } else {
index de42e26..ed6326a 100644 (file)
@@ -75,7 +75,6 @@ public class Routes<TRANS extends Trans> {
                 rv = null; // not quite, keep going
             }
         }
-        //TODO a Default?
         return rv;
     }
     
index 6c54709..36ee42d 100644 (file)
@@ -153,8 +153,8 @@ public abstract class ArtifactDir implements PlaceArtifact {
        if(symm==null) {
             if (!f.exists()) {
                 write(f,Chmod.to400,Symm.keygen());
-            } else {
-               System.out.println("Encryptor using " + f.getCanonicalPath());
+//            } else {
+//             System.out.println("Encryptor using " + f.getCanonicalPath());
             }
             symm = Symm.obtain(f); 
             symms.put(f.getCanonicalPath(),symm);