public KeystoneAccess getToken(String token) throws KeystoneServerException, KeystoneConnectionException { Client client = Client.create(clientConfig); WebResource resource = client.resource(getTokensUrl(token)); try { return sendGetRequest(resource, KeystoneAccess.class); } catch (KeystoneServerException ex) { if (ex.getStatus() == Response.Status.NOT_FOUND.getStatusCode()) { // This indicates that the token was not found log.warn("Keystone v2 token not found {}", token); return null; } throw ex; } }
/** * Retrieves from Keystone server a tenant given its ID. * * @param id ID of the tenant * @return {@link KeystoneTenant} object * @throws KeystoneServerException * @throws KeystoneConnectionException */ public KeystoneTenant getTenant(String id) throws KeystoneServerException, KeystoneConnectionException { log.debug("Keystone v2 get tenant {}", id); Client client = Client.create(clientConfig); WebResource resource = client.resource(getTenantUrl(id)); try { return sendGetRequest(resource, KeystoneTenant.class); } catch (KeystoneServerException ex) { if (ex.getStatus() == Response.Status.NOT_FOUND.getStatusCode()) { // This indicates that the tenant was not found. Not an error // from MidoNet. log.info("Keystone v2 tenant not found {}", id); return null; } throw ex; } }