=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/oauth2/OAuth2Client.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/oauth2/OAuth2Client.java 2015-06-10 08:13:05 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/oauth2/OAuth2Client.java 2015-06-24 05:11:33 +0000 @@ -29,11 +29,16 @@ */ import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import org.hisp.dhis.common.BaseIdentifiableObject; import org.hisp.dhis.common.DxfNamespaces; +import org.hisp.dhis.common.IdentifiableObject; +import org.hisp.dhis.common.MergeStrategy; +import java.util.ArrayList; +import java.util.List; import java.util.Objects; import java.util.UUID; @@ -47,6 +52,10 @@ private String secret = UUID.randomUUID().toString(); + private List redirectUris = new ArrayList<>(); + + private List grantTypes = new ArrayList<>(); + public OAuth2Client() { } @@ -75,10 +84,36 @@ this.secret = secret; } + @JsonProperty + @JacksonXmlElementWrapper( localName = "redirectUris", namespace = DxfNamespaces.DXF_2_0 ) + @JacksonXmlProperty( localName = "redirectUri", namespace = DxfNamespaces.DXF_2_0 ) + public List getRedirectUris() + { + return redirectUris; + } + + public void setRedirectUris( List redirectUris ) + { + this.redirectUris = redirectUris; + } + + @JsonProperty + @JacksonXmlElementWrapper( localName = "grantTypes", namespace = DxfNamespaces.DXF_2_0 ) + @JacksonXmlProperty( localName = "grantType", namespace = DxfNamespaces.DXF_2_0 ) + public List getGrantTypes() + { + return grantTypes; + } + + public void setGrantTypes( List grantTypes ) + { + this.grantTypes = grantTypes; + } + @Override public int hashCode() { - return 31 * super.hashCode() + Objects.hash( cid, secret ); + return 31 * super.hashCode() + Objects.hash( cid, secret, redirectUris, grantTypes ); } @Override @@ -100,6 +135,36 @@ final OAuth2Client other = (OAuth2Client) obj; return Objects.equals( this.cid, other.cid ) - && Objects.equals( this.secret, other.secret ); + && Objects.equals( this.secret, other.secret ) + && Objects.equals( this.redirectUris, other.redirectUris ) + && Objects.equals( this.grantTypes, other.grantTypes ); + } + + @Override + public void mergeWith( IdentifiableObject other, MergeStrategy strategy ) + { + super.mergeWith( other, strategy ); + + if ( other.getClass().isInstance( this ) ) + { + OAuth2Client oAuth2Client = (OAuth2Client) other; + + if ( strategy.isReplace() ) + { + cid = oAuth2Client.getCid(); + secret = oAuth2Client.getSecret(); + } + else if ( strategy.isMerge() ) + { + cid = oAuth2Client.getCid() == null ? cid : oAuth2Client.getCid(); + secret = oAuth2Client.getSecret() == null ? secret : oAuth2Client.getSecret(); + } + + redirectUris.clear(); + grantTypes.clear(); + + redirectUris.addAll( oAuth2Client.getRedirectUris() ); + grantTypes.addAll( oAuth2Client.getGrantTypes() ); + } } } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/OAuth2ClientSchemaDescriptor.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/OAuth2ClientSchemaDescriptor.java 2015-06-21 12:44:37 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/OAuth2ClientSchemaDescriptor.java 2015-06-24 05:11:33 +0000 @@ -53,7 +53,6 @@ { Schema schema = new Schema( OAuth2Client.class, SINGULAR, PLURAL ); schema.setRelativeApiEndpoint( API_ENDPOINT ); - schema.setMetadata( false ); schema.setOrder( 1030 ); schema.getAuthorities().add( new Authority( AuthorityType.READ, Lists.newArrayList( "F_OAUTH2_CLIENT_MANAGE" ) ) ); === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/oauth2.hibernate/OAuth2Client.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/oauth2.hibernate/OAuth2Client.hbm.xml 2015-06-11 04:19:07 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/oauth2.hibernate/OAuth2Client.hbm.xml 2015-06-24 05:11:33 +0000 @@ -21,5 +21,19 @@ + + + + + + + + + + + + + +