scouterx.webapp.layer.controller.TempTestController Maven / Gradle / Ivy
package scouterx.webapp.layer.controller;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import scouterx.webapp.framework.exception.ErrorState;
import scouterx.webapp.framework.exception.ErrorStateBizException;
import scouterx.webapp.framework.exception.ErrorStateException;
import scouterx.webapp.view.CommonResultView;
import scouterx.webapp.framework.annotation.NoAuth;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
import java.util.Map;
/**
* This class is for testing
* Created by gunlee on 2017. 8. 24.
*/
@Path("/v0/temp/test")
@Produces(MediaType.APPLICATION_JSON)
public class TempTestController {
@GET
public String check(@Context HttpServletRequest request) {
HttpSession session = request.getSession(true);
session.setAttribute("testId", "testIdValue");
return "OK";
}
@GET @Path("/more")
@NoAuth
public String checkMore() {
return "OK-More";
}
@GET @Path("/todo")
public ToDo checkTodo() {
return new ToDo("morning todo", "brew a coffee", new Job("mytypes", "jobname!!"));
}
@GET @Path("/todoAsResult")
public CommonResultView checkTodoAsResult() {
ToDo todo = new ToDo("morning todo", "brew a coffee", new Job("mytypes", "jobname!!"));
CommonResultView resultView = CommonResultView.success(todo);
return resultView;
}
@GET @Path("/exception")
public CommonResultView exception() {
if (true) {
throw new RuntimeException("my exception");
}
return null;
}
@GET @Path("/exception/state")
public CommonResultView exceptionState() {
if (true) {
throw new ErrorStateException(ErrorState.INTERNAL_SERVER_ERROR, "test error state exception", new RuntimeException("my runtime ex!!!!!"));
}
return null;
}
@GET @Path("/exception/biz")
public CommonResultView exceptionBizState() {
if (true) {
throw new ErrorStateBizException(ErrorState.INTERNAL_SERVER_ERROR, "test error state BIZ !! exception");
}
return null;
}
@GET @Path("/map")
public CommonResultView