inisialisasi kembali 3
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// 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