You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2023/12/14 07:48:21 UTC
(james-project) 03/04: JAMES-2586 Remove JPAMailRepositoryUrlStore.java
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch postgresql
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 6e6e0d05fedf4e0cf25152710f4bfd834b327564
Author: Benoit TELLIER <bt...@linagora.com>
AuthorDate: Tue Dec 12 11:22:49 2023 +0100
JAMES-2586 Remove JPAMailRepositoryUrlStore.java
---
.../src/main/resources/META-INF/persistence.xml | 1 -
.../jpa/JPAMailRepositoryUrlStore.java | 65 ----------------------
.../james/mailrepository/jpa/model/JPAUrl.java | 65 ----------------------
.../src/test/resources/persistence.xml | 1 -
4 files changed, 132 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 489b1e81d7..a5837560c7 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
@@ -24,7 +24,6 @@
version="2.0">
<persistence-unit name="Global" transaction-type="RESOURCE_LOCAL">
- <class>org.apache.james.mailrepository.jpa.model.JPAUrl</class>
<class>org.apache.james.mailrepository.jpa.model.JPAMail</class>
<class>org.apache.james.sieve.postgres.model.JPASieveScript</class>
diff --git a/server/data/data-postgres/src/main/java/org/apache/james/mailrepository/jpa/JPAMailRepositoryUrlStore.java b/server/data/data-postgres/src/main/java/org/apache/james/mailrepository/jpa/JPAMailRepositoryUrlStore.java
deleted file mode 100644
index 1f448a9eca..0000000000
--- a/server/data/data-postgres/src/main/java/org/apache/james/mailrepository/jpa/JPAMailRepositoryUrlStore.java
+++ /dev/null
@@ -1,65 +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.mailrepository.jpa;
-
-import java.util.stream.Stream;
-
-import javax.inject.Inject;
-import javax.persistence.EntityManagerFactory;
-
-import org.apache.james.backends.jpa.TransactionRunner;
-import org.apache.james.mailrepository.api.MailRepositoryUrl;
-import org.apache.james.mailrepository.api.MailRepositoryUrlStore;
-import org.apache.james.mailrepository.jpa.model.JPAUrl;
-
-public class JPAMailRepositoryUrlStore implements MailRepositoryUrlStore {
- private final TransactionRunner transactionRunner;
-
- @Inject
- public JPAMailRepositoryUrlStore(EntityManagerFactory entityManagerFactory) {
- this.transactionRunner = new TransactionRunner(entityManagerFactory);
- }
-
- @Override
- public void add(MailRepositoryUrl url) {
- transactionRunner.run(entityManager ->
- entityManager.merge(JPAUrl.from(url)));
- }
-
- @Override
- public Stream<MailRepositoryUrl> listDistinct() {
- return transactionRunner.runAndRetrieveResult(entityManager ->
- entityManager
- .createNamedQuery("listUrls", JPAUrl.class)
- .getResultList()
- .stream()
- .map(JPAUrl::toMailRepositoryUrl));
- }
-
- @Override
- public boolean contains(MailRepositoryUrl url) {
- return transactionRunner.runAndRetrieveResult(entityManager ->
- ! entityManager.createNamedQuery("getUrl", JPAUrl.class)
- .setParameter("value", url.asString())
- .getResultList()
- .isEmpty());
- }
-}
-
diff --git a/server/data/data-postgres/src/main/java/org/apache/james/mailrepository/jpa/model/JPAUrl.java b/server/data/data-postgres/src/main/java/org/apache/james/mailrepository/jpa/model/JPAUrl.java
deleted file mode 100644
index 9f8e74c69c..0000000000
--- a/server/data/data-postgres/src/main/java/org/apache/james/mailrepository/jpa/model/JPAUrl.java
+++ /dev/null
@@ -1,65 +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.mailrepository.jpa.model;
-
-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.james.mailrepository.api.MailRepositoryUrl;
-
-@Entity(name = "JamesMailRepos")
-@Table(name = "JAMES_MAIL_REPOS")
-@NamedQueries({
- @NamedQuery(name = "listUrls", query = "SELECT url FROM JamesMailRepos url"),
- @NamedQuery(name = "getUrl", query = "SELECT url FROM JamesMailRepos url WHERE url.value=:value")})
-public class JPAUrl {
- public static JPAUrl from(MailRepositoryUrl url) {
- return new JPAUrl(url.asString());
- }
-
- @Id
- @Column(name = "MAIL_REPO_NAME", nullable = false)
- private String value;
-
- /**
- * Default no-args constructor for JPA class enhancement.
- * The constructor need to be public or protected to be used by JPA.
- * See: http://docs.oracle.com/javaee/6/tutorial/doc/bnbqa.html
- * Do not us this constructor, it is for JPA only.
- */
- protected JPAUrl() {
- }
-
- public JPAUrl(String value) {
- this.value = value;
- }
-
- public String getValue() {
- return value;
- }
-
- public MailRepositoryUrl toMailRepositoryUrl() {
- return MailRepositoryUrl.from(value);
- }
-}
diff --git a/server/data/data-postgres/src/test/resources/persistence.xml b/server/data/data-postgres/src/test/resources/persistence.xml
index 6ac35df9a4..4ba4447800 100644
--- a/server/data/data-postgres/src/test/resources/persistence.xml
+++ b/server/data/data-postgres/src/test/resources/persistence.xml
@@ -26,7 +26,6 @@
<persistence-unit name="James" transaction-type="JTA">
<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.JPAUrl</class>
<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>
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org