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