Example usage for java.rmi RemoteException getMessage

List of usage examples for java.rmi RemoteException getMessage

Introduction

In this page you can find the example usage for java.rmi RemoteException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message, including the message from the cause, if any, of this exception.

Usage

From source file:org.wso2.am.integration.tests.version.DefaultVersionWithScopesTestCase.java

@Test(groups = "wso2.am", description = "Check functionality of the default version API with scopes")
public void testDefaultVersionAPIWithScopes() throws UserAdminUserAdminException, RemoteException,
        XPathExpressionException, APIManagerIntegrationTestException {

    //Add a user called mike and assign him to the subscriber role.
    try {// www. j a v a  2 s.  c o m
        userManagementClient = new UserManagementClient(keyManagerContext.getContextUrls().getBackEndUrl(),
                "admin", "admin");
        //adding new role subscriber
        userManagementClient.addRole(SUBSCRIBER_ROLE, new String[] {},
                new String[] { "/permission/admin/login", "/permission/admin/manage/api/subscribe" });

        //creating user mike
        userManagementClient.addUser(USER_MIKE, "mike123", new String[] {}, USER_MIKE);

        //creating user sam
        userManagementClient.addUser(USER_SAM, "sam123", new String[] { SUBSCRIBER_ROLE }, "sam");

    } catch (AxisFault axisFault) {
        log.error("Error while creating UserManagementClient " + axisFault.getMessage());
        //Fail the test case.
        assertTrue(false, axisFault.getMessage());
    } catch (RemoteException e) {
        log.error("Error while adding role 'subscriber' or user 'mike'" + e.getMessage());
        //Fail the test case.
        assertTrue(false, e.getMessage());
    } catch (UserAdminUserAdminException e) {
        log.error("Error while adding role 'subscriber' or user 'mike'" + e.getMessage());
        //Fail the test case.
        assertTrue(false, e.getMessage());
    }

    String apiProviderPassword = "admin";

    // Adding API
    String apiContext = "defaultversionscope";
    String endpointUrl = "http://localhost:8280/response";

    //Create the api creation request object
    APIRequest apiRequest = null;
    try {
        apiRequest = new APIRequest(API_NAME, apiContext, new URL(endpointUrl));
    } catch (MalformedURLException e) {
        log.error("Invalid URL " + endpointUrl, e);
        //Fail the test case
        assertTrue(false);
    }
    apiRequest.setDefault_version("default_version");
    apiRequest.setDefault_version_checked("default_version");
    apiRequest.setVersion(API_VERSION);
    apiRequest.setTiersCollection("Unlimited");
    apiRequest.setTier("Unlimited");

    try {
        apiPublisher.login(API_PROVIDER, apiProviderPassword);

        apiPublisher.addAPI(apiRequest);

        //publishing API
        APILifeCycleStateRequest updateRequest = new APILifeCycleStateRequest(API_NAME, API_PROVIDER,
                APILifeCycleState.PUBLISHED);
        apiPublisher.changeAPILifeCycleStatus(updateRequest);

        //resources are modified using swagger doc.
        String modifiedResource = "{\"apiVersion\":\"1.0.0\",\"swaggerVersion\":\"1.2\","
                + "\"authorizations\":{\"oauth2\":{\"scopes\":[{\"description\":\"\", "
                + "\"name\":\"admin_scope\",\"roles\":\"admin\",\"key\":\"admin_scope\"},"
                + "{\"description\":\"\",\"name\":\"user_scope\",\"roles\":\"subscriber\","
                + "\"key\":\"user_scope\"}],"
                + "\"type\":\"oauth2\"}},\"apis\":[{\"index\":0,\"file\":{\"apiVersion\":\"1.0.0\","
                + "\"swaggerVersion\":\"1.2\",\"resourcePath\":\"/default\",\"apis\":[{\"index\":0,"
                + "\"path\":\"/*\",\"operations\":[{\"scope\":\"user_scope\","
                + "\"auth_type\":\"Application User\","
                + "\"throttling_tier\":\"Unlimited\",\"method\":\"GET\",\"parameters\":[]},"
                + "{\"scope\":\"\",\"auth_type\":\"Application User\"," + "\"throttling_tier\":\"Unlimited\","
                + "\"method\":\"POST\",\"parameters\":[]},{\"scope\":\"\",\"auth_type\":\"Application"
                + " User\"," + "\"throttling_tier\":\"Unlimited\",\"method\":\"PUT\",\"parameters\":[]},"
                + "{\"auth_type\":\"Application User\",\"throttling_tier\":\"Unlimited\","
                + "\"method\":\"DELETE\","
                + "\"parameters\":[]},{\"auth_type\":\"None\",\"throttling_tier\":\"Unlimited\","
                + "\"method\":\"OPTIONS\",\"parameters\":[]}]}]},\"description\":\"\",\"path\":"
                + "\"/default\"}],\"info\":{\"title\":\"" + API_NAME + "\",\"termsOfServiceUrl\":\""
                + "\",\"description\":\"\",\"license\":\"\",\"contact\":\"\",\"licenseUrl\":\"\"}}";

        apiPublisher.updateResourceOfAPI(API_PROVIDER, API_NAME, API_VERSION, modifiedResource);

        // For Admin user
        // create new application and subscribing
        apiStore.login("admin", "admin");
        apiStore.addApplication(APP_NAME, "Unlimited", "", "");
        SubscriptionRequest subscriptionRequest = new SubscriptionRequest(API_NAME, API_PROVIDER);
        subscriptionRequest.setApplicationName(APP_NAME);
        apiStore.subscribe(subscriptionRequest);

        //Generate production token and invoke with that
        APPKeyRequestGenerator generateAppKeyRequest = new APPKeyRequestGenerator(APP_NAME);
        String responseString = apiStore.generateApplicationKey(generateAppKeyRequest).getData();
        JSONObject jsonResponse = new JSONObject(responseString);

        // get Consumer Key and Consumer Secret
        String consumerKey = jsonResponse.getJSONObject("data").getJSONObject("key").getString("consumerKey");
        String consumerSecret = jsonResponse.getJSONObject("data").getJSONObject("key")
                .getString("consumerSecret");

        URL tokenEndpointURL = new URL(gatewayUrlsWrk.getWebAppURLNhttps() + "token");
        String accessToken;
        Map<String, String> requestHeaders;
        HttpResponse response;
        String requestBody;
        JSONObject accessTokenGenerationResponse;

        //Obtain user access token for sam, request scope 'user_scope'
        requestBody = "grant_type=password&username=" + USER_SAM + "&password=sam123&scope=user_scope";
        accessTokenGenerationResponse = new JSONObject(apiStore
                .generateUserAccessKey(consumerKey, consumerSecret, requestBody, tokenEndpointURL).getData());
        accessToken = accessTokenGenerationResponse.getString("access_token");

        requestHeaders = new HashMap<String, String>();
        requestHeaders.put("Authorization", "Bearer " + accessToken);

        //Accessing GET method without the version in the URL using the token sam received
        response = HttpRequestUtil.doGet(gatewayUrlsWrk.getWebAppURLNhttp() + "defaultversionscope",
                requestHeaders);
        assertEquals(response.getResponseCode(), Response.Status.OK.getStatusCode(),
                "sam cannot access the GET Method. Response = " + response.getData());

        //Obtaining user access token for mike, request scope 'user_scope'
        requestBody = "grant_type=password&username=" + USER_MIKE + "&password=mike123&scope=user_scope";
        accessTokenGenerationResponse = new JSONObject(apiStore
                .generateUserAccessKey(consumerKey, consumerSecret, requestBody, tokenEndpointURL).getData());
        accessToken = accessTokenGenerationResponse.getString("access_token");

        requestHeaders = new HashMap<String, String>();
        requestHeaders.put("Authorization", "Bearer " + accessToken);

        //Accessing GET method without the version in the URL using the token mike received.
        response = HttpRequestUtil.doGet(gatewayUrlsWrk.getWebAppURLNhttp() + "defaultversionscope",
                requestHeaders);
        assertEquals(response.getResponseCode(), Response.Status.FORBIDDEN.getStatusCode(),
                "Mike should receive an HTTP 403 when trying to access"
                        + " the GET resource. But the response code was " + response.getResponseCode());
    }
    //Catching generic Exception since apiPublisher and apiStore classes throw Exception from their methods.
    catch (Exception e) {
        log.error("Error while executing test case " + e.getMessage(), e);
        //fail the test case.
        assertTrue(false, e.getMessage());
    }
}

From source file:org.wso2.analytics.apim.integration.common.clients.ExecutionManagerAdminServiceClient.java

public TemplateDomainDTO[] getAllDomains() throws RemoteException {
    try {//from  www  .  ja v  a  2  s .  c  o  m
        return executionManagerAdminServiceStub.getAllDomains();
    } catch (RemoteException e) {
        log.error("RemoteException", e);
        throw new RemoteException(e.getMessage(), e);
    }
}

From source file:org.wso2.analytics.apim.integration.common.clients.ExecutionManagerAdminServiceClient.java

public TemplateDomainDTO getDomain(String domainName) throws RemoteException {
    try {/*from   w  ww  .j a v a 2 s. co m*/
        return executionManagerAdminServiceStub.getDomain(domainName);
    } catch (RemoteException e) {
        log.error("RemoteException", e);
        throw new RemoteException(e.getMessage(), e);
    }
}

From source file:org.wso2.analytics.apim.integration.common.clients.ExecutionManagerAdminServiceClient.java

public TemplateConfigurationDTO getConfiguration(String domainName, String configurationName)
        throws RemoteException {
    try {/*from w w w.  j a va  2s  .c o  m*/
        return executionManagerAdminServiceStub.getConfiguration(domainName, configurationName);
    } catch (RemoteException e) {
        log.error("RemoteException", e);
        throw new RemoteException(e.getMessage(), e);
    }
}

From source file:org.wso2.analytics.apim.integration.common.clients.ExecutionManagerAdminServiceClient.java

public TemplateConfigurationDTO[] getConfigurations(String domainName) throws RemoteException {
    try {/*w  w  w. ja  v  a2 s.  c o  m*/
        return executionManagerAdminServiceStub.getConfigurations(domainName);
    } catch (RemoteException e) {
        log.error("RemoteException", e);
        throw new RemoteException(e.getMessage(), e);
    }
}

From source file:org.wso2.analytics.apim.integration.common.clients.ExecutionManagerAdminServiceClient.java

public boolean saveConfiguration(TemplateConfigurationDTO templateConfigDTO) throws RemoteException {
    try {//from  ww  w .j  av a 2s.  com
        return executionManagerAdminServiceStub.saveConfiguration(templateConfigDTO);
    } catch (RemoteException e) {
        log.error("RemoteException", e);
        throw new RemoteException(e.getMessage(), e);
    }
}

From source file:org.wso2.analytics.apim.integration.common.clients.ExecutionManagerAdminServiceClient.java

public boolean deleteConfiguration(String domainName, String configurationName) throws RemoteException {
    try {/*from w w w  .jav a 2  s  .co  m*/
        return executionManagerAdminServiceStub.deleteConfiguration(domainName, configurationName);
    } catch (RemoteException e) {
        log.error("RemoteException", e);
        throw new RemoteException(e.getMessage(), e);
    }
}

From source file:org.wso2.analytics.apim.integration.common.clients.ExecutionManagerAdminServiceClient.java

public int getConfigurationsCount(String domainName) throws RemoteException {
    int count = 0;
    try {//www. j a  v  a  2s .  c o  m
        TemplateConfigurationDTO[] configs = executionManagerAdminServiceStub.getConfigurations(domainName);
        if (configs != null) {
            count = configs.length;
        }
        return count;
    } catch (RemoteException e) {
        log.error("RemoteException", e);
        throw new RemoteException(e.getMessage(), e);
    }
}

From source file:org.wso2.analytics.apim.integration.common.clients.TemplateManagerAdminServiceClient.java

public DomainInfoDTO[] getAllDomains() throws RemoteException {
    try {/*from  w w w.  jav  a  2s  . c o m*/
        return templateManagerAdminServiceStub.getAllDomainInfos();
    } catch (RemoteException e) {
        log.error("RemoteException", e);
        throw new RemoteException(e.getMessage(), e);
    }
}

From source file:org.wso2.analytics.apim.integration.common.clients.TemplateManagerAdminServiceClient.java

public DomainInfoDTO getDomain(String domainName) throws RemoteException {
    try {/*from w w  w.j av a2  s  . com*/
        return templateManagerAdminServiceStub.getDomainInfo(domainName);
    } catch (RemoteException e) {
        log.error("RemoteException", e);
        throw new RemoteException(e.getMessage(), e);
    }
}