mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-04-06 04:07:34 +02:00
Fixed some code smells
This commit is contained in:
parent
3e5a1ce793
commit
15535e2469
@ -35,17 +35,15 @@ public class RequestTarget {
|
|||||||
resourceString = targetURI.getPath();
|
resourceString = targetURI.getPath();
|
||||||
resource = Arrays.stream(resourceString.split("/")).filter(part -> !part.isEmpty()).collect(Collectors.toList());
|
resource = Arrays.stream(resourceString.split("/")).filter(part -> !part.isEmpty()).collect(Collectors.toList());
|
||||||
|
|
||||||
String parameterString = targetURI.getQuery();
|
parameters = new TreeMap<>();
|
||||||
parameters = parseParameters(parameterString);
|
parseParameters(targetURI.getQuery());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, String> parseParameters(String parameterString) {
|
private void parseParameters(String parameterString) {
|
||||||
if (parameterString == null || parameterString.isEmpty()) {
|
if (parameterString == null || parameterString.isEmpty()) {
|
||||||
return Collections.emptyMap();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeMap<String, String> parameters = new TreeMap<>();
|
|
||||||
|
|
||||||
String[] keysAndValues = parameterString.split("&");
|
String[] keysAndValues = parameterString.split("&");
|
||||||
for (String kv : keysAndValues) {
|
for (String kv : keysAndValues) {
|
||||||
if (kv.isEmpty()) {
|
if (kv.isEmpty()) {
|
||||||
@ -56,8 +54,6 @@ public class RequestTarget {
|
|||||||
parameters.put(keyAndValue[0], keyAndValue[1]);
|
parameters.put(keyAndValue[0], keyAndValue[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return parameters;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
|
@ -139,13 +139,11 @@ public class ResponseHandler extends TreePageHandler {
|
|||||||
}
|
}
|
||||||
boolean isNotInfoRequest = target.isEmpty() || !target.get(0).equals("info");
|
boolean isNotInfoRequest = target.isEmpty() || !target.get(0).equals("info");
|
||||||
boolean isAuthRequired = webServer.get().isAuthRequired() && isNotInfoRequest;
|
boolean isAuthRequired = webServer.get().isAuthRequired() && isNotInfoRequest;
|
||||||
if (isAuthRequired) {
|
if (isAuthRequired && !authentication.isPresent()) {
|
||||||
if (!authentication.isPresent()) {
|
if (webServer.get().isUsingHTTPS()) {
|
||||||
if (webServer.get().isUsingHTTPS()) {
|
return responseFactory.basicAuth();
|
||||||
return responseFactory.basicAuth();
|
} else {
|
||||||
} else {
|
return responseFactory.forbidden403();
|
||||||
return responseFactory.forbidden403();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PageHandler pageHandler = getPageHandler(target);
|
PageHandler pageHandler = getPageHandler(target);
|
||||||
|
Loading…
Reference in New Issue
Block a user