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.webcurator.core.reader.LogReaderSOAPClient.java

public String[] getByRegExpr(String aJob, String aFileName, String regExpr, String addLines,
        boolean prependLineNumbers, int skipFirstMatches, int numberOfMatches) {
    try {//from  ww  w . ja v a  2s .  com
        WCTSoapCall call = new WCTSoapCall(host, port, service, "getByRegExpr");
        Object[] data = { aJob, aFileName, regExpr, addLines, new Boolean(prependLineNumbers),
                new Integer(skipFirstMatches), new Integer(numberOfMatches) };

        String[] logLines = (String[]) call.invoke(data);

        return logLines;
    } catch (RemoteException e) {
        if (log.isErrorEnabled()) {
            log.error("Failed to invoke getByRegExpr on the SOAP service : " + e.getMessage(), e);
        }
        throw new WCTRuntimeException("Failed to invoke getByRegExpr on the SOAP service : " + e.getMessage(),
                e);
    } catch (ServiceException e) {
        if (log.isErrorEnabled()) {
            log.error("Failed to create the SOAP call getByRegExpr : " + e.getMessage(), e);
        }
        throw new WCTRuntimeException("Failed to create the SOAP call getByRegExpr : " + e.getMessage(), e);
    }
}

From source file:org.wso2.am.admin.clients.registry.ResourceAdminServiceClient.java

public void updateTextContent(String path, String content)
        throws RemoteException, ResourceAdminServiceExceptionException {
    try {//  ww w. java2 s  . c om
        resourceAdminServiceStub.updateTextContent(path, content);
    } catch (RemoteException e) {
        log.error("Cannot edit the content of the resource : " + e.getMessage());
        throw new RemoteException("Edit content error : ", e);

    } catch (ResourceAdminServiceExceptionException e) {
        log.error("Cannot edit the content of the resource : " + e.getMessage());
        throw new ResourceAdminServiceExceptionException("Get version error : ", e);

    }
}

From source file:org.wso2.am.admin.clients.registry.ResourceAdminServiceClient.java

public VersionPath[] getVersionPaths(String path)
        throws RemoteException, ResourceAdminServiceExceptionException {
    VersionPath[] versionPaths = null;/*from w  w  w  . java 2s . com*/
    try {
        VersionsBean vb = resourceAdminServiceStub.getVersionsBean(path);
        versionPaths = vb.getVersionPaths();
    } catch (RemoteException e) {
        log.error("No versions for created path : " + e.getMessage());
        throw new RemoteException("Get version error : ", e);
    } catch (ResourceAdminServiceExceptionException e) {
        log.error("Get version error : " + e.getMessage());
        throw new ResourceAdminServiceExceptionException("Get version error : ", e);
    }
    return versionPaths;
}

From source file:org.wso2.am.admin.clients.registry.ResourceAdminServiceClient.java

public VersionsBean getVersionsBean(String path)
        throws RemoteException, ResourceAdminServiceExceptionException {

    try {//from   w  w  w.  j  a v  a 2s .c  om
        return resourceAdminServiceStub.getVersionsBean(path);
    } catch (RemoteException e) {
        log.error("Get version bean fails: " + e.getMessage());
        throw new RemoteException("Get version bean fails:  ", e);
    } catch (ResourceAdminServiceExceptionException e) {
        log.error("Get version bean fails:  " + e.getMessage());
        throw new ResourceAdminServiceExceptionException("Get version bean fails:  : ", e);
    }
}

From source file:org.wso2.am.admin.clients.registry.ResourceAdminServiceClient.java

public void createVersion(String resourcePath) throws RemoteException, ResourceAdminServiceExceptionException {
    try {//from  w  w  w .j  av a2 s . com
        resourceAdminServiceStub.createVersion(resourcePath);
    } catch (RemoteException e) {
        log.error("Create version error : " + e.getMessage());
        throw new RemoteException("Create version error : ", e);
    } catch (ResourceAdminServiceExceptionException e) {
        log.error("Create version error : " + e.getMessage());
        throw new ResourceAdminServiceExceptionException("Create version error : ", e);
    }
}

From source file:org.wso2.am.admin.clients.registry.ResourceAdminServiceClient.java

public void deleteVersionHistory(String path, String snapshotID)
        throws RemoteException, ResourceAdminServiceExceptionException {
    try {/* w w w .j a v a 2 s.  com*/
        resourceAdminServiceStub.deleteVersionHistory(path, snapshotID);

    } catch (RemoteException e) {
        log.error("No versions to delete : " + e.getMessage());
        throw new RemoteException("Delete version error : ", e);
    } catch (ResourceAdminServiceExceptionException e) {
        log.error("Delete version error : " + e.getMessage());
        throw new ResourceAdminServiceExceptionException("Delete version error : ", e);

    }
}

From source file:org.wso2.am.admin.clients.registry.ResourceAdminServiceClient.java

public boolean restoreVersion(String path) throws RemoteException, ResourceAdminServiceExceptionException {
    boolean status = false;
    try {/*  w w w  .ja  v a 2  s .  co m*/
        status = resourceAdminServiceStub.restoreVersion(path);

    } catch (RemoteException e) {
        log.error("No versions to restore : " + e.getMessage());
        throw new RemoteException("Restore version error : ", e);
    } catch (ResourceAdminServiceExceptionException e) {
        log.error("Restore version error : " + e.getMessage());
        throw new ResourceAdminServiceExceptionException("Restore version error : ", e);
    }
    return status;
}

From source file:org.wso2.am.admin.clients.registry.ResourceAdminServiceClient.java

public String getTextContent(String path) throws RemoteException, ResourceAdminServiceExceptionException {
    String content = null;/* ww  w . j av  a  2  s .  co m*/
    try {
        content = resourceAdminServiceStub.getTextContent(path);
    } catch (RemoteException e) {
        log.error("Unable get content : " + e.getMessage());
        throw new RemoteException("Restore version error : ", e);
    } catch (ResourceAdminServiceExceptionException e) {
        log.error("GetTextContent Error : " + e.getMessage());
        throw new ResourceAdminServiceExceptionException("GetTextContent Error :  ", e);
    }
    return content;
}

From source file:org.wso2.am.integration.tests.other.TokenEncryptionScopeTestCase.java

@Test(groups = "wso2.am", description = "Check if Scopes work fine with token encryption enabled.")
public void testTokenEncryptionWithScopes() {

    try {/*from  ww  w  . j  a v a  2  s . c  o  m*/
        userManagementClient = new UserManagementClient(publisherContext.getContextUrls().getBackEndUrl(),
                publisherContext.getContextTenant().getContextUser().getUserName(),
                publisherContext.getContextTenant().getContextUser().getPassword());
        //adding new role subscriber
        userManagementClient.addRole(SUBSCRIBER_ROLE, new String[] {},
                new String[] { "/permission/admin/login", "/permission/admin/manage/api/subscribe" });

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

        //creating user mike
        userManagementClient.addUser(APP_DEV_USER, APP_DEV_PWD, new String[] { SUBSCRIBER_ROLE }, APP_DEV_USER);

    } catch (AxisFault axisFault) {
        log.error("Error while creating UserManagementClient " + axisFault.getMessage());
        //Fail the test case.
        Assert.assertTrue(false, axisFault.getMessage());
    } catch (RemoteException e) {
        log.error("Error while adding role 'subscriber' or user 'mike'" + e.getMessage());
        //Fail the test case.
        Assert.assertTrue(false, e.getMessage());
    } catch (UserAdminUserAdminException e) {
        log.error("Error while adding role 'subscriber' or user 'mike'" + e.getMessage());
        //Fail the test case.
        Assert.assertTrue(false, e.getMessage());
    } catch (XPathExpressionException e) {
        log.error("Error when getting backend URLs of the publisher to initialize the UserManagementClient"
                + e.getMessage());
        //Fail the test case.
        Assert.assertTrue(false, e.getMessage());
    }

    // Adding API
    String apiContext = "tokenencapi";
    String endpointUrl = gatewayUrlsWrk.getWebAppURLNhttp() + "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
        Assert.assertTrue(false);
    } catch (APIManagerIntegrationTestException e) {
        log.error("Integration Test error occurred ", e);
        //Fail the test case
        Assert.assertTrue(false);
    }
    apiRequest.setVersion(API_VERSION);
    apiRequest.setTiersCollection(APIMIntegrationConstants.API_TIER.UNLIMITED);
    apiRequest.setTier(APIMIntegrationConstants.API_TIER.UNLIMITED);

    try {
        apiPublisher.login(publisherContext.getContextTenant().getContextUser().getUserName(),
                publisherContext.getContextTenant().getContextUser().getPassword());

        apiPublisher.addAPI(apiRequest);

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

        //resources are modified using swagger doc.
        // admin_scope(used for POST) :- admin
        // user_scope (used for GET) :- admin,subscriber
        String modifiedResource = "{\"paths\":{ \"/*\":{\"put\":{ \"responses\":{\"200\":{}},\"x-auth-type\":\"Application User\","
                + "\"x-throttling-tier\":\"Unlimited\" },\"post\":{ \"responses\":{\"200\":{}},\"x-auth-type\":\"Application User\","
                + "\"x-throttling-tier\":\"Unlimited\",\"x-scope\":\"admin_scope\"},\"get\":{ \"responses\":{\"200\":{}},\"x-auth-type\":\"Application User\","
                + "\"x-throttling-tier\":\"Unlimited\",\"x-scope\":\"user_scope\"},\"delete\":{ \"responses\":{\"200\":{}},\"x-auth-type\":\"Application User\","
                + "\"x-throttling-tier\":\"Unlimited\"},\"options\":{ \"responses\":{\"200\":{}},\"x-auth-type\":\"None\","
                + "\"x-throttling-tier\":\"Unlimited\"}}},\"swagger\":\"2.0\",\"info\":{\"title\":\"" + API_NAME
                + "\",\"version\":\"1.0.0\"},"
                + "\"x-wso2-security\":{\"apim\":{\"x-wso2-scopes\":[{\"name\":\"admin_scope\",\"description\":\"\",\"key\":\"admin_scope\",\"roles\":\"admin\"},"
                + "{\"name\":\"user_scope\",\"description\":\"\",\"key\":\"user_scope\",\"roles\":\"admin,subscriber\"}]}}}";

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

        // For Admin user
        // create new application and subscribing
        apiStore.login(APP_DEV_USER, APP_DEV_PWD);
        apiStore.addApplication(APP_NAME, APIMIntegrationConstants.APPLICATION_TIER.UNLIMITED, "some_url2",
                "NewApp");
        SubscriptionRequest subscriptionRequest = new SubscriptionRequest(API_NAME, apiProvider);
        subscriptionRequest.setApplicationName(APP_NAME);
        subscriptionRequest.setTier(APIMIntegrationConstants.API_TIER.UNLIMITED);
        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 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());
        String receivedScope = accessTokenGenerationResponse.getString("scope");

        //Check if we receive the scope we requested for.
        Assert.assertEquals(receivedScope, "user_scope",
                "Received scope is " + receivedScope + ", but expected user_scope");
    } catch (APIManagerIntegrationTestException e) {
        log.error("Error occurred while executing Test", e);
        //Fail the test case
        Assert.assertTrue(false);
    } catch (MalformedURLException e) {
        log.error("Malformed tokenEndpointURL ", e);
        //Fail the test case
        Assert.assertTrue(false);
    } catch (JSONException e) {
        log.error("Could not parse response JSON message received from the token endpoint ", e);
        //Fail the test case
        //Assert.assertTrue(false);
    } catch (XPathExpressionException e) {
        log.error("Error occurred while getting credentials from the publisher/store context ", e);
        //Fail the test case
        Assert.assertTrue(false);
    }
}

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

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

    //Add a user called mike and assign him to the subscriber role.
    try {//from  ww  w . ja  va  2 s.  c  om
        userManagementClient = new UserManagementClient(apimContext.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.changeAPILifeCycleStatusTo(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
        GenerateAppKeyRequest generateAppKeyRequest = new GenerateAppKeyRequest(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("https://localhost:8243/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(getGatewayServerURLHttp() + "/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(getGatewayServerURLHttp() + "/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());
    }
}