[DEV] error path
This commit is contained in:
parent
9c8cdc2b50
commit
6ecaed9e5f
@ -1,10 +1,12 @@
|
||||
package org.kar.oauth.api;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.security.PermitAll;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.CacheControl;
|
||||
import javax.ws.rs.core.PathSegment;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.ResponseBuilder;
|
||||
|
||||
@ -19,34 +21,39 @@ public class Front {
|
||||
return "";
|
||||
}
|
||||
private Response retrive(String fileName) throws Exception {
|
||||
String filePathName = ConfigVariable.getFrontFolder() + File.separator + fileName;
|
||||
String filePathName = ConfigVariable.getSsoFolder() + File.separator + fileName;
|
||||
String extention = getExtension(filePathName);
|
||||
String mineType = null;
|
||||
if (extention.equalsIgnoreCase("jpg") || extention.equalsIgnoreCase("jpeg")) {
|
||||
mineType = "image/jpeg";
|
||||
} else if (extention.equalsIgnoreCase("gif")) {
|
||||
mineType = "image/gif";
|
||||
} else if (extention.equalsIgnoreCase("png")) {
|
||||
mineType = "image/png";
|
||||
} else if (extention.equalsIgnoreCase("svg")) {
|
||||
mineType = "image/svg+xml";
|
||||
} else if (extention.equalsIgnoreCase("webp")) {
|
||||
mineType = "image/webp";
|
||||
} else if (extention.equalsIgnoreCase("js")) {
|
||||
mineType = "application/javascript";
|
||||
} else if (extention.equalsIgnoreCase("json")) {
|
||||
mineType = "application/json";
|
||||
} else if (extention.equalsIgnoreCase("ico")) {
|
||||
mineType = "image/x-icon";
|
||||
} else if (extention.equalsIgnoreCase("html")) {
|
||||
mineType = "text/html";
|
||||
} else if (extention.equalsIgnoreCase("css")) {
|
||||
mineType = "text/css";
|
||||
if (!extention.isEmpty()) {
|
||||
if (extention.equalsIgnoreCase("jpg") || extention.equalsIgnoreCase("jpeg")) {
|
||||
mineType = "image/jpeg";
|
||||
} else if (extention.equalsIgnoreCase("gif")) {
|
||||
mineType = "image/gif";
|
||||
} else if (extention.equalsIgnoreCase("png")) {
|
||||
mineType = "image/png";
|
||||
} else if (extention.equalsIgnoreCase("svg")) {
|
||||
mineType = "image/svg+xml";
|
||||
} else if (extention.equalsIgnoreCase("webp")) {
|
||||
mineType = "image/webp";
|
||||
} else if (extention.equalsIgnoreCase("js")) {
|
||||
mineType = "application/javascript";
|
||||
} else if (extention.equalsIgnoreCase("json")) {
|
||||
mineType = "application/json";
|
||||
} else if (extention.equalsIgnoreCase("ico")) {
|
||||
mineType = "image/x-icon";
|
||||
} else if (extention.equalsIgnoreCase("html")) {
|
||||
mineType = "text/html";
|
||||
} else if (extention.equalsIgnoreCase("css")) {
|
||||
mineType = "text/css";
|
||||
} else {
|
||||
return Response.status(403).
|
||||
entity("Not supported model: '" + fileName + "'").
|
||||
type("text/plain").
|
||||
build();
|
||||
}
|
||||
} else {
|
||||
return Response.status(403).
|
||||
entity("Not supported model: '" + fileName + "'").
|
||||
type("text/plain").
|
||||
build();
|
||||
mineType = "text/html";
|
||||
filePathName = "index.html";
|
||||
}
|
||||
// reads input image
|
||||
File download = new File(filePathName);
|
||||
@ -67,35 +74,28 @@ public class Front {
|
||||
|
||||
return response.build();
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@PermitAll()
|
||||
//@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
//@CacheMaxAge(time = 10, unit = TimeUnit.DAYS)
|
||||
//@CacheMaxAge(time = 1, unit = TimeUnit.DAYS)
|
||||
public Response retrive0() throws Exception {
|
||||
return retrive("index.html");
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@Path("{baseA}")
|
||||
@Path("{any: .*}")
|
||||
@PermitAll()
|
||||
//@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
//@CacheMaxAge(time = 10, unit = TimeUnit.DAYS)
|
||||
public Response retrive1(@PathParam("baseA") String baseA) throws Exception {
|
||||
return retrive(baseA);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("assets/images/{baseB}")
|
||||
@PermitAll()
|
||||
public Response retrive2(@PathParam("baseB") String baseB) throws Exception {
|
||||
return retrive("assets" + File.separator + "images" + File.separator + baseB);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("assets/js_3rd_party/{baseB}")
|
||||
@PermitAll()
|
||||
public Response retrive3(@PathParam("baseB") String baseB) throws Exception {
|
||||
return retrive("assets" + File.separator + "js_3rd_party" + File.separator + baseB);
|
||||
public Response retrive1(@PathParam("any") List<PathSegment> segments) throws Exception {
|
||||
String filename = "";
|
||||
for (PathSegment elem: segments) {
|
||||
if (!filename.isEmpty()) {
|
||||
filename += File.separator;
|
||||
}
|
||||
filename += elem.getPath();
|
||||
}
|
||||
return retrive(filename);
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
package org.kar.oauth.api;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.security.PermitAll;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.CacheControl;
|
||||
import javax.ws.rs.core.PathSegment;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.ResponseBuilder;
|
||||
|
||||
@ -24,31 +26,36 @@ public class FrontSSO {
|
||||
String filePathName = ConfigVariable.getSsoFolder() + File.separator + fileName;
|
||||
String extention = getExtension(filePathName);
|
||||
String mineType = null;
|
||||
if (extention.equalsIgnoreCase("jpg") || extention.equalsIgnoreCase("jpeg")) {
|
||||
mineType = "image/jpeg";
|
||||
} else if (extention.equalsIgnoreCase("gif")) {
|
||||
mineType = "image/gif";
|
||||
} else if (extention.equalsIgnoreCase("png")) {
|
||||
mineType = "image/png";
|
||||
} else if (extention.equalsIgnoreCase("svg")) {
|
||||
mineType = "image/svg+xml";
|
||||
} else if (extention.equalsIgnoreCase("webp")) {
|
||||
mineType = "image/webp";
|
||||
} else if (extention.equalsIgnoreCase("js")) {
|
||||
mineType = "application/javascript";
|
||||
} else if (extention.equalsIgnoreCase("json")) {
|
||||
mineType = "application/json";
|
||||
} else if (extention.equalsIgnoreCase("ico")) {
|
||||
mineType = "image/x-icon";
|
||||
} else if (extention.equalsIgnoreCase("html")) {
|
||||
mineType = "text/html";
|
||||
} else if (extention.equalsIgnoreCase("css")) {
|
||||
mineType = "text/css";
|
||||
if (!extention.isEmpty()) {
|
||||
if (extention.equalsIgnoreCase("jpg") || extention.equalsIgnoreCase("jpeg")) {
|
||||
mineType = "image/jpeg";
|
||||
} else if (extention.equalsIgnoreCase("gif")) {
|
||||
mineType = "image/gif";
|
||||
} else if (extention.equalsIgnoreCase("png")) {
|
||||
mineType = "image/png";
|
||||
} else if (extention.equalsIgnoreCase("svg")) {
|
||||
mineType = "image/svg+xml";
|
||||
} else if (extention.equalsIgnoreCase("webp")) {
|
||||
mineType = "image/webp";
|
||||
} else if (extention.equalsIgnoreCase("js")) {
|
||||
mineType = "application/javascript";
|
||||
} else if (extention.equalsIgnoreCase("json")) {
|
||||
mineType = "application/json";
|
||||
} else if (extention.equalsIgnoreCase("ico")) {
|
||||
mineType = "image/x-icon";
|
||||
} else if (extention.equalsIgnoreCase("html")) {
|
||||
mineType = "text/html";
|
||||
} else if (extention.equalsIgnoreCase("css")) {
|
||||
mineType = "text/css";
|
||||
} else {
|
||||
return Response.status(403).
|
||||
entity("Not supported model: '" + fileName + "'").
|
||||
type("text/plain").
|
||||
build();
|
||||
}
|
||||
} else {
|
||||
return Response.status(403).
|
||||
entity("Not supported model: '" + fileName + "'").
|
||||
type("text/plain").
|
||||
build();
|
||||
mineType = "text/html";
|
||||
filePathName = "index.html";
|
||||
}
|
||||
// reads input image
|
||||
File download = new File(filePathName);
|
||||
@ -79,25 +86,18 @@ public class FrontSSO {
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{baseA}")
|
||||
@Path("{any: .*}")
|
||||
@PermitAll()
|
||||
//@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
//@CacheMaxAge(time = 10, unit = TimeUnit.DAYS)
|
||||
public Response retrive1(@PathParam("baseA") String baseA) throws Exception {
|
||||
return retrive(baseA);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("assets/images/{baseB}")
|
||||
@PermitAll()
|
||||
public Response retrive2(@PathParam("baseB") String baseB) throws Exception {
|
||||
return retrive("assets" + File.separator + "images" + File.separator + baseB);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("assets/js_3rd_party/{baseB}")
|
||||
@PermitAll()
|
||||
public Response retrive3(@PathParam("baseB") String baseB) throws Exception {
|
||||
return retrive("assets" + File.separator + "js_3rd_party" + File.separator + baseB);
|
||||
public Response retrive1(@PathParam("any") List<PathSegment> segments) throws Exception {
|
||||
String filename = "";
|
||||
for (PathSegment elem: segments) {
|
||||
if (!filename.isEmpty()) {
|
||||
filename += File.separator;
|
||||
}
|
||||
filename += elem.getPath();
|
||||
}
|
||||
return retrive(filename);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user