inisialisasi kembali
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
package org.sadigit.control.errorhandler;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.sadigit.control.exception.BadRequestBodyException;
|
||||
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import jakarta.ws.rs.ext.ExceptionMapper;
|
||||
import jakarta.ws.rs.ext.Provider;
|
||||
|
||||
@Provider
|
||||
public class BadRequestBodyErrorHandler implements ExceptionMapper<BadRequestBodyException> {
|
||||
|
||||
@Override
|
||||
public Response toResponse(BadRequestBodyException exception) {
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
response.put("status", false);
|
||||
response.put("title", "Bad Request");
|
||||
response.put("message", exception.getMessage());
|
||||
|
||||
return Response.status(403).entity(response).build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package org.sadigit.control.errorhandler;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.sadigit.control.exception.FileProcessingException;
|
||||
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import jakarta.ws.rs.ext.ExceptionMapper;
|
||||
import jakarta.ws.rs.ext.Provider;
|
||||
|
||||
@Provider
|
||||
public class FileProcessingErrorHandler implements ExceptionMapper<FileProcessingException> {
|
||||
|
||||
@Override
|
||||
public Response toResponse(FileProcessingException exception) {
|
||||
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
response.put("status", false);
|
||||
response.put("title", "Bad Request");
|
||||
response.put("message", exception.getMessage());
|
||||
|
||||
return Response.status(403).entity(response).build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package org.sadigit.control.errorhandler;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import jakarta.validation.ConstraintViolationException;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import jakarta.ws.rs.ext.ExceptionMapper;
|
||||
import jakarta.ws.rs.ext.Provider;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Provider
|
||||
@Slf4j
|
||||
public class ValidationExceptionErrorHandler implements ExceptionMapper<ConstraintViolationException>{
|
||||
|
||||
@Override
|
||||
public Response toResponse(ConstraintViolationException exception) {
|
||||
|
||||
var errorStructure = exception.getConstraintViolations()
|
||||
.stream()
|
||||
.map(violation -> Map.of(
|
||||
"path", violation.getPropertyPath().toString(),
|
||||
"message", violation.getMessage()
|
||||
))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
log.error("Validation error: {}", errorStructure);
|
||||
return Response.status(Response.Status.OK).entity(errorStructure).build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package org.sadigit.control.errorhandlers;
|
||||
|
||||
// import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import org.sadigit.control.exception.CustomException;
|
||||
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import jakarta.ws.rs.core.Response.Status;
|
||||
import jakarta.ws.rs.ext.ExceptionMapper;
|
||||
import jakarta.ws.rs.ext.Provider;
|
||||
|
||||
@Provider
|
||||
public class CustomExceptionHandler implements ExceptionMapper<CustomException>{
|
||||
|
||||
@Override
|
||||
public Response toResponse(CustomException exception) {
|
||||
|
||||
if (exception.getCustomErrorStructure() != null) {
|
||||
return Response.status(Status.OK).entity(exception.getCustomErrorStructure()).build();
|
||||
} else {
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
exception.printStackTrace();
|
||||
response.put("status", false);
|
||||
response.put("title", "Terjadi Kesalahan");
|
||||
response.put("message", exception.getMessage());
|
||||
return Response.status(Status.OK).entity(response).build();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package org.sadigit.control.errorhandlers;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.sadigit.control.exception.GetDataGarduV2Exception;
|
||||
import org.sadigit.model.response.base.ResponseModelGarduV2;
|
||||
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import jakarta.ws.rs.ext.ExceptionMapper;
|
||||
import jakarta.ws.rs.ext.Provider;
|
||||
|
||||
@Provider
|
||||
public class GetDataGarduV2Handler implements ExceptionMapper<GetDataGarduV2Exception>{
|
||||
|
||||
@Override
|
||||
public Response toResponse(GetDataGarduV2Exception exception) {
|
||||
|
||||
ResponseModelGarduV2<Map<String,Object>> response = new ResponseModelGarduV2<>();
|
||||
response.setP_return(Map.of(
|
||||
"errorcode", exception.getErrorCode(),
|
||||
"info", exception.getMessage()
|
||||
));
|
||||
|
||||
return Response.status(Response.Status.OK).entity(response).build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package org.sadigit.control.exception;
|
||||
|
||||
public class AppFlowException extends RuntimeException{
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package org.sadigit.control.exception;
|
||||
|
||||
public class BadRequestBodyException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public BadRequestBodyException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public BadRequestBodyException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public BadRequestBodyException(String msg, Exception e) {
|
||||
super(msg, e);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package org.sadigit.control.exception;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class CustomException extends RuntimeException{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Object customErrorStructure;
|
||||
|
||||
public CustomException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CustomException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public CustomException(String msg, Object customErrorStructure) {
|
||||
super();
|
||||
this.customErrorStructure = customErrorStructure;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package org.sadigit.control.exception;
|
||||
|
||||
public class FileProcessingException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public FileProcessingException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public FileProcessingException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public FileProcessingException(String msg, Exception e) {
|
||||
super(msg, e);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package org.sadigit.control.exception;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class GetDataGarduV2Exception extends RuntimeException{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String errorCode;
|
||||
|
||||
public GetDataGarduV2Exception(String errorCode) {
|
||||
super();
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public GetDataGarduV2Exception(String errorCode, String msg) {
|
||||
super(msg);
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
// package org.sadigit.control.security;
|
||||
|
||||
// import io.quarkus.elytron.security.common.BcryptUtil;
|
||||
// import io.quarkus.security.jpa.Password;
|
||||
// import io.quarkus.security.jpa.Roles;
|
||||
// import io.quarkus.security.jpa.UserDefinition;
|
||||
// import io.quarkus.security.jpa.Username;
|
||||
|
||||
// @UserDefinition
|
||||
// public class User {
|
||||
|
||||
// @Username
|
||||
// public String username;
|
||||
// @Password
|
||||
// public String password;
|
||||
// @Roles
|
||||
// public String role;
|
||||
|
||||
// public User(String username, String password, String role) {
|
||||
// this.username = username;
|
||||
// this.password = BcryptUtil.bcryptHash(password);
|
||||
// this.role = role;
|
||||
// }
|
||||
// }
|
||||
Reference in New Issue
Block a user