[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,9 +21,10 @@ 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.isEmpty()) {
|
||||||
if (extention.equalsIgnoreCase("jpg") || extention.equalsIgnoreCase("jpeg")) {
|
if (extention.equalsIgnoreCase("jpg") || extention.equalsIgnoreCase("jpeg")) {
|
||||||
mineType = "image/jpeg";
|
mineType = "image/jpeg";
|
||||||
} else if (extention.equalsIgnoreCase("gif")) {
|
} else if (extention.equalsIgnoreCase("gif")) {
|
||||||
@ -48,6 +51,10 @@ public class Front {
|
|||||||
type("text/plain").
|
type("text/plain").
|
||||||
build();
|
build();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
mineType = "text/html";
|
||||||
|
filePathName = "index.html";
|
||||||
|
}
|
||||||
// reads input image
|
// reads input image
|
||||||
File download = new File(filePathName);
|
File download = new File(filePathName);
|
||||||
if (!download.exists()) {
|
if (!download.exists()) {
|
||||||
@ -71,31 +78,24 @@ public class Front {
|
|||||||
@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()) {
|
||||||
|
filename += File.separator;
|
||||||
}
|
}
|
||||||
|
filename += elem.getPath();
|
||||||
@GET
|
|
||||||
@Path("assets/images/{baseB}")
|
|
||||||
@PermitAll()
|
|
||||||
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,6 +26,7 @@ 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.isEmpty()) {
|
||||||
if (extention.equalsIgnoreCase("jpg") || extention.equalsIgnoreCase("jpeg")) {
|
if (extention.equalsIgnoreCase("jpg") || extention.equalsIgnoreCase("jpeg")) {
|
||||||
mineType = "image/jpeg";
|
mineType = "image/jpeg";
|
||||||
} else if (extention.equalsIgnoreCase("gif")) {
|
} else if (extention.equalsIgnoreCase("gif")) {
|
||||||
@ -50,6 +53,10 @@ public class FrontSSO {
|
|||||||
type("text/plain").
|
type("text/plain").
|
||||||
build();
|
build();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
mineType = "text/html";
|
||||||
|
filePathName = "index.html";
|
||||||
|
}
|
||||||
// reads input image
|
// reads input image
|
||||||
File download = new File(filePathName);
|
File download = new File(filePathName);
|
||||||
if (!download.exists()) {
|
if (!download.exists()) {
|
||||||
@ -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()) {
|
||||||
|
filename += File.separator;
|
||||||
}
|
}
|
||||||
|
filename += elem.getPath();
|
||||||
@GET
|
|
||||||
@Path("assets/images/{baseB}")
|
|
||||||
@PermitAll()
|
|
||||||
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