diff --git a/back/src/org/kar/karso/WebLauncher.java b/back/src/org/kar/karso/WebLauncher.java deleted file mode 100755 index f50af75..0000000 --- a/back/src/org/kar/karso/WebLauncher.java +++ /dev/null @@ -1,173 +0,0 @@ - -package org.kar.karso; - -import java.net.URI; - -import org.glassfish.grizzly.http.server.HttpServer; -import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; -import org.glassfish.jersey.jackson.JacksonFeature; -import org.glassfish.jersey.server.ResourceConfig; -import org.kar.archidata.GlobalConfiguration; -import org.kar.archidata.backup.BackupEngine; -import org.kar.archidata.backup.BackupEngine.StoreMode; -//import org.kar.archidata.model.Migration; -import org.kar.archidata.catcher.ExceptionCatcher; -import org.kar.archidata.catcher.FailException404API; -import org.kar.archidata.catcher.FailExceptionCatcher; -import org.kar.archidata.catcher.InputExceptionCatcher; -import org.kar.archidata.catcher.SystemExceptionCatcher; -import org.kar.archidata.filter.CORSFilter; -import org.kar.archidata.filter.OptionFilter; -import org.kar.archidata.migration.MigrationEngine; -import org.kar.archidata.migration.model.Migration; -import org.kar.archidata.tools.ConfigBaseVariable; -import org.kar.archidata.tools.JWTWrapper; -import org.kar.karso.api.ApplicationResource; -import org.kar.karso.api.ApplicationTokenResource; -import org.kar.karso.api.Front; -import org.kar.karso.api.HealthCheck; -import org.kar.karso.api.PublicKeyResource; -import org.kar.karso.api.RightResource; -import org.kar.karso.api.SystemConfigResource; -import org.kar.karso.api.UserResource; -import org.kar.karso.filter.KarsoAuthenticationFilter; -import org.kar.karso.migration.Initialization; -import org.kar.karso.migration.Migration20231015; -import org.kar.karso.migration.Migration20231126; -import org.kar.karso.model.Application; -import org.kar.karso.model.ApplicationToken; -import org.kar.karso.model.Right; -import org.kar.karso.model.RightDescription; -import org.kar.karso.model.Settings; -import org.kar.karso.model.UserAuth; -import org.kar.karso.util.ConfigVariable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import jakarta.ws.rs.core.UriBuilder; - -public class WebLauncher { - private final static Logger LOGGER = LoggerFactory.getLogger(WebLauncher.class); - protected ResourceConfig rc = null; - HttpServer server = null; - protected BackupEngine backupEngine = new BackupEngine("./backup", StoreMode.JSON); - - public WebLauncher() { - ConfigBaseVariable.bdDatabase = "karso"; - - this.backupEngine.addClass(Migration.class); - this.backupEngine.addClass(Settings.class); - this.backupEngine.addClass(UserAuth.class); - this.backupEngine.addClass(Application.class); - this.backupEngine.addClass(ApplicationToken.class); - this.backupEngine.addClass(RightDescription.class); - this.backupEngine.addClass(Right.class); - - } - - private static URI getBaseURI() { - return UriBuilder.fromUri(ConfigBaseVariable.getlocalAddress()).build(); - } - - 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(); - WebLauncher.LOGGER.info("STOP the REST server:"); - } - - public void migrateDB() throws Exception { - WebLauncher.LOGGER.info("Create migration engine"); - final MigrationEngine migrationEngine = new MigrationEngine(); - WebLauncher.LOGGER.info("Add initialization"); - migrationEngine.setInit(new Initialization()); - migrationEngine.add(new Migration20231015()); - migrationEngine.add(new Migration20231126()); - WebLauncher.LOGGER.info("Add migration since last version"); - // NOTHING for now - WebLauncher.LOGGER.info("Migrate the DB [START]"); - migrationEngine.migrateWaitAdmin(GlobalConfiguration.dbConfig); - WebLauncher.LOGGER.info("Migrate the DB [STOP]"); - } - - public void process() throws InterruptedException { - try { - JWTWrapper.initLocalToken(ConfigVariable.getUUIDKeyRoot()); - } catch (final Exception e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - LOGGER.info("Wait 10 seconds ...."); - Thread.sleep(10000); - return; - } - - // =================================================================== - // Configure resources - // =================================================================== - this.rc = new ResourceConfig(); - // global authentication system - this.rc.register(OptionFilter.class); - this.rc.register(CORSFilter.class); - this.rc.register(KarsoAuthenticationFilter.class); - // register exception catcher - this.rc.register(InputExceptionCatcher.class); - this.rc.register(SystemExceptionCatcher.class); - this.rc.register(FailExceptionCatcher.class); - this.rc.register(FailException404API.class); - this.rc.register(ExceptionCatcher.class); - // add default resource: - this.rc.register(UserResource.class); - this.rc.register(PublicKeyResource.class); - this.rc.register(ApplicationResource.class); - this.rc.register(ApplicationTokenResource.class); - this.rc.register(SystemConfigResource.class); - this.rc.register(RightResource.class); - this.rc.register(Front.class); - this.rc.register(HealthCheck.class); - // add jackson to be discover when we are ins stand-alone server - this.rc.register(JacksonFeature.class); - // enable this to show low level request - //rc.property(LoggingFeature.LOGGING_FEATURE_LOGGER_LEVEL_SERVER, Level.WARNING.getName()); - - this.server = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), this.rc); - final HttpServer serverLink = this.server; - Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { - @Override - public void run() { - LOGGER.info("Stopping server.."); - serverLink.shutdownNow(); - } - }, "shutdownHook")); - - // =================================================================== - // run JERSEY - // =================================================================== - try { - this.server.start(); - LOGGER.info("Jersey app started at {}", getBaseURI()); - } catch (final Exception e) { - LOGGER.error("There was an error while starting Grizzly HTTP server."); - e.printStackTrace(); - } - } - - public void stop() { - if (this.server != null) { - this.server.shutdownNow(); - - while (this.server.isStarted()) { - LOGGER.info("wait stop"); - try { - Thread.sleep(200); - } catch (final InterruptedException e) { - e.printStackTrace(); - } - } - this.server = null; - } - } -} diff --git a/front/package.json b/front/package.json index 43bbc8e..eac0891 100644 --- a/front/package.json +++ b/front/package.json @@ -29,7 +29,8 @@ "@angular/platform-browser-dynamic": "^17.2.2", "@angular/router": "^17.2.2", "rxjs": "^7.8.1", - "zone.js": "^0.14.4" + "zone.js": "^0.14.4", + "zod": "3.22.4" }, "devDependencies": { "@angular-devkit/build-angular": "^17.2.1", @@ -53,6 +54,6 @@ "karma-jasmine-html-reporter": "^2.1.0", "karma-spec-reporter": "^0.0.36", "prettier": "^3.2.5", - "npm-check-updates": "^16.14.15" + "npm-check-updates": "^16.14.15" } -} +} \ No newline at end of file