Moved unnecessary response.api package classes

This commit is contained in:
Rsl1122 2018-08-12 09:57:54 +03:00
parent cab63df82f
commit bf1f28388d
11 changed files with 21 additions and 50 deletions

View File

@ -11,7 +11,7 @@ import com.djrapitops.plan.system.locale.lang.ErrorPageLang;
import com.djrapitops.plan.system.webserver.Request; import com.djrapitops.plan.system.webserver.Request;
import com.djrapitops.plan.system.webserver.pages.PageHandler; import com.djrapitops.plan.system.webserver.pages.PageHandler;
import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.Response;
import com.djrapitops.plan.system.webserver.response.api.BadRequestResponse; import com.djrapitops.plan.system.webserver.response.errors.BadRequestResponse;
import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;

View File

@ -10,7 +10,7 @@ import com.djrapitops.plan.api.exceptions.connection.WebException;
import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plan.system.webserver.response.DefaultResponses; import com.djrapitops.plan.system.webserver.response.DefaultResponses;
import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.Response;
import com.djrapitops.plan.system.webserver.response.api.BadRequestResponse; import com.djrapitops.plan.system.webserver.response.errors.BadRequestResponse;
import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.api.utility.log.Log;

View File

@ -13,7 +13,7 @@ import com.djrapitops.plan.system.info.server.Server;
import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plan.system.webserver.response.DefaultResponses; import com.djrapitops.plan.system.webserver.response.DefaultResponses;
import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.Response;
import com.djrapitops.plan.system.webserver.response.api.BadRequestResponse; import com.djrapitops.plan.system.webserver.response.errors.BadRequestResponse;
import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;

View File

@ -8,7 +8,7 @@ import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plan.system.update.ShutdownUpdateHook; import com.djrapitops.plan.system.update.ShutdownUpdateHook;
import com.djrapitops.plan.system.webserver.response.DefaultResponses; import com.djrapitops.plan.system.webserver.response.DefaultResponses;
import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.Response;
import com.djrapitops.plan.system.webserver.response.api.BadRequestResponse; import com.djrapitops.plan.system.webserver.response.errors.BadRequestResponse;
import java.util.Map; import java.util.Map;

View File

@ -11,7 +11,6 @@ import com.djrapitops.plan.system.locale.lang.ErrorPageLang;
import com.djrapitops.plan.system.webserver.auth.Authentication; import com.djrapitops.plan.system.webserver.auth.Authentication;
import com.djrapitops.plan.system.webserver.pages.*; import com.djrapitops.plan.system.webserver.pages.*;
import com.djrapitops.plan.system.webserver.response.*; import com.djrapitops.plan.system.webserver.response.*;
import com.djrapitops.plan.system.webserver.response.api.BadRequestResponse;
import com.djrapitops.plan.system.webserver.response.cache.PageId; import com.djrapitops.plan.system.webserver.response.cache.PageId;
import com.djrapitops.plan.system.webserver.response.cache.ResponseCache; import com.djrapitops.plan.system.webserver.response.cache.ResponseCache;
import com.djrapitops.plan.system.webserver.response.errors.*; import com.djrapitops.plan.system.webserver.response.errors.*;

View File

@ -4,8 +4,6 @@
*/ */
package com.djrapitops.plan.system.webserver.response; package com.djrapitops.plan.system.webserver.response;
import com.djrapitops.plan.system.webserver.response.api.SuccessResponse;
/** /**
* Enum containing default responses that don't need to be cached because they're always the same. * Enum containing default responses that don't need to be cached because they're always the same.
* *
@ -13,7 +11,7 @@ import com.djrapitops.plan.system.webserver.response.api.SuccessResponse;
*/ */
public enum DefaultResponses { public enum DefaultResponses {
BASIC_AUTH(PromptAuthorizationResponse.getBasicAuthResponse()), BASIC_AUTH(PromptAuthorizationResponse.getBasicAuthResponse()),
SUCCESS(new SuccessResponse()); SUCCESS(new TextResponse("Success"));
private final Response response; private final Response response;

View File

@ -0,0 +1,14 @@
package com.djrapitops.plan.system.webserver.response;
/**
* Response for raw text.
*
* @author Rsl1122
*/
public class TextResponse extends Response {
public TextResponse(String content) {
setHeader("HTTP/1.1 200 OK");
setContent(content);
}
}

View File

@ -1,23 +0,0 @@
/*
* License is provided in the jar as LICENSE also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/LICENSE
*/
package com.djrapitops.plan.system.webserver.response.api;
import com.djrapitops.plan.system.webserver.response.Response;
import com.djrapitops.plan.system.webserver.response.ResponseType;
import com.google.gson.Gson;
/**
* @author Fuzzlemann
*/
public class JsonResponse extends Response {
public <T> JsonResponse(T object) {
super(ResponseType.JSON);
Gson gson = new Gson();
super.setHeader("HTTP/1.1 200 OK");
super.setContent(gson.toJson(object));
}
}

View File

@ -1,18 +0,0 @@
/*
* License is provided in the jar as LICENSE also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/LICENSE
*/
package com.djrapitops.plan.system.webserver.response.api;
import com.djrapitops.plan.system.webserver.response.Response;
/**
* @author Fuzzlemann
*/
public class SuccessResponse extends Response {
public SuccessResponse() {
super.setHeader("HTTP/1.1 200 OK");
super.setContent("Success");
}
}

View File

@ -2,7 +2,7 @@
* License is provided in the jar as LICENSE also here: * License is provided in the jar as LICENSE also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/LICENSE * https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/LICENSE
*/ */
package com.djrapitops.plan.system.webserver.response.api; package com.djrapitops.plan.system.webserver.response.errors;
import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.Response;

View File

@ -14,6 +14,7 @@ import com.djrapitops.plan.utilities.html.pages.NetworkPage;
public class NetworkPageResponse extends Response { public class NetworkPageResponse extends Response {
public NetworkPageResponse() throws ParseException { public NetworkPageResponse() throws ParseException {
super.setHeader("HTTP/1.1 200 OK");
NetworkContainer networkContainer = CacheSystem.getInstance().getDataContainerCache().getNetworkContainer(); NetworkContainer networkContainer = CacheSystem.getInstance().getDataContainerCache().getNetworkContainer();
setContent(new NetworkPage(networkContainer).toHtml()); setContent(new NetworkPage(networkContainer).toHtml());
} }