当前位置: 首页>>代码示例>>Java>>正文


Java ClientResponseFailure类代码示例

本文整理汇总了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);
	}
}
 
开发者ID:quintoandar,项目名称:desk.com,代码行数:17,代码来源:DeskApiWrapper.java

示例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);
	}
}
 
开发者ID:quintoandar,项目名称:desk.com,代码行数:17,代码来源:DeskApiWrapper.java

示例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");
}
 
开发者ID:GluuFederation,项目名称:oxAuth,代码行数:25,代码来源:UmaRegisterPermissionFlowHttpTest.java

示例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;
    }
}
 
开发者ID:GluuFederation,项目名称:oxAuth,代码行数:19,代码来源:RegisterResourceFlowHttpTest.java

示例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;
    }
}
 
开发者ID:GluuFederation,项目名称:oxAuth,代码行数:19,代码来源:RegisterResourceFlowHttpTest.java

示例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");
    }
}
 
开发者ID:GluuFederation,项目名称:oxAuth,代码行数:21,代码来源:RegisterResourceFlowHttpTest.java

示例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");
}
 
开发者ID:GluuFederation,项目名称:oxAuth,代码行数:23,代码来源:RegisterResourceFlowHttpTest.java

示例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;
    }
}
 
开发者ID:GluuFederation,项目名称:oxAuth,代码行数:19,代码来源:RegisterResourceFlowHttpTest.java

示例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");
}
 
开发者ID:GluuFederation,项目名称:oxAuth,代码行数:19,代码来源:RegisterResourceFlowHttpTest.java

示例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);
}
 
开发者ID:GluuFederation,项目名称:oxAuth,代码行数:22,代码来源:MetaDataFlowHttpTest.java

示例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

    }
 
开发者ID:tadayosi,项目名称:samples-switchyard,代码行数:17,代码来源:GreetingProxyRoute.java

示例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;
}
 
开发者ID:tadayosi,项目名称:samples-switchyard,代码行数:24,代码来源:GreetingProxyBean.java

示例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);
    }
}
 
开发者ID:lorislab,项目名称:smonitor,代码行数:17,代码来源:RSClientUtil.java

示例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);
	}
}
 
开发者ID:quintoandar,项目名称:desk.com,代码行数:9,代码来源:DeskApiWrapper.java

示例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);
	}
}
 
开发者ID:quintoandar,项目名称:desk.com,代码行数:8,代码来源:DeskApiWrapper.java


注:本文中的org.jboss.resteasy.client.ClientResponseFailure类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。