List of usage examples for javax.xml.bind JAXBException getMessage
public String getMessage()
From source file:com.xerox.amazonws.ec2.Jec2.java
/** * Allocates an address for this account. * * @return the new address allocated//from w w w. jav a 2 s .c o m * @throws EC2Exception wraps checked exceptions */ public String allocateAddress() throws EC2Exception { Map<String, String> params = new HashMap<String, String>(); GetMethod method = new GetMethod(); try { AllocateAddressResponse response = makeRequest(method, "AllocateAddress", params, AllocateAddressResponse.class); return response.getPublicIp(); } catch (JAXBException ex) { throw new EC2Exception("Problem parsing returned message.", ex); } catch (MalformedURLException ex) { throw new EC2Exception(ex.getMessage(), ex); } catch (IOException ex) { throw new EC2Exception(ex.getMessage(), ex); } finally { method.releaseConnection(); } }
From source file:com.xerox.amazonws.ec2.Jec2.java
/** * Register the given AMI.// w w w . j a v a 2s . c om * * @param imageLocation An AMI path within S3. * @return A unique AMI ID that can be used to create and manage instances of this AMI. * @throws EC2Exception wraps checked exceptions */ public String registerImage(String imageLocation) throws EC2Exception { Map<String, String> params = new HashMap<String, String>(); params.put("ImageLocation", imageLocation); GetMethod method = new GetMethod(); try { RegisterImageResponse response = makeRequest(method, "RegisterImage", params, RegisterImageResponse.class); return response.getImageId(); } catch (JAXBException ex) { throw new EC2Exception("Problem parsing returned message.", ex); } catch (MalformedURLException ex) { throw new EC2Exception(ex.getMessage(), ex); } catch (IOException ex) { throw new EC2Exception(ex.getMessage(), ex); } finally { method.releaseConnection(); } }
From source file:com.xerox.amazonws.ec2.Jec2.java
/** * Creates a public/private keypair.//from ww w . ja va2 s . c o m * * @param keyName Name of the keypair. * @return A keypair description ({@link KeyPairInfo}). * @throws EC2Exception wraps checked exceptions */ public KeyPairInfo createKeyPair(String keyName) throws EC2Exception { Map<String, String> params = new HashMap<String, String>(); params.put("KeyName", keyName); GetMethod method = new GetMethod(); try { CreateKeyPairResponse response = makeRequest(method, "CreateKeyPair", params, CreateKeyPairResponse.class); return new KeyPairInfo(response.getKeyName(), response.getKeyFingerprint(), response.getKeyMaterial()); } catch (JAXBException ex) { throw new EC2Exception("Problem parsing returned message.", ex); } catch (MalformedURLException ex) { throw new EC2Exception(ex.getMessage(), ex); } catch (IOException ex) { throw new EC2Exception(ex.getMessage(), ex); } finally { method.releaseConnection(); } }
From source file:com.xerox.amazonws.ec2.Jec2.java
/** * Get an instance's console output./* w w w .j a v a2s . co m*/ * * @param instanceId An instance's id ({@link com.xerox.amazonws.ec2.ReservationDescription.Instance#instanceId}. * @return ({@link ConsoleOutput}) * @throws EC2Exception wraps checked exceptions */ public ConsoleOutput getConsoleOutput(String instanceId) throws EC2Exception { Map<String, String> params = new HashMap<String, String>(); params.put("InstanceId", instanceId); GetMethod method = new GetMethod(); try { GetConsoleOutputResponse response = makeRequest(method, "GetConsoleOutput", params, GetConsoleOutputResponse.class); return new ConsoleOutput(response.getInstanceId(), response.getTimestamp().toGregorianCalendar(), new String(Base64.decodeBase64(response.getOutput().getBytes()))); } catch (JAXBException ex) { throw new EC2Exception("Problem parsing returned message.", ex); } catch (MalformedURLException ex) { throw new EC2Exception(ex.getMessage(), ex); } catch (IOException ex) { throw new EC2Exception(ex.getMessage(), ex); } finally { method.releaseConnection(); } }
From source file:com.xerox.amazonws.ec2.Jec2.java
/** * Deregister the given AMI.//from w w w .j av a2 s. co m * * @param imageId An AMI ID as returned by {@link #registerImage(String)}. * @throws EC2Exception wraps checked exceptions */ public void deregisterImage(String imageId) throws EC2Exception { Map<String, String> params = new HashMap<String, String>(); params.put("ImageId", imageId); GetMethod method = new GetMethod(); try { DeregisterImageResponse response = makeRequest(method, "DeregisterImage", params, DeregisterImageResponse.class); if (!response.isReturn()) { throw new EC2Exception("Could not deregister image : " + imageId + ". No reason given."); } } catch (JAXBException ex) { throw new EC2Exception("Problem parsing returned message.", ex); } catch (MalformedURLException ex) { throw new EC2Exception(ex.getMessage(), ex); } catch (IOException ex) { throw new EC2Exception(ex.getMessage(), ex); } finally { method.releaseConnection(); } }
From source file:com.xerox.amazonws.ec2.Jec2.java
/** * Deletes a security group. /*from w w w . j a v a 2s.co m*/ * * @param name The name of the security group. * @throws EC2Exception wraps checked exceptions */ public void deleteSecurityGroup(String name) throws EC2Exception { Map<String, String> params = new HashMap<String, String>(); params.put("GroupName", name); GetMethod method = new GetMethod(); try { DeleteSecurityGroupResponse response = makeRequest(method, "DeleteSecurityGroup", params, DeleteSecurityGroupResponse.class); if (!response.isReturn()) { throw new EC2Exception("Could not delete security group : " + name + ". No reason given."); } } catch (JAXBException ex) { throw new EC2Exception("Problem parsing returned message.", ex); } catch (MalformedURLException ex) { throw new EC2Exception(ex.getMessage(), ex); } catch (IOException ex) { throw new EC2Exception(ex.getMessage(), ex); } finally { method.releaseConnection(); } }
From source file:com.xerox.amazonws.ec2.Jec2.java
/** * Deletes a public/private keypair.//from w ww . j a v a2 s . c o m * * @param keyName Name of the keypair. * @throws EC2Exception wraps checked exceptions */ public void deleteKeyPair(String keyName) throws EC2Exception { Map<String, String> params = new HashMap<String, String>(); params.put("KeyName", keyName); GetMethod method = new GetMethod(); try { DeleteKeyPairResponse response = makeRequest(method, "DeleteKeyPair", params, DeleteKeyPairResponse.class); if (!response.isReturn()) { throw new EC2Exception("Could not delete keypair : " + keyName + ". No reason given."); } } catch (JAXBException ex) { throw new EC2Exception("Problem parsing returned message.", ex); } catch (MalformedURLException ex) { throw new EC2Exception(ex.getMessage(), ex); } catch (IOException ex) { throw new EC2Exception(ex.getMessage(), ex); } finally { method.releaseConnection(); } }
From source file:com.xerox.amazonws.ec2.Jec2.java
/** * Disassociates an address with an instance. * * @param publicIp the ip address to disassociate * @throws EC2Exception wraps checked exceptions *///www . j a va 2 s.c o m public void disassociateAddress(String publicIp) throws EC2Exception { Map<String, String> params = new HashMap<String, String>(); params.put("PublicIp", publicIp); GetMethod method = new GetMethod(); try { DisassociateAddressResponse response = makeRequest(method, "DisassociateAddress", params, DisassociateAddressResponse.class); if (!response.isReturn()) { throw new EC2Exception("Could not disassociate address with instance (no reason given)."); } } catch (JAXBException ex) { throw new EC2Exception("Problem parsing returned message.", ex); } catch (MalformedURLException ex) { throw new EC2Exception(ex.getMessage(), ex); } catch (IOException ex) { throw new EC2Exception(ex.getMessage(), ex); } finally { method.releaseConnection(); } }
From source file:com.xerox.amazonws.ec2.Jec2.java
/** * Releases an address//from ww w .j ava 2 s. c om * * @param publicIp the ip address to release * @throws EC2Exception wraps checked exceptions */ public void releaseAddress(String publicIp) throws EC2Exception { Map<String, String> params = new HashMap<String, String>(); params.put("PublicIp", publicIp); GetMethod method = new GetMethod(); try { ReleaseAddressResponse response = makeRequest(method, "ReleaseAddress", params, ReleaseAddressResponse.class); if (!response.isReturn()) { throw new EC2Exception("Could not release address (no reason given)."); } } catch (JAXBException ex) { throw new EC2Exception("Problem parsing returned message.", ex); } catch (MalformedURLException ex) { throw new EC2Exception(ex.getMessage(), ex); } catch (IOException ex) { throw new EC2Exception(ex.getMessage(), ex); } finally { method.releaseConnection(); } }
From source file:com.xerox.amazonws.ec2.Jec2.java
/** * Creates a security group./*from ww w . ja v a 2s . c o m*/ * * @param name The name of the security group. * @param desc The description of the security group. * @throws EC2Exception wraps checked exceptions */ public void createSecurityGroup(String name, String desc) throws EC2Exception { Map<String, String> params = new HashMap<String, String>(); params.put("GroupName", name); params.put("GroupDescription", desc); GetMethod method = new GetMethod(); try { CreateSecurityGroupResponse response = makeRequest(method, "CreateSecurityGroup", params, CreateSecurityGroupResponse.class); if (!response.isReturn()) { throw new EC2Exception("Could not create security group : " + name + ". No reason given."); } } catch (JAXBException ex) { throw new EC2Exception("Problem parsing returned message.", ex); } catch (MalformedURLException ex) { throw new EC2Exception(ex.getMessage(), ex); } catch (IOException ex) { throw new EC2Exception(ex.getMessage(), ex); } finally { method.releaseConnection(); } }