use of org.kie.server.api.exception.KieServicesHttpException in project kie-wb-common by kiegroup.
the class DefaultWorkbenchErrorCallbackTest method testForbiddenException.
@Test
public void testForbiddenException() {
assertTrue(isKieServerForbiddenException(new KieServicesHttpException(null, 403, null, null)));
assertTrue(isKieServerForbiddenException(new DataSetLookupException(null, null, new Exception("Unexpected HTTP response code when requesting URI ''! Error code: 403, message: <html><head><title>Error</title></head><body>Forbidden</body></html>"))));
assertFalse(isKieServerForbiddenException(new KieServicesHttpException(null, 401, null, null)));
assertFalse(isKieServerForbiddenException(new DataSetLookupException(null, null, new Exception("Unexpected HTTP response code when requesting URI ''! Error code: 401, message: <html><head><title>Error</title></head><body>Unauthorized</body></html>"))));
assertFalse(isKieServerForbiddenException(new Exception("Some Unexpected HTTP response code when requesting URI")));
}
use of org.kie.server.api.exception.KieServicesHttpException in project kie-wb-common by kiegroup.
the class DefaultWorkbenchErrorCallback method error.
@Override
public boolean error(final Message message, final Throwable throwable) {
if (isInvalidBusContentException(throwable)) {
final YesNoCancelPopup result = YesNoCancelPopup.newYesNoCancelPopup(DefaultWorkbenchConstants.INSTANCE.SessionTimeout(), DefaultWorkbenchConstants.INSTANCE.InvalidBusResponseProbablySessionTimeout(), Window.Location::reload, null, () -> {
});
result.clearScrollHeight();
result.show();
return false;
} else if (isKieServerForbiddenException(throwable)) {
ErrorPopup.showMessage(DefaultWorkbenchConstants.INSTANCE.KieServerError403());
return false;
} else if (isKieServerUnauthorizedException(throwable)) {
ErrorPopup.showMessage(DefaultWorkbenchConstants.INSTANCE.KieServerError401());
return false;
} else if (throwable instanceof KieServicesHttpException) {
KieServicesHttpException ex = (KieServicesHttpException) throwable;
ErrorPopup.showMessage(CommonConstants.INSTANCE.ExceptionGeneric0(ex.getExceptionMessage()));
return false;
} else {
return super.error(message, throwable);
}
}
use of org.kie.server.api.exception.KieServicesHttpException in project kie-wb-common by kiegroup.
the class DefaultWorkbenchErrorCallbackTest method testUnauthorizedException.
@Test
public void testUnauthorizedException() {
assertTrue(isKieServerUnauthorizedException(new KieServicesHttpException(null, 401, null, null)));
assertTrue(isKieServerUnauthorizedException(new DataSetLookupException(null, null, new Exception("Unexpected HTTP response code when requesting URI ''! Error code: 401, message: <html><head><title>Error</title></head><body>Unauthorized</body></html>"))));
assertFalse(isKieServerUnauthorizedException(new KieServicesHttpException(null, 403, null, null)));
assertFalse(isKieServerUnauthorizedException(new DataSetLookupException(null, null, new Exception("Unexpected HTTP response code when requesting URI ''! Error code: 403, message: <html><head><title>Error</title></head><body>Forbidden</body></html>"))));
assertFalse(isKieServerUnauthorizedException(new Exception("Some Unexpected HTTP response code when requesting URI")));
}
Aggregations