diff --git a/README.textile b/README.textile index 4e7cccd86..6b1a34ccc 100644 --- a/README.textile +++ b/README.textile @@ -1,9 +1,11 @@ h1. OpenStack Java SDK +Release 1.0-RC3 is compatible with Essex and Folsom. + h2. Maven |groupId|artifactId|version| -|org.openstack|openstack-java-sdk|1.0-RC2| +|org.openstack|openstack-java-sdk|1.0-RC3| https://raw.github.com/woorea/maven/master/releases/ diff --git a/pom.xml b/pom.xml index 06cb23ba1..73b00f0bb 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ jar org.openstack openstack-java-sdk - 1.0-RC2 + 1.0-RC6 OpenStack Java SDK http://github.com/woorea/openstack-java-sdk diff --git a/src/main/java/org/glassfish/jersey/client/HttpUrlConnector.java b/src/main/java/org/glassfish/jersey/client/HttpUrlConnector.java deleted file mode 100644 index 83f303459..000000000 --- a/src/main/java/org/glassfish/jersey/client/HttpUrlConnector.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2011-2012 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * http://glassfish.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.glassfish.jersey.client; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.util.List; - -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Request; -import javax.ws.rs.core.Response; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLContext; - -import org.glassfish.jersey.internal.util.CommittingOutputStream; -import org.glassfish.jersey.message.internal.Responses; -import org.glassfish.jersey.process.Inflector; - -import com.google.common.base.Predicates; -import com.google.common.collect.Maps; - -/** - * Default client transport connector using {@link HttpURLConnection}. - * - * @author Marek Potociar (marek.potociar at oracle.com) - */ -public class HttpUrlConnector extends RequestWriter implements Inflector { - - private static InputStream getInputStream(HttpURLConnection uc) throws IOException { - if (uc.getResponseCode() < 300) { - return uc.getInputStream(); - } else { - InputStream ein = uc.getErrorStream(); - return (ein != null) ? ein : new ByteArrayInputStream(new byte[0]); - } - } - - @Override - public Response apply(Request request) { - try { - return _apply(request); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - - private Response _apply(final Request request) throws IOException { - final HttpURLConnection uc; - // TODO introduce & leverage optional connection factory to support customized connections - uc = (HttpURLConnection) request.getUri().toURL().openConnection(); - uc.setRequestMethod(request.getMethod()); - - if (uc instanceof HttpsURLConnection) { - if (request.getProperties().containsKey(ClientProperties.HOSTNAME_VERIFIER)) { - final Object o = request.getProperties().get(ClientProperties.HOSTNAME_VERIFIER); - if (o != null && (o instanceof HostnameVerifier)) { - ((HttpsURLConnection) uc).setHostnameVerifier((HostnameVerifier) o); - } - } - - if (request.getProperties().containsKey(ClientProperties.SSL_CONTEXT)) { - final Object o = request.getProperties().get(ClientProperties.SSL_CONTEXT); - if (o != null && (o instanceof SSLContext)) { - ((HttpsURLConnection) uc).setSSLSocketFactory(((SSLContext) o).getSocketFactory()); - } - } - } - - final Object entity = request.getEntity(); - if (entity != null) { - uc.setDoOutput(true); - - writeRequestEntity(request, new RequestEntityWriterListener() { - @Override - public void onRequestEntitySize(long size) { - if (size != -1 && size < Integer.MAX_VALUE) { - System.out.println("setFixedLengthStreamingMode " + size); - // HttpURLConnection uses the int type for content length - - // this just does not work for several consecutive requests. - // another day wasted on HttpUrlConnection bug :/ - //uc.setFixedLengthStreamingMode((int)size); - System.out.println("setChunkedStreamingMode " + size); - uc.setChunkedStreamingMode(256 * 1024); - } else { - // TODO (copied from Jersey 1.x) it appears HttpURLConnection has some bugs in - // chunked encoding - // uc.setChunkedStreamingMode(0); - - // TODO deal with chunked encoding -// Integer chunkedEncodingSize = (Integer)request.getProperties().get( -// ClientConfig.PROPERTY_CHUNKED_ENCODING_SIZE); -// if (chunkedEncodingSize != null) { -// uc.setChunkedStreamingMode(chunkedEncodingSize); -// } - //default - System.out.println("setChunkedStreamingMode " + size); - uc.setChunkedStreamingMode(256 * 1024); - } - } - - @Override - public OutputStream onGetOutputStream() throws IOException { - return new CommittingOutputStream() { - @Override - protected OutputStream getOutputStream() throws IOException { - return uc.getOutputStream(); - } - - @Override - public void commit() throws IOException { - writeOutBoundHeaders(request.getHeaders().asMap(), uc); - } - }; - } - - }); - } else { - writeOutBoundHeaders(request.getHeaders().asMap(), uc); - } - - Response.ResponseBuilder rb = - Responses.from(uc.getResponseCode(), request, getInputStream(uc)); - Responses.fillHeaders(rb, Maps.filterKeys(uc.getHeaderFields(), Predicates.notNull())); - - return rb.build(); - } - - private void writeOutBoundHeaders(MultivaluedMap headers, HttpURLConnection uc) { - for (String key : headers.keySet()) { - List headerValues = headers.get(key); - if (headerValues.size() == 1) { - uc.setRequestProperty(key, headerValues.get(0)); - } else { - StringBuilder b = new StringBuilder(); - boolean add = false; - for (Object value : headerValues) { - if (add) { - b.append(','); - } - add = true; - b.append(value); - } - uc.setRequestProperty(key, b.toString()); - } - } - } -} diff --git a/src/main/java/org/openstack/api/identity/resources/TokensResource.java b/src/main/java/org/openstack/api/identity/resources/TokensResource.java index bd7aacef7..eceee3068 100644 --- a/src/main/java/org/openstack/api/identity/resources/TokensResource.java +++ b/src/main/java/org/openstack/api/identity/resources/TokensResource.java @@ -12,16 +12,16 @@ import org.openstack.model.identity.keystone.KeystoneAccess; public class TokensResource extends Resource { - - public TokensResource(Target target, Properties properties) { + + public TokensResource(final Target target, final Properties properties) { super(target, properties); } - public Access post(Authentication authentication) { + public Access post(final Authentication authentication) { return target.request(MediaType.APPLICATION_JSON).post(Entity.json(authentication), KeystoneAccess.class); } - - public T post(Authentication authentication, Class type) { + + public T post(final Authentication authentication, final Class type) { return target.request(MediaType.APPLICATION_JSON).post(Entity.json(authentication), type); } diff --git a/src/main/java/org/openstack/client/OpenStackClient.java b/src/main/java/org/openstack/client/OpenStackClient.java index 8f47cfaf4..e02f3f431 100644 --- a/src/main/java/org/openstack/client/OpenStackClient.java +++ b/src/main/java/org/openstack/client/OpenStackClient.java @@ -17,189 +17,200 @@ import org.openstack.model.exceptions.OpenStackException; import org.openstack.model.identity.Access; import org.openstack.model.identity.Authentication; +import org.openstack.model.identity.keystone.KeystoneAccess; import org.openstack.model.identity.keystone.KeystoneAuthentication; import com.google.common.base.Preconditions; public class OpenStackClient { - - //private LoggingFilter loggingFilter = new LoggingFilter(Logger.getLogger(OpenStackClient.class.getPackage().getName()),false); - - //private LoggingFilter loggingEntityFilter = new LoggingFilter(Logger.getLogger(OpenStackClient.class.getPackage().getName()),true); - - private Properties properties; - - private Access access; - - private XAuthTokenFilter authFilter; - - private XAuthTokenFilter authAsAdministratorFilter; - - private OpenStackClient() { - System.setProperty(MessageProperties.IO_BUFFER_SIZE,"4096"); - } - - public static OpenStackClient authenticate(Properties properties, Access access) { - OpenStackClient client = new OpenStackClient(); - properties.put("auth.token", access.getToken().getId()); - client.properties = properties; - client.access = access; - client.authFilter = new XAuthTokenFilter(access.getToken().getId()); - client.authAsAdministratorFilter = new XAuthTokenFilter(properties.getProperty("identity.admin.token")); - return client; - } - - public static OpenStackClient authenticate(Properties properties) { - OpenStackClient client = new OpenStackClient(); - client.properties = properties; - - String credentials = properties.getProperty("auth.credentials"); - - KeystoneAuthentication authentication = null; - - if("apiAccessKeyCredentials".equals(credentials)) { - String accessKey = properties.getProperty("auth.accessKey"); - String secretKey = properties.getProperty("auth.secretKey"); - authentication = KeystoneAuthentication.withApiAccessKeyCredentials(accessKey, secretKey); - } else { - String username = properties.getProperty("auth.username"); - String password = properties.getProperty("auth.password"); - authentication = KeystoneAuthentication.withPasswordCredentials(username, password); - } - - String tenantId = properties.getProperty("auth.tenantId"); - String tenantName = properties.getProperty("auth.tenantName"); - - if(tenantId != null) { - authentication.setTenantId(tenantId); - } else if(tenantName != null) { - authentication.setTenantName(tenantName); - } - Access access = client.getIdentityEndpoint().tokens().post(authentication); - return authenticate(properties, access); - } - - public static OpenStackClient authenticate() { - try { - Properties properties = new Properties(); - properties.load(OpenStackClient.class.getResourceAsStream("/openstack.properties")); - return authenticate(properties); - } catch (IOException e) { - throw new OpenStackException("openstack.properties not found in the CLASSPATH"); - } - } - - public OpenStackClient reauthenticateOnTenantById(String tenantId) { - properties.setProperty("auth.tenantId", tenantId); - return authenticate(properties); - } - - public OpenStackClient reauthenticateOnTenantByName(String tenantName) { - properties.setProperty("auth.tenantName", tenantName); - return authenticate(properties); - } - - public void exchangeTokenForTenant(String tenantId) { - String endpoint = properties.getProperty("identity.endpoint.publicURL"); - Authentication authentication = KeystoneAuthentication.withTokenAndTenant(access.getToken().getId(), tenantId); - this.access = target(endpoint, IdentityPublicEndpoint.class).tokens().post(authentication); - } - - public Access getAccess() { - return this.access; - } - - public IdentityClient getIdentityClient() { - return new IdentityClient(getIdentityAdministationEndpoint()); - } - - public IdentityPublicEndpoint getIdentityEndpoint() { - String url = properties.getProperty("identity.endpoint.publicURL"); - Preconditions.checkNotNull(url, "'identity.endpoint.publicURL' property not found"); - return target(url, IdentityPublicEndpoint.class); - } - - public IdentityInternalEndpoint getIdentityInternalEndpoint() { - String url = properties.getProperty("identity.endpoint.public"); - Preconditions.checkNotNull(url, "'identity.endpoint.internalURL' property not found"); - return target(url, IdentityInternalEndpoint.class); - } - - public IdentityAdministrationEndpoint getIdentityAdministationEndpoint() { - String url = properties.getProperty("identity.endpoint.adminURL"); - Preconditions.checkNotNull(url, "'identity.endpoint.adminURL' property not found"); - return target(url, IdentityAdministrationEndpoint.class, true); - } - - public ComputeClient getComputeClient() { - return new ComputeClient(getComputeEndpoint()); - } - - public TenantResource getComputeEndpoint() { - return target(access.getEndpoint("compute", null).getPublicURL(), TenantResource.class); - } - - public ComputeClient getComputeInternalClient() { - return new ComputeClient(getComputeInternalEndpoint()); - } - - public TenantResource getComputeInternalEndpoint() { - return target(access.getEndpoint("compute", null).getInternalURL(), TenantResource.class); - } - - public ComputeClient getComputeAdministrationClient() { - return new ComputeClient(getComputeAdministationEndpoint()); - } - - public TenantResource getComputeAdministationEndpoint() { - return target(access.getEndpoint("compute", null).getAdminURL(), TenantResource.class); - } - - public ImagesClient getImagesClient() { - return new ImagesClient(getImagesEndpoint()); - } - - public ImagesResource getImagesEndpoint() { - return target(access.getEndpoint("image", null).getPublicURL().concat("/v1/images"), ImagesResource.class); - } - - public ImagesResource getImagesInternalEndpoint() { - return target(access.getEndpoint("image", null).getAdminURL().concat("/images"), ImagesResource.class); - } - - public ImagesResource getImagesAdministationEndpoint() { - return target(access.getEndpoint("image", null).getAdminURL().concat("/images"), ImagesResource.class); - } - - public AccountResource getStorageEndpoint() { - return target(access.getEndpoint("object-store", null).getPublicURL(), AccountResource.class); - } - - public AccountResource getStorageInternalEndpoint() { - return target(access.getEndpoint("object-store", null).getInternalURL().replace("AUTH_", ""), AccountResource.class); - } - - public AccountResource getStorageAdministationEndpoint() { - return target(access.getEndpoint("object-store", null).getAdminURL().replace("AUTH_", ""), AccountResource.class); - } - - public T target(String absoluteURL, Class clazz) { - return target(absoluteURL, clazz, false); - } - - private T target(String absoluteURL, Class clazz, boolean useAdministrationToken) { - try { - Target target = RestClient.INSTANCE.getJerseyClient().target(absoluteURL); - if (access != null) { - target.configuration().register(useAdministrationToken ? authAsAdministratorFilter : authFilter); - } - return clazz.getConstructor(Target.class, Properties.class).newInstance(target, properties); - } catch (Exception e) { - throw new RuntimeException(e.getMessage(), e); - } - - } - - + + // private LoggingFilter loggingFilter = new + // LoggingFilter(Logger.getLogger(OpenStackClient.class.getPackage().getName()),false); + + // private LoggingFilter loggingEntityFilter = new + // LoggingFilter(Logger.getLogger(OpenStackClient.class.getPackage().getName()),true); + + private Properties properties; + + private Access access; + + private XAuthTokenFilter authFilter; + + private XAuthTokenFilter authAsAdministratorFilter; + + private OpenStackClient() { + System.setProperty(MessageProperties.IO_BUFFER_SIZE, "4096"); + } + + public static OpenStackClient authenticate(Properties properties, Access access) { + OpenStackClient client = new OpenStackClient(); + properties.put("auth.token", access.getToken().getId()); + client.properties = properties; + client.access = access; + client.authFilter = new XAuthTokenFilter(access.getToken().getId()); + client.authAsAdministratorFilter = new XAuthTokenFilter(properties.getProperty("identity.admin.token")); + return client; + } + + public static OpenStackClient initForAdmin(Properties properties) { + OpenStackClient client = new OpenStackClient(); + client.properties = properties; + client.access = new KeystoneAccess(); + client.authAsAdministratorFilter = new XAuthTokenFilter(properties.getProperty("identity.admin.token")); + return client; + } + + public static OpenStackClient authenticate(Properties properties) { + OpenStackClient client = new OpenStackClient(); + client.properties = properties; + + String credentials = properties.getProperty("auth.credentials"); + + KeystoneAuthentication authentication = null; + + if ("apiAccessKeyCredentials".equals(credentials)) { + String accessKey = properties.getProperty("auth.accessKey"); + String secretKey = properties.getProperty("auth.secretKey"); + authentication = KeystoneAuthentication.withApiAccessKeyCredentials(accessKey, secretKey); + } else { + String username = properties.getProperty("auth.username"); + String password = properties.getProperty("auth.password"); + authentication = KeystoneAuthentication.withPasswordCredentials(username, password); + } + + String tenantId = properties.getProperty("auth.tenantId"); + String tenantName = properties.getProperty("auth.tenantName"); + + if (tenantId != null) { + authentication.setTenantId(tenantId); + } else if (tenantName != null) { + authentication.setTenantName(tenantName); + } + Access access = client.getIdentityEndpoint().tokens().post(authentication); + return authenticate(properties, access); + } + + public static OpenStackClient authenticate() { + try { + Properties properties = new Properties(); + properties.load(OpenStackClient.class.getResourceAsStream("/openstack.properties")); + return authenticate(properties); + } catch (IOException e) { + throw new OpenStackException("openstack.properties not found in the CLASSPATH"); + } + } + + public OpenStackClient reauthenticateOnTenantById(String tenantId) { + properties.setProperty("auth.tenantId", tenantId); + return authenticate(properties); + } + + public OpenStackClient reauthenticateOnTenantByName(String tenantName) { + properties.setProperty("auth.tenantName", tenantName); + return authenticate(properties); + } + + public void exchangeTokenForTenant(String tenantId) { + String endpoint = properties.getProperty("identity.endpoint.publicURL"); + Authentication authentication = KeystoneAuthentication.withTokenAndTenant(access.getToken().getId(), tenantId); + this.access = target(endpoint, IdentityPublicEndpoint.class).tokens().post(authentication); + } + + public Access getAccess() { + return this.access; + } + + public IdentityClient getIdentityClient() { + return new IdentityClient(getIdentityAdministationEndpoint()); + } + + public IdentityPublicEndpoint getIdentityEndpoint() { + String url = properties.getProperty("identity.endpoint.publicURL"); + Preconditions.checkNotNull(url, "'identity.endpoint.publicURL' property not found"); + return target(url, IdentityPublicEndpoint.class); + } + + public IdentityInternalEndpoint getIdentityInternalEndpoint() { + String url = properties.getProperty("identity.endpoint.public"); + Preconditions.checkNotNull(url, "'identity.endpoint.internalURL' property not found"); + return target(url, IdentityInternalEndpoint.class); + } + + public IdentityAdministrationEndpoint getIdentityAdministationEndpoint() { + String url = properties.getProperty("identity.endpoint.adminURL"); + Preconditions.checkNotNull(url, "'identity.endpoint.adminURL' property not found"); + return target(url, IdentityAdministrationEndpoint.class, true); + } + + public ComputeClient getComputeClient() { + return new ComputeClient(getComputeEndpoint()); + } + + public TenantResource getComputeEndpoint() { + return target(access.getEndpoint("compute", null).getPublicURL(), TenantResource.class); + } + + public ComputeClient getComputeInternalClient() { + return new ComputeClient(getComputeInternalEndpoint()); + } + + public TenantResource getComputeInternalEndpoint() { + return target(access.getEndpoint("compute", null).getInternalURL(), TenantResource.class); + } + + public ComputeClient getComputeAdministrationClient() { + return new ComputeClient(getComputeAdministationEndpoint()); + } + + public TenantResource getComputeAdministationEndpoint() { + return target(access.getEndpoint("compute", null).getAdminURL(), TenantResource.class); + } + + public ImagesClient getImagesClient() { + return new ImagesClient(getImagesEndpoint()); + } + + public ImagesResource getImagesEndpoint() { + return target(access.getEndpoint("image", null).getPublicURL().concat("/v1/images"), ImagesResource.class); + } + + public ImagesResource getImagesInternalEndpoint() { + return target(access.getEndpoint("image", null).getAdminURL().concat("/images"), ImagesResource.class); + } + + public ImagesResource getImagesAdministationEndpoint() { + return target(access.getEndpoint("image", null).getAdminURL().concat("/images"), ImagesResource.class); + } + + public AccountResource getStorageEndpoint() { + return target(access.getEndpoint("object-store", null).getPublicURL(), AccountResource.class); + } + + public AccountResource getStorageInternalEndpoint() { + return target(access.getEndpoint("object-store", null).getInternalURL().replace("AUTH_", ""), + AccountResource.class); + } + + public AccountResource getStorageAdministationEndpoint() { + return target(access.getEndpoint("object-store", null).getAdminURL().replace("AUTH_", ""), + AccountResource.class); + } + + public T target(String absoluteURL, Class clazz) { + return target(absoluteURL, clazz, false); + } + + private T target(String absoluteURL, Class clazz, boolean useAdministrationToken) { + try { + Target target = RestClient.INSTANCE.getJerseyClient().target(absoluteURL); + if (access != null) { + target.configuration().register(useAdministrationToken ? authAsAdministratorFilter : authFilter); + } + return clazz.getConstructor(Target.class, Properties.class).newInstance(target, properties); + } catch (Exception e) { + throw new RuntimeException(e.getMessage(), e); + } + + } } diff --git a/src/main/java/org/openstack/model/identity/keystone/KeystoneAccess.java b/src/main/java/org/openstack/model/identity/keystone/KeystoneAccess.java index 9991b7815..e09806690 100644 --- a/src/main/java/org/openstack/model/identity/keystone/KeystoneAccess.java +++ b/src/main/java/org/openstack/model/identity/keystone/KeystoneAccess.java @@ -3,6 +3,7 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.NoSuchElementException; import javax.xml.bind.annotation.XmlAccessType; @@ -44,6 +45,9 @@ public class KeystoneAccess implements Serializable, Access { @XmlElement(type = KeystoneUser.class) private KeystoneUser user; + @XmlElement + private Map metadata; + /* (non-Javadoc) * @see org.openstack.model.identity.glance.Access#getToken() */ @@ -120,4 +124,18 @@ public boolean apply(ServiceEndpoint endpoint) { } } + /** + * @return the metadata + */ + public Map getMetadata() { + return metadata; + } + + /** + * @param metadata the metadata to set + */ + public void setMetadata(Map metadata) { + this.metadata = metadata; + } + } diff --git a/src/main/java/org/openstack/model/identity/keystone/KeystoneRole.java b/src/main/java/org/openstack/model/identity/keystone/KeystoneRole.java index 664e6a7b8..7a2942cbd 100644 --- a/src/main/java/org/openstack/model/identity/keystone/KeystoneRole.java +++ b/src/main/java/org/openstack/model/identity/keystone/KeystoneRole.java @@ -7,17 +7,19 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlRootElement; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.map.annotate.JsonRootName; import org.openstack.model.identity.Role; @XmlRootElement(name="role") @XmlAccessorType(XmlAccessType.NONE) @JsonRootName("role") +@JsonIgnoreProperties(ignoreUnknown = true) public class KeystoneRole implements Serializable, Role { - + @XmlAttribute private String id; - + @XmlAttribute private String name; @@ -26,12 +28,12 @@ public class KeystoneRole implements Serializable, Role { @XmlAttribute private String tenantId; - + public KeystoneRole() { - + } - - public KeystoneRole(String id, String name) { + + public KeystoneRole(final String id, final String name) { this.id = id; this.name = name; } @@ -44,7 +46,7 @@ public String getId() { return id; } - public void setId(String id) { + public void setId(final String id) { this.id = id; } @@ -56,17 +58,17 @@ public String getName() { return name; } - public void setName(String name) { + public void setName(final String name) { this.name = name; } - + //serviceId and tenantId are only in access/user/roles public String getServiceId() { return serviceId; } - public void setServiceId(String serviceId) { + public void setServiceId(final String serviceId) { this.serviceId = serviceId; } @@ -74,7 +76,7 @@ public String getTenantId() { return tenantId; } - public void setTenantId(String tenantId) { + public void setTenantId(final String tenantId) { this.tenantId = tenantId; } @@ -82,6 +84,6 @@ public void setTenantId(String tenantId) { public String toString() { return "Role [id=" + id + ", name=" + name + "]"; } - + } diff --git a/src/main/java/org/openstack/model/identity/keystone/KeystoneServiceEndpoint.java b/src/main/java/org/openstack/model/identity/keystone/KeystoneServiceEndpoint.java index f7d62787e..d32454083 100644 --- a/src/main/java/org/openstack/model/identity/keystone/KeystoneServiceEndpoint.java +++ b/src/main/java/org/openstack/model/identity/keystone/KeystoneServiceEndpoint.java @@ -13,6 +13,9 @@ @JsonIgnoreProperties({"publicURL2"}) public class KeystoneServiceEndpoint implements Serializable, ServiceEndpoint { + @XmlAttribute + private String id; + @XmlAttribute private String region; @@ -128,5 +131,19 @@ public String toString() { + publicURL + ", adminURL=" + adminURL + ", versionId=" + versionId + ", versionList=" + versionList + "]"; } + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(String id) { + this.id = id; + } } diff --git a/src/main/java/org/openstack/model/identity/keystone/KeystoneToken.java b/src/main/java/org/openstack/model/identity/keystone/KeystoneToken.java index f55c99541..dab13ee79 100644 --- a/src/main/java/org/openstack/model/identity/keystone/KeystoneToken.java +++ b/src/main/java/org/openstack/model/identity/keystone/KeystoneToken.java @@ -7,11 +7,13 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.map.annotate.JsonDeserialize; import org.openstack.model.identity.Tenant; import org.openstack.model.identity.Token; @XmlAccessorType(XmlAccessType.NONE) +@JsonIgnoreProperties(ignoreUnknown = true) public class KeystoneToken implements Serializable, Token { @XmlAttribute diff --git a/src/main/java/org/openstack/model/identity/keystone/KeystoneUser.java b/src/main/java/org/openstack/model/identity/keystone/KeystoneUser.java index a82528847..86753a2c4 100644 --- a/src/main/java/org/openstack/model/identity/keystone/KeystoneUser.java +++ b/src/main/java/org/openstack/model/identity/keystone/KeystoneUser.java @@ -10,6 +10,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.annotate.JsonProperty; import org.codehaus.jackson.map.annotate.JsonDeserialize; import org.codehaus.jackson.map.annotate.JsonRootName; @@ -19,6 +20,7 @@ @XmlRootElement(name = "user") @XmlAccessorType(XmlAccessType.NONE) @JsonRootName("user") +@JsonIgnoreProperties(ignoreUnknown = true) public class KeystoneUser implements Serializable, User { @XmlAttribute @@ -38,10 +40,10 @@ public class KeystoneUser implements Serializable, User { @XmlAttribute private boolean enabled; - + @XmlAttribute private String tenantId; - + @XmlElement(name = "roles") @JsonDeserialize(as=List.class, contentAs=KeystoneRole.class) private List roles; @@ -53,10 +55,10 @@ public class KeystoneUser implements Serializable, User { private Map extra; public KeystoneUser() { - + } - - public KeystoneUser(String id, String name) { + + public KeystoneUser(final String id, final String name) { this.id = id; this.name = name; } @@ -69,7 +71,7 @@ public String getId() { return id; } - public void setId(String id) { + public void setId(final String id) { this.id = id; } @@ -81,7 +83,7 @@ public String getName() { return name; } - public void setName(String name) { + public void setName(final String name) { this.name = name; } @@ -93,7 +95,7 @@ public String getPassword() { return password; } - public void setPassword(String password) { + public void setPassword(final String password) { this.password = password; } @@ -105,7 +107,7 @@ public String getEmail() { return email; } - public void setEmail(String email) { + public void setEmail(final String email) { this.email = email; } @@ -117,7 +119,7 @@ public boolean isEnabled() { return enabled; } - public void setEnabled(boolean enabled) { + public void setEnabled(final boolean enabled) { this.enabled = enabled; } @@ -129,7 +131,7 @@ public String getUsername() { return username; } - public void setUsername(String username) { + public void setUsername(final String username) { this.username = username; } @@ -137,7 +139,7 @@ public String getTenantId() { return tenantId; } - public void setTenantId(String tenantId) { + public void setTenantId(final String tenantId) { this.tenantId = tenantId; } @@ -145,7 +147,7 @@ public List getRolesLinks() { return rolesLinks; } - public void setRolesLinks(List rolesLinks) { + public void setRolesLinks(final List rolesLinks) { this.rolesLinks = rolesLinks; } @@ -157,7 +159,7 @@ public List getRoles() { return roles; } - public void setRoles(List roles) { + public void setRoles(final List roles) { this.roles = roles; } @@ -165,7 +167,7 @@ public Map getExtra() { return extra; } - public void setExtra(Map extra) { + public void setExtra(final Map extra) { this.extra = extra; }