本文整理汇总了Java中org.jboss.resteasy.client.ClientResponseFailure类的典型用法代码示例。如果您正苦于以下问题:Java ClientResponseFailure类的具体用法?Java ClientResponseFailure怎么用?Java ClientResponseFailure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClientResponseFailure类属于org.jboss.resteasy.client包,在下文中一共展示了ClientResponseFailure类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listAllCompanies
import org.jboss.resteasy.client.ClientResponseFailure; //导入依赖的package包/类
public List<Company> listAllCompanies() throws DeskComException {
Set<Company> companies = new LinkedHashSet<Company>();
try {
Integer page = 1;
SearchResponse<Company> results;
do {
results = companyApi.list(authProvider.genAuthorizationHeader(), page++);
for(Company company: results.get_embedded().getEntries()) {
companies.add(company);
}
} while (results.hasNextPage());
return new LinkedList<Company>(companies);
}catch(ClientResponseFailure t){
throw new DeskComException(t);
}
}
示例2: listAllCompanyCases
import org.jboss.resteasy.client.ClientResponseFailure; //导入依赖的package包/类
public List<Case> listAllCompanyCases(BigInteger companyId) throws DeskComException {
Set<Case> cases = new LinkedHashSet<Case>();
try {
Integer page = 1;
SearchResponse<Case> results;
do {
results = companyApi.listCases(authProvider.genAuthorizationHeader(), companyId, page++);
for(Case _case : results.get_embedded().getEntries()) {
cases.add(_case);
}
} while (results.hasNextPage());
return new LinkedList<Case>(cases);
}catch(ClientResponseFailure t){
throw new DeskComException(t);
}
}
示例3: testRegisterPermissionForInvalidResource
import org.jboss.resteasy.client.ClientResponseFailure; //导入依赖的package包/类
/**
* Test for registering permissions for resource
*/
@Test
public void testRegisterPermissionForInvalidResource() throws Exception {
showTitle("testRegisterPermissionForInvalidResource");
UmaPermission permission = new UmaPermission();
permission.setResourceId(this.registerResourceTest.resourceId + "1");
permission.setScopes(Arrays.asList("http://photoz.example.com/dev/scopes/view", "http://photoz.example.com/dev/scopes/all"));
PermissionTicket ticket = null;
try {
ticket = getPermissionService().registerPermission(
"Bearer " + this.registerResourceTest.pat.getAccessToken(), UmaPermissionList.instance(permission));
} catch (ClientResponseFailure ex) {
System.err.println(ex.getResponse().getEntity(String.class));
assertTrue(ex.getResponse().getStatus() != Response.Status.CREATED.getStatusCode() &&
ex.getResponse().getStatus() != Response.Status.OK.getStatusCode()
, "Unexpected response status");
}
assertNull(ticket, "Resource permission is not null");
}
示例4: registerResource
import org.jboss.resteasy.client.ClientResponseFailure; //导入依赖的package包/类
public String registerResource(List<String> scopes) throws Exception {
try {
UmaResource resource = new UmaResource();
resource.setName("Photo Album");
resource.setIconUri("http://www.example.com/icons/flower.png");
resource.setScopes(scopes);
resource.setType("myType");
UmaResourceResponse resourceStatus = getResourceService().addResource("Bearer " + pat.getAccessToken(), resource);
UmaTestUtil.assert_(resourceStatus);
this.resourceId = resourceStatus.getId();
return this.resourceId;
} catch (ClientResponseFailure ex) {
System.err.println(ex.getResponse().getEntity(String.class));
throw ex;
}
}
示例5: registerResourceWithScopeExpression
import org.jboss.resteasy.client.ClientResponseFailure; //导入依赖的package包/类
public String registerResourceWithScopeExpression(String scopeExpression) throws Exception {
try {
UmaResource resource = new UmaResource();
resource.setName("Photo Album");
resource.setIconUri("http://www.example.com/icons/flower.png");
resource.setScopeExpression(scopeExpression);
resource.setType("myType");
UmaResourceResponse resourceStatus = getResourceService().addResource("Bearer " + pat.getAccessToken(), resource);
UmaTestUtil.assert_(resourceStatus);
this.resourceIdWithScopeExpression = resourceStatus.getId();
return this.resourceIdWithScopeExpression;
} catch (ClientResponseFailure ex) {
System.err.println(ex.getResponse().getEntity(String.class));
throw ex;
}
}
示例6: modifyNotExistingResource
import org.jboss.resteasy.client.ClientResponseFailure; //导入依赖的package包/类
/**
* Test non existing UMA resource description modification
*/
@Test(dependsOnMethods = {"modifyResource"})
public void modifyNotExistingResource() throws Exception {
showTitle("modifyNotExistingResource");
try {
UmaResource resource = new UmaResource();
resource.setName("Photo Album 3");
resource.setIconUri("http://www.example.com/icons/flower.png");
resource.setScopes(Arrays.asList("http://photoz.example.com/dev/scopes/view", "http://photoz.example.com/dev/scopes/all"));
getResourceService().updateResource("Bearer " + pat.getAccessToken(), "fake_resource_id", resource);
} catch (ClientResponseFailure ex) {
System.err.println(ex.getResponse().getEntity(String.class));
int status = ex.getResponse().getStatus();
assertTrue(status != Response.Status.OK.getStatusCode(), "Unexpected response status");
}
}
示例7: testModifyResourceWithInvalidPat
import org.jboss.resteasy.client.ClientResponseFailure; //导入依赖的package包/类
/**
* Test UMA resource description modification with invalid PAT
*/
@Test(dependsOnMethods = {"modifyResource"})
public void testModifyResourceWithInvalidPat() throws Exception {
showTitle("testModifyResourceWithInvalidPat");
UmaResourceResponse resourceStatus = null;
try {
UmaResource resource = new UmaResource();
resource.setName("Photo Album 4");
resource.setIconUri("http://www.example.com/icons/flower.png");
resource.setScopes(Arrays.asList("http://photoz.example.com/dev/scopes/view", "http://photoz.example.com/dev/scopes/all"));
resourceStatus = getResourceService().updateResource("Bearer " + pat.getAccessToken() + "_invalid", this.resourceId + "_invalid", resource);
} catch (ClientResponseFailure ex) {
System.err.println(ex.getResponse().getEntity(String.class));
assertEquals(ex.getResponse().getStatus(), Response.Status.UNAUTHORIZED.getStatusCode(), "Unexpected response status");
}
assertNull(resourceStatus, "Resource status is not null");
}
示例8: getOneResource
import org.jboss.resteasy.client.ClientResponseFailure; //导入依赖的package包/类
/**
* Get resource
*/
@Test(dependsOnMethods = {"modifyResource"})
public void getOneResource() throws Exception {
showTitle("getOneResource");
try {
UmaResourceWithId resource = getResourceService().getResource("Bearer " + pat.getAccessToken(), this.resourceId);
assertEquals(resource.getType(), "myType");
UmaResourceWithId resourceWithExpression = getResourceService().getResource("Bearer " + pat.getAccessToken(), this.resourceIdWithScopeExpression);
assertEquals(resourceWithExpression.getScopeExpression(), MODIFY_SCOPE_EXPRESSION);
} catch (ClientResponseFailure ex) {
System.err.println(ex.getResponse().getEntity(String.class));
throw ex;
}
}
示例9: getResources
import org.jboss.resteasy.client.ClientResponseFailure; //导入依赖的package包/类
/**
* Get resources
*/
@Test(dependsOnMethods = {"getOneResource"})
public void getResources() throws Exception {
showTitle("getResources");
List<String> resources = null;
try {
resources = getResourceService().getResourceList("Bearer " + pat.getAccessToken(), "");
} catch (ClientResponseFailure ex) {
System.err.println(ex.getResponse().getEntity(String.class));
throw ex;
}
assertNotNull(resources, "Resources is null");
assertTrue(resources.contains(this.resourceId), "Resource list doesn't contain added resource");
}
示例10: testGetUmaMetaDataConfiguration
import org.jboss.resteasy.client.ClientResponseFailure; //导入依赖的package包/类
/**
* Test for getting meta data configuration
*/
@Test
@Parameters({"umaMetaDataUrl"})
public void testGetUmaMetaDataConfiguration(final String umaMetaDataUrl) throws Exception {
showTitle("testGetUmaMetaDataConfiguration");
UmaMetadataService metaDataConfigurationService = UmaClientFactory.instance().createMetadataService(umaMetaDataUrl, clientExecutor(true));
// Get meta data
UmaMetadata c = null;
try {
c = metaDataConfigurationService.getMetadata();
} catch (ClientResponseFailure ex) {
System.err.println(ex.getResponse().getEntity(String.class));
throw ex;
}
UmaTestUtil.assert_(c);
}
示例11: configure
import org.jboss.resteasy.client.ClientResponseFailure; //导入依赖的package包/类
public void configure() {
//@formatter:off
from("switchyard://GreetingCamelProxy")
.routeId(getClass().getName())
.log("********************************************************************************")
.log("body = ${body}")
.log("********************************************************************************")
.doTry()
.to("switchyard://GreetingService")
.doCatch(ClientResponseFailure.class)
.process(new FailureStatusProcessor())
.end();
//@formatter:on
}
示例12: invoke
import org.jboss.resteasy.client.ClientResponseFailure; //导入依赖的package包/类
private String invoke(String operation, Object content) {
int statusCode = 500;
ClientResponse<?> response = null;
ReferenceInvocation invocation = null;
try {
invocation = greeting.newInvocation(operation);
Message message = invocation.invoke(content).getMessage();
response = message.getContent(ClientResponse.class);
statusCode = response.getStatus();
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
// TODO this won't work due to SWITCHYARD-1890
if (e.getCause() instanceof ClientResponseFailure) {
response = ((ClientResponseFailure) e.getCause()).getResponse();
statusCode = response.getStatus();
}
}
String replyContent = response != null ? response.getEntity(String.class) : "";
sendReply(statusCode, replyContent);
return replyContent;
}
示例13: handleException
import org.jboss.resteasy.client.ClientResponseFailure; //导入依赖的package包/类
public static void handleException(String guid, Exception ex) throws ServiceException {
if (ex instanceof ClientResponseFailure) {
ClientResponseFailure e = (ClientResponseFailure) ex;
ClientResponse response = e.getResponse();
if (response.getResponseStatus().equals(Response.Status.FORBIDDEN)) {
throw new ServiceException(guid, "Authentification failed", e);
}
throw new ServiceException(guid, "Error in the communication to the server " + response.getResponseStatus().getStatusCode(), e);
} else {
String msg = ex.getMessage();
if (msg.startsWith(ClientProtocolException.class.getName())) {
throw new ServiceException(guid, "The server is not valid address.", ex);
}
throw new ServiceException(guid, "Could not connect to the server", ex);
}
}
示例14: searchCustomer
import org.jboss.resteasy.client.ClientResponseFailure; //导入依赖的package包/类
public List<Customer> searchCustomer(Set<String> email, Set<String> externalId) throws DeskComException{
try {
SearchCustomerResponse<Customer> customer = customerApi.search(authProvider.genAuthorizationHeader(), null, null, email, externalId);
return customer.get_embedded().getEntries();
}catch(ClientResponseFailure t){
throw new DeskComException(t);
}
}
示例15: showCustomer
import org.jboss.resteasy.client.ClientResponseFailure; //导入依赖的package包/类
public Customer showCustomer(BigInteger id) throws DeskComException{
try{
return customerApi.show(authProvider.genAuthorizationHeader(), id.toString());
}catch(ClientResponseFailure t){
throw new DeskComException(t);
}
}