Example usage for java.rmi RemoteException getLocalizedMessage

List of usage examples for java.rmi RemoteException getLocalizedMessage

Introduction

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

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

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

/**
 * Remove deployment policy//  w w  w.j a v  a 2  s .  c om
 *
 * @param deploymentPolicyID Deployment policy ID
 * @throws RestAPIException
 */
public static void removeDeploymentPolicy(String deploymentPolicyID)
        throws RestAPIException, AutoscalerServiceDeploymentPolicyNotExistsExceptionException,
        AutoscalerServiceUnremovablePolicyExceptionException {
    try {
        AutoscalerServiceClient.getInstance().removeDeploymentPolicy(deploymentPolicyID);
    } catch (RemoteException e) {
        String msg = "Could not remove deployment policy " + e.getLocalizedMessage();
        log.error(msg, e);
        throw new RestAPIException(msg);
    }
}

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

/**
 * Get Application Policies//www. j ava  2s .  c  o m
 *
 * @return Array of ApplicationPolicyBeans
 * @throws RestAPIException
 */
public static ApplicationPolicyBean[] getApplicationPolicies() throws RestAPIException {

    ApplicationPolicy[] applicationPolicies = null;
    AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
    if (autoscalerServiceClient != null) {
        try {
            applicationPolicies = autoscalerServiceClient.getApplicationPolicies();
        } catch (RemoteException e) {
            String msg = "Could not get application policies" + e.getLocalizedMessage();
            log.error(msg, e);
            throw new RestAPIException(msg);
        }
    }
    return ObjectConverter.convertASStubApplicationPoliciesToApplicationPolicies(applicationPolicies);
}

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

/**
 * Removes an Application Policy/*  w w w.  j  a va2  s  .  co  m*/
 *
 * @param applicationPolicyId applicationPolicyId
 * @throws RestAPIException
 */
public static void removeApplicationPolicy(String applicationPolicyId) throws RestAPIException,
        AutoscalerServiceInvalidPolicyExceptionException, AutoscalerServiceUnremovablePolicyExceptionException {

    if (applicationPolicyId == null) {
        String msg = "Application policy bean id null";
        log.error(msg);
        throw new ApplicationPolicyIdIsEmptyException(msg);
    }

    if (StringUtils.isBlank(applicationPolicyId)) {
        String msg = "Application policy id is empty";
        log.error(msg);
        throw new ApplicationPolicyIdIsEmptyException(msg);
    }

    AutoscalerServiceClient serviceClient = getAutoscalerServiceClient();
    try {
        serviceClient.removeApplicationPolicy(applicationPolicyId);
    } catch (RemoteException e) {
        String msg = "Could not remove application policy. " + e.getLocalizedMessage();
        log.error(msg, e);
        throw new RestAPIException(msg);
    }
}

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

/**
 * Add an application policy//w w  w .j a  v  a2  s .  c o m
 *
 * @param applicationPolicyBean applicationPolicyBean
 * @throws RestAPIException
 */
public static void addApplicationPolicy(ApplicationPolicyBean applicationPolicyBean)
        throws RestAPIException, AutoscalerServiceInvalidApplicationPolicyExceptionException,
        AutoscalerServiceApplicationPolicyAlreadyExistsExceptionException {

    if (applicationPolicyBean == null) {
        String msg = "Application policy bean is null";
        log.error(msg);
        throw new ApplicationPolicyIsEmptyException(msg);
    }

    AutoscalerServiceClient serviceClient = getAutoscalerServiceClient();
    try {
        ApplicationPolicy applicationPolicy = ObjectConverter
                .convertApplicationPolicyBeanToStubAppPolicy(applicationPolicyBean);
        if (applicationPolicy == null) {
            String msg = "Application policy is null";
            log.error(msg);
            throw new ApplicationPolicyIsEmptyException(msg);
        }
        serviceClient.addApplicationPolicy(applicationPolicy);
    } catch (RemoteException e) {
        String msg = "Could not add application policy. " + e.getLocalizedMessage();
        log.error(msg, e);
        throw new RestAPIException(msg);
    } catch (AutoscalerServiceRemoteExceptionException e) {
        String msg = "Could not add application policy. " + e.getLocalizedMessage();
        log.error(msg, e);
        throw new RestAPIException(msg);
    }
}

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

/**
 * Updates Application Policy/*from   w w  w  .  j  a  va2  s  . c o m*/
 *
 * @param applicationPolicyBean applicationPolicyBean
 * @throws RestAPIException
 */
public static void updateApplicationPolicy(ApplicationPolicyBean applicationPolicyBean)
        throws RestAPIException, AutoscalerServiceInvalidApplicationPolicyExceptionException,
        AutoscalerServiceApplicatioinPolicyNotExistsExceptionException {

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

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

        ApplicationPolicy applicationPolicy = ObjectConverter
                .convertApplicationPolicyBeanToStubAppPolicy(applicationPolicyBean);

        try {
            autoscalerServiceClient.updateApplicationPolicy(applicationPolicy);
        } catch (RemoteException e) {
            String msg = "Could not update application policy" + e.getLocalizedMessage();
            log.error(msg, e);
            throw new RestAPIException(msg);
        } catch (AutoscalerServiceRemoteExceptionException e) {
            String msg = "Could not update application policy" + e.getLocalizedMessage();
            log.error(msg, e);
            throw new RestAPIException(msg);
        }
    }
}

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

/**
 * Update deployement policy/*w ww.  j a va2  s  .  c o m*/
 *
 * @param deploymentPolicyDefinitionBean DeploymentPolicyBean
 * @throws RestAPIException
 */
public static void updateDeploymentPolicy(DeploymentPolicyBean deploymentPolicyDefinitionBean)
        throws RestAPIException, AutoscalerServiceInvalidPolicyExceptionException,
        AutoscalerServiceInvalidDeploymentPolicyExceptionException,
        AutoscalerServiceDeploymentPolicyNotExistsExceptionException {
    try {
        if (log.isDebugEnabled()) {
            log.debug(String.format("Updating deployment policy: [deployment-policy-id] %s ",
                    deploymentPolicyDefinitionBean.getId()));
        }

        org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy deploymentPolicy = ObjectConverter
                .convertDeploymentPolicyBeanToASDeploymentPolicy(deploymentPolicyDefinitionBean);

        AutoscalerServiceClient.getInstance().updateDeploymentPolicy(deploymentPolicy);

        if (log.isDebugEnabled()) {
            log.debug(String.format("DeploymentPolicy updated successfully : [deployment-policy-id] %s ",
                    deploymentPolicyDefinitionBean.getId()));
        }
    } catch (RemoteException e) {

        String msg = "Could not update deployment policy " + e.getLocalizedMessage();
        log.error(msg, e);
        throw new RestAPIException(msg);
    } catch (AutoscalerServiceCloudControllerConnectionExceptionException e) {

        String msg = "Could not update deployment policy " + e.getLocalizedMessage();
        log.error(msg, e);
        throw new RestAPIException(msg);
    } catch (AutoscalerServiceRemoteExceptionException e) {

        String msg = "Could not update deployment policy " + e.getLocalizedMessage();
        log.error(msg, e);
        throw new RestAPIException(msg);
    }
}

From source file:com.amalto.core.delegator.IXtentisWSDelegator.java

@Override
public WSVersion getComponentVersion(WSGetComponentVersion wsGetComponentVersion) throws RemoteException {
    try {//from  www .  j  a va 2 s  . c  o m
        if (WSComponent.DataManager.equals(wsGetComponentVersion.getComponent())) {
            Version version = Version.getVersion(this.getClass());
            return new WSVersion(version.getMajor(), version.getMinor(), version.getRevision(),
                    version.getBuild(), version.getDescription(), version.getDate());
        }
        throw new RemoteException(
                "Version information is not available yet for " + wsGetComponentVersion.getComponent() //$NON-NLS-1$
                        + " components"); //$NON-NLS-1$
    } catch (RemoteException e) {
        throw (e);
    } catch (Exception e) {
        throw new RemoteException(
                (e.getCause() == null ? e.getLocalizedMessage() : e.getCause().getLocalizedMessage()));
    }
}