本文整理了Java中com.atlassian.sal.api.net.Response.getEntity
方法的一些代码示例,展示了Response.getEntity
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.getEntity
方法的具体详情如下:
包路径:com.atlassian.sal.api.net.Response
类名称:Response
方法名:getEntity
暂无
代码示例来源:origin: com.atlassian.cpji/cpji-jira-plugin
@Override
protected CopyInformationBean parseResponse(Response response) throws ResponseException, JSONException {
return response.getEntity(CopyInformationBean.class);
}
});
代码示例来源:origin: com.atlassian.cpji/cpji-jira-plugin
@Override
protected FieldPermissionsBean parseResponse(Response response) throws ResponseException, JSONException {
return response.getEntity(FieldPermissionsBean.class);
}
});
代码示例来源:origin: com.atlassian.refapp/platform-ctk-plugin
public Object handle(Response response) throws ResponseException {
return response.getEntity(resultClass);
}
}
代码示例来源:origin: com.atlassian.applinks/applinks-plugin
public ErrorListEntity handle(final Response response) throws ResponseException {
// 201 means we created a new application link.
// 200 means there already is an application link and we just updated this one.
return !response.isSuccessful() ?
response.getEntity(ErrorListEntity.class) :
null;
}
});
代码示例来源:origin: com.atlassian.applinks/applinks-plugin
private Set<ApplinksCapabilities> getCapabilities(Response response) throws ResponseException {
@SuppressWarnings("unchecked") Iterable<String> stringCapabilities = response.getEntity(List.class);
Iterable<ApplinksCapabilities> enumCapabilities = transform(stringCapabilities,
fromNameSafe(ApplinksCapabilities.class));
return Sets.newEnumSet(filter(enumCapabilities, Predicates.notNull()), ApplinksCapabilities.class);
}
}
代码示例来源:origin: com.atlassian.cpji/cpji-jira-plugin
@Override
protected IssueCreationResultBean parseResponse(Response response) throws ResponseException, JSONException {
if (response.isSuccessful()) {
return response.getEntity(IssueCreationResultBean.class);
} else {
ErrorBean errorBean = response.getEntity(ErrorBean.class);
return provideResponseStatus(NegativeResponseStatus.errorOccured(jiraLocation, errorBean));
}
}
});
代码示例来源:origin: com.atlassian.applinks/applinks-plugin
private ApplinkOAuthStatus getStatusFrom(Response response) throws ResponseException {
try {
return response.getEntity(RestApplinkOAuthStatus.class).asDomain();
} catch (Exception e) {
throw new ResponseContentException(response, e);
}
}
}
代码示例来源:origin: com.atlassian.applinks/applinks-plugin
public void handle(final Response response) throws ResponseException {
if (response.getStatusCode() == 200) {
Iterables.addAll(entities, response.getEntity(ReferenceEntityList.class).getEntities(typeAccessor));
} else {
throw new ResponseException(String.format("Failed to retrieve entity list, received %s response: %s",
response.getStatusCode(), response.getStatusText()));
}
}
});
代码示例来源:origin: com.atlassian.applinks/applinks-plugin
public void handle(final com.atlassian.sal.api.net.Response response) throws ResponseException {
// 201 means we created a new application link.
// 200 means there already is an application link and we just updated this one.
if (!response.isSuccessful()) {
try {
final ErrorListEntity listEntity = response.getEntity(ErrorListEntity.class);
warnings.addAll(listEntity.getErrors());
} catch (RuntimeException re) {
LOG.warn("Could not parse the peer's response to " +
"upgrade application link \"" + oldApplicationLink.getName() +
"\" to a bi-directional link. Status code: " +
response.getStatusCode() + ".");
throw re;
}
}
}
});
代码示例来源:origin: com.atlassian.applinks/applinks-plugin
@Override
public void handle(final Response response) throws ResponseException {
super.handle(response);
if (isSuccessful()) {
final AuthenticationProviderEntityListEntity listEntity = response.getEntity(AuthenticationProviderEntityListEntity.class);
final List<AuthenticationProviderEntity> providers = listEntity.getAuthenticationProviders();
if (providers != null) {
for (AuthenticationProviderEntity provider : providers) {
if (BasicAuthenticationProvider.class.getName().equals(provider.getProvider())) {
legacyConfig = legacyConfig.basic(true);
}
if (TrustedAppsAuthenticationProvider.class.getName().equals(provider.getProvider())) {
legacyConfig = legacyConfig.trusted(true);
}
}
}
}
}
}
代码示例来源:origin: com.atlassian.applinks/applinks-plugin
public PermissionCode handle(final com.atlassian.sal.api.net.Response response) throws ResponseException {
if (response.getStatusCode() == 200) {
try {
return response.getEntity(PermissionCodeEntity.class).getCode();
} catch (Exception e) {
throw new ResponseException(
String.format("Permission check failed, exception " +
"encountered processing response: %s", e));
}
} else if (response.getStatusCode() == 401) {
ApplicationLinkRequestFactory authenticatedRequestFactory = applicationLink.createImpersonatingAuthenticatedRequestFactory();
if (authenticatedRequestFactory == null) {
authenticatedRequestFactory = applicationLink.createNonImpersonatingAuthenticatedRequestFactory();
}
if (authenticatedRequestFactory != null) {
LOG.warn("Authentication failed for application link " +
applicationLink + ". Response headers: " + response.getHeaders().toString() +
" body: " + response.getResponseBodyAsString());
} else if (LOG.isDebugEnabled()) {
LOG.debug("Authentication failed for application link " +
applicationLink + ". Response headers: " + response.getHeaders().toString() +
" body: " + response.getResponseBodyAsString());
}
return AUTHENTICATION_FAILED;
} else {
throw new ResponseException(String.format("Permission check failed, received %s",
response.getStatusCode()));
}
}
});
代码示例来源:origin: com.atlassian.applinks/applinks-plugin
@Override
public ApplinkOAuthStatus handle(Response response) throws ResponseException {
if (response.getStatusCode() == NOT_FOUND.getStatusCode()) {
return null;
} else if (response.getStatusCode() == FORBIDDEN.getStatusCode() ||
response.getStatusCode() == UNAUTHORIZED.getStatusCode()) {
throw new ApplinkStatusAccessException(ApplinkErrorType.INSUFFICIENT_REMOTE_PERMISSION, uriGenerator,
INSUFFICIENT_PERMISSION_MESSAGE);
} else {
checkStatusOk(response);
try {
RestApplicationLinkAuthentication authenticationEntity = response.getEntity(
RestApplicationLinkAuthentication.class);
return new ApplinkOAuthStatus(
getIncomingConfig(authenticationEntity),
getOutgoingConfig(authenticationEntity)
);
} catch (Exception e) {
throw new ResponseContentException(response, e);
}
}
}
代码示例来源:origin: com.atlassian.applinks/applinks-plugin-core
public void handle(Response response) throws ResponseException
{
// this means the response indicates a redirection.
if (response.getStatusCode() >= 300 && response.getStatusCode() < 400)
{
final String location = response.getHeader("Location");
if (location == null)
{
throw new ResponseException("manifest not found");
}
LOG.info("Manifest request got redirected to '" + location + "'.");
exception.set(new ManifestGotRedirectedException("manifest got redirected", location));
}
else if (response.isSuccessful())
{
try
{
manifestHolder.set(asManifest(response.getEntity(ManifestEntity.class)));
}
catch (Exception ex)
{
exception.set(ex);
}
}
}
});
代码示例来源:origin: com.atlassian.applinks/applinks-common
public void handle(Response response) throws ResponseException {
// this means the response indicates a redirection.
if (response.getStatusCode() >= 300 && response.getStatusCode() < 400) {
final String location = response.getHeader("Location");
if (location == null) {
throw new ResponseException("manifest not found");
}
LOG.info("Manifest request got redirected to '" + location + "'.");
exception.set(new ManifestGotRedirectedException("manifest got redirected", location));
} else {
checkStatusOk(response);
try {
manifestHolder.set(asManifest(response.getEntity(ManifestEntity.class)));
} catch (Exception ex) {
exception.set(new ResponseContentException(response, ex));
}
}
}
});
代码示例来源:origin: com.atlassian.cpji/cpji-jira-plugin
public Either<NegativeResponseStatus, T> handle(final Response response) throws ResponseException {
if (log.isDebugEnabled()) {
log.debug("Response is: " + response.getResponseBodyAsString());
}
if (response.getStatusCode() == 401) {
return Either.left(NegativeResponseStatus.authenticationFailed(jiraLocation));
}
if (response.getStatusCode() == 404) {
return Either.left(NegativeResponseStatus.pluginNotInstalled(jiraLocation));
}
if (!response.isSuccessful()) {
try {
ErrorBean error = response.getEntity(ErrorBean.class);
return Either.left(NegativeResponseStatus.errorOccured(jiraLocation, error));
} catch (ResponseException e) {
return Either.left(NegativeResponseStatus.communicationFailed(jiraLocation));
}
}
try {
T parsedResponse = parseResponse(response);
if (providedResponseStatus != null) {
return Either.left(providedResponseStatus);
} else {
return Either.right(parsedResponse);
}
} catch (JSONException e) {
log.error(String.format("Failed to parse JSON from Application Link: %s (%s)", jiraLocation.getId(), e.getMessage()));
return Either.left(NegativeResponseStatus.communicationFailed(jiraLocation));
}
}
代码示例来源:origin: com.atlassian.bamboo.plugins/bamboo-stash-plugin
respBuilder.errors(response.getEntity(Errors.class));
内容来源于网络,如有侵权,请联系作者删除!