}
}
} 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());
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;
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
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>();
}
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)
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 {