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