[IX] continue integration of mango

This commit is contained in:
Edouard DUPIN 2024-12-22 10:31:29 +01:00
parent 2c0fb99202
commit a503aa95a9
11 changed files with 56 additions and 50 deletions

View File

@ -1,13 +1,13 @@
package org.kar.karusic; package org.kar.karusic;
import org.kar.archidata.db.DbInterfaceMorphia; import org.kar.archidata.db.DbIoMorphia;
import org.kar.karusic.model.Album; import org.kar.karusic.model.Album;
import org.kar.karusic.model.Artist; import org.kar.karusic.model.Artist;
import org.kar.karusic.model.Gender; import org.kar.karusic.model.Gender;
import org.kar.karusic.model.Playlist; import org.kar.karusic.model.Playlist;
import org.kar.karusic.model.Track; import org.kar.karusic.model.Track;
public class MorphiaService extends DbInterfaceMorphia { public class MorphiaService extends DbIoMorphia {
public MorphiaService() { public MorphiaService() {
super("mongodb://root:base_db_password@localhost:27017", "karusic", Album.class, Artist.class, Gender.class, Playlist.class, Track.class); super("mongodb://root:base_db_password@localhost:27017", "karusic", Album.class, Artist.class, Gender.class, Playlist.class, Track.class);

View File

@ -17,9 +17,11 @@ import org.kar.archidata.UpdateJwtPublicKey;
import org.kar.archidata.api.DataResource; import org.kar.archidata.api.DataResource;
import org.kar.archidata.api.ProxyResource; import org.kar.archidata.api.ProxyResource;
import org.kar.archidata.catcher.GenericCatcher; import org.kar.archidata.catcher.GenericCatcher;
import org.kar.archidata.dataAccess.DataAccess; import org.kar.archidata.dataAccess.DBAccess;
import org.kar.archidata.filter.ArchiveHttpMethodFilter;
import org.kar.archidata.filter.CORSFilter; import org.kar.archidata.filter.CORSFilter;
import org.kar.archidata.filter.OptionFilter; import org.kar.archidata.filter.OptionFilter;
import org.kar.archidata.filter.RestoreHttpMethodFilter;
import org.kar.archidata.migration.MigrationEngine; import org.kar.archidata.migration.MigrationEngine;
import org.kar.archidata.tools.ConfigBaseVariable; import org.kar.archidata.tools.ConfigBaseVariable;
import org.kar.karusic.api.AlbumResource; import org.kar.karusic.api.AlbumResource;
@ -46,11 +48,11 @@ public class WebLauncher {
protected UpdateJwtPublicKey keyUpdater = null; protected UpdateJwtPublicKey keyUpdater = null;
protected HttpServer server = null; protected HttpServer server = null;
private final DataAccess da; private final DBAccess da;
public WebLauncher() { public WebLauncher() {
ConfigBaseVariable.bdDatabase = "karusic"; ConfigBaseVariable.bdDatabase = "karusic";
this.da = DataAccess.createInterface(); this.da = DBAccess.createInterface();
} }
private static URI getBaseURI() { private static URI getBaseURI() {
@ -126,6 +128,9 @@ public class WebLauncher {
rc.register(CORSFilter.class); rc.register(CORSFilter.class);
// global authentication system // global authentication system
rc.register(KarusicAuthenticationFilter.class); rc.register(KarusicAuthenticationFilter.class);
// add dependency of restore and archive
rc.register(RestoreHttpMethodFilter.class);
rc.register(ArchiveHttpMethodFilter.class);
// register exception catcher // register exception catcher
GenericCatcher.addAll(rc); GenericCatcher.addAll(rc);
// add default resource: // add default resource:

View File

@ -9,7 +9,7 @@ import org.glassfish.jersey.media.multipart.FormDataParam;
import org.kar.archidata.annotation.AsyncType; import org.kar.archidata.annotation.AsyncType;
import org.kar.archidata.annotation.FormDataOptional; import org.kar.archidata.annotation.FormDataOptional;
import org.kar.archidata.annotation.TypeScriptProgress; import org.kar.archidata.annotation.TypeScriptProgress;
import org.kar.archidata.dataAccess.DataAccess; import org.kar.archidata.dataAccess.DBAccess;
import org.kar.archidata.dataAccess.addOn.AddOnDataJson; import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
import org.kar.archidata.dataAccess.options.CheckFunction; import org.kar.archidata.dataAccess.options.CheckFunction;
import org.kar.archidata.tools.DataTools; import org.kar.archidata.tools.DataTools;
@ -36,7 +36,7 @@ public class AlbumResource {
private static final Logger LOGGER = LoggerFactory.getLogger(AlbumResource.class); private static final Logger LOGGER = LoggerFactory.getLogger(AlbumResource.class);
static final AlbumChecker CHECKER = new AlbumChecker(); static final AlbumChecker CHECKER = new AlbumChecker();
private final DataAccess da = DataAccess.createInterface(); private final DBAccess da = DBAccess.createInterface();
@GET @GET
@Path("{id}") @Path("{id}")

View File

@ -9,7 +9,7 @@ import org.glassfish.jersey.media.multipart.FormDataParam;
import org.kar.archidata.annotation.AsyncType; import org.kar.archidata.annotation.AsyncType;
import org.kar.archidata.annotation.FormDataOptional; import org.kar.archidata.annotation.FormDataOptional;
import org.kar.archidata.annotation.TypeScriptProgress; import org.kar.archidata.annotation.TypeScriptProgress;
import org.kar.archidata.dataAccess.DataAccess; import org.kar.archidata.dataAccess.DBAccess;
import org.kar.archidata.dataAccess.addOn.AddOnDataJson; import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
import org.kar.archidata.dataAccess.options.CheckFunction; import org.kar.archidata.dataAccess.options.CheckFunction;
import org.kar.archidata.tools.DataTools; import org.kar.archidata.tools.DataTools;
@ -34,7 +34,7 @@ import jakarta.ws.rs.core.MediaType;
public class ArtistResource { public class ArtistResource {
private static final Logger LOGGER = LoggerFactory.getLogger(ArtistResource.class); private static final Logger LOGGER = LoggerFactory.getLogger(ArtistResource.class);
static final ArtistChecker CHECKER = new ArtistChecker(); static final ArtistChecker CHECKER = new ArtistChecker();
private final DataAccess da = DataAccess.createInterface(); private final DBAccess da = DBAccess.createInterface();
@GET @GET
@Path("{id}") @Path("{id}")

View File

@ -9,7 +9,7 @@ import org.glassfish.jersey.media.multipart.FormDataParam;
import org.kar.archidata.annotation.AsyncType; import org.kar.archidata.annotation.AsyncType;
import org.kar.archidata.annotation.FormDataOptional; import org.kar.archidata.annotation.FormDataOptional;
import org.kar.archidata.annotation.TypeScriptProgress; import org.kar.archidata.annotation.TypeScriptProgress;
import org.kar.archidata.dataAccess.DataAccess; import org.kar.archidata.dataAccess.DBAccess;
import org.kar.archidata.dataAccess.addOn.AddOnDataJson; import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
import org.kar.archidata.dataAccess.options.CheckFunction; import org.kar.archidata.dataAccess.options.CheckFunction;
import org.kar.archidata.tools.DataTools; import org.kar.archidata.tools.DataTools;
@ -34,7 +34,7 @@ import jakarta.ws.rs.core.MediaType;
public class GenderResource { public class GenderResource {
private static final Logger LOGGER = LoggerFactory.getLogger(GenderResource.class); private static final Logger LOGGER = LoggerFactory.getLogger(GenderResource.class);
static final GenderChecker CHECKER = new GenderChecker(); static final GenderChecker CHECKER = new GenderChecker();
private final DataAccess da = DataAccess.createInterface(); private final DBAccess da = DBAccess.createInterface();
@GET @GET
@Path("{id}") @Path("{id}")

View File

@ -7,7 +7,7 @@ import java.util.UUID;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam; import org.glassfish.jersey.media.multipart.FormDataParam;
import org.kar.archidata.annotation.AsyncType; import org.kar.archidata.annotation.AsyncType;
import org.kar.archidata.dataAccess.DataAccess; import org.kar.archidata.dataAccess.DBAccess;
import org.kar.archidata.dataAccess.addOn.AddOnDataJson; import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
import org.kar.archidata.dataAccess.options.CheckFunction; import org.kar.archidata.dataAccess.options.CheckFunction;
import org.kar.archidata.tools.DataTools; import org.kar.archidata.tools.DataTools;
@ -32,7 +32,7 @@ import jakarta.ws.rs.core.MediaType;
public class PlaylistResource { public class PlaylistResource {
private static final Logger LOGGER = LoggerFactory.getLogger(PlaylistResource.class); private static final Logger LOGGER = LoggerFactory.getLogger(PlaylistResource.class);
static final TrackChecker CHECKER = new TrackChecker(); static final TrackChecker CHECKER = new TrackChecker();
private final DataAccess da = DataAccess.createInterface(); private final DBAccess da = DBAccess.createInterface();
@GET @GET
@Path("{id}") @Path("{id}")

View File

@ -12,7 +12,7 @@ import org.glassfish.jersey.media.multipart.FormDataParam;
import org.kar.archidata.annotation.AsyncType; import org.kar.archidata.annotation.AsyncType;
import org.kar.archidata.annotation.FormDataOptional; import org.kar.archidata.annotation.FormDataOptional;
import org.kar.archidata.annotation.TypeScriptProgress; import org.kar.archidata.annotation.TypeScriptProgress;
import org.kar.archidata.dataAccess.DataAccess; import org.kar.archidata.dataAccess.DBAccess;
import org.kar.archidata.dataAccess.addOn.AddOnDataJson; import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
import org.kar.archidata.dataAccess.options.CheckFunction; import org.kar.archidata.dataAccess.options.CheckFunction;
import org.kar.archidata.model.Data; import org.kar.archidata.model.Data;
@ -39,7 +39,7 @@ import jakarta.ws.rs.core.Response;
public class TrackResource { public class TrackResource {
private static final Logger LOGGER = LoggerFactory.getLogger(TrackResource.class); private static final Logger LOGGER = LoggerFactory.getLogger(TrackResource.class);
static final TrackChecker CHECKER = new TrackChecker(); static final TrackChecker CHECKER = new TrackChecker();
private final DataAccess da = DataAccess.createInterface(); private final DBAccess da = DBAccess.createInterface();
@GET @GET
@Path("{id}") @Path("{id}")

View File

@ -3,7 +3,7 @@ package org.kar.karusic.api;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.kar.archidata.dataAccess.DataAccess; import org.kar.archidata.dataAccess.DBAccess;
import org.kar.archidata.filter.GenericContext; import org.kar.archidata.filter.GenericContext;
import org.kar.karusic.api.UserResourceModel.PartRight; import org.kar.karusic.api.UserResourceModel.PartRight;
import org.kar.karusic.api.UserResourceModel.UserMe; import org.kar.karusic.api.UserResourceModel.UserMe;
@ -26,7 +26,7 @@ import jakarta.ws.rs.core.SecurityContext;
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public class UserResource { public class UserResource {
private static final Logger LOGGER = LoggerFactory.getLogger(UserResource.class); private static final Logger LOGGER = LoggerFactory.getLogger(UserResource.class);
private final DataAccess da = DataAccess.createInterface(); private final DBAccess da = DBAccess.createInterface();
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
public class UserOut { public class UserOut {

View File

@ -2,7 +2,7 @@ package org.kar.karusic.migration;
import java.util.List; import java.util.List;
import org.kar.archidata.dataAccess.DataAccess; import org.kar.archidata.dataAccess.DBAccess;
import org.kar.archidata.migration.MigrationSqlStep; import org.kar.archidata.migration.MigrationSqlStep;
import org.kar.archidata.model.Data; import org.kar.archidata.model.Data;
import org.kar.archidata.model.User; import org.kar.archidata.model.User;
@ -35,7 +35,7 @@ public class Initialization extends MigrationSqlStep {
addClass(elem); addClass(elem);
} }
addAction((final DataAccess da) -> { addAction((final DBAccess da) -> {
final List<Gender> data = List.of(// final List<Gender> data = List.of(//
new Gender(1L, "Variété française"), // new Gender(1L, "Variété française"), //
new Gender(2L, "Pop"), // new Gender(2L, "Pop"), //
@ -85,7 +85,7 @@ public class Initialization extends MigrationSqlStep {
""", "mysql"); """, "mysql");
} }
public static void dropAll(final DataAccess da) { public static void dropAll(final DBAccess da) {
for (final Class<?> element : CLASSES_BASE) { for (final Class<?> element : CLASSES_BASE) {
try { try {
da.drop(element); da.drop(element);
@ -96,7 +96,7 @@ public class Initialization extends MigrationSqlStep {
} }
} }
public static void cleanAll(final DataAccess da) { public static void cleanAll(final DBAccess da) {
for (final Class<?> element : CLASSES_BASE) { for (final Class<?> element : CLASSES_BASE) {
try { try {
da.cleanAll(element); da.cleanAll(element);

View File

@ -8,7 +8,7 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import org.kar.archidata.api.DataResource; import org.kar.archidata.api.DataResource;
import org.kar.archidata.dataAccess.DataAccess; import org.kar.archidata.dataAccess.DBAccess;
import org.kar.archidata.dataAccess.addOn.model.LinkTableLongLong; import org.kar.archidata.dataAccess.addOn.model.LinkTableLongLong;
import org.kar.archidata.dataAccess.options.AccessDeletedItems; import org.kar.archidata.dataAccess.options.AccessDeletedItems;
import org.kar.archidata.dataAccess.options.OverrideTableName; import org.kar.archidata.dataAccess.options.OverrideTableName;
@ -40,12 +40,12 @@ public class Migration20240226 extends MigrationSqlStep {
ALTER TABLE `data` ADD `uuid` binary(16) AFTER `id`; ALTER TABLE `data` ADD `uuid` binary(16) AFTER `id`;
"""); """);
addAction(() -> { addAction(() -> {
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data")); final List<UUIDConversion> datas = DBAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
for (final UUIDConversion elem : datas) { for (final UUIDConversion elem : datas) {
elem.uuid = UuidUtils.nextUUID(); elem.uuid = UuidUtils.nextUUID();
} }
for (final UUIDConversion elem : datas) { for (final UUIDConversion elem : datas) {
DataAccess.update(elem, elem.id, List.of("uuid"), new OverrideTableName("data")); DBAccess.update(elem, elem.id, List.of("uuid"), new OverrideTableName("data"));
} }
}); });
addAction(""" addAction("""
@ -55,9 +55,9 @@ public class Migration20240226 extends MigrationSqlStep {
for (final String tableName : tableToTransform) { for (final String tableName : tableToTransform) {
addAction("ALTER TABLE `" + tableName + "` ADD `covers` text NULL;"); addAction("ALTER TABLE `" + tableName + "` ADD `covers` text NULL;");
addAction(() -> { addAction(() -> {
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data")); final List<UUIDConversion> datas = DBAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
final List<CoverConversion> medias = DataAccess.gets(CoverConversion.class, new AccessDeletedItems(), new OverrideTableName(tableName)); final List<CoverConversion> medias = DBAccess.gets(CoverConversion.class, new AccessDeletedItems(), new OverrideTableName(tableName));
final List<LinkTableLongLong> links = DataAccess.gets(LinkTableLongLong.class, new OverrideTableName(tableName + "_link_cover")); final List<LinkTableLongLong> links = DBAccess.gets(LinkTableLongLong.class, new OverrideTableName(tableName + "_link_cover"));
LOGGER.info("Get somes data: {} {} {}", datas.size(), medias.size(), links.size()); LOGGER.info("Get somes data: {} {} {}", datas.size(), medias.size(), links.size());
for (final CoverConversion media : medias) { for (final CoverConversion media : medias) {
final List<UUID> values = new ArrayList<>(); final List<UUID> values = new ArrayList<>();
@ -75,7 +75,7 @@ public class Migration20240226 extends MigrationSqlStep {
if (values.size() != 0) { if (values.size() != 0) {
media.covers = values; media.covers = values;
LOGGER.info(" update: {} => {}", media.id, media.covers); LOGGER.info(" update: {} => {}", media.id, media.covers);
DataAccess.update(media, media.id, List.of("covers"), new OverrideTableName(tableName)); DBAccess.update(media, media.id, List.of("covers"), new OverrideTableName(tableName));
} }
} }
}); });
@ -85,13 +85,13 @@ public class Migration20240226 extends MigrationSqlStep {
ALTER TABLE `track` ADD `dataUUID` binary(16) AFTER dataId; ALTER TABLE `track` ADD `dataUUID` binary(16) AFTER dataId;
"""); """);
addAction(() -> { addAction(() -> {
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data")); final List<UUIDConversion> datas = DBAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
final List<MediaConversion> medias = DataAccess.gets(MediaConversion.class, new AccessDeletedItems(), new OverrideTableName("track")); final List<MediaConversion> medias = DBAccess.gets(MediaConversion.class, new AccessDeletedItems(), new OverrideTableName("track"));
for (final MediaConversion media : medias) { for (final MediaConversion media : medias) {
for (final UUIDConversion data : datas) { for (final UUIDConversion data : datas) {
if (data.id.equals(media.dataId)) { if (data.id.equals(media.dataId)) {
media.dataUUID = data.uuid; media.dataUUID = data.uuid;
DataAccess.update(media, media.id, List.of("dataUUID"), new OverrideTableName("track")); DBAccess.update(media, media.id, List.of("dataUUID"), new OverrideTableName("track"));
break; break;
} }
} }
@ -112,7 +112,7 @@ public class Migration20240226 extends MigrationSqlStep {
"""); """);
// Move the files... // Move the files...
addAction(() -> { addAction(() -> {
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data")); final List<UUIDConversion> datas = DBAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
for (final UUIDConversion data : datas) { for (final UUIDConversion data : datas) {
final String origin = DataResource.getFileDataOld(data.id); final String origin = DataResource.getFileDataOld(data.id);
final String destination = DataResource.getFileData(data.uuid); final String destination = DataResource.getFileData(data.uuid);

View File

@ -19,6 +19,7 @@ services:
kar_mongodb_service: kar_mongodb_service:
image: mongo:latest image: mongo:latest
restart: always
environment: environment:
MONGO_INITDB_ROOT_USERNAME: root MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: base_db_password MONGO_INITDB_ROOT_PASSWORD: base_db_password