本文整理汇总了Java中com.taskadapter.redmineapi.NotAuthorizedException类的典型用法代码示例。如果您正苦于以下问题:Java NotAuthorizedException类的具体用法?Java NotAuthorizedException怎么用?Java NotAuthorizedException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NotAuthorizedException类属于com.taskadapter.redmineapi包,在下文中一共展示了NotAuthorizedException类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMemberships
import com.taskadapter.redmineapi.NotAuthorizedException; //导入依赖的package包/类
public Observable<List<Membership>> getMemberships(final Project project) {
return updateObservable(new Observable.OnSubscribe<List<Membership>>() {
@Override
public void call(Subscriber<? super List<Membership>> subscriber) {
try {
subscriber.onNext(redmineManager.getMemberships(project));
subscriber.onCompleted();
} catch (RedMineException e) {
logger.trace(e.getMessage(), e);
if (e instanceof NotAuthorizedException) {
// Because sometimes user does not has permissions to get memberships o0
subscriber.onNext(new ArrayList<Membership>());
subscriber.onCompleted();
} else {
subscriber.onError(e);
}
}
}
});
}
示例2: getStatuses
import com.taskadapter.redmineapi.NotAuthorizedException; //导入依赖的package包/类
public Observable<List<IssueStatus>> getStatuses() {
return updateObservable(new Observable.OnSubscribe<List<IssueStatus>>() {
@Override
public void call(Subscriber<? super List<IssueStatus>> subscriber) {
try {
subscriber.onNext(redmineManager.getStatuses());
subscriber.onCompleted();
} catch (RedMineException e) {
logger.trace(e.getMessage(), e);
if (e instanceof NotAuthorizedException) {
// Because sometimes user does not has permissions to get statuses o0
subscriber.onNext(new ArrayList<IssueStatus>());
subscriber.onCompleted();
} else {
subscriber.onError(e);
}
}
}
});
}
示例3: processContent
import com.taskadapter.redmineapi.NotAuthorizedException; //导入依赖的package包/类
@Override
public BasicHttpResponse processContent(BasicHttpResponse httpResponse)
throws RedmineException {
final int responseCode = httpResponse.getResponseCode();
if (responseCode == HttpStatus.SC_UNAUTHORIZED) {
throw new RedmineAuthenticationException(
"Authorization error. Please check if you provided a valid API access key or Login and Password and REST API service is enabled on the server.");
}
if (responseCode == HttpStatus.SC_FORBIDDEN) {
throw new NotAuthorizedException(
"Forbidden. Please check the user has proper permissions.");
}
if (responseCode == HttpStatus.SC_NOT_FOUND) {
throw new NotFoundException(
"Server returned '404 not found'. response body:"
+ getContent(httpResponse));
}
if (responseCode == HttpStatus.SC_UNPROCESSABLE_ENTITY) {
List<String> errors;
try {
errors = RedmineJSONParser.parseErrors(getContent(httpResponse));
errors = remap(errors);
} catch (JSONException e) {
throw new RedmineFormatException("Bad redmine error response", e);
}
throw new RedmineProcessingException(errors);
}
return httpResponse;
}
示例4: processContent
import com.taskadapter.redmineapi.NotAuthorizedException; //导入依赖的package包/类
@Override
public BasicHttpResponse processContent(BasicHttpResponse httpResponse)
throws RedMineException {
final int responseCode = httpResponse.getResponseCode();
if (responseCode == HttpStatus.SC_UNAUTHORIZED) {
throw new RedMineAuthenticationException(
"Authorization error. Please check if you provided a valid API access key or Login and Password and REST API service is enabled on the server.");
}
if (responseCode == HttpStatus.SC_FORBIDDEN) {
throw new NotAuthorizedException(
"Forbidden. Please check the user has proper permissions.");
}
if (responseCode == HttpStatus.SC_NOT_FOUND) {
throw new NotFoundException(
"Server returned '404 not found'. response body:"
+ getContent(httpResponse));
}
if (responseCode == HttpStatus.SC_UNPROCESSABLE_ENTITY) {
List<String> errors;
try {
errors = RedmineJSONParser.parseErrors(getContent(httpResponse));
errors = remap(errors);
} catch (JSONException e) {
throw new RedMineFormatException("Bad redmine error response", e);
}
throw new RedMineProcessingException(errors);
}
return httpResponse;
}