From e55262c8cca26d2c838185a993f5c792a1863ea0 Mon Sep 17 00:00:00 2001 From: Martin Stockhammer Date: Sat, 19 Nov 2016 23:26:08 +0100 Subject: [PATCH] Add schema changes for compatibility with JDO implementation --- .../main/resources/META-INF/persistence.xml | 1 + .../redback/rbac/jpa/model/JpaOperation.java | 2 +- .../redback/rbac/jpa/model/JpaPermission.java | 2 +- .../redback/rbac/jpa/model/JpaResource.java | 8 ++++---- .../redback/rbac/jpa/model/JpaRole.java | 4 ++-- .../rbac/jpa/model/JpaUserAssignment.java | 2 +- .../redback/users/jpa/model/JpaUser.java | 18 +++++++++++------- 7 files changed, 21 insertions(+), 16 deletions(-) diff --git a/redback-common/redback-common-jpa/src/main/resources/META-INF/persistence.xml b/redback-common/redback-common-jpa/src/main/resources/META-INF/persistence.xml index 6d9f1afa..602cd977 100644 --- a/redback-common/redback-common-jpa/src/main/resources/META-INF/persistence.xml +++ b/redback-common/redback-common-jpa/src/main/resources/META-INF/persistence.xml @@ -34,6 +34,7 @@ + diff --git a/redback-rbac/redback-rbac-providers/redback-rbac-jpa/src/main/java/org/apache/archiva/redback/rbac/jpa/model/JpaOperation.java b/redback-rbac/redback-rbac-providers/redback-rbac-jpa/src/main/java/org/apache/archiva/redback/rbac/jpa/model/JpaOperation.java index aaf0af7a..bf9e7477 100644 --- a/redback-rbac/redback-rbac-providers/redback-rbac-jpa/src/main/java/org/apache/archiva/redback/rbac/jpa/model/JpaOperation.java +++ b/redback-rbac/redback-rbac-providers/redback-rbac-jpa/src/main/java/org/apache/archiva/redback/rbac/jpa/model/JpaOperation.java @@ -40,7 +40,7 @@ public class JpaOperation implements Operation, Serializable { @Column(name="DESCRIPTION") private String description; @Column(name="PERMANENT", nullable = false) - private boolean permanent; + private Boolean permanent = false; @Override diff --git a/redback-rbac/redback-rbac-providers/redback-rbac-jpa/src/main/java/org/apache/archiva/redback/rbac/jpa/model/JpaPermission.java b/redback-rbac/redback-rbac-providers/redback-rbac-jpa/src/main/java/org/apache/archiva/redback/rbac/jpa/model/JpaPermission.java index 218cbc7d..ed3928a6 100644 --- a/redback-rbac/redback-rbac-providers/redback-rbac-jpa/src/main/java/org/apache/archiva/redback/rbac/jpa/model/JpaPermission.java +++ b/redback-rbac/redback-rbac-providers/redback-rbac-jpa/src/main/java/org/apache/archiva/redback/rbac/jpa/model/JpaPermission.java @@ -40,7 +40,7 @@ public class JpaPermission implements Permission,Serializable { @Column(name="DESCRIPTION") private String description; @Column(name="PERMANENT", nullable = false) - private boolean permanent; + private Boolean permanent = false; @ManyToOne(cascade = CascadeType.ALL) @JoinColumn( name="OPERATION_NAME_OID", diff --git a/redback-rbac/redback-rbac-providers/redback-rbac-jpa/src/main/java/org/apache/archiva/redback/rbac/jpa/model/JpaResource.java b/redback-rbac/redback-rbac-providers/redback-rbac-jpa/src/main/java/org/apache/archiva/redback/rbac/jpa/model/JpaResource.java index dd2f3f42..19da451d 100644 --- a/redback-rbac/redback-rbac-providers/redback-rbac-jpa/src/main/java/org/apache/archiva/redback/rbac/jpa/model/JpaResource.java +++ b/redback-rbac/redback-rbac-providers/redback-rbac-jpa/src/main/java/org/apache/archiva/redback/rbac/jpa/model/JpaResource.java @@ -37,10 +37,10 @@ public class JpaResource implements Resource, Serializable { @Id @Column(name="IDENTIFIER") private String identifier; - @Column(name="PATTERN", nullable = false) - private boolean pattern; - @Column(name="PERMANENT", nullable = false) - private boolean permanent; + @Column(name="PATTERN", nullable = false, columnDefinition = "CHAR(1)") + private Boolean pattern = false; + @Column(name="PERMANENT", nullable = false, columnDefinition = "CHAR(1)") + private Boolean permanent = false; @Override diff --git a/redback-rbac/redback-rbac-providers/redback-rbac-jpa/src/main/java/org/apache/archiva/redback/rbac/jpa/model/JpaRole.java b/redback-rbac/redback-rbac-providers/redback-rbac-jpa/src/main/java/org/apache/archiva/redback/rbac/jpa/model/JpaRole.java index 425fa35c..565409b1 100644 --- a/redback-rbac/redback-rbac-providers/redback-rbac-jpa/src/main/java/org/apache/archiva/redback/rbac/jpa/model/JpaRole.java +++ b/redback-rbac/redback-rbac-providers/redback-rbac-jpa/src/main/java/org/apache/archiva/redback/rbac/jpa/model/JpaRole.java @@ -43,9 +43,9 @@ public class JpaRole extends AbstractRole implements Serializable { @Column(name="DESCRIPTION") private String description; @Column(name="ASSIGNABLE",nullable = false) - private boolean assignable; + private Boolean assignable = false; @Column(name="PERMANENT", nullable = false) - private boolean permanent; + private Boolean permanent = false; @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @OrderColumn(name="INTEGER_IDX", nullable = false) @JoinTable( diff --git a/redback-rbac/redback-rbac-providers/redback-rbac-jpa/src/main/java/org/apache/archiva/redback/rbac/jpa/model/JpaUserAssignment.java b/redback-rbac/redback-rbac-providers/redback-rbac-jpa/src/main/java/org/apache/archiva/redback/rbac/jpa/model/JpaUserAssignment.java index 3b6853c8..7e64bdd1 100644 --- a/redback-rbac/redback-rbac-providers/redback-rbac-jpa/src/main/java/org/apache/archiva/redback/rbac/jpa/model/JpaUserAssignment.java +++ b/redback-rbac/redback-rbac-providers/redback-rbac-jpa/src/main/java/org/apache/archiva/redback/rbac/jpa/model/JpaUserAssignment.java @@ -58,7 +58,7 @@ public class JpaUserAssignment extends AbstractUserAssignment implements UserAss ) private List roleNames = new ArrayList(); @Column(name="PERMANENT", nullable = false) - private boolean permanent = false; + private Boolean permanent = false; @Column(name="LAST_UPDATED") private Date timestamp; diff --git a/redback-users/redback-users-providers/redback-users-jpa/src/main/java/org/apache/archiva/redback/users/jpa/model/JpaUser.java b/redback-users/redback-users-providers/redback-users-jpa/src/main/java/org/apache/archiva/redback/users/jpa/model/JpaUser.java index cf45ba37..e5ee5eb4 100644 --- a/redback-users/redback-users-providers/redback-users-jpa/src/main/java/org/apache/archiva/redback/users/jpa/model/JpaUser.java +++ b/redback-users/redback-users-providers/redback-users-jpa/src/main/java/org/apache/archiva/redback/users/jpa/model/JpaUser.java @@ -19,6 +19,9 @@ package org.apache.archiva.redback.users.jpa.model; * under the License. */ +import org.apache.openjpa.persistence.ExternalValues; +import org.apache.openjpa.persistence.Type; + import javax.persistence.CollectionTable; import javax.persistence.Column; import javax.persistence.ElementCollection; @@ -26,6 +29,7 @@ import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.Id; import javax.persistence.JoinColumn; +import javax.persistence.OneToMany; import javax.persistence.OrderColumn; import javax.persistence.Table; import java.util.ArrayList; @@ -52,26 +56,26 @@ public class JpaUser implements org.apache.archiva.redback.users.User { private Date lastPasswordChange; @ElementCollection(fetch = FetchType.EAGER) @OrderColumn(name="INTEGER_IDX", nullable = false) - @Column(name="STRING_ELE") + @Column(name="STRING_ELE", nullable = false) @CollectionTable(name="JDOUSER_PREVIOUSENCODEDPASSWORDS", joinColumns = @JoinColumn(name = "USERNAME_OID", nullable = false, referencedColumnName = "USERNAME") ) private List previousEncodedPasswords = new ArrayList(); @Column(name="PERMANENT", nullable = false) - private boolean permanent; + private Boolean permanent = false; @Column(name="LOCKED", nullable = false) - private boolean locked; + private Boolean locked = false; @Column(name="PASSWORD_CHANGE_REQUIRED", nullable = false) - private boolean passwordChangeRequired; + private Boolean passwordChangeRequired = false; @Column(name="VALIDATED", nullable = false) - private boolean validated; + private Boolean validated = false; @Column(name="COUNT_FAILED_LOGIN_ATTEMPTS",nullable = false) - private int countFailedLoginAttempts; + private int countFailedLoginAttempts = 0; @Column(name="ACCOUNT_CREATION_DATE") private Date accountCreationDate; @Column(name="LAST_LOGIN_DATE") private Date lastLoginDate; - @Column(name="USER_PASSSWORD") + @Column(name="USER_PASSWORD") private String rawPassword;