Skip to content

Commit 2b53a78

Browse files
committed
- Fix APIFilter for IBM WebSphere
Please enter the commit message for your changes. Lines starting
1 parent a1e381c commit 2b53a78

1 file changed

Lines changed: 19 additions & 22 deletions

File tree

java/src/main/java/com/genexus/filters/APIObjectFilter.java

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,32 @@
1919
public class APIObjectFilter extends Filter {
2020

2121
private ArrayList<String> appPath = new ArrayList<String>();
22-
22+
static final String PRIVATEDIR="private";
23+
static final String WEBINFO="WEB-INF";
2324
public static final Logger logger = LogManager.getLogger(APIObjectFilter.class);
2425

25-
public void doFilter(IServletRequest request, IServletResponse response, IFilterChain chain) throws Exception {
26+
public void doFilter(IServletRequest request, IServletResponse response, IFilterChain chain) throws Exception {
2627
if (request.isHttpServletRequest() && response.isHttpServletResponse()) {
2728
IHttpServletRequest httpRequest = request.getHttpServletRequest();
2829
String path = httpRequest.getRequestURI().substring(httpRequest.getContextPath().length()).substring(1);
2930
String urlString = path.toLowerCase();
3031
boolean isPath = false;
31-
for(String appBasePath : appPath)
32-
{
33-
if (urlString.startsWith(appBasePath))
34-
{
32+
for(String appBasePath : appPath) {
33+
if (urlString.startsWith(appBasePath)) {
3534
isPath = true;
3635
break;
3736
}
3837
}
39-
if(isPath)
40-
{
38+
if(isPath) {
4139
String fwdURI = "/rest/" + path;
40+
logger.info("Forwarding from " + path +" to: " + fwdURI) ;
4241
httpRequest.getRequestDispatcher(fwdURI).forward(request,response);
4342
}
44-
else
45-
{
43+
else {
4644
chain.doFilter(request, response);
4745
}
4846
}
49-
else
50-
{
47+
else {
5148
chain.doFilter(request, response);
5249
}
5350
}
@@ -56,28 +53,28 @@ public void init(Map<String, String> headers, String path, String sessionCookieN
5653
try {
5754
String paramValue = headers.get("BasePath");
5855
if (paramValue != null && !paramValue.isEmpty())
59-
{
56+
{
57+
Path privateFolder = Paths.get(paramValue + File.separator);
6058
if (paramValue.equals("*"))
61-
{
59+
{
6260
if (path != null && !path.isEmpty())
63-
{
64-
paramValue = path + "private";
65-
Path privateFolder = Paths.get(paramValue);
61+
{
62+
privateFolder = Paths.get(path, PRIVATEDIR);
6663
if (!Files.exists(privateFolder)){
67-
paramValue = path + "WEB-INF" + File.separator + "private";
64+
privateFolder = Paths.get(path, WEBINFO, PRIVATEDIR);
6865
}
6966
}
7067
}
71-
logger.info("API metadata path: " + paramValue) ;
72-
Stream<Path> walk = Files.walk(Paths.get(paramValue + File.separator));
68+
logger.info("API metadata folder: [" + privateFolder.toString() + "]") ;
69+
Stream<Path> walk = Files.walk(privateFolder);
7370
List<String> result = walk.map(x -> x.toString()).filter(f -> f.endsWith(".grp.json")).collect(Collectors.toList());
7471
for (String temp : result)
7572
{
7673
try{
7774
String read = String.join( "", Files.readAllLines(Paths.get(temp)));
7875
JSONObject jo = new JSONObject(read);
79-
String apipath = jo.getString("BasePath");
80-
appPath.add(apipath.toLowerCase());
76+
String apiPath = jo.getString("BasePath");
77+
appPath.add(apiPath.toLowerCase());
8178
}
8279
catch(IOException e)
8380
{

0 commit comments

Comments
 (0)