Search in sources :

Example 1 with KieServicesHttpException

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")));
}
Also used : KieServicesHttpException(org.kie.server.api.exception.KieServicesHttpException) InvalidBusContentException(org.jboss.errai.bus.client.api.InvalidBusContentException) DefaultWorkbenchErrorCallback.isInvalidBusContentException(org.kie.workbench.common.workbench.client.error.DefaultWorkbenchErrorCallback.isInvalidBusContentException) DefaultWorkbenchErrorCallback.isKieServerForbiddenException(org.kie.workbench.common.workbench.client.error.DefaultWorkbenchErrorCallback.isKieServerForbiddenException) KieServicesHttpException(org.kie.server.api.exception.KieServicesHttpException) DefaultWorkbenchErrorCallback.isKieServerUnauthorizedException(org.kie.workbench.common.workbench.client.error.DefaultWorkbenchErrorCallback.isKieServerUnauthorizedException) Test(org.junit.Test)

Example 2 with KieServicesHttpException

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);
    }
}
Also used : KieServicesHttpException(org.kie.server.api.exception.KieServicesHttpException) YesNoCancelPopup(org.uberfire.ext.widgets.common.client.common.popups.YesNoCancelPopup)

Example 3 with KieServicesHttpException

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")));
}
Also used : KieServicesHttpException(org.kie.server.api.exception.KieServicesHttpException) InvalidBusContentException(org.jboss.errai.bus.client.api.InvalidBusContentException) DefaultWorkbenchErrorCallback.isInvalidBusContentException(org.kie.workbench.common.workbench.client.error.DefaultWorkbenchErrorCallback.isInvalidBusContentException) DefaultWorkbenchErrorCallback.isKieServerForbiddenException(org.kie.workbench.common.workbench.client.error.DefaultWorkbenchErrorCallback.isKieServerForbiddenException) KieServicesHttpException(org.kie.server.api.exception.KieServicesHttpException) DefaultWorkbenchErrorCallback.isKieServerUnauthorizedException(org.kie.workbench.common.workbench.client.error.DefaultWorkbenchErrorCallback.isKieServerUnauthorizedException) Test(org.junit.Test)

Aggregations

KieServicesHttpException (org.kie.server.api.exception.KieServicesHttpException)3 InvalidBusContentException (org.jboss.errai.bus.client.api.InvalidBusContentException)2 Test (org.junit.Test)2 DefaultWorkbenchErrorCallback.isInvalidBusContentException (org.kie.workbench.common.workbench.client.error.DefaultWorkbenchErrorCallback.isInvalidBusContentException)2 DefaultWorkbenchErrorCallback.isKieServerForbiddenException (org.kie.workbench.common.workbench.client.error.DefaultWorkbenchErrorCallback.isKieServerForbiddenException)2 DefaultWorkbenchErrorCallback.isKieServerUnauthorizedException (org.kie.workbench.common.workbench.client.error.DefaultWorkbenchErrorCallback.isKieServerUnauthorizedException)2 YesNoCancelPopup (org.uberfire.ext.widgets.common.client.common.popups.YesNoCancelPopup)1