[IX] continue integration of mango
This commit is contained in:
parent
2c0fb99202
commit
a503aa95a9
@ -1,13 +1,13 @@
|
||||
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.Artist;
|
||||
import org.kar.karusic.model.Gender;
|
||||
import org.kar.karusic.model.Playlist;
|
||||
import org.kar.karusic.model.Track;
|
||||
|
||||
public class MorphiaService extends DbInterfaceMorphia {
|
||||
public class MorphiaService extends DbIoMorphia {
|
||||
|
||||
public MorphiaService() {
|
||||
super("mongodb://root:base_db_password@localhost:27017", "karusic", Album.class, Artist.class, Gender.class, Playlist.class, Track.class);
|
||||
|
@ -17,9 +17,11 @@ import org.kar.archidata.UpdateJwtPublicKey;
|
||||
import org.kar.archidata.api.DataResource;
|
||||
import org.kar.archidata.api.ProxyResource;
|
||||
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.OptionFilter;
|
||||
import org.kar.archidata.filter.RestoreHttpMethodFilter;
|
||||
import org.kar.archidata.migration.MigrationEngine;
|
||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||
import org.kar.karusic.api.AlbumResource;
|
||||
@ -45,18 +47,18 @@ public class WebLauncher {
|
||||
final static Logger LOGGER = LoggerFactory.getLogger(WebLauncher.class);
|
||||
protected UpdateJwtPublicKey keyUpdater = null;
|
||||
protected HttpServer server = null;
|
||||
|
||||
private final DataAccess da;
|
||||
|
||||
|
||||
private final DBAccess da;
|
||||
|
||||
public WebLauncher() {
|
||||
ConfigBaseVariable.bdDatabase = "karusic";
|
||||
this.da = DataAccess.createInterface();
|
||||
this.da = DBAccess.createInterface();
|
||||
}
|
||||
|
||||
|
||||
private static URI getBaseURI() {
|
||||
return UriBuilder.fromUri(ConfigBaseVariable.getlocalAddress()).build();
|
||||
}
|
||||
|
||||
|
||||
public void migrateDB() throws Exception {
|
||||
WebLauncher.LOGGER.info("Create migration engine");
|
||||
final MigrationEngine migrationEngine = new MigrationEngine(this.da);
|
||||
@ -71,12 +73,12 @@ public class WebLauncher {
|
||||
migrationEngine.migrateWaitAdmin(GlobalConfiguration.getDbconfig());
|
||||
WebLauncher.LOGGER.info("Migrate the DB [STOP]");
|
||||
}
|
||||
|
||||
|
||||
public static void main(final String[] args) throws Exception {
|
||||
WebLauncher.LOGGER.info("[START] application wake UP");
|
||||
final WebLauncher launcher = new WebLauncher();
|
||||
launcher.migrateDB();
|
||||
|
||||
|
||||
launcher.process();
|
||||
WebLauncher.LOGGER.info("end-configure the server & wait finish process:");
|
||||
Thread.currentThread().join();
|
||||
@ -84,7 +86,7 @@ public class WebLauncher {
|
||||
launcher.stopOther();
|
||||
WebLauncher.LOGGER.info("STOP the REST server:");
|
||||
}
|
||||
|
||||
|
||||
public void plop(final String aaa) {
|
||||
// List available Image Readers
|
||||
System.out.println("Available Image Readers:");
|
||||
@ -95,7 +97,7 @@ public class WebLauncher {
|
||||
System.out.println("Reader CN: " + reader.getOriginatingProvider().getPluginClassName());
|
||||
// ImageIO.deregisterServiceProvider(reader.getOriginatingProvider());
|
||||
}
|
||||
|
||||
|
||||
// List available Image Writers
|
||||
System.out.println("\nAvailable Image Writers:");
|
||||
final Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName(aaa);
|
||||
@ -105,9 +107,9 @@ public class WebLauncher {
|
||||
System.out.println("Writer CN: " + writer.getOriginatingProvider().getPluginClassName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void process() throws InterruptedException {
|
||||
|
||||
|
||||
ImageIO.scanForPlugins();
|
||||
plop("jpeg");
|
||||
plop("png");
|
||||
@ -117,7 +119,7 @@ public class WebLauncher {
|
||||
// Configure resources
|
||||
// ===================================================================
|
||||
final ResourceConfig rc = new ResourceConfig();
|
||||
|
||||
|
||||
// add multipart models ..
|
||||
rc.register(MultiPartFeature.class);
|
||||
// global authentication system
|
||||
@ -126,6 +128,9 @@ public class WebLauncher {
|
||||
rc.register(CORSFilter.class);
|
||||
// global authentication system
|
||||
rc.register(KarusicAuthenticationFilter.class);
|
||||
// add dependency of restore and archive
|
||||
rc.register(RestoreHttpMethodFilter.class);
|
||||
rc.register(ArchiveHttpMethodFilter.class);
|
||||
// register exception catcher
|
||||
GenericCatcher.addAll(rc);
|
||||
// add default resource:
|
||||
@ -137,15 +142,15 @@ public class WebLauncher {
|
||||
rc.register(TrackResource.class);
|
||||
rc.register(DataResource.class);
|
||||
rc.register(ProxyResource.class);
|
||||
|
||||
|
||||
rc.register(HealthCheck.class);
|
||||
rc.register(Front.class);
|
||||
|
||||
|
||||
// add jackson to be discover when we are ins standalone server
|
||||
rc.register(JacksonFeature.class);
|
||||
// enable this to show low level request
|
||||
// rc.property(LoggingFeature.LOGGING_FEATURE_LOGGER_LEVEL_SERVER, Level.WARNING.getName());
|
||||
|
||||
|
||||
// System.out.println("Connect on the BDD:");
|
||||
// System.out.println(" getDBHost: '" + ConfigVariable.getDBHost() + "'");
|
||||
// System.out.println(" getDBPort: '" + ConfigVariable.getDBPort() + "'");
|
||||
@ -163,13 +168,13 @@ public class WebLauncher {
|
||||
serverLink.shutdownNow();
|
||||
}
|
||||
}, "shutdownHook"));
|
||||
|
||||
|
||||
// ===================================================================
|
||||
// start periodic update of the token ...
|
||||
// ===================================================================
|
||||
this.keyUpdater = new UpdateJwtPublicKey();
|
||||
this.keyUpdater.start();
|
||||
|
||||
|
||||
// ===================================================================
|
||||
// run JERSEY
|
||||
// ===================================================================
|
||||
@ -181,14 +186,14 @@ public class WebLauncher {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void stop() {
|
||||
if (this.server != null) {
|
||||
this.server.shutdownNow();
|
||||
this.server = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void stopOther() {
|
||||
this.keyUpdater.kill();
|
||||
try {
|
||||
|
@ -9,7 +9,7 @@ import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||
import org.kar.archidata.annotation.AsyncType;
|
||||
import org.kar.archidata.annotation.FormDataOptional;
|
||||
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.options.CheckFunction;
|
||||
import org.kar.archidata.tools.DataTools;
|
||||
@ -36,7 +36,7 @@ public class AlbumResource {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AlbumResource.class);
|
||||
static final AlbumChecker CHECKER = new AlbumChecker();
|
||||
|
||||
private final DataAccess da = DataAccess.createInterface();
|
||||
private final DBAccess da = DBAccess.createInterface();
|
||||
|
||||
@GET
|
||||
@Path("{id}")
|
||||
|
@ -9,7 +9,7 @@ import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||
import org.kar.archidata.annotation.AsyncType;
|
||||
import org.kar.archidata.annotation.FormDataOptional;
|
||||
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.options.CheckFunction;
|
||||
import org.kar.archidata.tools.DataTools;
|
||||
@ -34,7 +34,7 @@ import jakarta.ws.rs.core.MediaType;
|
||||
public class ArtistResource {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ArtistResource.class);
|
||||
static final ArtistChecker CHECKER = new ArtistChecker();
|
||||
private final DataAccess da = DataAccess.createInterface();
|
||||
private final DBAccess da = DBAccess.createInterface();
|
||||
|
||||
@GET
|
||||
@Path("{id}")
|
||||
|
@ -9,7 +9,7 @@ import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||
import org.kar.archidata.annotation.AsyncType;
|
||||
import org.kar.archidata.annotation.FormDataOptional;
|
||||
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.options.CheckFunction;
|
||||
import org.kar.archidata.tools.DataTools;
|
||||
@ -34,7 +34,7 @@ import jakarta.ws.rs.core.MediaType;
|
||||
public class GenderResource {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GenderResource.class);
|
||||
static final GenderChecker CHECKER = new GenderChecker();
|
||||
private final DataAccess da = DataAccess.createInterface();
|
||||
private final DBAccess da = DBAccess.createInterface();
|
||||
|
||||
@GET
|
||||
@Path("{id}")
|
||||
|
@ -7,7 +7,7 @@ import java.util.UUID;
|
||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||
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.options.CheckFunction;
|
||||
import org.kar.archidata.tools.DataTools;
|
||||
@ -32,7 +32,7 @@ import jakarta.ws.rs.core.MediaType;
|
||||
public class PlaylistResource {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PlaylistResource.class);
|
||||
static final TrackChecker CHECKER = new TrackChecker();
|
||||
private final DataAccess da = DataAccess.createInterface();
|
||||
private final DBAccess da = DBAccess.createInterface();
|
||||
|
||||
@GET
|
||||
@Path("{id}")
|
||||
|
@ -12,7 +12,7 @@ import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||
import org.kar.archidata.annotation.AsyncType;
|
||||
import org.kar.archidata.annotation.FormDataOptional;
|
||||
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.options.CheckFunction;
|
||||
import org.kar.archidata.model.Data;
|
||||
@ -39,7 +39,7 @@ import jakarta.ws.rs.core.Response;
|
||||
public class TrackResource {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TrackResource.class);
|
||||
static final TrackChecker CHECKER = new TrackChecker();
|
||||
private final DataAccess da = DataAccess.createInterface();
|
||||
private final DBAccess da = DBAccess.createInterface();
|
||||
|
||||
@GET
|
||||
@Path("{id}")
|
||||
|
@ -3,7 +3,7 @@ package org.kar.karusic.api;
|
||||
import java.util.List;
|
||||
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.karusic.api.UserResourceModel.PartRight;
|
||||
import org.kar.karusic.api.UserResourceModel.UserMe;
|
||||
@ -26,7 +26,7 @@ import jakarta.ws.rs.core.SecurityContext;
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public class UserResource {
|
||||
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)
|
||||
public class UserOut {
|
||||
|
@ -2,7 +2,7 @@ package org.kar.karusic.migration;
|
||||
|
||||
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.model.Data;
|
||||
import org.kar.archidata.model.User;
|
||||
@ -35,7 +35,7 @@ public class Initialization extends MigrationSqlStep {
|
||||
addClass(elem);
|
||||
}
|
||||
|
||||
addAction((final DataAccess da) -> {
|
||||
addAction((final DBAccess da) -> {
|
||||
final List<Gender> data = List.of(//
|
||||
new Gender(1L, "Variété française"), //
|
||||
new Gender(2L, "Pop"), //
|
||||
@ -85,7 +85,7 @@ public class Initialization extends MigrationSqlStep {
|
||||
""", "mysql");
|
||||
}
|
||||
|
||||
public static void dropAll(final DataAccess da) {
|
||||
public static void dropAll(final DBAccess da) {
|
||||
for (final Class<?> element : CLASSES_BASE) {
|
||||
try {
|
||||
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) {
|
||||
try {
|
||||
da.cleanAll(element);
|
||||
|
@ -8,7 +8,7 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
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.options.AccessDeletedItems;
|
||||
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`;
|
||||
""");
|
||||
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) {
|
||||
elem.uuid = UuidUtils.nextUUID();
|
||||
}
|
||||
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("""
|
||||
@ -55,9 +55,9 @@ public class Migration20240226 extends MigrationSqlStep {
|
||||
for (final String tableName : tableToTransform) {
|
||||
addAction("ALTER TABLE `" + tableName + "` ADD `covers` text NULL;");
|
||||
addAction(() -> {
|
||||
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
||||
final List<CoverConversion> medias = DataAccess.gets(CoverConversion.class, new AccessDeletedItems(), new OverrideTableName(tableName));
|
||||
final List<LinkTableLongLong> links = DataAccess.gets(LinkTableLongLong.class, new OverrideTableName(tableName + "_link_cover"));
|
||||
final List<UUIDConversion> datas = DBAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
||||
final List<CoverConversion> medias = DBAccess.gets(CoverConversion.class, new AccessDeletedItems(), new OverrideTableName(tableName));
|
||||
final List<LinkTableLongLong> links = DBAccess.gets(LinkTableLongLong.class, new OverrideTableName(tableName + "_link_cover"));
|
||||
LOGGER.info("Get somes data: {} {} {}", datas.size(), medias.size(), links.size());
|
||||
for (final CoverConversion media : medias) {
|
||||
final List<UUID> values = new ArrayList<>();
|
||||
@ -75,7 +75,7 @@ public class Migration20240226 extends MigrationSqlStep {
|
||||
if (values.size() != 0) {
|
||||
media.covers = values;
|
||||
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;
|
||||
""");
|
||||
addAction(() -> {
|
||||
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
||||
final List<MediaConversion> medias = DataAccess.gets(MediaConversion.class, new AccessDeletedItems(), new OverrideTableName("track"));
|
||||
final List<UUIDConversion> datas = DBAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
||||
final List<MediaConversion> medias = DBAccess.gets(MediaConversion.class, new AccessDeletedItems(), new OverrideTableName("track"));
|
||||
for (final MediaConversion media : medias) {
|
||||
for (final UUIDConversion data : datas) {
|
||||
if (data.id.equals(media.dataId)) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -112,7 +112,7 @@ public class Migration20240226 extends MigrationSqlStep {
|
||||
""");
|
||||
// Move the files...
|
||||
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) {
|
||||
final String origin = DataResource.getFileDataOld(data.id);
|
||||
final String destination = DataResource.getFileData(data.uuid);
|
||||
|
@ -19,6 +19,7 @@ services:
|
||||
|
||||
kar_mongodb_service:
|
||||
image: mongo:latest
|
||||
restart: always
|
||||
environment:
|
||||
MONGO_INITDB_ROOT_USERNAME: root
|
||||
MONGO_INITDB_ROOT_PASSWORD: base_db_password
|
||||
|
Loading…
Reference in New Issue
Block a user