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.apache.stratos.rest.endpoint.services.ServiceUtils.java

public static org.apache.stratos.rest.endpoint.bean.autoscaler.policy.deployment.DeploymentPolicy[] getDeploymentPolicies(
        String cartridgeType) throws RestAPIException {

    DeploymentPolicy[] deploymentPolicies = null;
    AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
    if (autoscalerServiceClient != null) {
        try {// w  w  w.java 2 s .  co m
            deploymentPolicies = autoscalerServiceClient.getDeploymentPolicies(cartridgeType);

        } catch (RemoteException e) {
            String errorMsg = "Error while getting available deployment policies for cartridge type "
                    + cartridgeType + ". Cause: " + e.getMessage();
            ;
            log.error(errorMsg, e);
            throw new RestAPIException(errorMsg, e);
        }
    }

    if (deploymentPolicies.length == 0) {
        String errorMsg = "Cannot find any matching deployment policy for Cartridge [type] " + cartridgeType;
        log.error(errorMsg);
        throw new RestAPIException(errorMsg);
    }

    return PojoConverter.populateDeploymentPolicyPojos(deploymentPolicies);
}

From source file:org.apache.stratos.rest.endpoint.services.ServiceUtils.java

public static org.apache.stratos.rest.endpoint.bean.autoscaler.policy.deployment.DeploymentPolicy getDeploymentPolicy(
        String deploymentPolicyId) throws RestAPIException {

    DeploymentPolicy deploymentPolicy = null;
    AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
    if (autoscalerServiceClient != null) {
        try {//from w w  w.j  a v  a2s .c  o m
            deploymentPolicy = autoscalerServiceClient.getDeploymentPolicy(deploymentPolicyId);

        } catch (RemoteException e) {
            String errorMsg = "Error while getting deployment policy with id " + deploymentPolicyId
                    + ". Cause: " + e.getMessage();
            log.error(errorMsg, e);
            throw new RestAPIException(errorMsg, e);
        }
    }

    if (deploymentPolicy == null) {
        String errorMsg = "Cannot find a matching deployment policy for [id] " + deploymentPolicyId;
        log.error(errorMsg);
        throw new RestAPIException(errorMsg);
    }

    return PojoConverter.populateDeploymentPolicyPojo(deploymentPolicy);
}

From source file:org.apache.stratos.rest.endpoint.services.ServiceUtils.java

public static PartitionGroup[] getPartitionGroups(String deploymentPolicyId) throws RestAPIException {

    org.apache.stratos.autoscaler.partition.PartitionGroup[] partitionGroups = null;
    AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
    if (autoscalerServiceClient != null) {
        try {/*from w  ww  .  j a  v  a  2s  .  c  o m*/
            partitionGroups = autoscalerServiceClient.getPartitionGroups(deploymentPolicyId);

        } catch (RemoteException e) {
            String errorMsg = "Error getting available partition groups for deployment policy id "
                    + deploymentPolicyId + ". Cause: " + e.getMessage();
            log.error(errorMsg, e);
            throw new RestAPIException(errorMsg, e);
        }
    }

    return PojoConverter.populatePartitionGroupPojos(partitionGroups);
}

From source file:org.bbsync.webservice.client.proxytool.ContextProxyTool.java

/**
 * Deactivates the proxy tool associated with the current session. The 
 * caller must be logged in as the tool that it wishes to deactivate. The 
 * status field of the returned object will be true if the deactivation 
 * succeeds, and false otherwise. In case of failure, consult the 
 * failureError field for the reasons why.
 * //from w w  w  . j  a v  a 2s  .  c  o m
 * Because you must be logged in as the tool to be deactivated in order to
 * use this method, be sure that the tool has been configured to use the
 * tool method "Context.WS:deactivateTool" in conf.xml.
 * 
 * @param ignore - Currently unused
 * @return Returns the results of deactivation (true, false or error code).
 */
protected DeactivateToolResultVO deactivateTool(String ignore) {
    DeactivateToolResponse response = null;
    DeactivateTool deactivate = new DeactivateTool();
    deactivate.setIgnore(ignore);
    //Don't setupSession() or initializeSession().
    //To use this method, your session should already be active.
    try {
        response = contextWS.deactivateTool(deactivate);
    } catch (RemoteException e) {
        logger.error("Encountered a remote exception while trying to Deactivate Tool");
        logger.error(e.getMessage());
        return null;
    }
    //don't cleanupSession() here.  Do it at logout().
    if (response == null) {
        logger.warn("deactivateTool returned null.");
        return null;
    }
    return response.get_return();
}

From source file:org.bbsync.webservice.client.proxytool.ContextProxyTool.java

/**
 * emulateUser can be used to switch the 'current' user for your Web 
 * Service session to someone else. Once you have emulated a user you will 
 * lose all your current entitlements (including tool based entitlements if
 * you logged in as a 'tool'). To regain those tool entitlements you either
 * have to logout/initialize/logintool again or 
 * //from   ww  w .  j ava  2s.  com
 * session = emulateUser(session,null); 
 * 
 * (If you were originally logged in as a user with this entitlement (i.e. 
 * 'administrator') then you cannot emulate a null user - null is only valid 
 * if originally logged in as a tool.  
 * 
 * If you use emulate user with tool login, be sure to grant the following
 * entitlement: webservices.tools.EMULATE.  This can be done by adding
 * "Context.WS:emulateUser" to the list of entitlements for the particular 
 * tool in conf.xml.  You'll then have to re-register the tool for the
 * entitlement to take effect.  
 * 
 * When emulating a user, make sure that the emulated user has the correct 
 * System privileges to perform the task. This means that the user should 
 * have a system role assigned that is not "None", "Guest", or "User".  
 * System privileges can be assigned to System roles by using the Admin GUI. 
 * 
 * @param user_to_emulate - username/login id of the user you wish to 
 *                          become.  Null will 'unemulate' any user.
 * @return Returns true if successful.  Otherwise returns false.
 */
protected boolean emulateUser(String user_to_emulate) {
    EmulateUserResponse response = null;
    EmulateUser emulate_user = new EmulateUser();
    emulate_user.setUserToEmulate(user_to_emulate);
    //Don't setupSession() or initializeSession().
    //To use this method, your session should already be active.
    try {
        response = contextWS.emulateUser(emulate_user);
    } catch (RemoteException e) {
        logger.error("Encountered a remote exception while trying to Emulate User");
        logger.error(e.getMessage());
        return false;
    }
    //don't cleanupSession() here.  Do it at logout().
    if (response == null) {
        logger.warn("emulateUser returned null.");
        return false;
    }
    return response.get_return();
}

From source file:org.bbsync.webservice.client.proxytool.ContextProxyTool.java

/**
 * Call this to extend the life of your Web Service session.  Note that you
 * cannot set a session to be live for more than 24 hours from the current 
 * time./*from w ww.  ja v  a 2  s. c o m*/
 * 
 * @param additional_seconds - the number of additional seconds you want to 
 *                             add to the life of your session.
 * @return Returns true if successful.  Otherwise returns false.
 */
protected boolean extendSessionLife(Long additional_seconds) {
    ExtendSessionLifeResponse response = null;
    ExtendSessionLife extend = new ExtendSessionLife();
    extend.setAdditionalSeconds(additional_seconds);
    //Don't setupSession() or initializeSession().
    //To use this method, your session should already be active.
    try {
        response = contextWS.extendSessionLife(extend);
    } catch (RemoteException e) {
        logger.error("Encountered a remote exception while trying to Extend SessionLife");
        logger.error(e.getMessage());
        return false;
    }
    //Don't cleanupSession() here.  Do it at logout().
    if (response == null) {
        logger.warn("extendSessionLife returned null.");
        return false;
    }
    return response.get_return();
}

From source file:org.bbsync.webservice.client.proxytool.ContextProxyTool.java

/**
 * If session is a user then return the courses they are enrolled in.
 * If session is a tool then return an empty set.
 * //ww  w .  ja va2s .  c om
 * @return Returns an array of courseidvo's representing the currently 
 *         logged-in user's memberships.
 */
protected CourseIdVO[] getMyMemberships() {
    GetMyMembershipsResponse response = null;
    //Don't setupSession() or initializeSession().
    //To use this method, your session should already be active.
    try {
        response = contextWS.getMyMemberships();
    } catch (RemoteException e) {
        logger.error("Encountered a remote exception while trying to Get My Memberships");
        logger.error(e.getMessage());
        return null;
    }
    //don't cleanupSession() here.  Do it at logout().
    if (response == null) {
        logger.warn("getMyMemberships returned null.");
        return null;
    }
    return response.get_return();
}

From source file:org.bbsync.webservice.client.proxytool.ContextProxyTool.java

/**
 * If session is a user and userid==session.userid then return the courses 
 * they are enrolled in.// w  w w . j a va2 s . c om
 * If session is a user and userid!=session.userid then return an empty 
 * set.
 * If session is a tool then return the courses the given user is enrolled 
 * in.
 * 
 * Entitlement Required: webservices.tools.getMemberships.VIEW
 * 
 * @param user_id - the user you wish to get memberships for
 * @return Returns an array of courseidvo's representing the user's 
 *         memberships.
 */
protected CourseIdVO[] getMemberships(String user_id) {
    GetMembershipsResponse response = null;
    GetMemberships memberships = new GetMemberships();
    memberships.setUserid(user_id);
    //Don't setupSession() or initializeSession().
    //To use this method, your session should already be active.
    try {
        response = contextWS.getMemberships(memberships);
    } catch (RemoteException e) {
        logger.error("Encountered a remote exception while trying to Get Memberships");
        logger.error(e.getMessage());
        return null;
    }
    //don't cleanupSession() here.  Do it at logout().
    if (response == null) {
        logger.warn("getMemberships returned null.");
        return null;
    }
    return response.get_return();
}

From source file:org.bbsync.webservice.client.proxytool.ContextProxyTool.java

/**
 * This will return a list of the entitlements the specified method
 * requires for successful completion. Typical use of this method is during
 * client application installation to build up the arguments required when 
 * calling registerTool./*from   w w  w . j  a va  2 s  .c om*/
 * 
 * @param method - the name of a method on this Web Service that you plan 
 *                 to call while using tool based authentication.
 * @return Returns a String[] array of entitlement UIDs.
 */
protected String[] getRequiredEntitlements(String method) {
    GetRequiredEntitlementsResponse response = null;
    GetRequiredEntitlements gre = new GetRequiredEntitlements();
    gre.setMethod(method);
    setupSession();
    try {
        response = contextWS.getRequiredEntitlements(gre);
    } catch (RemoteException e) {
        logger.error("Encountered a remote exception while trying to Get Required Entitlements");
        logger.error(e.getMessage());
        return null;
    }
    cleanupSession();
    if (response == null) {
        logger.warn("getRequiredEntitlements returned null.");
        return null;
    }
    return response.get_return();
}

From source file:org.bbsync.webservice.client.proxytool.ContextProxyTool.java

private VersionVO _getServerVersion(VersionVO unused) {
    GetServerVersionResponse response = null;
    GetServerVersion version = new GetServerVersion();
    version.setUnused(unused);//from  w ww. j  a v  a2 s.c o  m
    //Don't setupSession() or initializeSession().
    //To use this method, your session should already be active.
    try {
        response = contextWS.getServerVersion(version);
    } catch (RemoteException e) {
        logger.error("Encountered a remote exception while trying to Get Server Version");
        logger.error(e.getMessage());
        return null;
    }
    //don't cleanupSession() here.  Do it at logout().
    if (response == null) {
        logger.warn("getServerVersion returned null.");
        return null;
    }
    return response.get_return();
}