Example usage for java.rmi RemoteException RemoteException

List of usage examples for java.rmi RemoteException RemoteException

Introduction

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

Prototype

public RemoteException(String s) 

Source Link

Document

Constructs a RemoteException with the specified detail message.

Usage

From source file:org.nimbustools.messaging.gt4_0_elastic.v2008_05_05.rm.ServiceRMImpl.java

public DescribeSpotPriceHistoryResponseType describeSpotPriceHistory(DescribeSpotPriceHistoryType req)
        throws RemoteException {
    if (req == null) {
        throw new RemoteException("DescribeSpotPriceHistoryType request is missing");
    }/*from w w  w .  ja v  a2 s. c  om*/
    return this.priceHistory.describeSpotPriceHistory(req, manager);
}

From source file:org.nimbustools.messaging.gt4_0_elastic.v2008_05_05.security.RMServiceSecurity.java

public CreateKeyPairResponseType createKeyPair(CreateKeyPairType createKeyPairRequestMsg)
        throws RemoteException {

    final String keyName = createKeyPairRequestMsg.getKeyName();

    final KeyPair keyPair;
    try {/*w ww . ja  v  a  2 s  . c  o  m*/
        keyPair = keyManager.generateKey(keyName, containerInterface.getCaller());

    } catch (AuthorizationException e) {
        logger.error("Error generating keypair", e);
        throw new RemoteException("You do not have authorization to generate a keypair");
    } catch (OperationDisabledException e) {
        logger.error("Error generating keypair", e);
        throw new RemoteException("Key generation is not supported");
    } catch (KeyExistsException e) {
        logger.error("Error generating keypair", e);
        throw new RemoteException("A keypair named '" + keyName + "' already exists");
    }

    return new CreateKeyPairResponseType(keyPair.getFingerprint(), keyPair.getPrivateKey(), keyName, ""); // TODO do something real with requestId
}

From source file:org.nimbustools.messaging.gt4_0_elastic.v2008_05_05.security.RMServiceSecurity.java

public DescribeKeyPairsResponseType describeKeyPairs(DescribeKeyPairsType describeKeyPairsRequestMsg)
        throws RemoteException {

    //TODO specific key describe. needs API modification

    final List<KeyPair> list;
    try {// w  w w. j  a v a  2 s. co  m
        list = keyManager.listKeys(containerInterface.getCaller());
    } catch (AuthorizationException e) {
        logger.error("Error describing keypairs", e);
        throw new RemoteException("You do not have authorization to list keypairs");
    }

    DescribeKeyPairsResponseItemType[] items = new DescribeKeyPairsResponseItemType[list.size()];
    for (int i = 0; i < list.size(); i++) {
        KeyPair keyPair = list.get(i);
        items[i] = new DescribeKeyPairsResponseItemType(keyPair.getFingerprint(), keyPair.getKeyName());
    }

    DescribeKeyPairsResponseInfoType respInfo = new DescribeKeyPairsResponseInfoType(items);
    return new DescribeKeyPairsResponseType(respInfo, "");
    // TODO do something real with requestId
}

From source file:org.nimbustools.messaging.gt4_0_elastic.v2008_05_05.security.RMServiceSecurity.java

public DeleteKeyPairResponseType deleteKeyPair(DeleteKeyPairType deleteKeyPairRequestMsg)
        throws RemoteException {

    boolean success = true;
    try {//w w w .  j a v  a2 s . c om
        keyManager.removeKey(deleteKeyPairRequestMsg.getKeyName(), containerInterface.getCaller());
    } catch (AuthorizationException e) {
        logger.error("Error removing keypair", e);
        throw new RemoteException("You do not have authorization to remove keypairs");
    } catch (DoesNotExistException e) {
        logger.error("Error removing keypair", e);
        success = false;
    }
    return new DeleteKeyPairResponseType(success, "");
    // TODO do something real with requestId
}

From source file:org.nimbustools.messaging.gt4_0_elastic.v2008_05_05.security.ServiceSecurityImpl.java

protected CreateKeyPairResponseType splitMethod(String splitToken, String input, String ownerID)
        throws RemoteException {

    final String err = "Cannot register keypair.  Semantics "
            + "for keypair creation are different than normal, see " + "documentation.  "
            + "(Expecting <keyname>" + splitToken + "<keyvalue>)";

    final int idx = input.indexOf(splitToken);
    if (idx < 1) {
        // (can't be idx 0 either, there would be no keyname then)
        throw new RemoteException(err + " (no token '" + splitToken + "')");
    }/*w w  w  .ja va  2 s. c  om*/

    if (input.length() < splitToken.length() + 2) {
        throw new RemoteException(err + " (token present but " + "name or value is missing)");
    }

    final String givenKeyName = input.substring(0, idx);
    final int validx = idx + splitToken.length();
    final String givenKeyValue = input.substring(validx);

    final String keyName = givenKeyName.trim();
    final String keyValue = givenKeyValue.trim();

    if (keyName.length() == 0 || keyValue.length() == 0) {
        throw new RemoteException(err + " (token present but " + "name or value is missing)");
    }

    final String fingerprint = FAKE_FINGERPRINT;
    this.sshKeys.newKey(ownerID, keyName, keyValue, fingerprint);

    final CreateKeyPairResponseType ckprt = new CreateKeyPairResponseType();
    ckprt.setKeyFingerprint(fingerprint);
    ckprt.setKeyName(keyName);
    ckprt.setKeyMaterial(keyValue);

    logger.info("SSH key registered, name='" + keyName + "', owner ID='" + ownerID + "'");

    return ckprt;
}

From source file:org.nimbustools.messaging.gt4_0_elastic.v2008_05_05.service.DelegatingService.java

public RunInstancesResponseType runInstances(RunInstancesType runInstancesRequestMsg) throws RemoteException {

    try {/*from   ww w.j av  a2  s.c om*/
        if (this.rm == null) {
            this.findManager();
        }
        return this.rm.runInstances(runInstancesRequestMsg);
    } catch (RemoteException e) {
        if (logger.isDebugEnabled()) {
            logger.error(e.getMessage(), e);
        } else {
            logger.error(e.getMessage());
        }
        throw e;
    } catch (Throwable t) {
        throw new RemoteException(this.unknown(t, "runInstances"));
    }
}

From source file:org.nimbustools.messaging.gt4_0_elastic.v2008_05_05.service.DelegatingService.java

public TerminateInstancesResponseType terminateInstances(TerminateInstancesType terminateInstancesRequestMsg)
        throws RemoteException {

    try {//  ww w .  j a v  a  2 s  .co  m
        if (this.rm == null) {
            this.findManager();
        }
        return this.rm.terminateInstances(terminateInstancesRequestMsg);
    } catch (RemoteException e) {
        if (logger.isDebugEnabled()) {
            logger.error(e.getMessage(), e);
        } else {
            logger.error(e.getMessage());
        }
        throw e;
    } catch (Throwable t) {
        throw new RemoteException(this.unknown(t, "terminateInstances"));
    }
}

From source file:org.nimbustools.messaging.gt4_0_elastic.v2008_05_05.service.DelegatingService.java

public RebootInstancesResponseType rebootInstances(RebootInstancesType rebootInstancesRequestMsg)
        throws RemoteException {

    try {/* w  ww .  j  ava2 s .c o m*/
        if (this.rm == null) {
            this.findManager();
        }
        return this.rm.rebootInstances(rebootInstancesRequestMsg);
    } catch (RemoteException e) {
        if (logger.isDebugEnabled()) {
            logger.error(e.getMessage(), e);
        } else {
            logger.error(e.getMessage());
        }
        throw e;
    } catch (Throwable t) {
        throw new RemoteException(this.unknown(t, "rebootInstances"));
    }
}

From source file:org.nimbustools.messaging.gt4_0_elastic.v2008_05_05.service.DelegatingService.java

public DescribeInstancesResponseType describeInstances(DescribeInstancesType describeInstancesRequestMsg)
        throws RemoteException {

    try {/* w w  w.  j av a2  s . co m*/
        if (this.rm == null) {
            this.findManager();
        }
        return this.rm.describeInstances(describeInstancesRequestMsg);
    } catch (RemoteException e) {
        if (logger.isDebugEnabled()) {
            logger.error(e.getMessage(), e);
        } else {
            logger.error(e.getMessage());
        }
        throw e;
    } catch (Throwable t) {
        throw new RemoteException(this.unknown(t, "describeInstances"));
    }
}

From source file:org.nimbustools.messaging.gt4_0_elastic.v2008_05_05.service.DelegatingService.java

public DescribeAvailabilityZonesResponseType describeAvailabilityZones(
        DescribeAvailabilityZonesType describeAvailabilityZonesRequestMsg) throws RemoteException {
    try {/*from   ww w. j a  v  a 2  s  .  com*/
        if (this.general == null) {
            this.findGeneral();
        }
        return this.general.describeAvailabilityZones(describeAvailabilityZonesRequestMsg);
    } catch (RemoteException e) {
        if (logger.isDebugEnabled()) {
            logger.error(e.getMessage(), e);
        } else {
            logger.error(e.getMessage());
        }
        throw e;
    } catch (Throwable t) {
        throw new RemoteException(this.unknown(t, "describeAvailabilityZones"));
    }
}