本文整理汇总了Java中org.eclipse.che.ide.commons.exception.UnauthorizedException类的典型用法代码示例。如果您正苦于以下问题:Java UnauthorizedException类的具体用法?Java UnauthorizedException怎么用?Java UnauthorizedException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnauthorizedException类属于org.eclipse.che.ide.commons.exception包,在下文中一共展示了UnauthorizedException类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: uploadKey
import org.eclipse.che.ide.commons.exception.UnauthorizedException; //导入依赖的package包/类
@Override
public void uploadKey(String userId, final AsyncCallback<Void> callback) {
this.callback = callback;
this.userId = userId;
bitbucketService.generateAndUploadSSHKey(
new AsyncRequestCallback<Void>() {
@Override
protected void onSuccess(final Void notUsed) {
callback.onSuccess(notUsed);
}
@Override
protected void onFailure(final Throwable exception) {
if (exception instanceof UnauthorizedException) {
oAuthLoginStart();
return;
}
callback.onFailure(exception);
}
});
}
示例2: onLoadRepoClickedWhenAuthorizeIsSuccessful
import org.eclipse.che.ide.commons.exception.UnauthorizedException; //导入依赖的package包/类
@Test
public void onLoadRepoClickedWhenAuthorizeIsSuccessful() throws Exception {
final Throwable exception = mock(UnauthorizedException.class);
String userId = "userId";
CurrentUser user = mock(CurrentUser.class);
doReturn(exception).when(promiseError).getCause();
when(appContext.getCurrentUser()).thenReturn(user);
when(user.getId()).thenReturn(userId);
presenter.onLoadRepoClicked();
verify(gitHubClientService).getRepositoriesList(anyString());
verify(gitHubClientService).getUserInfo(anyString());
verify(gitHubClientService).getOrganizations(anyString());
verify(gitHubAuthenticator).authenticate(anyString(), asyncCallbackCaptor.capture());
AsyncCallback<OAuthStatus> asyncCallback = asyncCallbackCaptor.getValue();
asyncCallback.onSuccess(null);
verify(view, times(3)).setLoaderVisibility(eq(true));
verify(view, times(3)).setInputsEnableState(eq(false));
verify(view, times(3)).setInputsEnableState(eq(true));
}
示例3: authenticate
import org.eclipse.che.ide.commons.exception.UnauthorizedException; //导入依赖的package包/类
private void authenticate(final WorkflowExecutor executor, final Context context) {
context
.getVcsHostingService()
.authenticate(appContext.getCurrentUser())
.then(authSuccessOp(executor, context))
.catchError(
new Operation<PromiseError>() {
@Override
public void apply(PromiseError err) throws OperationException {
try {
throw err.getCause();
} catch (UnauthorizedException unEx) {
notificationManager.notify(
messages.stepAuthorizeCodenvyOnVCSHostErrorCannotAccessVCSHostTitle(),
messages.stepAuthorizeCodenvyOnVCSHostErrorCannotAccessVCSHostContent(),
FAIL,
FLOAT_MODE);
executor.fail(
AuthorizeCodenvyOnVCSHostStep.this, context, unEx.getLocalizedMessage());
} catch (Throwable thr) {
handleThrowable(thr, executor, context);
}
}
});
}
示例4: uploadKey
import org.eclipse.che.ide.commons.exception.UnauthorizedException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void uploadKey(final String userId, final AsyncCallback<Void> callback) {
this.callback = callback;
this.userId = userId;
oAuthServiceClient
.getToken("github")
.then(
result -> {
gitHubService.updatePublicKey(
result.getToken(),
new AsyncRequestCallback<Void>() {
@Override
protected void onSuccess(Void o) {
callback.onSuccess(o);
}
@Override
protected void onFailure(Throwable e) {
if (e instanceof UnauthorizedException) {
oAuthLoginStart();
return;
}
callback.onFailure(e);
}
});
})
.catchError(
error -> {
oAuthLoginStart();
});
}
示例5: onFailRequest
import org.eclipse.che.ide.commons.exception.UnauthorizedException; //导入依赖的package包/类
protected void onFailRequest(PromiseError arg) {
showProcessing(false);
if (arg.getCause() instanceof UnauthorizedException) {
authorize();
} else {
notificationManager.notify(locale.authorizationFailed(), FAIL, FLOAT_MODE);
}
}
示例6: onLoadRepoClickedWhenAuthorizeIsFailed
import org.eclipse.che.ide.commons.exception.UnauthorizedException; //导入依赖的package包/类
@Test
public void onLoadRepoClickedWhenAuthorizeIsFailed() throws Exception {
String userId = "userId";
CurrentUser user = mock(CurrentUser.class);
when(appContext.getCurrentUser()).thenReturn(user);
when(user.getId()).thenReturn(userId);
final Throwable exception = mock(UnauthorizedException.class);
doReturn(exception).when(promiseError).getCause();
presenter.onLoadRepoClicked();
verify(gitHubClientService).getRepositoriesList(anyString());
verify(gitHubClientService).getUserInfo(anyString());
verify(gitHubClientService).getOrganizations(anyString());
verify(gitHubAuthenticator).authenticate(anyString(), asyncCallbackCaptor.capture());
AsyncCallback<OAuthStatus> asyncCallback = asyncCallbackCaptor.getValue();
asyncCallback.onFailure(exception);
verify(view, times(2)).setLoaderVisibility(eq(true));
verify(view, times(2)).setInputsEnableState(eq(false));
verify(view, times(2)).setInputsEnableState(eq(true));
verify(view, never()).setAccountNames(any());
verify(view, never()).showGithubPanel();
verify(view, never()).setRepositories(org.mockito.ArgumentMatchers.any());
}
示例7: handleError
import org.eclipse.che.ide.commons.exception.UnauthorizedException; //导入依赖的package包/类
/**
* Handler some action whether some exception happened.
*
* @param throwable exception what happened
*/
void handleError(
@NotNull Throwable throwable, StatusNotification notification, GitOutputConsole console) {
notification.setStatus(FAIL);
if (throwable instanceof UnauthorizedException) {
console.printError(locale.messagesNotAuthorizedTitle());
console.print(locale.messagesNotAuthorizedContent());
notification.setTitle(locale.messagesNotAuthorizedTitle());
notification.setContent(locale.messagesNotAuthorizedContent());
return;
}
String errorMessage = throwable.getMessage();
if (errorMessage == null) {
console.printError(locale.pushFail());
notification.setTitle(locale.pushFail());
return;
}
try {
errorMessage = dtoFactory.createDtoFromJson(errorMessage, ServiceError.class).getMessage();
if (errorMessage.equals("Unable get private ssh key")) {
console.printError(locale.messagesUnableGetSshKey());
notification.setTitle(locale.messagesUnableGetSshKey());
return;
}
console.printError(errorMessage);
notification.setTitle(errorMessage);
} catch (Exception e) {
console.printError(errorMessage);
notification.setTitle(errorMessage);
}
}
示例8: getUserErrorOp
import org.eclipse.che.ide.commons.exception.UnauthorizedException; //导入依赖的package包/类
private Operation<PromiseError> getUserErrorOp(
final WorkflowExecutor executor, final Context context) {
return new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
try {
throw error.getCause();
} catch (UnauthorizedException unEx) {
authenticate(executor, context);
} catch (Throwable thr) {
handleThrowable(thr, executor, context);
}
}
};
}
示例9: onUnauthorized
import org.eclipse.che.ide.commons.exception.UnauthorizedException; //导入依赖的package包/类
/**
* If unauthorized.
*
* @param response
*/
protected void onUnauthorized(Response response) {
onFailure(new UnauthorizedException(response, request));
}