This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch postgresql
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit c3ee8db7ee9970682bb307de71f53258add1935b
Author: Benoit TELLIER <btell...@linagora.com>
AuthorDate: Tue Dec 12 10:02:02 2023 +0100

    JAMES-2586 Delete JPASieveScript.java
    
    Co-authored-by: Quan Tran <hqt...@linagora.com>
---
 .../src/main/resources/META-INF/persistence.xml    |   1 -
 server/data/data-postgres/pom.xml                  |   6 +-
 .../james/sieve/postgres/model/JPASieveScript.java | 200 ---------------------
 .../src/test/resources/persistence.xml             |   1 -
 4 files changed, 2 insertions(+), 206 deletions(-)

diff --git 
a/server/apps/postgres-app/src/main/resources/META-INF/persistence.xml 
b/server/apps/postgres-app/src/main/resources/META-INF/persistence.xml
index a5837560c7..9c79e80651 100644
--- a/server/apps/postgres-app/src/main/resources/META-INF/persistence.xml
+++ b/server/apps/postgres-app/src/main/resources/META-INF/persistence.xml
@@ -25,7 +25,6 @@
 
     <persistence-unit name="Global" transaction-type="RESOURCE_LOCAL">
         <class>org.apache.james.mailrepository.jpa.model.JPAMail</class>
-        <class>org.apache.james.sieve.postgres.model.JPASieveScript</class>
 
         <properties>
             <property name="openjpa.jdbc.SynchronizeMappings" 
value="buildSchema(ForeignKeys=true)"/>
diff --git a/server/data/data-postgres/pom.xml 
b/server/data/data-postgres/pom.xml
index 88b2b88b9c..f3be0c4f27 100644
--- a/server/data/data-postgres/pom.xml
+++ b/server/data/data-postgres/pom.xml
@@ -155,8 +155,7 @@
                 <artifactId>openjpa-maven-plugin</artifactId>
                 <version>${apache.openjpa.version}</version>
                 <configuration>
-                    
<includes>org/apache/james/sieve/postgres/model/JPASieveScript.class,
-                        org/apache/james/mailrepository/jpa/model/JPAUrl.class,
+                    
<includes>org/apache/james/mailrepository/jpa/model/JPAUrl.class,
                         
org/apache/james/mailrepository/jpa/model/JPAMail.class</includes>
                     <addDefaultConstructor>true</addDefaultConstructor>
                     
<enforcePropertyRestrictions>true</enforcePropertyRestrictions>
@@ -167,8 +166,7 @@
                         </property>
                         <property>
                             <name>metaDataFactory</name>
-                            
<value>jpa(Types=org.apache.james.sieve.postgres.model.JPASieveScript;
-                                
org.apache.james.mailrepository.jpa.model.JPAUrl;
+                            
<value>jpa(Types=org.apache.james.mailrepository.jpa.model.JPAUrl;
                                 
org.apache.james.mailrepository.jpa.model.JPAMail)</value>
                         </property>
                     </toolProperties>
diff --git 
a/server/data/data-postgres/src/main/java/org/apache/james/sieve/postgres/model/JPASieveScript.java
 
b/server/data/data-postgres/src/main/java/org/apache/james/sieve/postgres/model/JPASieveScript.java
deleted file mode 100644
index 8575b34a17..0000000000
--- 
a/server/data/data-postgres/src/main/java/org/apache/james/sieve/postgres/model/JPASieveScript.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.sieve.postgres.model;
-
-import java.time.OffsetDateTime;
-import java.util.Objects;
-import java.util.UUID;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.james.sieverepository.api.ScriptContent;
-import org.apache.james.sieverepository.api.ScriptName;
-import org.apache.james.sieverepository.api.ScriptSummary;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
-
-@Entity(name = "JamesSieveScript")
-@Table(name = "JAMES_SIEVE_SCRIPT")
-@NamedQueries({
-        @NamedQuery(name = "findAllByUsername", query = "SELECT sieveScript 
FROM JamesSieveScript sieveScript WHERE sieveScript.username=:username"),
-        @NamedQuery(name = "findActiveByUsername", query = "SELECT sieveScript 
FROM JamesSieveScript sieveScript WHERE sieveScript.username=:username AND 
sieveScript.isActive=true"),
-        @NamedQuery(name = "findSieveScript", query = "SELECT sieveScript FROM 
JamesSieveScript sieveScript WHERE sieveScript.username=:username AND 
sieveScript.scriptName=:scriptName")
-})
-public class JPASieveScript {
-
-    public static Builder builder() {
-        return new Builder();
-    }
-
-    public static ScriptSummary toSummary(JPASieveScript script) {
-        return new ScriptSummary(new ScriptName(script.getScriptName()), 
script.isActive(), script.getScriptSize());
-    }
-
-    public static class Builder {
-
-        private String username;
-        private String scriptName;
-        private String scriptContent;
-        private long scriptSize;
-        private boolean isActive;
-        private OffsetDateTime activationDateTime;
-
-        public Builder username(String username) {
-            Preconditions.checkNotNull(username);
-            this.username = username;
-            return this;
-        }
-
-        public Builder scriptName(String scriptName) {
-            Preconditions.checkNotNull(scriptName);
-            this.scriptName = scriptName;
-            return this;
-        }
-
-        public Builder scriptContent(ScriptContent scriptContent) {
-            Preconditions.checkNotNull(scriptContent);
-            this.scriptContent = scriptContent.getValue();
-            this.scriptSize = scriptContent.length();
-            return this;
-        }
-
-        public Builder isActive(boolean isActive) {
-            this.isActive = isActive;
-            return this;
-        }
-
-        public JPASieveScript build() {
-            Preconditions.checkState(StringUtils.isNotBlank(username), 
"'username' is mandatory");
-            Preconditions.checkState(StringUtils.isNotBlank(scriptName), 
"'scriptName' is mandatory");
-            this.activationDateTime = isActive ? OffsetDateTime.now() : null;
-            return new JPASieveScript(username, scriptName, scriptContent, 
scriptSize, isActive, activationDateTime);
-        }
-    }
-
-    @Id
-    private String uuid = UUID.randomUUID().toString();
-
-    @Column(name = "USER_NAME", nullable = false, length = 100)
-    private String username;
-
-    @Column(name = "SCRIPT_NAME", nullable = false, length = 255)
-    private String scriptName;
-
-    @Column(name = "SCRIPT_CONTENT", nullable = false, length = 1024)
-    private String scriptContent;
-
-    @Column(name = "SCRIPT_SIZE", nullable = false)
-    private long scriptSize;
-
-    @Column(name = "IS_ACTIVE", nullable = false)
-    private boolean isActive;
-
-    @Column(name = "ACTIVATION_DATE_TIME")
-    private OffsetDateTime activationDateTime;
-
-    /**
-     * @deprecated enhancement only
-     */
-    @Deprecated
-    protected JPASieveScript() {
-    }
-
-    private JPASieveScript(String username, String scriptName, String 
scriptContent, long scriptSize, boolean isActive, OffsetDateTime 
activationDateTime) {
-        this.username = username;
-        this.scriptName = scriptName;
-        this.scriptContent = scriptContent;
-        this.scriptSize = scriptSize;
-        this.isActive = isActive;
-        this.activationDateTime = activationDateTime;
-    }
-
-    public String getUsername() {
-        return username;
-    }
-
-    public String getScriptName() {
-        return scriptName;
-    }
-
-    public String getScriptContent() {
-        return scriptContent;
-    }
-
-    public long getScriptSize() {
-        return scriptSize;
-    }
-
-    public boolean isActive() {
-        return isActive;
-    }
-
-    public OffsetDateTime getActivationDateTime() {
-        return activationDateTime;
-    }
-
-    public void activate() {
-        this.isActive = true;
-        this.activationDateTime = OffsetDateTime.now();
-    }
-
-    public void deactivate() {
-        this.isActive = false;
-        this.activationDateTime = null;
-    }
-
-    public void renameTo(ScriptName newName) {
-        this.scriptName = newName.getValue();
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) {
-            return true;
-        }
-        if (o == null || getClass() != o.getClass()) {
-            return false;
-        }
-        JPASieveScript that = (JPASieveScript) o;
-        return Objects.equals(uuid, that.uuid);
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(uuid);
-    }
-
-    @Override
-    public String toString() {
-        return MoreObjects.toStringHelper(this)
-                .add("uuid", uuid)
-                .add("username", username)
-                .add("scriptName", scriptName)
-                .add("isActive", isActive)
-                .toString();
-    }
-}
diff --git a/server/data/data-postgres/src/test/resources/persistence.xml 
b/server/data/data-postgres/src/test/resources/persistence.xml
index 4ba4447800..d844186105 100644
--- a/server/data/data-postgres/src/test/resources/persistence.xml
+++ b/server/data/data-postgres/src/test/resources/persistence.xml
@@ -27,7 +27,6 @@
        
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
         
<jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/james)</jta-data-source>
         <class>org.apache.james.mailrepository.jpa.model.JPAMail</class>
-        <class>org.apache.james.sieve.postgres.model.JPASieveScript</class>
         <exclude-unlisted-classes>true</exclude-unlisted-classes>
         <properties>
             <property name="openjpa.jdbc.SynchronizeMappings" 
value="buildSchema(ForeignKeys=true)"/>


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org
For additional commands, e-mail: notifications-h...@james.apache.org

Reply via email to