backend migrated to Java 17
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
module net.woggioni.jpacrepo.api {
|
||||
requires static lombok;
|
||||
requires static jakarta.xml.bind;
|
||||
requires static jakarta.ejb;
|
||||
requires static jakarta.persistence;
|
||||
requires jakarta.xml.bind;
|
||||
requires jakarta.ejb;
|
||||
requires jakarta.persistence;
|
||||
requires jakarta.annotation;
|
||||
requires jakarta.json.bind;
|
||||
|
||||
exports net.woggioni.jpacrepo.api.model;
|
||||
exports net.woggioni.jpacrepo.api.service;
|
||||
exports net.woggioni.jpacrepo.api.wire;
|
||||
}
|
@@ -3,6 +3,8 @@ package net.woggioni.jpacrepo.api.model;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public enum CompressionFormat {
|
||||
XZ("xz"), GZIP("gz"), Z_STANDARD("zst");
|
||||
|
@@ -1,27 +1,28 @@
|
||||
package net.woggioni.jpacrepo.api.model;
|
||||
|
||||
import jakarta.persistence.ElementCollection;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.json.bind.annotation.JsonbTransient;
|
||||
import jakarta.json.bind.annotation.JsonbVisibility;
|
||||
import jakarta.json.bind.config.PropertyVisibilityStrategy;
|
||||
import jakarta.persistence.Access;
|
||||
import jakarta.persistence.AccessType;
|
||||
import jakarta.persistence.ElementCollection;
|
||||
import jakarta.persistence.EmbeddedId;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.Index;
|
||||
import jakarta.persistence.NamedQueries;
|
||||
import jakarta.persistence.NamedQuery;
|
||||
import jakarta.persistence.PrePersist;
|
||||
import jakarta.persistence.PreUpdate;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.persistence.Index;
|
||||
import jakarta.persistence.EmbeddedId;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||
|
||||
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
import jakarta.xml.bind.annotation.XmlTransient;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
@@ -38,8 +39,8 @@ import java.util.Set;
|
||||
@Index(columnList = "fileName", unique = true)
|
||||
})
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class PkgData {
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
public class PkgData implements Serializable {
|
||||
|
||||
@EmbeddedId
|
||||
private PkgId id;
|
||||
@@ -50,7 +51,7 @@ public class PkgData {
|
||||
|
||||
private String url;
|
||||
|
||||
private OffsetDateTime buildDate;
|
||||
private Instant buildDate;
|
||||
|
||||
private String packager;
|
||||
|
||||
@@ -86,12 +87,14 @@ public class PkgData {
|
||||
@ElementCollection(fetch = FetchType.EAGER)
|
||||
private Set<String> backup;
|
||||
|
||||
private OffsetDateTime updTimestamp;
|
||||
@XmlTransient
|
||||
@JsonbTransient
|
||||
private Instant updTimestamp;
|
||||
|
||||
@PreUpdate
|
||||
@PrePersist
|
||||
private void writeTimestamp() {
|
||||
updTimestamp = OffsetDateTime.now();
|
||||
updTimestamp = Instant.now();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -15,7 +15,7 @@ import java.io.Serializable;
|
||||
@Embeddable
|
||||
@Access(AccessType.FIELD)
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
public class PkgId implements Serializable {
|
||||
|
||||
private String name;
|
||||
|
@@ -1,8 +1,7 @@
|
||||
package net.woggioni.jpacrepo.api.service;
|
||||
|
||||
import jakarta.ejb.Local;
|
||||
|
||||
|
||||
import net.woggioni.jpacrepo.api.model.CompressionFormat;
|
||||
import net.woggioni.jpacrepo.api.model.PkgData;
|
||||
|
||||
import java.util.List;
|
||||
@@ -10,5 +9,11 @@ import java.util.List;
|
||||
@Local
|
||||
public interface PacmanServiceLocal extends PacmanServiceRemote {
|
||||
long countResults(String name, String version, String arch);
|
||||
List<PkgData> searchPackage(String name, String version, String arch, int page, int pageSize, String fileName);
|
||||
List<PkgData> searchPackage(String name,
|
||||
String version,
|
||||
String arch,
|
||||
CompressionFormat compressionFormat,
|
||||
String fileName,
|
||||
int pageNumber,
|
||||
int pageSize);
|
||||
}
|
@@ -1,9 +1,47 @@
|
||||
package net.woggioni.jpacrepo.api.service;
|
||||
|
||||
import jakarta.annotation.Nonnull;
|
||||
import jakarta.annotation.Nullable;
|
||||
import jakarta.ejb.Remote;
|
||||
import net.woggioni.jpacrepo.api.model.CompressionFormat;
|
||||
import net.woggioni.jpacrepo.api.model.PkgData;
|
||||
import net.woggioni.jpacrepo.api.model.PkgId;
|
||||
import net.woggioni.jpacrepo.api.wire.PkgTuple;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.Set;
|
||||
|
||||
@Remote
|
||||
public interface PacmanServiceRemote {
|
||||
void syncDB();
|
||||
|
||||
void deletePackage(String filename);
|
||||
|
||||
List<String> searchName(@Nonnull String name);
|
||||
|
||||
List<PkgData> searchByHash(@Nonnull String hash);
|
||||
|
||||
List<PkgData> searchByFileName(@Nonnull String fileName);
|
||||
|
||||
List<String> listFiles();
|
||||
|
||||
List<String> listHashes();
|
||||
|
||||
List<PkgId> searchPkgId(
|
||||
String name,
|
||||
String version,
|
||||
String arch,
|
||||
CompressionFormat compressionFormat);
|
||||
|
||||
@Nullable
|
||||
PkgData getPackage(PkgId pkgId);
|
||||
|
||||
@Nullable
|
||||
Long getFileSize(String fileName);
|
||||
|
||||
Set<String> missingFiles(Collection<String> fileNames);
|
||||
|
||||
NavigableMap<PkgId, PkgTuple> getPkgMap();
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
package net.woggioni.jpacrepo.api.wire;
|
||||
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
import net.woggioni.jpacrepo.api.model.PkgData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "packages")
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
public class PkgDataList extends ArrayList<PkgData> {
|
||||
public PkgDataList() {}
|
||||
public PkgDataList(Collection<PkgData> c) {
|
||||
super(c);
|
||||
}
|
||||
|
||||
public PkgDataList(PkgData... elements) {
|
||||
for (PkgData el : elements) add(el);
|
||||
}
|
||||
|
||||
@XmlElement(name = "pkgData")
|
||||
public List<PkgData> getItems() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setItems(List<PkgData> pkgs) {
|
||||
this.clear();
|
||||
this.addAll(pkgs);
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package net.woggioni.jpacrepo.api.wire;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@XmlRootElement
|
||||
public class PkgTuple {
|
||||
String md5sum;
|
||||
|
||||
String fileName;
|
||||
|
||||
long size;
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
package net.woggioni.jpacrepo.api.wire;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement
|
||||
public class StringList extends ArrayList<String> {
|
||||
|
||||
public StringList(Iterable<String> l) {
|
||||
for (String el : l) add(el);
|
||||
}
|
||||
|
||||
public StringList(String... strings) {
|
||||
for (String el : strings) add(el);
|
||||
}
|
||||
|
||||
@XmlElement(name = "pkgData")
|
||||
List<String> getItems() {
|
||||
return this;
|
||||
}
|
||||
|
||||
void setItems(List<String> strings) {
|
||||
this.clear();
|
||||
this.addAll(strings);
|
||||
}
|
||||
}
|
5
jpacrepo-api/src/main/resources/META-INF/beans.xml
Normal file
5
jpacrepo-api/src/main/resources/META-INF/beans.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd"
|
||||
version="4.0" bean-discovery-mode="annotated">
|
||||
</beans>
|
Reference in New Issue
Block a user