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.api.StratosApiV40Utils.java

public static AutoscalePolicyBean[] getAutoScalePolicies() throws RestAPIException {

    org.apache.stratos.autoscaler.stub.autoscale.policy.AutoscalePolicy[] autoscalePolicies = null;
    AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
    if (autoscalerServiceClient != null) {
        try {/*  w w w.ja  va 2 s. c o  m*/
            autoscalePolicies = autoscalerServiceClient.getAutoScalePolicies();

        } catch (RemoteException e) {
            String errorMsg = "Error while getting available autoscaling policies. Cause : " + e.getMessage();
            log.error(errorMsg, e);
            throw new RestAPIException(errorMsg, e);
        }
    }
    return ObjectConverter.convertStubAutoscalePoliciesToAutoscalePolicies(autoscalePolicies);
}

From source file:org.apache.stratos.rest.endpoint.api.StratosApiV40Utils.java

public static AutoscalePolicyBean getAutoScalePolicy(String autoscalePolicyId) throws RestAPIException {

    org.apache.stratos.autoscaler.stub.autoscale.policy.AutoscalePolicy autoscalePolicy = null;
    AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
    if (autoscalerServiceClient != null) {
        try {/*from  ww w.  j a  v a 2 s. co  m*/
            autoscalePolicy = autoscalerServiceClient.getAutoScalePolicy(autoscalePolicyId);

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

    return ObjectConverter.convertStubAutoscalePolicyToAutoscalePolicy(autoscalePolicy);
}

From source file:org.apache.stratos.rest.endpoint.api.StratosApiV41.java

/**
 * Deletes a cartridge definition./*  w w w. j a  v  a 2 s . c o m*/
 *
 * @param cartridgeType the cartridge type
 * @return 200 if cartridge is successfully removed
 * @throws RestAPIException the rest api exception
 */
@DELETE
@Path("/cartridges/{cartridgeType}")
@Produces("application/json")
@Consumes("application/json")
@AuthorizationAction("/permission/admin/stratos/cartridges/manage")
public Response removeCartridge(@PathParam("cartridgeType") String cartridgeType) throws RestAPIException {
    try {
        StratosApiV41Utils.removeCartridge(cartridgeType);
        return Response.ok()
                .entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
                        String.format("Cartridge deleted successfully: [cartridge-type] %s", cartridgeType)))
                .build();
    } catch (RemoteException e) {
        throw new RestAPIException(e.getMessage());
    } catch (CloudControllerServiceInvalidCartridgeTypeExceptionException e) {
        return Response.status(Response.Status.BAD_REQUEST)
                .entity(new ResponseMessageBean(ResponseMessageBean.ERROR,
                        e.getFaultMessage().getInvalidCartridgeTypeException().getMessage()))
                .build();
    } catch (CloudControllerServiceCartridgeNotFoundExceptionException e) {
        return Response.status(Response.Status.BAD_REQUEST)
                .entity(new ResponseMessageBean(ResponseMessageBean.ERROR,
                        e.getFaultMessage().getCartridgeNotFoundException().getMessage()))
                .build();
    }
}

From source file:org.apache.stratos.rest.endpoint.api.StratosApiV41Utils.java

/**
 * Get cartridge details//from  w  w  w .  ja  va2 s  . co  m
 *
 * @param cartridgeType Catridge Type
 * @return Cartridge details
 * @throws RestAPIException
 */
public static CartridgeBean getCartridge(String cartridgeType) throws RestAPIException {
    try {
        Cartridge cartridgeInfo = CloudControllerServiceClient.getInstance().getCartridge(cartridgeType);
        if (cartridgeInfo == null) {
            return null;
        }
        return ObjectConverter.convertCartridgeToCartridgeDefinitionBean(cartridgeInfo);
    } catch (RemoteException e) {
        String message = e.getMessage();
        log.error(message);
        throw new RestAPIException(message, e);
    } catch (CloudControllerServiceCartridgeNotFoundExceptionException e) {
        String message = e.getFaultMessage().getCartridgeNotFoundException().getMessage();
        log.error(message);
        throw new RestAPIException(message, e);
    }
}

From source file:org.apache.stratos.rest.endpoint.api.StratosApiV41Utils.java

/**
 * Check cartridge is available//  www.  j  av a2s.  com
 *
 * @param cartridgeType cartridgeType
 * @return CartridgeBean
 * @throws RestAPIException
 */
public static CartridgeBean getCartridgeForValidate(String cartridgeType)
        throws RestAPIException, CloudControllerServiceCartridgeNotFoundExceptionException {
    try {
        Cartridge cartridgeInfo = CloudControllerServiceClient.getInstance().getCartridge(cartridgeType);
        if (cartridgeInfo == null) {
            return null;
        }
        return ObjectConverter.convertCartridgeToCartridgeDefinitionBean(cartridgeInfo);
    } catch (RemoteException e) {
        String message = e.getMessage();
        log.error(message, e);
        throw new RestAPIException(message, e);
    }

}

From source file:org.apache.stratos.rest.endpoint.api.StratosApiV41Utils.java

/**
 * Add AutoscalePolicy/*w  w  w  .j  a v a  2s  . c o  m*/
 *
 * @param autoscalePolicyBean autoscalePolicyBean
 * @throws RestAPIException
 */
public static void addAutoscalingPolicy(AutoscalePolicyBean autoscalePolicyBean)
        throws RestAPIException, AutoscalerServiceInvalidPolicyExceptionException,
        AutoscalerServiceAutoScalingPolicyAlreadyExistExceptionException {

    log.info(String.format("Adding autoscaling policy: [id] %s", autoscalePolicyBean.getId()));

    AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
    if (autoscalerServiceClient != null) {

        org.apache.stratos.autoscaler.stub.autoscale.policy.AutoscalePolicy autoscalePolicy = ObjectConverter
                .convertToCCAutoscalerPojo(autoscalePolicyBean);

        try {
            autoscalerServiceClient.addAutoscalingPolicy(autoscalePolicy);
        } catch (RemoteException e) {
            log.error(e.getMessage(), e);
            throw new RestAPIException(e.getMessage(), e);
        }
    }
}

From source file:org.apache.stratos.rest.endpoint.api.StratosApiV41Utils.java

/**
 * Updates an Autoscaling Policy/*www .ja  v  a  2s . c om*/
 *
 * @param autoscalePolicyBean autoscalePolicyBean
 * @throws RestAPIException
 */
public static void updateAutoscalingPolicy(AutoscalePolicyBean autoscalePolicyBean)
        throws RestAPIException, AutoscalerServiceInvalidPolicyExceptionException {

    log.info(String.format("Updating autoscaling policy: [id] %s", autoscalePolicyBean.getId()));

    AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
    if (autoscalerServiceClient != null) {

        org.apache.stratos.autoscaler.stub.autoscale.policy.AutoscalePolicy autoscalePolicy = ObjectConverter
                .convertToCCAutoscalerPojo(autoscalePolicyBean);
        try {
            autoscalerServiceClient.updateAutoscalingPolicy(autoscalePolicy);
        } catch (RemoteException e) {
            log.error(e.getMessage(), e);
            throw new RestAPIException(e.getMessage(), e);
        }
    }
}

From source file:org.apache.stratos.rest.endpoint.api.StratosApiV41Utils.java

/**
 * Removes an AutoscalingPolicy//from  w w  w. j  av a 2s . c o m
 *
 * @param autoscalePolicyId autoscalePolicyId
 * @throws RestAPIException
 */
public static void removeAutoscalingPolicy(String autoscalePolicyId)
        throws RestAPIException, AutoscalerServicePolicyDoesNotExistExceptionException,
        AutoscalerServiceUnremovablePolicyExceptionException {

    log.info(String.format("Removing autoscaling policy: [id] %s", autoscalePolicyId));

    AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
    if (autoscalerServiceClient != null) {

        try {
            autoscalerServiceClient.removeAutoscalingPolicy(autoscalePolicyId);
        } catch (RemoteException e) {
            log.error(e.getMessage(), e);
            throw new RestAPIException(e.getMessage(), e);
        }
    }
}

From source file:org.apache.stratos.rest.endpoint.api.StratosApiV41Utils.java

/**
 * Get list of Autoscaling Policies/*w  w  w. ja  va2  s.  c  o  m*/
 *
 * @return Array of AutoscalingPolicies
 * @throws RestAPIException
 */
public static AutoscalePolicyBean[] getAutoScalePolicies() throws RestAPIException {

    org.apache.stratos.autoscaler.stub.autoscale.policy.AutoscalePolicy[] autoscalePolicies = null;
    AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
    if (autoscalerServiceClient != null) {
        try {
            autoscalePolicies = autoscalerServiceClient.getAutoScalePolicies();

        } catch (RemoteException e) {
            String errorMsg = "Error while getting available autoscaling policies. Cause : " + e.getMessage();
            log.error(errorMsg, e);
            throw new RestAPIException(errorMsg, e);
        }
    }
    return ObjectConverter.convertStubAutoscalePoliciesToAutoscalePolicies(autoscalePolicies);
}

From source file:org.apache.stratos.rest.endpoint.api.StratosApiV41Utils.java

/**
 * Get an AutoScalePolicy//from   ww w  .ja  va2 s.c om
 *
 * @param autoscalePolicyId autoscalePolicyId
 * @return AutoscalePolicyBean
 * @throws RestAPIException
 */
public static AutoscalePolicyBean getAutoScalePolicy(String autoscalePolicyId) throws RestAPIException {

    org.apache.stratos.autoscaler.stub.autoscale.policy.AutoscalePolicy autoscalePolicy = null;
    AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
    if (autoscalerServiceClient != null) {
        try {
            autoscalePolicy = autoscalerServiceClient.getAutoScalePolicy(autoscalePolicyId);

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

    return ObjectConverter.convertStubAutoscalePolicyToAutoscalePolicy(autoscalePolicy);
}