diff --git a/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/Nsh.java b/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/Nsh.java index d17e7b7a5..bd218c91f 100644 --- a/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/Nsh.java +++ b/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/Nsh.java @@ -4,9 +4,8 @@ import net.thevpc.nuts.cmdline.NCmdLine; import net.thevpc.nuts.cmdline.NCmdLineRunner; import net.thevpc.nuts.cmdline.NCmdLineContext; -import net.thevpc.nuts.env.NBootManager; -import net.thevpc.nuts.env.NEnvs; -import net.thevpc.nuts.env.NLauncherOptions; + +import net.thevpc.nuts.NLauncherOptions; import net.thevpc.nuts.text.NTextStyle; import net.thevpc.nuts.text.NTexts; import net.thevpc.nuts.toolbox.nsh.nshell.NShell; @@ -56,7 +55,6 @@ public void run(NCmdLine cmdLine, NCmdLineContext context) { } //id will not include version or String nshIdStr = NApp.of().getId().get().getShortName(); - NConfigs cfg = NConfigs.of(); // HashMap parameters = new HashMap<>(); // parameters.put("forList", nshIdStr + " --!color -c find-forCommand"); // parameters.put("find", nshIdStr + " --!color -c find-forCommand %n"); @@ -81,8 +79,7 @@ public void run(NCmdLine cmdLine, NCmdLineContext context) { if (!CONTEXTUAL_BUILTINS.contains(command.getName())) { // avoid recursive definition! // disable trace, summary will be traced later! - if (NCommands.of( - ) + if (session.getWorkspace() .addCommand(new NCommandConfig() .setFactoryId("nsh") .setName(command.getName()) @@ -120,14 +117,14 @@ public void run(NCmdLine cmdLine, NCmdLineContext context) { )); } } - cfg.save(false); - if (NBootManager.of().getBootOptions().getInitScripts() + session.getWorkspace().saveConfig(false); + if (NWorkspace.get().getBootOptions().getInitScripts() .ifEmpty(true) .orElse(false)) { - boolean initLaunchers = NBootManager.of().getBootOptions().getInitLaunchers() + boolean initLaunchers = NWorkspace.get().getBootOptions().getInitLaunchers() .ifEmpty(true) .orElse(false); - NEnvs.of().addLauncher( + NWorkspace.get().addLauncher( new NLauncherOptions() .setId(NApp.of().getId().orNull()) .setCreateScript(true) @@ -157,15 +154,14 @@ public void onUninstallApplication() { NSession session = NSession.of().get(); try { try { - NCommands.of().removeCommandFactory("nsh"); + NWorkspace.get().removeCommandFactory("nsh"); } catch (Exception notFound) { //ignore! } Set uninstalled = new TreeSet<>(); - for (NCustomCmd command : NCommands.of().findCommandsByOwner(NApp.of().getId().orNull())) { + for (NCustomCmd command : NWorkspace.get().findCommandsByOwner(NApp.of().getId().orNull())) { try { - NCommands.of( - ).removeCommand(command.getName()); + NWorkspace.get().removeCommand(command.getName()); uninstalled.add(command.getName()); } catch (Exception ex) { if (session.isPlainTrace()) { diff --git a/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/autocomplete/NshAutoCompleter.java b/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/autocomplete/NshAutoCompleter.java index ac9542084..f5df0f1a6 100644 --- a/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/autocomplete/NshAutoCompleter.java +++ b/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/autocomplete/NshAutoCompleter.java @@ -5,7 +5,7 @@ import net.thevpc.nuts.cmdline.NArgCandidate; import net.thevpc.nuts.cmdline.NCmdLine; import net.thevpc.nuts.cmdline.NCmdLineAutoCompleteResolver; -import net.thevpc.nuts.env.NEnvs; + import net.thevpc.nuts.toolbox.nsh.cmds.NShellBuiltin; import net.thevpc.nuts.toolbox.nsh.eval.NShellContext; import net.thevpc.nuts.util.NBlankable; @@ -25,7 +25,7 @@ public NshAutoCompleter(NWorkspace workspace) { public List resolveCandidates(NCmdLine cmdLine, int wordIndex) { List candidates = new ArrayList<>(); NSession session=workspace.currentSession(); - NShellContext fileContext = (NShellContext) NEnvs.of().getProperties().get(NShellContext.class.getName()); + NShellContext fileContext = (NShellContext) NWorkspace.get().getProperties().get(NShellContext.class.getName()); if (wordIndex == 0) { for (NShellBuiltin command : fileContext.builtins().getAll()) { diff --git a/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/cmds/bash/HistoryCommand.java b/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/cmds/bash/HistoryCommand.java index 3023f1f0f..b995260d1 100644 --- a/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/cmds/bash/HistoryCommand.java +++ b/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/cmds/bash/HistoryCommand.java @@ -28,7 +28,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NLocations; + import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.spi.NComponentScope; import net.thevpc.nuts.spi.NScopeType; @@ -133,7 +133,7 @@ protected void main(NCmdLine cmdLine, NShellExecutionContext context) { shistory.save(); } else { - shistory.save(NPath.of(options.sval).toAbsolute(NLocations.of().getWorkspaceLocation())); + shistory.save(NPath.of(options.sval).toAbsolute(NWorkspace.get().getWorkspaceLocation())); } } catch (IOException ex) { throw new NExecutionException(NMsg.ofC("%s", ex), ex, NExecutionException.ERROR_2); @@ -146,7 +146,7 @@ protected void main(NCmdLine cmdLine, NShellExecutionContext context) { shistory.clear(); shistory.load(); } else { - shistory.load(NPath.of(options.sval).toAbsolute(NLocations.of().getWorkspaceLocation())); + shistory.load(NPath.of(options.sval).toAbsolute(NWorkspace.get().getWorkspaceLocation())); } } catch (IOException ex) { throw new NExecutionException(NMsg.ofC("%s", ex), ex, NExecutionException.ERROR_2); diff --git a/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/cmds/bash/UnameCommand.java b/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/cmds/bash/UnameCommand.java index 0d0418924..5af174426 100644 --- a/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/cmds/bash/UnameCommand.java +++ b/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/cmds/bash/UnameCommand.java @@ -27,12 +27,12 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NEnvs; + import net.thevpc.nuts.spi.NComponentScope; import net.thevpc.nuts.spi.NScopeType; import net.thevpc.nuts.toolbox.nsh.cmds.NShellBuiltinDefault; import net.thevpc.nuts.toolbox.nsh.eval.NShellExecutionContext; -import net.thevpc.nuts.env.NArchFamily; +import net.thevpc.nuts.NArchFamily; import java.util.ArrayList; import java.util.List; @@ -81,9 +81,9 @@ protected void main(NCmdLine cmdLine, NShellExecutionContext context) { NSession session = context.getSession(); Result rr = new Result(); - rr.osDist = NEnvs.of().getOsDist(); - rr.os = NEnvs.of().getOs(); - rr.arch = NEnvs.of().getArchFamily(); + rr.osDist = NWorkspace.get().getOsDist(); + rr.os = NWorkspace.get().getOs(); + rr.arch = NWorkspace.get().getArchFamily(); if (!config.farch && !config.fos && !config.fdist) { config.farch = true; config.fos = true; diff --git a/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/cmds/common/PropsCommand.java b/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/cmds/common/PropsCommand.java index 8714cbe3c..05a55fb1e 100644 --- a/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/cmds/common/PropsCommand.java +++ b/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/cmds/common/PropsCommand.java @@ -29,7 +29,7 @@ import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NArgName; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NBootManager; + import net.thevpc.nuts.format.NObjectFormat; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.toolbox.nsh.cmds.NShellBuiltinDefault; @@ -316,7 +316,7 @@ private void storeProperties(Map p, Options o, NShellExecutionCo switch (format) { case AUTO: { NObjectFormat f = NObjectFormat.of().setValue(p); - f.configure(true, NBootManager.of().getBootOptions().getOutputFormatOptions().orElseGet(Collections::emptyList).toArray(new String[0])); + f.configure(true, NWorkspace.get().getBootOptions().getOutputFormatOptions().orElseGet(Collections::emptyList).toArray(new String[0])); f.configure(true, session.getOutputFormatOptions().toArray(new String[0])); f.println(session.out()); break; diff --git a/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/cmds/posix/CpCommand.java b/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/cmds/posix/CpCommand.java index 3a838a29f..82943219e 100644 --- a/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/cmds/posix/CpCommand.java +++ b/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/cmds/posix/CpCommand.java @@ -28,7 +28,8 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NLocations; + + import net.thevpc.nuts.io.NCp; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.spi.NComponentScope; @@ -83,7 +84,7 @@ protected void main(NCmdLine cmdLine, NShellExecutionContext context) { for (String value : options.files) { NAssert.requireNonBlank(value, "file path"); options.xfiles.add(NPath.of((value.contains("://") ? value : - NPath.of(value).toAbsolute(NLocations.of().getWorkspaceLocation()).toString() + NPath.of(value).toAbsolute(NWorkspace.get().getWorkspaceLocation()).toString() ))); } if (options.xfiles.size() < 2) { diff --git a/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/cmds/posix/JpsCommand.java b/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/cmds/posix/JpsCommand.java index c076761f2..f3726a8ab 100644 --- a/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/cmds/posix/JpsCommand.java +++ b/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/cmds/posix/JpsCommand.java @@ -28,12 +28,12 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NEnvs; + import net.thevpc.nuts.spi.NComponentScope; import net.thevpc.nuts.spi.NScopeType; import net.thevpc.nuts.toolbox.nsh.cmds.NShellBuiltinDefault; import net.thevpc.nuts.toolbox.nsh.eval.NShellExecutionContext; -import net.thevpc.nuts.env.NOsFamily; +import net.thevpc.nuts.NOsFamily; import java.nio.file.Files; import java.nio.file.Path; @@ -56,7 +56,7 @@ public static String resolveJpsCommand(NSession session) { } public static String resolveJavaToolCommand(NSession session, String javaHome, String javaCommand) { - String exe = NEnvs.of().getOsFamily().equals(NOsFamily.WINDOWS) ? (javaCommand + ".exe") : javaCommand; + String exe = NWorkspace.get().getOsFamily().equals(NOsFamily.WINDOWS) ? (javaCommand + ".exe") : javaCommand; if (javaHome == null) { javaHome = System.getProperty("java.home"); } diff --git a/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/cmds/posix/WhoamiCommand.java b/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/cmds/posix/WhoamiCommand.java index 5bcedb20c..655ccf111 100644 --- a/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/cmds/posix/WhoamiCommand.java +++ b/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/cmds/posix/WhoamiCommand.java @@ -28,7 +28,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NUser; +import net.thevpc.nuts.NUser; import net.thevpc.nuts.io.NPrintStream; import net.thevpc.nuts.spi.NComponentScope; import net.thevpc.nuts.spi.NScopeType; @@ -114,7 +114,7 @@ protected void main(NCmdLine cmdLine, NShellExecutionContext context) { result.remoteId = user.getRemoteIdentity(); } List rr = new ArrayList<>(); - for (NRepository repository : NRepositories.of().getRepositories()) { + for (NRepository repository : NWorkspace.get().getRepositories()) { NUser ruser = repository.security().getEffectiveUser(login); if (ruser != null && (ruser.getGroups().size() > 0 || ruser.getPermissions().size() > 0 diff --git a/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/eval/AbstractNShellContext.java b/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/eval/AbstractNShellContext.java index 0b1a4f6b8..e0ff0ee57 100644 --- a/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/eval/AbstractNShellContext.java +++ b/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/eval/AbstractNShellContext.java @@ -3,7 +3,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.cmdline.*; import net.thevpc.nuts.elem.NEDesc; -import net.thevpc.nuts.env.NShellFamily; +import net.thevpc.nuts.NShellFamily; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.io.NPrintStream; import net.thevpc.nuts.toolbox.nsh.autocomplete.NShellAutoCompleteCandidate; diff --git a/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/nshell/NShell.java b/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/nshell/NShell.java index fb8c8c7f0..3fcef4028 100755 --- a/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/nshell/NShell.java +++ b/companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/nshell/NShell.java @@ -32,9 +32,8 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.cmdline.NCmdLineHistory; import net.thevpc.nuts.elem.NEDesc; -import net.thevpc.nuts.env.NEnvs; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.*; import net.thevpc.nuts.spi.NDefaultSupportLevelContext; import net.thevpc.nuts.spi.NSupportLevelContext; @@ -181,7 +180,7 @@ public NShell(NShellConfiguration configuration) { if (session != null) { NShellContext _rootContext = getRootContext(); - NEnvs.of().setProperty(NShellContext.class.getName(), _rootContext); + NWorkspace.get().setProperty(NShellContext.class.getName(), _rootContext); _rootContext.setSession(session); //add default commands List allCommand = new ArrayList<>(); @@ -205,7 +204,7 @@ public NShell(NShellConfiguration configuration) { try { NPath histFile = this.history.getHistoryFile(); if (histFile == null) { - histFile = NLocations.of().getStoreLocation(this.appId, NStoreType.VAR).resolve((serviceName == null ? "" : serviceName) + ".history"); + histFile = NWorkspace.get().getStoreLocation(this.appId, NStoreType.VAR).resolve((serviceName == null ? "" : serviceName) + ".history"); this.history.setHistoryFile(histFile); if (histFile.exists()) { this.history.load(histFile); @@ -217,7 +216,7 @@ public NShell(NShellConfiguration configuration) { .error(ex) .log(NMsg.ofC("error resolving history file %s", this.history.getHistoryFile())); } - NEnvs.of().setProperty(NShellHistory.class.getName(), this.history); + NWorkspace.get().setProperty(NShellHistory.class.getName(), this.history); } } @@ -673,7 +672,7 @@ protected void executeInteractive(NShellContext context) { NSystemTerminal.enableRichTerm(); NPath appVarFolder = NApp.of().getVarFolder(); if (appVarFolder == null) { - appVarFolder = NLocations.of().getStoreLocation( + appVarFolder = NWorkspace.get().getStoreLocation( NId.of("net.thevpc.app.nuts.toolbox:nsh").get() , NStoreType.VAR); } diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/DefaultNEnvCondition.java b/core/nuts-api/src/main/java/net/thevpc/nuts/DefaultNEnvCondition.java similarity index 99% rename from core/nuts-api/src/main/java/net/thevpc/nuts/env/DefaultNEnvCondition.java rename to core/nuts-api/src/main/java/net/thevpc/nuts/DefaultNEnvCondition.java index aea74b167..470b68865 100755 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/DefaultNEnvCondition.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/DefaultNEnvCondition.java @@ -23,7 +23,7 @@ *
* ==================================================================== */ -package net.thevpc.nuts.env; +package net.thevpc.nuts; import net.thevpc.nuts.reserved.NReservedUtils; import net.thevpc.nuts.util.NBlankable; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/DefaultNId.java b/core/nuts-api/src/main/java/net/thevpc/nuts/DefaultNId.java index 6c1eca335..9f2e87157 100755 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/DefaultNId.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/DefaultNId.java @@ -26,7 +26,6 @@ package net.thevpc.nuts; import net.thevpc.nuts.boot.reserved.util.NBootStringUtils; -import net.thevpc.nuts.env.NEnvCondition; import net.thevpc.nuts.reserved.NReservedLangUtils; import net.thevpc.nuts.reserved.NReservedUtils; import net.thevpc.nuts.util.NBlankable; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NApp.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NApp.java index 355c11300..3d6776c44 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NApp.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NApp.java @@ -3,7 +3,6 @@ import net.thevpc.nuts.cmdline.NCmdLine; import net.thevpc.nuts.cmdline.NCmdLineAutoComplete; import net.thevpc.nuts.cmdline.NCmdLineRunner; -import net.thevpc.nuts.env.NStoreType; import net.thevpc.nuts.ext.NExtensions; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.spi.NComponent; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NAppStoreLocationResolver.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NAppStoreLocationResolver.java index 7e1f7068f..435723058 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NAppStoreLocationResolver.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NAppStoreLocationResolver.java @@ -24,7 +24,6 @@ */ package net.thevpc.nuts; -import net.thevpc.nuts.env.NStoreType; import net.thevpc.nuts.io.NPath; /** diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NApplications.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NApplications.java index cfcca2694..d950edaf7 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NApplications.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NApplications.java @@ -24,7 +24,7 @@ */ package net.thevpc.nuts; -import net.thevpc.nuts.env.NBootManager; + import net.thevpc.nuts.reserved.NApiUtilsRPI; import net.thevpc.nuts.time.NClock; import net.thevpc.nuts.log.NLog; @@ -195,8 +195,7 @@ public static void runApplication(NApplication applicationInstance) { return; } ws.runWith(() -> { - NSession session = NSession.of().get(); - boolean inherited = NBootManager.of().getBootOptions().getInherited().orElse(false); + boolean inherited = NWorkspace.get().getBootOptions().getInherited().orElse(false); NLog.of(NApplications.class).with().level(Level.FINE).verb(NLogVerb.START) .log( NMsg.ofC( diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NArchFamily.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NArchFamily.java similarity index 99% rename from core/nuts-api/src/main/java/net/thevpc/nuts/env/NArchFamily.java rename to core/nuts-api/src/main/java/net/thevpc/nuts/NArchFamily.java index 8d203174a..c6e595b39 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NArchFamily.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NArchFamily.java @@ -22,7 +22,7 @@ * governing permissions and limitations under the License. *
==================================================================== */ -package net.thevpc.nuts.env; +package net.thevpc.nuts; import net.thevpc.nuts.util.NEnum; import net.thevpc.nuts.util.NEnumUtils; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NBootOptions.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NBootOptions.java similarity index 98% rename from core/nuts-api/src/main/java/net/thevpc/nuts/env/NBootOptions.java rename to core/nuts-api/src/main/java/net/thevpc/nuts/NBootOptions.java index 83bc425db..3fabd9ad6 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NBootOptions.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NBootOptions.java @@ -1,9 +1,7 @@ -package net.thevpc.nuts.env; +package net.thevpc.nuts; -import net.thevpc.nuts.*; import net.thevpc.nuts.boot.NBootOptionsBoot; import net.thevpc.nuts.boot.NBootWorkspaceFactory; -import net.thevpc.nuts.boot.NBootClassLoaderNode; import net.thevpc.nuts.boot.NBootDescriptor; import net.thevpc.nuts.cmdline.NCmdLine; import net.thevpc.nuts.format.NContentType; @@ -27,11 +25,11 @@ public interface NBootOptions { NOptional getBootRepositories(); - NOptional getRuntimeBootDependencyNode(); + NOptional getRuntimeBootDependencyNode(); NOptional> getExtensionBootDescriptors(); - NOptional> getExtensionBootDependencyNodes(); + NOptional> getExtensionBootDependencyNodes(); NOptional getBootWorkspaceFactory(); diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NBootOptionsBuilder.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NBootOptionsBuilder.java similarity index 96% rename from core/nuts-api/src/main/java/net/thevpc/nuts/env/NBootOptionsBuilder.java rename to core/nuts-api/src/main/java/net/thevpc/nuts/NBootOptionsBuilder.java index 69adbc316..4ba15ba56 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NBootOptionsBuilder.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NBootOptionsBuilder.java @@ -1,8 +1,6 @@ -package net.thevpc.nuts.env; +package net.thevpc.nuts; -import net.thevpc.nuts.*; import net.thevpc.nuts.boot.NBootWorkspaceFactory; -import net.thevpc.nuts.boot.NBootClassLoaderNode; import net.thevpc.nuts.boot.NBootDescriptor; import net.thevpc.nuts.ext.NExtensions; import net.thevpc.nuts.format.NContentType; @@ -33,11 +31,11 @@ static NBootOptionsBuilder of(){ NBootOptionsBuilder setBootRepositories(String bootRepositories); - NBootOptionsBuilder setRuntimeBootDependencyNode(NBootClassLoaderNode runtimeBootDependencyNode); + NBootOptionsBuilder setRuntimeBootDependencyNode(NClassLoaderNode runtimeBootDependencyNode); NBootOptionsBuilder setExtensionBootDescriptors(List extensionBootDescriptors); - NBootOptionsBuilder setExtensionBootDependencyNodes(List extensionBootDependencyNodes); + NBootOptionsBuilder setExtensionBootDependencyNodes(List extensionBootDependencyNodes); NBootOptionsBuilder setBootWorkspaceFactory(NBootWorkspaceFactory bootWorkspaceFactory); diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NImports.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NClassLoaderNode.java similarity index 60% rename from core/nuts-api/src/main/java/net/thevpc/nuts/env/NImports.java rename to core/nuts-api/src/main/java/net/thevpc/nuts/NClassLoaderNode.java index aad29cb22..98b83d0a5 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NImports.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NClassLoaderNode.java @@ -9,45 +9,43 @@ * Nuts is not tied to java and is a good choice to share shell scripts and * other 'things' . Its based on an extensible architecture to help supporting a * large range of sub managers / repositories. - * *
*

- * Copyright [2020] [thevpc] - * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 (the "License"); + * Copyright [2020] [thevpc] + * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 (the "License"); * you may not use this file except in compliance with the License. You may obtain * a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html - * 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 + * 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 net.thevpc.nuts.env; +package net.thevpc.nuts; -import net.thevpc.nuts.ext.NExtensions; -import net.thevpc.nuts.spi.NComponent; +import net.thevpc.nuts.boot.reserved.util.NBootUtils; -import java.util.Set; +import java.net.URL; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; /** - * @app.category Base + * Loaded Package Information used to Boot + * + * @author thevpc + * @app.category Internal */ -public interface NImports extends NComponent { - static NImports of() { - return NExtensions.of(NImports.class); - } - - NImports addImports(String... importExpression); - - NImports clearImports(); +public interface NClassLoaderNode { - NImports removeImports(String... importExpression); + public boolean isIncludedInClasspath(); - NImports updateImports(String[] imports); + public boolean isEnabled(); - Set getAllImports(); + public NId getId(); - boolean isImportedGroupId(String groupId); + public URL getURL(); + public List getDependencies(); } diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NCommands.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NCommands.java deleted file mode 100644 index bb96c8000..000000000 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NCommands.java +++ /dev/null @@ -1,156 +0,0 @@ -/** - * ==================================================================== - * Nuts : Network Updatable Things Service - * (universal package manager) - *
- * is a new Open Source Package Manager to help install packages - * and libraries for runtime execution. Nuts is the ultimate companion for - * maven (and other build managers) as it helps installing all package - * dependencies at runtime. Nuts is not tied to java and is a good choice - * to share shell scripts and other 'things' . Its based on an extensible - * architecture to help supporting a large range of sub managers / repositories. - * - *
- *

- * Copyright [2020] [thevpc] - * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 (the "License"); - * you may not use this file except in compliance with the License. You may obtain - * a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html - * 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 net.thevpc.nuts; - -import net.thevpc.nuts.ext.NExtensions; -import net.thevpc.nuts.spi.NComponent; - -import java.util.List; - -/** - * Manage (add/update/remove) custom nuts commands (aliases) - * - * @author thevpc - * @app.category Config - */ -public interface NCommands extends NComponent { - static NCommands of() { - return NExtensions.of(NCommands.class); - } - - /** - * return registered command factories - * - * @return registered command factories - */ - List getCommandFactories(); - - /** - * register a new commandFactory. If it already exists, a NutsIllegalArgumentException is thrown - * - * @param commandFactory commandFactory - */ - void addCommandFactory(NCommandFactoryConfig commandFactory); - - /** - * unregister an existing commandFactory. If it is not found, a NutsIllegalArgumentException is thrown - * - * @param commandFactoryId commandFactoryId - */ - void removeCommandFactory(String commandFactoryId); - - /** - * unregister an existing commandFactory if it exists. - * - * @param commandFactoryId commandFactoryId - * @return true if removed - */ - boolean removeCommandFactoryIfExists(String commandFactoryId); - - /** - * return true if the command is registered or provided by a registered command factory - * - * @param command command name - * @return true if the command is registered or provided by a registered command factory - */ - boolean commandExists(String command); - - /** - * return true if the command factory is registered - * - * @param command command name - * @return true if the command factory is registered - */ - boolean commandFactoryExists(String command); - - /** - * add command. if the command is already registered (regardless off being defined by command factories) a confirmation is required to update it. - * - * @param command command - * @return true if successfully added - */ - boolean addCommand(NCommandConfig command); - - /** - * update command. if the command does not exists (not registered, regardless off being defined by command factories) a NutsIllegalArgumentException is thrown. - * - * @param command command - * @return true if successfully updated - */ - boolean updateCommand(NCommandConfig command); - - /** - * remove command. if the command does not exists a NutsIllegalArgumentException is thrown. - * - * @param command command name - */ - void removeCommand(String command); - - /** - * return true if exists and is removed - * - * @param name name - * @return true if exists and is removed - */ - boolean removeCommandIfExists(String name); - - /** - * return the first command for a given name, id and owner. - * Search is first performed in the registered commands then in each registered command factory. - * - * @param name command name, not null - * @param forId if not null, the alias name should resolve to the given id - * @param forOwner if not null, the alias name should resolve to the owner - * @return alias definition or null - */ - NCustomCmd findCommand(String name, NId forId, NId forOwner); - - /** - * return the first command for a given name, id and owner. - * Search is first performed in the registered commands then in each registered command factory. - * - * @param name command name, not null - * @return alias definition or null - */ - NCustomCmd findCommand(String name); - - /** - * find all registered and factory defined commands - * - * @return find all registered and factory defined commands - */ - List findAllCommands(); - - /** - * find all registered and factory defined commands by owner - * - * @param id owner - * @return all registered and factory defined commands by owner - */ - List findCommandsByOwner(NId id); - -} diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NConfigs.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NConfigs.java deleted file mode 100644 index 84c644504..000000000 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NConfigs.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * ==================================================================== - * Nuts : Network Updatable Things Service - * (universal package manager) - *
- * is a new Open Source Package Manager to help install packages and libraries - * for runtime execution. Nuts is the ultimate companion for maven (and other - * build managers) as it helps installing all package dependencies at runtime. - * Nuts is not tied to java and is a good choice to share shell scripts and - * other 'things' . Its based on an extensible architecture to help supporting a - * large range of sub managers / repositories. - *
- *

- * Copyright [2020] [thevpc] - * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 (the "License"); - * you may not use this file except in compliance with the License. You may obtain - * a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html - * 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 net.thevpc.nuts; - -import net.thevpc.nuts.ext.NExtensions; -import net.thevpc.nuts.io.NPath; -import net.thevpc.nuts.spi.NComponent; -import net.thevpc.nuts.spi.NIndexStoreFactory; -import net.thevpc.nuts.util.NLiteral; -import net.thevpc.nuts.util.NOptional; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * @author thevpc - * @app.category Config - * @since 0.5.4 - */ -public interface NConfigs extends NComponent { - static NConfigs of() { - return NExtensions.of(NConfigs.class); - } - - NWorkspaceStoredConfig stored(); - - boolean isReadOnly(); - - /** - * save config file if force is activated or non read only and some changes - * was detected in config file - * - * @param force when true, save will always be performed - * @return true if the save action was applied - */ - boolean save(boolean force); - - boolean save(); - - NWorkspaceBootConfig loadBootConfig(String path, boolean global, boolean followLinks); - - boolean isSupportedRepositoryType(String repositoryType); - - List getDefaultRepositories(); - - Set getAvailableArchetypes(); - - NPath resolveRepositoryPath(String repositoryLocation); - - NIndexStoreFactory getIndexStoreClientFactory(); - - String getJavaCommand(); - - String getJavaOptions(); - - boolean isSystemWorkspace(); - - - Map getConfigMap(); - - NOptional getConfigProperty(String property); - - /** - * @param property property - * @param value value - * @return {@code this} instance - */ - NConfigs setConfigProperty(String property, String value); -} diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NDependencies.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NDependencies.java index de77aa215..141e0fd1d 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NDependencies.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NDependencies.java @@ -54,22 +54,22 @@ public interface NDependencies extends NIterable { NDependencyFilter filter(); /** - * return immediate dependencies (not including sources) + * return immediate dependencies (not including source ids) * @return immediate dependencies */ NStream immediate(); /** - * return transitive (all but sources) dependencies - * @return transitive (all but sources) dependencies + * return transitive (all but source ids) dependencies + * @return transitive (all but source ids) dependencies */ NStream transitive(); /** - * transitive dependencies merged with ids, which may constitute a full classpath + * transitive dependencies merged with source ids, which may constitute a full classpath * - * @return transitive dependencies merged with ids, which may constitute a full classpath + * @return transitive dependencies merged with source ids, which may constitute a full classpath */ NStream transitiveWithSource(); diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NDependency.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NDependency.java index ab7531c73..386c381c9 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NDependency.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NDependency.java @@ -25,7 +25,6 @@ */ package net.thevpc.nuts; -import net.thevpc.nuts.env.NEnvCondition; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.util.NOptional; @@ -45,6 +44,12 @@ public interface NDependency extends Serializable, NBlankable { static NOptional of(String value) { return NId.of(value).map(NId::toDependency); } + static NOptional of(NId value) { + if(value==null){ + return NOptional.ofNamedEmpty("id"); + } + return NOptional.of(value.toDependency()); + } /** * return mutable id builder instance initialized with {@code this} instance. diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NDependencyBuilder.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NDependencyBuilder.java index 8c743e60d..5a3892d78 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NDependencyBuilder.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NDependencyBuilder.java @@ -25,7 +25,6 @@ */ package net.thevpc.nuts; -import net.thevpc.nuts.env.NEnvCondition; import net.thevpc.nuts.ext.NExtensions; import net.thevpc.nuts.spi.NComponent; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NDependencyFilters.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NDependencyFilters.java index 97ee43cf8..4aec07309 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NDependencyFilters.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NDependencyFilters.java @@ -25,10 +25,6 @@ */ package net.thevpc.nuts; -import net.thevpc.nuts.env.NArchFamily; -import net.thevpc.nuts.env.NDesktopEnvironmentFamily; -import net.thevpc.nuts.env.NOsFamily; -import net.thevpc.nuts.env.NPlatformFamily; import net.thevpc.nuts.ext.NExtensions; import java.util.Collection; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NDescriptor.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NDescriptor.java index 99927d4b8..9764f9dc8 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NDescriptor.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NDescriptor.java @@ -25,8 +25,6 @@ */ package net.thevpc.nuts; -import net.thevpc.nuts.env.NEnvCondition; -import net.thevpc.nuts.env.NIdLocation; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.util.NLiteral; import net.thevpc.nuts.util.NOptional; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NDescriptorBuilder.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NDescriptorBuilder.java index 5d620f08b..53b6617bd 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NDescriptorBuilder.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NDescriptorBuilder.java @@ -25,8 +25,6 @@ */ package net.thevpc.nuts; -import net.thevpc.nuts.env.NEnvCondition; -import net.thevpc.nuts.env.NIdLocation; import net.thevpc.nuts.ext.NExtensions; import net.thevpc.nuts.spi.NComponent; import net.thevpc.nuts.util.NLiteral; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NDescriptorProperty.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NDescriptorProperty.java index 5be972e20..3c89ec823 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NDescriptorProperty.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NDescriptorProperty.java @@ -26,7 +26,6 @@ */ package net.thevpc.nuts; -import net.thevpc.nuts.env.NEnvCondition; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.util.NLiteral; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NDescriptorPropertyBuilder.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NDescriptorPropertyBuilder.java index 088f4a1bd..d9c15b207 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NDescriptorPropertyBuilder.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NDescriptorPropertyBuilder.java @@ -1,7 +1,5 @@ package net.thevpc.nuts; -import net.thevpc.nuts.env.NEnvCondition; - public interface NDescriptorPropertyBuilder extends NDescriptorProperty { NDescriptorPropertyBuilder setCondition(NEnvCondition condition); diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NDesktopEnvironmentFamily.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NDesktopEnvironmentFamily.java similarity index 99% rename from core/nuts-api/src/main/java/net/thevpc/nuts/env/NDesktopEnvironmentFamily.java rename to core/nuts-api/src/main/java/net/thevpc/nuts/NDesktopEnvironmentFamily.java index 455d902f3..7f2279cc7 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NDesktopEnvironmentFamily.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NDesktopEnvironmentFamily.java @@ -24,7 +24,7 @@ *
* ==================================================================== */ -package net.thevpc.nuts.env; +package net.thevpc.nuts; import net.thevpc.nuts.util.NEnum; import net.thevpc.nuts.util.NEnumUtils; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NDesktopIntegrationItem.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NDesktopIntegrationItem.java similarity index 98% rename from core/nuts-api/src/main/java/net/thevpc/nuts/env/NDesktopIntegrationItem.java rename to core/nuts-api/src/main/java/net/thevpc/nuts/NDesktopIntegrationItem.java index 3a091d305..7ffc32cc9 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NDesktopIntegrationItem.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NDesktopIntegrationItem.java @@ -24,7 +24,7 @@ *
* ==================================================================== */ -package net.thevpc.nuts.env; +package net.thevpc.nuts; import net.thevpc.nuts.util.NEnum; import net.thevpc.nuts.util.NEnumUtils; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NEnvCondition.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NEnvCondition.java similarity index 99% rename from core/nuts-api/src/main/java/net/thevpc/nuts/env/NEnvCondition.java rename to core/nuts-api/src/main/java/net/thevpc/nuts/NEnvCondition.java index c074f8f80..eaae6cd91 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NEnvCondition.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NEnvCondition.java @@ -23,7 +23,7 @@ *
* ==================================================================== */ -package net.thevpc.nuts.env; +package net.thevpc.nuts; import net.thevpc.nuts.util.NBlankable; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NEnvConditionBuilder.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NEnvConditionBuilder.java similarity index 98% rename from core/nuts-api/src/main/java/net/thevpc/nuts/env/NEnvConditionBuilder.java rename to core/nuts-api/src/main/java/net/thevpc/nuts/NEnvConditionBuilder.java index 229021151..4ec74c764 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NEnvConditionBuilder.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NEnvConditionBuilder.java @@ -1,4 +1,4 @@ -package net.thevpc.nuts.env; +package net.thevpc.nuts; import net.thevpc.nuts.ext.NExtensions; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NEvents.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NEvents.java index 38bb39121..1582dc909 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NEvents.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NEvents.java @@ -1,67 +1,67 @@ -/** - * ==================================================================== - * Nuts : Network Updatable Things Service - * (universal package manager) - *
- * is a new Open Source Package Manager to help install packages and libraries - * for runtime execution. Nuts is the ultimate companion for maven (and other - * build managers) as it helps installing all package dependencies at runtime. - * Nuts is not tied to java and is a good choice to share shell scripts and - * other 'things' . Its based on an extensible architecture to help supporting a - * large range of sub managers / repositories. - * - *
- *

- * Copyright [2020] [thevpc] - * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 (the "License"); - * you may not use this file except in compliance with the License. You may obtain - * a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html - * 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 net.thevpc.nuts; - -import net.thevpc.nuts.ext.NExtensions; -import net.thevpc.nuts.spi.NComponent; -import net.thevpc.nuts.util.NObservableMapListener; - -import java.util.List; - -/** - * @author thevpc - * @app.category Events - */ -public interface NEvents extends NComponent { - static NEvents of() { - return NExtensions.of(NEvents.class); - } - - NEvents removeRepositoryListener(NRepositoryListener listener); - - NEvents addRepositoryListener(NRepositoryListener listener); - - List getRepositoryListeners(); - - NEvents addUserPropertyListener(NObservableMapListener listener); - - NEvents removeUserPropertyListener(NObservableMapListener listener); - - List> getUserPropertyListeners(); - - NEvents removeWorkspaceListener(NWorkspaceListener listener); - - NEvents addWorkspaceListener(NWorkspaceListener listener); - - List getWorkspaceListeners(); - - NEvents removeInstallListener(NInstallListener listener); - - NEvents addInstallListener(NInstallListener listener); - - List getInstallListeners(); - -} +///** +// * ==================================================================== +// * Nuts : Network Updatable Things Service +// * (universal package manager) +// *
+// * is a new Open Source Package Manager to help install packages and libraries +// * for runtime execution. Nuts is the ultimate companion for maven (and other +// * build managers) as it helps installing all package dependencies at runtime. +// * Nuts is not tied to java and is a good choice to share shell scripts and +// * other 'things' . Its based on an extensible architecture to help supporting a +// * large range of sub managers / repositories. +// * +// *
+// *

+// * Copyright [2020] [thevpc] +// * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 (the "License"); +// * you may not use this file except in compliance with the License. You may obtain +// * a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html +// * 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 net.thevpc.nuts; +// +//import net.thevpc.nuts.ext.NExtensions; +//import net.thevpc.nuts.spi.NComponent; +//import net.thevpc.nuts.util.NObservableMapListener; +// +//import java.util.List; +// +///** +// * @author thevpc +// * @app.category Events +// */ +//public interface NEvents extends NComponent { +// static NEvents of() { +// return NExtensions.of(NEvents.class); +// } +// +// NEvents removeRepositoryListener(NRepositoryListener listener); +// +// NEvents addRepositoryListener(NRepositoryListener listener); +// +// List getRepositoryListeners(); +// +// NEvents addUserPropertyListener(NObservableMapListener listener); +// +// NEvents removeUserPropertyListener(NObservableMapListener listener); +// +// List> getUserPropertyListeners(); +// +// NEvents removeWorkspaceListener(NWorkspaceListener listener); +// +// NEvents addWorkspaceListener(NWorkspaceListener listener); +// +// List getWorkspaceListeners(); +// +// NEvents removeInstallListener(NInstallListener listener); +// +// NEvents addInstallListener(NInstallListener listener); +// +// List getInstallListeners(); +// +//} diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NExecutableType.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NExecutableType.java index 204148aa7..c8b07dd34 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NExecutableType.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NExecutableType.java @@ -25,6 +25,7 @@ */ package net.thevpc.nuts; + import net.thevpc.nuts.util.NEnum; import net.thevpc.nuts.util.NEnumUtils; import net.thevpc.nuts.util.NNameFormat; @@ -45,7 +46,7 @@ public enum NExecutableType implements NEnum { /** * workspace configured command using - * {@link NCommands#addCommand(NCommandConfig)} + * {@link NEnvs#addCommand(NCommandConfig)} */ ALIAS, diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NHomeLocation.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NHomeLocation.java similarity index 99% rename from core/nuts-api/src/main/java/net/thevpc/nuts/env/NHomeLocation.java rename to core/nuts-api/src/main/java/net/thevpc/nuts/NHomeLocation.java index 1ca1f6ec9..36b87c32e 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NHomeLocation.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NHomeLocation.java @@ -24,7 +24,7 @@ *
* ==================================================================== */ -package net.thevpc.nuts.env; +package net.thevpc.nuts; import net.thevpc.nuts.util.NEnum; import net.thevpc.nuts.util.NMsg; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NId.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NId.java index eb8e24185..37386ca53 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NId.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NId.java @@ -25,7 +25,6 @@ */ package net.thevpc.nuts; -import net.thevpc.nuts.env.NEnvCondition; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.reserved.NReservedUtils; import net.thevpc.nuts.util.NBlankable; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NIdBuilder.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NIdBuilder.java index e721b4a5c..060e82f40 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NIdBuilder.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NIdBuilder.java @@ -25,8 +25,6 @@ */ package net.thevpc.nuts; -import net.thevpc.nuts.env.NEnvCondition; -import net.thevpc.nuts.env.NEnvConditionBuilder; import net.thevpc.nuts.ext.NExtensions; import net.thevpc.nuts.spi.NComponent; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NIdLocation.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NIdLocation.java similarity index 98% rename from core/nuts-api/src/main/java/net/thevpc/nuts/env/NIdLocation.java rename to core/nuts-api/src/main/java/net/thevpc/nuts/NIdLocation.java index 68fd1512b..a2d5907f7 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NIdLocation.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NIdLocation.java @@ -24,9 +24,8 @@ *
* ==================================================================== */ -package net.thevpc.nuts.env; +package net.thevpc.nuts; -import net.thevpc.nuts.NDescriptor; import net.thevpc.nuts.util.NBlankable; import java.util.Objects; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NIndexStore.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NIndexStore.java similarity index 97% rename from core/nuts-api/src/main/java/net/thevpc/nuts/env/NIndexStore.java rename to core/nuts-api/src/main/java/net/thevpc/nuts/NIndexStore.java index 2cbfe3988..91339e8ea 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NIndexStore.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NIndexStore.java @@ -24,10 +24,8 @@ *
* ==================================================================== */ -package net.thevpc.nuts.env; +package net.thevpc.nuts; -import net.thevpc.nuts.NId; -import net.thevpc.nuts.NIdFilter; import net.thevpc.nuts.util.NIterator; /** diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NInstallSvcCmd.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NInstallSvcCmd.java index be57ac0f8..9ab0d257c 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NInstallSvcCmd.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NInstallSvcCmd.java @@ -1,7 +1,6 @@ package net.thevpc.nuts; import net.thevpc.nuts.cmdline.NCmdLineConfigurable; -import net.thevpc.nuts.env.NOsServiceType; import net.thevpc.nuts.ext.NExtensions; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.spi.NComponent; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NIsolationLevel.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NIsolationLevel.java similarity index 98% rename from core/nuts-api/src/main/java/net/thevpc/nuts/env/NIsolationLevel.java rename to core/nuts-api/src/main/java/net/thevpc/nuts/NIsolationLevel.java index 6e886e2b9..9d8914f48 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NIsolationLevel.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NIsolationLevel.java @@ -24,7 +24,7 @@ *
* ==================================================================== */ -package net.thevpc.nuts.env; +package net.thevpc.nuts; import net.thevpc.nuts.util.NEnum; import net.thevpc.nuts.util.NEnumUtils; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NLauncherOptions.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NLauncherOptions.java similarity index 99% rename from core/nuts-api/src/main/java/net/thevpc/nuts/env/NLauncherOptions.java rename to core/nuts-api/src/main/java/net/thevpc/nuts/NLauncherOptions.java index 940a7a3c8..7096fbf4a 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NLauncherOptions.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NLauncherOptions.java @@ -24,9 +24,8 @@ *
* ==================================================================== */ -package net.thevpc.nuts.env; +package net.thevpc.nuts; -import net.thevpc.nuts.NId; import net.thevpc.nuts.util.NSupportMode; import java.util.ArrayList; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NLocations.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NLocations.java similarity index 98% rename from core/nuts-api/src/main/java/net/thevpc/nuts/env/NLocations.java rename to core/nuts-api/src/main/java/net/thevpc/nuts/NLocations.java index 8b4e904b9..d71c7fb8a 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NLocations.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NLocations.java @@ -23,9 +23,8 @@ * governing permissions and limitations under the License. *
==================================================================== */ -package net.thevpc.nuts.env; +package net.thevpc.nuts; -import net.thevpc.nuts.NId; import net.thevpc.nuts.ext.NExtensions; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.spi.NComponent; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NOsFamily.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NOsFamily.java similarity index 99% rename from core/nuts-api/src/main/java/net/thevpc/nuts/env/NOsFamily.java rename to core/nuts-api/src/main/java/net/thevpc/nuts/NOsFamily.java index 3d72d622d..e16a09513 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NOsFamily.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NOsFamily.java @@ -23,7 +23,7 @@ *
* ==================================================================== */ -package net.thevpc.nuts.env; +package net.thevpc.nuts; import net.thevpc.nuts.util.NEnum; import net.thevpc.nuts.util.NEnumUtils; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NOsServiceType.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NOsServiceType.java similarity index 71% rename from core/nuts-api/src/main/java/net/thevpc/nuts/env/NOsServiceType.java rename to core/nuts-api/src/main/java/net/thevpc/nuts/NOsServiceType.java index 8d2653cc2..fd6256399 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NOsServiceType.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NOsServiceType.java @@ -1,4 +1,4 @@ -package net.thevpc.nuts.env; +package net.thevpc.nuts; public enum NOsServiceType { INITD, diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NPlatformFamily.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NPlatformFamily.java similarity index 98% rename from core/nuts-api/src/main/java/net/thevpc/nuts/env/NPlatformFamily.java rename to core/nuts-api/src/main/java/net/thevpc/nuts/NPlatformFamily.java index 4fb6a1574..368f38ab1 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NPlatformFamily.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NPlatformFamily.java @@ -22,7 +22,7 @@ * governing permissions and limitations under the License. *
==================================================================== */ -package net.thevpc.nuts.env; +package net.thevpc.nuts; import net.thevpc.nuts.util.NEnum; import net.thevpc.nuts.util.NEnumUtils; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NPlatformHome.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NPlatformHome.java similarity index 99% rename from core/nuts-api/src/main/java/net/thevpc/nuts/env/NPlatformHome.java rename to core/nuts-api/src/main/java/net/thevpc/nuts/NPlatformHome.java index a793d5e03..583197e9c 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NPlatformHome.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NPlatformHome.java @@ -1,7 +1,5 @@ -package net.thevpc.nuts.env; +package net.thevpc.nuts; -import net.thevpc.nuts.*; -import net.thevpc.nuts.NConstants; import net.thevpc.nuts.reserved.NApiUtilsRPI; import net.thevpc.nuts.util.NAssert; import net.thevpc.nuts.util.NBlankable; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NPlatformLocation.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NPlatformLocation.java index 6db0fc631..f1d47c53f 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NPlatformLocation.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NPlatformLocation.java @@ -26,7 +26,6 @@ package net.thevpc.nuts; import net.thevpc.nuts.util.NBlankable; -import net.thevpc.nuts.env.NPlatformFamily; import java.util.Objects; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NPlatforms.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NPlatforms.java index 814e45020..22c5ad04b 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NPlatforms.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NPlatforms.java @@ -1,88 +1,88 @@ -/** - * ==================================================================== - * Nuts : Network Updatable Things Service - * (universal package manager) - *
- * is a new Open Source Package Manager to help install packages - * and libraries for runtime execution. Nuts is the ultimate companion for - * maven (and other build managers) as it helps installing all package - * dependencies at runtime. Nuts is not tied to java and is a good choice - * to share shell scripts and other 'things' . Its based on an extensible - * architecture to help supporting a large range of sub managers / repositories. - * - *
- *

- * Copyright [2020] [thevpc] - * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 (the "License"); - * you may not use this file except in compliance with the License. You may obtain - * a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html - * 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 net.thevpc.nuts; - -import net.thevpc.nuts.ext.NExtensions; -import net.thevpc.nuts.io.NPath; -import net.thevpc.nuts.spi.NComponent; -import net.thevpc.nuts.util.NOptional; -import net.thevpc.nuts.env.NPlatformFamily; -import net.thevpc.nuts.util.NStream; - -import java.util.function.Predicate; - -/** - * @app.category Toolkit - */ -public interface NPlatforms extends NComponent { - static NPlatforms of() { - return NExtensions.of(NPlatforms.class); - } - - boolean addPlatform(NPlatformLocation location); - - boolean updatePlatform(NPlatformLocation oldLocation, NPlatformLocation newLocation); - - boolean removePlatform(NPlatformLocation location); - - NOptional findPlatformByName(NPlatformFamily platformType, String locationName); - - NOptional findPlatformByPath(NPlatformFamily platformType, NPath path); - - NOptional findPlatformByVersion(NPlatformFamily platformType, String version); - - NOptional findPlatform(NPlatformLocation location); - - NOptional findPlatformByVersion(NPlatformFamily platformType, NVersionFilter requestedVersion); - - - NStream searchSystemPlatforms(NPlatformFamily platformFamily); - - NStream searchSystemPlatforms(NPlatformFamily platformFamily, NPath path); - - /** - * verify if the path is a valid platform path and return null if not - * - * @param platformType platform type - * @param path platform path - * @param preferredName preferredName - * @return null if not a valid jdk path - */ - NOptional resolvePlatform(NPlatformFamily platformType, NPath path, String preferredName); - - NOptional findPlatform(NPlatformFamily type, Predicate filter); - - NStream findPlatforms(NPlatformFamily type, Predicate filter); - - NStream findPlatforms(); - - NStream findPlatforms(NPlatformFamily type); - - void addDefaultPlatforms(NPlatformFamily type); - - void addDefaultPlatform(NPlatformFamily type); -} +///** +// * ==================================================================== +// * Nuts : Network Updatable Things Service +// * (universal package manager) +// *
+// * is a new Open Source Package Manager to help install packages +// * and libraries for runtime execution. Nuts is the ultimate companion for +// * maven (and other build managers) as it helps installing all package +// * dependencies at runtime. Nuts is not tied to java and is a good choice +// * to share shell scripts and other 'things' . Its based on an extensible +// * architecture to help supporting a large range of sub managers / repositories. +// * +// *
+// *

+// * Copyright [2020] [thevpc] +// * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 (the "License"); +// * you may not use this file except in compliance with the License. You may obtain +// * a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html +// * 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 net.thevpc.nuts; +// +//import net.thevpc.nuts.ext.NExtensions; +//import net.thevpc.nuts.io.NPath; +//import net.thevpc.nuts.spi.NComponent; +//import net.thevpc.nuts.util.NOptional; +//import net.thevpc.nuts.NPlatformFamily; +//import net.thevpc.nuts.util.NStream; +// +//import java.util.function.Predicate; +// +///** +// * @app.category Toolkit +// */ +//public interface NPlatforms extends NComponent { +// static NPlatforms of() { +// return NExtensions.of(NPlatforms.class); +// } +// +// boolean addPlatform(NPlatformLocation location); +// +// boolean updatePlatform(NPlatformLocation oldLocation, NPlatformLocation newLocation); +// +// boolean removePlatform(NPlatformLocation location); +// +// NOptional findPlatformByName(NPlatformFamily platformType, String locationName); +// +// NOptional findPlatformByPath(NPlatformFamily platformType, NPath path); +// +// NOptional findPlatformByVersion(NPlatformFamily platformType, String version); +// +// NOptional findPlatform(NPlatformLocation location); +// +// NOptional findPlatformByVersion(NPlatformFamily platformType, NVersionFilter requestedVersion); +// +// +// NStream searchSystemPlatforms(NPlatformFamily platformFamily); +// +// NStream searchSystemPlatforms(NPlatformFamily platformFamily, NPath path); +// +// /** +// * verify if the path is a valid platform path and return null if not +// * +// * @param platformType platform type +// * @param path platform path +// * @param preferredName preferredName +// * @return null if not a valid jdk path +// */ +// NOptional resolvePlatform(NPlatformFamily platformType, NPath path, String preferredName); +// +// NOptional findPlatform(NPlatformFamily type, Predicate filter); +// +// NStream findPlatforms(NPlatformFamily type, Predicate filter); +// +// NStream findPlatforms(); +// +// NStream findPlatforms(NPlatformFamily type); +// +// void addDefaultPlatforms(NPlatformFamily type); +// +// void addDefaultPlatform(NPlatformFamily type); +//} diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NReadOnlyException.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NReadOnlyException.java index 26ccfd355..385b5b560 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NReadOnlyException.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NReadOnlyException.java @@ -25,7 +25,7 @@ */ package net.thevpc.nuts; -import net.thevpc.nuts.env.NLocations; + import net.thevpc.nuts.text.NText; import net.thevpc.nuts.text.NTextStyle; import net.thevpc.nuts.util.NMsg; @@ -51,6 +51,6 @@ public NReadOnlyException(String location) { * Constructs a new NutsReadOnlyException exception */ public NReadOnlyException() { - this(NSession.of().isNotPresent()? null : String.valueOf(NLocations.of().getWorkspaceLocation())); + this(NSession.of().isNotPresent()? null : String.valueOf(NWorkspace.get().getWorkspaceLocation())); } } diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NRepositoryConfig.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NRepositoryConfig.java index 10e49cd74..bb97ee319 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NRepositoryConfig.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NRepositoryConfig.java @@ -25,9 +25,6 @@ */ package net.thevpc.nuts; -import net.thevpc.nuts.env.NStoreStrategy; -import net.thevpc.nuts.env.NStoreType; -import net.thevpc.nuts.env.NUserConfig; import net.thevpc.nuts.spi.NRepositoryLocation; import java.io.Serializable; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NRepositoryConfigManager.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NRepositoryConfigManager.java index 2b0a60ffb..5e387f0ab 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NRepositoryConfigManager.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NRepositoryConfigManager.java @@ -24,9 +24,6 @@ */ package net.thevpc.nuts; -import net.thevpc.nuts.env.NSpeedQualifier; -import net.thevpc.nuts.env.NStoreStrategy; -import net.thevpc.nuts.env.NStoreType; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.spi.NRepositoryLocation; import net.thevpc.nuts.util.NLiteral; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NRepositoryModel.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NRepositoryModel.java index 516bbbcea..b17ba00b1 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NRepositoryModel.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NRepositoryModel.java @@ -26,8 +26,6 @@ */ package net.thevpc.nuts; -import net.thevpc.nuts.env.NSpeedQualifier; -import net.thevpc.nuts.env.NStoreStrategy; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.util.NIterator; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NRepositorySecurityManager.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NRepositorySecurityManager.java index 9bd344ecc..afc802cf2 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NRepositorySecurityManager.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NRepositorySecurityManager.java @@ -25,7 +25,6 @@ */ package net.thevpc.nuts; -import net.thevpc.nuts.env.NUser; import net.thevpc.nuts.security.NAuthenticationAgent; import java.util.List; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NSearchCmd.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NSearchCmd.java index 7af46e285..2480be1ca 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NSearchCmd.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NSearchCmd.java @@ -26,7 +26,6 @@ import net.thevpc.nuts.cmdline.NCmdLineConfigurable; import net.thevpc.nuts.elem.NElement; -import net.thevpc.nuts.env.NStoreType; import net.thevpc.nuts.ext.NExtensions; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.util.NComparator; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NShellFamily.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NShellFamily.java similarity index 99% rename from core/nuts-api/src/main/java/net/thevpc/nuts/env/NShellFamily.java rename to core/nuts-api/src/main/java/net/thevpc/nuts/NShellFamily.java index e8a6104e4..4c1771db9 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NShellFamily.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NShellFamily.java @@ -23,7 +23,7 @@ *
* ==================================================================== */ -package net.thevpc.nuts.env; +package net.thevpc.nuts; import net.thevpc.nuts.util.*; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NSpeedQualifier.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NSpeedQualifier.java similarity index 98% rename from core/nuts-api/src/main/java/net/thevpc/nuts/env/NSpeedQualifier.java rename to core/nuts-api/src/main/java/net/thevpc/nuts/NSpeedQualifier.java index 2edf290af..a1f10b087 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NSpeedQualifier.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NSpeedQualifier.java @@ -24,7 +24,7 @@ *
* ==================================================================== */ -package net.thevpc.nuts.env; +package net.thevpc.nuts; import net.thevpc.nuts.util.NEnum; import net.thevpc.nuts.util.NEnumUtils; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NStoreStrategy.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NStoreStrategy.java similarity index 98% rename from core/nuts-api/src/main/java/net/thevpc/nuts/env/NStoreStrategy.java rename to core/nuts-api/src/main/java/net/thevpc/nuts/NStoreStrategy.java index c97612786..a959d2b40 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NStoreStrategy.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NStoreStrategy.java @@ -24,7 +24,7 @@ *
* ==================================================================== */ -package net.thevpc.nuts.env; +package net.thevpc.nuts; import net.thevpc.nuts.util.NEnum; import net.thevpc.nuts.util.NEnumUtils; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NStoreType.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NStoreType.java similarity index 99% rename from core/nuts-api/src/main/java/net/thevpc/nuts/env/NStoreType.java rename to core/nuts-api/src/main/java/net/thevpc/nuts/NStoreType.java index a82bc5916..fa92f5077 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NStoreType.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NStoreType.java @@ -24,7 +24,7 @@ *
* ==================================================================== */ -package net.thevpc.nuts.env; +package net.thevpc.nuts; import net.thevpc.nuts.util.NEnum; import net.thevpc.nuts.util.NEnumUtils; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NUser.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NUser.java similarity index 98% rename from core/nuts-api/src/main/java/net/thevpc/nuts/env/NUser.java rename to core/nuts-api/src/main/java/net/thevpc/nuts/NUser.java index c48a2fded..66b55c2fb 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NUser.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NUser.java @@ -24,7 +24,7 @@ *
* ==================================================================== */ -package net.thevpc.nuts.env; +package net.thevpc.nuts; import java.util.List; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NUserConfig.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NUserConfig.java similarity index 98% rename from core/nuts-api/src/main/java/net/thevpc/nuts/env/NUserConfig.java rename to core/nuts-api/src/main/java/net/thevpc/nuts/NUserConfig.java index a200f328f..cc97c69c5 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NUserConfig.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NUserConfig.java @@ -23,9 +23,8 @@ *
* ==================================================================== */ -package net.thevpc.nuts.env; +package net.thevpc.nuts; -import net.thevpc.nuts.NConfigItem; import net.thevpc.nuts.reserved.NReservedLangUtils; import java.util.ArrayList; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NWorkspace.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NWorkspace.java index f059cea23..ade7ed5d7 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NWorkspace.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NWorkspace.java @@ -29,11 +29,19 @@ import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.reserved.NScopedWorkspace; import net.thevpc.nuts.spi.NComponent; -import net.thevpc.nuts.util.NCallable; -import net.thevpc.nuts.util.NOptional; -import net.thevpc.nuts.util.NRunnable; +import net.thevpc.nuts.spi.NIndexStoreFactory; +import net.thevpc.nuts.util.*; import java.io.Closeable; +import java.net.URL; +import java.nio.file.Path; +import java.time.Duration; +import java.time.Instant; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Function; +import java.util.function.Predicate; /** * Created by vpc on 1/5/17. @@ -101,4 +109,464 @@ static T call(NCallable callable) { NExtensions extensions(); void close(); + + /// //////////////////// + + + NWorkspace removeRepositoryListener(NRepositoryListener listener); + + NWorkspace addRepositoryListener(NRepositoryListener listener); + + List getRepositoryListeners(); + + NWorkspace addUserPropertyListener(NObservableMapListener listener); + + NWorkspace removeUserPropertyListener(NObservableMapListener listener); + + List> getUserPropertyListeners(); + + NWorkspace removeWorkspaceListener(NWorkspaceListener listener); + + NWorkspace addWorkspaceListener(NWorkspaceListener listener); + + List getWorkspaceListeners(); + + NWorkspace removeInstallListener(NInstallListener listener); + + NWorkspace addInstallListener(NInstallListener listener); + + List getInstallListeners(); + + /// /////////////////////////////// + + NRepository addRepository(NAddRepositoryOptions options); + + /** + * creates a new repository from the given + * {@code repositoryNamedUrl}.Accepted {@code repositoryNamedUrl} values are + * : + *

    + *
  • 'local' : corresponds to a local updatable repository. + *

    + * will be named 'local'

  • + *
  • 'm2', '.m2', 'maven-local' : corresponds the local maven folder + * repository. will be named 'local'
  • + *
  • 'maven-central': corresponds the remote maven central repository. + * will be named 'local'
  • + *
  • 'maven-git', 'vpc-public-maven': corresponds the remote maven + * vpc-public-maven git folder repository. will be named 'local'
  • + *
  • 'maven-git', 'nuts-public': corresponds the remote nuts + * nuts-public git folder repository. will be named 'local'
  • + *
  • name=uri-or-path : corresponds the given uri. will be named name. + * Here are some examples: + *
      + *
    • myremote=http://192.168.6.3/folder
    • + *
    • myremote=/folder/subfolder
    • + *
    • myremote=c:/folder/subfolder
    • + *
    + *
  • + *
  • uri-or-path : corresponds the given uri. will be named uri's last + * path package name. Here are some examples: + *
      + *
    • http://192.168.6.3/folder : will be named 'folder'
    • + *
    • myremote=/folder/subfolder : will be named 'folder'
    • + *
    • myremote=c:/folder/subfolder : will be named 'folder'
    • + *
    + *
  • + *
+ * + * @param repositoryNamedUrl repositoryNamedUrl + * @return created repository + */ + NRepository addRepository(String repositoryNamedUrl); + + NOptional findRepositoryById(String repositoryIdOrName); + + NOptional findRepositoryByName(String repositoryIdOrName); + + /** + * @param repositoryIdOrName repository id or name + * @return null if not found + */ + NOptional findRepository(String repositoryIdOrName); + + NWorkspace removeRepository(String locationOrRepositoryId); + + List getRepositories(); + + NWorkspace removeAllRepositories(); + + /// ///////// + + + + /** + * @return properties + * @since 0.8.1 + */ + Map getProperties(); + + /** + * return property raw value + * + * @param property property name + * @return property raw value + * @since 0.8.1 + */ + NOptional getProperty(String property); + + /** + * @param property property + * @param value value + * @return {@code this} instance + * @since 0.8.1 + */ + NWorkspace setProperty(String property, Object value); + + String getHostName(); + + String getPid(); + + NOsFamily getOsFamily(); + + Set getShellFamilies(); + + NShellFamily getShellFamily(); + + NId getDesktopEnvironment(); + + Set getDesktopEnvironments(); + + NDesktopEnvironmentFamily getDesktopEnvironmentFamily(); + + Set getDesktopEnvironmentFamilies(); + + NId getPlatform(); + + NId getOs(); + + NId getOsDist(); + + NId getArch(); + + NArchFamily getArchFamily(); + + boolean isGraphicalDesktopEnvironment(); + + NSupportMode getDesktopIntegrationSupport(NDesktopIntegrationItem target); + + Path getDesktopPath(); + + void addLauncher(NLauncherOptions launcher); + + List buildEffectiveCommand(String[] cmd, + NRunAs runAsMode, + Set de, + Function sysWhich, + Boolean gui, + String rootName, + String userName, + String[] executorOptions + ); + + NPath getHomeLocation(NStoreType folderType); + + NPath getStoreLocation(NStoreType folderType); + + NPath getStoreLocation(NId id, NStoreType folderType); + + NPath getStoreLocation(NStoreType folderType, String repositoryIdOrName); + + NPath getStoreLocation(NId id, NStoreType folderType, String repositoryIdOrName); + + NStoreStrategy getStoreStrategy(); + + NWorkspace setStoreStrategy(NStoreStrategy strategy); + + NStoreStrategy getRepositoryStoreStrategy(); + + NOsFamily getStoreLayout(); + + NWorkspace setStoreLayout(NOsFamily storeLayout); + + /** + * all home locations key/value map where keys are in the form "location" + * and values are absolute paths. + * + * @return home locations mapping + */ + Map getStoreLocations(); + + String getDefaultIdFilename(NId id); + + NPath getDefaultIdBasedir(NId id); + + String getDefaultIdContentExtension(String packaging); + + String getDefaultIdExtension(NId id); + + /** + * all home locations key/value map where keys are in the form + * "osfamily:location" and values are absolute paths. + * + * @return home locations mapping + */ + Map getHomeLocations(); + + NPath getHomeLocation(NHomeLocation location); + + NPath getWorkspaceLocation(); + + NWorkspace setStoreLocation(NStoreType folderType, String location); + + NWorkspace setHomeLocation(NHomeLocation homeType, String location); + + boolean addPlatform(NPlatformLocation location); + + boolean updatePlatform(NPlatformLocation oldLocation, NPlatformLocation newLocation); + + boolean removePlatform(NPlatformLocation location); + + NOptional findPlatformByName(NPlatformFamily platformType, String locationName); + + NOptional findPlatformByPath(NPlatformFamily platformType, NPath path); + + NOptional findPlatformByVersion(NPlatformFamily platformType, String version); + + NOptional findPlatform(NPlatformLocation location); + + NOptional findPlatformByVersion(NPlatformFamily platformType, NVersionFilter requestedVersion); + + + NStream searchSystemPlatforms(NPlatformFamily platformFamily); + + NStream searchSystemPlatforms(NPlatformFamily platformFamily, NPath path); + + /** + * verify if the path is a valid platform path and return null if not + * + * @param platformType platform type + * @param path platform path + * @param preferredName preferredName + * @return null if not a valid jdk path + */ + NOptional resolvePlatform(NPlatformFamily platformType, NPath path, String preferredName); + + NOptional findPlatform(NPlatformFamily type, Predicate filter); + + NStream findPlatforms(NPlatformFamily type, Predicate filter); + + NStream findPlatforms(); + + NStream findPlatforms(NPlatformFamily type); + + NWorkspace addDefaultPlatforms(NPlatformFamily type); + + NWorkspace addDefaultPlatform(NPlatformFamily type); + + /// / + + NWorkspace addImports(String... importExpression); + + NWorkspace clearImports(); + + NWorkspace removeImports(String... importExpression); + + NWorkspace updateImports(String[] imports); + + Set getAllImports(); + + boolean isImportedGroupId(String groupId); + + /// ///////////////// + + NWorkspaceStoredConfig getStoredConfig(); + + boolean isReadOnly(); + + /** + * save config file if force is activated or non read only and some changes + * was detected in config file + * + * @param force when true, save will always be performed + * @return true if the save action was applied + */ + boolean saveConfig(boolean force); + + boolean saveConfig(); + + NWorkspaceBootConfig loadBootConfig(String path, boolean global, boolean followLinks); + + boolean isSupportedRepositoryType(String repositoryType); + + List getDefaultRepositories(); + + Set getAvailableArchetypes(); + + NPath resolveRepositoryPath(String repositoryLocation); + + NIndexStoreFactory getIndexStoreClientFactory(); + + String getJavaCommand(); + + String getJavaOptions(); + + boolean isSystemWorkspace(); + + + Map getConfigMap(); + + NOptional getConfigProperty(String property); + + /** + * @param property property + * @param value value + * @return {@code this} instance + */ + NWorkspace setConfigProperty(String property, String value); + + /// /////////////////////// + + /** + * return registered command factories + * + * @return registered command factories + */ + List getCommandFactories(); + + /** + * register a new commandFactory. If it already exists, a NutsIllegalArgumentException is thrown + * + * @param commandFactory commandFactory + */ + void addCommandFactory(NCommandFactoryConfig commandFactory); + + /** + * unregister an existing commandFactory. If it is not found, a NutsIllegalArgumentException is thrown + * + * @param commandFactoryId commandFactoryId + */ + void removeCommandFactory(String commandFactoryId); + + /** + * unregister an existing commandFactory if it exists. + * + * @param commandFactoryId commandFactoryId + * @return true if removed + */ + boolean removeCommandFactoryIfExists(String commandFactoryId); + + /** + * return true if the command is registered or provided by a registered command factory + * + * @param command command name + * @return true if the command is registered or provided by a registered command factory + */ + boolean commandExists(String command); + + /** + * return true if the command factory is registered + * + * @param command command name + * @return true if the command factory is registered + */ + boolean commandFactoryExists(String command); + + /** + * add command. if the command is already registered (regardless off being defined by command factories) a confirmation is required to update it. + * + * @param command command + * @return true if successfully added + */ + boolean addCommand(NCommandConfig command); + + /** + * update command. if the command does not exists (not registered, regardless off being defined by command factories) a NutsIllegalArgumentException is thrown. + * + * @param command command + * @return true if successfully updated + */ + boolean updateCommand(NCommandConfig command); + + /** + * remove command. if the command does not exists a NutsIllegalArgumentException is thrown. + * + * @param command command name + */ + void removeCommand(String command); + + /** + * return true if exists and is removed + * + * @param name name + * @return true if exists and is removed + */ + boolean removeCommandIfExists(String name); + + /** + * return the first command for a given name, id and owner. + * Search is first performed in the registered commands then in each registered command factory. + * + * @param name command name, not null + * @param forId if not null, the alias name should resolve to the given id + * @param forOwner if not null, the alias name should resolve to the owner + * @return alias definition or null + */ + NCustomCmd findCommand(String name, NId forId, NId forOwner); + + /** + * return the first command for a given name, id and owner. + * Search is first performed in the registered commands then in each registered command factory. + * + * @param name command name, not null + * @return alias definition or null + */ + NCustomCmd findCommand(String name); + + /** + * find all registered and factory defined commands + * + * @return find all registered and factory defined commands + */ + List findAllCommands(); + + /** + * find all registered and factory defined commands by owner + * + * @param id owner + * @return all registered and factory defined commands by owner + */ + List findCommandsByOwner(NId id); + + /// /////////////////////////////// + + /** + * return true when this is a first boot of the workspace (just installed!) + * + * @return true when this is a first boot of the workspace (just installed!) + */ + boolean isFirstBoot(); + + NOptional getCustomBootOption(String... names); + + NBootOptions getBootOptions(); + + ClassLoader getBootClassLoader(); + + List getBootClassWorldURLs(); + + String getBootRepositories(); + + Instant getCreationStartTime(); + + Instant getCreationFinishTime(); + + Duration getCreationDuration(); + + NClassLoaderNode getBootRuntimeClassLoaderNode(); + + List getBootExtensionClassLoaderNode(); + + NWorkspaceTerminalOptions getBootTerminal(); + } diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NWorkspaceBootConfig.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NWorkspaceBootConfig.java index 972e8f98a..a2a4ad055 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NWorkspaceBootConfig.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NWorkspaceBootConfig.java @@ -26,11 +26,6 @@ */ package net.thevpc.nuts; -import net.thevpc.nuts.env.NHomeLocation; -import net.thevpc.nuts.env.NOsFamily; -import net.thevpc.nuts.env.NStoreStrategy; -import net.thevpc.nuts.env.NStoreType; - import java.util.List; import java.util.Map; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NWorkspaceOptions.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NWorkspaceOptions.java index b4f590307..5e2f1c94c 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NWorkspaceOptions.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NWorkspaceOptions.java @@ -27,7 +27,6 @@ import net.thevpc.nuts.boot.NBootOptionsBoot; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.*; import net.thevpc.nuts.format.NContentType; import net.thevpc.nuts.io.NTerminalMode; import net.thevpc.nuts.log.NLogConfig; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NWorkspaceOptionsBuilder.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NWorkspaceOptionsBuilder.java index ddb3b06f3..a316e4f82 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NWorkspaceOptionsBuilder.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NWorkspaceOptionsBuilder.java @@ -25,7 +25,6 @@ */ package net.thevpc.nuts; -import net.thevpc.nuts.env.*; import net.thevpc.nuts.ext.NExtensions; import net.thevpc.nuts.format.NContentType; import net.thevpc.nuts.io.NTerminalMode; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NWorkspaceSecurityManager.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NWorkspaceSecurityManager.java index bce45082b..acaeddd7b 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NWorkspaceSecurityManager.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NWorkspaceSecurityManager.java @@ -26,7 +26,6 @@ */ package net.thevpc.nuts; -import net.thevpc.nuts.env.NUser; import net.thevpc.nuts.ext.NExtensions; import net.thevpc.nuts.security.NAuthenticationAgent; import net.thevpc.nuts.spi.NComponent; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/NWorkspaceStoredConfig.java b/core/nuts-api/src/main/java/net/thevpc/nuts/NWorkspaceStoredConfig.java index 380c2ae49..930d48285 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/NWorkspaceStoredConfig.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/NWorkspaceStoredConfig.java @@ -26,11 +26,6 @@ */ package net.thevpc.nuts; -import net.thevpc.nuts.env.NHomeLocation; -import net.thevpc.nuts.env.NOsFamily; -import net.thevpc.nuts.env.NStoreStrategy; -import net.thevpc.nuts.env.NStoreType; - import java.util.Map; /** diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/cmdline/NCmdLine.java b/core/nuts-api/src/main/java/net/thevpc/nuts/cmdline/NCmdLine.java index 50dabb3f7..9ce2dfc9d 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/cmdline/NCmdLine.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/cmdline/NCmdLine.java @@ -25,7 +25,7 @@ */ package net.thevpc.nuts.cmdline; -import net.thevpc.nuts.env.NShellFamily; +import net.thevpc.nuts.NShellFamily; import net.thevpc.nuts.text.NText; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.util.NLiteral; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/cmdline/NCmdLines.java b/core/nuts-api/src/main/java/net/thevpc/nuts/cmdline/NCmdLines.java index 21bcd9659..68ce6a253 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/cmdline/NCmdLines.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/cmdline/NCmdLines.java @@ -27,7 +27,7 @@ package net.thevpc.nuts.cmdline; import net.thevpc.nuts.ext.NExtensions; -import net.thevpc.nuts.env.NShellFamily; +import net.thevpc.nuts.NShellFamily; import net.thevpc.nuts.spi.NComponent; /** diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/cmdline/NWorkspaceCmdLineParser.java b/core/nuts-api/src/main/java/net/thevpc/nuts/cmdline/NWorkspaceCmdLineParser.java index 15864b0d5..72c37ba28 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/cmdline/NWorkspaceCmdLineParser.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/cmdline/NWorkspaceCmdLineParser.java @@ -25,7 +25,6 @@ package net.thevpc.nuts.cmdline; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.*; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.format.NContentType; import net.thevpc.nuts.io.NTerminalMode; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NBootManager.java b/core/nuts-api/src/main/java/net/thevpc/nuts/env/NBootManager.java deleted file mode 100644 index 4920f1083..000000000 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NBootManager.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * ==================================================================== - * Nuts : Network Updatable Things Service - * (universal package manager) - *

- * is a new Open Source Package Manager to help install packages - * and libraries for runtime execution. Nuts is the ultimate companion for - * maven (and other build managers) as it helps installing all package - * dependencies at runtime. Nuts is not tied to java and is a good choice - * to share shell scripts and other 'things' . Its based on an extensible - * architecture to help supporting a large range of sub managers / repositories. - *
- *

- * Copyright [2020] [thevpc] - * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 (the "License"); - * you may not use this file except in compliance with the License. You may obtain - * a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html - * 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 net.thevpc.nuts.env; - -import net.thevpc.nuts.NWorkspaceTerminalOptions; -import net.thevpc.nuts.boot.NBootClassLoaderNode; -import net.thevpc.nuts.ext.NExtensions; -import net.thevpc.nuts.spi.NComponent; -import net.thevpc.nuts.util.NLiteral; -import net.thevpc.nuts.util.NOptional; - -import java.net.URL; -import java.time.Duration; -import java.time.Instant; -import java.util.List; - -/** - * @author thevpc - */ -public interface NBootManager extends NComponent { - - static NBootManager of() { - return NExtensions.of(NBootManager.class); - } - - /** - * return true when this is a first boot of the workspace (just installed!) - * - * @return true when this is a first boot of the workspace (just installed!) - */ - boolean isFirstBoot(); - - NOptional getCustomBootOption(String... names); - - NBootOptions getBootOptions(); - - ClassLoader getBootClassLoader(); - - List getBootClassWorldURLs(); - - String getBootRepositories(); - - Instant getCreationStartTime(); - - Instant getCreationFinishTime(); - - Duration getCreationDuration(); - - NBootClassLoaderNode getBootRuntimeClassLoaderNode(); - - List getBootExtensionClassLoaderNode(); - - NWorkspaceTerminalOptions getBootTerminal(); -} diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NEnvs.java b/core/nuts-api/src/main/java/net/thevpc/nuts/env/NEnvs.java deleted file mode 100644 index 8a8340379..000000000 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/env/NEnvs.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * ==================================================================== - * Nuts : Network Updatable Things Service - * (universal package manager) - *
- * is a new Open Source Package Manager to help install packages and libraries - * for runtime execution. Nuts is the ultimate companion for maven (and other - * build managers) as it helps installing all package dependencies at runtime. - * Nuts is not tied to java and is a good choice to share shell scripts and - * other 'things' . Its based on an extensible architecture to help supporting a - * large range of sub managers / repositories. - * - *
- *

- * Copyright [2020] [thevpc] - * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 (the "License"); - * you may not use this file except in compliance with the License. You may obtain - * a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html - * 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 net.thevpc.nuts.env; - -import net.thevpc.nuts.NId; -import net.thevpc.nuts.NRunAs; -import net.thevpc.nuts.ext.NExtensions; -import net.thevpc.nuts.spi.NComponent; -import net.thevpc.nuts.util.*; - -import java.nio.file.Path; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Function; - -/** - * @author thevpc - * @app.category Base - */ -public interface NEnvs extends NComponent { - static NEnvs of() { - return NExtensions.of(NEnvs.class); - } - - /** - * @return properties - * @since 0.8.1 - */ - Map getProperties(); - - /** - * return property raw value - * - * @param property property name - * @return property raw value - * @since 0.8.1 - */ - NOptional getProperty(String property); - - /** - * @param property property - * @param value value - * @return {@code this} instance - * @since 0.8.1 - */ - NEnvs setProperty(String property, Object value); - - String getHostName(); - - String getPid(); - - NOsFamily getOsFamily(); - - Set getShellFamilies(); - - NShellFamily getShellFamily(); - - NId getDesktopEnvironment(); - - Set getDesktopEnvironments(); - - NDesktopEnvironmentFamily getDesktopEnvironmentFamily(); - - Set getDesktopEnvironmentFamilies(); - - NId getPlatform(); - - NId getOs(); - - NId getOsDist(); - - NId getArch(); - - NArchFamily getArchFamily(); - - - boolean isGraphicalDesktopEnvironment(); - - NSupportMode getDesktopIntegrationSupport(NDesktopIntegrationItem target); - - Path getDesktopPath(); - - void addLauncher(NLauncherOptions launcher); - - List buildEffectiveCommand(String[] cmd, - NRunAs runAsMode, - Set de, - Function sysWhich, - Boolean gui, - String rootName, - String userName, - String[] executorOptions - ); - -} diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/format/NCmdLineFormat.java b/core/nuts-api/src/main/java/net/thevpc/nuts/format/NCmdLineFormat.java index fe8f8adbf..7a0c4fd94 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/format/NCmdLineFormat.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/format/NCmdLineFormat.java @@ -29,7 +29,7 @@ import net.thevpc.nuts.cmdline.NCmdLineConfigurable; import net.thevpc.nuts.cmdline.NCmdLineFormatStrategy; import net.thevpc.nuts.ext.NExtensions; -import net.thevpc.nuts.env.NShellFamily; +import net.thevpc.nuts.NShellFamily; /** * Simple Command line Format diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/io/NContentTypes.java b/core/nuts-api/src/main/java/net/thevpc/nuts/io/NContentTypes.java deleted file mode 100644 index 54b56e1c6..000000000 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/io/NContentTypes.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * ==================================================================== - * Nuts : Network Updatable Things Service - * (universal package manager) - *
- * is a new Open Source Package Manager to help install packages - * and libraries for runtime execution. Nuts is the ultimate companion for - * maven (and other build managers) as it helps installing all package - * dependencies at runtime. Nuts is not tied to java and is a good choice - * to share shell scripts and other 'things' . Its based on an extensible - * architecture to help supporting a large range of sub managers / repositories. - * - *
- *

- * Copyright [2020] [thevpc] - * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 (the "License"); - * you may not use this file except in compliance with the License. You may obtain - * a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html - * 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 net.thevpc.nuts.io; - -import net.thevpc.nuts.ext.NExtensions; -import net.thevpc.nuts.spi.NComponent; - -import java.io.File; -import java.io.InputStream; -import java.net.URL; -import java.nio.file.Path; -import java.util.List; - -/** - * Probing content types (or mime types) from paths and contents. - * Probing is highly dependent on the underlying system and user configuration - * - * @author thevpc - * @since 0.8.3 - */ -public interface NContentTypes extends NComponent { - static NContentTypes of() { - return NExtensions.of(NContentTypes.class); - } - - String probeContentType(URL path); - - String probeContentType(File path); - - String probeContentType(Path path); - - String probeContentType(NPath path); - - String probeContentType(InputStream stream); - - String probeContentType(byte[] stream); - - //////// - String probeCharset(URL path); - - String probeCharset(File path); - - String probeCharset(Path path); - - String probeCharset(NPath path); - - String probeCharset(InputStream stream); - - String probeCharset(byte[] stream); - - List findExtensionsByContentType(String contentType); - List findContentTypesByExtension(String extension); -} diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/io/NIO.java b/core/nuts-api/src/main/java/net/thevpc/nuts/io/NIO.java index c714a62aa..111a3f35e 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/io/NIO.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/io/NIO.java @@ -26,12 +26,19 @@ */ package net.thevpc.nuts.io; +import net.thevpc.nuts.NRepository; import net.thevpc.nuts.ext.NExtensions; import net.thevpc.nuts.spi.NComponent; +import net.thevpc.nuts.spi.NPathFactorySPI; +import net.thevpc.nuts.spi.NPathSPI; import net.thevpc.nuts.spi.NSystemTerminalBase; +import java.io.File; import java.io.InputStream; import java.io.OutputStream; +import java.net.URL; +import java.nio.file.Path; +import java.util.List; public interface NIO extends NComponent { static NIO of() { @@ -115,5 +122,114 @@ static OutputStream ofNullRawOutputStream(){ */ NIO setDefaultTerminal(NTerminal terminal); + /** + * expand path to Workspace Location + * + * @param path path to expand + * @return expanded path + */ + NPath createPath(String path); + + NPath createPath(File path); + + NPath createPath(Path path); + + NPath createPath(URL path); + + NPath createPath(String path, ClassLoader classLoader); + + NPath createPath(NPathSPI path); + + NIO addPathFactory(NPathFactorySPI pathFactory); + + NIO removePathFactory(NPathFactorySPI pathFactory); + + /** + * create temp file in the repositoryId's temp folder + * + * @param name file name + * @return newly created file path + */ + NPath ofTempFile(String name); + + /** + * create temp file in the repositoryId's temp folder + * + * @return newly created file path + */ + NPath ofTempFile(); + + /** + * create temp folder in the workspace's temp folder + * + * @param name folder name + * @return newly created temp folder + */ + NPath ofTempFolder(String name); + + /** + * create temp folder in the workspace's temp folder + * + * @return newly created temp folder + */ + NPath ofTempFolder(); + + /** + * create temp file in the repositoryId's temp folder + * + * @param name file name + * @return newly created file path + */ + NPath ofTempRepositoryFile(String name, NRepository repository); + + /** + * create temp file in the repositoryId's temp folder + * + * @return newly created file path + */ + NPath ofTempRepositoryFile(NRepository repository); + + /** + * create temp folder in the repository's temp folder + * + * @param name folder name + * @return newly created temp folder + */ + NPath ofTempRepositoryFolder(String name, NRepository repository); + + /** + * create temp folder in the repository's temp folder + * + * @return newly created temp folder + */ + NPath ofTempRepositoryFolder(NRepository repository); + + + String probeContentType(URL path); + + String probeContentType(File path); + + String probeContentType(Path path); + + String probeContentType(NPath path); + + String probeContentType(InputStream stream); + + String probeContentType(byte[] stream); + + //////// + String probeCharset(URL path); + + String probeCharset(File path); + + String probeCharset(Path path); + + String probeCharset(NPath path); + + String probeCharset(InputStream stream); + + String probeCharset(byte[] stream); + List findExtensionsByContentType(String contentType); + List findContentTypesByExtension(String extension); } diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/io/NPath.java b/core/nuts-api/src/main/java/net/thevpc/nuts/io/NPath.java index 544bd3215..3bdfa1c81 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/io/NPath.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/io/NPath.java @@ -53,27 +53,27 @@ public interface NPath extends NInputSource, NOutputTarget, NWorkspaceProvider { static NPath of(URL path) { - return NPaths.of().createPath(path); + return NIO.of().createPath(path); } static NPath of(String path, ClassLoader classLoader) { - return NPaths.of().createPath(path, classLoader); + return NIO.of().createPath(path, classLoader); } static NPath of(File path) { - return NPaths.of().createPath(path); + return NIO.of().createPath(path); } static NPath of(Path path) { - return NPaths.of().createPath(path); + return NIO.of().createPath(path); } static NPath of(String path) { - return NPaths.of().createPath(path); + return NIO.of().createPath(path); } static NPath of(NPathSPI path) { - return NPaths.of().createPath(path); + return NIO.of().createPath(path); } /** @@ -101,7 +101,7 @@ static NPath ofUserDirectory() { * @return newly created file path */ static NPath ofTempFile(String name) { - return NPaths.of().ofTempFile(name); + return NIO.of().ofTempFile(name); } /** @@ -110,7 +110,7 @@ static NPath ofTempFile(String name) { * @return newly created file path */ static NPath ofTempFile() { - return NPaths.of().ofTempFile(); + return NIO.of().ofTempFile(); } /** @@ -120,7 +120,7 @@ static NPath ofTempFile() { * @return newly created temp folder */ static NPath ofTempFolder(String name) { - return NPaths.of().ofTempFolder(name); + return NIO.of().ofTempFolder(name); } /** @@ -129,7 +129,7 @@ static NPath ofTempFolder(String name) { * @return newly created temp folder */ static NPath ofTempFolder() { - return NPaths.of().ofTempFolder(); + return NIO.of().ofTempFolder(); } /** @@ -139,7 +139,7 @@ static NPath ofTempFolder() { * @return newly created file path */ static NPath ofTempRepositoryFile(String name, NRepository repository) { - return NPaths.of().ofTempRepositoryFile(name, repository); + return NIO.of().ofTempRepositoryFile(name, repository); } /** @@ -148,7 +148,7 @@ static NPath ofTempRepositoryFile(String name, NRepository repository) { * @return newly created file path */ static NPath ofTempRepositoryFile(NRepository repository) { - return NPaths.of().ofTempRepositoryFile(repository); + return NIO.of().ofTempRepositoryFile(repository); } /** @@ -158,7 +158,7 @@ static NPath ofTempRepositoryFile(NRepository repository) { * @return newly created temp folder */ static NPath ofTempRepositoryFolder(String name, NRepository repository) { - return NPaths.of().ofTempRepositoryFolder(name, repository); + return NIO.of().ofTempRepositoryFolder(name, repository); } /** @@ -167,7 +167,7 @@ static NPath ofTempRepositoryFolder(String name, NRepository repository) { * @return newly created temp folder */ static NPath ofTempRepositoryFolder(NRepository repository) { - return NPaths.of().ofTempRepositoryFolder(repository); + return NIO.of().ofTempRepositoryFolder(repository); } /** diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/io/NPaths.java b/core/nuts-api/src/main/java/net/thevpc/nuts/io/NPaths.java deleted file mode 100644 index c40610384..000000000 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/io/NPaths.java +++ /dev/null @@ -1,99 +0,0 @@ -package net.thevpc.nuts.io; - -import net.thevpc.nuts.NRepository; -import net.thevpc.nuts.ext.NExtensions; -import net.thevpc.nuts.spi.NComponent; -import net.thevpc.nuts.spi.NPathFactorySPI; -import net.thevpc.nuts.spi.NPathSPI; - -import java.io.File; -import java.net.URL; -import java.nio.file.Path; - -public interface NPaths extends NComponent { - static NPaths of() { - return NExtensions.of(NPaths.class); - } - - /** - * expand path to Workspace Location - * - * @param path path to expand - * @return expanded path - */ - NPath createPath(String path); - - NPath createPath(File path); - - NPath createPath(Path path); - - NPath createPath(URL path); - - NPath createPath(String path, ClassLoader classLoader); - - NPath createPath(NPathSPI path); - - NPaths addPathFactory(NPathFactorySPI pathFactory); - - NPaths removePathFactory(NPathFactorySPI pathFactory); - - /** - * create temp file in the repositoryId's temp folder - * - * @param name file name - * @return newly created file path - */ - NPath ofTempFile(String name); - - /** - * create temp file in the repositoryId's temp folder - * - * @return newly created file path - */ - NPath ofTempFile(); - - /** - * create temp folder in the workspace's temp folder - * - * @param name folder name - * @return newly created temp folder - */ - NPath ofTempFolder(String name); - - /** - * create temp folder in the workspace's temp folder - * - * @return newly created temp folder - */ - NPath ofTempFolder(); - - /** - * create temp file in the repositoryId's temp folder - * - * @param name file name - * @return newly created file path - */ - NPath ofTempRepositoryFile(String name, NRepository repository); - - /** - * create temp file in the repositoryId's temp folder - * - * @return newly created file path - */ - NPath ofTempRepositoryFile(NRepository repository); - - /** - * create temp folder in the repository's temp folder - * - * @param name folder name - * @return newly created temp folder - */ - NPath ofTempRepositoryFolder(String name, NRepository repository); - - /** - * create temp folder in the repository's temp folder - * - * @return newly created temp folder - */ - NPath ofTempRepositoryFolder(NRepository repository); -} diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/io/NPlainOutputNull.java b/core/nuts-api/src/main/java/net/thevpc/nuts/io/NPlainOutputNull.java deleted file mode 100644 index ce4fdd2a1..000000000 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/io/NPlainOutputNull.java +++ /dev/null @@ -1,97 +0,0 @@ -//package net.thevpc.nuts.io; -// -//import net.thevpc.nuts.format.NFormat; -//import net.thevpc.nuts.NSession; -// -//import java.io.ByteArrayOutputStream; -//import java.io.IOException; -//import java.io.OutputStream; -// -//public class NPlainOutputNull implements NOutputStream { -// private DefaultNContentMetadata md = new DefaultNContentMetadata(); -// -// @Override -// public OutputStream getOutputStream() { -// return new OutputStream() { -// @Override -// public void write(int b) throws IOException { -// // -// } -// }; -// } -// -// @Override -// public NTerminalMode getTerminalMode() { -// return NTerminalMode.INHERITED; -// } -// -// @Override -// public boolean isAutoFlash() { -// return false; -// } -// -// @Override -// public NOutputStream setTerminalMode(NTerminalMode other) { -// return null; -// } -// -// @Override -// public OutputStream asOutputStream(NSession session) { -// return getOutputStream(); -// } -// -// @Override -// public NContentMetadata getMetaData() { -// return md; -// } -// -// @Override -// public NOutputStream flush(NSession session) { -// return this; -// } -// -// @Override -// public NOutputStream close(NSession session) { -// return this; -// } -// -// @Override -// public NOutputStream write(byte[] b, NSession session) { -// return this; -// } -// -// @Override -// public NOutputStream write(int b, NSession session) { -// return this; -// } -// -// @Override -// public boolean isNtf() { -// return false; -// } -// -// public String toString() { -// return "NPlainOutputNull"; -// } -// -// @Override -// public NOutputStream write(byte[] buf, int off, int len, NSession session) { -// return this; -// } -// -// @Override -// public NOutputStream write(char[] buf, int off, int len, NSession session) { -// return this; -// } -// -// -// @Override -// public NOutputStream writeRaw(byte[] buf, int off, int len, NSession session) { -// return this; -// } -// -// @Override -// public NFormat formatter(NSession session) { -// return NFormat.of(session, new NContentMetadataProviderFormatSPI(this, null, "print-stream")); -// } -//} diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/io/NPlainOutputStream.java b/core/nuts-api/src/main/java/net/thevpc/nuts/io/NPlainOutputStream.java deleted file mode 100644 index 1074c0609..000000000 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/io/NPlainOutputStream.java +++ /dev/null @@ -1,122 +0,0 @@ -//package net.thevpc.nuts.io; -// -//import net.thevpc.nuts.format.NFormat; -//import net.thevpc.nuts.util.NMsg; -//import net.thevpc.nuts.NSession; -//import net.thevpc.nuts.text.NText; -//import net.thevpc.nuts.spi.NSystemTerminalBase; -//import net.thevpc.nuts.text.NTerminalCommand; -//import net.thevpc.nuts.text.NTextStyle; -//import net.thevpc.nuts.text.NTextStyles; -// -//import java.io.*; -//import java.time.temporal.Temporal; -//import java.util.Date; -// -//public class NPlainOutputStream implements NOutputStream { -// private ByteArrayOutputStream sb = new ByteArrayOutputStream(); -// private DefaultNContentMetadata md = new DefaultNContentMetadata(); -// -// @Override -// public OutputStream getOutputStream() { -// return new OutputStream() { -// @Override -// public void write(int b) throws IOException { -// sb.write(b); -// } -// }; -// } -// -// @Override -// public NTerminalMode getTerminalMode() { -// return NTerminalMode.INHERITED; -// } -// -// @Override -// public boolean isAutoFlash() { -// return false; -// } -// -// @Override -// public NOutputStream setTerminalMode(NTerminalMode other) { -// return null; -// } -// -// @Override -// public OutputStream asOutputStream(NSession session) { -// return new OutputStream() { -// @Override -// public void write(int b) throws IOException { -// sb.write(b); -// } -// }; -// } -// -// @Override -// public NContentMetadata getMetaData() { -// return md; -// } -// -// @Override -// public NOutputStream flush(NSession session) { -// return this; -// } -// -// @Override -// public NOutputStream close(NSession session) { -// return this; -// } -// -// @Override -// public NOutputStream write(byte[] b, NSession session) { -// try { -// sb.write(b); -// } catch (IOException e) { -// throw new NIOException(session, e); -// } -// return this; -// } -// -// @Override -// public NOutputStream write(int b, NSession session) { -// sb.write(b); -// return this; -// } -// -// @Override -// public boolean isNtf() { -// return false; -// } -// -// public String toString() { -// return sb.toString(); -// } -// -// @Override -// public NOutputStream write(byte[] buf, int off, int len, NSession session) { -// sb.write(buf, off, len); -// return this; -// } -// -// @Override -// public NOutputStream write(char[] buf, int off, int len, NSession session) { -// try { -// sb.write(new String(buf, off, len).getBytes()); -// } catch (IOException e) { -// throw new NIOException(session, e); -// } -// return this; -// } -// -// -// @Override -// public NOutputStream writeRaw(byte[] buf, int off, int len, NSession session) { -// sb.write(buf, off, len); -// return this; -// } -// -// @Override -// public NFormat formatter(NSession session) { -// return NFormat.of(session, new NContentMetadataProviderFormatSPI(this, null, "print-stream")); -// } -//} diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/log/NLog.java b/core/nuts-api/src/main/java/net/thevpc/nuts/log/NLog.java index 833d9415c..d7637b356 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/log/NLog.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/log/NLog.java @@ -189,6 +189,26 @@ static void setFileLevel(Level level) { */ void log(Level level, NLogVerb verb, NMsg msg, Throwable thrown); + default void log(Level level, NLogVerb verb, NMsg msg){ + log(level,verb,msg,null); + } + + default void warn(NMsg msg, Throwable thrown){ + log(Level.WARNING, NLogVerb.WARNING, msg, thrown); + } + + default void warn(NMsg msg){ + log(Level.WARNING, NLogVerb.WARNING, msg,null); + } + + default void error(NMsg msg, Throwable thrown){ + log(Level.SEVERE, NLogVerb.FAIL, msg, thrown); + } + + default void error(NMsg msg){ + log(Level.SEVERE, NLogVerb.FAIL, msg,null); + } + /** * log message using the given verb and level * diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/reserved/NApiUtilsRPI.java b/core/nuts-api/src/main/java/net/thevpc/nuts/reserved/NApiUtilsRPI.java index 1aa754eb1..0e5ef280e 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/reserved/NApiUtilsRPI.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/reserved/NApiUtilsRPI.java @@ -26,7 +26,7 @@ package net.thevpc.nuts.reserved; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NBootManager; + import net.thevpc.nuts.text.NText; import net.thevpc.nuts.text.NTextBuilder; import net.thevpc.nuts.util.NBlankable; @@ -149,7 +149,7 @@ public static int processThrowable(Throwable ex, NLog out) { NSession session = NSessionAwareExceptionBase.resolveSession(ex).orNull(); NWorkspaceOptionsBuilder bo = null; if (session != null) { - bo = NBootManager.of().getBootOptions().builder().toWorkspaceOptions().builder(); + bo = NWorkspace.get().getBootOptions().builder().toWorkspaceOptions().builder(); } else { NWorkspaceOptionsBuilder options = NWorkspaceOptionsBuilder.of(); //load inherited diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/reserved/NReservedUtils.java b/core/nuts-api/src/main/java/net/thevpc/nuts/reserved/NReservedUtils.java index 6c63a02b7..7bafb0d18 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/reserved/NReservedUtils.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/reserved/NReservedUtils.java @@ -26,7 +26,6 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.*; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.log.NLog; import net.thevpc.nuts.log.NLogVerb; @@ -276,7 +275,7 @@ public static NOptional parseId(String nutsId) { Map.Entry e = iterator.next(); String key = e.getKey(); String value = e.getValue(); - switch (key) { + switch (NStringUtils.trim(key)) { case NConstants.IdProperties.CLASSIFIER: { classifier = value; break; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/reserved/NReservedWorkspaceOptionsToCmdLineBuilder.java b/core/nuts-api/src/main/java/net/thevpc/nuts/reserved/NReservedWorkspaceOptionsToCmdLineBuilder.java index c9dc30555..93ecf4edf 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/reserved/NReservedWorkspaceOptionsToCmdLineBuilder.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/reserved/NReservedWorkspaceOptionsToCmdLineBuilder.java @@ -1,7 +1,6 @@ package net.thevpc.nuts.reserved; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.*; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.cmdline.NCmdLine; import net.thevpc.nuts.io.NTerminalMode; diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/spi/NIndexStoreFactory.java b/core/nuts-api/src/main/java/net/thevpc/nuts/spi/NIndexStoreFactory.java index c033b83a7..0b5cd251d 100644 --- a/core/nuts-api/src/main/java/net/thevpc/nuts/spi/NIndexStoreFactory.java +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/spi/NIndexStoreFactory.java @@ -25,7 +25,7 @@ */ package net.thevpc.nuts.spi; -import net.thevpc.nuts.env.NIndexStore; +import net.thevpc.nuts.NIndexStore; import net.thevpc.nuts.NRepository; /** diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/util/BytePredicate.java b/core/nuts-api/src/main/java/net/thevpc/nuts/util/BytePredicate.java new file mode 100644 index 000000000..65f7696a3 --- /dev/null +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/util/BytePredicate.java @@ -0,0 +1,5 @@ +package net.thevpc.nuts.util; + +public interface BytePredicate { + boolean test(byte c); +} diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/util/CharPredicate.java b/core/nuts-api/src/main/java/net/thevpc/nuts/util/CharPredicate.java new file mode 100644 index 000000000..d549123fd --- /dev/null +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/util/CharPredicate.java @@ -0,0 +1,5 @@ +package net.thevpc.nuts.util; + +public interface CharPredicate { + boolean test(char c); +} diff --git a/core/nuts-api/src/main/java/net/thevpc/nuts/util/FloatPredicate.java b/core/nuts-api/src/main/java/net/thevpc/nuts/util/FloatPredicate.java new file mode 100644 index 000000000..84c7dec00 --- /dev/null +++ b/core/nuts-api/src/main/java/net/thevpc/nuts/util/FloatPredicate.java @@ -0,0 +1,5 @@ +package net.thevpc.nuts.util; + +public interface FloatPredicate { + boolean test(float c); +} diff --git a/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/NBootOptionsBoot.java b/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/NBootOptionsBoot.java index 5c3c2e544..eea703e49 100644 --- a/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/NBootOptionsBoot.java +++ b/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/NBootOptionsBoot.java @@ -11,14 +11,14 @@ * large range of sub managers / repositories. *
*

- * Copyright [2020] [thevpc] - * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 (the "License"); + * Copyright [2020] [thevpc] + * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 (the "License"); * you may not use this file except in compliance with the License. You may obtain * a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html - * 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 + * 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. *
==================================================================== */ @@ -92,12 +92,6 @@ public final class NBootOptionsBoot { * special */ private NBootDescriptor runtimeBootDescriptor; - /** - * user options - */ - private NBootOptionsBoot userOptions; - - /// ///////////////////////////////// /// @@ -458,77 +452,74 @@ public final class NBootOptionsBoot { private String userLauncher; - - public String getDesktopLauncher() { return desktopLauncher; } - + public String getMenuLauncher() { return menuLauncher; } - + public String getUserLauncher() { return userLauncher; } - + public NBootOptionsBoot setInitLaunchers(Boolean initLaunchers) { this.initLaunchers = initLaunchers; return this; } - + public NBootOptionsBoot setInitScripts(Boolean initScripts) { this.initScripts = initScripts; return this; } - + public NBootOptionsBoot setInitPlatforms(Boolean initPlatforms) { this.initPlatforms = initPlatforms; return this; } - + public NBootOptionsBoot setInitJava(Boolean initJava) { this.initJava = initJava; return this; } - + public NBootOptionsBoot setIsolationLevel(String isolationLevel) { this.isolationLevel = isolationLevel; return this; } - + public NBootOptionsBoot setDesktopLauncher(String desktopLauncher) { this.desktopLauncher = desktopLauncher; return this; } - + public NBootOptionsBoot setMenuLauncher(String menuLauncher) { this.menuLauncher = menuLauncher; return this; } - + public NBootOptionsBoot setUserLauncher(String userLauncher) { this.userLauncher = userLauncher; return this; } - + public NBootOptionsBoot copy() { return new NBootOptionsBoot().setAll(this); } - public String getApiVersion() { return apiVersion; } @@ -539,13 +530,13 @@ public String getApiVersion() { * @param apiVersion new value * @return {@code this} instance */ - + public NBootOptionsBoot setApiVersion(String apiVersion) { this.apiVersion = apiVersion; return this; } - + public List getApplicationArguments() { return applicationArguments; } @@ -556,13 +547,13 @@ public List getApplicationArguments() { * @param applicationArguments new value * @return {@code this} instance */ - + public NBootOptionsBoot setApplicationArguments(List applicationArguments) { this.applicationArguments = applicationArguments; return this; } - + public String getArchetype() { return archetype; } @@ -573,13 +564,13 @@ public String getArchetype() { * @param archetype new value * @return {@code this} instance */ - + public NBootOptionsBoot setArchetype(String archetype) { this.archetype = archetype; return this; } - + public Supplier getClassLoaderSupplier() { return classLoaderSupplier; } @@ -590,13 +581,13 @@ public Supplier getClassLoaderSupplier() { * @param provider new value * @return {@code this} instance */ - + public NBootOptionsBoot setClassLoaderSupplier(Supplier provider) { this.classLoaderSupplier = provider; return this; } - + public String getConfirm() { return confirm; } @@ -607,18 +598,18 @@ public String getConfirm() { * @param confirm new value * @return {@code this} instance */ - + public NBootOptionsBoot setConfirm(String confirm) { this.confirm = confirm; return this; } - + public Boolean getDry() { return dry; } - + public Boolean getShowStacktrace() { return showStacktrace; } @@ -629,7 +620,7 @@ public Boolean getShowStacktrace() { * @param dry new value * @return {@code this} instance */ - + public NBootOptionsBoot setDry(Boolean dry) { this.dry = dry; return this; @@ -642,13 +633,13 @@ public NBootOptionsBoot setDry(Boolean dry) { * @return {@code this} instance * @since 0.8.4 */ - + public NBootOptionsBoot setShowStacktrace(Boolean showStacktrace) { this.showStacktrace = showStacktrace; return this; } - + public Instant getCreationTime() { return creationTime; } @@ -659,13 +650,13 @@ public Instant getCreationTime() { * @param creationTime new value * @return {@code this} instance */ - + public NBootOptionsBoot setCreationTime(Instant creationTime) { this.creationTime = creationTime; return this; } - + public List getExcludedExtensions() { return excludedExtensions; } @@ -676,13 +667,13 @@ public List getExcludedExtensions() { * @param excludedExtensions new value * @return {@code this} instance */ - + public NBootOptionsBoot setExcludedExtensions(List excludedExtensions) { this.excludedExtensions = excludedExtensions; return this; } - + public String getExecutionType() { return executionType; } @@ -693,13 +684,13 @@ public String getExecutionType() { * @param executionType new value * @return {@code this} instance */ - + public NBootOptionsBoot setExecutionType(String executionType) { this.executionType = executionType; return this; } - + public String getRunAs() { return runAs; } @@ -715,7 +706,7 @@ public NBootOptionsBoot setRunAs(String runAs) { return this; } - + public List getExecutorOptions() { return executorOptions; } @@ -726,23 +717,23 @@ public List getExecutorOptions() { * @param executorOptions new value * @return {@code this} instance */ - + public NBootOptionsBoot setExecutorOptions(List executorOptions) { this.executorOptions = executorOptions; return this; } - + public String getHomeLocation(NBootHomeLocation location) { - return homeLocations==null?null:homeLocations.get(location); + return homeLocations == null ? null : homeLocations.get(location); } - + public Map getHomeLocations() { return homeLocations; } - + public NBootOptionsBoot setHomeLocations(Map homeLocations) { if (homeLocations != null) { if (this.homeLocations == null) { @@ -755,18 +746,18 @@ public NBootOptionsBoot setHomeLocations(Map homeLoca return this; } - + public String getJavaCommand() { return javaCommand; } - + public NBootOptionsBoot setJavaCommand(String javaCommand) { this.javaCommand = javaCommand; return this; } - + public String getJavaOptions() { return javaOptions; } @@ -777,13 +768,13 @@ public String getJavaOptions() { * @param javaOptions new value * @return {@code this} instance */ - + public NBootOptionsBoot setJavaOptions(String javaOptions) { this.javaOptions = javaOptions; return this; } - + public NBootLogConfig getLogConfig() { return logConfig; } @@ -794,13 +785,13 @@ public NBootLogConfig getLogConfig() { * @param logConfig new value * @return {@code this} instance */ - + public NBootOptionsBoot setLogConfig(NBootLogConfig logConfig) { this.logConfig = logConfig == null ? null : logConfig.copy(); return this; } - + public String getName() { return name; } @@ -811,13 +802,13 @@ public String getName() { * @param workspaceName new value * @return {@code this} instance */ - + public NBootOptionsBoot setName(String workspaceName) { this.name = workspaceName; return this; } - + public String getOpenMode() { return openMode; } @@ -828,13 +819,13 @@ public String getOpenMode() { * @param openMode new value * @return {@code this} instance */ - + public NBootOptionsBoot setOpenMode(String openMode) { this.openMode = openMode; return this; } - + public String getOutputFormat() { return outputFormat; } @@ -845,13 +836,13 @@ public String getOutputFormat() { * @param outputFormat new value * @return {@code this} instance */ - + public NBootOptionsBoot setOutputFormat(String outputFormat) { this.outputFormat = outputFormat; return this; } - + public List getOutputFormatOptions() { return outputFormatOptions; } @@ -862,7 +853,7 @@ public List getOutputFormatOptions() { * @param options new value * @return {@code this} instance */ - + public NBootOptionsBoot setOutputFormatOptions(List options) { if (options != null) { if (outputFormatOptions == null) { @@ -884,7 +875,7 @@ public NBootOptionsBoot setOutputFormatOptions(String... options) { return addOutputFormatOptions(options); } - + public char[] getCredentials() { return credentials; } @@ -895,13 +886,13 @@ public char[] getCredentials() { * @param credentials new value * @return {@code this} instance */ - + public NBootOptionsBoot setCredentials(char[] credentials) { this.credentials = credentials; return this; } - + public String getRepositoryStoreStrategy() { return repositoryStoreStrategy; } @@ -912,13 +903,13 @@ public String getRepositoryStoreStrategy() { * @param repositoryStoreStrategy new value * @return {@code this} instance */ - + public NBootOptionsBoot setRepositoryStoreStrategy(String repositoryStoreStrategy) { this.repositoryStoreStrategy = repositoryStoreStrategy; return this; } - + public String getRuntimeId() { return runtimeId; } @@ -929,18 +920,18 @@ public String getRuntimeId() { * @param runtimeId new value * @return {@code this} instance */ - + public NBootOptionsBoot setRuntimeId(String runtimeId) { this.runtimeId = runtimeId; return this; } - + public String getStoreType(String folder) { - return storeLocations==null?null:storeLocations.get(folder); + return storeLocations == null ? null : storeLocations.get(folder); } - + public String getStoreLayout() { return storeLayout; } @@ -951,13 +942,13 @@ public String getStoreLayout() { * @param storeLayout new value * @return {@code this} instance */ - + public NBootOptionsBoot setStoreLayout(String storeLayout) { this.storeLayout = storeLayout; return this; } - + public String getStoreStrategy() { return storeStrategy; } @@ -968,18 +959,18 @@ public String getStoreStrategy() { * @param storeStrategy new value * @return {@code this} instance */ - + public NBootOptionsBoot setStoreStrategy(String storeStrategy) { this.storeStrategy = storeStrategy; return this; } - + public Map getStoreLocations() { return storeLocations; } - + public NBootOptionsBoot setStoreLocations(Map storeLocations) { if (storeLocations != null) { if (this.storeLocations == null) { @@ -993,7 +984,7 @@ public NBootOptionsBoot setStoreLocations(Map storeLocations) { return this; } - + public String getTerminalMode() { return terminalMode; } @@ -1004,13 +995,13 @@ public String getTerminalMode() { * @param terminalMode new value * @return {@code this} instance */ - + public NBootOptionsBoot setTerminalMode(String terminalMode) { this.terminalMode = terminalMode; return this; } - + public List getRepositories() { return repositories; } @@ -1021,18 +1012,18 @@ public List getRepositories() { * @param repositories new value * @return {@code this} instance */ - + public NBootOptionsBoot setRepositories(List repositories) { this.repositories = repositories; return this; } - + public String getUserName() { return userName; } - + public String getWorkspace() { return workspace; } @@ -1043,13 +1034,13 @@ public String getWorkspace() { * @param workspace workspace * @return {@code this} instance */ - + public NBootOptionsBoot setWorkspace(String workspace) { this.workspace = workspace; return this; } - + public String getDebug() { return debug; } @@ -1060,13 +1051,13 @@ public String getDebug() { * @param debug new value * @return {@code this} instance */ - + public NBootOptionsBoot setDebug(String debug) { this.debug = debug; return this; } - + public Boolean getSystem() { return system; } @@ -1077,13 +1068,13 @@ public Boolean getSystem() { * @param system new value * @return {@code this} instance */ - + public NBootOptionsBoot setSystem(Boolean system) { this.system = system; return this; } - + public Boolean getGui() { return gui; } @@ -1094,13 +1085,13 @@ public Boolean getGui() { * @param gui new value * @return {@code this} instance */ - + public NBootOptionsBoot setGui(Boolean gui) { this.gui = gui; return this; } - + public Boolean getInherited() { return inherited; } @@ -1111,13 +1102,13 @@ public Boolean getInherited() { * @param inherited new value * @return {@code this} instance */ - + public NBootOptionsBoot setInherited(Boolean inherited) { this.inherited = inherited; return this; } - + public Boolean getReadOnly() { return readOnly; } @@ -1128,13 +1119,13 @@ public Boolean getReadOnly() { * @param readOnly new value * @return {@code this} instance */ - + public NBootOptionsBoot setReadOnly(Boolean readOnly) { this.readOnly = readOnly; return this; } - + public Boolean getRecover() { return recover; } @@ -1145,13 +1136,13 @@ public Boolean getRecover() { * @param recover new value * @return {@code this} instance */ - + public NBootOptionsBoot setRecover(Boolean recover) { this.recover = recover; return this; } - + public Boolean getReset() { return reset; } @@ -1162,35 +1153,35 @@ public Boolean getReset() { * @param reset new value * @return {@code this} instance */ - + public NBootOptionsBoot setReset(Boolean reset) { this.reset = reset; return this; } - + public Boolean getCommandVersion() { return commandVersion; } - + public NBootOptionsBoot setCommandVersion(Boolean version) { this.commandVersion = version; return this; } - + public Boolean getCommandHelp() { return commandHelp; } - + public NBootOptionsBoot setCommandHelp(Boolean help) { this.commandHelp = help; return this; } - + public Boolean getInstallCompanions() { return installCompanions; } @@ -1201,13 +1192,13 @@ public Boolean getInstallCompanions() { * @param skipInstallCompanions new value * @return {@code this} instance */ - + public NBootOptionsBoot setInstallCompanions(Boolean skipInstallCompanions) { this.installCompanions = skipInstallCompanions; return this; } - + public Boolean getSkipWelcome() { return skipWelcome; } @@ -1218,35 +1209,35 @@ public Boolean getSkipWelcome() { * @param skipWelcome new value * @return {@code this} instance */ - + public NBootOptionsBoot setSkipWelcome(Boolean skipWelcome) { this.skipWelcome = skipWelcome; return this; } - + public String getOutLinePrefix() { return outLinePrefix; } - + public NBootOptionsBoot setOutLinePrefix(String outLinePrefix) { this.outLinePrefix = outLinePrefix; return this; } - + public String getErrLinePrefix() { return errLinePrefix; } - + public NBootOptionsBoot setErrLinePrefix(String errLinePrefix) { this.errLinePrefix = errLinePrefix; return this; } - + public Boolean getSkipBoot() { return skipBoot; } @@ -1257,13 +1248,13 @@ public Boolean getSkipBoot() { * @param skipBoot new value * @return {@code this} instance */ - + public NBootOptionsBoot setSkipBoot(Boolean skipBoot) { this.skipBoot = skipBoot; return this; } - + public Boolean getTrace() { return trace; } @@ -1274,7 +1265,7 @@ public Boolean getTrace() { * @param trace new value * @return {@code this} instance */ - + public NBootOptionsBoot setTrace(Boolean trace) { this.trace = trace; return this; @@ -1284,145 +1275,145 @@ public String getProgressOptions() { return progressOptions; } - + public NBootOptionsBoot setProgressOptions(String progressOptions) { this.progressOptions = progressOptions; return this; } - + public Boolean getCached() { return cached; } - + public NBootOptionsBoot setCached(Boolean cached) { this.cached = cached; return this; } - + public Boolean getIndexed() { return indexed; } - + public NBootOptionsBoot setIndexed(Boolean indexed) { this.indexed = indexed; return this; } - + public Boolean getTransitive() { return transitive; } - + public NBootOptionsBoot setTransitive(Boolean transitive) { this.transitive = transitive; return this; } - + public Boolean getBot() { return bot; } - + public NBootOptionsBoot setBot(Boolean bot) { this.bot = bot; return this; } - + public Boolean getPreviewRepo() { return previewRepo; } - + public NBootOptionsBoot setPreviewRepo(Boolean bot) { this.previewRepo = bot; return this; } - + public String getFetchStrategy() { return fetchStrategy; } - + public NBootOptionsBoot setFetchStrategy(String fetchStrategy) { this.fetchStrategy = fetchStrategy; return this; } - + public InputStream getStdin() { return stdin; } - + public NBootOptionsBoot setStdin(InputStream stdin) { this.stdin = stdin; return this; } - + public PrintStream getStdout() { return stdout; } - + public NBootOptionsBoot setStdout(PrintStream stdout) { this.stdout = stdout; return this; } - + public PrintStream getStderr() { return stderr; } - + public NBootOptionsBoot setStderr(PrintStream stderr) { this.stderr = stderr; return this; } - + public ExecutorService getExecutorService() { return executorService; } - + public NBootOptionsBoot setExecutorService(ExecutorService executorService) { this.executorService = executorService; return this; } - + public Instant getExpireTime() { return expireTime; } - + public NBootOptionsBoot setExpireTime(Instant expireTime) { this.expireTime = expireTime; return this; } - + public Boolean getSkipErrors() { return skipErrors; } - + public NBootOptionsBoot setSkipErrors(Boolean value) { this.skipErrors = value; return this; } - + public Boolean getSwitchWorkspace() { return switchWorkspace; } @@ -1432,51 +1423,51 @@ public NBootOptionsBoot setSwitchWorkspace(Boolean switchWorkspace) { return this; } - + public List getErrors() { return errors; } - + public NBootOptionsBoot setErrors(List errors) { this.errors = errors; return this; } - + public List getCustomOptions() { return customOptions; } - + public NBootOptionsBoot setCustomOptions(List properties) { this.customOptions = properties; return this; } - + public String getLocale() { return locale; } - + public NBootOptionsBoot setLocale(String locale) { this.locale = locale; return this; } - + public String getTheme() { return theme; } - + public NBootOptionsBoot setTheme(String theme) { this.theme = theme; return this; } - + public NBootOptionsBoot setAll(NBootOptionsBoot other) { this.setApiVersion(other.getApiVersion()); this.setRuntimeId(other.getRuntimeId()); @@ -1564,264 +1555,263 @@ public NBootOptionsBoot setAll(NBootOptionsBoot other) { this.setUuid(other.getUuid()); this.setExtensionsSet(other.getExtensionsSet()); this.setRuntimeBootDescriptor(other.getRuntimeBootDescriptor()); - this.setUserOptions(other.getUserOptions()); return this; } - + public NBootOptionsBoot setAllPresent(NBootOptionsBoot o) { if (o != null) { - if (o.getApiVersion()!=null) { + if (o.getApiVersion() != null) { this.setApiVersion(o.getApiVersion()); } - if (o.getRuntimeId()!=null) { + if (o.getRuntimeId() != null) { this.setRuntimeId(o.getRuntimeId()); } - if (o.getJavaCommand()!=null) { + if (o.getJavaCommand() != null) { this.setJavaCommand(o.getJavaCommand()); } - if (o.getJavaOptions()!=null) { + if (o.getJavaOptions() != null) { this.setJavaOptions(o.getJavaOptions()); } - if (o.getWorkspace()!=null) { + if (o.getWorkspace() != null) { this.setWorkspace(o.getWorkspace()); } - if (o.getName()!=null) { + if (o.getName() != null) { this.setName(o.getName()); } - if (o.getInstallCompanions()!=null) { + if (o.getInstallCompanions() != null) { this.setInstallCompanions(o.getInstallCompanions()); } - if (o.getSkipWelcome()!=null) { + if (o.getSkipWelcome() != null) { this.setSkipWelcome(o.getSkipWelcome()); } - if (o.getSkipBoot()!=null) { + if (o.getSkipBoot() != null) { this.setSkipBoot(o.getSkipBoot()); } - if (o.getSystem()!=null) { + if (o.getSystem() != null) { this.setSystem(o.getSystem()); } - if (o.getGui()!=null) { + if (o.getGui() != null) { this.setGui(o.getGui()); } - if (o.getUserName()!=null) { + if (o.getUserName() != null) { this.setUserName(o.getUserName()); } - if (o.getCredentials()!=null) { + if (o.getCredentials() != null) { this.setCredentials(o.getCredentials()); } - if (o.getTerminalMode()!=null) { + if (o.getTerminalMode() != null) { this.setTerminalMode(o.getTerminalMode()); } - if (o.getReadOnly()!=null) { + if (o.getReadOnly() != null) { this.setReadOnly(o.getReadOnly()); } - if (o.getTrace()!=null) { + if (o.getTrace() != null) { this.setTrace(o.getTrace()); } - if (o.getProgressOptions()!=null) { + if (o.getProgressOptions() != null) { this.setProgressOptions(o.getProgressOptions()); } - if (o.getLogConfig()!=null) { + if (o.getLogConfig() != null) { this.setLogConfig(o.getLogConfig()); } - if (o.getConfirm()!=null) { + if (o.getConfirm() != null) { this.setConfirm(o.getConfirm()); } - if (o.getConfirm()!=null) { + if (o.getConfirm() != null) { this.setConfirm(o.getConfirm()); } - if (o.getOutputFormat()!=null) { + if (o.getOutputFormat() != null) { this.setOutputFormat(o.getOutputFormat()); } - if (o.getOutputFormatOptions()!=null) { + if (o.getOutputFormatOptions() != null) { this.setOutputFormatOptions(o.getOutputFormatOptions()); } - if (o.getOpenMode()!=null) { + if (o.getOpenMode() != null) { this.setOpenMode(o.getOpenMode()); } - if (o.getCreationTime()!=null) { + if (o.getCreationTime() != null) { this.setCreationTime(o.getCreationTime()); } - if (o.getDry()!=null) { + if (o.getDry() != null) { this.setDry(o.getDry()); } - if (o.getShowStacktrace()!=null) { + if (o.getShowStacktrace() != null) { this.setShowStacktrace(o.getShowStacktrace()); } - if (o.getClassLoaderSupplier()!=null) { + if (o.getClassLoaderSupplier() != null) { this.setClassLoaderSupplier(o.getClassLoaderSupplier()); } - if (o.getExecutorOptions()!=null) { + if (o.getExecutorOptions() != null) { this.setExecutorOptions(o.getExecutorOptions()); } - if (o.getRecover()!=null) { + if (o.getRecover() != null) { this.setRecover(o.getRecover()); } - if (o.getReset()!=null) { + if (o.getReset() != null) { this.setReset(o.getReset()); } - if (o.getCommandVersion()!=null) { + if (o.getCommandVersion() != null) { this.setCommandVersion(o.getCommandVersion()); } - if (o.getCommandHelp()!=null) { + if (o.getCommandHelp() != null) { this.setCommandHelp(o.getCommandHelp()); } - if (o.getDebug()!=null) { + if (o.getDebug() != null) { this.setDebug(o.getDebug()); } - if (o.getInherited()!=null) { + if (o.getInherited() != null) { this.setInherited(o.getInherited()); } - if (o.getExecutionType()!=null) { + if (o.getExecutionType() != null) { this.setExecutionType(o.getExecutionType()); } - if (o.getRunAs()!=null) { + if (o.getRunAs() != null) { this.setRunAs(o.getRunAs()); } - if (o.getArchetype()!=null) { + if (o.getArchetype() != null) { this.setArchetype(o.getArchetype()); } - if (o.getStoreStrategy()!=null) { + if (o.getStoreStrategy() != null) { this.setStoreStrategy(o.getStoreStrategy()); } - if (o.getHomeLocations()!=null) { + if (o.getHomeLocations() != null) { this.setHomeLocations(o.getHomeLocations()); } - if (o.getStoreLocations()!=null) { + if (o.getStoreLocations() != null) { this.setStoreLocations(o.getStoreLocations()); } - if (o.getStoreLayout()!=null) { + if (o.getStoreLayout() != null) { this.setStoreLayout(o.getStoreLayout()); } - if (o.getStoreStrategy()!=null) { + if (o.getStoreStrategy() != null) { this.setStoreStrategy(o.getStoreStrategy()); } - if (o.getRepositoryStoreStrategy()!=null) { + if (o.getRepositoryStoreStrategy() != null) { this.setRepositoryStoreStrategy(o.getRepositoryStoreStrategy()); } - if (o.getFetchStrategy()!=null) { + if (o.getFetchStrategy() != null) { this.setFetchStrategy(o.getFetchStrategy()); } - if (o.getCached()!=null) { + if (o.getCached() != null) { this.setCached(o.getCached()); } - if (o.getIndexed()!=null) { + if (o.getIndexed() != null) { this.setIndexed(o.getIndexed()); } - if (o.getTransitive()!=null) { + if (o.getTransitive() != null) { this.setTransitive(o.getTransitive()); } - if (o.getBot()!=null) { + if (o.getBot() != null) { this.setBot(o.getBot()); } - if (o.getStdin()!=null) { + if (o.getStdin() != null) { this.setStdin(o.getStdin()); } - if (o.getStdout()!=null) { + if (o.getStdout() != null) { this.setStdout(o.getStdout()); } - if (o.getStderr()!=null) { + if (o.getStderr() != null) { this.setStderr(o.getStderr()); } - if (o.getExecutorService()!=null) { + if (o.getExecutorService() != null) { this.setExecutorService(o.getExecutorService()); } - if (o.getExcludedExtensions()!=null) { + if (o.getExcludedExtensions() != null) { this.setExcludedExtensions(o.getExcludedExtensions()); } - if (o.getRepositories()!=null) { + if (o.getRepositories() != null) { this.setRepositories(o.getRepositories()); } - if (o.getApplicationArguments()!=null) { + if (o.getApplicationArguments() != null) { this.setApplicationArguments(o.getApplicationArguments()); } - if (o.getCustomOptions()!=null) { + if (o.getCustomOptions() != null) { this.setCustomOptions(o.getCustomOptions()); } - if (o.getExpireTime()!=null) { + if (o.getExpireTime() != null) { this.setExpireTime(o.getExpireTime()); } - if (o.getErrors()!=null) { + if (o.getErrors() != null) { this.setErrors(o.getErrors()); } - if (o.getSkipErrors()!=null) { + if (o.getSkipErrors() != null) { this.setSkipErrors(o.getSkipErrors()); } - if (o.getSwitchWorkspace()!=null) { + if (o.getSwitchWorkspace() != null) { this.setSwitchWorkspace(o.getSwitchWorkspace()); } - if (o.getLocale()!=null) { + if (o.getLocale() != null) { this.setLocale(o.getLocale()); } - if (o.getTheme()!=null) { + if (o.getTheme() != null) { this.setTheme(o.getTheme()); } - if (o.getDependencySolver()!=null) { + if (o.getDependencySolver() != null) { this.setDependencySolver(o.getDependencySolver()); } - if (o.getIsolationLevel()!=null) { + if (o.getIsolationLevel() != null) { this.setIsolationLevel(o.getIsolationLevel()); } - if (o.getInitLaunchers()!=null) { + if (o.getInitLaunchers() != null) { this.setInitLaunchers(o.getInitLaunchers()); } - if (o.getInitJava()!=null) { + if (o.getInitJava() != null) { this.setInitJava(o.getInitJava()); } - if (o.getInitScripts()!=null) { + if (o.getInitScripts() != null) { this.setInitScripts(o.getInitScripts()); } - if (o.getInitLaunchers()!=null) { + if (o.getInitLaunchers() != null) { this.setInitLaunchers(o.getInitLaunchers()); } - if (o.getDesktopLauncher()!=null) { + if (o.getDesktopLauncher() != null) { this.setDesktopLauncher(o.getDesktopLauncher()); } - if (o.getMenuLauncher()!=null) { + if (o.getMenuLauncher() != null) { this.setMenuLauncher(o.getMenuLauncher()); } - if (o.getUserLauncher()!=null) { + if (o.getUserLauncher() != null) { this.setUserLauncher(o.getUserLauncher()); } - if (o.getPreviewRepo()!=null) { + if (o.getPreviewRepo() != null) { this.setPreviewRepo(o.getPreviewRepo()); } - if (o.getSharedInstance()!=null) { + if (o.getSharedInstance() != null) { this.setSharedInstance(o.getSharedInstance()); } - if (o.getUserOptions()!=null) { - setUserOptions(o.getUserOptions()); + if(o.getBootRepositories()!=null) { + setBootRepositories(o.getBootRepositories()); } - setBootRepositories(o.getBootRepositories()); - if (o.getUserOptions()!=null) { + if (o.getRuntimeBootDependencyNode() != null) { setRuntimeBootDependencyNode(o.getRuntimeBootDependencyNode()); } - if (o.getUserOptions()!=null) { + if (o.getExtensionBootDescriptors() != null) { setExtensionBootDescriptors(o.getExtensionBootDescriptors()); } - if (o.getUserOptions()!=null) { + if (o.getExtensionBootDependencyNodes() != null) { setExtensionBootDependencyNodes(o.getExtensionBootDependencyNodes()); } - if (o.getUserOptions()!=null) { + if (o.getBootWorkspaceFactory() != null) { setBootWorkspaceFactory(o.getBootWorkspaceFactory()); } - if (o.getUserOptions()!=null) { + if (o.getClassWorldURLs() != null) { setClassWorldURLs(o.getClassWorldURLs()); } - if (o.getUserOptions()!=null) { + if (o.getClassWorldLoader() != null) { setClassWorldLoader(o.getClassWorldLoader()); } - if (o.getUserOptions()!=null) { + if (o.getUuid() != null) { setUuid(o.getUuid()); } - if (o.getUserOptions()!=null) { + if (o.getExtensionsSet() != null) { setExtensionsSet(o.getExtensionsSet()); } - if (o.getUserOptions()!=null) { + if (o.getRuntimeBootDescriptor() != null) { setRuntimeBootDescriptor(o.getRuntimeBootDescriptor()); - } } + } + } return this; } @@ -1831,7 +1821,7 @@ public NBootOptionsBoot setAllPresent(NBootOptionsBoot o) { // return this; // } -// public NBootOptionsBuilderBoot setCmdLine(String[] args) { + // public NBootOptionsBuilderBoot setCmdLine(String[] args) { // NWorkspaceCmdLineParser.parseNutsArguments(args, this); // return this; // } @@ -1839,7 +1829,7 @@ public Boolean getSharedInstance() { return sharedInstance; } - + public NBootOptionsBoot setSharedInstance(Boolean sharedInstance) { this.sharedInstance = sharedInstance; return this; @@ -1851,7 +1841,7 @@ public NBootOptionsBoot setSharedInstance(Boolean sharedInstance) { * @param username new value * @return {@code this} instance */ - + public NBootOptionsBoot setUserName(String username) { this.userName = username; return this; @@ -1864,7 +1854,7 @@ public NBootOptionsBoot setUserName(String username) { * @param value new value * @return {@code this} instance */ - + public NBootOptionsBoot setStoreLocation(String location, String value) { if (NBootStringUtils.isBlank(value)) { if (storeLocations != null) { @@ -1886,7 +1876,7 @@ public NBootOptionsBoot setStoreLocation(String location, String value) { * @param value new value * @return {@code this} instance */ - + public NBootOptionsBoot setHomeLocation(NBootHomeLocation location, String value) { if (NBootStringUtils.isBlank(value)) { if (homeLocations != null) { @@ -1907,7 +1897,7 @@ public NBootOptionsBoot setHomeLocation(NBootHomeLocation location, String value * @param options new value * @return {@code this} instance */ - + public NBootOptionsBoot addOutputFormatOptions(String... options) { if (options != null) { for (String option : options) { @@ -1926,50 +1916,47 @@ public NBootOptionsBoot addOutputFormatOptions(String... options) { } - public String getDependencySolver() { return dependencySolver; } - + public NBootOptionsBoot setDependencySolver(String dependencySolver) { this.dependencySolver = dependencySolver; return this; } - + // public String toString() { // return toCmdLine().toString(); // } - - public String getIsolationLevel() { return isolationLevel; } - + public Boolean getInitLaunchers() { return initLaunchers; } - + public Boolean getInitScripts() { return initScripts; } - + public Boolean getInitPlatforms() { return initPlatforms; } - + public Boolean getInitJava() { return initJava; } - + public NBootOptionsBoot unsetRuntimeOptions() { setCommandHelp(null); setCommandVersion(null); @@ -1985,7 +1972,7 @@ public NBootOptionsBoot unsetRuntimeOptions() { return this; } - + public NBootOptionsBoot unsetCreationOptions() { setName(null); setArchetype(null); @@ -1998,7 +1985,7 @@ public NBootOptionsBoot unsetCreationOptions() { return this; } - + public NBootOptionsBoot unsetExportedOptions() { setJavaCommand(null); setJavaOptions(null); @@ -2047,24 +2034,11 @@ public NBootOptionsBoot unsetExportedOptions() { /// /// ///////////////////////////////// - - public NBootOptionsBoot getUserOptions() { - return userOptions; - } - - - public NBootOptionsBoot setUserOptions(NBootOptionsBoot userOptions) { - this.userOptions = userOptions; - return this; - } - - - public String getBootRepositories() { return bootRepositories; } - + public NBootOptionsBoot setBootRepositories(String bootRepositories) { this.bootRepositories = NBootStringUtils.trimToNull(bootRepositories); return this; @@ -2074,7 +2048,7 @@ public NBootClassLoaderNode getRuntimeBootDependencyNode() { return runtimeBootDependencyNode; } - + public NBootOptionsBoot setRuntimeBootDependencyNode(NBootClassLoaderNode runtimeBootDependencyNode) { this.runtimeBootDependencyNode = runtimeBootDependencyNode; return this; @@ -2084,7 +2058,7 @@ public List getExtensionBootDescriptors() { return extensionBootDescriptors; } - + public NBootOptionsBoot setExtensionBootDescriptors(List extensionBootDescriptors) { this.extensionBootDescriptors = NBootUtils.nonNullList(extensionBootDescriptors); return this; @@ -2094,7 +2068,7 @@ public List getExtensionBootDependencyNodes() { return extensionBootDependencyNodes; } - + public NBootOptionsBoot setExtensionBootDependencyNodes(List extensionBootDependencyNodes) { this.extensionBootDependencyNodes = NBootUtils.nonNullList(extensionBootDependencyNodes); return this; @@ -2104,7 +2078,7 @@ public NBootWorkspaceFactory getBootWorkspaceFactory() { return bootWorkspaceFactory; } - + public NBootOptionsBoot setBootWorkspaceFactory(NBootWorkspaceFactory bootWorkspaceFactory) { this.bootWorkspaceFactory = bootWorkspaceFactory; return this; @@ -2114,7 +2088,7 @@ public List getClassWorldURLs() { return classWorldURLs; } - + public NBootOptionsBoot setClassWorldURLs(List classWorldURLs) { this.classWorldURLs = NBootUtils.nonNullList(classWorldURLs); return this; @@ -2124,7 +2098,7 @@ public ClassLoader getClassWorldLoader() { return classWorldLoader; } - + public NBootOptionsBoot setClassWorldLoader(ClassLoader classWorldLoader) { this.classWorldLoader = classWorldLoader; return this; @@ -2134,7 +2108,7 @@ public String getUuid() { return uuid; } - + public NBootOptionsBoot setUuid(String uuid) { this.uuid = NBootStringUtils.trimToNull(uuid); return this; @@ -2144,7 +2118,7 @@ public Set getExtensionsSet() { return extensionsSet; } - + public NBootOptionsBoot setExtensionsSet(Set extensionsSet) { this.extensionsSet = NBootUtils.nonNullSet(extensionsSet); return this; @@ -2154,7 +2128,7 @@ public NBootDescriptor getRuntimeBootDescriptor() { return runtimeBootDescriptor; } - + public NBootOptionsBoot setRuntimeBootDescriptor(NBootDescriptor runtimeBootDescriptor) { this.runtimeBootDescriptor = runtimeBootDescriptor; return this; diff --git a/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/NBootRepositoryRef.java b/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/NBootRepositoryRef.java deleted file mode 100644 index 288bcf25a..000000000 --- a/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/NBootRepositoryRef.java +++ /dev/null @@ -1,164 +0,0 @@ -/** - * ==================================================================== - * Nuts : Network Updatable Things Service - * (universal package manager) - *
- * is a new Open Source Package Manager to help install packages - * and libraries for runtime execution. Nuts is the ultimate companion for - * maven (and other build managers) as it helps installing all package - * dependencies at runtime. Nuts is not tied to java and is a good choice - * to share shell scripts and other 'things' . Its based on an extensible - * architecture to help supporting a large range of sub managers / repositories. - * - *
- *

- * Copyright [2020] [thevpc] - * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 (the "License"); - * you may not use this file except in compliance with the License. You may obtain - * a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html - * 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 net.thevpc.nuts.boot; - -import java.util.Objects; - -/** - * @author thevpc - * @app.category Base - * @since 0.5.4 - */ -public class NBootRepositoryRef implements Cloneable { - - private static final long serialVersionUID = 2; - - private String name; - private String location; - private boolean enabled = true; - private boolean failSafe = false; - private int deployWeight; - - public NBootRepositoryRef() { - } - - public NBootRepositoryRef(NBootRepositoryRef other) { - this.name = other.getName(); - this.location = other.getLocation(); - this.enabled = other.isEnabled(); - this.failSafe = other.isEnabled(); - this.deployWeight = other.getDeployWeight(); - } - - public NBootRepositoryRef(String name, String location, int deployPriority, boolean enabled) { - this.name = name; - this.location = location; - this.deployWeight = deployPriority; - this.enabled = enabled; - } - - public boolean isEnabled() { - return enabled; - } - - public NBootRepositoryRef setEnabled(boolean enabled) { - this.enabled = enabled; - return this; - } - - public String getLocation() { - return location; - } - - public NBootRepositoryRef setLocation(String location) { - this.location = location; - return this; - } - - public String getName() { - return name; - } - - public NBootRepositoryRef setName(String name) { - this.name = name; - return this; - } - - public boolean isFailSafe() { - return failSafe; - } - - public NBootRepositoryRef setFailSafe(boolean failSafe) { - this.failSafe = failSafe; - return this; - } - - public NBootRepositoryRef copy() { - return clone(); - } - - @Override - protected NBootRepositoryRef clone() { - try { - return (NBootRepositoryRef) super.clone(); - } catch (CloneNotSupportedException e) { - throw new RuntimeException(e); - } - } - - public int getDeployWeight() { - return deployWeight; - } - - public NBootRepositoryRef setDeployWeight(int deployPriority) { - this.deployWeight = deployPriority; - return this; - } - - @Override - public int hashCode() { - int hash = 3; - hash = 79 * hash + Objects.hashCode(this.name); - hash = 79 * hash + Objects.hashCode(this.location); - hash = 79 * hash + this.deployWeight; - hash = 79 * hash + (this.enabled ? 1 : 0); - hash = 79 * hash + (this.failSafe ? 1 : 0); - return hash; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final NBootRepositoryRef other = (NBootRepositoryRef) obj; - if (this.enabled != other.enabled) { - return false; - } - if (this.failSafe != other.failSafe) { - return false; - } - if (this.deployWeight != other.deployWeight) { - return false; - } - if (!Objects.equals(this.name, other.name)) { - return false; - } - return Objects.equals(this.location, other.location); - } - - @Override - public String toString() { - return "NutsRepositoryRef{" + "name=" + name + ", location=" + location + ", enabled=" + enabled + ", failSafe=" + failSafe + ", deployPriority=" + deployWeight + '}'; - } -} diff --git a/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/NBootWorkspace.java b/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/NBootWorkspace.java index 8ec75f1a3..09d1fe8e2 100644 --- a/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/NBootWorkspace.java +++ b/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/NBootWorkspace.java @@ -74,16 +74,15 @@ public static String getVersion() { } private final Instant creationTime = Instant.now(); - private final NBootOptionsBoot userOptions; + private NBootOptionsBoot options; private final NBootLog bLog; - private final NBootOptionsBoot computedOptions = new NBootOptionsBoot(); private final NBootRepositoryDB repositoryDB = new NBootRepositoryDB(); private final Function pathExpansionConverter = new Function() { @Override public String apply(String from) { switch (from) { case "workspace": - return computedOptions.getWorkspace(); + return options.getWorkspace(); case "user.home": return System.getProperty("user.home"); case "home.apps": @@ -94,7 +93,7 @@ public String apply(String from) { case "home.cache": case "home.run": case "home.log": - return NBootUtils.getHome(from.substring("home.".length()).toUpperCase(), computedOptions); + return NBootUtils.getHome(from.substring("home.".length()).toUpperCase(), options); case "apps": case "config": case "lib": @@ -103,7 +102,7 @@ public String apply(String from) { case "temp": case "log": case "var": { - Map s = NBootUtils.firstNonNull(computedOptions.getStoreLocations(), Collections.emptyMap()); + Map s = NBootUtils.firstNonNull(options.getStoreLocations(), Collections.emptyMap()); String v = s.get(from); if (v == null) { return "${" + from + "}"; @@ -146,24 +145,25 @@ public NBootWorkspace(NBootArguments userOptionsUnparsed) { } } errorMessage.append("Try 'nuts --help' for more information."); - bLog.log(Level.WARNING, "WARNING", NBootMsg.ofC("Error : %s", errorMessage)); + bLog.warn(NBootMsg.ofC("Skipped Error : %s", errorMessage)); } - this.userOptions = userOptions.copy(); + this.options = userOptions.copy(); this.postInit(); } - public NBootWorkspace(NBootOptionsBoot userOptions) { - if (userOptions == null) { - userOptions = new NBootOptionsBoot(); + public NBootWorkspace(NBootOptionsBoot options) { + if (options == null) { + options = new NBootOptionsBoot(); } - this.bLog = new NBootLog(userOptions); - this.userOptions = userOptions; + this.bLog = new NBootLog(options); + this.options = options; this.postInit(); } private void postInit() { - this.computedOptions.setAll(userOptions); - this.computedOptions.setUserOptions(this.userOptions); + if(options==null){ + options=new NBootOptionsBoot(); + } // this.computedOptions.setIsolationLevel(this.computedOptions.getIsolationLevel().orElse(NIsolationLevel.SYSTEM)); // this.computedOptions.setExecutionType(this.computedOptions.getExecutionType().orElse(NExecutionType.SPAWN)); // this.computedOptions.setConfirm(this.computedOptions.getConfirm().orElse(NConfirmationMode.ASK)); @@ -176,11 +176,13 @@ private void postInit() { // this.computedOptions.setStderr(this.computedOptions.getStderr().orElse(System.err)); // this.computedOptions.setLocale(this.computedOptions.getLocale().orElse(Locale.getDefault().toString())); // this.computedOptions.setOutputFormat(this.computedOptions.getOutputFormat().orElse(NContentType.PLAIN)); -// this.computedOptions.setCreationTime(this.computedOptions.getCreationTime().orElse(creationTime)); - if (this.computedOptions.getApplicationArguments().isEmpty()) { - this.computedOptions.setApplicationArguments(new ArrayList<>()); +// if (this.computedOptions.getApplicationArguments().isEmpty()) { +// this.computedOptions.setApplicationArguments(new ArrayList<>()); +// } + if(this.options.getCreationTime()==null) { + this.options.setCreationTime(creationTime); } - this.bLog.setOptions(this.computedOptions); + this.bLog.setOptions(this.options); } private static void revalidateLocations(NBootOptionsBoot bootOptions, String workspaceName, boolean immediateLocation, String sandboxMode) { @@ -281,11 +283,11 @@ public Set resolveBootRuntimeRepositories(boolean depen return parsedBootRuntimeRepositories; } bLog.log(Level.FINE, "START", NBootMsg.ofC("resolve boot repositories to load nuts-runtime from options : %s and config: %s", - computedOptions.getRepositories() == null ? "[]" : computedOptions.getRepositories().toString(), - computedOptions.getBootRepositories() == null ? "[]" : computedOptions.getBootRepositories().toString())); + options.getRepositories() == null ? "[]" : options.getRepositories().toString(), + options.getBootRepositories() == null ? "[]" : options.getBootRepositories().toString())); // } - NBootRepositorySelectorList bootRepositoriesSelector = NBootRepositorySelectorList.of(computedOptions.getRepositories(), repositoryDB); - NBootRepositorySelector[] old = NBootRepositorySelectorList.of(Arrays.asList(computedOptions.getBootRepositories()), repositoryDB).toArray(); + NBootRepositorySelectorList bootRepositoriesSelector = NBootRepositorySelectorList.of(options.getRepositories(), repositoryDB); + NBootRepositorySelector[] old = NBootRepositorySelectorList.of(Arrays.asList(options.getBootRepositories()), repositoryDB).toArray(); NBootRepositoryLocation[] result; if (old.length == 0) { //no previous config, use defaults! @@ -352,29 +354,29 @@ public Set resolveBootRuntimeRepositories(boolean depen public String[] createProcessCmdLine() { prepareWorkspace(); - bLog.log(Level.FINE, "START", NBootMsg.ofC("running version %s. %s", computedOptions.getApiVersion(), getRequirementsHelpString(true))); - String defaultWorkspaceLibFolder = computedOptions.getStoreType("LIB") + "/" + NBootConstants.Folders.ID; + bLog.log(Level.FINE, "START", NBootMsg.ofC("running version %s. %s", options.getApiVersion(), getRequirementsHelpString(true))); + String defaultWorkspaceLibFolder = options.getStoreType("LIB") + "/" + NBootConstants.Folders.ID; List repos = new ArrayList<>(); repos.add(NBootRepositoryLocation.of("nuts@" + defaultWorkspaceLibFolder)); Collection bootRepositories = resolveBootRuntimeRepositories(true); repos.addAll(bootRepositories); NBootErrorInfoList errorList = new NBootErrorInfoList(); - File file = NReservedMavenUtilsBoot.resolveOrDownloadJar(NBootId.ofApi(computedOptions.getApiVersion()), repos.toArray(new NBootRepositoryLocation[0]), - NBootRepositoryLocation.of("nuts@" + computedOptions.getStoreType("LIB") + File.separator + NBootConstants.Folders.ID), bLog, false, computedOptions.getExpireTime(), errorList); + File file = NReservedMavenUtilsBoot.resolveOrDownloadJar(NBootId.ofApi(options.getApiVersion()), repos.toArray(new NBootRepositoryLocation[0]), + NBootRepositoryLocation.of("nuts@" + options.getStoreType("LIB") + File.separator + NBootConstants.Folders.ID), bLog, false, options.getExpireTime(), errorList); if (file == null) { - errorList.insert(0, new NReservedErrorInfo(null, null, null, "unable to load nuts " + computedOptions.getApiVersion(), null)); + errorList.insert(0, new NReservedErrorInfo(null, null, null, "unable to load nuts " + options.getApiVersion(), null)); logError(null, errorList); - throw new NBootException(NBootMsg.ofC("unable to load %s#%s", NBootConstants.Ids.NUTS_API, computedOptions.getApiVersion())); + throw new NBootException(NBootMsg.ofC("unable to load %s#%s", NBootConstants.Ids.NUTS_API, options.getApiVersion())); } List cmd = new ArrayList<>(); - String jc = computedOptions.getJavaCommand(); + String jc = options.getJavaCommand(); if (jc == null || jc.trim().isEmpty()) { jc = NBootUtils.resolveJavaCommand(null); } cmd.add(jc); boolean showCommand = false; - for (String c : NBootCmdLine.parseDefaultList(computedOptions.getJavaOptions())) { + for (String c : NBootCmdLine.parseDefaultList(options.getJavaOptions())) { if (!c.isEmpty()) { if (c.equals("--show-command")) { showCommand = true; @@ -383,12 +385,12 @@ public String[] createProcessCmdLine() { } } } - if (computedOptions.getJavaOptions() == null) { - Collections.addAll(cmd, NBootCmdLine.parseDefaultList(computedOptions.getJavaOptions())); + if (options.getJavaOptions() == null) { + Collections.addAll(cmd, NBootCmdLine.parseDefaultList(options.getJavaOptions())); } cmd.add("-jar"); cmd.add(file.getPath()); - cmd.addAll(asCmdLine(computedOptions, new NBootWorkspaceOptionsConfig().setCompact(true).setApiVersion(computedOptions.getApiVersion())).toStringList()); + cmd.addAll(asCmdLine(options, new NBootWorkspaceOptionsConfig().setCompact(true).setApiVersion(options.getApiVersion())).toStringList()); if (showCommand) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < cmd.size(); i++) { @@ -416,7 +418,7 @@ private NBootCmdLine asCmdLine(NBootOptionsBoot cc, NBootWorkspaceOptionsConfig } public NBootOptionsBoot getOptions() { - return computedOptions; + return options; } @@ -429,7 +431,7 @@ private NBootIdCache getFallbackCache(NBootId baseId, boolean lastWorkspace, boo NBootIdCache fid = new NBootIdCache(); fid.baseId = baseId; cache.fallbackIdMap.put(fid.baseId, fid); - String s = (lastWorkspace ? lastWorkspaceOptions : computedOptions).getStoreLocations().get("LIB") + "/id/" + String s = (lastWorkspace ? lastWorkspaceOptions : options).getStoreLocations().get("LIB") + "/id/" + NBootUtils.resolveIdPath(baseId.getShortId()); // Path ss = Paths.get(s); @@ -467,7 +469,7 @@ private NBootIdCache getFallbackCache(NBootId baseId, boolean lastWorkspace, boo Set dependencies = NReservedMavenUtilsBoot.loadDependenciesFromNutsUrl(descNutsPath.toString(), bLog); if (dependencies != null) { fid.deps = dependencies.stream() - .filter(x -> NBootUtils.isAcceptDependency(x.toDependency(), computedOptions)) + .filter(x -> NBootUtils.isAcceptDependency(x.toDependency(), options)) .collect(Collectors.toSet()); fid.depsData = fid.deps.stream() .map(x -> { @@ -524,7 +526,7 @@ private boolean prepareWorkspace() { if (!preparedWorkspace) { preparedWorkspace = true; - String isolationLevel = NBootStringUtils.firstNonBlank(computedOptions.getIsolationLevel(), "SYSTEM"); + String isolationLevel = NBootStringUtils.firstNonBlank(options.getIsolationLevel(), "SYSTEM"); if (bLog.isLoggable(Level.CONFIG)) { bLog.log(Level.CONFIG, "START", NBootMsg.ofC("bootstrap Nuts version %s %s digest %s...", getVersion(), NBootUtils.sameEnum(isolationLevel, "SYSTEM") ? "" : @@ -566,9 +568,9 @@ private boolean prepareWorkspace() { NBootOptionsBoot lastConfigLoaded = null; String lastNutsWorkspaceJsonConfigPath = null; boolean immediateLocation = false; - boolean resetFlag = NBootUtils.firstNonNull(computedOptions.getReset(), false); - boolean dryFlag = NBootUtils.firstNonNull(computedOptions.getDry(), false); - String _ws = computedOptions.getWorkspace(); + boolean resetFlag = NBootUtils.firstNonNull(options.getReset(), false); + boolean dryFlag = NBootUtils.firstNonNull(options.getDry(), false); + String _ws = options.getWorkspace(); if (NBootUtils.sameEnum(isolationLevel, "SANDBOX")) { Path t = null; try { @@ -580,22 +582,22 @@ private boolean prepareWorkspace() { immediateLocation = true; workspaceName = t.getFileName().toString(); resetFlag = false; //no need for reset - if (NBootUtils.firstNonNull(computedOptions.getSystem(), false)) { + if (NBootUtils.firstNonNull(options.getSystem(), false)) { throw new NBootException(NBootMsg.ofPlain("you cannot specify option '--global' in sandbox mode")); } - if (!NBootStringUtils.isBlank(computedOptions.getWorkspace())) { + if (!NBootStringUtils.isBlank(options.getWorkspace())) { throw new NBootException(NBootMsg.ofPlain("you cannot specify '--workspace' in sandbox mode")); } - if (!NBootUtils.sameEnum(computedOptions.getStoreStrategy(), "STANDALONE")) { + if (!NBootUtils.sameEnum(options.getStoreStrategy(), "STANDALONE")) { throw new NBootException(NBootMsg.ofPlain("you cannot specify '--exploded' in sandbox mode")); } - if (NBootUtils.firstNonNull(computedOptions.getSystem(), false)) { + if (NBootUtils.firstNonNull(options.getSystem(), false)) { throw new NBootException(NBootMsg.ofPlain("you cannot specify '--global' in sandbox mode")); } - computedOptions.setWorkspace(lastNutsWorkspaceJsonConfigPath); + options.setWorkspace(lastNutsWorkspaceJsonConfigPath); } else { - if (!NBootUtils.sameEnum(isolationLevel, "SYSTEM") && NBootUtils.firstNonNull(userOptions.getSystem(), false)) { - if (NBootUtils.firstNonNull(userOptions.getReset(), false)) { + if (!NBootUtils.sameEnum(isolationLevel, "SYSTEM") && NBootUtils.firstNonNull(options.getSystem(), false)) { + if (NBootUtils.firstNonNull(options.getReset(), false)) { throw new NBootException(NBootMsg.ofC("invalid option 'global' in %s mode", isolationLevel)); } } @@ -603,7 +605,7 @@ private boolean prepareWorkspace() { //this is a protocol based workspace //String protocol=ws.substring(0,ws.indexOf("://")); workspaceName = "remote-bootstrap"; - lastNutsWorkspaceJsonConfigPath = NBootPlatformHome.of(null, NBootUtils.firstNonNull(computedOptions.getSystem(), false)).getWorkspaceLocation(NBootUtils.resolveValidWorkspaceName(workspaceName)); + lastNutsWorkspaceJsonConfigPath = NBootPlatformHome.of(null, NBootUtils.firstNonNull(options.getSystem(), false)).getWorkspaceLocation(NBootUtils.resolveValidWorkspaceName(workspaceName)); lastConfigLoaded = NBootBootConfigLoader.loadBootConfig(lastNutsWorkspaceJsonConfigPath, bLog); immediateLocation = true; @@ -611,7 +613,7 @@ private boolean prepareWorkspace() { immediateLocation = NBootUtils.isValidWorkspaceName(_ws); int maxDepth = 36; for (int i = 0; i < maxDepth; i++) { - lastNutsWorkspaceJsonConfigPath = NBootUtils.isValidWorkspaceName(_ws) ? NBootPlatformHome.of(null, NBootUtils.firstNonNull(computedOptions.getSystem(), false)).getWorkspaceLocation(NBootUtils.resolveValidWorkspaceName(_ws)) : NBootIOUtilsBoot.getAbsolutePath(_ws); + lastNutsWorkspaceJsonConfigPath = NBootUtils.isValidWorkspaceName(_ws) ? NBootPlatformHome.of(null, NBootUtils.firstNonNull(options.getSystem(), false)).getWorkspaceLocation(NBootUtils.resolveValidWorkspaceName(_ws)) : NBootIOUtilsBoot.getAbsolutePath(_ws); NBootOptionsBoot configLoaded = NBootBootConfigLoader.loadBootConfig(lastNutsWorkspaceJsonConfigPath, bLog); if (configLoaded == null) { @@ -627,17 +629,17 @@ private boolean prepareWorkspace() { throw new NBootException(NBootMsg.ofPlain("cyclic workspace resolution")); } } - workspaceName = NBootUtils.resolveValidWorkspaceName(computedOptions.getWorkspace()); + workspaceName = NBootUtils.resolveValidWorkspaceName(options.getWorkspace()); } } - computedOptions.setWorkspace(lastNutsWorkspaceJsonConfigPath); + options.setWorkspace(lastNutsWorkspaceJsonConfigPath); if (lastConfigLoaded != null) { - computedOptions.setWorkspace(lastNutsWorkspaceJsonConfigPath); - computedOptions.setName(lastConfigLoaded.getName()); - computedOptions.setUuid(lastConfigLoaded.getUuid()); + options.setWorkspace(lastNutsWorkspaceJsonConfigPath); + options.setName(lastConfigLoaded.getName()); + options.setUuid(lastConfigLoaded.getUuid()); NBootOptionsBoot curr; if (!resetFlag) { - curr = computedOptions; + curr = options; } else { lastWorkspaceOptions = new NBootOptionsBoot(); curr = lastWorkspaceOptions; @@ -655,7 +657,7 @@ private boolean prepareWorkspace() { curr.setStoreLocations(NBootUtils.nonNullMap(lastConfigLoaded.getStoreLocations())); curr.setHomeLocations(NBootUtils.nonNullMap(lastConfigLoaded.getHomeLocations())); } - revalidateLocations(computedOptions, workspaceName, immediateLocation, isolationLevel); + revalidateLocations(options, workspaceName, immediateLocation, isolationLevel); long countDeleted = 0; //now that config is prepared proceed to any cleanup if (resetFlag) { @@ -676,11 +678,11 @@ private boolean prepareWorkspace() { } else { bLog.log(Level.CONFIG, "WARNING", NBootMsg.ofPlain("reset workspace")); getFallbackCache(NBootId.RUNTIME_ID, false, true); - countDeleted = NBootIOUtilsBoot.deleteStoreLocations(computedOptions, getOptions(), true, bLog, NBootPlatformHome.storeTypes(), () -> scanner.nextLine()); + countDeleted = NBootIOUtilsBoot.deleteStoreLocations(options, getOptions(), true, bLog, NBootPlatformHome.storeTypes(), () -> scanner.nextLine()); NBootUtils.ndiUndo(bLog); } } - } else if (NBootUtils.firstNonNull(computedOptions.getRecover(), false)) { + } else if (NBootUtils.firstNonNull(options.getRecover(), false)) { if (dryFlag) { bLog.log(Level.INFO, "DEBUG", NBootMsg.ofPlain("[dry] [recover] delete CACHE/TEMP workspace folders")); } else { @@ -689,113 +691,115 @@ private boolean prepareWorkspace() { folders.add("CACHE"); folders.add("TEMP"); //delete nuts.jar and nuts-runtime.jar in the lib folder. They will be re-downloaded. - String p = NBootIOUtilsBoot.getStoreLocationPath(computedOptions, "LIB"); + String p = NBootIOUtilsBoot.getStoreLocationPath(options, "LIB"); if (p != null) { folders.add(Paths.get(p).resolve("id/net/thevpc/nuts/nuts")); folders.add(Paths.get(p).resolve("id/net/thevpc/nuts/nuts-runtime")); } - countDeleted = NBootIOUtilsBoot.deleteStoreLocations(computedOptions, getOptions(), false, bLog, folders.toArray(), () -> scanner.nextLine()); + countDeleted = NBootIOUtilsBoot.deleteStoreLocations(options, getOptions(), false, bLog, folders.toArray(), () -> scanner.nextLine()); } } - if (computedOptions.getExtensionsSet() == null) { + if (options.getExtensionsSet() == null) { if (lastWorkspaceOptions != null && !resetFlag) { - computedOptions.setExtensionsSet(NBootUtils.firstNonNull(lastWorkspaceOptions.getExtensionsSet(), Collections.emptySet())); + options.setExtensionsSet(NBootUtils.firstNonNull(lastWorkspaceOptions.getExtensionsSet(), Collections.emptySet())); } else { - computedOptions.setExtensionsSet(Collections.emptySet()); + options.setExtensionsSet(Collections.emptySet()); } } - if (computedOptions.getHomeLocations() == null) { + if (options.getHomeLocations() == null) { if (lastWorkspaceOptions != null && !resetFlag) { - computedOptions.setHomeLocations(NBootUtils.firstNonNull(lastWorkspaceOptions.getHomeLocations(), Collections.emptyMap())); + options.setHomeLocations(NBootUtils.firstNonNull(lastWorkspaceOptions.getHomeLocations(), Collections.emptyMap())); } else { - computedOptions.setHomeLocations(Collections.emptyMap()); + options.setHomeLocations(Collections.emptyMap()); } } - if (computedOptions.getStoreLayout() == null) { + if (options.getStoreLayout() == null) { if (lastWorkspaceOptions != null && !resetFlag) { - computedOptions.setStoreLayout(NBootUtils.firstNonNull(lastWorkspaceOptions.getStoreLayout(), NBootPlatformHome.currentOsFamily())); + options.setStoreLayout(NBootUtils.firstNonNull(lastWorkspaceOptions.getStoreLayout(), NBootPlatformHome.currentOsFamily())); } else { - computedOptions.setHomeLocations(Collections.emptyMap()); + options.setHomeLocations(Collections.emptyMap()); } } //if recover or reset mode with -Q option (SkipBoot) //as long as there are no applications to run, will exit before creating workspace - if (computedOptions.getApplicationArguments().size() == 0 && NBootUtils.firstNonNull(computedOptions.getSkipBoot(), false) && (NBootUtils.firstNonNull(computedOptions.getRecover(), false) || resetFlag)) { + if ( + NBootUtils.isEmptyList(options.getApplicationArguments()) + && NBootUtils.firstNonNull(options.getSkipBoot(), false) && (NBootUtils.firstNonNull(options.getRecover(), false) || resetFlag)) { if (isPlainTrace()) { if (countDeleted > 0) { - bLog.log(Level.WARNING, "WARNING", NBootMsg.ofC("workspace erased : %s", computedOptions.getWorkspace())); + bLog.warn(NBootMsg.ofC("workspace erased : %s", options.getWorkspace())); } else { - bLog.log(Level.WARNING, "WARNING", NBootMsg.ofC("workspace is not erased because it does not exist : %s", computedOptions.getWorkspace())); + bLog.warn(NBootMsg.ofC("workspace is not erased because it does not exist : %s", options.getWorkspace())); } } throw new NBootException(NBootMsg.ofPlain(""), 0); } //after eventual clean up - if (NBootUtils.firstNonNull(computedOptions.getInherited(), false)) { + if (NBootUtils.firstNonNull(options.getInherited(), false)) { //when Inherited, always use the current Api version! - computedOptions.setApiVersion(getVersion().toString()); + options.setApiVersion(getVersion().toString()); } else { - NBootVersion nutsVersion = NBootVersion.of(computedOptions.getApiVersion()); + NBootVersion nutsVersion = NBootVersion.of(options.getApiVersion()); if (nutsVersion.isLatestVersion() || nutsVersion.isReleaseVersion()) { - NBootId s = NReservedMavenUtilsBoot.resolveLatestMavenId(NBootId.ofApi(""), null, bLog, resolveBootRuntimeRepositories(true), computedOptions); + NBootId s = NReservedMavenUtilsBoot.resolveLatestMavenId(NBootId.ofApi(""), null, bLog, resolveBootRuntimeRepositories(true), options); if (s == null) { throw new NBootException(NBootMsg.ofPlain("unable to load latest nuts version")); } - computedOptions.setApiVersion(s.getVersion()); + options.setApiVersion(s.getVersion()); } if (nutsVersion.isBlank()) { - computedOptions.setApiVersion(getVersion().toString()); + options.setApiVersion(getVersion().toString()); } } - NBootId bootApiId = NBootId.ofApi(computedOptions.getApiVersion()); - Path nutsApiConfigBootPath = Paths.get(computedOptions.getStoreType("CONF") + File.separator + NBootConstants.Folders.ID).resolve(NBootUtils.resolveIdPath(bootApiId)).resolve(NBootConstants.Files.API_BOOT_CONFIG_FILE_NAME); + NBootId bootApiId = NBootId.ofApi(options.getApiVersion()); + Path nutsApiConfigBootPath = Paths.get(options.getStoreType("CONF") + File.separator + NBootConstants.Folders.ID).resolve(NBootUtils.resolveIdPath(bootApiId)).resolve(NBootConstants.Files.API_BOOT_CONFIG_FILE_NAME); boolean loadedApiConfig = false; //This is not cache, but still, if recover or reset, config will be ignored! - if (isLoadFromCache() && NBootIOUtilsBoot.isFileAccessible(nutsApiConfigBootPath, computedOptions.getExpireTime(), bLog)) { + if (isLoadFromCache() && NBootIOUtilsBoot.isFileAccessible(nutsApiConfigBootPath, options.getExpireTime(), bLog)) { try { Map obj = NBootJsonParser.parse(nutsApiConfigBootPath); if (!obj.isEmpty()) { bLog.log(Level.CONFIG, "READ", NBootMsg.ofC("loaded %s file : %s", nutsApiConfigBootPath.getFileName(), nutsApiConfigBootPath.toString())); loadedApiConfig = true; - if (computedOptions.getRuntimeId() == null) { + if (options.getRuntimeId() == null) { String runtimeId = (String) obj.get("runtimeId"); if (NBootStringUtils.isBlank(runtimeId)) { bLog.log(Level.CONFIG, "FAIL", NBootMsg.ofC("%s does not contain runtime-id", nutsApiConfigBootPath)); } - computedOptions.setRuntimeId(runtimeId); + options.setRuntimeId(runtimeId); } - if (computedOptions.getJavaCommand() == null) { - computedOptions.setJavaCommand((String) obj.get("javaCommand")); + if (options.getJavaCommand() == null) { + options.setJavaCommand((String) obj.get("javaCommand")); } - if (computedOptions.getJavaOptions() == null) { - computedOptions.setJavaOptions((String) obj.get("javaOptions")); + if (options.getJavaOptions() == null) { + options.setJavaOptions((String) obj.get("javaOptions")); } } } catch (UncheckedIOException e) { bLog.log(Level.CONFIG, "READ", NBootMsg.ofC("unable to read %s : %s", nutsApiConfigBootPath, e)); } } - if (!loadedApiConfig || computedOptions.getRuntimeId() == null || computedOptions.getRuntimeBootDescriptor() == null || computedOptions.getExtensionBootDescriptors() == null || computedOptions.getBootRepositories() == null) { + if (!loadedApiConfig || options.getRuntimeId() == null || options.getRuntimeBootDescriptor() == null || options.getExtensionBootDescriptors() == null || options.getBootRepositories() == null) { - NBootVersion apiVersion = NBootVersion.of(computedOptions.getApiVersion()); + NBootVersion apiVersion = NBootVersion.of(options.getApiVersion()); if (isRuntimeLoaded() && (apiVersion.isBlank() || getVersion().equals(apiVersion))) { - if (computedOptions.getRuntimeId() == null) { - computedOptions.setRuntimeId(runtimeLoadedId == null ? null : runtimeLoadedId.toString()); - computedOptions.setRuntimeBootDescriptor(null); + if (options.getRuntimeId() == null) { + options.setRuntimeId(runtimeLoadedId == null ? null : runtimeLoadedId.toString()); + options.setRuntimeBootDescriptor(null); } } //resolve runtime id - if (computedOptions.getRuntimeId() == null) { + if (options.getRuntimeId() == null) { //load from local lib folder NBootId runtimeId = null; - if (!resetFlag && !NBootUtils.firstNonNull(computedOptions.getRecover(), false)) { - runtimeId = NReservedMavenUtilsBoot.resolveLatestMavenId(NBootId.of(NBootConstants.Ids.NUTS_RUNTIME), (rtVersion) -> rtVersion.getValue().startsWith(apiVersion + "."), bLog, Collections.singletonList(NBootRepositoryLocation.of("nuts@" + computedOptions.getStoreType("LIB") + File.separatorChar + NBootConstants.Folders.ID)), computedOptions); + if (!resetFlag && !NBootUtils.firstNonNull(options.getRecover(), false)) { + runtimeId = NReservedMavenUtilsBoot.resolveLatestMavenId(NBootId.of(NBootConstants.Ids.NUTS_RUNTIME), (rtVersion) -> rtVersion.getValue().startsWith(apiVersion + "."), bLog, Collections.singletonList(NBootRepositoryLocation.of("nuts@" + options.getStoreType("LIB") + File.separatorChar + NBootConstants.Folders.ID)), options); } if (runtimeId == null) { - runtimeId = NReservedMavenUtilsBoot.resolveLatestMavenId(NBootId.of(NBootConstants.Ids.NUTS_RUNTIME), (rtVersion) -> rtVersion.getValue().startsWith(apiVersion + "."), bLog, resolveBootRuntimeRepositories(true), computedOptions); + runtimeId = NReservedMavenUtilsBoot.resolveLatestMavenId(NBootId.of(NBootConstants.Ids.NUTS_RUNTIME), (rtVersion) -> rtVersion.getValue().startsWith(apiVersion + "."), bLog, resolveBootRuntimeRepositories(true), options); } if (runtimeId == null) { runtimeId = getFallbackCache(NBootId.RUNTIME_ID, false, false).id; @@ -803,26 +807,26 @@ private boolean prepareWorkspace() { if (runtimeId == null) { bLog.log(Level.FINEST, "FAIL", NBootMsg.ofPlain("unable to resolve latest runtime-id version (is connection ok?)")); } - computedOptions.setRuntimeId(runtimeId == null ? null : runtimeId.toString()); - computedOptions.setRuntimeBootDescriptor(null); + options.setRuntimeId(runtimeId == null ? null : runtimeId.toString()); + options.setRuntimeBootDescriptor(null); } - if (computedOptions.getRuntimeId() == null) { - computedOptions.setRuntimeId((resolveDefaultRuntimeId(computedOptions.getApiVersion()))); - bLog.log(Level.CONFIG, "READ", NBootMsg.ofC("consider default runtime-id : %s", computedOptions.getRuntimeId())); + if (options.getRuntimeId() == null) { + options.setRuntimeId((resolveDefaultRuntimeId(options.getApiVersion()))); + bLog.log(Level.CONFIG, "READ", NBootMsg.ofC("consider default runtime-id : %s", options.getRuntimeId())); } - NBootId runtimeIdObject = NBootId.of(computedOptions.getRuntimeId()); + NBootId runtimeIdObject = NBootId.of(options.getRuntimeId()); if (NBootStringUtils.isBlank(runtimeIdObject.getVersion())) { - computedOptions.setRuntimeId(resolveDefaultRuntimeId(computedOptions.getApiVersion())); + options.setRuntimeId(resolveDefaultRuntimeId(options.getApiVersion())); } //resolve runtime libraries - if (computedOptions.getRuntimeBootDescriptor() == null && !isRuntimeLoaded()) { + if (options.getRuntimeBootDescriptor() == null && !isRuntimeLoaded()) { Set loadedDeps = null; - String rid = computedOptions.getRuntimeId(); - Path nutsRuntimeCacheConfigPath = Paths.get(computedOptions.getStoreType("CONF") + File.separator + NBootConstants.Folders.ID).resolve(NBootUtils.resolveIdPath(bootApiId)).resolve(NBootConstants.Files.RUNTIME_BOOT_CONFIG_FILE_NAME); + String rid = options.getRuntimeId(); + Path nutsRuntimeCacheConfigPath = Paths.get(options.getStoreType("CONF") + File.separator + NBootConstants.Folders.ID).resolve(NBootUtils.resolveIdPath(bootApiId)).resolve(NBootConstants.Files.RUNTIME_BOOT_CONFIG_FILE_NAME); try { boolean cacheLoaded = false; - if (!NBootUtils.firstNonNull(computedOptions.getRecover(), false) && !resetFlag && NBootIOUtilsBoot.isFileAccessible(nutsRuntimeCacheConfigPath, computedOptions.getExpireTime(), bLog)) { + if (!NBootUtils.firstNonNull(options.getRecover(), false) && !resetFlag && NBootIOUtilsBoot.isFileAccessible(nutsRuntimeCacheConfigPath, options.getExpireTime(), bLog)) { try { Map obj = NBootJsonParser.parse(nutsRuntimeCacheConfigPath); bLog.log(Level.CONFIG, "READ", NBootMsg.ofC("loaded %s file : %s", nutsRuntimeCacheConfigPath.getFileName(), nutsRuntimeCacheConfigPath.toString())); @@ -838,7 +842,7 @@ private boolean prepareWorkspace() { } if (!cacheLoaded || loadedDeps == null) { - loadedDeps = NReservedMavenUtilsBoot.loadDependenciesFromId(NBootId.of(computedOptions.getRuntimeId()), bLog, resolveBootRuntimeRepositories(false), cache); + loadedDeps = NReservedMavenUtilsBoot.loadDependenciesFromId(NBootId.of(options.getRuntimeId()), bLog, resolveBootRuntimeRepositories(false), cache); bLog.log(Level.CONFIG, "SUCCESS", NBootMsg.ofC("detect runtime dependencies : %s", loadedDeps)); } } catch (Exception ex) { @@ -853,7 +857,7 @@ private boolean prepareWorkspace() { if (loadedDeps == null) { throw new NBootException(NBootMsg.ofC("unable to load dependencies for %s", rid)); } - computedOptions.setRuntimeBootDescriptor(new NBootDescriptor().setId(computedOptions.getRuntimeId()).setDependencies(loadedDeps.stream().map(NBootId::toDependency).collect(Collectors.toList()))); + options.setRuntimeBootDescriptor(new NBootDescriptor().setId(options.getRuntimeId()).setDependencies(loadedDeps.stream().map(NBootId::toDependency).collect(Collectors.toList()))); Set bootRepositories = resolveBootRuntimeRepositories(false); if (bLog.isLoggable(Level.CONFIG)) { if (bootRepositories.size() == 0) { @@ -867,27 +871,27 @@ private boolean prepareWorkspace() { } } } - computedOptions.setBootRepositories(bootRepositories.stream().map(NBootRepositoryLocation::toString).collect(Collectors.joining(";"))); + options.setBootRepositories(bootRepositories.stream().map(NBootRepositoryLocation::toString).collect(Collectors.joining(";"))); } //resolve extension libraries - if (computedOptions.getExtensionBootDescriptors() == null) { + if (options.getExtensionBootDescriptors() == null) { LinkedHashSet excludedExtensions = new LinkedHashSet<>(); - if (computedOptions.getExcludedExtensions() != null) { - for (String excludedExtensionGroup : computedOptions.getExcludedExtensions()) { + if (options.getExcludedExtensions() != null) { + for (String excludedExtensionGroup : options.getExcludedExtensions()) { for (String excludedExtension : NBootStringUtils.split(excludedExtensionGroup, ";,", true, true)) { excludedExtensions.add(NBootId.of(excludedExtension).getShortName()); } } } - if (computedOptions.getExtensionsSet() != null) { + if (options.getExtensionsSet() != null) { List all = new ArrayList<>(); - for (String extension : computedOptions.getExtensionsSet()) { + for (String extension : options.getExtensionsSet()) { NBootId eid = NBootId.of(extension); if (!excludedExtensions.contains(eid.getShortName()) && !excludedExtensions.contains(eid.getArtifactId())) { - Path extensionFile = Paths.get(computedOptions.getStoreType("CONF") + File.separator + NBootConstants.Folders.ID).resolve(NBootUtils.resolveIdPath(bootApiId)).resolve(NBootConstants.Files.EXTENSION_BOOT_CONFIG_FILE_NAME); + Path extensionFile = Paths.get(options.getStoreType("CONF") + File.separator + NBootConstants.Folders.ID).resolve(NBootUtils.resolveIdPath(bootApiId)).resolve(NBootConstants.Files.EXTENSION_BOOT_CONFIG_FILE_NAME); Set loadedDeps = null; - if (isLoadFromCache() && NBootIOUtilsBoot.isFileAccessible(extensionFile, computedOptions.getExpireTime(), bLog)) { + if (isLoadFromCache() && NBootIOUtilsBoot.isFileAccessible(extensionFile, options.getExpireTime(), bLog)) { try { Properties obj = NBootIOUtilsBoot.loadURLProperties(extensionFile, bLog); bLog.log(Level.CONFIG, "READ", NBootMsg.ofC("loaded %s file : %s", extensionFile.getFileName(), extensionFile.toString())); @@ -907,16 +911,16 @@ private boolean prepareWorkspace() { all.add(new NBootDescriptor().setId(NBootId.of(extension)).setDependencies(loadedDeps.stream().map(NBootId::toDependency).collect(Collectors.toList()))); } } - computedOptions.setExtensionBootDescriptors(all); + options.setExtensionBootDescriptors(all); } else { - computedOptions.setExtensionBootDescriptors(new ArrayList<>()); + options.setExtensionBootDescriptors(new ArrayList<>()); } } } newInstanceRequirements = checkRequirements(true); if (newInstanceRequirements == 0) { - computedOptions.setJavaCommand(null); - computedOptions.setJavaOptions(null); + options.setJavaCommand(null); + options.setJavaOptions(null); } return true; } @@ -924,13 +928,13 @@ private boolean prepareWorkspace() { } private boolean isPlainTrace() { - return NBootUtils.firstNonNull(computedOptions.getTrace(), true) - && !NBootUtils.firstNonNull(computedOptions.getBot(), false) - && (NBootUtils.sameEnum(computedOptions.getOutputFormat(), "PLAIN") || NBootStringUtils.isBlank(computedOptions.getOutputFormat())); + return NBootUtils.firstNonNull(options.getTrace(), true) + && !NBootUtils.firstNonNull(options.getBot(), false) + && (NBootUtils.sameEnum(options.getOutputFormat(), "PLAIN") || NBootStringUtils.isBlank(options.getOutputFormat())); } private boolean isLoadFromCache() { - return !NBootUtils.firstNonNull(computedOptions.getRecover(), false) && !NBootUtils.firstNonNull(computedOptions.getReset(), false); + return !NBootUtils.firstNonNull(options.getRecover(), false) && !NBootUtils.firstNonNull(options.getReset(), false); } /** @@ -956,9 +960,10 @@ private Object openOrRunWorkspace(boolean run) { } //if recover or reset mode with -K option (SkipWelcome) //as long as there are no applications to run, will exit before creating workspace - if (computedOptions.getApplicationArguments().size() == 0 && NBootUtils.firstNonNull(computedOptions.getSkipBoot(), false) && (NBootUtils.firstNonNull(computedOptions.getRecover(), false) || NBootUtils.firstNonNull(computedOptions.getReset(), false))) { + if (NBootUtils.isEmptyList(options.getApplicationArguments()) + && NBootUtils.firstNonNull(options.getSkipBoot(), false) && (NBootUtils.firstNonNull(options.getRecover(), false) || NBootUtils.firstNonNull(options.getReset(), false))) { if (isPlainTrace()) { - bLog.log(Level.WARNING, "WARNING", NBootMsg.ofC("workspace erased : %s", computedOptions.getWorkspace())); + bLog.warn(NBootMsg.ofC("workspace erased : %s", options.getWorkspace())); } throw new NBootException(null, 0); } @@ -967,50 +972,50 @@ private Object openOrRunWorkspace(boolean run) { Object wsInstance = null; NBootErrorInfoList errorList = new NBootErrorInfoList(); try { - Path configFile = Paths.get(computedOptions.getWorkspace()).resolve(NBootConstants.Files.WORKSPACE_CONFIG_FILE_NAME); - if (NBootUtils.sameEnum(computedOptions.getOpenMode(), "OPEN_OR_ERROR")) { + Path configFile = Paths.get(options.getWorkspace()).resolve(NBootConstants.Files.WORKSPACE_CONFIG_FILE_NAME); + if (NBootUtils.sameEnum(options.getOpenMode(), "OPEN_OR_ERROR")) { //add fail fast test!! if (!Files.isRegularFile(configFile)) { - throw new NBootWorkspaceNotFoundException(computedOptions.getWorkspace()); + throw new NBootWorkspaceNotFoundException(options.getWorkspace()); } - } else if (NBootUtils.sameEnum(computedOptions.getOpenMode(), "CREATE_OR_ERROR")) { + } else if (NBootUtils.sameEnum(options.getOpenMode(), "CREATE_OR_ERROR")) { if (Files.exists(configFile)) { - throw new NBootWorkspaceAlreadyExistsException(computedOptions.getWorkspace()); + throw new NBootWorkspaceAlreadyExistsException(options.getWorkspace()); } } - if (NBootStringUtils.isBlank(computedOptions.getApiVersion()) - || NBootStringUtils.isBlank(computedOptions.getRuntimeId()) - || (!isRuntimeLoaded() && computedOptions.getRuntimeBootDescriptor() == null) - || computedOptions.getExtensionBootDescriptors() == null + if (NBootStringUtils.isBlank(options.getApiVersion()) + || NBootStringUtils.isBlank(options.getRuntimeId()) + || (!isRuntimeLoaded() && options.getRuntimeBootDescriptor() == null) + || options.getExtensionBootDescriptors() == null // || (!runtimeLoaded && (computedOptions.getBootRepositories().isBlank())) ) { throw new NBootException(NBootMsg.ofPlain("invalid workspace state")); } - boolean recover = NBootUtils.firstNonNull(computedOptions.getRecover(), false) || NBootUtils.firstNonNull(computedOptions.getReset(), false); + boolean recover = NBootUtils.firstNonNull(options.getRecover(), false) || NBootUtils.firstNonNull(options.getReset(), false); List deps = new ArrayList<>(); - String workspaceBootLibFolder = computedOptions.getStoreType("LIB") + File.separator + NBootConstants.Folders.ID; + String workspaceBootLibFolder = options.getStoreType("LIB") + File.separator + NBootConstants.Folders.ID; - NBootRepositoryLocation[] repositories = NBootStringUtils.split(computedOptions.getBootRepositories(), "\n;", true, true).stream().map(NBootRepositoryLocation::of).toArray(NBootRepositoryLocation[]::new); + NBootRepositoryLocation[] repositories = NBootStringUtils.split(options.getBootRepositories(), "\n;", true, true).stream().map(NBootRepositoryLocation::of).toArray(NBootRepositoryLocation[]::new); NBootRepositoryLocation workspaceBootLibFolderRepo = NBootRepositoryLocation.of("nuts@" + workspaceBootLibFolder); - computedOptions.setRuntimeBootDependencyNode( + options.setRuntimeBootDependencyNode( isRuntimeLoaded() ? null : - createClassLoaderNode(computedOptions.getRuntimeBootDescriptor(), repositories, workspaceBootLibFolderRepo, recover, errorList, true) + createClassLoaderNode(options.getRuntimeBootDescriptor(), repositories, workspaceBootLibFolderRepo, recover, errorList, true) ); - if (computedOptions.getExtensionBootDescriptors() != null) { - for (NBootDescriptor nutsBootDescriptor : computedOptions.getExtensionBootDescriptors()) { + if (options.getExtensionBootDescriptors() != null) { + for (NBootDescriptor nutsBootDescriptor : options.getExtensionBootDescriptors()) { deps.add(createClassLoaderNode(nutsBootDescriptor, repositories, workspaceBootLibFolderRepo, recover, errorList, false)); } } - computedOptions.setExtensionBootDependencyNodes(deps); - deps.add(0, computedOptions.getRuntimeBootDependencyNode()); + options.setExtensionBootDependencyNodes(deps); + deps.add(0, options.getRuntimeBootDependencyNode()); bootClassWorldURLs = NBootUtils.resolveClassWorldURLs(deps.toArray(new NBootClassLoaderNode[0]), getContextClassLoader(), bLog); workspaceClassLoader = /*bootClassWorldURLs.length == 0 ? getContextClassLoader() : */ new NBootClassLoader(deps.toArray(new NBootClassLoaderNode[0]), getContextClassLoader()); - computedOptions.setClassWorldLoader(workspaceClassLoader); + options.setClassWorldLoader(workspaceClassLoader); if (bLog.isLoggable(Level.CONFIG)) { if (bootClassWorldURLs.length == 0) { bLog.log(Level.CONFIG, "SUCCESS", NBootMsg.ofPlain("empty nuts class world. All dependencies are already loaded in classpath, most likely")); @@ -1023,14 +1028,14 @@ private Object openOrRunWorkspace(boolean run) { } } } - computedOptions.setClassWorldURLs(Arrays.asList(bootClassWorldURLs)); + options.setClassWorldURLs(Arrays.asList(bootClassWorldURLs)); bLog.log(Level.CONFIG, "INFO", NBootMsg.ofPlain("search for NutsBootWorkspaceFactory service implementations")); ServiceLoader serviceLoader = ServiceLoader.load(NBootWorkspaceFactory.class, workspaceClassLoader); List factories = new ArrayList<>(5); for (NBootWorkspaceFactory a : serviceLoader) { factories.add(a); } - factories.sort(new NBootWorkspaceFactoryComparator(computedOptions)); + factories.sort(new NBootWorkspaceFactoryComparator(options)); if (bLog.isLoggable(Level.CONFIG)) { switch (factories.size()) { case 0: { @@ -1057,15 +1062,15 @@ private Object openOrRunWorkspace(boolean run) { if (bLog.isLoggable(Level.CONFIG)) { bLog.log(Level.CONFIG, "INFO", NBootMsg.ofC("create workspace using %s", factoryInstance.getClass().getName())); } - computedOptions.setBootWorkspaceFactory(factoryInstance); + options.setBootWorkspaceFactory(factoryInstance); if (run) { - wsInstance = a.runWorkspace(computedOptions); + wsInstance = a.runWorkspace(options); } else { - wsInstance = a.createWorkspace(computedOptions); + wsInstance = a.createWorkspace(options); } } catch (UnsatisfiedLinkError | Exception ex) { exceptions.add(ex); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC("unable to create workspace using factory %s", a), ex); + bLog.error(NBootMsg.ofC("unable to create workspace using factory %s", a), ex); // if the creation generates an error // just stop break; @@ -1076,15 +1081,15 @@ private Object openOrRunWorkspace(boolean run) { } if (wsInstance == null) { //should never happen - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC("unable to load Workspace \"%s\" from ClassPath :", computedOptions.getName())); + bLog.error(NBootMsg.ofC("unable to load Workspace \"%s\" from ClassPath :", options.getName())); for (URL url : bootClassWorldURLs) { - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC("\t %s", NBootIOUtilsBoot.formatURL(url))); + bLog.error(NBootMsg.ofC("\t %s", NBootIOUtilsBoot.formatURL(url))); } for (Throwable exception : exceptions) { - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC("%s", exception), exception); + bLog.error(NBootMsg.ofC("%s", exception), exception); } - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC("unable to load Workspace Component from ClassPath : %s", Arrays.asList(bootClassWorldURLs))); - throw new NBootInvalidWorkspaceException(this.computedOptions.getWorkspace(), NBootMsg.ofC("unable to load Workspace Component from ClassPath : %s%n caused by:%n\t%s", Arrays.asList(bootClassWorldURLs), exceptions.stream().map(Throwable::toString).collect(Collectors.joining("\n\t")))); + bLog.error(NBootMsg.ofC("unable to load Workspace Component from ClassPath : %s", Arrays.asList(bootClassWorldURLs))); + throw new NBootInvalidWorkspaceException(this.options.getWorkspace(), NBootMsg.ofC("unable to load Workspace Component from ClassPath : %s%n caused by:%n\t%s", Arrays.asList(bootClassWorldURLs), exceptions.stream().map(Throwable::toString).collect(Collectors.joining("\n\t")))); } return wsInstance; // } catch (NReadOnlyException | NCancelException | NNoSessionCancelException ex) { @@ -1106,7 +1111,7 @@ private Object openOrRunWorkspace(boolean run) { } private ClassLoader getContextClassLoader() { - Supplier classLoaderSupplier = computedOptions.getClassLoaderSupplier(); + Supplier classLoaderSupplier = options.getClassLoaderSupplier(); if (classLoaderSupplier != null) { ClassLoader classLoader = classLoaderSupplier.get(); if (classLoader != null) { @@ -1117,8 +1122,8 @@ private ClassLoader getContextClassLoader() { } private void runCommandHelp() { - String f = NBootUtils.firstNonNull(computedOptions.getOutputFormat(), "PLAIN"); - if (NBootUtils.firstNonNull(computedOptions.getDry(), false)) { + String f = NBootUtils.firstNonNull(options.getOutputFormat(), "PLAIN"); + if (NBootUtils.firstNonNull(options.getDry(), false)) { printDryCommand("help"); } else { String msg = "nuts is an open source package manager mainly for java applications. Type 'nuts help' or visit https://github.com/thevpc/nuts for more help."; @@ -1164,8 +1169,8 @@ private void runCommandHelp() { } private void printDryCommand(String cmd) { - String f = NBootUtils.firstNonNull(computedOptions.getOutputFormat(), "PLAIN"); - if (NBootUtils.firstNonNull(computedOptions.getDry(), false)) { + String f = NBootUtils.firstNonNull(options.getOutputFormat(), "PLAIN"); + if (NBootUtils.firstNonNull(options.getDry(), false)) { switch (NBootUtils.enumName(f)) { case "JSON": { bLog.outln("{"); @@ -1208,8 +1213,8 @@ private void printDryCommand(String cmd) { } private void runCommandVersion() { - String f = NBootUtils.firstNonNull(computedOptions.getOutputFormat(), "PLAIN"); - if (NBootUtils.firstNonNull(computedOptions.getDry(), false)) { + String f = NBootUtils.firstNonNull(options.getOutputFormat(), "PLAIN"); + if (NBootUtils.firstNonNull(options.getDry(), false)) { printDryCommand("version"); return; } @@ -1269,10 +1274,10 @@ private void runCommandVersion() { * @return NWorkspace instance as object */ public Object runWorkspace() { - if (NBootUtils.firstNonNull(computedOptions.getCommandHelp(), false)) { + if (NBootUtils.firstNonNull(options.getCommandHelp(), false)) { runCommandHelp(); return null; - } else if (NBootUtils.firstNonNull(computedOptions.getCommandVersion(), false)) { + } else if (NBootUtils.firstNonNull(options.getCommandVersion(), false)) { runCommandVersion(); return null; } @@ -1284,88 +1289,88 @@ public Object runWorkspace() { } private void fallbackInstallActionUnavailable(String message) { - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofPlain(message)); + bLog.error(NBootMsg.ofPlain(message)); } private void logError(URL[] bootClassWorldURLs, NBootErrorInfoList ths) { - String workspace = computedOptions.getWorkspace(); - Map rbc_locations = computedOptions.getStoreLocations(); + String workspace = options.getWorkspace(); + Map rbc_locations = options.getStoreLocations(); if (rbc_locations == null) { rbc_locations = new HashMap<>(); } - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC("unable to bootstrap nuts (digest %s):", getApiDigestOrInternal())); + bLog.error(NBootMsg.ofC("unable to bootstrap nuts (digest %s):", getApiDigestOrInternal())); if (!ths.list().isEmpty()) { - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC("%s", ths.list().get(0))); + bLog.error(NBootMsg.ofC("%s", ths.list().get(0))); } - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofPlain("here after current environment info:")); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" nuts-boot-api-version : %s", NBootUtils.firstNonNull(computedOptions.getApiVersion(), " Not Found!"))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" nuts-boot-runtime : %s", NBootUtils.firstNonNull(computedOptions.getRuntimeId(), " Not Found!"))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" nuts-boot-repositories : %s", NBootUtils.firstNonNull(computedOptions.getBootRepositories(), " Not Found!"))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" workspace-location : %s", NBootUtils.firstNonNull(workspace, ""))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" nuts-store-bin : %s", rbc_locations.get("BIN"))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" nuts-store-conf : %s", rbc_locations.get("CONF"))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" nuts-store-var : %s", rbc_locations.get("VAR"))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" nuts-store-log : %s", rbc_locations.get("LOG"))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" nuts-store-temp : %s", rbc_locations.get("TEMP"))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" nuts-store-cache : %s", rbc_locations.get("CACHE"))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" nuts-store-run : %s", rbc_locations.get("RUN"))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" nuts-store-lib : %s", rbc_locations.get("LIB"))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" nuts-store-strategy : %s", NBootUtils.desc(computedOptions.getStoreStrategy()))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" nuts-store-layout : %s", NBootUtils.desc(computedOptions.getStoreLayout()))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" nuts-boot-args : %s", asCmdLine(this.computedOptions, null))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" nuts-app-args : %s", this.computedOptions.getApplicationArguments())); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" option-read-only : %s", NBootUtils.firstNonNull(this.computedOptions.getReadOnly(), false))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" option-trace : %s", NBootUtils.firstNonNull(this.computedOptions.getTrace(), false))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" option-progress : %s", NBootUtils.desc(this.computedOptions.getProgressOptions()))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" option-open-mode : %s", NBootUtils.desc(NBootUtils.firstNonNull(this.computedOptions.getOpenMode(), "OPEN_OR_CREATE")))); + bLog.error(NBootMsg.ofPlain("here after current environment info:")); + bLog.error(NBootMsg.ofC(" nuts-boot-api-version : %s", NBootUtils.firstNonNull(options.getApiVersion(), " Not Found!"))); + bLog.error(NBootMsg.ofC(" nuts-boot-runtime : %s", NBootUtils.firstNonNull(options.getRuntimeId(), " Not Found!"))); + bLog.error(NBootMsg.ofC(" nuts-boot-repositories : %s", NBootUtils.firstNonNull(options.getBootRepositories(), " Not Found!"))); + bLog.error(NBootMsg.ofC(" workspace-location : %s", NBootUtils.firstNonNull(workspace, ""))); + bLog.error(NBootMsg.ofC(" nuts-store-bin : %s", rbc_locations.get("BIN"))); + bLog.error(NBootMsg.ofC(" nuts-store-conf : %s", rbc_locations.get("CONF"))); + bLog.error(NBootMsg.ofC(" nuts-store-var : %s", rbc_locations.get("VAR"))); + bLog.error(NBootMsg.ofC(" nuts-store-log : %s", rbc_locations.get("LOG"))); + bLog.error(NBootMsg.ofC(" nuts-store-temp : %s", rbc_locations.get("TEMP"))); + bLog.error(NBootMsg.ofC(" nuts-store-cache : %s", rbc_locations.get("CACHE"))); + bLog.error(NBootMsg.ofC(" nuts-store-run : %s", rbc_locations.get("RUN"))); + bLog.error(NBootMsg.ofC(" nuts-store-lib : %s", rbc_locations.get("LIB"))); + bLog.error(NBootMsg.ofC(" nuts-store-strategy : %s", NBootUtils.desc(options.getStoreStrategy()))); + bLog.error(NBootMsg.ofC(" nuts-store-layout : %s", NBootUtils.desc(options.getStoreLayout()))); + bLog.error(NBootMsg.ofC(" nuts-boot-args : %s", asCmdLine(this.options, null))); + bLog.error(NBootMsg.ofC(" nuts-app-args : %s", NBootUtils.nonNullStrList(this.options.getApplicationArguments()))); + bLog.error(NBootMsg.ofC(" option-read-only : %s", NBootUtils.firstNonNull(this.options.getReadOnly(), false))); + bLog.error(NBootMsg.ofC(" option-trace : %s", NBootUtils.firstNonNull(this.options.getTrace(), false))); + bLog.error(NBootMsg.ofC(" option-progress : %s", NBootUtils.desc(this.options.getProgressOptions()))); + bLog.error(NBootMsg.ofC(" option-open-mode : %s", NBootUtils.desc(NBootUtils.firstNonNull(this.options.getOpenMode(), "OPEN_OR_CREATE")))); - NBootClassLoaderNode rtn = this.computedOptions.getRuntimeBootDependencyNode(); + NBootClassLoaderNode rtn = this.options.getRuntimeBootDependencyNode(); String rtHash = ""; if (rtn != null) { rtHash = NBootIOUtilsBoot.getURLDigest(rtn.getURL(), bLog); } - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" nuts-runtime-digest : %s", rtHash)); + bLog.error(NBootMsg.ofC(" nuts-runtime-digest : %s", rtHash)); if (bootClassWorldURLs == null || bootClassWorldURLs.length == 0) { - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" nuts-runtime-classpath : %s", "")); + bLog.error(NBootMsg.ofC(" nuts-runtime-classpath : %s", "")); } else { - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" nuts-runtime-hash : %s", "")); + bLog.error(NBootMsg.ofC(" nuts-runtime-hash : %s", "")); for (int i = 0; i < bootClassWorldURLs.length; i++) { URL bootClassWorldURL = bootClassWorldURLs[i]; if (i == 0) { - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" nuts-runtime-classpath : %s", NBootIOUtilsBoot.formatURL(bootClassWorldURL))); + bLog.error(NBootMsg.ofC(" nuts-runtime-classpath : %s", NBootIOUtilsBoot.formatURL(bootClassWorldURL))); } else { - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" %s", NBootIOUtilsBoot.formatURL(bootClassWorldURL))); + bLog.error(NBootMsg.ofC(" %s", NBootIOUtilsBoot.formatURL(bootClassWorldURL))); } } } - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" java-version : %s", System.getProperty("java.version"))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" java-executable : %s", NBootUtils.resolveJavaCommand(null))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" java-class-path : %s", System.getProperty("java.class.path"))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" java-library-path : %s", System.getProperty("java.library.path"))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" os-name : %s", System.getProperty("os.name"))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" os-arch : %s", System.getProperty("os.arch"))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" os-version : %s", System.getProperty("os.version"))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" user-name : %s", System.getProperty("user.name"))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" user-home : %s", System.getProperty("user.home"))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(" user-dir : %s", System.getProperty("user.dir"))); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofPlain("")); - NBootLogConfig logConfig = this.computedOptions.getLogConfig(); + bLog.error(NBootMsg.ofC(" java-version : %s", System.getProperty("java.version"))); + bLog.error(NBootMsg.ofC(" java-executable : %s", NBootUtils.resolveJavaCommand(null))); + bLog.error(NBootMsg.ofC(" java-class-path : %s", System.getProperty("java.class.path"))); + bLog.error(NBootMsg.ofC(" java-library-path : %s", System.getProperty("java.library.path"))); + bLog.error(NBootMsg.ofC(" os-name : %s", System.getProperty("os.name"))); + bLog.error(NBootMsg.ofC(" os-arch : %s", System.getProperty("os.arch"))); + bLog.error(NBootMsg.ofC(" os-version : %s", System.getProperty("os.version"))); + bLog.error(NBootMsg.ofC(" user-name : %s", System.getProperty("user.name"))); + bLog.error(NBootMsg.ofC(" user-home : %s", System.getProperty("user.home"))); + bLog.error(NBootMsg.ofC(" user-dir : %s", System.getProperty("user.dir"))); + bLog.error(NBootMsg.ofPlain("")); + NBootLogConfig logConfig = this.options.getLogConfig(); if (logConfig == null || logConfig.getLogTermLevel() == null || (logConfig.getLogFileLevel() != null && logConfig.getLogFileLevel().intValue() > Level.FINEST.intValue())) { - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofPlain("If the problem persists you may want to get more debug info by adding '--verbose' arguments.")); + bLog.error(NBootMsg.ofPlain("If the problem persists you may want to get more debug info by adding '--verbose' arguments.")); } - if (!NBootUtils.firstNonNull(this.computedOptions.getReset(), false) && !NBootUtils.firstNonNull(this.computedOptions.getRecover(), false) && this.computedOptions.getExpireTime() == null) { - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofPlain("You may also enable recover mode to ignore existing cache info with '--recover' and '--expire' arguments.")); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofPlain("Here is the proper command : ")); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofPlain(" java -jar nuts.jar --verbose --recover --expire [...]")); - } else if (!NBootUtils.firstNonNull(this.computedOptions.getReset(), false) && NBootUtils.firstNonNull(this.computedOptions.getRecover(), false) && this.computedOptions.getExpireTime() == null) { - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofPlain("You may also enable full reset mode to ignore existing configuration with '--reset' argument.")); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofPlain("ATTENTION: this will delete all your nuts configuration. Use it at your own risk.")); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofPlain("Here is the proper command : ")); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofPlain(" java -jar nuts.jar --verbose --reset [...]")); + if (!NBootUtils.firstNonNull(this.options.getReset(), false) && !NBootUtils.firstNonNull(this.options.getRecover(), false) && this.options.getExpireTime() == null) { + bLog.error(NBootMsg.ofPlain("You may also enable recover mode to ignore existing cache info with '--recover' and '--expire' arguments.")); + bLog.error(NBootMsg.ofPlain("Here is the proper command : ")); + bLog.error(NBootMsg.ofPlain(" java -jar nuts.jar --verbose --recover --expire [...]")); + } else if (!NBootUtils.firstNonNull(this.options.getReset(), false) && NBootUtils.firstNonNull(this.options.getRecover(), false) && this.options.getExpireTime() == null) { + bLog.error(NBootMsg.ofPlain("You may also enable full reset mode to ignore existing configuration with '--reset' argument.")); + bLog.error(NBootMsg.ofPlain("ATTENTION: this will delete all your nuts configuration. Use it at your own risk.")); + bLog.error(NBootMsg.ofPlain("Here is the proper command : ")); + bLog.error(NBootMsg.ofPlain(" java -jar nuts.jar --verbose --reset [...]")); } if (!ths.list().isEmpty()) { - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofPlain("error stack trace is:")); + bLog.error(NBootMsg.ofPlain("error stack trace is:")); for (NReservedErrorInfo th : ths.list()) { StringBuilder msg = new StringBuilder(); List msgParams = new ArrayList<>(); @@ -1389,13 +1394,13 @@ private void logError(URL[] bootClassWorldURLs, NBootErrorInfoList ths) { msg.append(" =%s"); msgParams.add("unexpected error"); } - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofC(msg.toString(), msgParams.toArray())); - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofPlain(th.toString()), th.getThrowable()); + bLog.error(NBootMsg.ofC(msg.toString(), msgParams.toArray())); + bLog.error(NBootMsg.ofPlain(th.toString()), th.getThrowable()); } } else { - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofPlain("no stack trace is available.")); + bLog.error(NBootMsg.ofPlain("no stack trace is available.")); } - bLog.log(Level.SEVERE, "FAIL", NBootMsg.ofPlain("now exiting nuts, Bye!")); + bLog.error(NBootMsg.ofPlain("now exiting nuts, Bye!")); } /** @@ -1406,15 +1411,15 @@ private void logError(URL[] bootClassWorldURLs, NBootErrorInfoList ths) { */ private int checkRequirements(boolean unsatisfiedOnly) { int req = 0; - if (!NBootStringUtils.isBlank(computedOptions.getApiVersion())) { - if (!unsatisfiedOnly || !computedOptions.getApiVersion().equals(getVersion())) { + if (!NBootStringUtils.isBlank(options.getApiVersion())) { + if (!unsatisfiedOnly || !options.getApiVersion().equals(getVersion())) { req += 1; } } - if (!unsatisfiedOnly || !NBootUtils.isActualJavaCommand(computedOptions.getJavaCommand())) { + if (!unsatisfiedOnly || !NBootUtils.isActualJavaCommand(options.getJavaCommand())) { req += 2; } - if (!unsatisfiedOnly || !NBootUtils.isActualJavaOptions(computedOptions.getJavaOptions())) { + if (!unsatisfiedOnly || !NBootUtils.isActualJavaOptions(options.getJavaOptions())) { req += 4; } return req; @@ -1430,19 +1435,19 @@ public String getRequirementsHelpString(boolean unsatisfiedOnly) { int req = unsatisfiedOnly ? newInstanceRequirements : checkRequirements(false); StringBuilder sb = new StringBuilder(); if ((req & 1) != 0) { - sb.append("nuts version ").append(NBootId.ofApi(computedOptions.getApiVersion())); + sb.append("nuts version ").append(NBootId.ofApi(options.getApiVersion())); } if ((req & 2) != 0) { if (sb.length() > 0) { sb.append(" and "); } - sb.append("java command ").append(computedOptions.getJavaCommand()); + sb.append("java command ").append(options.getJavaCommand()); } if ((req & 4) != 0) { if (sb.length() > 0) { sb.append(" and "); } - sb.append("java options ").append(computedOptions.getJavaOptions()); + sb.append("java options ").append(options.getJavaOptions()); } if (sb.length() > 0) { sb.insert(0, "required "); @@ -1456,14 +1461,14 @@ private NBootClassLoaderNode createClassLoaderNode(NBootDescriptor descr, NBootR List deps = descr.getDependencies(); NBootClassLoaderNodeBuilder rt = new NBootClassLoaderNodeBuilder(); String name = runtimeDep ? "runtime" : ("extension " + id.toString()); - File file = NReservedMavenUtilsBoot.getBootCacheJar(NBootId.of(computedOptions.getRuntimeId()), repositories, workspaceBootLibFolder, !recover, name, computedOptions.getExpireTime(), errorList, computedOptions, pathExpansionConverter, bLog, cache); + File file = NReservedMavenUtilsBoot.getBootCacheJar(NBootId.of(options.getRuntimeId()), repositories, workspaceBootLibFolder, !recover, name, options.getExpireTime(), errorList, options, pathExpansionConverter, bLog, cache); rt.setId(id.toString()); rt.setUrl(file.toURI().toURL()); rt.setIncludedInClasspath(NBootUtils.isLoadedClassPath(rt.getURL(), getContextClassLoader(), bLog)); if (bLog.isLoggable(Level.CONFIG)) { String rtHash = ""; - if (computedOptions.getRuntimeId() != null) { + if (options.getRuntimeId() != null) { rtHash = NBootIOUtilsBoot.getFileOrDirectoryDigest(file.toPath()); if (rtHash == null) { rtHash = ""; @@ -1474,8 +1479,8 @@ private NBootClassLoaderNode createClassLoaderNode(NBootDescriptor descr, NBootR for (NBootDependency s : deps) { NBootClassLoaderNodeBuilder x = new NBootClassLoaderNodeBuilder(); - if (NBootUtils.isAcceptDependency(s, computedOptions)) { - x.setId(s.toString()).setUrl(NReservedMavenUtilsBoot.getBootCacheJar(s.toId(), repositories, workspaceBootLibFolder, !recover, name + " dependency", computedOptions.getExpireTime(), errorList, computedOptions, pathExpansionConverter, bLog, cache).toURI().toURL()); + if (NBootUtils.isAcceptDependency(s, options)) { + x.setId(s.toString()).setUrl(NReservedMavenUtilsBoot.getBootCacheJar(s.toId(), repositories, workspaceBootLibFolder, !recover, name + " dependency", options.getExpireTime(), errorList, options, pathExpansionConverter, bLog, cache).toURI().toURL()); x.setIncludedInClasspath(NBootUtils.isLoadedClassPath(x.getURL(), getContextClassLoader(), bLog)); rt.addDependency(x.build()); } diff --git a/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/reserved/cmdline/NBootWorkspaceCmdLineFormatter.java b/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/reserved/cmdline/NBootWorkspaceCmdLineFormatter.java index ba53662e2..b489584b3 100644 --- a/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/reserved/cmdline/NBootWorkspaceCmdLineFormatter.java +++ b/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/reserved/cmdline/NBootWorkspaceCmdLineFormatter.java @@ -529,16 +529,17 @@ public NBootCmdLine toCmdLine() { } if (isApiVersionOrAfter(V081)) { if (options.getCustomOptions() != null) { - arguments.addAll(nonNullStrList(options.getCustomOptions())); + arguments.addAll(NBootUtils.nonNullStrList(options.getCustomOptions())); } } //final options for execution - if ((!config.isOmitDefaults() && options.getApplicationArguments() != null && !options.getApplicationArguments().isEmpty()) - || !nonNullStrList(options.getExecutorOptions()).isEmpty()) { + if ((!config.isOmitDefaults() && + !NBootUtils.isEmptyList(options.getApplicationArguments()) + || !NBootUtils.nonNullStrList(options.getExecutorOptions()).isEmpty())) { arguments.add(selectOptionName("--exec", "-e")); } - arguments.addAll(nonNullStrList(options.getExecutorOptions())); - arguments.addAll(nonNullStrList(options.getApplicationArguments())); + arguments.addAll(NBootUtils.nonNullStrList(options.getExecutorOptions())); + arguments.addAll(NBootUtils.nonNullStrList(options.getApplicationArguments())); return new NBootCmdLine(arguments); } @@ -551,11 +552,4 @@ private boolean isApiVersionOrAfter(String version) { return apiVersionObj.compareTo(version) >= 0; } - private List nonNullStrList(List list) { - if (list == null) { - return new ArrayList<>(); - } - return list; - } - } diff --git a/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/reserved/cmdline/NBootWorkspaceCmdLineParser.java b/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/reserved/cmdline/NBootWorkspaceCmdLineParser.java index 26cb66dbc..1fab1605a 100644 --- a/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/reserved/cmdline/NBootWorkspaceCmdLineParser.java +++ b/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/reserved/cmdline/NBootWorkspaceCmdLineParser.java @@ -1087,11 +1087,7 @@ public static List nextNutsArgument(NBootCmdLine cmdLine, NBootOptions showError.add(NBootMsg.ofC("invalid argument for workspace: %s", a.getImage()).toString()); options.setErrors(showError); } - List applicationArguments = options.getApplicationArguments(); - if (applicationArguments == null) { - applicationArguments = new ArrayList<>(); - } - + List applicationArguments = NBootUtils.nonNullStrList(options.getApplicationArguments()); applicationArguments.addAll(newArgs); options.setApplicationArguments(applicationArguments); } @@ -1218,10 +1214,7 @@ public static List nextNutsArgument(NBootCmdLine cmdLine, NBootOptions } } else { if (options != null) { - List applicationArguments = options.getApplicationArguments(); - if (applicationArguments == null) { - applicationArguments = new ArrayList<>(); - } + List applicationArguments = NBootUtils.nonNullStrList(options.getApplicationArguments()); applicationArguments.add(NBootUtils.firstNonNull(a.toString(), "")); List list = Arrays.asList(cmdLine.toStringArray()); applicationArguments.addAll(list); @@ -1445,10 +1438,7 @@ public static List nextNutsArgument(NBootCmdLine cmdLine, NBootOptions newArgs.addAll(Arrays.asList(cmdLine.toStringArray())); cmdLine.skipAll(); if (options != null) { - List applicationArguments = options.getApplicationArguments(); - if (applicationArguments == null) { - applicationArguments = new ArrayList<>(); - } + List applicationArguments = NBootUtils.nonNullStrList(options.getApplicationArguments()); applicationArguments.addAll(newArgs); options.setApplicationArguments(applicationArguments); } diff --git a/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/reserved/util/NBootLog.java b/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/reserved/util/NBootLog.java index 6fb8614ca..b9e39dabc 100644 --- a/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/reserved/util/NBootLog.java +++ b/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/reserved/util/NBootLog.java @@ -75,6 +75,16 @@ public NBootLog(NBootOptionsBoot bootTerminal) { cachedFileLogLevel = Level.OFF.intValue(); } + public void error(NBootMsg message, Throwable e) { + log(Level.SEVERE, "FAIL",message,e); + } + public void warn(NBootMsg message) { + log(Level.WARNING, "WARNING",message); + } + + public void error(NBootMsg message) { + log(Level.SEVERE, "FAIL",message); + } public void log(Level lvl, String logVerb, NBootMsg message) { if (isLoggableTerm(lvl)) { doLogTerm(lvl, logVerb, message == null ? "" : message.toString()); diff --git a/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/reserved/util/NBootMsg.java b/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/reserved/util/NBootMsg.java index d4ec89275..dbfd6ce5f 100644 --- a/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/reserved/util/NBootMsg.java +++ b/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/reserved/util/NBootMsg.java @@ -109,14 +109,6 @@ public static NBootMsg ofV(String message, Function vars) { return of("VFORMAT", message, new Object[]{vars}, null, null); } - public static NBootMsg ofJ(String message, NBootMsgParam... params) { - if (params == null) { - return ofJ(message, new Object[]{null}); - } - Object[] paramsAsObjects = Arrays.stream(params).map(NBootMsgParam::getValue).toArray(); - return ofJ(message, paramsAsObjects); - } - public static NBootMsg ofC(String message, NBootMsgParam... params) { if (params == null) { return ofC(message, new Object[]{null}); @@ -125,15 +117,6 @@ public static NBootMsg ofC(String message, NBootMsgParam... params) { return ofC(message, paramsAsObjects); } - @Deprecated - public static NBootMsg ofJ(String message) { - return of("JFORMAT", message, NO_PARAMS, null, null); - } - - public static NBootMsg ofJ(String message, Object... params) { - return of("JFORMAT", message, params, null, null); - } - public String getFormat() { return format; } @@ -181,55 +164,6 @@ public String toString() { new Formatter(sb).format((String) message, _preFormatArr(params)); return sb.toString(); } - case "JFORMAT": { - //must process special case of {} - String sMsg = (String) message; - if (sMsg.contains("{}")) { - StringBuilder sb = new StringBuilder(); - char[] chars = sMsg.toCharArray(); - int currentIndex = 0; - for (int i = 0; i < chars.length; i++) { - char c = chars[i]; - if (c == '{') { - StringBuilder sb2 = new StringBuilder(); - i++; - while (i < chars.length) { - char c2 = chars[i]; - if (c2 == '}') { - break; - } else if (c2 == '\\') { - sb2.append(c2); - i++; - if (i < chars.length) { - c2 = chars[i]; - sb2.append(c2); - } - } else { - sb2.append(c2); - } - } - String s2 = sb2.toString(); - if (s2.isEmpty()) { - s2 = String.valueOf(currentIndex); - } else if (s2.trim().startsWith(":")) { - s2 = String.valueOf(currentIndex) + s2; - } - sb.append("{").append(s2).append("}"); - currentIndex++; - } else if (c == '\\') { - sb.append(c); - i++; - if (i < chars.length) { - sb.append(c); - } - } else { - sb.append(c); - } - } - sMsg = sb.toString(); - } - return MessageFormat.format(sMsg, _preFormatArr(params)); - } case "VFORMAT": { return formatAsV(); } diff --git a/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/reserved/util/NBootUtils.java b/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/reserved/util/NBootUtils.java index 0255360f0..6f372ee1c 100644 --- a/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/reserved/util/NBootUtils.java +++ b/core/nuts-boot/src/main/java/net/thevpc/nuts/boot/reserved/util/NBootUtils.java @@ -1438,4 +1438,15 @@ public static String resolveFilePath(NBootId id, String extension) { String fileName = resolveFileName(id, extension); return resolveIdPath(id) + '/' + fileName; } + + public static List nonNullStrList(List list) { + if (list == null) { + return new ArrayList<>(); + } + return list; + } + + public static boolean isEmptyList(List any) { + return any==null || any.isEmpty(); + } } diff --git a/core/nuts-lib/src/main/java/net/thevpc/nuts/util/DefaultNProperties.java b/core/nuts-lib/src/main/java/net/thevpc/nuts/util/DefaultNProperties.java index 90aa3e5f5..82aa50a1e 100644 --- a/core/nuts-lib/src/main/java/net/thevpc/nuts/util/DefaultNProperties.java +++ b/core/nuts-lib/src/main/java/net/thevpc/nuts/util/DefaultNProperties.java @@ -1,7 +1,7 @@ package net.thevpc.nuts.util; import net.thevpc.nuts.NDescriptorProperty; -import net.thevpc.nuts.env.NEnvCondition; +import net.thevpc.nuts.NEnvCondition; import java.util.*; diff --git a/core/nuts-lib/src/main/java/net/thevpc/nuts/util/NCoreArrayUtils.java b/core/nuts-lib/src/main/java/net/thevpc/nuts/util/NCoreArrayUtils.java index 06869325e..51bc18fb7 100644 --- a/core/nuts-lib/src/main/java/net/thevpc/nuts/util/NCoreArrayUtils.java +++ b/core/nuts-lib/src/main/java/net/thevpc/nuts/util/NCoreArrayUtils.java @@ -29,7 +29,7 @@ import java.util.Arrays; import java.util.List; import java.util.Set; -import net.thevpc.nuts.env.NIdLocation; +import net.thevpc.nuts.NIdLocation; /** * diff --git a/core/nuts-lib/src/main/java/net/thevpc/nuts/util/NCoreCollectionUtils.java b/core/nuts-lib/src/main/java/net/thevpc/nuts/util/NCoreCollectionUtils.java index 5eb1e50ba..d1ac7eb37 100644 --- a/core/nuts-lib/src/main/java/net/thevpc/nuts/util/NCoreCollectionUtils.java +++ b/core/nuts-lib/src/main/java/net/thevpc/nuts/util/NCoreCollectionUtils.java @@ -24,7 +24,7 @@ */ package net.thevpc.nuts.util; -import net.thevpc.nuts.env.NIdLocation; +import net.thevpc.nuts.NIdLocation; import java.util.*; import java.util.function.Predicate; diff --git a/core/nuts-lib/src/main/java/net/thevpc/nuts/util/NIOUtils.java b/core/nuts-lib/src/main/java/net/thevpc/nuts/util/NIOUtils.java index 9101f42d0..5f957c7b3 100644 --- a/core/nuts-lib/src/main/java/net/thevpc/nuts/util/NIOUtils.java +++ b/core/nuts-lib/src/main/java/net/thevpc/nuts/util/NIOUtils.java @@ -128,6 +128,9 @@ public static long copy(InputStream in, OutputStream out) { * @return size copied */ public static long copy(InputStream in, OutputStream out, int bufferSize) { + if(bufferSize<=0){ + bufferSize=DEFAULT_BUFFER_SIZE; + } byte[] buffer = new byte[bufferSize]; int len; long count = 0; @@ -150,6 +153,9 @@ public static long copy(InputStream in, OutputStream out, int bufferSize) { * @param bufferSize bufferSize */ public static long copy(Reader in, Writer out, int bufferSize) { + if(bufferSize<=0){ + bufferSize=DEFAULT_BUFFER_SIZE; + } char[] buffer = new char[bufferSize]; int len; long count = 0; diff --git a/core/nuts-lib/src/main/java/net/thevpc/nuts/util/NIndexFirstIterator.java b/core/nuts-lib/src/main/java/net/thevpc/nuts/util/NIndexFirstIterator.java index 3f4d34a2c..fe89ff753 100755 --- a/core/nuts-lib/src/main/java/net/thevpc/nuts/util/NIndexFirstIterator.java +++ b/core/nuts-lib/src/main/java/net/thevpc/nuts/util/NIndexFirstIterator.java @@ -25,12 +25,10 @@ public class NIndexFirstIterator extends NIteratorBase { private long readFromIndex; private T nextItem; private boolean hasNextItem; - private NSession session; - public NIndexFirstIterator(Iterator index, Iterator other, NSession session) { + public NIndexFirstIterator(Iterator index, Iterator other) { this.index = index; this.other = other; - this.session = session; } @Override diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/deprecated/NDeleteFileHelper.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/deprecated/NDeleteFileHelper.java index dacbc6726..5312da7d8 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/deprecated/NDeleteFileHelper.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/deprecated/NDeleteFileHelper.java @@ -1,9 +1,10 @@ package net.thevpc.nuts.runtime.deprecated; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NBootOptions; -import net.thevpc.nuts.env.NBootOptionsBuilder; -import net.thevpc.nuts.env.NStoreType; +import net.thevpc.nuts.NBootOptions; +import net.thevpc.nuts.NBootOptionsBuilder; + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.format.NContentType; import net.thevpc.nuts.log.NLog; import net.thevpc.nuts.log.NLogVerb; @@ -62,7 +63,6 @@ public static long deleteStoreLocations(NBootOptions lastBootOptions, NBootOptio throw new NNoSessionCancelException(NMsg.ofPlain("cancel delete folder")); } } - NConfigs conf = null; List folders = new ArrayList<>(); if (includeRoot) { folders.add(Paths.get(lastBootOptions.getWorkspace().get())); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/optional/jansi/OptionalJansi.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/optional/jansi/OptionalJansi.java index a6ac2b7da..7aea18087 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/optional/jansi/OptionalJansi.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/optional/jansi/OptionalJansi.java @@ -25,7 +25,7 @@ package net.thevpc.nuts.runtime.optional.jansi; import net.thevpc.nuts.NWorkspaceTerminalOptions; -import net.thevpc.nuts.env.NOsFamily; +import net.thevpc.nuts.NOsFamily; import java.io.InputStream; import java.io.PrintStream; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/remote/RemoteNWorkspace.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/remote/RemoteNWorkspace.java index 791930bdf..d637c52b0 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/remote/RemoteNWorkspace.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/remote/RemoteNWorkspace.java @@ -4,7 +4,7 @@ import net.thevpc.nuts.elem.NElement; import net.thevpc.nuts.elem.NElements; import net.thevpc.nuts.elem.NObjectElement; -import net.thevpc.nuts.env.NBootManager; + import net.thevpc.nuts.runtime.standalone.workspace.AbstractNWorkspace; import net.thevpc.nuts.runtime.standalone.xtra.ntalk.NTalkClient; import net.thevpc.nuts.text.NText; @@ -24,7 +24,7 @@ public NElement createCall(String commandName, NElement body) { .set("cmd", commandName) .set("body", body).build(); NText json = e.setValue(q).format(); - String wsURL = NBootManager.of().getBootOptions().getWorkspace().orNull(); + String wsURL = NWorkspace.get().getBootOptions().getWorkspace().orNull(); byte[] result = cli.request("nuts/ws:"+wsURL, json.toString().getBytes()); NObjectElement resultObject = e.parse(result, NObjectElement.class); NElements prv = NElements.of(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNBootOptions.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNBootOptions.java index 4bdbccc72..9bc21b914 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNBootOptions.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNBootOptions.java @@ -11,14 +11,14 @@ * large range of sub managers / repositories. *
*

- * Copyright [2020] [thevpc] - * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 (the "License"); + * Copyright [2020] [thevpc] + * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 (the "License"); * you may not use this file except in compliance with the License. You may obtain * a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html - * 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 + * 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. *
==================================================================== */ @@ -27,7 +27,6 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.boot.*; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.*; import net.thevpc.nuts.format.NContentType; import net.thevpc.nuts.io.NTerminalMode; import net.thevpc.nuts.reserved.NReservedLangUtils; @@ -63,7 +62,7 @@ public class DefaultNBootOptions implements NBootOptions { /** * special */ - private final NBootClassLoaderNode runtimeBootDependencyNode; + private final NClassLoaderNode runtimeBootDependencyNode; /** * special */ @@ -71,7 +70,7 @@ public class DefaultNBootOptions implements NBootOptions { /** * special */ - private final List extensionBootDependencyNodes; + private final List extensionBootDependencyNodes; /** * special @@ -471,8 +470,8 @@ public DefaultNBootOptions(List outputFormatOptions, List custom InputStream stdin, PrintStream stdout, PrintStream stderr, ExecutorService executorService, Instant expireTime, List errors, Boolean skipErrors, String locale, - String theme, String uuid, String bootRepositories, NBootClassLoaderNode runtimeBootDependencyNode, - List extensionBootDescriptors, List extensionBootDependencyNodes, + String theme, String uuid, String bootRepositories, NClassLoaderNode runtimeBootDependencyNode, + List extensionBootDescriptors, List extensionBootDependencyNodes, List classWorldURLs, Set extensionsSet, NBootWorkspaceFactory bootWorkspaceFactory, NBootDescriptor runtimeBootDescriptor, ClassLoader classWorldLoader, NSupportMode desktopLauncher, NSupportMode menuLauncher, NSupportMode userLauncher, Boolean previewRepo, Boolean sharedInstance) { ; @@ -968,7 +967,7 @@ public NOptional getBootRepositories() { } @Override - public NOptional getRuntimeBootDependencyNode() { + public NOptional getRuntimeBootDependencyNode() { return NOptional.ofNamed(runtimeBootDependencyNode, "runtimeBootDependencyNode"); } @@ -978,7 +977,7 @@ public NOptional> getExtensionBootDescriptors() { } @Override - public NOptional> getExtensionBootDependencyNodes() { + public NOptional> getExtensionBootDependencyNodes() { return NOptional.ofNamed(extensionBootDependencyNodes, "extensionBootDependencyNodes"); } @@ -1015,9 +1014,9 @@ public NOptional getRuntimeBootDescriptor() { /// /////////// public NBootOptionsBoot toBootOptions() { - NBootOptionsBoot r=new NBootOptionsBoot(); - r.setApiVersion(this.getApiVersion().map(x->x.toString()).orNull()); - r.setRuntimeId(this.getRuntimeId().map(x->x.toString()).orNull()); + NBootOptionsBoot r = new NBootOptionsBoot(); + r.setApiVersion(this.getApiVersion().map(Object::toString).orNull()); + r.setRuntimeId(this.getRuntimeId().map(Object::toString).orNull()); r.setJavaCommand(this.getJavaCommand().orNull()); r.setJavaOptions(this.getJavaOptions().orNull()); r.setWorkspace(this.getWorkspace().orNull()); @@ -1029,15 +1028,15 @@ public NBootOptionsBoot toBootOptions() { r.setGui(this.getGui().orNull()); r.setUserName(this.getUserName().orNull()); r.setCredentials(this.getCredentials().orNull()); - r.setTerminalMode(this.getTerminalMode().map(x->x.id()).orNull()); + r.setTerminalMode(this.getTerminalMode().map(NTerminalMode::id).orNull()); r.setReadOnly(this.getReadOnly().orNull()); r.setTrace(this.getTrace().orNull()); r.setProgressOptions(this.getProgressOptions().orNull()); { NLogConfig c = this.getLogConfig().orNull(); NBootLogConfig v = null; - if(c!=null){ - v=new NBootLogConfig(); + if (c != null) { + v = new NBootLogConfig(); v.setLogFileBase(c.getLogFileBase()); v.setLogFileLevel(c.getLogFileLevel()); v.setLogFileFilter(c.getLogFileFilter()); @@ -1050,11 +1049,11 @@ public NBootOptionsBoot toBootOptions() { } r.setLogConfig(v); } - r.setConfirm(this.getConfirm().map(x->x.id()).orNull()); - r.setConfirm(this.getConfirm().map(x->x.id()).orNull()); - r.setOutputFormat(this.getOutputFormat().map(x->x.id()).orNull()); + r.setConfirm(this.getConfirm().map(NConfirmationMode::id).orNull()); + r.setConfirm(this.getConfirm().map(NConfirmationMode::id).orNull()); + r.setOutputFormat(this.getOutputFormat().map(NContentType::id).orNull()); r.setOutputFormatOptions(this.getOutputFormatOptions().orNull()); - r.setOpenMode(this.getOpenMode().map(x->x.id()).orNull()); + r.setOpenMode(this.getOpenMode().map(NOpenMode::id).orNull()); r.setCreationTime(this.getCreationTime().orNull()); r.setDry(this.getDry().orNull()); r.setShowStacktrace(this.getShowStacktrace().orNull()); @@ -1066,15 +1065,15 @@ public NBootOptionsBoot toBootOptions() { r.setCommandHelp(this.getCommandHelp().orNull()); r.setDebug(this.getDebug().orNull()); r.setInherited(this.getInherited().orNull()); - r.setExecutionType(this.getExecutionType().map(x->x.id()).orNull()); - r.setRunAs(this.getRunAs().map(x->x.toString()).orNull()); + r.setExecutionType(this.getExecutionType().map(NExecutionType::id).orNull()); + r.setRunAs(this.getRunAs().map(NRunAs::toString).orNull()); r.setArchetype(this.getArchetype().orNull()); - r.setStoreStrategy(this.getStoreStrategy().map(x->x.id()).orNull()); + r.setStoreStrategy(this.getStoreStrategy().map(NStoreStrategy::id).orNull()); { Map c = this.getHomeLocations().orNull(); - Map v =null; - if(c!=null){ - v=new HashMap<>(); + Map v = null; + if (c != null) { + v = new HashMap<>(); for (Map.Entry e : c.entrySet()) { v.put(NBootHomeLocation.of( e.getKey().getOsFamily().id(), @@ -1086,19 +1085,19 @@ public NBootOptionsBoot toBootOptions() { } { Map c = this.getStoreLocations().orNull(); - Map v =null; - if(c!=null){ - v=new HashMap<>(); + Map v = null; + if (c != null) { + v = new HashMap<>(); for (Map.Entry e : c.entrySet()) { v.put(e.getKey().id(), e.getValue()); } } r.setStoreLocations(v); } - r.setStoreLayout(this.getStoreLayout().map(x->x.toString()).orNull()); - r.setStoreStrategy(this.getStoreStrategy().map(x->x.toString()).orNull()); - r.setRepositoryStoreStrategy(this.getRepositoryStoreStrategy().map(x->x.toString()).orNull()); - r.setFetchStrategy(this.getFetchStrategy().map(x->x.toString()).orNull()); + r.setStoreLayout(this.getStoreLayout().map(Enum::toString).orNull()); + r.setStoreStrategy(this.getStoreStrategy().map(Enum::toString).orNull()); + r.setRepositoryStoreStrategy(this.getRepositoryStoreStrategy().map(Enum::toString).orNull()); + r.setFetchStrategy(this.getFetchStrategy().map(Enum::toString).orNull()); r.setCached(this.getCached().orNull()); r.setIndexed(this.getIndexed().orNull()); r.setTransitive(this.getTransitive().orNull()); @@ -1115,25 +1114,56 @@ public NBootOptionsBoot toBootOptions() { r.setApplicationArguments(this.getApplicationArguments().orNull()); r.setCustomOptions(this.getCustomOptions().orNull()); r.setExpireTime(this.getExpireTime().orNull()); - r.setErrors(this.getErrors().isNotPresent()?new ArrayList<>():this.getErrors().get().stream().map(x->x.toString()).collect(Collectors.toList())); + r.setErrors(this.getErrors().isNotPresent() ? new ArrayList<>() : this.getErrors().get().stream().map(NMsg::toString).collect(Collectors.toList())); r.setSkipErrors(this.getSkipErrors().orNull()); r.setSwitchWorkspace(this.getSwitchWorkspace().orNull()); r.setLocale(this.getLocale().orNull()); r.setTheme(this.getTheme().orNull()); r.setDependencySolver(this.getDependencySolver().orNull()); - r.setIsolationLevel(this.getIsolationLevel().map(x->x.id()).orNull()); + r.setIsolationLevel(this.getIsolationLevel().map(NIsolationLevel::id).orNull()); r.setInitLaunchers(this.getInitLaunchers().orNull()); r.setInitJava(this.getInitJava().orNull()); r.setInitScripts(this.getInitScripts().orNull()); r.setInitPlatforms(this.getInitPlatforms().orNull()); - r.setDesktopLauncher(this.getDesktopLauncher().map(x->x.id()).orNull()); - r.setMenuLauncher(this.getMenuLauncher().map(x->x.id()).orNull()); - r.setUserLauncher(this.getUserLauncher().map(x->x.id()).orNull()); + r.setDesktopLauncher(this.getDesktopLauncher().map(NSupportMode::id).orNull()); + r.setMenuLauncher(this.getMenuLauncher().map(NSupportMode::id).orNull()); + r.setUserLauncher(this.getUserLauncher().map(NSupportMode::id).orNull()); r.setSharedInstance(this.getSharedInstance().orNull()); r.setPreviewRepo(this.getPreviewRepo().orNull()); + + r.setBootRepositories(this.getBootRepositories().orNull()); + r.setRuntimeBootDependencyNode(convertNode(this.getRuntimeBootDependencyNode().orNull())); + r.setExtensionBootDescriptors(this.getExtensionBootDescriptors().orNull()); + r.setExtensionBootDependencyNodes(convertNodes(this.getExtensionBootDependencyNodes().orNull())); + r.setBootWorkspaceFactory(this.getBootWorkspaceFactory().orNull()); + r.setClassWorldURLs(this.getClassWorldURLs().orNull()); + r.setClassWorldLoader(this.getClassWorldLoader().orNull()); + r.setUuid(this.getUuid().orNull()); + r.setExtensionsSet(this.getExtensionsSet().orNull()); + r.setRuntimeBootDescriptor(this.getRuntimeBootDescriptor().orNull()); + return r; } + private List convertNodes(List dependencies) { + return dependencies == null ? null : dependencies.stream().map(this::convertNode).collect(Collectors.toList()); + } + + private NBootClassLoaderNode convertNode(NClassLoaderNode n) { + if (n == null) { + return null; + } + List dependencies = n.getDependencies(); + List children = convertNodes(dependencies); + return new NBootClassLoaderNode( + n.getId() == null ? null : n.getId().toString(), + n.getURL(), + n.isEnabled(), + n.isIncludedInClasspath(), + children == null ? null : children.toArray(new NBootClassLoaderNode[0]) + ); + } + @Override public NWorkspaceOptions toWorkspaceOptions() { return builder().toWorkspaceOptions(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNBootOptionsBuilder.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNBootOptionsBuilder.java index 4815eae47..b827f0fb8 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNBootOptionsBuilder.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNBootOptionsBuilder.java @@ -28,11 +28,11 @@ import net.thevpc.nuts.boot.*; import net.thevpc.nuts.cmdline.NCmdLine; import net.thevpc.nuts.cmdline.NWorkspaceCmdLineParser; -import net.thevpc.nuts.env.*; import net.thevpc.nuts.format.NContentType; import net.thevpc.nuts.io.NTerminalMode; import net.thevpc.nuts.log.NLogConfig; import net.thevpc.nuts.reserved.NReservedLangUtils; +import net.thevpc.nuts.runtime.standalone.util.NDefaultClassLoaderNode; import net.thevpc.nuts.spi.NSupportLevelContext; import net.thevpc.nuts.util.*; @@ -422,7 +422,7 @@ public final class DefaultNBootOptionsBuilder implements NBootOptionsBuilder, Se /** * special */ - private NBootClassLoaderNode runtimeBootDependencyNode; + private NClassLoaderNode runtimeBootDependencyNode; /** * special */ @@ -430,7 +430,7 @@ public final class DefaultNBootOptionsBuilder implements NBootOptionsBuilder, Se /** * special */ - private List extensionBootDependencyNodes; + private List extensionBootDependencyNodes; /** * special @@ -691,12 +691,12 @@ public DefaultNBootOptionsBuilder setBootRepositories(String bootRepositories) { return this; } - public NOptional getRuntimeBootDependencyNode() { + public NOptional getRuntimeBootDependencyNode() { return NOptional.of(runtimeBootDependencyNode); } @Override - public DefaultNBootOptionsBuilder setRuntimeBootDependencyNode(NBootClassLoaderNode runtimeBootDependencyNode) { + public DefaultNBootOptionsBuilder setRuntimeBootDependencyNode(NClassLoaderNode runtimeBootDependencyNode) { this.runtimeBootDependencyNode = runtimeBootDependencyNode; return this; } @@ -711,12 +711,12 @@ public DefaultNBootOptionsBuilder setExtensionBootDescriptors(List> getExtensionBootDependencyNodes() { + public NOptional> getExtensionBootDependencyNodes() { return NOptional.of(extensionBootDependencyNodes); } @Override - public DefaultNBootOptionsBuilder setExtensionBootDependencyNodes(List extensionBootDependencyNodes) { + public DefaultNBootOptionsBuilder setExtensionBootDependencyNodes(List extensionBootDependencyNodes) { this.extensionBootDependencyNodes = NReservedLangUtils.nonNullList(extensionBootDependencyNodes); return this; } @@ -2520,9 +2520,9 @@ public NBootOptionsBuilder setAll(NBootOptionsBoot other) { this.setClassWorldLoader(other.getClassWorldLoader()); this.setBootRepositories(other.getBootRepositories()); - this.setRuntimeBootDependencyNode(other.getRuntimeBootDependencyNode()); + this.setRuntimeBootDependencyNode(convertNode(other.getRuntimeBootDependencyNode())); this.setExtensionBootDescriptors(other.getExtensionBootDescriptors()); - this.setExtensionBootDependencyNodes(other.getExtensionBootDependencyNodes()); + this.setExtensionBootDependencyNodes(convertNodes(other.getExtensionBootDependencyNodes())); this.setBootWorkspaceFactory(other.getBootWorkspaceFactory()); this.setClassWorldURLs(other.getClassWorldURLs()); this.setClassWorldLoader(other.getClassWorldLoader()); @@ -2532,7 +2532,24 @@ public NBootOptionsBuilder setAll(NBootOptionsBoot other) { return this; } + private List convertNodes(List dependencies) { + return dependencies == null ? null : dependencies.stream().map(this::convertNode).collect(Collectors.toList()); + } + private NClassLoaderNode convertNode(NBootClassLoaderNode n) { + if (n == null) { + return null; + } + List dependencies = n.getDependencies(); + List children = convertNodes(dependencies); + return new NDefaultClassLoaderNode( + NBlankable.isBlank(n.getId()) ? null : NId.of(n.getId()).get(), + n.getURL(), + n.isEnabled(), + n.isIncludedInClasspath(), + children == null ? null : children.toArray(new NClassLoaderNode[0]) + ); + } @Override public NBootOptionsBuilder setCmdLine(String cmdLine) { setCmdLine(NCmdLine.parseDefault(cmdLine).get().toStringArray()); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNDependency.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNDependency.java index 82cabcd21..311b7a66c 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNDependency.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNDependency.java @@ -25,7 +25,7 @@ package net.thevpc.nuts.runtime.standalone; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NEnvCondition; +import net.thevpc.nuts.NEnvCondition; import net.thevpc.nuts.reserved.NReservedLangUtils; import net.thevpc.nuts.reserved.NReservedUtils; import net.thevpc.nuts.util.NBlankable; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNDependencyBuilder.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNDependencyBuilder.java index 906f100fa..d19463575 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNDependencyBuilder.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNDependencyBuilder.java @@ -26,8 +26,8 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.boot.NBootDependency; -import net.thevpc.nuts.env.NEnvCondition; -import net.thevpc.nuts.env.NEnvConditionBuilder; +import net.thevpc.nuts.NEnvCondition; +import net.thevpc.nuts.NEnvConditionBuilder; import net.thevpc.nuts.reserved.NReservedLangUtils; import net.thevpc.nuts.reserved.NReservedUtils; import net.thevpc.nuts.spi.NSupportLevelContext; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNDescriptor.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNDescriptor.java index 4e8f900a4..a01249147 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNDescriptor.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNDescriptor.java @@ -26,8 +26,8 @@ package net.thevpc.nuts.runtime.standalone; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NEnvCondition; -import net.thevpc.nuts.env.NIdLocation; +import net.thevpc.nuts.NEnvCondition; +import net.thevpc.nuts.NIdLocation; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.reserved.NReservedLangUtils; import net.thevpc.nuts.util.*; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNDescriptorBuilder.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNDescriptorBuilder.java index 767adf429..526eb53c5 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNDescriptorBuilder.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNDescriptorBuilder.java @@ -28,9 +28,9 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.boot.NBootDescriptor; -import net.thevpc.nuts.env.NEnvCondition; -import net.thevpc.nuts.env.NEnvConditionBuilder; -import net.thevpc.nuts.env.NIdLocation; +import net.thevpc.nuts.NEnvCondition; +import net.thevpc.nuts.NEnvConditionBuilder; +import net.thevpc.nuts.NIdLocation; import net.thevpc.nuts.spi.NSupportLevelContext; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.reserved.NReservedLangUtils; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNDescriptorProperty.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNDescriptorProperty.java index 7d51e30f3..f1b47d674 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNDescriptorProperty.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNDescriptorProperty.java @@ -3,7 +3,7 @@ import net.thevpc.nuts.NDescriptorProperty; import net.thevpc.nuts.NDescriptorPropertyBuilder; -import net.thevpc.nuts.env.NEnvCondition; +import net.thevpc.nuts.NEnvCondition; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.util.NLiteral; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNDescriptorPropertyBuilder.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNDescriptorPropertyBuilder.java index 84ba90410..b43178641 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNDescriptorPropertyBuilder.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNDescriptorPropertyBuilder.java @@ -28,8 +28,8 @@ import net.thevpc.nuts.NDescriptorProperty; import net.thevpc.nuts.NDescriptorPropertyBuilder; -import net.thevpc.nuts.env.NEnvCondition; -import net.thevpc.nuts.env.NEnvConditionBuilder; +import net.thevpc.nuts.NEnvCondition; +import net.thevpc.nuts.NEnvConditionBuilder; import net.thevpc.nuts.boot.NBootDescriptorProperty; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.util.NLiteral; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNEnvConditionBuilder.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNEnvConditionBuilder.java index c28542dbf..33055615c 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNEnvConditionBuilder.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNEnvConditionBuilder.java @@ -25,10 +25,10 @@ */ package net.thevpc.nuts.runtime.standalone; -import net.thevpc.nuts.env.DefaultNEnvCondition; +import net.thevpc.nuts.DefaultNEnvCondition; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NEnvCondition; -import net.thevpc.nuts.env.NEnvConditionBuilder; +import net.thevpc.nuts.NEnvCondition; +import net.thevpc.nuts.NEnvConditionBuilder; import net.thevpc.nuts.boot.NBootEnvCondition; import net.thevpc.nuts.reserved.NReservedLangUtils; import net.thevpc.nuts.reserved.NReservedUtils; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNIdBuilder.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNIdBuilder.java index eb8aed24c..b8beb1e9a 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNIdBuilder.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNIdBuilder.java @@ -26,8 +26,8 @@ package net.thevpc.nuts.runtime.standalone; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NEnvCondition; -import net.thevpc.nuts.env.NEnvConditionBuilder; +import net.thevpc.nuts.NEnvCondition; +import net.thevpc.nuts.NEnvConditionBuilder; import net.thevpc.nuts.reserved.NReservedLangUtils; import net.thevpc.nuts.reserved.NReservedUtils; import net.thevpc.nuts.spi.NSupportLevelContext; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNWorkspaceOptions.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNWorkspaceOptions.java index af2db4934..f0a7ffd25 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNWorkspaceOptions.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNWorkspaceOptions.java @@ -29,7 +29,6 @@ import net.thevpc.nuts.boot.NBootHomeLocation; import net.thevpc.nuts.boot.NBootLogConfig; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.*; import net.thevpc.nuts.format.NContentType; import net.thevpc.nuts.reserved.NReservedLangUtils; import net.thevpc.nuts.reserved.NReservedWorkspaceOptionsToCmdLineBuilder; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNWorkspaceOptionsBuilder.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNWorkspaceOptionsBuilder.java index 4fbb4d244..fa9704f73 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNWorkspaceOptionsBuilder.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/DefaultNWorkspaceOptionsBuilder.java @@ -29,7 +29,6 @@ import net.thevpc.nuts.boot.NBootHomeLocation; import net.thevpc.nuts.boot.NBootLogConfig; import net.thevpc.nuts.cmdline.NWorkspaceCmdLineParser; -import net.thevpc.nuts.env.*; import net.thevpc.nuts.reserved.NReservedLangUtils; import net.thevpc.nuts.spi.NSupportLevelContext; import net.thevpc.nuts.util.NBlankable; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/NLocationKey.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/NLocationKey.java index 963c034b5..98401a257 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/NLocationKey.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/NLocationKey.java @@ -1,7 +1,7 @@ package net.thevpc.nuts.runtime.standalone; import net.thevpc.nuts.NId; -import net.thevpc.nuts.env.NStoreType; +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.util.NAssert; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.util.NStringUtils; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/NWsConfDB.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/NWsConfDB.java index e24fd9a39..52f489f2e 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/NWsConfDB.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/NWsConfDB.java @@ -1,8 +1,7 @@ package net.thevpc.nuts.runtime.standalone; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.NSession; import net.thevpc.nuts.NWorkspace; + import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.util.NBlankable; @@ -18,8 +17,7 @@ public void storeStringNonBlank(NLocationKey k, String value) { } public void storeString(NLocationKey k, String value, boolean deleteIfBlank) { - NSession session = ws.currentSession(); - NPath path = NLocations.of().getStoreLocation(k.getId(), k.getStoreType(), k.getRepoUuid()) + NPath path = NWorkspace.get().getStoreLocation(k.getId(), k.getStoreType(), k.getRepoUuid()) .resolve(k.getName()); if (NBlankable.isBlank(value) && deleteIfBlank) { if (path.isRegularFile()) { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/NAppImpl.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/NAppImpl.java index a8c90e7f1..8936de934 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/NAppImpl.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/NAppImpl.java @@ -3,8 +3,8 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; import net.thevpc.nuts.cmdline.*; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.io.NPrintStream; import net.thevpc.nuts.runtime.standalone.app.cmdline.NCmdLineUtils; @@ -182,10 +182,10 @@ public void prepare(NAppInitInfo appInitInfo) { this.args = (args); this.id = (_appId); this.appClass = appClass == null ? null : JavaClassUtils.unwrapCGLib(appClass); - NLocations locations = NLocations.of(); + NWorkspace workspace = NWorkspace.get(); for (NStoreType folder : NStoreType.values()) { - this.setFolder(folder, locations.getStoreLocation(this.id, folder)); - this.setSharedFolder(folder, locations.getStoreLocation(this.id.builder().setVersion("SHARED").build(), folder)); + this.setFolder(folder, workspace.getStoreLocation(this.id, folder)); + this.setSharedFolder(folder, workspace.getStoreLocation(this.id.builder().setVersion("SHARED").build(), folder)); } if (this.mode == NApplicationMode.AUTO_COMPLETE) { //TODO fix me @@ -317,7 +317,7 @@ public NPath getVersionFolder(NStoreType location, String version) { return r; } } - return NLocations.of().getStoreLocation(newId, location); + return NWorkspace.get().getStoreLocation(newId, location); } @Override diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/DefaultNCmdLineFormat.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/DefaultNCmdLineFormat.java index b482591c1..d8006549c 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/DefaultNCmdLineFormat.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/DefaultNCmdLineFormat.java @@ -6,7 +6,7 @@ import net.thevpc.nuts.format.NCmdLineFormat; import net.thevpc.nuts.cmdline.NCmdLineFormatStrategy; import net.thevpc.nuts.cmdline.NCmdLines; -import net.thevpc.nuts.env.NShellFamily; +import net.thevpc.nuts.NShellFamily; import net.thevpc.nuts.io.NPrintStream; import net.thevpc.nuts.runtime.standalone.format.DefaultFormatBase; import net.thevpc.nuts.runtime.standalone.shell.NShellHelper; @@ -41,7 +41,6 @@ public NCmdLineFormat setValue(String[] args) { @Override public NCmdLineFormat setValue(String args) { - NSession session=getWorkspace().currentSession(); return setValue(args == null ? null : NCmdLines.of().parseCmdLine(args)); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/DefaultNCmdLines.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/DefaultNCmdLines.java index 5c5068a09..24a9c4cf1 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/DefaultNCmdLines.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/DefaultNCmdLines.java @@ -7,8 +7,8 @@ import net.thevpc.nuts.cmdline.NArgName; import net.thevpc.nuts.cmdline.NCmdLine; import net.thevpc.nuts.cmdline.NCmdLines; -import net.thevpc.nuts.env.NEnvs; -import net.thevpc.nuts.env.NShellFamily; + +import net.thevpc.nuts.NShellFamily; import net.thevpc.nuts.runtime.standalone.app.cmdline.option.*; import net.thevpc.nuts.runtime.standalone.shell.NShellHelper; import net.thevpc.nuts.spi.NSupportLevelContext; @@ -43,7 +43,7 @@ public NCmdLine parseCmdLine(String line) { private String[] parseCmdLineArr(String line) { NShellFamily f = getShellFamily(); if (f == null) { - f = NEnvs.of().getShellFamily(); + f = NWorkspace.get().getShellFamily(); } if (f == null) { f = NShellFamily.getCurrent(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/option/GroupNonOption.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/option/GroupNonOption.java index 5ddf09dd4..2dc32b68c 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/option/GroupNonOption.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/option/GroupNonOption.java @@ -30,8 +30,8 @@ import net.thevpc.nuts.cmdline.DefaultNArgCandidate; import net.thevpc.nuts.cmdline.NArgCandidate; import net.thevpc.nuts.cmdline.NCmdLineAutoComplete; -import net.thevpc.nuts.env.NUser; -import net.thevpc.nuts.env.NUserConfig; +import net.thevpc.nuts.NUser; +import net.thevpc.nuts.NUserConfig; import java.util.ArrayList; import java.util.List; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/option/PermissionNonOption.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/option/PermissionNonOption.java index 0fe1eee6a..c17106120 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/option/PermissionNonOption.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/option/PermissionNonOption.java @@ -31,7 +31,7 @@ import net.thevpc.nuts.cmdline.DefaultNArgCandidate; import net.thevpc.nuts.cmdline.NArgCandidate; import net.thevpc.nuts.cmdline.NCmdLineAutoComplete; -import net.thevpc.nuts.env.NUser; +import net.thevpc.nuts.NUser; import java.util.*; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/option/RepositoryNonOption.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/option/RepositoryNonOption.java index 95c46b9a9..5c220f1b7 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/option/RepositoryNonOption.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/option/RepositoryNonOption.java @@ -57,7 +57,7 @@ public List getCandidates(NCmdLineAutoComplete context) { } } }else{ - for (NRepository repo : NRepositories.of().getRepositories()) { + for (NRepository repo : NWorkspace.get().getRepositories()) { all.add(new DefaultNArgCandidate(repo.getName())); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/option/RepositoryTypeNonOption.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/option/RepositoryTypeNonOption.java index 207a416ba..f847973d5 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/option/RepositoryTypeNonOption.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/option/RepositoryTypeNonOption.java @@ -31,6 +31,7 @@ import net.thevpc.nuts.cmdline.DefaultNArgCandidate; import net.thevpc.nuts.cmdline.NArgCandidate; import net.thevpc.nuts.cmdline.NCmdLineAutoComplete; + import net.thevpc.nuts.runtime.standalone.repository.util.NRepositoryUtils; import net.thevpc.nuts.util.NBlankable; @@ -53,8 +54,7 @@ public List getCandidates(NCmdLineAutoComplete context) { TreeSet allValid = new TreeSet<>(); allValid.add(NConstants.RepoTypes.NUTS); allValid.add(NConstants.RepoTypes.MAVEN); - for (NAddRepositoryOptions repo : NConfigs.of() - .getDefaultRepositories()) { + for (NAddRepositoryOptions repo : NWorkspace.get().getDefaultRepositories()) { if(repo.getConfig()!=null) { String t = NRepositoryUtils.getRepoType(repo.getConfig()); if(!NBlankable.isBlank(t)){ diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/option/UserNonOption.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/option/UserNonOption.java index ac1b5688e..098646872 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/option/UserNonOption.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/app/cmdline/option/UserNonOption.java @@ -28,7 +28,7 @@ import net.thevpc.nuts.cmdline.DefaultNArgCandidate; import net.thevpc.nuts.cmdline.NArgCandidate; import net.thevpc.nuts.cmdline.NCmdLineAutoComplete; -import net.thevpc.nuts.env.NUser; +import net.thevpc.nuts.NUser; import java.util.ArrayList; import java.util.List; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/boot/DefaultNBootManager.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/boot/DefaultNBootManager.java deleted file mode 100644 index de1bc9653..000000000 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/boot/DefaultNBootManager.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * ==================================================================== - * Nuts : Network Updatable Things Service - * (universal package manager) - *
- * is a new Open Source Package Manager to help install packages and libraries - * for runtime execution. Nuts is the ultimate companion for maven (and other - * build managers) as it helps installing all package dependencies at runtime. - * Nuts is not tied to java and is a good choice to share shell scripts and - * other 'things' . Its based on an extensible architecture to help supporting a - * large range of sub managers / repositories. - *
- *

- * Copyright [2020] [thevpc] - * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 (the "License"); - * you may not use this file except in compliance with the License. You may obtain - * a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html - * 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 net.thevpc.nuts.runtime.standalone.boot; - -import net.thevpc.nuts.*; -import net.thevpc.nuts.boot.NBootClassLoaderNode; -import net.thevpc.nuts.env.NBootManager; -import net.thevpc.nuts.env.NBootOptions; -import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.NWorkspaceTerminalOptions; -import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; -import net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNConfigs; -import net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNWorkspaceConfigModel; -import net.thevpc.nuts.spi.NSupportLevelContext; -import net.thevpc.nuts.util.NLiteral; -import net.thevpc.nuts.util.NOptional; - -import java.net.URL; -import java.time.Duration; -import java.time.Instant; -import java.util.Collections; -import java.util.List; - -/** - * @author thevpc - */ -public class DefaultNBootManager implements NBootManager { - - private DefaultNBootModel model; - - public DefaultNBootManager(NWorkspace ws) { - NWorkspaceExt e = (NWorkspaceExt) ws; - this.model = e.getModel().bootModel; - } - - @Override - public int getSupportLevel(NSupportLevelContext context) { - return NConstants.Support.DEFAULT_SUPPORT; - } - - public NBootModel getModel() { - return model; - } - - @Override - public boolean isFirstBoot() { - return model.isFirstBoot(); - } - - @Override - public NOptional getCustomBootOption(String... names) { - return model.getCustomBootOption(names); - } - - - @Override - public NBootOptions getBootOptions() { - return _configModel().getBootModel().getBootEffectiveOptions(); - } - - @Override - public ClassLoader getBootClassLoader() { - return _configModel().getBootClassLoader(); - } - - @Override - public List getBootClassWorldURLs() { - return Collections.unmodifiableList(_configModel().getBootClassWorldURLs()); - } - - @Override - public String getBootRepositories() { - return _configModel().getBootRepositories(); - } - - @Override - public Instant getCreationStartTime() { - return _configModel().getCreationStartTime(); - } - - @Override - public Instant getCreationFinishTime() { - return _configModel().getCreationFinishTime(); - } - - @Override - public Duration getCreationDuration() { - return _configModel().getCreateDuration(); - } - - public NBootClassLoaderNode getBootRuntimeClassLoaderNode() { - return model.bOptions.getRuntimeBootDependencyNode().get(); - } - - public List getBootExtensionClassLoaderNode() { - return model.bOptions.getExtensionBootDependencyNodes().orElseGet(Collections::emptyList); - } - - @Override - public NWorkspaceTerminalOptions getBootTerminal() { - return model.getBootTerminal(); - } - - private DefaultNWorkspaceConfigModel _configModel() { - DefaultNConfigs config = (DefaultNConfigs) NConfigs.of(); - DefaultNWorkspaceConfigModel configModel = config.getModel(); - return configModel; - } - -} diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/boot/DefaultNBootModel.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/boot/DefaultNBootModel.java index 7645fc68f..c32d2a33d 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/boot/DefaultNBootModel.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/boot/DefaultNBootModel.java @@ -25,10 +25,11 @@ package net.thevpc.nuts.runtime.standalone.boot; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NBootManager; -import net.thevpc.nuts.env.NBootOptions; + +import net.thevpc.nuts.NBootOptions; import net.thevpc.nuts.NWorkspaceTerminalOptions; import net.thevpc.nuts.cmdline.DefaultNArg; + import net.thevpc.nuts.ext.NExtensions; import net.thevpc.nuts.io.NPrintStream; import net.thevpc.nuts.io.NSystemTerminal; @@ -49,7 +50,7 @@ import net.thevpc.nuts.util.NLiteral; import net.thevpc.nuts.util.NMsg; import net.thevpc.nuts.util.NOptional; -import net.thevpc.nuts.env.NOsFamily; +import net.thevpc.nuts.NOsFamily; import java.io.InputStream; import java.io.OutputStream; @@ -245,9 +246,8 @@ public void enableRichTerm() { if (st.isAutoCompleteSupported()) { //that's ok } else { - NSession session=getWorkspace().currentSession(); NId extId = NId.of("net.thevpc.nuts.ext:next-term#" + workspace.getApiVersion()).get(); - if (!NExtensions.of().isExcludedExtension(extId.toString(), NBootManager.of().getBootOptions().toWorkspaceOptions())) { + if (!NExtensions.of().isExcludedExtension(extId.toString(), NWorkspace.get().getBootOptions().toWorkspaceOptions())) { NExtensions extensions = NExtensions.of(); extensions.loadExtension(extId); NSystemTerminal systemTerminal = createSystemTerminal( diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/boot/DefaultNBootWorkspaceFactory.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/boot/DefaultNBootWorkspaceFactory.java index 184ee9ed6..4b6489073 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/boot/DefaultNBootWorkspaceFactory.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/boot/DefaultNBootWorkspaceFactory.java @@ -28,7 +28,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.boot.*; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NBootOptions; +import net.thevpc.nuts.NBootOptions; import net.thevpc.nuts.log.NLog; import net.thevpc.nuts.log.NLogOp; import net.thevpc.nuts.log.NLogVerb; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/boot/NBootConfig.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/boot/NBootConfig.java index e38a2eec8..d6249d0b6 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/boot/NBootConfig.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/boot/NBootConfig.java @@ -27,13 +27,13 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NHomeLocation; -import net.thevpc.nuts.env.NStoreStrategy; -import net.thevpc.nuts.env.NStoreType; +import net.thevpc.nuts.NHomeLocation; +import net.thevpc.nuts.NStoreStrategy; +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.util.NCoreCollectionUtils; import net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNWorkspaceCurrentConfig; import net.thevpc.nuts.util.NBlankable; -import net.thevpc.nuts.env.NOsFamily; +import net.thevpc.nuts.NOsFamily; import java.io.Serializable; import java.util.LinkedHashMap; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/filter/InternalNDependencyFilters.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/filter/InternalNDependencyFilters.java index 89392d075..0b19368bd 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/filter/InternalNDependencyFilters.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/filter/InternalNDependencyFilters.java @@ -2,7 +2,6 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.*; import net.thevpc.nuts.runtime.standalone.util.filters.InternalNTypedFilters; import net.thevpc.nuts.spi.NSupportLevelContext; import net.thevpc.nuts.util.NAssert; @@ -185,16 +184,16 @@ public NDependencyFilter byOs(Collection os) { @Override public NDependencyFilter byCurrentDesktop() { - return byDesktop(NEnvs.of().getDesktopEnvironmentFamilies()); + return byDesktop(NWorkspace.get().getDesktopEnvironmentFamilies()); } public NDependencyFilter byCurrentArch() { - return byArch(NEnvs.of().getArchFamily()); + return byArch(NWorkspace.get().getArchFamily()); } @Override public NDependencyFilter byCurrentOs() { - return byOs(NEnvs.of().getOsFamily()); + return byOs(NWorkspace.get().getOsFamily()); } @Override diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/filter/NDependencyArchFamilyFilter.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/filter/NDependencyArchFamilyFilter.java index ee9c936a3..d0bb336a8 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/filter/NDependencyArchFamilyFilter.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/filter/NDependencyArchFamilyFilter.java @@ -3,7 +3,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.runtime.standalone.util.CoreStringUtils; import net.thevpc.nuts.runtime.standalone.xtra.expr.StringTokenizerUtils; -import net.thevpc.nuts.env.NArchFamily; +import net.thevpc.nuts.NArchFamily; import net.thevpc.nuts.util.NFilterOp; import java.util.Collection; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/filter/NDependencyDEFilter.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/filter/NDependencyDEFilter.java index e43cfdfc2..8be12e7bf 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/filter/NDependencyDEFilter.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/filter/NDependencyDEFilter.java @@ -1,7 +1,7 @@ package net.thevpc.nuts.runtime.standalone.dependency.filter; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NDesktopEnvironmentFamily; +import net.thevpc.nuts.NDesktopEnvironmentFamily; import net.thevpc.nuts.runtime.standalone.util.CoreStringUtils; import net.thevpc.nuts.runtime.standalone.xtra.expr.StringTokenizerUtils; import net.thevpc.nuts.util.NFilterOp; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/filter/NDependencyOsFilter.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/filter/NDependencyOsFilter.java index 2d41f0b8f..0acad3a52 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/filter/NDependencyOsFilter.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/filter/NDependencyOsFilter.java @@ -3,7 +3,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.runtime.standalone.util.CoreStringUtils; import net.thevpc.nuts.runtime.standalone.xtra.expr.StringTokenizerUtils; -import net.thevpc.nuts.env.NOsFamily; +import net.thevpc.nuts.NOsFamily; import net.thevpc.nuts.util.NFilterOp; import java.util.Collection; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/filter/NDependencyPlatformFamilyFilter.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/filter/NDependencyPlatformFamilyFilter.java index 2b40aee9d..25a7a5c17 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/filter/NDependencyPlatformFamilyFilter.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/filter/NDependencyPlatformFamilyFilter.java @@ -2,7 +2,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.runtime.standalone.util.CoreStringUtils; -import net.thevpc.nuts.env.NPlatformFamily; +import net.thevpc.nuts.NPlatformFamily; import net.thevpc.nuts.util.NFilterOp; import java.util.Collection; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/solver/DefaultNDependencySolvers.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/solver/DefaultNDependencySolvers.java index 3dab59f15..cfc8155ad 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/solver/DefaultNDependencySolvers.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/solver/DefaultNDependencySolvers.java @@ -2,7 +2,8 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNConfigs; + +import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; import net.thevpc.nuts.spi.NDependencySolvers; import net.thevpc.nuts.spi.NDependencySolver; import net.thevpc.nuts.spi.NSupportLevelContext; @@ -23,14 +24,12 @@ public NDependencySolver createSolver() { @Override public NDependencySolver createSolver(String solverName) { - DefaultNConfigs config = (DefaultNConfigs) NConfigs.of(); - return config.createDependencySolver(solverName); + return NWorkspaceExt.of().createDependencySolver(solverName); } @Override public List getSolverNames() { - DefaultNConfigs config = (DefaultNConfigs)NConfigs.of(); - return config.getDependencySolverNames(); + return NWorkspaceExt.of().getDependencySolverNames(); } @Override diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/solver/MavenNDependencySolver.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/solver/MavenNDependencySolver.java index abe0ace7d..6af856d9c 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/solver/MavenNDependencySolver.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/solver/MavenNDependencySolver.java @@ -27,7 +27,7 @@ public MavenNDependencySolver(NWorkspace workspace) { this.workspace = workspace; } - ; + public NDependencySolver addRootId(NId id) { pending.add(new RootInfo(id.toDependency(), null)); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/util/NClassLoaderUtils.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/util/NClassLoaderUtils.java index e08ce63e3..e1faa0fdc 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/util/NClassLoaderUtils.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/dependency/util/NClassLoaderUtils.java @@ -30,34 +30,42 @@ import java.util.*; import net.thevpc.nuts.*; -import net.thevpc.nuts.boot.NBootClassLoaderNode; import net.thevpc.nuts.io.NPath; +import net.thevpc.nuts.runtime.standalone.util.NDefaultClassLoaderNode; /** * @author thevpc */ public final class NClassLoaderUtils { - public static NBootClassLoaderNode definitionToClassLoaderNode(NDefinition def, NRepositoryFilter repositoryFilter) { + public static NClassLoaderNode definitionToClassLoaderNodeSafer(NDefinition def, NRepositoryFilter repositoryFilter) { + try { + return definitionToClassLoaderNode(def, repositoryFilter); + }catch (NNotFoundException ex){ + return definitionToClassLoaderNode(def, null); + } + } + + public static NClassLoaderNode definitionToClassLoaderNode(NDefinition def, NRepositoryFilter repositoryFilter) { def.getDependencies().get(); def.getContent().get(); def.getContent().flatMap(NPath::toURL).get(); - return new NBootClassLoaderNode( - def.getId().toString(), + return new NDefaultClassLoaderNode( + def.getId(), def.getContent().flatMap(NPath::toURL).orNull(), true, true, def.getDependencies().get().transitiveWithSource().stream().map(x -> toClassLoaderNodeWithOptional(x, false, repositoryFilter)) .filter(Objects::nonNull) - .toArray(NBootClassLoaderNode[]::new) + .toArray(NClassLoaderNode[]::new) ); } - private static NBootClassLoaderNode toClassLoaderNode(NDependencyTreeNode d, boolean withChildren, NRepositoryFilter repositoryFilter) { + private static NClassLoaderNode toClassLoaderNode(NDependencyTreeNode d, boolean withChildren, NRepositoryFilter repositoryFilter) { return toClassLoaderNodeWithOptional(d, false, withChildren, repositoryFilter); } - private static NBootClassLoaderNode toClassLoaderNodeWithOptional(NDependency d, boolean isOptional, NRepositoryFilter repositoryFilter) { + private static NClassLoaderNode toClassLoaderNodeWithOptional(NDependency d, boolean isOptional, NRepositoryFilter repositoryFilter) { NPath cc = null; if (!isOptional) { if (!NDependencyUtils.isRequiredDependency(d)) { @@ -75,10 +83,10 @@ private static NBootClassLoaderNode toClassLoaderNodeWithOptional(NDependency d, if (cc != null) { URL url = cc.toURL().orNull(); if (url != null) { - List aa = new ArrayList<>(); - return new NBootClassLoaderNode( - id.toString(), url, true, true, - aa.toArray(new NBootClassLoaderNode[0]) + List aa = new ArrayList<>(); + return new NDefaultClassLoaderNode( + id, url, true, true, + aa.toArray(new NClassLoaderNode[0]) ); } } @@ -88,7 +96,7 @@ private static NBootClassLoaderNode toClassLoaderNodeWithOptional(NDependency d, throw new NNotFoundException(id); } - private static NBootClassLoaderNode toClassLoaderNodeWithOptional(NDependencyTreeNode d, boolean isOptional, boolean withChildren, NRepositoryFilter repositoryFilter) { + private static NClassLoaderNode toClassLoaderNodeWithOptional(NDependencyTreeNode d, boolean isOptional, boolean withChildren, NRepositoryFilter repositoryFilter) { NPath cc = null; if (!isOptional) { if (!NDependencyUtils.isRequiredDependency(d.getDependency())) { @@ -105,18 +113,18 @@ private static NBootClassLoaderNode toClassLoaderNodeWithOptional(NDependencyTre if (cc != null) { URL url = cc.toURL().orNull(); if (url != null) { - List aa = new ArrayList<>(); + List aa = new ArrayList<>(); if (withChildren) { for (NDependencyTreeNode child : d.getChildren()) { - NBootClassLoaderNode q = toClassLoaderNodeWithOptional(child, isOptional, true, repositoryFilter); + NClassLoaderNode q = toClassLoaderNodeWithOptional(child, isOptional, true, repositoryFilter); if (q != null) { aa.add(q); } } } - return new NBootClassLoaderNode( - d.getDependency().toId().toString(), url, true, true, - aa.toArray(new NBootClassLoaderNode[0]) + return new NDefaultClassLoaderNode( + d.getDependency().toId(), url, true, true, + aa.toArray(new NClassLoaderNode[0]) ); } } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/descriptor/DelegateNDescriptor.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/descriptor/DelegateNDescriptor.java index 17e934e80..b0d330030 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/descriptor/DelegateNDescriptor.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/descriptor/DelegateNDescriptor.java @@ -26,8 +26,8 @@ package net.thevpc.nuts.runtime.standalone.descriptor; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NEnvCondition; -import net.thevpc.nuts.env.NIdLocation; +import net.thevpc.nuts.NEnvCondition; +import net.thevpc.nuts.NIdLocation; import net.thevpc.nuts.util.NLiteral; import net.thevpc.nuts.util.NOptional; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/descriptor/util/NDescriptorUtils.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/descriptor/util/NDescriptorUtils.java index f3b383186..e95705173 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/descriptor/util/NDescriptorUtils.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/descriptor/util/NDescriptorUtils.java @@ -1,8 +1,8 @@ package net.thevpc.nuts.runtime.standalone.descriptor.util; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NEnvCondition; -import net.thevpc.nuts.env.NEnvConditionBuilder; +import net.thevpc.nuts.NEnvCondition; +import net.thevpc.nuts.NEnvConditionBuilder; import net.thevpc.nuts.runtime.standalone.DefaultNDescriptorBuilder; import net.thevpc.nuts.runtime.standalone.DefaultNEnvConditionBuilder; import net.thevpc.nuts.util.NBlankable; @@ -107,16 +107,15 @@ public static void checkValidEffectiveDescriptor(NDescriptor effectiveDescriptor CoreNIdUtils.checkValidEffectiveId(effectiveDescriptor.getId()); for (NDependency dependency : effectiveDescriptor.getDependencies()) { if (!CoreNIdUtils.isValidEffectiveId(dependency.toId())) { - if (dependency.isOptional()) { - NLogOp.of(NDescriptorUtils.class) - .verb(NLogVerb.WARNING).level(Level.FINE) - .log(NMsg.ofJ("{0} is using dependency {1} which defines an unresolved variable. This is a potential bug.", - effectiveDescriptor.getId(), - dependency - )); - } else { + NLogOp.of(NDescriptorUtils.class) + .verb(NLogVerb.WARNING).level(Level.FINE) + .log(NMsg.ofJ("{0} is using dependency {1} which defines an unresolved variable. This is a potential bug.", + effectiveDescriptor.getId(), + dependency + )); + if (!dependency.isOptional()) { topException = true; - throw new NIllegalArgumentException(NMsg.ofJ("{0} is using dependency {1} which defines an unresolved variable. This is a potential bug.", + throw new NNotFoundException(effectiveDescriptor.getId(), NMsg.ofJ("{0} is using dependency {1} which defines an unresolved variable. This is a potential bug.", effectiveDescriptor.getId(), dependency )); @@ -124,7 +123,6 @@ public static void checkValidEffectiveDescriptor(NDescriptor effectiveDescriptor } } for (NDependency dependency : effectiveDescriptor.getStandardDependencies()) { - //NutsIdUtils.checkValidEffectiveId(dependency.toId(),session); // replace direct call to checkValidEffectiveId with the following... if (!CoreNIdUtils.isValidEffectiveId(dependency.toId())) { // sometimes the variable is defined later in the pom that uses this POM standard Dependencies @@ -142,6 +140,8 @@ public static void checkValidEffectiveDescriptor(NDescriptor effectiveDescriptor throw ex; } throw new NIllegalArgumentException(NMsg.ofC("unable to evaluate effective descriptor for %s", effectiveDescriptor.getId()), ex); + } catch (NNotFoundException ex) { + throw new NNotFoundException(effectiveDescriptor.getId(), NMsg.ofC("unable to evaluate effective descriptor for %s", effectiveDescriptor.getId()), ex); } catch (Exception ex) { throw new NIllegalArgumentException(NMsg.ofC("unable to evaluate effective descriptor for %s", effectiveDescriptor.getId()), ex); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/elem/DefaultNElementFactoryService.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/elem/DefaultNElementFactoryService.java index ecf12b2bb..d4a353b1f 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/elem/DefaultNElementFactoryService.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/elem/DefaultNElementFactoryService.java @@ -30,9 +30,9 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NEnvCondition; -import net.thevpc.nuts.env.NEnvConditionBuilder; -import net.thevpc.nuts.env.NIdLocation; +import net.thevpc.nuts.NEnvCondition; +import net.thevpc.nuts.NEnvConditionBuilder; +import net.thevpc.nuts.NIdLocation; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.elem.mapper.*; import net.thevpc.nuts.runtime.standalone.format.xml.NElementFactoryXmlDocument; @@ -222,7 +222,6 @@ public NElementMapper getMapper(Type type, boolean defaultOnly) { return F_NULL; } Class cls = ReflectUtils.getRawClass(type); - NSession session = workspace.currentSession(); if(NSession.class.isAssignableFrom(cls)){ throw new NIllegalArgumentException(NMsg.ofC( "%s is not serializable", type diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/elem/mapper/NElementMapperNEnvCondition.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/elem/mapper/NElementMapperNEnvCondition.java index 8ef7b164e..2d464dbc6 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/elem/mapper/NElementMapperNEnvCondition.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/elem/mapper/NElementMapperNEnvCondition.java @@ -4,8 +4,8 @@ import net.thevpc.nuts.elem.NElement; import net.thevpc.nuts.elem.NElementFactoryContext; import net.thevpc.nuts.elem.NElementMapper; -import net.thevpc.nuts.env.NEnvCondition; -import net.thevpc.nuts.env.NEnvConditionBuilder; +import net.thevpc.nuts.NEnvCondition; +import net.thevpc.nuts.NEnvConditionBuilder; import net.thevpc.nuts.runtime.standalone.DefaultNEnvConditionBuilder; import java.lang.reflect.Type; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/elem/mapper/NElementMapperNEnvConditionBuilder.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/elem/mapper/NElementMapperNEnvConditionBuilder.java index aacba2ee7..cb0ac6253 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/elem/mapper/NElementMapperNEnvConditionBuilder.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/elem/mapper/NElementMapperNEnvConditionBuilder.java @@ -3,9 +3,9 @@ import net.thevpc.nuts.elem.NElement; import net.thevpc.nuts.elem.NElementFactoryContext; import net.thevpc.nuts.elem.NElementMapper; -import net.thevpc.nuts.env.DefaultNEnvCondition; -import net.thevpc.nuts.env.NEnvCondition; -import net.thevpc.nuts.env.NEnvConditionBuilder; +import net.thevpc.nuts.DefaultNEnvCondition; +import net.thevpc.nuts.NEnvCondition; +import net.thevpc.nuts.NEnvConditionBuilder; import net.thevpc.nuts.runtime.standalone.DefaultNEnvConditionBuilder; import java.lang.reflect.Type; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/elem/mapper/NElementMapperNIdLocation.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/elem/mapper/NElementMapperNIdLocation.java index af9aff9b7..99dc55b28 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/elem/mapper/NElementMapperNIdLocation.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/elem/mapper/NElementMapperNIdLocation.java @@ -3,7 +3,7 @@ import net.thevpc.nuts.elem.NElement; import net.thevpc.nuts.elem.NElementFactoryContext; import net.thevpc.nuts.elem.NElementMapper; -import net.thevpc.nuts.env.NIdLocation; +import net.thevpc.nuts.NIdLocation; import java.lang.reflect.Type; import java.util.Map; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/event/DefaultNEvents.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/event/DefaultNEvents.java index ef8956a87..228385092 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/event/DefaultNEvents.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/event/DefaultNEvents.java @@ -1,107 +1,107 @@ -package net.thevpc.nuts.runtime.standalone.event; - -import net.thevpc.nuts.*; -import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; -import net.thevpc.nuts.spi.NComponentScope; -import net.thevpc.nuts.spi.NScopeType; -import net.thevpc.nuts.spi.NSupportLevelContext; -import net.thevpc.nuts.util.NObservableMapListener; - -import java.util.List; - -@NComponentScope(NScopeType.SESSION) -public class DefaultNEvents implements NEvents { - - private DefaultNWorkspaceEventModel model; - private NWorkspace workspace; - - public DefaultNEvents(NWorkspace workspace) { - this.workspace = workspace; - NWorkspaceExt e = NWorkspaceExt.of(); - this.model = e.getModel().eventsModel; - } - - @Override - public int getSupportLevel(NSupportLevelContext context) { - return NConstants.Support.DEFAULT_SUPPORT; - } - - public DefaultNWorkspaceEventModel getModel() { - return model; - } - - public void setModel(DefaultNWorkspaceEventModel model) { - this.model = model; - } - - @Override - public NEvents removeRepositoryListener(NRepositoryListener listener) { - model.removeRepositoryListener(listener); - return this; - } - - @Override - public NEvents addRepositoryListener(NRepositoryListener listener) { - model.addRepositoryListener(listener); - return this; - } - - @Override - public List getRepositoryListeners() { - return model.getRepositoryListeners(); - } - - @Override - public NEvents addUserPropertyListener(NObservableMapListener listener) { - model.addUserPropertyListener(listener); - return this; - } - - @Override - public NEvents removeUserPropertyListener(NObservableMapListener listener) { - model.removeUserPropertyListener(listener); - return this; - } - - @Override - public List> getUserPropertyListeners() { - return model.getUserPropertyListeners(); - } - - @Override - public NEvents removeWorkspaceListener(NWorkspaceListener listener) { - model.removeWorkspaceListener(listener); - return this; - } - - @Override - public NEvents addWorkspaceListener(NWorkspaceListener listener) { - model.addWorkspaceListener(listener); - return this; - } - - @Override - public List getWorkspaceListeners() { - return model.getWorkspaceListeners(); - } - - @Override - public NEvents removeInstallListener(NInstallListener listener) { - model.removeInstallListener(listener); - return this; - } - - @Override - public NEvents addInstallListener(NInstallListener listener) { - model.addInstallListener(listener); - return this; - } - - @Override - public List getInstallListeners() { - return model.getInstallListeners(); - } - - -} +//package net.thevpc.nuts.runtime.standalone.event; +// +//import net.thevpc.nuts.*; +//import net.thevpc.nuts.NConstants; +//import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; +//import net.thevpc.nuts.spi.NComponentScope; +//import net.thevpc.nuts.spi.NScopeType; +//import net.thevpc.nuts.spi.NSupportLevelContext; +//import net.thevpc.nuts.util.NObservableMapListener; +// +//import java.util.List; +// +//@NComponentScope(NScopeType.SESSION) +//public class DefaultNEvents implements NEvents { +// +// private DefaultNWorkspaceEventModel model; +// private NWorkspace workspace; +// +// public DefaultNEvents(NWorkspace workspace) { +// this.workspace = workspace; +// NWorkspaceExt e = NWorkspaceExt.of(); +// this.model = e.getModel().eventsModel; +// } +// +// @Override +// public int getSupportLevel(NSupportLevelContext context) { +// return NConstants.Support.DEFAULT_SUPPORT; +// } +// +// public DefaultNWorkspaceEventModel getModel() { +// return model; +// } +// +// public void setModel(DefaultNWorkspaceEventModel model) { +// this.model = model; +// } +// +// @Override +// public NEvents removeRepositoryListener(NRepositoryListener listener) { +// model.removeRepositoryListener(listener); +// return this; +// } +// +// @Override +// public NEvents addRepositoryListener(NRepositoryListener listener) { +// model.addRepositoryListener(listener); +// return this; +// } +// +// @Override +// public List getRepositoryListeners() { +// return model.getRepositoryListeners(); +// } +// +// @Override +// public NEvents addUserPropertyListener(NObservableMapListener listener) { +// model.addUserPropertyListener(listener); +// return this; +// } +// +// @Override +// public NEvents removeUserPropertyListener(NObservableMapListener listener) { +// model.removeUserPropertyListener(listener); +// return this; +// } +// +// @Override +// public List> getUserPropertyListeners() { +// return model.getUserPropertyListeners(); +// } +// +// @Override +// public NEvents removeWorkspaceListener(NWorkspaceListener listener) { +// model.removeWorkspaceListener(listener); +// return this; +// } +// +// @Override +// public NEvents addWorkspaceListener(NWorkspaceListener listener) { +// model.addWorkspaceListener(listener); +// return this; +// } +// +// @Override +// public List getWorkspaceListeners() { +// return model.getWorkspaceListeners(); +// } +// +// @Override +// public NEvents removeInstallListener(NInstallListener listener) { +// model.removeInstallListener(listener); +// return this; +// } +// +// @Override +// public NEvents addInstallListener(NInstallListener listener) { +// model.addInstallListener(listener); +// return this; +// } +// +// @Override +// public List getInstallListeners() { +// return model.getInstallListeners(); +// } +// +// +//} diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/event/DefaultNWorkspaceEventModel.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/event/DefaultNWorkspaceEventModel.java index d84066cde..07f525b31 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/event/DefaultNWorkspaceEventModel.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/event/DefaultNWorkspaceEventModel.java @@ -1,7 +1,7 @@ package net.thevpc.nuts.runtime.standalone.event; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NEnvs; + import net.thevpc.nuts.util.NObservableMap; import net.thevpc.nuts.util.NObservableMapListener; @@ -37,17 +37,17 @@ public List getRepositoryListeners() { public void addUserPropertyListener(NObservableMapListener listener) { - ((NObservableMap) NEnvs.of().getProperties()).addMapListener(listener); + ((NObservableMap) NWorkspace.get().getProperties()).addMapListener(listener); } public void removeUserPropertyListener(NObservableMapListener listener) { - ((NObservableMap) NEnvs.of().getProperties()).removeMapListener(listener); + ((NObservableMap) NWorkspace.get().getProperties()).removeMapListener(listener); } public List> getUserPropertyListeners() { - return ((NObservableMap) NEnvs.of().getProperties()).getMapListeners(); + return ((NObservableMap) NWorkspace.get().getProperties()).getMapListeners(); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/NExecutionContextUtils.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/NExecutionContextUtils.java index 8aa621375..ff67a4bcf 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/NExecutionContextUtils.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/NExecutionContextUtils.java @@ -1,8 +1,9 @@ package net.thevpc.nuts.runtime.standalone.executor; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; + + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.xtra.expr.StringPlaceHolderParser; @@ -15,35 +16,35 @@ public String get(String key, NDefinition definition) { return (definition.getId().toString()); } case "NUTS_ID_BIN": { - NPath v = NLocations.of().getStoreLocation(definition.getId(), NStoreType.BIN); + NPath v = NWorkspace.get().getStoreLocation(definition.getId(), NStoreType.BIN); return (v.toString()); } case "NUTS_ID_CONF": { - NPath v = NLocations.of().getStoreLocation(definition.getId(), NStoreType.CONF); + NPath v = NWorkspace.get().getStoreLocation(definition.getId(), NStoreType.CONF); return (v.toString()); } case "NUTS_ID_LOG": { - NPath v = NLocations.of().getStoreLocation(definition.getId(), NStoreType.LOG); + NPath v = NWorkspace.get().getStoreLocation(definition.getId(), NStoreType.LOG); return (v.toString()); } case "NUTS_ID_CACHE": { - NPath v = NLocations.of().getStoreLocation(definition.getId(), NStoreType.CACHE); + NPath v = NWorkspace.get().getStoreLocation(definition.getId(), NStoreType.CACHE); return (v.toString()); } case "NUTS_ID_LIB": { - NPath v = NLocations.of().getStoreLocation(definition.getId(), NStoreType.LIB); + NPath v = NWorkspace.get().getStoreLocation(definition.getId(), NStoreType.LIB); return (v.toString()); } case "NUTS_ID_RUN": { - NPath v = NLocations.of().getStoreLocation(definition.getId(), NStoreType.RUN); + NPath v = NWorkspace.get().getStoreLocation(definition.getId(), NStoreType.RUN); return (v.toString()); } case "NUTS_ID_TEMP": { - NPath v = NLocations.of().getStoreLocation(definition.getId(), NStoreType.TEMP); + NPath v = NWorkspace.get().getStoreLocation(definition.getId(), NStoreType.TEMP); return (v.toString()); } case "NUTS_ID_VAR": { - NPath v = NLocations.of().getStoreLocation(definition.getId(), NStoreType.VAR); + NPath v = NWorkspace.get().getStoreLocation(definition.getId(), NStoreType.VAR); return (v.toString()); } } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/embedded/ClassloaderAwareRunnableImpl.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/embedded/ClassloaderAwareRunnableImpl.java index 90870ab70..471078847 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/embedded/ClassloaderAwareRunnableImpl.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/embedded/ClassloaderAwareRunnableImpl.java @@ -2,7 +2,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.format.NCmdLineFormat; -import net.thevpc.nuts.env.NShellFamily; +import net.thevpc.nuts.NShellFamily; import net.thevpc.nuts.runtime.standalone.executor.java.JavaExecutorComponent; import net.thevpc.nuts.runtime.standalone.executor.java.JavaExecutorOptions; import net.thevpc.nuts.runtime.standalone.util.CoreNUtils; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/exec/NExecHelper.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/exec/NExecHelper.java index 428b06404..2ffade3f8 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/exec/NExecHelper.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/exec/NExecHelper.java @@ -3,8 +3,9 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.cmdline.NCmdLine; import net.thevpc.nuts.concurrent.NScheduler; -import net.thevpc.nuts.env.NBootManager; -import net.thevpc.nuts.env.NLocations; + + + import net.thevpc.nuts.format.NExecCmdFormat; import net.thevpc.nuts.io.*; import net.thevpc.nuts.runtime.standalone.app.cmdline.NCmdLineUtils; @@ -65,7 +66,7 @@ public static NExecHelper ofArgs(String[] args, Map env, Path di )); } NSession session = workspace.currentSession(); - if (showCommand || NBootManager.of().getCustomBootOption("---show-command") + if (showCommand || NWorkspace.get().getCustomBootOption("---show-command") .flatMap(NLiteral::asBoolean) .orElse(false)) { @@ -86,7 +87,7 @@ public static NExecHelper ofDefinition(NDefinition nutMainFile, NRunAs runAs, NWorkspace workspace ) throws NExecutionException { - Path wsLocation = NLocations.of().getWorkspaceLocation().toPath().get(); + Path wsLocation = NWorkspace.get().getWorkspaceLocation().toPath().get(); Path pdirectory = null; if (NBlankable.isBlank(directory)) { pdirectory = wsLocation; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/java/JavaExecutorComponent.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/java/JavaExecutorComponent.java index 0a4d5dbf2..f996adfab 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/java/JavaExecutorComponent.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/java/JavaExecutorComponent.java @@ -25,15 +25,15 @@ package net.thevpc.nuts.runtime.standalone.executor.java; import net.thevpc.nuts.*; -import net.thevpc.nuts.boot.NBootClassLoaderNode; import net.thevpc.nuts.NConstants; import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; + import net.thevpc.nuts.format.NCmdLineFormat; import net.thevpc.nuts.cmdline.NWorkspaceCmdLineParser; -import net.thevpc.nuts.env.NBootManager; -import net.thevpc.nuts.env.NIsolationLevel; -import net.thevpc.nuts.env.NShellFamily; + +import net.thevpc.nuts.NIsolationLevel; +import net.thevpc.nuts.NShellFamily; import net.thevpc.nuts.ext.NExtensions; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.io.NPrintStream; @@ -116,7 +116,7 @@ public int getSupportLevel(NSupportLevelContext ctx) { public static NWorkspaceOptionsBuilder createChildOptions(NExecutionContext executionContext) { NSession session = executionContext.getSession(); - NWorkspaceOptionsBuilder options = NBootManager.of().getBootOptions().toWorkspaceOptions().builder(); + NWorkspaceOptionsBuilder options = NWorkspace.get().getBootOptions().toWorkspaceOptions().builder(); options.setDry(executionContext.isDry()); options.setBot(executionContext.isBot()); @@ -422,7 +422,9 @@ public int exec() { List cmdLine = new ArrayList<>(); cmdLine.add("embedded-java"); cmdLine.add("-cp"); - cmdLine.add(joptions.getClassPathNodes().stream().map(NBootClassLoaderNode::getId).collect(Collectors.joining(":"))); + cmdLine.add(joptions.getClassPathNodes().stream().map(NClassLoaderNode::getId).filter(NBlankable::isNonBlank) + .map(Object::toString) + .collect(Collectors.joining(":"))); cmdLine.add(joptions.getMainClass()); cmdLine.addAll(joptions.getAppArgs()); @@ -446,7 +448,7 @@ public int exec() { def.getId().toString(), null//getSession().getWorkspace().config().getBootClassLoader() ); - for (NBootClassLoaderNode n : joptions.getClassPathNodes()) { + for (NClassLoaderNode n : joptions.getClassPathNodes()) { classLoader.add(n); } if (joptions.getMainClass() == null) { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/java/JavaExecutorOptions.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/java/JavaExecutorOptions.java index 2ff9b3367..a0e28ba4a 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/java/JavaExecutorOptions.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/java/JavaExecutorOptions.java @@ -1,8 +1,9 @@ package net.thevpc.nuts.runtime.standalone.executor.java; import net.thevpc.nuts.*; -import net.thevpc.nuts.boot.NBootClassLoaderNode; import net.thevpc.nuts.cmdline.NWorkspaceCmdLineParser; + +import net.thevpc.nuts.log.NLog; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; @@ -22,7 +23,9 @@ import java.net.URL; import java.nio.file.Path; import java.util.*; +import java.util.function.Predicate; import java.util.stream.Collectors; +import java.util.stream.Stream; public final class JavaExecutorOptions { @@ -39,7 +42,7 @@ public final class JavaExecutorOptions { private final List appendArgs = new ArrayList<>(); // private NutsDefinition nutsMainDef; private final NWorkspace workspace; - private final List classPathNodes = new ArrayList<>(); + private final List classPathNodes = new ArrayList<>(); private final List classPath = new ArrayList<>(); private String javaVersion = null;//runnerProps.getProperty("java.parseVersion"); private String javaEffVersion = null; @@ -80,7 +83,7 @@ public JavaExecutorOptions(NDefinition def, boolean tempId, List args, //will accept all -- and - based options! NCmdLine cmdLine = NCmdLine.of(getExecArgs()).setExpandSimpleOptions(false); NArg a; - List currentCP = new ArrayList<>(); + List currentCP = new ArrayList<>(); List extraMayBeJvmOptions = new ArrayList<>(); while (cmdLine.hasNext()) { @@ -217,7 +220,7 @@ public JavaExecutorOptions(NDefinition def, boolean tempId, List args, .and(dependencyFilters.byOptional(false)); if (tempId) { for (NDependency dependency : descriptor.getDependencies()) { - if(defFilter.acceptDependency(null,dependency)) { + if (defFilter.acceptDependency(null, dependency)) { se.addId(dependency.toId()); } } @@ -256,12 +259,36 @@ public JavaExecutorOptions(NDefinition def, boolean tempId, List args, if (!NBlankable.isBlank(explicitJavaVersion) && (NBlankable.isBlank(javaVersion) || explicitJavaVersion.compareTo(javaVersion) > 0)) { javaVersion = explicitJavaVersion.toString(); } - NPlatformLocation nutsPlatformLocation = NJavaSdkUtils.of(workspace).resolveJdkLocation(getJavaVersion()); + NJavaSdkUtils nJavaSdkUtils = NJavaSdkUtils.of(workspace); + NPlatformLocation nutsPlatformLocation = nJavaSdkUtils.resolveJdkLocation(getJavaVersion()); if (nutsPlatformLocation == null) { - throw new NExecutionException(NMsg.ofC("no java version %s was found", NStringUtils.trim(getJavaVersion())), NExecutionException.ERROR_1); + NLog.of(JavaExecutorOptions.class).warn(NMsg.ofC("No JRE %s is configured in nuts. search of system installations.", javaVersion)); + Predicate versionFilterPredicate = nJavaSdkUtils.createVersionFilterPredicate(getJavaVersion()); + NPlatformLocation[] existing = Stream.of(nJavaSdkUtils.searchJdkLocations()).filter( + aa -> { + return versionFilterPredicate.test(aa.getVersion()); + } + ).toArray(NPlatformLocation[]::new); + if (existing.length > 0) { + if (NAsk.of().forBoolean( + NMsg.ofC("No JRE %s is configured in nuts. However %s %s found. Would you like to auto-configure and use %s?", javaVersion, existing.length + , existing.length == 1 ? "is" : "are" + , existing.length == 1 ? "it" : "them" + ) + ).setDefaultValue(true) + .getBooleanValue()) { + for (NPlatformLocation p : existing) { + workspace.addPlatform(p); + } + nutsPlatformLocation = nJavaSdkUtils.resolveJdkLocation(getJavaVersion()); + } + } + if (nutsPlatformLocation == null) { + throw new NExecutionException(NMsg.ofC("no java version %s was found", NStringUtils.trim(getJavaVersion())), NExecutionException.ERROR_1); + } } javaEffVersion = nutsPlatformLocation.getVersion(); - javaCommand = NJavaSdkUtils.of(workspace).resolveJavaCommandByVersion(nutsPlatformLocation, javaw); + javaCommand = nJavaSdkUtils.resolveJavaCommandByVersion(nutsPlatformLocation, javaw); if (javaCommand == null) { throw new NExecutionException(NMsg.ofC("no java version %s was found", getJavaVersion()), NExecutionException.ERROR_1); } @@ -326,19 +353,19 @@ public JavaExecutorOptions(NDefinition def, boolean tempId, List args, boolean baseDetected = false; NRepositoryFilters nRepositoryFilters = NRepositoryFilters.of(); for (NDefinition nDefinition : nDefinitions) { - NBootClassLoaderNode nn = null; + NClassLoaderNode nn = null; if (nDefinition.getContent().isPresent()) { if (id.getLongName().equals(nDefinition.getId().getLongName())) { baseDetected = true; if (!isExcludeBase()) { - nn = (NClassLoaderUtils.definitionToClassLoaderNode(nDefinition, + nn = (NClassLoaderUtils.definitionToClassLoaderNodeSafer(nDefinition, nRepositoryFilters.installedRepo() )); // classPath.add(nutsDefinition.getPath().toString()); // nutsPath.add(nutsIdFormat.value(nutsDefinition.getId()).format()); } } else { - nn = (NClassLoaderUtils.definitionToClassLoaderNode(nDefinition, + nn = (NClassLoaderUtils.definitionToClassLoaderNodeSafer(nDefinition, nRepositoryFilters.installedRepo() )); // classPath.add(nutsDefinition.getPath().toString()); @@ -351,12 +378,12 @@ public JavaExecutorOptions(NDefinition def, boolean tempId, List args, } if (!isExcludeBase() && !baseDetected) { NAssert.requireNonNull(path, () -> NMsg.ofC("missing path %s", finalId)); - currentCP.add(0, NClassLoaderUtils.definitionToClassLoaderNode(def, nRepositoryFilters.installedRepo())); + currentCP.add(0, NClassLoaderUtils.definitionToClassLoaderNodeSafer(def, nRepositoryFilters.installedRepo())); } classPathNodes.addAll(currentCP); List ln = NJavaSdkUtils.loadNutsClassLoaderNodeExts( - currentCP.toArray(new NBootClassLoaderNode[0]), + currentCP.toArray(new NClassLoaderNode[0]), java9, workspace ); if (java9) { @@ -587,7 +614,7 @@ private String resolveMainClass(String name, List possibleClasses) { return null; } - private void addCp(List classPath, String value) { + private void addCp(List classPath, String value) { if (value == null) { value = ""; } @@ -599,14 +626,14 @@ private void addCp(List classPath, String value) { for (String n : StringTokenizerUtils.splitColon(value)) { if (!NBlankable.isBlank(n)) { URL url = NPath.of(n).toURL().get(); - classPath.add(new NBootClassLoaderNode("", url, true, true)); + classPath.add(new NDefaultClassLoaderNode(null, url, true, true)); } } } } - private void addNp(List classPath, String value) { + private void addNp(List classPath, String value) { NSearchCmd ns = NSearchCmd.of().setLatest(true); NRepositoryFilters nRepositoryFilters = NRepositoryFilters.of(); for (String n : StringTokenizerUtils.splitDefault(value)) { @@ -617,7 +644,7 @@ private void addNp(List classPath, String value) { for (NId nutsId : ns.getResultIds()) { NDefinition f = NSearchCmd.of().addId(nutsId) .setLatest(true).getResultDefinitions().findFirst().get(); - classPath.add(NClassLoaderUtils.definitionToClassLoaderNode(f, nRepositoryFilters.installedRepo())); + classPath.add(NClassLoaderUtils.definitionToClassLoaderNodeSafer(f, nRepositoryFilters.installedRepo())); } } @@ -677,36 +704,36 @@ public NWorkspace getWorkspace() { return workspace; } - public void fillStrings(NBootClassLoaderNode n, List list) { + public void fillStrings(NClassLoaderNode n, List list) { URL f = n.getURL(); list.add(NPath.of(f).toPath().get().toString()); - for (NBootClassLoaderNode d : n.getDependencies()) { + for (NClassLoaderNode d : n.getDependencies()) { fillStrings(d, list); } } - public void fillNidStrings(NBootClassLoaderNode n, List list) { - if (n.getId() == null || n.getId().isEmpty()) { + public void fillNidStrings(NClassLoaderNode n, List list) { + if (NBlankable.isBlank(n.getId())) { URL f = n.getURL(); list.add(NPath.of(f).toPath().get().toString()); } else { - list.add(n.getId()); + list.add(n.getId().toString()); } - for (NBootClassLoaderNode d : n.getDependencies()) { + for (NClassLoaderNode d : n.getDependencies()) { fillStrings(d, list); } } public List getClassPathNidStrings() { List li = new ArrayList<>(); - for (NBootClassLoaderNode n : getClassPathNodes()) { + for (NClassLoaderNode n : getClassPathNodes()) { fillNidStrings(n, li); } return li; } - public List getClassPathNodes() { + public List getClassPathNodes() { return classPathNodes; } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/system/NSysExecUtils.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/system/NSysExecUtils.java index 678958bb1..ec3713f7c 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/system/NSysExecUtils.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/system/NSysExecUtils.java @@ -1,12 +1,12 @@ package net.thevpc.nuts.runtime.standalone.executor.system; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NEnvs; + import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NDesktopEnvironmentFamily; -import net.thevpc.nuts.env.NOsFamily; +import net.thevpc.nuts.NDesktopEnvironmentFamily; +import net.thevpc.nuts.NOsFamily; import net.thevpc.nuts.io.NNonBlockingInputStream; import net.thevpc.nuts.util.NRef; import net.thevpc.nuts.util.*; @@ -61,13 +61,13 @@ public static PipeRunnable pipe(String name, String cmd, String desc, final NNon } public static String resolveRootUserName() { - NOsFamily sysFamily = NEnvs.of().getOsFamily(); + NOsFamily sysFamily = NWorkspace.get().getOsFamily(); switch (sysFamily) { case WINDOWS: { NSession session = NSession.of().get(); String s = (String) session.getProperty("nuts.windows.root-user"); if (s == null) { - s = NConfigs.of().getConfigProperty("nuts.windows.root-user").flatMap(NLiteral::asString).orNull(); + s = NWorkspace.get().getConfigProperty("nuts.windows.root-user").flatMap(NLiteral::asString).orNull(); } if (NBlankable.isBlank(s)) { s = "Administrator"; @@ -85,7 +85,7 @@ public static String resolveRootUserName(NOsFamily sysFamily) { case WINDOWS: { String s = (String) NSession.of().get().getProperty("nuts.windows.root-user"); if (s == null) { - s = NConfigs.of().getConfigProperty("nuts.windows.root-user").flatMap(NLiteral::asString).orNull(); + s = NWorkspace.get().getConfigProperty("nuts.windows.root-user").flatMap(NLiteral::asString).orNull(); } if (NBlankable.isBlank(s)) { s = "Administrator"; @@ -104,7 +104,7 @@ public static List buildEffectiveCommandLocal(String[] args, ) { NSession session = NSession.of().get(); return NSysExecUtils.buildEffectiveCommand(args, runAsMode, - NEnvs.of().getDesktopEnvironmentFamilies(), + NWorkspace.get().getDesktopEnvironmentFamilies(), n -> { Path path = NSysExecUtils.sysWhich(n); if (path != null) { @@ -112,7 +112,7 @@ public static List buildEffectiveCommandLocal(String[] args, } return null; }, - session.isGui() && NEnvs.of().isGraphicalDesktopEnvironment(), + session.isGui() && NWorkspace.get().isGraphicalDesktopEnvironment(), NSysExecUtils.resolveRootUserName(), System.getProperty("user.name"), executionOptions @@ -129,13 +129,13 @@ public static List buildEffectiveCommand(String[] cmd, String[] executorOptions ) { //String runAsEffective = null; - NOsFamily sysFamily = NEnvs.of().getOsFamily(); + NOsFamily sysFamily = NWorkspace.get().getOsFamily(); List command = new ArrayList<>(Arrays.asList(cmd)); if (runAsMode == null) { runAsMode = NRunAs.CURRENT_USER; } NSession session = NSession.of().get(); - boolean runWithGui = gui != null ? gui : session.isGui() && NEnvs.of().isGraphicalDesktopEnvironment(); + boolean runWithGui = gui != null ? gui : session.isGui() && NWorkspace.get().isGraphicalDesktopEnvironment(); String rootUserName = rootName != null ? rootName : resolveRootUserName(); String currentUserName = userName != null ? userName : System.getProperty("user.name"); if (sysWhich == null) { @@ -281,7 +281,7 @@ public static List buildEffectiveCommand(String[] cmd, private static NOptional guiSu(Set de, Function sysWhich, NSession session) { if (de == null) { - de = NEnvs.of().getDesktopEnvironmentFamilies(); + de = NWorkspace.get().getDesktopEnvironmentFamilies(); } String currSu = null; if (de.contains(NDesktopEnvironmentFamily.KDE)) { @@ -315,7 +315,7 @@ private static NOptional guiSu(Set de, Functi private static NOptional guiSudo(Set de, Function sysWhich, NSession session) { if (de == null) { - de = NEnvs.of().getDesktopEnvironmentFamilies(); + de = NWorkspace.get().getDesktopEnvironmentFamilies(); } String currSu = null; if (de.contains(NDesktopEnvironmentFamily.KDE)) { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/system/ProcessBuilder2.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/system/ProcessBuilder2.java index 532e0f20c..03dad9720 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/system/ProcessBuilder2.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/system/ProcessBuilder2.java @@ -28,7 +28,7 @@ import net.thevpc.nuts.cmdline.DefaultNArg; import net.thevpc.nuts.cmdline.NCmdLine; import net.thevpc.nuts.cmdline.NCmdLineFormatStrategy; -import net.thevpc.nuts.env.NShellFamily; +import net.thevpc.nuts.NShellFamily; import net.thevpc.nuts.io.*; import net.thevpc.nuts.runtime.standalone.app.cmdline.NCmdLineShellOptions; import net.thevpc.nuts.runtime.standalone.shell.NShellHelper; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/system/ProcessExecHelper.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/system/ProcessExecHelper.java index 543c18a17..930294c03 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/system/ProcessExecHelper.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/executor/system/ProcessExecHelper.java @@ -2,8 +2,9 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NShellFamily; + + +import net.thevpc.nuts.NShellFamily; import net.thevpc.nuts.io.*; import net.thevpc.nuts.runtime.standalone.executor.AbstractSyncIProcessExecHelper; import net.thevpc.nuts.runtime.standalone.io.util.CoreIOUtils; @@ -116,7 +117,7 @@ public static ProcessExecHelper ofDefinition(NDefinition nutMainFile, if (map.containsKey("nuts.jar")) { map.put("nuts.cmd", map.get("nuts.java") + " -jar " + map.get("nuts.jar")); } - map.put("nuts.workspace", NLocations.of().getWorkspaceLocation().toString()); + map.put("nuts.workspace", NWorkspace.get().getWorkspaceLocation().toString()); if (installerFile != null) { map.put("nuts.installer", installerFile.toString()); } @@ -183,7 +184,7 @@ public String apply(String skey) { } args = args2.toArray(new String[0]); - Path wsLocation = NLocations.of().getWorkspaceLocation().toPath().get(); + Path wsLocation = NWorkspace.get().getWorkspaceLocation().toPath().get(); Path path = wsLocation.resolve(args[0]).normalize(); if (Files.exists(path)) { NPath.of(path).addPermissions(NPathPermission.CAN_EXECUTE); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/extension/DefaultNClassLoader.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/extension/DefaultNClassLoader.java index 7fa8c6361..8faa5f48d 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/extension/DefaultNClassLoader.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/extension/DefaultNClassLoader.java @@ -24,13 +24,13 @@ */ package net.thevpc.nuts.runtime.standalone.extension; +import net.thevpc.nuts.NClassLoaderNode; import net.thevpc.nuts.NId; import java.net.URL; import java.net.URLClassLoader; import java.util.LinkedHashMap; import net.thevpc.nuts.NWorkspace; -import net.thevpc.nuts.boot.NBootClassLoaderNode; import net.thevpc.nuts.NSession; @@ -38,8 +38,8 @@ public class DefaultNClassLoader extends URLClassLoader { private String name; private NWorkspace workspace; - private LinkedHashMap nodes = new LinkedHashMap<>(); - private LinkedHashMap effective = new LinkedHashMap<>(); + private LinkedHashMap nodes = new LinkedHashMap<>(); + private LinkedHashMap effective = new LinkedHashMap<>(); public DefaultNClassLoader(String name, NWorkspace workspace, ClassLoader parent) { super(new URL[0], parent); this.name = name; @@ -50,15 +50,14 @@ public String getName() { return name; } - public boolean contains(NBootClassLoaderNode node, boolean deep) { + public boolean contains(NClassLoaderNode node, boolean deep) { return search(node, deep) != null; } - public NBootClassLoaderNode search(NBootClassLoaderNode node, boolean deep) { - NSession session = workspace.currentSession(); - NId ii = NId.of(node.getId()).get(); + public NClassLoaderNode search(NClassLoaderNode node, boolean deep) { + NId ii = node.getId(); String sn = ii.getShortName(); - NBootClassLoaderNode o = nodes.get(sn); + NClassLoaderNode o = nodes.get(sn); if (o != null) { return o; } @@ -75,10 +74,9 @@ public NBootClassLoaderNode search(NBootClassLoaderNode node, boolean deep) { return null; } - public boolean add(NBootClassLoaderNode node) { - NSession session = workspace.currentSession(); - NId ii = NId.of(node.getId()).get(); - String sn = ii.getShortName(); + public boolean add(NClassLoaderNode node) { + NId ii = node.getId(); + String sn = ii==null?null:ii.getShortName(); if (!nodes.containsKey(sn)) { nodes.put(sn, node); return add(node, true); @@ -86,23 +84,21 @@ public boolean add(NBootClassLoaderNode node) { return false; } - protected boolean add(NBootClassLoaderNode node, boolean deep) { - NSession session = workspace.currentSession(); - String s = node.getId(); - NId ii = NId.of(s).get(); - String sn = ii.getShortName(); + protected boolean add(NClassLoaderNode node, boolean deep) { + NId ii = node.getId(); + String sn = ii==null?null:ii.getShortName(); if (!effective.containsKey(sn)) { effective.put(sn, node); super.addURL(node.getURL()); if (deep) { - for (NBootClassLoaderNode dependency : node.getDependencies()) { + for (NClassLoaderNode dependency : node.getDependencies()) { add(dependency, true); } } return true; } else { if (deep) { - for (NBootClassLoaderNode dependency : node.getDependencies()) { + for (NClassLoaderNode dependency : node.getDependencies()) { add(dependency, true); } } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/extension/DefaultNExtensions.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/extension/DefaultNExtensions.java index 999f62782..de9ced48d 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/extension/DefaultNExtensions.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/extension/DefaultNExtensions.java @@ -48,13 +48,11 @@ public Set getCompanionIds() { @Override public boolean installWorkspaceExtensionComponent(Class extensionPointType, T extensionImpl) { - NSession session = workspace.currentSession(); return wsModel.extensionModel.installWorkspaceExtensionComponent(extensionPointType, extensionImpl); } @Override public Set> discoverTypes(NId id, ClassLoader classLoader) { - NSession session = workspace.currentSession(); return wsModel.extensionModel.discoverTypes(id, classLoader); } @@ -148,7 +146,6 @@ public boolean isLoadedId(NId id, ClassLoader classLoader) { if (id == null) { return false; } - NSession session= wsModel.extensionModel.getWorkspace().currentSession(); if (classLoader == null) { classLoader = Thread.currentThread().getContextClassLoader(); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/extension/DefaultNWorkspaceExtensionModel.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/extension/DefaultNWorkspaceExtensionModel.java index 998138961..bf7ca9b11 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/extension/DefaultNWorkspaceExtensionModel.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/extension/DefaultNWorkspaceExtensionModel.java @@ -7,10 +7,10 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.boot.NBootWorkspaceFactory; -import net.thevpc.nuts.boot.NBootClassLoaderNode; -import net.thevpc.nuts.env.NBootOptions; +import net.thevpc.nuts.NBootOptions; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NLocations; + + import net.thevpc.nuts.runtime.standalone.util.ExtraApiUtils; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.elem.NElements; @@ -33,7 +33,6 @@ import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceFactory; import net.thevpc.nuts.runtime.standalone.workspace.config.NWorkspaceConfigBoot; -import net.thevpc.nuts.runtime.standalone.workspace.config.NConfigsExt; import net.thevpc.nuts.runtime.standalone.xtra.expr.StringTokenizerUtils; import net.thevpc.nuts.spi.*; import net.thevpc.nuts.util.*; @@ -143,13 +142,11 @@ public List findWorkspaceExtensions(String version) { //@Override public List findExtensions(String id, String extensionType) { - NSession session=getWorkspace().currentSession(); return findExtensions(NId.of(id).get(), extensionType); } // @Override public List findExtensions(NId id, String extensionType) { - NSession session=getWorkspace().currentSession(); NAssert.requireNonBlank(id.getVersion(), "version"); List ret = new ArrayList<>(); List allUrls = new ArrayList<>(); @@ -214,7 +211,6 @@ private boolean isJRELib(NPath path) { } public void onInitializeWorkspace(NBootOptions bOptions, ClassLoader bootClassLoader) { - NSession session = workspace.currentSession(); // add discover classpath ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); boolean resolveClassPathUrls=false; @@ -244,7 +240,7 @@ public PathAndUrl(URL url, NPath path) { .log(NMsg.ofC("initialize workspace extensions from %s/%s urls : %s", valid.length, urls.length, Arrays.asList(urls))); for (PathAndUrl v : valid) { objectFactory.discoverTypes( - CoreNIdUtils.resolveOrGenerateIdFromFileName(v.path, session), + CoreNIdUtils.resolveOrGenerateIdFromFileName(v.path), v.url, bootClassLoader ); @@ -257,21 +253,23 @@ public PathAndUrl(URL url, NPath path) { ); // discover runtime path - if (!bOptions.getRuntimeBootDependencyNode().isEmpty()) { + if (!bOptions.getRuntimeBootDependencyNode().isBlank()) { objectFactory.discoverTypes( - NId.of(bOptions.getRuntimeBootDependencyNode().get().getId()).get(), + bOptions.getRuntimeBootDependencyNode().get().getId(), bOptions.getRuntimeBootDependencyNode().get().getURL(), bootClassLoader ); } // discover extensions path - for (NBootClassLoaderNode idurl : bOptions.getExtensionBootDependencyNodes().orElseGet(Collections::emptyList)) { - objectFactory.discoverTypes( - NId.of(idurl.getId()).get(), - idurl.getURL(), - bootClassLoader - ); + for (NClassLoaderNode idurl : bOptions.getExtensionBootDependencyNodes().orElseGet(Collections::emptyList)) { + if(idurl.getId()!=null) { + objectFactory.discoverTypes( + idurl.getId(), + idurl.getURL(), + bootClassLoader + ); + } } this.workspaceExtensionsClassLoader = new DefaultNClassLoader("workspaceExtensionsClassLoader", workspace, bootClassLoader); } @@ -287,7 +285,6 @@ public PathAndUrl(URL url, NPath path) { // } // } public boolean installWorkspaceExtensionComponent(Class extensionPointType, T extensionImpl) { - NSession session = workspace.currentSession(); if (NComponent.class.isAssignableFrom(extensionPointType)) { if (extensionPointType.isInstance(extensionImpl)) { return registerInstance(extensionPointType, extensionImpl); @@ -324,7 +321,6 @@ public boolean installWorkspaceExtensionComponent(Class> discoverTypes(NId id, ClassLoader classLoader) { - NSession session = workspace.currentSession(); URL url = NFetchCmd.of(id).setContent(true).getResultContent().toURL().get(); return objectFactory.discoverTypes(id, url, classLoader); } @@ -453,7 +449,6 @@ public void loadExtensions(NId... extensions) { someUpdates = true; } else { //load extension - NSession session=getWorkspace().currentSession(); NDefinition def = NSearchCmd.of() .addId(extension).setTargetApiVersion(workspace.getApiVersion()) .setContent(true) @@ -490,7 +485,6 @@ public void loadExtensions(NId... extensions) { private void updateLoadedExtensionURLs() { loadedExtensionURLs.clear(); - NSession session=getWorkspace().currentSession(); for (NDefinition def : NSearchCmd.of().addIds(loadedExtensionIds.toArray(new NId[0])) .setTargetApiVersion(workspace.getApiVersion()) .setContent(true) @@ -588,7 +582,6 @@ public NWorkspaceExtension wireExtension(NId id, NFetchCmd options) { private boolean isLoadedClassPath(NDefinition file) { //session = CoreNutsUtils.validateSession(session,ws); - NSession session=getWorkspace().currentSession(); if (file.getId().equalsShortId(NId.of(NConstants.Ids.NUTS_API).get())) { return true; } @@ -689,7 +682,7 @@ public URL[] getExtensionURLLocations(NId nutsId, String appId, String extension public String[] getExtensionRepositoryLocations(NId appId) { //should parse this form config? //or should be parse from and extension component? - String repos = NConfigs.of() + String repos = workspace .getConfigProperty("nuts.bootstrap-repository-locations").flatMap(NLiteral::asString).orElse("") + ";" // + NutsConstants.BootstrapURLs.LOCAL_NUTS_FOLDER // + ";" + NutsConstants.BootstrapURLs.REMOTE_NUTS_GIT ; @@ -703,15 +696,11 @@ public String[] getExtensionRepositoryLocations(NId appId) { } protected URL expandURL(String url) { - NSession session=getWorkspace().currentSession(); return NPath.of(url) - .toAbsolute(NLocations.of().getWorkspaceLocation()) + .toAbsolute(NWorkspace.get().getWorkspaceLocation()) .toURL().get(); } - private NConfigsExt configExt() { - return NConfigsExt.of(NConfigs.of()); - } // @Override // public boolean addExtension(NutsId extensionId) { // if (extensionId == null) { @@ -778,15 +767,14 @@ private NConfigsExt configExt() { // configExt().fireConfigurationChanged(); // } private NWorkspaceConfigBoot getStoredConfig() { - return configExt().getModel().getStoredConfigBoot(); + return NWorkspaceExt.of(workspace).getConfigModel().getStoredConfigBoot(); } public synchronized DefaultNClassLoader getNutsURLClassLoader(String name, ClassLoader parent) { if (parent == null) { parent = workspaceExtensionsClassLoader; } - NSession session=getWorkspace().currentSession(); - return new DefaultNClassLoader(name, session.getWorkspace(), parent); + return new DefaultNClassLoader(name, workspace, parent); } public static class RegInfo { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/format/DefaultNObjectFormat.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/format/DefaultNObjectFormat.java index 84ef9a552..a5a696e43 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/format/DefaultNObjectFormat.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/format/DefaultNObjectFormat.java @@ -30,7 +30,8 @@ import net.thevpc.nuts.cmdline.NCmdLine; import net.thevpc.nuts.elem.NEDesc; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NBootManager; + + import net.thevpc.nuts.format.*; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.io.NPrintStream; @@ -154,7 +155,7 @@ public DefaultNObjectFormat setCompact(boolean compact) { public NContentTypeFormat getBase() { NSession session=workspace.currentSession(); NContentTypeFormat base = createObjectFormat(); - base.configure(true, NBootManager.of().getBootOptions().getOutputFormatOptions().orElseGet(Collections::emptyList).toArray(new String[0])); + base.configure(true, NWorkspace.get().getBootOptions().getOutputFormatOptions().orElseGet(Collections::emptyList).toArray(new String[0])); base.configure(true, session.getOutputFormatOptions().toArray(new String[0])); return base; } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/format/NFetchDisplayOptions.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/format/NFetchDisplayOptions.java index d700bf552..9c6f3f455 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/format/NFetchDisplayOptions.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/format/NFetchDisplayOptions.java @@ -145,7 +145,6 @@ public boolean configureFirst(NCmdLine cmdLine) { if (idFormat.configureFirst(cmdLine)) { return true; } - NSession session = workspace.currentSession(); NArg a = cmdLine.peek().get(); if (a == null) { return false; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/format/NIdFormatHelper.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/format/NIdFormatHelper.java index 06a5eb41b..fd52f6b03 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/format/NIdFormatHelper.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/format/NIdFormatHelper.java @@ -30,12 +30,11 @@ import java.util.stream.Collectors; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NEnvs; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; -import net.thevpc.nuts.env.NUserConfig; + + +import net.thevpc.nuts.NStoreType; +import net.thevpc.nuts.NUserConfig; import net.thevpc.nuts.runtime.standalone.workspace.config.NRepositoryConfigManagerExt; -import net.thevpc.nuts.runtime.standalone.workspace.config.NConfigsExt; import net.thevpc.nuts.runtime.standalone.repository.impl.main.NInstalledRepository; import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; import net.thevpc.nuts.runtime.standalone.util.CoreNUtils; @@ -158,47 +157,47 @@ public Object[] getMultiColumnRow(NFetchDisplayOptions oo) { } private static FormatHelper getFormatHelper(NWorkspace workspace) { - FormatHelper h = (FormatHelper) NEnvs.of().getProperties().get(FormatHelper.class.getName()); + FormatHelper h = (FormatHelper) NWorkspace.get().getProperties().get(FormatHelper.class.getName()); if (h != null) { return h; } - FormatHelperResetListener h2 = (FormatHelperResetListener) NEnvs.of() + FormatHelperResetListener h2 = (FormatHelperResetListener) workspace .getProperty(FormatHelperResetListener.class.getName()) .map(NLiteral::getRaw).orNull() ; if (h2 == null) { h2 = new FormatHelperResetListener(); - NEvents.of().addWorkspaceListener(h2); + workspace.addWorkspaceListener(h2); } h = new FormatHelper(workspace); - NEnvs.of().setProperty(FormatHelper.class.getName(), h); + NWorkspace.get().setProperty(FormatHelper.class.getName(), h); return h; } public static class FormatHelperResetListener implements NWorkspaceListener, NRepositoryListener { - private void _onReset(NSession session) { - NEnvs.of().setProperty(FormatHelper.class.getName(), null); + private void _onReset() { + NWorkspace.get().setProperty(FormatHelper.class.getName(), null); } @Override public void onAddRepository(NWorkspaceEvent event) { - _onReset(event.getSession()); + _onReset(); } @Override public void onRemoveRepository(NWorkspaceEvent event) { - _onReset(event.getSession()); + _onReset(); } @Override public void onReloadWorkspace(NWorkspaceEvent event) { - _onReset(event.getSession()); + _onReset(); } @Override public void onCreateWorkspace(NWorkspaceEvent event) { - _onReset(event.getSession()); + _onReset(); } @Override @@ -208,22 +207,22 @@ public void onUpdateProperty(NWorkspaceEvent event) { @Override public void onAddRepository(NRepositoryEvent event) { - _onReset(event.getSession()); + _onReset(); } @Override public void onRemoveRepository(NRepositoryEvent event) { - _onReset(event.getSession()); + _onReset(); } @Override public void onConfigurationChanged(NRepositoryEvent event) { - _onReset(event.getSession()); + _onReset(); } @Override public void onConfigurationChanged(NWorkspaceEvent event) { - _onReset(event.getSession()); + _onReset(); } } @@ -244,7 +243,7 @@ public int maxRepoNameSize() { } int z = 0; Stack stack = new Stack<>(); - for (NRepository repository : NRepositories.of() + for (NRepository repository : workspace .getRepositories()) { stack.push(repository); } @@ -269,8 +268,7 @@ public int maxUserNameSize() { return maxUserNameSize; } int z = "anonymous".length(); - NConfigsExt wc = NConfigsExt.of(NConfigs.of()); - NUserConfig[] users = wc.getModel().getStoredConfigSecurity().getUsers(); + NUserConfig[] users = NWorkspaceExt.of(workspace).getConfigModel().getStoredConfigSecurity().getUsers(); if (users != null) { for (NUserConfig user : users) { String s = user.getUser(); @@ -280,7 +278,7 @@ public int maxUserNameSize() { } } Stack stack = new Stack<>(); - for (NRepository repository : NRepositories.of().getRepositories()) { + for (NRepository repository : workspace.getRepositories()) { stack.push(repository); } while (!stack.isEmpty()) { @@ -433,7 +431,7 @@ public NText buildMain(NFetchDisplayOptions oo, NDisplayProperty dp) { rname = def.getRepositoryName(); } if (def.getRepositoryUuid() != null) { - NRepository r = NRepositories.of() + NRepository r = workspace .findRepositoryById(def.getRepositoryUuid()).orNull(); if (r != null) { rname = r.getName(); @@ -454,7 +452,7 @@ public NText buildMain(NFetchDisplayOptions oo, NDisplayProperty dp) { } if (ruuid == null && id != null) { String p = id.getRepository(); - NRepository r = NRepositories.of() + NRepository r = workspace .findRepositoryByName(p).orNull(); if (r != null) { ruuid = r.getUuid(); @@ -470,43 +468,43 @@ public NText buildMain(NFetchDisplayOptions oo, NDisplayProperty dp) { } case CACHE_FOLDER: { if (def != null) { - return stringValue(NLocations.of().getStoreLocation(def.getId(), NStoreType.CACHE)); + return stringValue(NWorkspace.get().getStoreLocation(def.getId(), NStoreType.CACHE)); } return text.ofStyled("", NTextStyle.error()); } case CONF_FOLDER: { if (def != null) { - return stringValue(NLocations.of().getStoreLocation(def.getId(), NStoreType.CONF)); + return stringValue(NWorkspace.get().getStoreLocation(def.getId(), NStoreType.CONF)); } return text.ofStyled("", NTextStyle.error()); } case LIB_FOLDER: { if (def != null) { - return stringValue(NLocations.of().getStoreLocation(def.getId(), NStoreType.LIB)); + return stringValue(NWorkspace.get().getStoreLocation(def.getId(), NStoreType.LIB)); } return text.ofStyled("", NTextStyle.error()); } case LOG_FOLDER: { if (def != null) { - return stringValue(NLocations.of().getStoreLocation(def.getId(), NStoreType.LOG)); + return stringValue(NWorkspace.get().getStoreLocation(def.getId(), NStoreType.LOG)); } return text.ofStyled("", NTextStyle.error()); } case TEMP_FOLDER: { if (def != null) { - return stringValue(NLocations.of().getStoreLocation(def.getId(), NStoreType.TEMP)); + return stringValue(NWorkspace.get().getStoreLocation(def.getId(), NStoreType.TEMP)); } return text.ofStyled("", NTextStyle.error()); } case VAR_LOCATION: { if (def != null) { - return stringValue(NLocations.of().getStoreLocation(def.getId(), NStoreType.VAR)); + return stringValue(NWorkspace.get().getStoreLocation(def.getId(), NStoreType.VAR)); } return text.ofStyled("", NTextStyle.error()); } case BIN_FOLDER: { if (def != null) { - return stringValue(NLocations.of().getStoreLocation(def.getId(), NStoreType.BIN)); + return stringValue(NWorkspace.get().getStoreLocation(def.getId(), NStoreType.BIN)); } return text.ofStyled("", NTextStyle.error()); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/format/table/DefaultSearchFormatTable.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/format/table/DefaultSearchFormatTable.java index 50a33a72a..9ce5d41ed 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/format/table/DefaultSearchFormatTable.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/format/table/DefaultSearchFormatTable.java @@ -10,7 +10,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NShellFamily; +import net.thevpc.nuts.NShellFamily; import net.thevpc.nuts.format.NContentType; import net.thevpc.nuts.format.NMutableTableModel; import net.thevpc.nuts.format.NTableFormat; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/format/tree/DefaultNTreeFormat.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/format/tree/DefaultNTreeFormat.java index d7da63d51..cb1725d00 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/format/tree/DefaultNTreeFormat.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/format/tree/DefaultNTreeFormat.java @@ -148,7 +148,6 @@ public void setOmitRoot(boolean hideRoot) { @Override public String toString() { ByteArrayOutputStream b = new ByteArrayOutputStream(); - NSession session = workspace.currentSession(); NPrintStream out = NPrintStream.of(b); NTreeModel tree = getModel(); print(tree, "", NPositionType.FIRST, tree.getRoot(), out, isEffectiveOmitRoot(), 0, false); @@ -164,7 +163,6 @@ public void print(NPrintStream out) { } private boolean print(NTreeModel tree, String prefix, NPositionType type, Object o, NPrintStream out, boolean hideRoot, int depth, boolean prefixNewLine) { - NSession session = workspace.currentSession(); Object oValue = o; if (oValue instanceof XNode) { oValue = ((XNode) oValue).toNutsString(); @@ -200,7 +198,6 @@ private boolean print(NTreeModel tree, String prefix, NPositionType type, Object } private void print(NTreeModel tree, String prefix, NPositionType type, Object o, PrintWriter out, boolean hideRoot, int depth) { - NSession session = workspace.currentSession(); boolean skipNewLine = true; if (!hideRoot) { out.print(prefix); @@ -241,7 +238,6 @@ private void print(NTreeModel tree, String prefix, NPositionType type, Object o, @Override public boolean configureFirst(NCmdLine cmdLine) { - NSession session = workspace.currentSession(); NArg aa = cmdLine.peek().orNull(); if (aa == null) { return false; @@ -301,7 +297,6 @@ private NText[] getMultilineArray(NText key, Object value) { if (vv.length == 0 || vv.length == 1) { return null; } - NSession session = workspace.currentSession(); return Arrays.stream(vv).map(x -> NText.of(x)).toArray(NText[]::new); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/id/filter/NPatternIdFilter.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/id/filter/NPatternIdFilter.java index a32bb24d5..426ea5e99 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/id/filter/NPatternIdFilter.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/id/filter/NPatternIdFilter.java @@ -13,7 +13,7 @@ import java.util.regex.Pattern; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NEnvCondition; +import net.thevpc.nuts.NEnvCondition; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.spi.base.AbstractIdFilter; import net.thevpc.nuts.runtime.standalone.util.filters.CoreFilterUtils; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/id/format/DefaultNIdFormat.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/id/format/DefaultNIdFormat.java index 2bfa10da2..33b8e6b61 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/id/format/DefaultNIdFormat.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/id/format/DefaultNIdFormat.java @@ -4,7 +4,8 @@ import net.thevpc.nuts.NConstants; import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NImports; + + import net.thevpc.nuts.io.NPrintStream; import net.thevpc.nuts.runtime.standalone.dependency.NDependencyScopes; import net.thevpc.nuts.runtime.standalone.format.DefaultFormatBase; @@ -148,7 +149,6 @@ public NIdFormat setValue(NId id) { @Override public NText format() { - NSession session=getWorkspace().currentSession(); if (id == null) { return isNtf() ? NText.ofStyled("", NTextStyle.of(NTextStyleType.BOOLEAN)) @@ -173,7 +173,7 @@ public NText format() { if (!isOmitGroupId()) { if (!NBlankable.isBlank(id.getGroupId())) { boolean importedGroup2 = NConstants.Ids.NUTS_GROUP_ID.equals(id.getGroupId()); - boolean importedGroup = NImports.of().getAllImports().contains(id.getGroupId()); + boolean importedGroup = NWorkspace.get().getAllImports().contains(id.getGroupId()); if (!(importedGroup && isOmitImportedGroupId())) { if (importedGroup || importedGroup2) { sb.append(id.getGroupId(), NTextStyle.pale()); @@ -285,11 +285,11 @@ public NText format() { } private String _encodeValue(String s) { - return NStringUtils.formatStringLiteral(s, NQuoteType.SIMPLE, NSupportMode.PREFERRED); + return NStringUtils.formatStringLiteral(s, NQuoteType.SIMPLE, NSupportMode.PREFERRED,"=&"); } private String _encodeKey(String s) { - return NStringUtils.formatStringLiteral(s, NQuoteType.SIMPLE, NSupportMode.PREFERRED); + return NStringUtils.formatStringLiteral(s, NQuoteType.SIMPLE, NSupportMode.PREFERRED,"=&"); } @Override @@ -312,7 +312,6 @@ public String toString() { @Override public boolean configureFirst(NCmdLine cmdLine) { - NSession session=getWorkspace().currentSession(); NArg aa = cmdLine.peek().get(); if (aa == null) { return false; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/id/util/CoreNIdUtils.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/id/util/CoreNIdUtils.java index 7faab060a..d0863476c 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/id/util/CoreNIdUtils.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/id/util/CoreNIdUtils.java @@ -3,8 +3,9 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; + + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NDigest; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.workspace.config.NWorkspaceConfigApi; @@ -17,7 +18,7 @@ import java.util.Map; public class CoreNIdUtils { - public static NId resolveOrGenerateIdFromFileName(NPath path, NSession session) { + public static NId resolveOrGenerateIdFromFileName(NPath path) { List nIds = NId.findByPath(path); if (nIds.size() == 1) { return nIds.get(0); @@ -136,7 +137,7 @@ public static NId findRuntimeForApi(String apiVersion) { if (apiVersion.equals(workspace.getApiVersion().toString())) { return workspace.getRuntimeId(); } - NPath apiBoot = NLocations.of().getStoreLocation(apiId(apiVersion), NStoreType.CONF).resolve(NConstants.Files.API_BOOT_CONFIG_FILE_NAME); + NPath apiBoot = NWorkspace.get().getStoreLocation(apiId(apiVersion), NStoreType.CONF).resolve(NConstants.Files.API_BOOT_CONFIG_FILE_NAME); if (apiBoot.isRegularFile()) { NWorkspaceConfigApi c = NElements.of() .json().parse(apiBoot, NWorkspaceConfigApi.class); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/installer/CommandForIdNInstallerComponent.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/installer/CommandForIdNInstallerComponent.java index c26cd3b98..0e9101729 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/installer/CommandForIdNInstallerComponent.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/installer/CommandForIdNInstallerComponent.java @@ -26,7 +26,8 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NBootManager; + + import net.thevpc.nuts.runtime.standalone.definition.DefaultNInstallInfo; import net.thevpc.nuts.runtime.standalone.executor.NExecutionContextUtils; import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceUtils; @@ -85,7 +86,7 @@ public void runMode(NExecutionContext executionContext, String mode) { cmd.addExecutorOptions("--nuts-auto-install=false"); } cmd.addCommand(executionContext.getArguments()) - .setExecutionType(NBootManager.of().getBootOptions().getExecutionType().orNull()) + .setExecutionType(NWorkspace.get().getBootOptions().getExecutionType().orNull()) .failFast() .run(); } @@ -108,7 +109,7 @@ public void runMode(NExecutionContext executionContext, String mode) { NExecCmd.of() .setCommandDefinition(def2) .addCommand(eargs) - .setExecutionType(NBootManager.of().getBootOptions().getExecutionType().orNull()) + .setExecutionType(NWorkspace.get().getBootOptions().getExecutionType().orNull()) .setExecutionType( "nsh".equals(def2.getId().getArtifactId()) ? NExecutionType.EMBEDDED : NExecutionType.SPAWN diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/installer/ZipInstallerComponent.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/installer/ZipInstallerComponent.java index 859c046de..830e2750b 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/installer/ZipInstallerComponent.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/installer/ZipInstallerComponent.java @@ -28,8 +28,9 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; + + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NIOException; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.io.util.UnzipOptions; @@ -65,7 +66,7 @@ public int getSupportLevel(NSupportLevelContext ctx) { @Override public void install(NExecutionContext executionContext) { DefaultNDefinition nutsDefinition = (DefaultNDefinition) executionContext.getDefinition(); - NPath installFolder = NLocations.of().getStoreLocation(nutsDefinition.getId(), NStoreType.BIN); + NPath installFolder = NWorkspace.get().getStoreLocation(nutsDefinition.getId(), NStoreType.BIN); NCmdLine cmd = NCmdLine.of(executionContext.getArguments()); UnzipOptions unzipOptions = new UnzipOptions(); while (cmd.hasNext()) { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/installer/svc/DefaultInstallSvcCommand.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/installer/svc/DefaultInstallSvcCommand.java index b6db7a938..fa07f9fba 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/installer/svc/DefaultInstallSvcCommand.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/installer/svc/DefaultInstallSvcCommand.java @@ -3,7 +3,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NOsServiceType; +import net.thevpc.nuts.NOsServiceType; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.io.NPathPermission; import net.thevpc.nuts.spi.NSupportLevelContext; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/NCoreIOUtils.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/NCoreIOUtils.java index c585e2024..421053c97 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/NCoreIOUtils.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/NCoreIOUtils.java @@ -1,7 +1,7 @@ package net.thevpc.nuts.runtime.standalone.io; -import net.thevpc.nuts.env.NBootOptions; -import net.thevpc.nuts.env.NStoreType; +import net.thevpc.nuts.NBootOptions; +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.log.NLog; import net.thevpc.nuts.log.NLogVerb; import net.thevpc.nuts.time.NChronometer; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/ask/DefaultNAsk.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/ask/DefaultNAsk.java index 0cd818814..fb1e12a81 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/ask/DefaultNAsk.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/ask/DefaultNAsk.java @@ -1,7 +1,7 @@ package net.thevpc.nuts.runtime.standalone.io.ask; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NEnvs; + import net.thevpc.nuts.text.NText; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.cmdline.NArg; @@ -79,7 +79,7 @@ private T execute() { + "You need to provide default response (-y|-n) for question : %s", os ), NExecutionException.ERROR_255); } - boolean gui = session.isGui() && NEnvs.of().isGraphicalDesktopEnvironment(); + boolean gui = session.isGui() && NWorkspace.get().isGraphicalDesktopEnvironment(); NMsg message = this.getMessage(); // if (message.endsWith("\n")) { @@ -470,7 +470,6 @@ public T getValue() { */ @Override public final NAsk configure(boolean skipUnsupported, String... args) { - NSession session= workspace.currentSession(); return NCmdLineConfigurable.configure(this, skipUnsupported, args,"question"); } @@ -482,7 +481,6 @@ public NAsk setCancelMessage(NMsg message) { @Override public boolean configureFirst(NCmdLine cmdLine) { - NSession session= workspace.currentSession(); NArg aa = cmdLine.peek().get(); if (aa == null) { return false; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/cache/DefaultCachedSupplier.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/cache/DefaultCachedSupplier.java index d8d4c7cc3..16ac224b9 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/cache/DefaultCachedSupplier.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/cache/DefaultCachedSupplier.java @@ -1,8 +1,10 @@ package net.thevpc.nuts.runtime.standalone.io.cache; -import net.thevpc.nuts.env.NLocations; + import net.thevpc.nuts.NSession; -import net.thevpc.nuts.env.NStoreType; +import net.thevpc.nuts.NWorkspace; + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.elem.NElements; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.NLocationKey; @@ -75,7 +77,7 @@ public DefaultCachedSupplier(NCacheLevel level, if (key.getStoreType() != NStoreType.CACHE) { throw new IllegalArgumentException("expected cache store"); } - NLocations nLocations = NLocations.of(); + NWorkspace nLocations = session.getWorkspace(); this.elems = NElements.of(); this.cachePath = nLocations.getStoreLocation(key.getId(), key.getStoreType(), key.getRepoUuid()) .resolve(nLocations.getDefaultIdFilename(key.getId().builder().setFace(key.getName() + ".value.cache").build())); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/inputstream/DefaultNIO.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/inputstream/DefaultNIO.java index c24d62974..58eb1f8a8 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/inputstream/DefaultNIO.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/inputstream/DefaultNIO.java @@ -2,16 +2,29 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; +import net.thevpc.nuts.NStoreType; +import net.thevpc.nuts.ext.NExtensions; import net.thevpc.nuts.io.*; import net.thevpc.nuts.runtime.standalone.boot.DefaultNBootModel; +import net.thevpc.nuts.runtime.standalone.io.path.NPathFromSPI; +import net.thevpc.nuts.runtime.standalone.io.path.spi.FilePath; +import net.thevpc.nuts.runtime.standalone.io.path.spi.URLPath; import net.thevpc.nuts.runtime.standalone.io.printstream.*; import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; -import net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNConfigs; import net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNWorkspaceConfigModel; -import net.thevpc.nuts.spi.NSupportLevelContext; -import net.thevpc.nuts.spi.NSystemTerminalBase; +import net.thevpc.nuts.spi.*; +import net.thevpc.nuts.util.NBlankable; +import net.thevpc.nuts.util.NIOUtils; +import net.thevpc.nuts.util.NMsg; +import net.thevpc.nuts.util.NStringBuilder; import java.io.*; +import java.net.URL; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.stream.Collectors; public class DefaultNIO implements NIO { public DefaultNWorkspaceConfigModel cmodel; @@ -20,7 +33,7 @@ public class DefaultNIO implements NIO { public DefaultNIO(NWorkspace workspace) { this.workspace=workspace; - this.cmodel = ((DefaultNConfigs) NConfigs.of()).getModel(); + this.cmodel = NWorkspaceExt.of().getConfigModel(); bootModel = NWorkspaceExt.of().getModel().bootModel; } @@ -85,7 +98,7 @@ public NPrintStream stderr() { } private DefaultNWorkspaceConfigModel getConfigModel() { - return ((DefaultNConfigs) NConfigs.of()).getModel(); + return NWorkspaceExt.of(workspace).getConfigModel(); } @@ -149,4 +162,321 @@ public NIO setDefaultTerminal(NTerminal terminal) { cmodel.setTerminal(terminal); return this; } + + @Override + public NPath createPath(String path) { + return createPath(path, null); + } + + @Override + public NPath createPath(File path) { + if (path == null) { + return null; + } + return createPath(new FilePath(path.toPath(), workspace)); + } + + @Override + public NPath createPath(Path path) { + if (path == null) { + return null; + } + return createPath(new FilePath(path, workspace)); + } + + @Override + public NPath createPath(URL path) { + if (path == null) { + return null; + } + return createPath(new URLPath(path, workspace)); + } + + @Override + public NPath createPath(String path, ClassLoader classLoader) { + if (path == null || path.trim().isEmpty()) { + return null; + } + NPath p = getConfigModel().resolve(path, classLoader); + if (p == null) { + throw new NIllegalArgumentException(NMsg.ofC("unable to resolve path from %s", path)); + } + return p; + } + + @Override + public NPath createPath(NPathSPI path) { + if (path == null) { + return null; + } + return new NPathFromSPI(workspace, path); + } + + @Override + public NIO addPathFactory(NPathFactorySPI pathFactory) { + getConfigModel().addPathFactory(pathFactory); + return this; + } + + @Override + public NIO removePathFactory(NPathFactorySPI pathFactory) { + getConfigModel().removePathFactory(pathFactory); + return this; + } + + public NPath ofTempFile(String name) { + return createAnyTempFile(name, false, null); + } + + @Override + public NPath ofTempFolder(String name) { + return createAnyTempFile(name, true, null); + } + + @Override + public NPath ofTempFile() { + return createAnyTempFile(null, false, null); + } + + @Override + public NPath ofTempFolder() { + return createAnyTempFile(null, true, null); + } + + + public NPath ofTempRepositoryFile(String name, NRepository repository) { + return createAnyTempFile(name, false, repository); + } + + @Override + public NPath ofTempRepositoryFolder(String name, NRepository repository) { + return createAnyTempFile(name, true, repository); + } + + @Override + public NPath ofTempRepositoryFile(NRepository repository) { + return createAnyTempFile(null, false, repository); + } + + @Override + public NPath ofTempRepositoryFolder(NRepository repository) { + return createAnyTempFile(null, true, repository); + } + + + public NPath createAnyTempFile(String name, boolean folder, NRepository repositoryId) { + NPath rootFolder = null; + NRepository repositoryById = null; + NSession session = workspace.currentSession(); + if (repositoryId == null) { + rootFolder = NWorkspace.get().getStoreLocation(NStoreType.TEMP); + } else { + repositoryById = repositoryId; + rootFolder = repositoryById.config().getStoreLocation(NStoreType.TEMP); + } + NId appId = NApp.of().getId().orElseGet(()->session.getWorkspace().getRuntimeId()); + if (appId != null) { + rootFolder = rootFolder.resolve(NConstants.Folders.ID).resolve(NWorkspace.get().getDefaultIdBasedir(appId)); + } + if (name == null) { + name = ""; + } + rootFolder.mkdirs(); + NStringBuilder ext = new NStringBuilder(NIOUtils.getFileExtension(name, false, true)); + NStringBuilder prefix = new NStringBuilder((ext.length() > 0) ? name.substring(0, name.length() - ext.length()) : name); + if (ext.isEmpty() && prefix.isEmpty()) { + prefix.append("nuts-"); + if (!folder) { + ext.append(".tmp"); + } + } else if (ext.isEmpty()) { + if (!folder) { + ext.append("-tmp"); + } + } else if (prefix.isEmpty()) { + prefix.append(ext); + ext.clear(); + ext.append("-tmp"); + } + if (!prefix.endsWith("-")) { + prefix.append('-'); + } + if (prefix.length() < 3) { + if (prefix.length() < 3) { + prefix.append('A'); + if (prefix.length() < 3) { + prefix.append('B'); + } + } + } + + if (folder) { + for (int i = 0; i < 15; i++) { + File temp = null; + try { + temp = File.createTempFile(prefix.toString(), ext.toString(), rootFolder.toFile().get()); + if (temp.delete() && temp.mkdir()) { + return NPath.of(temp.toPath()) + .setUserTemporary(true); + } + } catch (IOException ex) { + // + } + } + throw new NIOException(NMsg.ofC("could not create temp directory: %s*%s", rootFolder + File.separator + prefix, ext)); + } else { + try { + return NPath.of(File.createTempFile(prefix.toString(), ext.toString(), rootFolder.toFile().get()).toPath()) + .setUserTemporary(true); + } catch (IOException e) { + throw new NIOException(e); + } + } + } + + @Override + public String probeContentType(Path path) { + return probeContentType(path == null ? null : NPath.of(path)); + } + + @Override + public String probeContentType(File path) { + return probeContentType(path == null ? null : NPath.of(path)); + } + + @Override + public String probeContentType(URL path) { + return probeContentType(path == null ? null : NPath.of(path)); + } + + @Override + public String probeContentType(NPath path) { + List allSupported = NExtensions.of() + .createComponents(NContentTypeResolver.class, path); + NCallableSupport best = null; + for (NContentTypeResolver r : allSupported) { + NCallableSupport s = r.probeContentType(path); + if (s != null && s.isValid()) { + if (best == null || s.getSupportLevel() > best.getSupportLevel()) { + best = s; + } + } + } + if (best == null) { + return null; + } + return best.call(); + } + + @Override + public List findExtensionsByContentType(String contentType) { + List allSupported = NExtensions.of() + .createComponents(NContentTypeResolver.class, null); + LinkedHashSet all = new LinkedHashSet<>(); + for (NContentTypeResolver r : allSupported) { + List s = r.findExtensionsByContentType(contentType); + if (s != null) { + all.addAll(s.stream().filter(x->!NBlankable.isBlank(x)).collect(Collectors.toList())); + } + } + return new ArrayList<>(all); + } + + @Override + public List findContentTypesByExtension(String extension) { + List allSupported = NExtensions.of() + .createComponents(NContentTypeResolver.class, null); + LinkedHashSet all = new LinkedHashSet<>(); + for (NContentTypeResolver r : allSupported) { + List s = r.findContentTypesByExtension(extension); + if (s != null) { + all.addAll(s.stream().filter(NBlankable::isBlank).collect(Collectors.toList())); + } + } + return new ArrayList<>(all); + } + + @Override + public String probeContentType(InputStream stream) { + byte[] buffer = NIOUtils.readBestEffort(4096, stream); + return probeContentType(buffer); + } + + @Override + public String probeContentType(byte[] bytes) { + List allSupported = NExtensions.of() + .createComponents(NContentTypeResolver.class, bytes); + NCallableSupport best = null; + for (NContentTypeResolver r : allSupported) { + NCallableSupport s = r.probeContentType(bytes); + if (s != null && s.isValid()) { + if (best == null || s.getSupportLevel() > best.getSupportLevel()) { + best = s; + } + } + } + if (best == null) { + return null; + } + return best.call(); + } + + @Override + public String probeCharset(URL path) { + return probeCharset(path == null ? null : NPath.of(path)); + } + + @Override + public String probeCharset(File path) { + return probeCharset(path == null ? null : NPath.of(path)); + } + + @Override + public String probeCharset(Path path) { + return probeCharset(path == null ? null : NPath.of(path)); + } + + @Override + public String probeCharset(NPath path) { + List allSupported = NExtensions.of() + .createComponents(NCharsetResolver.class, path); + NCallableSupport best = null; + for (NCharsetResolver r : allSupported) { + NCallableSupport s = r.probeCharset(path); + if (s != null && s.isValid()) { + if (best == null || s.getSupportLevel() > best.getSupportLevel()) { + best = s; + } + } + } + if (best == null) { + return null; + } + return best.call(); + } + + @Override + public String probeCharset(InputStream stream) { + byte[] buffer = NIOUtils.readBestEffort(4096*10, stream); + return probeCharset(buffer); + } + + @Override + public String probeCharset(byte[] bytes) { + List allSupported = NExtensions.of() + .createComponents(NCharsetResolver.class, bytes); + NCallableSupport best = null; + for (NCharsetResolver r : allSupported) { + NCallableSupport s = r.probeCharset(bytes); + if (s != null && s.isValid()) { + if (best == null || s.getSupportLevel() > best.getSupportLevel()) { + best = s; + } + } + } + if (best == null) { + return null; + } + return best.call(); + } } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/inputstream/DefaultNIORPI.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/inputstream/DefaultNIORPI.java index dfbdff849..28fae46db 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/inputstream/DefaultNIORPI.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/inputstream/DefaultNIORPI.java @@ -1,8 +1,9 @@ package net.thevpc.nuts.runtime.standalone.io.inputstream; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NBootManager; -import net.thevpc.nuts.env.NBootOptions; + +import net.thevpc.nuts.NBootOptions; + import net.thevpc.nuts.io.*; import net.thevpc.nuts.runtime.standalone.boot.DefaultNBootModel; import net.thevpc.nuts.runtime.standalone.io.ask.DefaultNAsk; @@ -14,7 +15,6 @@ import net.thevpc.nuts.runtime.standalone.util.jclass.JavaClassUtils; import net.thevpc.nuts.runtime.standalone.util.jclass.JavaJarUtils; import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; -import net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNConfigs; import net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNWorkspaceConfigModel; import net.thevpc.nuts.spi.NSystemTerminalBase; import net.thevpc.nuts.text.NText; @@ -34,8 +34,7 @@ public class DefaultNIORPI implements NIORPI { public DefaultNIORPI(NWorkspace workspace) { this.workspace = workspace; - NSession session = workspace.currentSession(); - this.cmodel = ((DefaultNConfigs) NConfigs.of()).getModel(); + this.cmodel = NWorkspaceExt.of().getConfigModel(); bootModel = NWorkspaceExt.of().getModel().bootModel; } @@ -65,7 +64,7 @@ public NPrintStream ofPrintStream(OutputStream out, NTerminalMode expectedMode, if (out == null) { return null; } - NBootOptions woptions = NBootManager.of().getBootOptions(); + NBootOptions woptions = NWorkspace.get().getBootOptions(); NTerminalMode expectedMode0 = woptions.getTerminalMode().orElse(NTerminalMode.DEFAULT); if (expectedMode0 == NTerminalMode.DEFAULT) { if (woptions.getBot().orElse(false)) { @@ -212,7 +211,6 @@ public NInputSource ofMultiRead(NInputSource source) { if (source.isMultiRead()) { return source; } - NSession session = workspace.currentSession(); NPath tf = NPath.ofTempFile(); try (InputStream in = source.getInputStream()) { try (OutputStream out = tf.getOutputStream()) { @@ -313,7 +311,6 @@ public NTerminal createInMemoryTerminal() { @Override public NTerminal createInMemoryTerminal(boolean mergeErr) { ByteArrayInputStream in = new ByteArrayInputStream(new byte[0]); - NSession session = workspace.currentSession(); NMemoryPrintStream out = NMemoryPrintStream.of(); NMemoryPrintStream err = mergeErr ? out : NMemoryPrintStream.of(); return createTerminal(in, out, err); @@ -333,7 +330,6 @@ public List parseExecutionEntries(NPath file) { return parseExecutionEntries(in, "jar", file.toAbsolute().normalize().toString()); } } catch (IOException ex) { - NSession session = workspace.currentSession(); throw new NIOException(ex); } } else if (file.getName().toLowerCase().endsWith(".class")) { @@ -342,7 +338,6 @@ public List parseExecutionEntries(NPath file) { return parseExecutionEntries(in, "class", file.toAbsolute().normalize().toString()); } } catch (IOException ex) { - NSession session = workspace.currentSession(); throw new NIOException(ex); } } else { @@ -352,7 +347,6 @@ public List parseExecutionEntries(NPath file) { @Override public List parseExecutionEntries(InputStream inputStream, String type, String sourceName) { - NSession session = workspace.currentSession(); if ("jar".equals(type)) { return JavaJarUtils.parseJarExecutionEntries(inputStream); } else if ("class".equals(type)) { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/DefaultNCompressedPathHelper.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/DefaultNCompressedPathHelper.java index 25be90882..61249c108 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/DefaultNCompressedPathHelper.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/DefaultNCompressedPathHelper.java @@ -1,14 +1,13 @@ package net.thevpc.nuts.runtime.standalone.io.path; -import net.thevpc.nuts.*; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.io.util.NPathParts; import net.thevpc.nuts.text.NText; public class DefaultNCompressedPathHelper implements NCompressedPathHelper { @Override - public NText toCompressedString(NPath base, NSession session) { - return NPathParts.compressPath(base.toString(), session); + public NText toCompressedString(NPath base) { + return NPathParts.compressPath(base.toString()); } } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/DefaultNPaths.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/DefaultNPaths.java index 5f9f79da5..6821165ec 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/DefaultNPaths.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/DefaultNPaths.java @@ -1,214 +1,215 @@ -package net.thevpc.nuts.runtime.standalone.io.path; - -import net.thevpc.nuts.*; -import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; -import net.thevpc.nuts.io.NIOException; -import net.thevpc.nuts.io.NPath; -import net.thevpc.nuts.runtime.standalone.io.path.spi.FilePath; -import net.thevpc.nuts.runtime.standalone.io.path.spi.URLPath; -import net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNConfigs; -import net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNWorkspaceConfigModel; -import net.thevpc.nuts.spi.NPathFactorySPI; -import net.thevpc.nuts.spi.NPathSPI; -import net.thevpc.nuts.io.NPaths; -import net.thevpc.nuts.spi.NSupportLevelContext; -import net.thevpc.nuts.util.NIOUtils; -import net.thevpc.nuts.util.NMsg; -import net.thevpc.nuts.util.NStringBuilder; - -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.nio.file.Path; - -public class DefaultNPaths implements NPaths { - private final NWorkspace workspace; - - public DefaultNPaths(NWorkspace workspace) { - this.workspace = workspace; - } - - @Override - public NPath createPath(String path) { - return createPath(path, null); - } - - @Override - public NPath createPath(File path) { - if (path == null) { - return null; - } - return createPath(new FilePath(path.toPath(), workspace)); - } - - @Override - public NPath createPath(Path path) { - if (path == null) { - return null; - } - return createPath(new FilePath(path, workspace)); - } - - @Override - public NPath createPath(URL path) { - if (path == null) { - return null; - } - return createPath(new URLPath(path, workspace)); - } - - @Override - public NPath createPath(String path, ClassLoader classLoader) { - if (path == null || path.trim().isEmpty()) { - return null; - } - NPath p = getModel().resolve(path, classLoader); - if (p == null) { - throw new NIllegalArgumentException(NMsg.ofC("unable to resolve path from %s", path)); - } - return p; - } - - @Override - public NPath createPath(NPathSPI path) { - if (path == null) { - return null; - } - return new NPathFromSPI(workspace, path); - } - - @Override - public NPaths addPathFactory(NPathFactorySPI pathFactory) { - getModel().addPathFactory(pathFactory); - return this; - } - - @Override - public NPaths removePathFactory(NPathFactorySPI pathFactory) { - getModel().removePathFactory(pathFactory); - return this; - } - - private DefaultNWorkspaceConfigModel getModel() { - return ((DefaultNConfigs) NConfigs.of()).getModel(); - } - - @Override - public int getSupportLevel(NSupportLevelContext context) { - return NConstants.Support.DEFAULT_SUPPORT; - } - - - public NPath ofTempFile(String name) { - return createAnyTempFile(name, false, null); - } - - @Override - public NPath ofTempFolder(String name) { - return createAnyTempFile(name, true, null); - } - - @Override - public NPath ofTempFile() { - return createAnyTempFile(null, false, null); - } - - @Override - public NPath ofTempFolder() { - return createAnyTempFile(null, true, null); - } - - - public NPath ofTempRepositoryFile(String name, NRepository repository) { - return createAnyTempFile(name, false, repository); - } - - @Override - public NPath ofTempRepositoryFolder(String name, NRepository repository) { - return createAnyTempFile(name, true, repository); - } - - @Override - public NPath ofTempRepositoryFile(NRepository repository) { - return createAnyTempFile(null, false, repository); - } - - @Override - public NPath ofTempRepositoryFolder(NRepository repository) { - return createAnyTempFile(null, true, repository); - } - - - public NPath createAnyTempFile(String name, boolean folder, NRepository repositoryId) { - NPath rootFolder = null; - NRepository repositoryById = null; - NSession session = workspace.currentSession(); - if (repositoryId == null) { - rootFolder = NLocations.of().getStoreLocation(NStoreType.TEMP); - } else { - repositoryById = repositoryId; - rootFolder = repositoryById.config().getStoreLocation(NStoreType.TEMP); - } - NId appId = NApp.of().getId().orElseGet(()->session.getWorkspace().getRuntimeId()); - if (appId != null) { - rootFolder = rootFolder.resolve(NConstants.Folders.ID).resolve(NLocations.of().getDefaultIdBasedir(appId)); - } - if (name == null) { - name = ""; - } - rootFolder.mkdirs(); - NStringBuilder ext = new NStringBuilder(NIOUtils.getFileExtension(name, false, true)); - NStringBuilder prefix = new NStringBuilder((ext.length() > 0) ? name.substring(0, name.length() - ext.length()) : name); - if (ext.isEmpty() && prefix.isEmpty()) { - prefix.append("nuts-"); - if (!folder) { - ext.append(".tmp"); - } - } else if (ext.isEmpty()) { - if (!folder) { - ext.append("-tmp"); - } - } else if (prefix.isEmpty()) { - prefix.append(ext); - ext.clear(); - ext.append("-tmp"); - } - if (!prefix.endsWith("-")) { - prefix.append('-'); - } - if (prefix.length() < 3) { - if (prefix.length() < 3) { - prefix.append('A'); - if (prefix.length() < 3) { - prefix.append('B'); - } - } - } - - if (folder) { - for (int i = 0; i < 15; i++) { - File temp = null; - try { - temp = File.createTempFile(prefix.toString(), ext.toString(), rootFolder.toFile().get()); - if (temp.delete() && temp.mkdir()) { - return NPath.of(temp.toPath()) - .setUserTemporary(true); - } - } catch (IOException ex) { - // - } - } - throw new NIOException(NMsg.ofC("could not create temp directory: %s*%s", rootFolder + File.separator + prefix, ext)); - } else { - try { - return NPath.of(File.createTempFile(prefix.toString(), ext.toString(), rootFolder.toFile().get()).toPath()) - .setUserTemporary(true); - } catch (IOException e) { - throw new NIOException(e); - } - } - } - -} +//package net.thevpc.nuts.runtime.standalone.io.path; +// +//import net.thevpc.nuts.*; +//import net.thevpc.nuts.NConstants; +// +// +//import net.thevpc.nuts.NStoreType; +//import net.thevpc.nuts.io.NIOException; +//import net.thevpc.nuts.io.NPath; +//import net.thevpc.nuts.runtime.standalone.io.path.spi.FilePath; +//import net.thevpc.nuts.runtime.standalone.io.path.spi.URLPath; +//import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; +//import net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNWorkspaceConfigModel; +//import net.thevpc.nuts.spi.NPathFactorySPI; +//import net.thevpc.nuts.spi.NPathSPI; +//import net.thevpc.nuts.io.NPaths; +//import net.thevpc.nuts.spi.NSupportLevelContext; +//import net.thevpc.nuts.util.NIOUtils; +//import net.thevpc.nuts.util.NMsg; +//import net.thevpc.nuts.util.NStringBuilder; +// +//import java.io.File; +//import java.io.IOException; +//import java.net.URL; +//import java.nio.file.Path; +// +//public class DefaultNPaths implements NPaths { +// private final NWorkspace workspace; +// +// public DefaultNPaths(NWorkspace workspace) { +// this.workspace = workspace; +// } +// +// @Override +// public NPath createPath(String path) { +// return createPath(path, null); +// } +// +// @Override +// public NPath createPath(File path) { +// if (path == null) { +// return null; +// } +// return createPath(new FilePath(path.toPath(), workspace)); +// } +// +// @Override +// public NPath createPath(Path path) { +// if (path == null) { +// return null; +// } +// return createPath(new FilePath(path, workspace)); +// } +// +// @Override +// public NPath createPath(URL path) { +// if (path == null) { +// return null; +// } +// return createPath(new URLPath(path, workspace)); +// } +// +// @Override +// public NPath createPath(String path, ClassLoader classLoader) { +// if (path == null || path.trim().isEmpty()) { +// return null; +// } +// NPath p = getConfigModel().resolve(path, classLoader); +// if (p == null) { +// throw new NIllegalArgumentException(NMsg.ofC("unable to resolve path from %s", path)); +// } +// return p; +// } +// +// @Override +// public NPath createPath(NPathSPI path) { +// if (path == null) { +// return null; +// } +// return new NPathFromSPI(workspace, path); +// } +// +// @Override +// public NPaths addPathFactory(NPathFactorySPI pathFactory) { +// getConfigModel().addPathFactory(pathFactory); +// return this; +// } +// +// @Override +// public NPaths removePathFactory(NPathFactorySPI pathFactory) { +// getConfigModel().removePathFactory(pathFactory); +// return this; +// } +// +// private DefaultNWorkspaceConfigModel getConfigModel() { +// return NWorkspaceExt.of(workspace).getConfigModel(); +// } +// +// @Override +// public int getSupportLevel(NSupportLevelContext context) { +// return NConstants.Support.DEFAULT_SUPPORT; +// } +// +// +// public NPath ofTempFile(String name) { +// return createAnyTempFile(name, false, null); +// } +// +// @Override +// public NPath ofTempFolder(String name) { +// return createAnyTempFile(name, true, null); +// } +// +// @Override +// public NPath ofTempFile() { +// return createAnyTempFile(null, false, null); +// } +// +// @Override +// public NPath ofTempFolder() { +// return createAnyTempFile(null, true, null); +// } +// +// +// public NPath ofTempRepositoryFile(String name, NRepository repository) { +// return createAnyTempFile(name, false, repository); +// } +// +// @Override +// public NPath ofTempRepositoryFolder(String name, NRepository repository) { +// return createAnyTempFile(name, true, repository); +// } +// +// @Override +// public NPath ofTempRepositoryFile(NRepository repository) { +// return createAnyTempFile(null, false, repository); +// } +// +// @Override +// public NPath ofTempRepositoryFolder(NRepository repository) { +// return createAnyTempFile(null, true, repository); +// } +// +// +// public NPath createAnyTempFile(String name, boolean folder, NRepository repositoryId) { +// NPath rootFolder = null; +// NRepository repositoryById = null; +// NSession session = workspace.currentSession(); +// if (repositoryId == null) { +// rootFolder = NWorkspace.get().getStoreLocation(NStoreType.TEMP); +// } else { +// repositoryById = repositoryId; +// rootFolder = repositoryById.config().getStoreLocation(NStoreType.TEMP); +// } +// NId appId = NApp.of().getId().orElseGet(()->session.getWorkspace().getRuntimeId()); +// if (appId != null) { +// rootFolder = rootFolder.resolve(NConstants.Folders.ID).resolve(NWorkspace.get().getDefaultIdBasedir(appId)); +// } +// if (name == null) { +// name = ""; +// } +// rootFolder.mkdirs(); +// NStringBuilder ext = new NStringBuilder(NIOUtils.getFileExtension(name, false, true)); +// NStringBuilder prefix = new NStringBuilder((ext.length() > 0) ? name.substring(0, name.length() - ext.length()) : name); +// if (ext.isEmpty() && prefix.isEmpty()) { +// prefix.append("nuts-"); +// if (!folder) { +// ext.append(".tmp"); +// } +// } else if (ext.isEmpty()) { +// if (!folder) { +// ext.append("-tmp"); +// } +// } else if (prefix.isEmpty()) { +// prefix.append(ext); +// ext.clear(); +// ext.append("-tmp"); +// } +// if (!prefix.endsWith("-")) { +// prefix.append('-'); +// } +// if (prefix.length() < 3) { +// if (prefix.length() < 3) { +// prefix.append('A'); +// if (prefix.length() < 3) { +// prefix.append('B'); +// } +// } +// } +// +// if (folder) { +// for (int i = 0; i < 15; i++) { +// File temp = null; +// try { +// temp = File.createTempFile(prefix.toString(), ext.toString(), rootFolder.toFile().get()); +// if (temp.delete() && temp.mkdir()) { +// return NPath.of(temp.toPath()) +// .setUserTemporary(true); +// } +// } catch (IOException ex) { +// // +// } +// } +// throw new NIOException(NMsg.ofC("could not create temp directory: %s*%s", rootFolder + File.separator + prefix, ext)); +// } else { +// try { +// return NPath.of(File.createTempFile(prefix.toString(), ext.toString(), rootFolder.toFile().get()).toPath()) +// .setUserTemporary(true); +// } catch (IOException e) { +// throw new NIOException(e); +// } +// } +// } +// +//} diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/DirectoryScanner.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/DirectoryScanner.java index cb7add48f..cec2ad06f 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/DirectoryScanner.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/DirectoryScanner.java @@ -18,11 +18,9 @@ public class DirectoryScanner { // private Pattern pattern; private PathPart[] parts; // private DirectoryScannerFS fs; - private NSession session; - public DirectoryScanner(NPath pattern, NSession session) { + public DirectoryScanner(NPath pattern) { this.initialPattern = pattern.toAbsolute().normalize(); - this.session = session; parts = buildParts(initialPattern); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/NCompressedPath.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/NCompressedPath.java index fd210a78f..b7bc3f474 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/NCompressedPath.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/NCompressedPath.java @@ -31,7 +31,7 @@ public class NCompressedPath extends NPathBase { public NCompressedPath(NPath base, NCompressedPathHelper compressedPathHelper) { super(base.getWorkspace()); this.base = base; - this.formattedCompressedForm = compressedPathHelper.toCompressedString(base, base.getWorkspace().currentSession()); + this.formattedCompressedForm = compressedPathHelper.toCompressedString(base); this.compressedForm = this.formattedCompressedForm.filteredText(); this.compressedPathHelper = compressedPathHelper; } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/NCompressedPathBase.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/NCompressedPathBase.java index e08f05b02..29feecee6 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/NCompressedPathBase.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/NCompressedPathBase.java @@ -1,6 +1,5 @@ package net.thevpc.nuts.runtime.standalone.io.path; -import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; import net.thevpc.nuts.cmdline.NCmdLine; import net.thevpc.nuts.format.NFormat; @@ -11,7 +10,6 @@ import net.thevpc.nuts.spi.NSupportLevelContext; import net.thevpc.nuts.text.NText; import net.thevpc.nuts.text.NTextStyle; -import net.thevpc.nuts.text.NTexts; import net.thevpc.nuts.util.NOptional; import net.thevpc.nuts.util.NStream; @@ -34,7 +32,7 @@ public class NCompressedPathBase extends NPathBase { public NCompressedPathBase(NPath base) { super(base.getWorkspace()); this.base = base; - this.compressedForm = compressUrl(base.toString(), base.getWorkspace().currentSession()); + this.compressedForm = compressUrl(base.toString()); this.formattedCompressedForm = NText.ofStyled(compressedForm, NTextStyle.path()); } @@ -50,12 +48,12 @@ public NPath copy() { return new NCompressedPathBase(base, compressedForm, formattedCompressedForm).copyExtraFrom(this); } - public static String compressUrl(String path, NSession session) { + public static String compressUrl(String path) { NPathParts p = new NPathParts(path); switch (p.getType()) { case FILE_URL: case URL: { - return new NPathParts(p.getType(), p.getProtocol(), p.getAuthority(), NPathParts.compressLocalPath(p.getFile(), 0, 2), p.getQuery().length() > 0 ? "..." : "", p.getRef().length() > 0 ? "..." : "", session + return new NPathParts(p.getType(), p.getProtocol(), p.getAuthority(), NPathParts.compressLocalPath(p.getFile(), 0, 2), p.getQuery().length() > 0 ? "..." : "", p.getRef().length() > 0 ? "..." : "" ).toString(); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/NCompressedPathHelper.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/NCompressedPathHelper.java index 972fbfa3b..f0628e87c 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/NCompressedPathHelper.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/NCompressedPathHelper.java @@ -1,9 +1,8 @@ package net.thevpc.nuts.runtime.standalone.io.path; import net.thevpc.nuts.io.NPath; -import net.thevpc.nuts.NSession; import net.thevpc.nuts.text.NText; public interface NCompressedPathHelper { - NText toCompressedString(NPath path, NSession session); + NText toCompressedString(NPath path); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/NPathFromSPI.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/NPathFromSPI.java index 537b2740d..3aed5ca0b 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/NPathFromSPI.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/NPathFromSPI.java @@ -1,8 +1,9 @@ package net.thevpc.nuts.runtime.standalone.io.path; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; + + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.format.NTreeVisitor; import net.thevpc.nuts.io.*; import net.thevpc.nuts.runtime.standalone.io.path.spi.NPathSPIHelper; @@ -144,7 +145,6 @@ public NPath writeBytes(byte[] bytes, NPathOption... options) { try (OutputStream os = getOutputStream()) { os.write(bytes); } catch (IOException ex) { - NSession session = workspace.currentSession(); throw new NIOException(NMsg.ofC("unable to write to %s", this)); } return this; @@ -194,13 +194,11 @@ public NStream stream() { if (p != null) { return p; } - NSession session = workspace.currentSession(); return NStream.ofEmpty(); } @Override public InputStream getInputStream(NPathOption... options) { - NSession session = workspace.currentSession(); return NInputSourceBuilder.of(base.getInputStream(this, options)) .setMetadata(getMetaData()) .createInputStream(); @@ -208,7 +206,6 @@ public InputStream getInputStream(NPathOption... options) { @Override public OutputStream getOutputStream(NPathOption... options) { - NSession session = workspace.currentSession(); return NOutputStreamBuilder.of(base.getOutputStream(this, options)) .setMetadata(this.getMetaData()) .createOutputStream() @@ -250,12 +247,11 @@ public NPath expandPath(Function resolver) { String s = StringPlaceHolderParser.replaceDollarPlaceHolders(toString(), resolver); if (s.length() > 0) { if (s.startsWith("~")) { - NLocations locations = NLocations.of(); if (s.equals("~~")) { - NPath nutsHome = locations.getHomeLocation(NStoreType.CONF); + NPath nutsHome = workspace.getHomeLocation(NStoreType.CONF); return nutsHome.normalize(); } else if (s.startsWith("~~") && s.length() > 2 && (s.charAt(2) == '/' || s.charAt(2) == '\\')) { - NPath nutsHome = locations.getHomeLocation(NStoreType.CONF); + NPath nutsHome = workspace.getHomeLocation(NStoreType.CONF); return nutsHome.resolve(s.substring(3)).normalize(); } else if (s.equals("~")) { return NPath.ofUserHome(); @@ -430,8 +426,7 @@ public NStream walk(int maxDepth, NPathOption[] options) { } if (NUseDefaultUtils.isUseDefault(base.getClass(), "walk", NPath.class, int.class, NPathOption[].class)) { - NSession session = workspace.currentSession(); - return NPathSPIHelper.walk(session, this, maxDepth, options1); + return NPathSPIHelper.walk(this, maxDepth, options1); } else { return base.walk(this, maxDepth, options); } @@ -482,8 +477,7 @@ public NPath walkDfs(NTreeVisitor visitor, int maxDepth, NPathOption... o } if (NUseDefaultUtils.isUseDefault(base.getClass(), "walkDfs", NPath.class, NTreeVisitor.class, int.class, NPathOption[].class)) { - NSession session = workspace.currentSession(); - NPathSPIHelper.walkDfs(session, this, visitor, maxDepth, options); + NPathSPIHelper.walkDfs( this, visitor, maxDepth, options); } else { base.walkDfs(this, visitor, maxDepth, options); } @@ -492,8 +486,7 @@ public NPath walkDfs(NTreeVisitor visitor, int maxDepth, NPathOption... o @Override public NStream walkGlob(NPathOption... options) { - NSession session = workspace.currentSession(); - return new DirectoryScanner(this, session).stream(); + return new DirectoryScanner(this).stream(); } @Override diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/ClassLoaderPath.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/ClassLoaderPath.java index 9cf4b7e8f..ce22414dd 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/ClassLoaderPath.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/ClassLoaderPath.java @@ -16,7 +16,7 @@ public class ClassLoaderPath extends URLPath { private final String effectivePath; private final ClassLoader loader; private final NWorkspace workspace; - private static String fileOf(String path,boolean check, NSession session){ + private static String fileOf(String path,boolean check){ if(path!=null){ if(path.startsWith("classpath:")){ String p=path; @@ -34,9 +34,9 @@ private static String fileOf(String path,boolean check, NSession session){ } public ClassLoaderPath(String path, ClassLoader loader, NWorkspace workspace) { - super(loader.getResource(fileOf(path,true,workspace.currentSession())), workspace, true); + super(loader.getResource(fileOf(path,true)), workspace, true); this.path = path; - this.effectivePath = fileOf(path,false,workspace.currentSession()); + this.effectivePath = fileOf(path,false); this.loader = loader; this.workspace = workspace; } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/FilePath.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/FilePath.java index f492b0b8e..dbb0e13bb 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/FilePath.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/FilePath.java @@ -196,12 +196,12 @@ public String getContentEncoding(NPath basePath) { @Override public String getContentType(NPath basePath) { - return NContentTypes.of().probeContentType(value); + return NIO.of().probeContentType(value); } @Override public String getCharset(NPath basePath) { - return NContentTypes.of().probeCharset(value); + return NIO.of().probeCharset(value); } @Override diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/GenericFilePath.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/GenericFilePath.java index 0ea674830..f968b0af2 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/GenericFilePath.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/GenericFilePath.java @@ -3,7 +3,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NEnvs; + import net.thevpc.nuts.format.NTreeVisitor; import net.thevpc.nuts.io.*; import net.thevpc.nuts.spi.NFormatSPI; @@ -13,7 +13,7 @@ import net.thevpc.nuts.text.NText; import net.thevpc.nuts.util.NMsg; import net.thevpc.nuts.util.NOptional; -import net.thevpc.nuts.env.NOsFamily; +import net.thevpc.nuts.NOsFamily; import net.thevpc.nuts.util.NStream; import java.io.*; @@ -310,7 +310,7 @@ public boolean isAbsolute(NPath basePath) { if (f.getSeparator().length() > 0) { return true; } - if (NEnvs.of().getOsFamily() == NOsFamily.WINDOWS) { + if (NWorkspace.get().getOsFamily() == NOsFamily.WINDOWS) { String n = f.getName(); //test if the name is a drive name if (n.length() == 2 && n.charAt(1) == ':') { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/InvalidFilePath.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/InvalidFilePath.java index d3b0b030f..2da4cf4ca 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/InvalidFilePath.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/InvalidFilePath.java @@ -390,7 +390,6 @@ public MyPathFormat(InvalidFilePath p) { } public NText asFormattedString() { - NSession session=p.workspace.currentSession(); return NText.of(p.value); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/NPathSPIHelper.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/NPathSPIHelper.java index e1f8fef4e..efcf5a8b8 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/NPathSPIHelper.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/NPathSPIHelper.java @@ -1,6 +1,5 @@ package net.thevpc.nuts.runtime.standalone.io.path.spi; -import net.thevpc.nuts.*; import net.thevpc.nuts.elem.NElement; import net.thevpc.nuts.elem.NElements; import net.thevpc.nuts.format.NTreeVisitResult; @@ -26,13 +25,13 @@ public Data(NPath p, int depth, boolean folder) { this.folder = folder; } } - public static NStream walk(NSession session, NPath basePath, int maxDepth, NPathOption[] options) { + public static NStream walk(NPath basePath, int maxDepth, NPathOption[] options) { boolean noMax=maxDepth<=0 || maxDepth==Integer.MAX_VALUE; Iterator it = new NPathIterator(basePath, noMax, maxDepth); return NStream.of(it); } - public static void walkDfs(NSession session, NPath basePath, NTreeVisitor visitor, int maxDepth, NPathOption... options) { + public static void walkDfs(NPath basePath, NTreeVisitor visitor, int maxDepth, NPathOption... options) { boolean noMax=maxDepth<=0 || maxDepth==Integer.MAX_VALUE; Stack stack=new Stack<>(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/NResourcePath.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/NResourcePath.java index 887fe2b81..eaf489e1b 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/NResourcePath.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/NResourcePath.java @@ -92,7 +92,7 @@ protected static String rebuildURL(String location, NId[] ids) { sb.append(location); return sb.toString(); } - protected static NText rebuildURL2(NText location, NId[] ids, NSession session) { + protected static NText rebuildURL2(NText location, NId[] ids) { NTexts txt = NTexts.of(); NTextBuilder sb = txt.ofBuilder(); sb.append(nResourceProtocol, NTextStyle.path()); @@ -617,10 +617,9 @@ public int getSupportLevel(NSupportLevelContext context) { private class NResourceCompressedPath implements NCompressedPathHelper { @Override - public NText toCompressedString(NPath base, NSession session) { - return rebuildURL2(NPathParts.compressPath(location, session), + public NText toCompressedString(NPath base) { + return rebuildURL2(NPathParts.compressPath(location), ids.stream().map(x -> NId.of(x.getArtifactId()).get()).toArray(NId[]::new) - ,session ); } } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/URLPath.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/URLPath.java index e1029cbe7..bfb7ec985 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/URLPath.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/path/spi/URLPath.java @@ -15,7 +15,6 @@ import net.thevpc.nuts.spi.NPathSPI; import net.thevpc.nuts.spi.NSupportLevelContext; import net.thevpc.nuts.text.NText; -import net.thevpc.nuts.text.NTexts; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.util.NMsg; import net.thevpc.nuts.util.NOptional; @@ -393,7 +392,7 @@ public String getContentType(NPath basePath) { } catch (Exception e) { // } - return NContentTypes.of().probeContentType(basePath); + return NIO.of().probeContentType(basePath); } @Override @@ -413,7 +412,7 @@ public String getCharset(NPath basePath) { } catch (Exception e) { // } - return NContentTypes.of().probeCharset(basePath); + return NIO.of().probeCharset(basePath); } @Override @@ -524,15 +523,13 @@ public NPath getParent(NPath basePath) { if (ppath == null) { return null; } - NSession session=workspace.currentSession(); URL url = new URL( new NPathParts(NPathParts.Type.URL, this.url.getProtocol(), this.url.getAuthority(), ppath, this.url.getQuery(), - this.url.getRef(), - session + this.url.getRef() ).toString() ); return NPath.of(url); @@ -832,7 +829,6 @@ public String getName() { } public NText asFormattedString() { - NSession session=p.workspace.currentSession(); if (p.url == null) { return NText.ofPlain(""); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/printstream/AnsiNPrintStreamTerminalBase.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/printstream/AnsiNPrintStreamTerminalBase.java index 998ffb099..aebcdb75b 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/printstream/AnsiNPrintStreamTerminalBase.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/printstream/AnsiNPrintStreamTerminalBase.java @@ -84,7 +84,6 @@ public NCmdLineAutoCompleteResolver getAutoCompleteResolver() { @Override public Object run(NTerminalCmd command, NPrintStream printStream) { - NSession session=getWorkspace().currentSession(); String s = NAnsiTermHelper.of(getWorkspace()).command(command); if (s != null) { byte[] bytes = s.getBytes(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/printstream/NPrintStreamSystem.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/printstream/NPrintStreamSystem.java index c62333b44..d90f11d91 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/printstream/NPrintStreamSystem.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/printstream/NPrintStreamSystem.java @@ -2,7 +2,8 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NWorkspaceTerminalOptions; -import net.thevpc.nuts.env.NBootManager; + + import net.thevpc.nuts.io.NPrintStream; import net.thevpc.nuts.io.NTerminalMode; import net.thevpc.nuts.spi.NSystemTerminalBase; @@ -80,7 +81,7 @@ private static NTerminalMode resolveMode(OutputStream out, Boolean ansi, NWorksp if (ansi != null) { return ansi ? NTerminalMode.ANSI : NTerminalMode.INHERITED; } - NWorkspaceTerminalOptions b = NBootManager.of().getBootTerminal(); + NWorkspaceTerminalOptions b = NWorkspace.get().getBootTerminal(); if (b.getFlags().contains("ansi")) { return NTerminalMode.ANSI; } else { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/progress/DefaultNCountProgressListener.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/progress/DefaultNCountProgressListener.java index 5ae37c62d..0aaf7afcd 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/progress/DefaultNCountProgressListener.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/progress/DefaultNCountProgressListener.java @@ -37,7 +37,7 @@ public DecimalFormat df(NProgressEvent event) { } public BytesSizeFormat mf(NProgressEvent event) { - return new BytesSizeFormat("BTD1F",event.getSession()); + return new BytesSizeFormat("BTD1F"); } @Override diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/progress/ProgressOptions.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/progress/ProgressOptions.java index c626a0a79..47959292e 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/progress/ProgressOptions.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/progress/ProgressOptions.java @@ -1,6 +1,7 @@ package net.thevpc.nuts.runtime.standalone.io.progress; import net.thevpc.nuts.*; + import net.thevpc.nuts.spi.NScopeType; import net.thevpc.nuts.util.NLiteral; import net.thevpc.nuts.util.NOptional; @@ -38,7 +39,7 @@ public static ProgressOptions of(NSession session) { o.put(k, NLiteral.of(v)); } } - for (Map.Entry e : NConfigs.of().getConfigMap().entrySet()) { + for (Map.Entry e : NWorkspace.get().getConfigMap().entrySet()) { if (e.getKey().startsWith("progress.")) { String k = e.getKey().substring("progress.".length()); if (o.get(k).isNotPresent()) { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/progress/TraceNProgressListener.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/progress/TraceNProgressListener.java index f57aa8f3d..c27b0041c 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/progress/TraceNProgressListener.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/progress/TraceNProgressListener.java @@ -84,7 +84,7 @@ public boolean onProgress0(NProgressEvent event, boolean end) { return false; } formattedLine.append(p); - BytesSizeFormat mf = new BytesSizeFormat("BTD1F", event.getSession()); + BytesSizeFormat mf = new BytesSizeFormat("BTD1F"); if(Double.isNaN(percent)){ formattedLine.append(" ").append(text.ofStyled(String.format("%6s", ""), NTextStyle.config())).append(" "); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/terminal/DefaultNSystemTerminalBase.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/terminal/DefaultNSystemTerminalBase.java index b8b9ff423..70911291a 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/terminal/DefaultNSystemTerminalBase.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/terminal/DefaultNSystemTerminalBase.java @@ -5,8 +5,9 @@ import net.thevpc.nuts.NWorkspaceTerminalOptions; import net.thevpc.nuts.cmdline.NCmdLineAutoCompleteResolver; import net.thevpc.nuts.cmdline.NCmdLineHistory; -import net.thevpc.nuts.env.NBootManager; -import net.thevpc.nuts.env.NBootOptions; + +import net.thevpc.nuts.NBootOptions; + import net.thevpc.nuts.io.*; import net.thevpc.nuts.runtime.standalone.io.printstream.NPrintStreamSystem; import net.thevpc.nuts.runtime.standalone.util.NCachedValue; @@ -43,7 +44,7 @@ public DefaultNSystemTerminalBase(NWorkspace workspace) { @Override public int getSupportLevel(NSupportLevelContext criteria) { NWorkspace workspace = getWorkspace(); - NBootOptions options = NBootManager.of().getBootOptions(); + NBootOptions options = NWorkspace.get().getBootOptions(); NTerminalMode terminalMode = options.getTerminalMode().orElse(NTerminalMode.DEFAULT); NWorkspaceTerminalOptions bootStdFd = NWorkspaceExt.of().getModel().bootModel.getBootTerminal(); if (terminalMode == NTerminalMode.DEFAULT) { @@ -71,7 +72,6 @@ public int getSupportLevel(NSupportLevelContext criteria) { @Override public String readLine(NPrintStream out, NMsg message) { - NSession session = getWorkspace().currentSession(); if (out == null) { out = getOut(); } @@ -87,7 +87,6 @@ public String readLine(NPrintStream out, NMsg message) { @Override public char[] readPassword(NPrintStream out, NMsg message) { - NSession session = getWorkspace().currentSession(); if (out == null) { out = getOut(); } @@ -198,8 +197,8 @@ public void setStyles(NTextStyles styles, NPrintStream printStream) { // @Override // public int getColumns() { -// int tputCallTimeout = NBootManager.of(session).getBootCustomArgument("---nuts.term.tput.call.timeout").getValue().getInt(60); -// Integer w = NBootManager.of(session).getBootCustomArgument("---nuts.term.width").getValue().getInt(null); +// int tputCallTimeout = NEnvs.of(session).getBootCustomArgument("---nuts.term.tput.call.timeout").getValue().getInt(60); +// Integer w = NEnvs.of(session).getBootCustomArgument("---nuts.term.width").getValue().getInt(null); // if (w == null) { // if (tput_cols == null) { // tput_cols = new NutsCachedValue<>(new DefaultAnsiEscapeCommand.TputEvaluator(session), tputCallTimeout); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/terminal/DefaultNSystemTerminalBaseBoot.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/terminal/DefaultNSystemTerminalBaseBoot.java index fab4a7104..7e344bfba 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/terminal/DefaultNSystemTerminalBaseBoot.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/terminal/DefaultNSystemTerminalBaseBoot.java @@ -1,7 +1,6 @@ package net.thevpc.nuts.runtime.standalone.io.terminal; -import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NBootOptions; +import net.thevpc.nuts.NBootOptions; import net.thevpc.nuts.NConstants; import net.thevpc.nuts.NWorkspaceTerminalOptions; import net.thevpc.nuts.cmdline.NCmdLineAutoCompleteResolver; @@ -72,7 +71,6 @@ public String readLine(NPrintStream out, NMsg message) { out = getOut(); } if (out == null) { - NSession session = getWorkspace().currentSession(); out = NIO.of().stdout(); } if (message != null) { @@ -88,7 +86,6 @@ public char[] readPassword(NPrintStream out, NMsg message) { out = getOut(); } if (out == null) { - NSession session = getWorkspace().currentSession(); out = NIO.of().stdout(); } if (message != null) { @@ -174,7 +171,7 @@ public void setStyles(NTextStyles styles, NPrintStream printStream) { //try { byte[] bytes = s.getBytes(); printStream.writeRaw(bytes,0,bytes.length); -// NWorkspaceTerminalOptions bootStdFd = NBootManager.of(session).getBootTerminal(); +// NWorkspaceTerminalOptions bootStdFd = NEnvs.of(session).getBootTerminal(); // bootStdFd.getOut().write(bytes); //} catch (IOException e) { // throw new NIOException(session, e); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/terminal/DefaultNTerminalFromSystem.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/terminal/DefaultNTerminalFromSystem.java index 019805ad1..b438056c9 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/terminal/DefaultNTerminalFromSystem.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/terminal/DefaultNTerminalFromSystem.java @@ -52,7 +52,6 @@ public BufferedReader getReader() { @Override public String readLine(NPrintStream out, NMsg message) { - NSession session = workspace.currentSession(); if (out == null) { out = out(); } @@ -77,7 +76,6 @@ public String readLine(NPrintStream out, NMsg message) { @Override public char[] readPassword(NPrintStream out, NMsg prompt) { - NSession session = workspace.currentSession(); if (out == null) { out = out(); } @@ -234,7 +232,6 @@ public boolean isErrOverridden() { private CProgressBar getProgressBar() { if (progressBar == null) { - NSession session = workspace.currentSession(); progressBar = CProgressBar.of(); } return progressBar; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/terminal/DefaultWriteTypeProcessor.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/terminal/DefaultWriteTypeProcessor.java index e8a360157..2942bc5d6 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/terminal/DefaultWriteTypeProcessor.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/terminal/DefaultWriteTypeProcessor.java @@ -16,15 +16,13 @@ public class DefaultWriteTypeProcessor { private Supplier error; private NLog log; private NConfirmationMode writeType; - private NSession session; - public DefaultWriteTypeProcessor(NConfirmationMode writeType, NSession session) { + public DefaultWriteTypeProcessor(NConfirmationMode writeType) { this.writeType = writeType; - this.session = session; } - public static DefaultWriteTypeProcessor of(NConfirmationMode writeType, NSession session) { - return new DefaultWriteTypeProcessor(writeType, session); + public static DefaultWriteTypeProcessor of(NConfirmationMode writeType) { + return new DefaultWriteTypeProcessor(writeType); } public DefaultWriteTypeProcessor ask(NMsg m) { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/terminal/NSystemTerminalRef.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/terminal/NSystemTerminalRef.java index a225d6021..7c1039491 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/terminal/NSystemTerminalRef.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/terminal/NSystemTerminalRef.java @@ -33,13 +33,11 @@ public NSystemTerminalRef setBase(NSystemTerminalBase base) { if (old != base) { NWorkspaceEvent event = null; - if (session != null) { - for (NWorkspaceListener workspaceListener : NEvents.of().getWorkspaceListeners()) { - if (event == null) { - event = new DefaultNWorkspaceEvent(session, null, "systemTerminal", null, this); - } - workspaceListener.onUpdateProperty(event); + for (NWorkspaceListener workspaceListener : getWorkspace().getWorkspaceListeners()) { + if (event == null) { + event = new DefaultNWorkspaceEvent(session, null, "systemTerminal", null, this); } + workspaceListener.onUpdateProperty(event); } } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/util/AbstractNInputSource.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/util/AbstractNInputSource.java index 9797b9571..c719e9402 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/util/AbstractNInputSource.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/util/AbstractNInputSource.java @@ -180,7 +180,6 @@ public byte[] getDigest(String algo) { if (NBlankable.isBlank(algo)) { algo = "SHA-1"; } - NSession session = workspace.currentSession(); try (InputStream input = getInputStream()) { MessageDigest sha1 = null; try { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/util/CoreIOUtils.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/util/CoreIOUtils.java index 0f85ecdf4..7955725b7 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/util/CoreIOUtils.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/util/CoreIOUtils.java @@ -25,8 +25,9 @@ package net.thevpc.nuts.runtime.standalone.io.util; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; + + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.text.NText; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.io.*; @@ -335,7 +336,7 @@ public static File resolveLocalFileFromURL(URL url) { public static InputStream getCachedUrlWithSHA1(String path, String sourceTypeName, boolean ignoreSha1NotFound) { NWorkspace workspace=NWorkspace.of().get(); - final NPath cacheBasePath = NLocations.of().getStoreLocation(workspace.getRuntimeId(), NStoreType.CACHE); + final NPath cacheBasePath = NWorkspace.get().getStoreLocation(workspace.getRuntimeId(), NStoreType.CACHE); final NPath urlContent = cacheBasePath.resolve("urls-content"); String sha1 = null; try { @@ -546,10 +547,9 @@ public static Path toPathInputSource(NInputSource is, List tempPaths, bool NPath pp = NPath.of(temp); String ext = pp.getLastExtension(); if (ext.isEmpty()) { - NContentTypes ctt = NContentTypes.of(); - String ct = ctt.probeContentType(temp); + String ct = NIO.of().probeContentType(temp); if (ct != null) { - List e = ctt.findExtensionsByContentType(ct); + List e = NIO.of().findExtensionsByContentType(ct); if (!e.isEmpty()) { NPath newFile = NPath.ofTempFile(name + "." + e.get(0)); Path newFilePath = newFile.toPath().get(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/util/NPathParts.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/util/NPathParts.java index 360db381a..76980bdc8 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/util/NPathParts.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/util/NPathParts.java @@ -18,7 +18,7 @@ public class NPathParts { private final String ref; private final String query; - public NPathParts(Type type, String protocol, String authority, String location, String query, String ref, NSession session) { + public NPathParts(Type type, String protocol, String authority, String location, String query, String ref) { switch (type) { case REF: { this.type = type; @@ -307,7 +307,7 @@ public String toString() { return result.toString(); } - public static NText toNutsString(NText protocol, NText authority, NText path, NText query, NText ref, NSession session) { + public static NText toNutsString(NText protocol, NText authority, NText path, NText query, NText ref) { NTexts txt = NTexts.of(); NTextBuilder result = txt.ofBuilder(); result.append(protocol); @@ -357,11 +357,11 @@ private static String ensureNull(String s, String name) { return ""; } - public static NText compressPath(String path, NSession session) { - return compressPath(path, 2, 2, session); + public static NText compressPath(String path) { + return compressPath(path, 2, 2); } - public static NText compressPath(String path, int left, int right, NSession session) { + public static NText compressPath(String path, int left, int right) { NTexts txt = NTexts.of(); NPathParts p = new NPathParts(path); switch (p.getType()) { @@ -372,8 +372,7 @@ public static NText compressPath(String path, int left, int right, NSession sess NBlankable.isBlank(p.getAuthority()) ? null : txt.ofStyled(p.getAuthority(), NTextStyle.path()), NBlankable.isBlank(p.getFile()) ? null : txt.ofStyled(NPathParts.compressLocalPath(p.getFile(), 0, 2), NTextStyle.path()), NBlankable.isBlank(p.getQuery()) ? null : txt.ofStyled("...", NTextStyle.path()), - NBlankable.isBlank(p.getRef()) ? null : txt.ofStyled("...", NTextStyle.path()), - session + NBlankable.isBlank(p.getRef()) ? null : txt.ofStyled("...", NTextStyle.path()) ); } case REF: { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/lock/DefaultFileNLock.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/lock/DefaultFileNLock.java index 6c3a658b1..dc2db108f 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/lock/DefaultFileNLock.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/lock/DefaultFileNLock.java @@ -5,7 +5,7 @@ import net.thevpc.nuts.concurrent.NLockAcquireException; import net.thevpc.nuts.concurrent.NLockBarrierException; import net.thevpc.nuts.concurrent.NLockReleaseException; -import net.thevpc.nuts.env.NEnvs; + import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.util.TimePeriod; import net.thevpc.nuts.util.NAssert; @@ -24,17 +24,17 @@ public class DefaultFileNLock implements NLock { private static TimePeriod FIVE_MINUTES = new TimePeriod(5, TimeUnit.MINUTES); private Path path; private Object lockedObject; - private NSession session; + private NWorkspace workspace; - public DefaultFileNLock(Path path, Object lockedObject, NSession session) { + public DefaultFileNLock(Path path, Object lockedObject, NWorkspace workspace) { this.path = path; this.lockedObject = lockedObject; - this.session = session; + this.workspace = workspace; } public TimePeriod getDefaultTimePeriod() { return TimePeriod.parse( - NConfigs.of().getConfigProperty("nuts.file-lock.timeout").flatMap(NLiteral::asString).get(), + NWorkspace.get().getConfigProperty("nuts.file-lock.timeout").flatMap(NLiteral::asString).get(), TimeUnit.SECONDS ).orElse(FIVE_MINUTES); } @@ -197,12 +197,11 @@ public boolean tryLockImmediately() { NPath p = NPath.of(path); p.mkParentDirs(); Files.createFile(path); - NEnvs e = NEnvs.of(); Date now = new Date(); Files.write(path, ( - "hostname=" + e.getHostName() + "\n" - + "pid=" + e.getPid() + "\n" + "hostname=" + workspace.getHostName() + "\n" + + "pid=" + workspace.getPid() + "\n" + "time=" + now.getTime() + "\n" + "date=" + now + "\n" ).getBytes()); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/lock/DefaultNLocks.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/lock/DefaultNLocks.java index d848766a3..37828c424 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/lock/DefaultNLocks.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/lock/DefaultNLocks.java @@ -5,8 +5,9 @@ import net.thevpc.nuts.concurrent.NLock; import net.thevpc.nuts.concurrent.NLockAcquireException; import net.thevpc.nuts.concurrent.NLockException; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; + + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.spi.NSupportLevelContext; import net.thevpc.nuts.util.NBlankable; @@ -25,7 +26,6 @@ public DefaultNLocks(NWorkspace workspace) { @Override public NLock create() { - NSession session=getWorkspace().currentSession(); Object s = getSource(); Object lr = getResource(); Path lrPath = null; @@ -44,12 +44,11 @@ public NLock create() { throw new NLockException(NMsg.ofC("unsupported lock %s", lr.getClass().getName()), lr, s); } } - return new DefaultFileNLock(lrPath, s, session); + return new DefaultFileNLock(lrPath, s, getWorkspace()); } @Override public T call(Callable runnable) { - NSession session=getWorkspace().currentSession(); NLock lock = create(); if (!lock.tryLock()) { throw new NLockAcquireException(null, getResource(), lock); @@ -70,7 +69,6 @@ public T call(Callable runnable) { @Override public T call(Callable runnable, long time, TimeUnit unit) { - NSession session=getWorkspace().currentSession(); NLock lock = create(); boolean b = false; try { @@ -97,7 +95,6 @@ public T call(Callable runnable, long time, TimeUnit unit) { @Override public void run(Runnable runnable) { - NSession session=getWorkspace().currentSession(); NLock lock = create(); if (!lock.tryLock()) { throw new NLockAcquireException(null, getResource(), lock); @@ -116,7 +113,6 @@ public void run(Runnable runnable) { @Override public void run(Runnable runnable, long time, TimeUnit unit) { - NSession session=getWorkspace().currentSession(); NLock lock = create(); boolean b = false; try { @@ -146,8 +142,7 @@ private Path toPath(Object lockedObject) { if (NBlankable.isBlank(face)) { face = "content"; } - NSession session=getWorkspace().currentSession(); - return NLocations.of().getStoreLocation((NId) lockedObject, NStoreType.RUN) + return NWorkspace.get().getStoreLocation((NId) lockedObject, NStoreType.RUN) .resolve("nuts-" + face) .toPath().get() ; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/log/DefaultNLogModel.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/log/DefaultNLogModel.java index a9d4bf061..af5e6e1be 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/log/DefaultNLogModel.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/log/DefaultNLogModel.java @@ -25,8 +25,8 @@ package net.thevpc.nuts.runtime.standalone.log; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NBootOptions; -import net.thevpc.nuts.env.NStoreType; +import net.thevpc.nuts.NBootOptions; +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NPrintStream; import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; import net.thevpc.nuts.log.NLog; @@ -181,10 +181,9 @@ public void updateFileHandler(LogRecord record) { if (fileHandler == null) { if (logConfig.getLogFileLevel() != Level.OFF) { if (fileHandler == null) { - NSession session = NLogUtils.resolveSession(record, workspace); try { fileHandler = NLogFileHandler.create( - session, logConfig, true, logFolder); + workspace, logConfig, true, logFolder); fileHandler.setLevel(logConfig.getLogFileLevel()); } catch (Exception ex) { Logger.getLogger(DefaultNLogs.class.getName()).log(Level.FINE, "unable to create file handler", ex); @@ -208,9 +207,7 @@ public void updateTermHandler(LogRecord record) { consoleHandler.setLevel(logConfig.getLogTermLevel()); } } else { - consoleHandler = new NLogConsoleHandler(out, false, - NWorkspaceExt.of().defaultSession() - ); + consoleHandler = new NLogConsoleHandler(out, false,workspace); consoleHandler.setLevel(logConfig.getLogTermLevel()); } } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/log/NLogConsoleHandler.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/log/NLogConsoleHandler.java index 44310503d..d1b5462c5 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/log/NLogConsoleHandler.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/log/NLogConsoleHandler.java @@ -1,6 +1,8 @@ package net.thevpc.nuts.runtime.standalone.log; -import net.thevpc.nuts.env.NBootManager; + + +import net.thevpc.nuts.NWorkspace; import net.thevpc.nuts.log.NLogConfig; import net.thevpc.nuts.io.NPrintStream; import net.thevpc.nuts.NSession; @@ -14,11 +16,11 @@ public class NLogConsoleHandler extends StreamHandler { private NPrintStream out; - private NSession session; + private NWorkspace workspace; - public NLogConsoleHandler(NPrintStream out, boolean closeable, NSession session) { - this.session = session; - setFormatter(new NLogRichFormatter(session, false)); + public NLogConsoleHandler(NPrintStream out, boolean closeable, NWorkspace workspace) { + this.workspace = workspace; + setFormatter(new NLogRichFormatter(workspace, false)); setOutputStream(out, closeable); } @@ -42,11 +44,11 @@ public boolean isLoggable(LogRecord record) { if (!super.isLoggable(record)) { return false; } - NSession session = NLogUtils.resolveSession(record,this.session); + NSession session = NLogUtils.resolveSession(record,this.workspace); if (session.isBot()) { return false; } - NLogConfig logConfig = NBootManager.of().getBootOptions().getLogConfig().orElseGet(NLogConfig::new); + NLogConfig logConfig = NWorkspace.get().getBootOptions().getLogConfig().orElseGet(NLogConfig::new); Level sessionLogLevel = session.getLogTermLevel(); if (sessionLogLevel == null) { if (logConfig != null) { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/log/NLogFileHandler.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/log/NLogFileHandler.java index 4cd5b43fc..cdbdb3c33 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/log/NLogFileHandler.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/log/NLogFileHandler.java @@ -2,7 +2,8 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NBootManager; + + import net.thevpc.nuts.log.NLogConfig; import net.thevpc.nuts.log.NLogRecord; import net.thevpc.nuts.util.NBlankable; @@ -18,12 +19,12 @@ public class NLogFileHandler extends FileHandler { - private NSession session; + private NWorkspace workspace; private String pattern; private int limit; private int count; - public static NLogFileHandler create(NSession session, NLogConfig config, boolean append, Path logFolder) throws IOException, SecurityException { + public static NLogFileHandler create(NWorkspace workspace, NLogConfig config, boolean append, Path logFolder) throws IOException, SecurityException { Level level = config.getLogFileLevel(); String folder = config.getLogFileBase(); String name = config.getLogFileName(); @@ -38,7 +39,7 @@ public static NLogFileHandler create(NSession session, NLogConfig config, boolea name = Instant.now().toString().replace(":", "") + "-nuts-%g.log"; } if (folder == null || NBlankable.isBlank(folder)) { - folder = logFolder + "/" + NConstants.Folders.ID + "/net/thevpc/nuts/nuts/" + session.getWorkspace().getApiVersion(); + folder = logFolder + "/" + NConstants.Folders.ID + "/net/thevpc/nuts/nuts/" + workspace.getApiVersion(); } String pattern = (folder + "/" + name).replace('/', File.separatorChar); if (maxSize <= 0) { @@ -51,18 +52,18 @@ public static NLogFileHandler create(NSession session, NLogConfig config, boolea if (parentFile != null) { parentFile.mkdirs(); } - NLogFileHandler handler = new NLogFileHandler(pattern, maxSize * MEGA, count, append,session); + NLogFileHandler handler = new NLogFileHandler(pattern, maxSize * MEGA, count, append,workspace); handler.setLevel(level); return handler; } - private NLogFileHandler(String pattern, int limit, int count, boolean append, NSession session) throws IOException, SecurityException { + private NLogFileHandler(String pattern, int limit, int count, boolean append, NWorkspace workspace) throws IOException, SecurityException { super(prepare(pattern), limit, count, append); - this.session = session; + this.workspace = workspace; this.pattern = pattern; this.limit = limit; this.count = count; - setFormatter(new NLogRichFormatter(session,true)); + setFormatter(new NLogRichFormatter(workspace,true)); } private static String prepare(String pattern) { @@ -82,9 +83,9 @@ public boolean isLoggable(LogRecord record) { session=((NLogRecord) record).getSession(); } if(session==null){ - session=this.session; + session=this.workspace.currentSession(); } - NLogConfig logConfig = NBootManager.of().getBootOptions().getLogConfig().orElseGet(NLogConfig::new); + NLogConfig logConfig = workspace.getBootOptions().getLogConfig().orElseGet(NLogConfig::new); Level sessionLogLevel = session.getLogFileLevel(); if (sessionLogLevel == null) { if (logConfig != null) { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/log/NLogRichFormatter.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/log/NLogRichFormatter.java index 215c51e47..776420dfe 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/log/NLogRichFormatter.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/log/NLogRichFormatter.java @@ -14,18 +14,18 @@ public class NLogRichFormatter extends Formatter { private long lastMillis = -1; - private NSession session; + private NWorkspace workspace; private boolean filtered; // public static final NutsLogRichFormatter RICH = new NutsLogRichFormatter(); - public NLogRichFormatter(NSession session, boolean filtered) { - this.session = session; + public NLogRichFormatter(NWorkspace workspace, boolean filtered) { + this.workspace = workspace; this.filtered = filtered; } @Override public String format(LogRecord record) { - NLogRecord wRecord = NLogUtils.toNutsLogRecord(record, session); + NLogRecord wRecord = NLogUtils.toNutsLogRecord(record, workspace.currentSession()); NTexts tf = NTexts.of(); NTextBuilder sb = tf.ofBuilder(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/log/NLogUtils.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/log/NLogUtils.java index 755b2b29a..aabb4ec3e 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/log/NLogUtils.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/log/NLogUtils.java @@ -200,8 +200,11 @@ public static final NSession resolveSession(LogRecord record, NWorkspace ws) { if (record instanceof NLogRecord){ session=((NLogRecord) record).getSession(); } + if(session==null && ws!=null){ + session= ws.currentSession(); + } if(session==null){ - session= NWorkspaceExt.of().defaultSession(); + session= NWorkspace.get().currentSession(); } return session; } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/DefaultNRepoFactoryComponent.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/DefaultNRepoFactoryComponent.java index 2e426586c..deeb937ea 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/DefaultNRepoFactoryComponent.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/DefaultNRepoFactoryComponent.java @@ -26,6 +26,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; + import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.repository.impl.nuts.NFolderRepository; import net.thevpc.nuts.runtime.standalone.repository.impl.nuts.NHttpSrvRepository; @@ -76,7 +77,7 @@ public int getSupportLevel(NSupportLevelContext criteria) { public List getDefaultRepositories() { List all=new ArrayList<>(); NSession session=workspace.currentSession(); - if (!NConfigs.of().isSystemWorkspace()) { + if (!NWorkspace.get().isSystemWorkspace()) { all.add(NRepositorySelectorHelper.createRepositoryOptions( NRepositoryLocation.of("system", NRepositoryDB.of()).get(), true)); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/DefaultNRepositoryDB.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/DefaultNRepositoryDB.java index 17aad35dd..728e72eb4 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/DefaultNRepositoryDB.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/DefaultNRepositoryDB.java @@ -2,7 +2,8 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NStoreType; + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.util.NMaps; import net.thevpc.nuts.runtime.standalone.util.NMapWithAlias; @@ -11,7 +12,7 @@ import net.thevpc.nuts.spi.NSupportLevelContext; import net.thevpc.nuts.util.NMsg; import net.thevpc.nuts.util.NOptional; -import net.thevpc.nuts.env.NPlatformHome; +import net.thevpc.nuts.NPlatformHome; import java.util.*; @@ -30,7 +31,7 @@ private DefaultNRepositoryDB() { .setLocation(NRepositoryLocation.of("nuts@" + NPath.of( NPlatformHome.SYSTEM.getWorkspaceLocation( - NStoreType.LIB, NConfigs.of().stored().getHomeLocations(), + NStoreType.LIB, NWorkspace.get().getStoredConfig().getHomeLocations(), NConstants.Names.DEFAULT_WORKSPACE_NAME)) .resolve(NConstants.Folders.ID) .toString()) diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/NIdPathIterator.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/NIdPathIterator.java index 144438e54..bc6c7721b 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/NIdPathIterator.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/NIdPathIterator.java @@ -65,7 +65,6 @@ public NIdPathIterator(NRepository repository, NPath rootFolder, NPath basePath, this.filter = filter; this.model = model; this.maxDepth = maxDepth; - NSession session = repository.getWorkspace().currentSession(); if (rootFolder == null) { throw new NIllegalArgumentException(NMsg.ofPlain("could not iterate over null rootFolder")); } @@ -161,7 +160,6 @@ public void remove() { if (last != null) { model.undeploy(last); } - NSession session=repository.getWorkspace().currentSession(); throw new NUnsupportedOperationException(NMsg.ofPlain("unsupported Remove")); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/NIdPathIteratorBase.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/NIdPathIteratorBase.java index 281074a9d..bc9b3355c 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/NIdPathIteratorBase.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/NIdPathIteratorBase.java @@ -16,7 +16,6 @@ public abstract class NIdPathIteratorBase implements NIdPathIteratorModel { public abstract NWorkspace getWorkspace(); public NId validate(NId id, NDescriptor t, NPath pathname, NPath rootPath, NIdFilter filter, NRepository repository) throws IOException { - NSession session = getWorkspace().currentSession(); if (t != null) { if (!CoreNUtils.isEffectiveId(t.getId())) { NDescriptor nutsDescriptor = null; @@ -47,7 +46,6 @@ public NId validate(NId id, NDescriptor t, NPath pathname, NPath rootPath, NIdFi @Override public NId parseId(NPath pathname, NPath rootPath, NIdFilter filter, NRepository repository) throws IOException { NDescriptor t = null; - NSession session = getWorkspace().currentSession(); try { t = parseDescriptor(pathname, NInputStreamMonitor.of().setSource(pathname).create(), NFetchMode.LOCAL, repository, rootPath); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/NRepositoryHelper.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/NRepositoryHelper.java index 5de0236a2..ab061b8b6 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/NRepositoryHelper.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/NRepositoryHelper.java @@ -1,7 +1,7 @@ package net.thevpc.nuts.runtime.standalone.repository; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NSpeedQualifier; +import net.thevpc.nuts.NSpeedQualifier; import net.thevpc.nuts.format.NPositionType; import net.thevpc.nuts.runtime.standalone.repository.impl.NRepositoryExt; import net.thevpc.nuts.runtime.standalone.repository.impl.main.NInstalledRepository; @@ -38,7 +38,7 @@ public static NRepositoryHelper of(NRepository repo) { return wp; } - public static NSpeedQualifier getSupportSpeedLevel(NRepository repository, NRepositorySupportedAction supportedAction, NId id, NFetchMode mode, boolean transitive, NSession session) { + public static NSpeedQualifier getSupportSpeedLevel(NRepository repository, NRepositorySupportedAction supportedAction, NId id, NFetchMode mode, boolean transitive) { if (repository instanceof NInstalledRepository) { return NSpeedQualifier.UNAVAILABLE; } @@ -53,7 +53,7 @@ public static NSpeedQualifier getSupportSpeedLevel(NRepository repository, NRepo if (transitive) { for (NRepository remote : repository.config() .getMirrors()) { - NSpeedQualifier r = getSupportSpeedLevel(remote, supportedAction, id, mode, transitive, session); + NSpeedQualifier r = getSupportSpeedLevel(remote, supportedAction, id, mode, transitive); if (r != NSpeedQualifier.UNAVAILABLE) { speeds.add(r); } @@ -113,7 +113,7 @@ public void fireOnUndeploy(NContentEvent evt) { for (NRepositoryListener listener : u.repo.getRepositoryListeners()) { listener.onUndeploy(evt); } - for (NRepositoryListener listener : NEvents.of().getRepositoryListeners()) { + for (NRepositoryListener listener : u.repo.getWorkspace().getRepositoryListeners()) { listener.onUndeploy(evt); } } @@ -122,7 +122,7 @@ public void fireOnDeploy(NContentEvent event) { for (NRepositoryListener listener : u.repo.getRepositoryListeners()) { listener.onDeploy(event); } - for (NRepositoryListener listener : NEvents.of().getRepositoryListeners()) { + for (NRepositoryListener listener : u.repo.getWorkspace().getRepositoryListeners()) { listener.onDeploy(event); } } @@ -131,7 +131,7 @@ public void fireOnPush(NContentEvent event) { for (NRepositoryListener listener : u.repo.getRepositoryListeners()) { listener.onPush(event); } - for (NRepositoryListener listener : NEvents.of().getRepositoryListeners()) { + for (NRepositoryListener listener : u.repo.getWorkspace().getRepositoryListeners()) { listener.onPush(event); } for (NRepositoryListener listener : event.getSession().getListeners(NRepositoryListener.class)) { @@ -149,7 +149,7 @@ public void fireOnAddRepository(NRepositoryEvent event) { for (NRepositoryListener listener : u.repo.getRepositoryListeners()) { listener.onAddRepository(event); } - for (NRepositoryListener listener : NEvents.of().getRepositoryListeners()) { + for (NRepositoryListener listener : u.repo.getWorkspace().getRepositoryListeners()) { listener.onAddRepository(event); } for (NRepositoryListener listener : event.getSession().getListeners(NRepositoryListener.class)) { @@ -169,7 +169,7 @@ public void fireOnRemoveRepository(NRepositoryEvent event) { // } listener.onRemoveRepository(event); } - for (NRepositoryListener listener : NEvents.of().getRepositoryListeners()) { + for (NRepositoryListener listener : u.repo.getWorkspace().getRepositoryListeners()) { // if (event == null) { // event = new DefaultNRepositoryEvent(getWorkspace(), this, event, "mirror", event, null); // } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/NRepositoryRegistryHelper.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/NRepositoryRegistryHelper.java index 8c7507e3c..feb26073e 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/NRepositoryRegistryHelper.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/NRepositoryRegistryHelper.java @@ -44,10 +44,10 @@ public class NRepositoryRegistryHelper { private Map repositoriesByName = new LinkedHashMap<>(); private Map repositoriesByUuid = new LinkedHashMap<>(); - private NWorkspace ws; + private NWorkspace workspace; - public NRepositoryRegistryHelper(NWorkspace ws) { - this.ws = ws; + public NRepositoryRegistryHelper(NWorkspace workspace) { + this.workspace = workspace; } public NRepository[] getRepositories() { @@ -64,7 +64,6 @@ public void addRepository(NRepository repository) { if (repository == null) { return; } - NSession session=ws.currentSession(); NRepositoryRef repositoryRef = repository.config().getRepositoryRef(); String uuid = repository.getUuid(); String name = repository.getName(); @@ -93,7 +92,7 @@ public void addRepository(NRepository repository) { if (uuid != null) { repositoriesByUuid.put(uuid, rr); } - NWorkspaceConfigMain m = ((NWorkspaceExt) session.getWorkspace()).getModel().configModel.getStoreModelMain(); + NWorkspaceConfigMain m = ((NWorkspaceExt) workspace).getModel().configModel.getStoreModelMain(); List repositoriesRefs = m.getRepositories(); if (repositoriesRefs == null) { repositoriesRefs = new ArrayList<>(); @@ -137,12 +136,11 @@ public void addRepository(NRepository repository) { // } // } public NRepository removeRepository(String repository) { - NSession session=ws.currentSession(); final NRepository r = findRepository(repository); if (r != null) { repositoriesByName.remove(r.getName()); repositoriesByUuid.remove(r.getUuid()); - NWorkspaceConfigMain m = ((NWorkspaceExt) session.getWorkspace()).getModel().configModel.getStoreModelMain(); + NWorkspaceConfigMain m = NWorkspaceExt.of(workspace).getModel().configModel.getStoreModelMain(); List repositoriesRefs = m.getRepositories(); if (repositoriesRefs != null) { repositoriesRefs.removeIf(x -> x.getName().equals(r.getName())); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/NRepositorySelectorHelper.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/NRepositorySelectorHelper.java index c67dec7ef..c84f07ebe 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/NRepositorySelectorHelper.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/NRepositorySelectorHelper.java @@ -126,7 +126,7 @@ public static NAddRepositoryOptions createDefaultRepositoryOptions(String nameOr // .setLocation(NRepositoryLocation.of("nuts@" // + NPath.of( // NPlatformHome.SYSTEM.getWorkspaceLocation( -// NStoreType.LIB, NConfigs.of().stored().getHomeLocations(), +// NStoreType.LIB, NWorkspace.get().stored().getHomeLocations(), // NConstants.Names.DEFAULT_WORKSPACE_NAME)) // .resolve(NConstants.Folders.ID) // .toString()) diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/NRepositoryCmdBase.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/NRepositoryCmdBase.java index 508a3c18d..e8b8342dd 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/NRepositoryCmdBase.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/NRepositoryCmdBase.java @@ -78,7 +78,6 @@ public boolean configureFirst(NCmdLine cmdLine) { } // switch(a.key()) { // } - NSession session = repo.getWorkspace().currentSession(); if (configureFirst(cmdLine)) { return true; } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/deploy/AbstractNDeployRepositoryCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/deploy/AbstractNDeployRepositoryCmd.java index 62e6648f9..7f334d4d0 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/deploy/AbstractNDeployRepositoryCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/deploy/AbstractNDeployRepositoryCmd.java @@ -77,28 +77,24 @@ public NDeployRepositoryCmd setContent(NPath content) { @Override public NDeployRepositoryCmd setContent(Path content) { - NSession session = getRepo().getWorkspace().currentSession(); this.content = content == null ? null : NPath.of(content); return this; } @Override public NDeployRepositoryCmd setContent(URL content) { - NSession session = getRepo().getWorkspace().currentSession(); this.content = content == null ? null : NPath.of(content); return this; } @Override public NDeployRepositoryCmd setContent(File content) { - NSession session = getRepo().getWorkspace().currentSession(); this.content = content == null ? null : NPath.of(content); return this; } @Override public NDeployRepositoryCmd setContent(InputStream content) { - NSession session = getRepo().getWorkspace().currentSession(); this.content = content == null ? null : NInputSource.of(content); return this; } @@ -126,7 +122,6 @@ public NDeployRepositoryCmd setId(NId id) { } protected void checkParameters() { - NSession session = getRepo().getWorkspace().currentSession(); getRepo().security().checkAllowed(NConstants.Permissions.DEPLOY, "deploy"); CoreNIdUtils.checkLongId(getId()); NAssert.requireNonNull(this.getContent(), "content"); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/fetch/DefaultNFetchContentRepositoryCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/fetch/DefaultNFetchContentRepositoryCmd.java index 0a7bd78f0..d06ee99d8 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/fetch/DefaultNFetchContentRepositoryCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/fetch/DefaultNFetchContentRepositoryCmd.java @@ -63,8 +63,6 @@ protected NLog _LOG() { @Override public NFetchContentRepositoryCmd run() { NRepository repo = getRepo(); - NSession session = repo.getWorkspace().currentSession(); - NSessionUtils.checkSession(repo.getWorkspace(), session); NDescriptor descriptor0 = descriptor; if (descriptor0 == null) { NRepositorySPI repoSPI = NWorkspaceUtils.of(getRepo().getWorkspace()).repoSPI(repo); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/fetch/DefaultNFetchDescriptorRepositoryCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/fetch/DefaultNFetchDescriptorRepositoryCmd.java index 3258e07bd..939d2f8e9 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/fetch/DefaultNFetchDescriptorRepositoryCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/fetch/DefaultNFetchDescriptorRepositoryCmd.java @@ -71,9 +71,7 @@ public boolean configureFirst(NCmdLine cmdLine) { @Override public NFetchDescriptorRepositoryCmd run() { // NutsWorkspace ws = getRepo().getWorkspace(); - NSession session = getRepo().getWorkspace().currentSession(); CoreNIdUtils.checkLongId(id); - NSessionUtils.checkSession(getRepo().getWorkspace(), session); getRepo().security().checkAllowed(NConstants.Permissions.FETCH_DESC, "fetch-descriptor"); Map queryMap = id.getProperties(); queryMap.remove(NConstants.IdProperties.OPTIONAL); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/push/DefaultNPushRepositoryCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/push/DefaultNPushRepositoryCmd.java index 294c355b9..2ed798ad0 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/push/DefaultNPushRepositoryCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/push/DefaultNPushRepositoryCmd.java @@ -40,8 +40,6 @@ protected NLog _LOG() { @Override public NPushRepositoryCmd run() { - NSession session = repo.getWorkspace().currentSession(); - NSessionUtils.checkSession(getRepo().getWorkspace(), session); getRepo().security().checkAllowed(NConstants.Permissions.PUSH, "push"); try { NRepositoryExt.of(getRepo()).pushImpl(this); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/search/DefaultNSearchRepositoryCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/search/DefaultNSearchRepositoryCmd.java index ef511a7f2..0f24c715f 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/search/DefaultNSearchRepositoryCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/search/DefaultNSearchRepositoryCmd.java @@ -14,7 +14,6 @@ import net.thevpc.nuts.log.NLog; import net.thevpc.nuts.log.NLogOp; import net.thevpc.nuts.log.NLogVerb; -import net.thevpc.nuts.runtime.standalone.session.NSessionUtils; import net.thevpc.nuts.runtime.standalone.repository.impl.NRepositoryExt; import net.thevpc.nuts.util.*; import net.thevpc.nuts.spi.NSearchRepositoryCmd; @@ -43,7 +42,6 @@ protected NLog _LOG() { @Override public NSearchRepositoryCmd run() { NSession session = getRepo().getWorkspace().currentSession(); - NSessionUtils.checkSession(getRepo().getWorkspace(), session); NRunnable startRunnable = NRunnable.of( () -> { getRepo().security().checkAllowed(NConstants.Permissions.FETCH_DESC, "search"); @@ -74,7 +72,7 @@ public NSearchRepositoryCmd run() { } if (o != null) { result = NIteratorBuilder.of(new NIndexFirstIterator<>(o, - xrepo.searchImpl(filter, getFetchMode()),session + xrepo.searchImpl(filter, getFetchMode()) )).onStart(startRunnable).onFinish(endRunnable).build(); return this; } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/search/DefaultNSearchVersionsRepositoryCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/search/DefaultNSearchVersionsRepositoryCmd.java index 3d76e7afe..8adfd175e 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/search/DefaultNSearchVersionsRepositoryCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/search/DefaultNSearchVersionsRepositoryCmd.java @@ -44,7 +44,6 @@ protected NLog _LOG() { @Override public NSearchVersionsRepositoryCmd run() { NSession session = getRepo().getWorkspace().currentSession(); - NSessionUtils.checkSession(getRepo().getWorkspace(), session); //id = id.builder().setFaceContent().build(); getRepo().security().checkAllowed(NConstants.Permissions.FETCH_DESC, "find-versions"); NRepositoryExt xrepo = NRepositoryExt.of(getRepo()); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/undeploy/DefaultNRepositoryUndeployCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/undeploy/DefaultNRepositoryUndeployCmd.java index 9020717a4..40b358057 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/undeploy/DefaultNRepositoryUndeployCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/cmd/undeploy/DefaultNRepositoryUndeployCmd.java @@ -45,7 +45,6 @@ protected NLog _LOG() { @Override public NRepositoryUndeployCmd run() { NSession session = getRepo().getWorkspace().currentSession(); - NSessionUtils.checkSession(getRepo().getWorkspace(), session); getRepo().security().checkAllowed(NConstants.Permissions.UNDEPLOY, "undeploy"); try { NRepositoryExt xrepo = NRepositoryExt.of(getRepo()); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/config/DefaultNRepoConfigManager.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/config/DefaultNRepoConfigManager.java index 3bd26d947..91ae99b0e 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/config/DefaultNRepoConfigManager.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/config/DefaultNRepoConfigManager.java @@ -1,9 +1,9 @@ package net.thevpc.nuts.runtime.standalone.repository.config; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NSpeedQualifier; -import net.thevpc.nuts.env.NStoreStrategy; -import net.thevpc.nuts.env.NStoreType; +import net.thevpc.nuts.NSpeedQualifier; +import net.thevpc.nuts.NStoreStrategy; +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.workspace.config.NRepositoryConfigManagerExt; import net.thevpc.nuts.spi.NRepositoryLocation; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/config/DefaultNRepositories.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/config/DefaultNRepositories.java index 67f9f7fb0..307f1a352 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/config/DefaultNRepositories.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/config/DefaultNRepositories.java @@ -1,93 +1,44 @@ -package net.thevpc.nuts.runtime.standalone.repository.config; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -import net.thevpc.nuts.*; -import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; -import net.thevpc.nuts.spi.NComponentScope; -import net.thevpc.nuts.spi.NScopeType; -import net.thevpc.nuts.spi.NSupportLevelContext; -import net.thevpc.nuts.util.NOptional; - -@NComponentScope(NScopeType.SESSION) -public class DefaultNRepositories implements NRepositories { - - private DefaultNRepositoryModel model; - private NWorkspace workspace; - - public DefaultNRepositories(NWorkspace workspace) { - this.workspace = workspace; - NWorkspaceExt e = NWorkspaceExt.of(); - this.model = e.getModel().repositoryModel; - } - - @Override - public int getSupportLevel(NSupportLevelContext context) { - return NConstants.Support.DEFAULT_SUPPORT; - } - - @Override - public NRepositoryFilters filter() { - return NRepositoryFilters.of(); - } - -// private NRepository toSessionAwareRepo(NRepository x) { -// return NRepositorySessionAwareImpl.of(x, model.getWorkspace(), workspace); +//package net.thevpc.nuts.runtime.standalone.repository.config; +// +//import java.util.Arrays; +//import java.util.List; +//import java.util.stream.Collectors; +// +//import net.thevpc.nuts.*; +//import net.thevpc.nuts.NConstants; +//import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; +//import net.thevpc.nuts.spi.NComponentScope; +//import net.thevpc.nuts.spi.NScopeType; +//import net.thevpc.nuts.spi.NSupportLevelContext; +//import net.thevpc.nuts.util.NOptional; +// +//@NComponentScope(NScopeType.SESSION) +//public class DefaultNRepositories implements NRepositories { +// +// private NWorkspace workspace; +// +// public DefaultNRepositories(NWorkspace workspace) { +// this.workspace = workspace; // } - -// private NOptional toSessionAwareRepoOptional(NOptional x) { -// return x.map(r->NRepositorySessionAwareImpl.of(r, model.getWorkspace(), workspace)); +// +// +// @Override +// public int getSupportLevel(NSupportLevelContext context) { +// return NConstants.Support.DEFAULT_SUPPORT; // } - - @Override - public List getRepositories() { - return Arrays.stream(model.getRepositories()) - .collect(Collectors.toList()); - } - - @Override - public NOptional findRepositoryById(String repositoryNameOrId) { - return model.findRepositoryById(repositoryNameOrId); - } - - @Override - public NOptional findRepositoryByName(String repositoryNameOrId) { - return model.findRepositoryByName(repositoryNameOrId); - } - - @Override - public NOptional findRepository(String repositoryNameOrId) { - return model.findRepository(repositoryNameOrId); - } - - @Override - public NRepositories removeRepository(String repositoryId) { - model.removeRepository(repositoryId); - return this; - } - - @Override - public NRepositories removeAllRepositories() { - model.removeAllRepositories(); - return this; - } - - @Override - public NRepository addRepository(NAddRepositoryOptions options) { - return model.addRepository(options); - } - - @Override - public NRepository addRepository(String repositoryNamedUrl) { - return model.addRepository(repositoryNamedUrl); - } - - - public DefaultNRepositoryModel getModel() { - return model; - } - -} +// +// @Override +// public NRepositoryFilters filter() { +// return NRepositoryFilters.of(); +// } +// +//// private NRepository toSessionAwareRepo(NRepository x) { +//// return NRepositorySessionAwareImpl.of(x, model.getWorkspace(), workspace); +//// } +// +//// private NOptional toSessionAwareRepoOptional(NOptional x) { +//// return x.map(r->NRepositorySessionAwareImpl.of(r, model.getWorkspace(), workspace)); +//// } +// +// +//} diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/config/DefaultNRepositoryConfigModel.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/config/DefaultNRepositoryConfigModel.java index a50fb37bb..7bde27ef7 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/config/DefaultNRepositoryConfigModel.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/config/DefaultNRepositoryConfigModel.java @@ -2,7 +2,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.*; +import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.elem.NElements; import net.thevpc.nuts.format.NPositionType; @@ -209,9 +209,8 @@ public NRepositoryLocation getLocation() { @Override public NPath getLocationPath() { String s = NStringUtils.trimToNull(config.getLocation().getPath()); - NSession session = repository.getWorkspace().currentSession(); if (s != null) { - return NPath.of(s).toAbsolute(NLocations.of().getWorkspaceLocation()); + return NPath.of(s).toAbsolute(NWorkspace.get().getWorkspaceLocation()); } return null; } @@ -233,9 +232,6 @@ public NStoreStrategy getStoreStrategy() { @Override public NPath getStoreLocation(NStoreType folderType) { NStoreLocationsMap hlm = new NStoreLocationsMap(config.getStoreLocations()); - NSession session = repository.getWorkspace().currentSession(); - -// String n = CoreNutsUtils.getArrItem(config.getStoreLocations(), folderType.ordinal()); String n = hlm.get(folderType); if (temporary) { if (NBlankable.isBlank(n)) { @@ -253,7 +249,7 @@ public NPath getStoreLocation(NStoreType folderType) { return getStoreLocation().resolve(n); } case EXPLODED: { - NPath storeLocation = NLocations.of().getStoreLocation(folderType); + NPath storeLocation = NWorkspace.get().getStoreLocation(folderType); //uuid is added as return storeLocation.resolve(NConstants.Folders.REPOSITORIES).resolve(getName()).resolve(getUuid()); @@ -278,7 +274,7 @@ public void setConfig(NRepositoryConfig newConfig, boolean fireChange) { } if (this.config.getStoreStrategy() == null) { fireChange = true; - this.config.setStoreStrategy(NLocations.of().getRepositoryStoreStrategy()); + this.config.setStoreStrategy(NWorkspace.get().getRepositoryStoreStrategy()); } if (!Objects.equals(NRepositoryUtils.getRepoType(config), repositoryType)) { throw new NIllegalArgumentException( @@ -304,8 +300,8 @@ public void setConfig(NRepositoryConfig newConfig, boolean fireChange) { removeAllMirrors(); if (config.getMirrors() != null) { for (NRepositoryRef ref : config.getMirrors()) { - NRepository r = ((DefaultNRepositories) NRepositories.of()) - .getModel() + NRepository r = NWorkspaceExt.of() + .getRepositoryModel() .createRepository( NRepositoryUtils.refToOptions(ref), repository @@ -394,7 +390,7 @@ public void setMirrorEnabled(String repoName, boolean enabled) { @Override public boolean save(boolean force) { boolean ok = false; - if (force || (!NConfigs.of().isReadOnly() && isConfigurationChanged())) { + if (force || (!NWorkspace.get().isReadOnly() && isConfigurationChanged())) { NWorkspaceUtils.of(getWorkspace()).checkReadOnly(); repository.security().checkAllowed(NConstants.Permissions.SAVE, "save"); NPath file = getStoreLocation().resolve(NConstants.Files.REPOSITORY_CONFIG_FILE_NAME); @@ -551,7 +547,6 @@ public void removeMirror(String repositoryId) { // return getMirror(repositoryIdOrName, false); // } public NRepository getMirror(String repositoryIdPath) { - NSession session = repository.getWorkspace().currentSession(); NRepository r = findMirror(repositoryIdPath); if (r != null) { return r; @@ -645,15 +640,14 @@ public List getMirrors() { } public NRepository addMirror(NAddRepositoryOptions options) { - NSession session = repository.getWorkspace().currentSession(); if (!isSupportedMirroring()) { throw new NUnsupportedOperationException(NMsg.ofC("unsupported operation '%s'", "addMirror")); } if (options.isTemporary()) { return null; } - NRepository repo = ((DefaultNRepositories) NRepositories.of()) - .getModel() + NRepository repo = NWorkspaceExt.of() + .getRepositoryModel() .createRepository( options, repository @@ -701,8 +695,7 @@ public Map toMap() { public NOptional get(String key, boolean inherit) { NOptional o = config_getEnv(key, inherit); if (o.isBlank() && inherit) { - NSession session = repository.getWorkspace().currentSession(); - return o.orElseUse(() -> NConfigs.of().getConfigProperty(key)); + return o.orElseUse(() -> NWorkspace.get().getConfigProperty(key)); } return o; } @@ -731,19 +724,17 @@ public NOptional config_getEnv(String key, boolean inherit) { return NOptional.of(NLiteral.of(t)); } if (inherit) { - NSession session = repository.getWorkspace().currentSession(); - return NConfigs.of().getConfigProperty(key); + return NWorkspace.get().getConfigProperty(key); } return NOptional.ofEmpty(() -> NMsg.ofC("repository property not found : %s", key)); } private Map config_getEnv(boolean inherit) { - NSession session = repository.getWorkspace().currentSession(); NRepositoryConfigModel model = ((DefaultNRepoConfigManager) repository.config()).getModel(); NRepositoryConfig config = model.getConfig(); Map p = new LinkedHashMap<>(); if (inherit) { - p.putAll(NConfigs.of().getConfigMap()); + p.putAll(NWorkspace.get().getConfigMap()); } if (config.getEnv() != null) { p.putAll(config.getEnv()); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/config/DefaultNRepositoryModel.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/config/DefaultNRepositoryModel.java index bb815b742..17825636d 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/config/DefaultNRepositoryModel.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/config/DefaultNRepositoryModel.java @@ -3,10 +3,10 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NBootManager; -import net.thevpc.nuts.env.NEnvs; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; + + + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.ext.NExtensions; import net.thevpc.nuts.io.NIOException; import net.thevpc.nuts.io.NPath; @@ -18,7 +18,6 @@ import net.thevpc.nuts.runtime.standalone.repository.impl.NSimpleRepositoryWrapper; import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; import net.thevpc.nuts.runtime.standalone.workspace.config.NRepositoryConfigManagerExt; -import net.thevpc.nuts.runtime.standalone.workspace.config.NConfigsExt; import net.thevpc.nuts.runtime.standalone.event.DefaultNWorkspaceEvent; import net.thevpc.nuts.runtime.standalone.io.util.CoreIOUtils; import net.thevpc.nuts.runtime.standalone.util.CoreNUtils; @@ -155,9 +154,8 @@ public void removeRepository(String repositoryId) { NWorkspaceSecurityManager.of().checkAllowed(NConstants.Permissions.REMOVE_REPOSITORY, "remove-repository"); final NRepository repository = repositoryRegistryHelper.removeRepository(repositoryId); if (repository != null) { - NConfigs.of().save(); - NConfigsExt config = NConfigsExt.of(NConfigs.of()); - config.getModel().fireConfigurationChanged("config-main", ConfigEventType.MAIN); + NWorkspace.get().saveConfig(); + NWorkspaceExt.of(workspace).getConfigModel().fireConfigurationChanged("config-main", ConfigEventType.MAIN); NWorkspaceUtils.of(workspace).events().fireOnRemoveRepository(new DefaultNWorkspaceEvent(session, repository, "repository", repository, null)); } } @@ -174,8 +172,7 @@ protected void addRepository(NRepository repo, boolean temp, boolean enabled) { // NConfigs.of(session).save(); if (!temp) { NSession session = workspace.currentSession(); - NConfigsExt config = NConfigsExt.of(NConfigs.of()); - config.getModel().fireConfigurationChanged("config-main", ConfigEventType.MAIN); + NWorkspaceExt.of(workspace).getConfigModel().fireConfigurationChanged("config-main", ConfigEventType.MAIN); if (repo != null) { // repo would be null if the repo is not accessible // like for system repo, if not already created @@ -204,14 +201,12 @@ public NRepository createRepository(NAddRepositoryOptions options, NRepository p } public NRepository createRepository(NAddRepositoryOptions options, Path rootFolder, NRepository parentRepository) { - NSession session = workspace.currentSession(); NRepositoryModel repoModel = options.getRepositoryModel(); if (rootFolder == null) { if (parentRepository == null) { - NConfigsExt cc = NConfigsExt.of(NConfigs.of()); rootFolder = options.isTemporary() ? - cc.getModel().getTempRepositoriesRoot().toPath().get() - : cc.getModel().getRepositoriesRoot().toPath().get(); + NWorkspaceExt.of(workspace).getConfigModel().getTempRepositoriesRoot().toPath().get() + : NWorkspaceExt.of(workspace).getConfigModel().getRepositoriesRoot().toPath().get(); } else { NRepositoryConfigManagerExt cc = NRepositoryConfigManagerExt.of(parentRepository.config()); rootFolder = (options.isTemporary() ? cc.getModel().getTempMirrorsRoot() @@ -264,9 +259,9 @@ public NRepository createRepository(NAddRepositoryOptions options, Path rootFold options.setConfig(conf); if (options.isEnabled()) { options.setEnabled( - NBootManager.of().getBootOptions().getRepositories() == null + NWorkspace.get().getBootOptions().getRepositories() == null || NRepositorySelectorList.of( - NBootManager.of().getBootOptions().getRepositories().orNull(), + NWorkspace.get().getBootOptions().getRepositories().orNull(), NRepositoryDB.of() ).get().acceptExisting( conf.getLocation().setName(options.getName()) @@ -276,9 +271,9 @@ public NRepository createRepository(NAddRepositoryOptions options, Path rootFold options.setConfig(conf); if (options.isEnabled()) { options.setEnabled( - NBootManager.of().getBootOptions().getRepositories() == null + NWorkspace.get().getBootOptions().getRepositories() == null || NRepositorySelectorList.of( - NBootManager.of().getBootOptions().getRepositories().orNull(), + NWorkspace.get().getBootOptions().getRepositories().orNull(), NRepositoryDB.of() ).get().acceptExisting( conf.getLocation().setName(options.getName()) @@ -337,12 +332,11 @@ public NRepositoryConfig loadRepository(NPath file, String name) { if (file.isRegularFile() && file.getPermissions().contains(NPathPermission.CAN_READ)) { byte[] bytes = file.readBytes(); try { - NSession session = workspace.currentSession(); NElements elem = NElements.of(); Map a_config0 = elem.json().parse(bytes, Map.class); NVersion version = NVersion.of((String) a_config0.get("configVersion")).orNull(); if (version == null || version.isBlank()) { - version = session.getWorkspace().getApiVersion(); + version = workspace.getApiVersion(); } int buildNumber = CoreNUtils.getApiVersionOrdinalNumber(version); if (buildNumber < 506) { @@ -350,8 +344,7 @@ public NRepositoryConfig loadRepository(NPath file, String name) { } conf = elem.json().parse(file, NRepositoryConfig.class); } catch (RuntimeException ex) { - NSession session = workspace.currentSession(); - if (NBootManager.of().getBootOptions().getRecover().orElse(false)) { + if (NWorkspace.get().getBootOptions().getRecover().orElse(false)) { onLoadRepositoryError(file, name, null, ex); } else { throw ex; @@ -366,16 +359,13 @@ public NRepositorySPI toRepositorySPI(NRepository repo) { } private void onLoadRepositoryError(NPath file, String name, String uuid, Throwable ex) { - NConfigs wconfig = NConfigs.of(); - NBootManager wboot = NBootManager.of(); - NEnvs wenv = NEnvs.of(); - if (wconfig.isReadOnly()) { + if (workspace.isReadOnly()) { throw new NIOException(NMsg.ofC("error loading repository %s", file), ex); } String fileName = "nuts-repository" + (name == null ? "" : ("-") + name) + (uuid == null ? "" : ("-") + uuid) + "-" + Instant.now().toString(); _LOG().with().level(Level.SEVERE).verb(NLogVerb.FAIL).log( NMsg.ofJ("erroneous repository config file. Unable to load file {0} : {1}", file, ex)); - NPath logError = NLocations.of().getStoreLocation(getWorkspace().getApiId(), NStoreType.LOG) + NPath logError = NWorkspace.get().getStoreLocation(getWorkspace().getApiId(), NStoreType.LOG) .resolve("invalid-config"); try { logError.mkParentDirs(); @@ -392,11 +382,11 @@ private void onLoadRepositoryError(NPath file, String name, String uuid, Throwab } try (PrintStream o = new PrintStream(logError.resolve(fileName + ".error").getOutputStream())) { - o.printf("workspace.path:%s%n", NLocations.of().getWorkspaceLocation()); + o.printf("workspace.path:%s%n", NWorkspace.get().getWorkspaceLocation()); o.printf("repository.path:%s%n", file); - o.printf("workspace.options:%s%n", wboot.getBootOptions().toCmdLine(new NWorkspaceOptionsConfig().setCompact(false))); + o.printf("workspace.options:%s%n", workspace.getBootOptions().toCmdLine(new NWorkspaceOptionsConfig().setCompact(false))); for (NStoreType location : NStoreType.values()) { - o.printf("location." + location.id() + ":%s%n", NLocations.of().getStoreLocation(location)); + o.printf("location." + location.id() + ":%s%n", NWorkspace.get().getStoreLocation(location)); } o.printf("java.class.path:%s%n", System.getProperty("java.class.path")); o.println(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/config/NRepositoryConfigModel.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/config/NRepositoryConfigModel.java index ab6c89df3..de48276e2 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/config/NRepositoryConfigModel.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/config/NRepositoryConfigModel.java @@ -25,10 +25,10 @@ package net.thevpc.nuts.runtime.standalone.repository.config; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NSpeedQualifier; -import net.thevpc.nuts.env.NStoreStrategy; -import net.thevpc.nuts.env.NStoreType; -import net.thevpc.nuts.env.NUserConfig; +import net.thevpc.nuts.NSpeedQualifier; +import net.thevpc.nuts.NStoreStrategy; +import net.thevpc.nuts.NStoreType; +import net.thevpc.nuts.NUserConfig; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.spi.NRepositoryLocation; import net.thevpc.nuts.util.NLiteral; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/filter/DefaultNRepositoryNameFilter.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/filter/DefaultNRepositoryNameFilter.java index e039928a6..9d1a96157 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/filter/DefaultNRepositoryNameFilter.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/filter/DefaultNRepositoryNameFilter.java @@ -50,7 +50,7 @@ public boolean acceptRepository(NRepository repository) { @Override public NRepositoryFilter simplify() { if(exactRepos.isEmpty() && wildcardRepos.isEmpty()){ - return NRepositories.of().filter().always(); + return NRepositoryFilters.of().always(); } return this; } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/filter/DefaultNRepositorySelectorFilter.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/filter/DefaultNRepositorySelectorFilter.java index ed3c75056..5b89f07fe 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/filter/DefaultNRepositorySelectorFilter.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/filter/DefaultNRepositorySelectorFilter.java @@ -27,7 +27,7 @@ public DefaultNRepositorySelectorFilter(NWorkspace workspace, Collection for (String exactRepo : exactRepos) { li=li.merge(NRepositorySelectorList.of(exactRepo, db).get()); } - NRepositoryLocation[] input = NRepositories.of().getRepositories().stream() + NRepositoryLocation[] input = workspace.getRepositories().stream() .map(x -> x.config().getLocation().setName(x.getName())) .toArray(NRepositoryLocation[]::new); String[] names = Arrays.stream(li.resolve(input,db)).map(NRepositoryLocation::getName).toArray(String[]::new); @@ -64,7 +64,7 @@ public boolean acceptRepository(NRepository repository) { @Override public NRepositoryFilter simplify() { if(exactRepos.isEmpty() && wildcardRepos.isEmpty()){ - return NRepositories.of().filter().always(); + return NRepositoryFilters.of().always(); } return this; } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/filter/DefaultNRepositoryUuidFilter.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/filter/DefaultNRepositoryUuidFilter.java index c5bec6f4c..a25cd5abb 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/filter/DefaultNRepositoryUuidFilter.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/filter/DefaultNRepositoryUuidFilter.java @@ -28,7 +28,7 @@ public boolean acceptRepository(NRepository repository) { @Override public NRepositoryFilter simplify() { if(exactRepos.isEmpty()){ - return NRepositories.of().filter().always(); + return NRepositoryFilters.of().always(); } return this; } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/AbstractNRepository.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/AbstractNRepository.java index 63e99ed1b..1c03bb795 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/AbstractNRepository.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/AbstractNRepository.java @@ -26,7 +26,8 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NLocations; + + import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.repository.config.DefaultNRepoConfigManager; @@ -235,11 +236,11 @@ public String toString() { } protected String getIdExtension(NId id) { - return NLocations.of().getDefaultIdExtension(id); + return NWorkspace.get().getDefaultIdExtension(id); } public NPath getIdBasedir(NId id) { - return NLocations.of().getDefaultIdBasedir(id); + return NWorkspace.get().getDefaultIdBasedir(id); } public String getIdFilename(NId id) { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/AbstractNRepositoryBase.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/AbstractNRepositoryBase.java index f78308f22..a5c57e3b6 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/AbstractNRepositoryBase.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/AbstractNRepositoryBase.java @@ -25,9 +25,10 @@ package net.thevpc.nuts.runtime.standalone.repository.impl; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NIndexStore; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NSpeedQualifier; + +import net.thevpc.nuts.NIndexStore; + +import net.thevpc.nuts.NSpeedQualifier; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.log.NLog; import net.thevpc.nuts.runtime.standalone.log.NLogUtils; @@ -74,7 +75,7 @@ public NIndexStore getIndexStore() { protected void init(NAddRepositoryOptions options, NRepository parent, NSpeedQualifier speed, boolean supportedMirroring, String repositoryType) { this.parentRepository = parent; this.configModel = new DefaultNRepositoryConfigModel(this, options, workspace,speed, supportedMirroring, repositoryType); - this.nIndexStore = NConfigs.of().getIndexStoreClientFactory().createIndexStore(this); + this.nIndexStore = NWorkspace.get().getIndexStoreClientFactory().createIndexStore(this); // setEnabled(options.isEnabled(), initSession); } @@ -136,7 +137,6 @@ public NId searchLatestVersion(NId id, NIdFilter filter, NFetchMode fetchMode) { } protected void traceMessage(NFetchMode fetchMode, Level lvl, NId id, NLogVerb tracePhase, String title, long startTime, NMsg extraMessage) { - NSession session = workspace.currentSession(); NLogUtils.traceMessage(NLog.of(AbstractNRepositoryBase.class), lvl, getName(), fetchMode, id, tracePhase, title, startTime, extraMessage); } @@ -171,16 +171,16 @@ public NRepositoryUndeployCmd undeploy() { } protected String getIdComponentExtension(String packaging) { - return NLocations.of().getDefaultIdContentExtension(packaging); + return NWorkspace.get().getDefaultIdContentExtension(packaging); } protected String getIdExtension(NId id) { - return NLocations.of().getDefaultIdExtension(id); + return NWorkspace.get().getDefaultIdExtension(id); } @Override public NPath getIdBasedir(NId id) { - return NLocations.of().getDefaultIdBasedir(id); + return NWorkspace.get().getDefaultIdBasedir(id); } public NPath getIdRemotePath(NId id) { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/NCachedRepository.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/NCachedRepository.java index 9c0689dbf..53f9db64f 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/NCachedRepository.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/NCachedRepository.java @@ -26,8 +26,8 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NSpeedQualifier; -import net.thevpc.nuts.env.NStoreType; +import net.thevpc.nuts.NSpeedQualifier; +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.concurrent.NLocks; import net.thevpc.nuts.elem.NEDesc; @@ -67,7 +67,6 @@ public class NCachedRepository extends AbstractNRepositoryBase { public NCachedRepository(NAddRepositoryOptions options, NWorkspace workspace, NRepository parent, NSpeedQualifier speed, boolean supportedMirroring, String repositoryType, boolean supportsDeploy) { super(options, workspace, parent, speed, supportedMirroring, repositoryType, supportsDeploy); - NSession session = this.workspace.currentSession(); cache = new NRepositoryFolderHelper(this, this.workspace, config().getStoreLocation(NStoreType.CACHE).resolve(NConstants.Folders.ID), true, "cache", NElements.of().ofObject().set("repoKind", "cache").build() ); @@ -336,8 +335,8 @@ public final NPath fetchContentImpl(NId id, NDescriptor descriptor, NFetchMode f @Override public final NIterator searchImpl(final NIdFilter filter, NFetchMode fetchMode) { NSession session = getWorkspace().currentSession(); - List basePaths = CommonRootsByPathHelper.resolveRootPaths(filter, session); - List baseIds = CommonRootsByIdHelper.resolveRootPaths(filter, session); + List basePaths = CommonRootsByPathHelper.resolveRootPaths(filter); + List baseIds = CommonRootsByIdHelper.resolveRootPaths(filter); List> li = new ArrayList<>(); for (NPath basePath : basePaths) { if (fetchMode != NFetchMode.REMOTE) { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/NRepositoryExt.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/NRepositoryExt.java index 8c4224214..242b5323c 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/NRepositoryExt.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/NRepositoryExt.java @@ -6,7 +6,7 @@ package net.thevpc.nuts.runtime.standalone.repository.impl; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NIndexStore; +import net.thevpc.nuts.NIndexStore; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.repository.cmd.NRepositorySupportedAction; import net.thevpc.nuts.spi.NDeployRepositoryCmd; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/NRepositoryFolderHelper.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/NRepositoryFolderHelper.java index 44432d8b8..a09d86210 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/NRepositoryFolderHelper.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/NRepositoryFolderHelper.java @@ -11,7 +11,8 @@ import net.thevpc.nuts.elem.NEDesc; import net.thevpc.nuts.elem.NElements; import net.thevpc.nuts.elem.NObjectElement; -import net.thevpc.nuts.env.NLocations; + + import net.thevpc.nuts.format.NDescriptorFormat; import net.thevpc.nuts.io.*; import net.thevpc.nuts.runtime.standalone.descriptor.util.NDescriptorUtils; @@ -100,26 +101,25 @@ public void setWriteEnabled(boolean writeEnabled) { this.writeEnabled = writeEnabled; } - public NPath getLongIdLocalFolder(NId id, NSession session) { + public NPath getLongIdLocalFolder(NId id) { CoreNIdUtils.checkLongId(id); if (repo == null) { - return getStoreLocation().resolve(NLocations.of().getDefaultIdBasedir(id)); + return getStoreLocation().resolve(NWorkspace.get().getDefaultIdBasedir(id)); } return getStoreLocation().resolve(NRepositoryExt0.of(repo).getIdBasedir(id)); } public NPath getLongIdLocalFile(NId id) { - NSession session = currentSession(); if (repo == null) { - return getLongIdLocalFolder(id, session).resolve(NLocations.of().getDefaultIdFilename(id)); + return getLongIdLocalFolder(id).resolve(NWorkspace.get().getDefaultIdFilename(id)); } - return getLongIdLocalFolder(id, session).resolve(NRepositoryExt0.of(repo).getIdFilename(id)); + return getLongIdLocalFolder(id).resolve(NRepositoryExt0.of(repo).getIdFilename(id)); } - public NPath getShortIdLocalFolder(NId id, NSession session) { + public NPath getShortIdLocalFolder(NId id) { CoreNIdUtils.checkShortId(id); if (repo == null) { - return getStoreLocation().resolve(NLocations.of().getDefaultIdBasedir(id.builder().setVersion("").build())); + return getStoreLocation().resolve(NWorkspace.get().getDefaultIdBasedir(id.builder().setVersion("").build())); } return getStoreLocation().resolve(NRepositoryExt0.of(repo).getIdBasedir(id.builder().setVersion("").build())); } @@ -139,14 +139,14 @@ public NWorkspace getWorkspace() { protected String getIdFilename(NId id) { if (repo == null) { - return NLocations.of().getDefaultIdFilename(id); + return NWorkspace.get().getDefaultIdFilename(id); } return NRepositoryExt0.of(repo).getIdFilename(id); } - public NPath getGoodPath(NId id, NSession session) { + public NPath getGoodPath(NId id) { String idFilename = getIdFilename(id); - NPath versionFolder = getLongIdLocalFolder(id, session); + NPath versionFolder = getLongIdLocalFolder(id); return versionFolder.resolve(idFilename); } @@ -154,10 +154,9 @@ public NDescriptor fetchDescriptorImpl(NId id) { if (!isReadEnabled()) { return null; } - NSession session = currentSession(); String idFilename = getIdFilename(id.builder().setFaceDescriptor().build()); NPath goodFile = null; - NPath versionFolder = getLongIdLocalFolder(id, session); + NPath versionFolder = getLongIdLocalFolder(id); goodFile = versionFolder.resolve(idFilename); if (pathExists(goodFile)) { return NDescriptorParser.of().parse(goodFile).get(); @@ -222,7 +221,6 @@ public NDescriptor fetchDescriptorImpl(NId id) { protected NDescriptor loadMatchingDescriptor(NPath file, NId id) { if (pathExists(file)) { - NSession session = currentSession(); NDescriptor d = file.isRegularFile() ? NDescriptorParser.of().parse(file).get() : null; if (d != null) { Map query = id.getProperties(); @@ -291,7 +289,7 @@ public NIterator searchVersions(NId id, final NIdFilter filter, boolean dee ); } - public NIterator searchImpl(NIdFilter filter, NSession session) { + public NIterator searchImpl(NIdFilter filter) { if (!isReadEnabled()) { return null; } @@ -372,7 +370,6 @@ public NId searchLatestVersion(NId id, NIdFilter filter) { } public NDescriptor deploy(NDeployRepositoryCmd deployment, NConfirmationMode writeType) { - NSession session = repo.getWorkspace().currentSession(); if (!isWriteEnabled()) { throw new NIllegalArgumentException(NMsg.ofPlain("read-only repository")); } @@ -405,7 +402,7 @@ public NDescriptor deploy(NDeployRepositoryCmd deployment, NConfirmationMode wri if (isDeployed(id, descriptor)) { NId finalId = id; if (!DefaultWriteTypeProcessor - .of(writeType, session) + .of(writeType) .ask(NMsg.ofC("override deployment for %s?", id)) .withLog(_LOG(), NMsg.ofC("nuts deployment overridden %s", id)) .onError(() -> new NAlreadyDeployedException(finalId)) @@ -425,7 +422,7 @@ public NDescriptor deploy(NDeployRepositoryCmd deployment, NConfirmationMode wri NPath pckFile = inputSource == null ? null : deployContent(id, inputSource, descriptor, writeType); if (repo != null) { NRepositoryHelper.of(repo).events().fireOnDeploy(new DefaultNContentEvent( - pckFile, deployment, session, repo)); + pckFile, deployment, repo.getWorkspace().currentSession(), repo)); } return descriptor.builder().setId(id.getLongId()).build(); } @@ -435,7 +432,6 @@ protected NLog _LOG() { } public NPath deployDescriptor(NId id, NDescriptor desc, NConfirmationMode writeType) { - NSession session = repo.getWorkspace().currentSession(); if (!isWriteEnabled()) { throw new NIllegalArgumentException(NMsg.ofPlain("read only repository")); } @@ -443,7 +439,7 @@ public NPath deployDescriptor(NId id, NDescriptor desc, NConfirmationMode writeT NPath descFile = getLongIdLocalFile(id.builder().setFaceDescriptor().build()); if (descFile.exists()) { if (!DefaultWriteTypeProcessor - .of(writeType, session) + .of(writeType) .ask(NMsg.ofC("override descriptor file for %s?", id)) .withLog(_LOG(), NMsg.ofC("nuts descriptor file overridden %s", id)) .onError(() -> new NAlreadyDeployedException(id)) @@ -471,7 +467,6 @@ public NPath deployDescriptor(NId id, NDescriptor desc, NConfirmationMode writeT } public boolean isDeployed(NId id, NDescriptor descriptor) { - NSession session = repo.getWorkspace().currentSession(); NPath pckFile = getLongIdLocalFile(id.builder().setFaceContent().setPackaging(descriptor.getPackaging()).build()); if (!pckFile.exists() || (cacheFolder && CoreIOUtils.isObsoletePath(pckFile))) { return false; @@ -484,7 +479,6 @@ public NPath deployContent(NId id, NInputSource content, NDescriptor descriptor, if (!isWriteEnabled()) { return null; } - NSession session = repo.getWorkspace().currentSession(); CoreNIdUtils.checkLongId(id); NPath pckFile = getLongIdLocalFile(id.builder().setFaceContent().setPackaging(descriptor.getPackaging()).build()); if (pckFile.exists()) { @@ -495,7 +489,7 @@ public NPath deployContent(NId id, NInputSource content, NDescriptor descriptor, } } if (!DefaultWriteTypeProcessor - .of(writeType, session) + .of(writeType) .ask(NMsg.ofC("override content file for %s?", id)) .withLog(_LOG(), NMsg.ofC("nuts content file overridden %s", id)) .onError(() -> new NAlreadyDeployedException(id)) @@ -521,7 +515,6 @@ public boolean undeploy(NRepositoryUndeployCmd command) { if (!isWriteEnabled()) { return false; } - NSession session = repo.getWorkspace().currentSession(); NPath localFolder = getLongIdLocalFile(command.getId().builder().setFaceContent().build()); if (localFolder != null && localFolder.exists()) { if (NLocks.of().setSource(localFolder).call(() -> { @@ -530,7 +523,7 @@ public boolean undeploy(NRepositoryUndeployCmd command) { })) { if (repo != null) { NRepositoryHelper.of(repo).events().fireOnUndeploy(new DefaultNContentEvent( - localFolder, command, session, repo)); + localFolder, command, repo.getWorkspace().currentSession(), repo)); return true; } } @@ -546,7 +539,6 @@ private boolean reindexFolder(NPath path) { if (!isWriteEnabled()) { return false; } - NSession session = repo.getWorkspace().currentSession(); try { Path start = path.toPath().get(); @@ -590,7 +582,7 @@ public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOEx } } try (PrintStream p = new PrintStream(new File(folder, CoreNConstants.Files.DOT_FILES))) { - p.println("#version=" + session.getWorkspace().getApiVersion()); + p.println("#version=" + workspace.getApiVersion()); for (String file : folders) { p.println(file + "/"); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/NRepositoryList.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/NRepositoryList.java index cf93ef174..55fa2b2ef 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/NRepositoryList.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/NRepositoryList.java @@ -1,7 +1,7 @@ package net.thevpc.nuts.runtime.standalone.repository.impl; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NSpeedQualifier; +import net.thevpc.nuts.NSpeedQualifier; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.util.NIteratorBuilder; import net.thevpc.nuts.util.NIteratorUtils; @@ -62,7 +62,6 @@ public NIterator searchVersionsCore(final NId id, NIdFilter idFilter, NFetc .getResult() ); } - NSession session = workspace.currentSession(); return NIteratorBuilder.ofCoalesce(all).build(); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/NRepositoryMirroringHelper.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/NRepositoryMirroringHelper.java index 15befff0b..f06d1eda8 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/NRepositoryMirroringHelper.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/NRepositoryMirroringHelper.java @@ -6,7 +6,7 @@ package net.thevpc.nuts.runtime.standalone.repository.impl; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NSpeedQualifier; +import net.thevpc.nuts.NSpeedQualifier; import net.thevpc.nuts.format.NDescriptorFormat; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.event.DefaultNContentEvent; @@ -53,7 +53,7 @@ protected NIterator searchVersionsImpl_appendMirrors(NIterator namedNu for (NRepository repo : repo.config().getMirrors()) { NSpeedQualifier sup = NSpeedQualifier.UNAVAILABLE; try { - sup = NRepositoryHelper.getSupportSpeedLevel(repo, NRepositorySupportedAction.SEARCH, id, fetchMode, session.isTransitive(), session); + sup = NRepositoryHelper.getSupportSpeedLevel(repo, NRepositorySupportedAction.SEARCH, id, fetchMode, session.isTransitive()); } catch (Exception ex) { // errors.append(CoreStringUtils.exceptionToString(ex)).append("\n"); } @@ -108,7 +108,7 @@ protected NDescriptor fetchDescriptorImplInMirrors(NId id, NFetchMode fetchMode) String idFilename = getIdFilename(id); NWorkspace workspace = repo.getWorkspace(); NSession session = workspace.currentSession(); - NPath versionFolder = cache.getLongIdLocalFolder(id, session); + NPath versionFolder = cache.getLongIdLocalFolder(id); NRepositoryConfigManager rconf = repo.config(); if (session.isTransitive() && rconf.isSupportedMirroring()) { for (NRepository remote : rconf.getMirrors()) { @@ -172,7 +172,7 @@ public void push(NPushRepositoryCmd cmd) { if (NBlankable.isBlank(repository)) { List all = new ArrayList<>(); for (NRepository remote : repo.config().getMirrors()) { - NSpeedQualifier lvl = NRepositoryHelper.getSupportSpeedLevel(remote, NRepositorySupportedAction.DEPLOY, id, NFetchMode.LOCAL, false, session); + NSpeedQualifier lvl = NRepositoryHelper.getSupportSpeedLevel(remote, NRepositorySupportedAction.DEPLOY, id, NFetchMode.LOCAL, false); if (lvl != NSpeedQualifier.UNAVAILABLE) { all.add(remote); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/folder/NFolderRepositoryBase.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/folder/NFolderRepositoryBase.java index 4158399ed..99d1a7016 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/folder/NFolderRepositoryBase.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/folder/NFolderRepositoryBase.java @@ -4,8 +4,8 @@ import net.thevpc.nuts.NConstants; import net.thevpc.nuts.elem.NEDesc; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NSpeedQualifier; -import net.thevpc.nuts.env.NStoreStrategy; +import net.thevpc.nuts.NSpeedQualifier; +import net.thevpc.nuts.NStoreStrategy; import net.thevpc.nuts.format.NTreeVisitResult; import net.thevpc.nuts.format.NTreeVisitor; import net.thevpc.nuts.io.*; @@ -13,13 +13,9 @@ import net.thevpc.nuts.runtime.standalone.repository.NIdPathIteratorBase; import net.thevpc.nuts.runtime.standalone.repository.impl.NCachedRepository; import net.thevpc.nuts.runtime.standalone.repository.util.NIdLocationUtils; -import net.thevpc.nuts.util.NIteratorBuilder; -import net.thevpc.nuts.util.NIteratorUtils; +import net.thevpc.nuts.util.*; import net.thevpc.nuts.runtime.standalone.xtra.digest.NDigestUtils; -import net.thevpc.nuts.util.NIterator; import net.thevpc.nuts.log.NLogVerb; -import net.thevpc.nuts.util.NMsg; -import net.thevpc.nuts.util.NStringUtils; import java.io.IOException; import java.io.InputStream; @@ -71,7 +67,6 @@ public NIterator searchVersionsCore(final NId id, NIdFilter idFilter, NFetc if (!acceptedFetchNoCache(fetchMode)) { return null; } - NSession session = getWorkspace().currentSession(); NIdFilter filter2 = NIdFilters.of().nonnull(idFilter).and( NIdFilters.of().byName(id.getShortName()) ); @@ -84,11 +79,10 @@ public NIterator searchVersionsCore(final NId id, NIdFilter idFilter, NFetc @Override public NPath fetchContentCore(NId id, NDescriptor descriptor, NFetchMode fetchMode) { - NSession session = getWorkspace().currentSession(); if (!acceptedFetchNoCache(fetchMode)) { throw new NNotFoundException(id, new NFetchModeNotSupportedException(this, fetchMode, id.toString(), null)); } - NPath fetch = NIdLocationUtils.fetch(id, descriptor.getLocations(), this, session); + NPath fetch = NIdLocationUtils.fetch(id, descriptor.getLocations(), this); if (fetch != null) { return fetch; } @@ -165,7 +159,6 @@ public boolean isAcceptFetchMode(NFetchMode mode) { public NPath fetchContentCoreUsingRepoHelper(NId id, NDescriptor descriptor, NFetchMode fetchMode) { NPath p = getIdRemotePath(id); - NSession session = getWorkspace().currentSession(); if (p.isLocal()) { if (p.exists()) { return p.copy(); @@ -241,10 +234,12 @@ public NIterator findSingleVersionImpl(final NId id, NIdFilter idFilter, NF return NIteratorBuilder.ofSupplier( () -> { List ret = new ArrayList<>(); - session.getTerminal().printProgress(NMsg.ofC("%-14s %-8s %s", getName(), "search", metadataURL.toCompressedForm())); if (metadataURL.isRegularFile()) { + session.getTerminal().printProgress(NMsg.ofC("%-14s %-8s %s", getName(), "found", metadataURL.toCompressedForm())); // ok found!! ret.add(id); + }else{ + session.getTerminal().printProgress(NMsg.ofC("%-14s %-8s %s", getName(), "missing", metadataURL.toCompressedForm())); } return ret.iterator(); } @@ -268,7 +263,6 @@ public InputStream getStream(NId id, String typeName, String action) { } public String getStreamAsString(NId id, String typeName, String action) { - NSession session = getWorkspace().currentSession(); byte[] barr = NCp.of() .addOptions(NPathOption.LOG, NPathOption.TRACE, NPathOption.SAFE) .from(getIdRemotePath(id)) @@ -286,7 +280,6 @@ public void checkSHA1Hash(NId id, InputStream stream, String typeName) throws IO stream.close(); return; } - NSession session = getWorkspace().currentSession(); switch (NStringUtils.trim(id.getFace())) { case NConstants.QueryFaces.CONTENT_HASH: case NConstants.QueryFaces.DESCRIPTOR_HASH: { @@ -301,7 +294,7 @@ public void checkSHA1Hash(NId id, InputStream stream, String typeName) throws IO try { String rhash = null; try { - rhash = getStreamSHA1(id, session, typeName); + rhash = getStreamSHA1(id, typeName); } catch (UncheckedIOException | NIOException ex) { //sha is not provided... so do not check anything! return; @@ -315,13 +308,13 @@ public void checkSHA1Hash(NId id, InputStream stream, String typeName) throws IO } } - protected String getStreamSHA1(NId id, NSession session, String typeName) { + protected String getStreamSHA1(NId id, String typeName) { // if (!isRemoteRepository()) { // return CoreIOUtils.evalSHA1Hex(getStream(id.builder().setFace(NutsConstants.QueryFaces.CONTENT_HASH).build(), typeName, "verify", session), true, session); // } String hash = getStreamAsString(id, typeName + " SHA1", "verify").toUpperCase(); for (String s : hash.split("[ \n\r]")) { - if (s.length() > 0) { + if (!s.isEmpty()) { return s; } } @@ -330,7 +323,7 @@ protected String getStreamSHA1(NId id, NSession session, String typeName) { public InputStream openStream(NId id, NPath path, Object source, String typeName, String action) { NSession session = getWorkspace().currentSession(); - session.getTerminal().printProgress(NMsg.ofC("%-14s %-8s %s", getName(), action, path.toCompressedForm())); + session.getTerminal().printProgress(NMsg.ofC("%-14s %-8s %s %s", getName(), action, NNameFormat.LOWER_KEBAB_CASE.format(typeName), path.toCompressedForm())); return NInputStreamMonitor.of().setSource(path).setOrigin(source).setSourceTypeName(typeName).create(); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/main/DefaultNInstalledRepository.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/main/DefaultNInstalledRepository.java index 1d0e62b19..73fd56f5c 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/main/DefaultNInstalledRepository.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/main/DefaultNInstalledRepository.java @@ -25,10 +25,11 @@ package net.thevpc.nuts.runtime.standalone.repository.impl.main; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NBootOptions; +import net.thevpc.nuts.NBootOptions; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; + + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.concurrent.NLocks; import net.thevpc.nuts.elem.NEDesc; @@ -83,7 +84,6 @@ public class DefaultNInstalledRepository extends AbstractNRepository implements public DefaultNInstalledRepository(NWorkspace ws, NBootOptions bOptions) { super(ws); - NSession session = ws.currentSession(); this.deployments = new NRepositoryFolderHelper(this, ws, NPath.of(bOptions.getStoreType(NStoreType.LIB).get()).resolve(NConstants.Folders.ID) @@ -125,8 +125,7 @@ public boolean isDefaultVersion(NId id) { @Override public NIterator searchInstallInformation() { - NSession session = workspace.currentSession(); - NPath rootFolder = NLocations.of().getStoreLocation(NStoreType.CONF).resolve(NConstants.Folders.ID); + NPath rootFolder = NWorkspace.get().getStoreLocation(NStoreType.CONF).resolve(NConstants.Folders.ID); return new FolderObjectIterator("NutsInstallInformation", rootFolder, null, -1, new FolderObjectIterator.FolderIteratorModel() { @@ -161,7 +160,7 @@ public String getDefaultVersion(NId id) { return p; } } - NPath pp = NLocations.of().getStoreLocation(id + NPath pp = NWorkspace.get().getStoreLocation(id //.setAlternative("") .builder().setVersion("ANY").build(), NStoreType.CONF) .resolveSibling("default-version"); @@ -183,7 +182,7 @@ public String getDefaultVersion(NId id) { public void setDefaultVersion(NId id) { NId baseVersion = id.getShortId(); String version = id.getVersion().getValue(); - NPath pp = NLocations.of().getStoreLocation(id + NPath pp = NWorkspace.get().getStoreLocation(id // .setAlternative("") .builder().setVersion("ANY").build(), NStoreType.CONF) .resolveSibling("default-version"); @@ -223,7 +222,7 @@ public void install(NId id, NId forId) { try { invalidateInstallationDigest(); String repository = id.getRepository(); - NRepository r = NRepositories.of().findRepository(repository).orNull(); + NRepository r = workspace.findRepository(repository).orNull(); if (ii == null) { ii = new InstallInfoConfig(); ii.setId(id); @@ -394,7 +393,7 @@ public NStream findLog() { } public NId pathToId(NPath path) { - NPath rootFolder = NLocations.of().getStoreLocation(NStoreType.CONF).resolve(NConstants.Folders.ID); + NPath rootFolder = NWorkspace.get().getStoreLocation(NStoreType.CONF).resolve(NConstants.Folders.ID); String p = path.toString().substring(rootFolder.toString().length()); List split = StringTokenizerUtils.split(p, "/\\"); if (split.size() >= 4) { @@ -470,7 +469,7 @@ public InstallInfoConfig getInstallInfoConfig(NId id, NPath path) { } } } - if (changeStatus && !NConfigs.of().isReadOnly()) { + if (changeStatus && !NWorkspace.get().isReadOnly()) { NLocks.of().setSource(path).call(() -> { _LOGOP().level(Level.CONFIG) .log(NMsg.ofJ("install-info upgraded {0}", finalPath)); @@ -490,7 +489,7 @@ public InstallInfoConfig getInstallInfoConfig(NId id, NPath path) { } public NIterator searchInstallConfig() { - NPath rootFolder = NLocations.of().getStoreLocation(NStoreType.CONF).resolve(NConstants.Folders.ID); + NPath rootFolder = NWorkspace.get().getStoreLocation(NStoreType.CONF).resolve(NConstants.Folders.ID); return new FolderObjectIterator("InstallInfoConfig", rootFolder, null, -1, new FolderObjectIterator.FolderIteratorModel() { @@ -537,7 +536,7 @@ public NInstallInformation getInstallInformation(InstallInfoConfig ii) { NInstallStatus s = NInstallStatus.of(ii.isInstalled(), ii.isRequired(), obsolete, defaultVersion); return new DefaultNInstallInfo(ii.getId(), s, - NLocations.of().getStoreLocation(ii.getId(), NStoreType.BIN), + NWorkspace.get().getStoreLocation(ii.getId(), NStoreType.BIN), ii.getCreationDate(), ii.getLastModificationDate(), ii.getCreationUser(), @@ -685,7 +684,7 @@ public boolean contains(NId id, String name, NSession session) { } public NPath getPath(NId id, String name) { - return NLocations.of().getStoreLocation(id, NStoreType.CONF).resolve(name); + return NWorkspace.get().getStoreLocation(id, NStoreType.CONF).resolve(name); } ///////////////////////////////////////////////////////////////////////////////////////////// @@ -779,7 +778,6 @@ public NSearchRepositoryCmd search() { @Override public NSearchRepositoryCmd run() { NIterator installIter = searchInstallConfig(); - NSession session = workspace.currentSession(); NIterator idIter = NIteratorBuilder.of(installIter) .map(NFunction.of(InstallInfoConfig::getId).withDesc(NEDesc.of("NutsInstallInformation->Id"))) .build(); @@ -804,7 +802,7 @@ public NSearchVersionsRepositoryCmd searchVersions() { public NSearchVersionsRepositoryCmd run() { if (getFilter() instanceof NInstallStatusIdFilter) { NPath installFolder - = NLocations.of().getStoreLocation(getId() + = NWorkspace.get().getStoreLocation(getId() .builder().setVersion("ANY").build(), NStoreType.CONF).getParent(); if (installFolder.isDirectory()) { final NVersionFilter filter0 = getId().getVersion().filter(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/main/InstallLogDB.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/main/InstallLogDB.java index 33d712fae..1381eda9a 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/main/InstallLogDB.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/main/InstallLogDB.java @@ -1,25 +1,25 @@ package net.thevpc.nuts.runtime.standalone.repository.impl.main; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NEnvs; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; + + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.runtime.standalone.xtra.nanodb.NanoDB; import net.thevpc.nuts.runtime.standalone.repository.index.NanoDBNIdSerializer; public class InstallLogDB { static NanoDB of(NWorkspace workspace) { synchronized (workspace) { - NanoDB o = (NanoDB) NEnvs.of().getProperties().get(NanoDB.class.getName()); + NanoDB o = (NanoDB) NWorkspace.get().getProperties().get(NanoDB.class.getName()); if (o == null) { o = new NanoDB( - NLocations.of().getStoreLocation( + NWorkspace.get().getStoreLocation( workspace.getApiId().builder().setVersion("SHARED").build(), NStoreType.VAR ).resolve("install-log").toFile().get() ); o.getSerializers().setSerializer(NId.class, () -> new NanoDBNIdSerializer(workspace)); - NEnvs.of().getProperties().put(NanoDB.class.getName(), o); + NWorkspace.get().getProperties().put(NanoDB.class.getName(), o); } return o; } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/main/InstalledRepositoryConfigModel.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/main/InstalledRepositoryConfigModel.java index 4139fd35b..12d1978d4 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/main/InstalledRepositoryConfigModel.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/main/InstalledRepositoryConfigModel.java @@ -1,7 +1,6 @@ package net.thevpc.nuts.runtime.standalone.repository.impl.main; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.*; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.repository.config.AbstractNRepositoryConfigModel; import net.thevpc.nuts.spi.NRepositoryLocation; @@ -121,7 +120,7 @@ public NPath getStoreLocation(NStoreType folderType) { @Override public NStoreStrategy getStoreStrategy() { - return NLocations.of().getRepositoryStoreStrategy(); + return NWorkspace.get().getRepositoryStoreStrategy(); } @Override @@ -251,7 +250,7 @@ public NRepositoryConfig getConfig() { @Override public Map toMap(boolean inherit) { if (inherit) { - return NConfigs.of().getConfigMap(); + return NWorkspace.get().getConfigMap(); } return new HashMap<>(); } @@ -265,7 +264,7 @@ public Map toMap() { public NOptional get(String key, boolean inherit) { NOptional o = NOptional.ofEmpty(() -> NMsg.ofC("repo config property not found : %s", key)); if (inherit) { - return o.orElseUse(()->NConfigs.of().getConfigProperty(key)); + return o.orElseUse(()->NWorkspace.get().getConfigProperty(key)); } return o; } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/MavenFolderRepository.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/MavenFolderRepository.java index 23c2e605a..fd61f6bd8 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/MavenFolderRepository.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/MavenFolderRepository.java @@ -26,7 +26,8 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NLocations; + + import net.thevpc.nuts.io.*; import net.thevpc.nuts.runtime.standalone.io.util.CoreIOUtils; import net.thevpc.nuts.runtime.standalone.repository.impl.folder.NFolderRepositoryBase; @@ -97,13 +98,12 @@ public NIterator findNonSingleVersionImpl(final NId id, NIdFilter idFilter, } private NRepository getLocalMavenRepo() { - NSession session = getWorkspace().currentSession(); - for (NRepository nRepository : NRepositories.of().getRepositories()) { + for (NRepository nRepository : workspace.getRepositories()) { if (nRepository.getRepositoryType().equals(NConstants.RepoTypes.MAVEN) && nRepository.config().getLocationPath() != null && nRepository.config().getLocationPath().toString() .equals( - Paths.get(NPath.of("~/.m2").toAbsolute(NLocations.of().getWorkspaceLocation()).toString()).toString() + Paths.get(NPath.of("~/.m2").toAbsolute(NWorkspace.get().getWorkspaceLocation()).toString()).toString() )) { return nRepository; } @@ -111,7 +111,7 @@ private NRepository getLocalMavenRepo() { return null; } - protected NPath getMavenLocalFolderContent(NId id, NSession session) { + protected NPath getMavenLocalFolderContent(NId id) { NPath p = getIdRelativePath(id); if (p != null) { return NPath.ofUserHome().resolve(".m2").resolve(p); @@ -129,7 +129,6 @@ public NPath fetchContentCoreUsingWrapper(NId id, NDescriptor descriptor, NFetch if (wrapper == null) { wrapper = getWrapper(); } - NSession session = getWorkspace().currentSession(); if (wrapper != null && wrapper.get(id, config().getLocationPath().toString())) { NRepository repo = getLocalMavenRepo(); if (repo != null) { @@ -142,7 +141,7 @@ public NPath fetchContentCoreUsingWrapper(NId id, NDescriptor descriptor, NFetch .getResult(); } //should be already downloaded to m2 folder - NPath content = getMavenLocalFolderContent(id, session); + NPath content = getMavenLocalFolderContent(id); if (content != null && content.exists()) { return content.setUserCache(true).setUserTemporary(false); } @@ -154,7 +153,6 @@ public NPath fetchContentCoreUsingWrapper(NId id, NDescriptor descriptor, NFetch public String getIdExtension(NId id) { Map q = id.getProperties(); String f = NStringUtils.trim(q.get(NConstants.IdProperties.FACE)); - NSession session = getWorkspace().currentSession(); switch (f) { case NConstants.QueryFaces.DESCRIPTOR: { return ".pom"; @@ -170,7 +168,7 @@ public String getIdExtension(NId id) { } case NConstants.QueryFaces.CONTENT: { String packaging = q.get(NConstants.IdProperties.PACKAGING); - return NLocations.of().getDefaultIdContentExtension(packaging); + return NWorkspace.get().getDefaultIdContentExtension(packaging); } default: { throw new NUnsupportedArgumentException(NMsg.ofC("unsupported fact %s", f)); @@ -179,7 +177,6 @@ public String getIdExtension(NId id) { } public NDescriptor fetchDescriptorCore(NId id, NFetchMode fetchMode) { - NSession session = getWorkspace().currentSession(); if (!acceptedFetchNoCache(fetchMode)) { throw new NNotFoundException(id, new NFetchModeNotSupportedException(this, fetchMode, id.toString(), null)); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/MavenRemoteXmlRepository.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/MavenRemoteXmlRepository.java index aa42a1daf..de3a287e8 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/MavenRemoteXmlRepository.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/MavenRemoteXmlRepository.java @@ -71,7 +71,7 @@ public NIterator findNonSingleVersionImpl(NId id, NIdFilter idFilter, NFetc } catch (UncheckedIOException | NIOException ex) { return NIteratorBuilder.emptyIterator(); } - MavenMetadata info = MavenUtils.of().parseMavenMetaData(metadataStream, session); + MavenMetadata info = MavenUtils.of().parseMavenMetaData(metadataStream); if (info != null) { for (String version : info.getVersions()) { final NId nutsId = id.builder().setVersion(version).build(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/MavenSettingsRepository.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/MavenSettingsRepository.java index afd498dc0..3656d5d39 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/MavenSettingsRepository.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/MavenSettingsRepository.java @@ -65,7 +65,6 @@ public boolean isEnabled() { } private MavenFolderRepository createChild(NAddRepositoryOptions options0, String type, String id, String url) { - NSession session = getWorkspace().currentSession(); NPath p = NPath.of(url); String pr = NStringUtils.trim(p.getProtocol()); MavenFolderRepository mavenChild = null; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/NReservedMavenUtils.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/NReservedMavenUtils.java index 7ad04f803..4f3f52700 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/NReservedMavenUtils.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/NReservedMavenUtils.java @@ -28,7 +28,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.boot.reserved.util.NBootJsonParser; -import net.thevpc.nuts.env.NBootOptionsBuilder; +import net.thevpc.nuts.NBootOptionsBuilder; import net.thevpc.nuts.runtime.standalone.io.NCoreIOUtils; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.log.NLog; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/solrsearch/MavenSolrSearchCommand.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/solrsearch/MavenSolrSearchCommand.java index 797323246..c952cb4e6 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/solrsearch/MavenSolrSearchCommand.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/solrsearch/MavenSolrSearchCommand.java @@ -71,7 +71,6 @@ public NIterator search(NIdFilter filter, NId[] baseIds, NFetchMode fetchMo public NPath getSolrSearchUrl() { String a = repo.config().getConfigProperty("maven.solrsearch.url").flatMap(NLiteral::asString).orNull(); if (a != null) { - NSession session = repo.getWorkspace().currentSession(); return NPath.of(a); } return null; @@ -98,7 +97,6 @@ public Iterator search(MavenSolrSearchRequest r, NPath url, NIdFilter idFil } index++; } - NSession session = repo.getWorkspace().currentSession(); NPath query = NPath.of(q2.toString()); NIteratorBuilder it = NIteratorBuilder.ofSupplier(new Supplier>() { @Override diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/util/MavenMetadataParser.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/util/MavenMetadataParser.java index 50c15191d..1d680d12b 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/util/MavenMetadataParser.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/util/MavenMetadataParser.java @@ -1,6 +1,5 @@ package net.thevpc.nuts.runtime.standalone.repository.impl.maven.util; -import net.thevpc.nuts.*; import net.thevpc.nuts.io.NIOException; import net.thevpc.nuts.runtime.standalone.util.xml.XmlUtils; import net.thevpc.nuts.log.NLog; @@ -30,10 +29,7 @@ public class MavenMetadataParser { private final NLog LOG; - private NSession session; - - public MavenMetadataParser(NSession session) { - this.session = session; + public MavenMetadataParser() { LOG= NLog.of(MavenMetadataParser.class); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/util/MavenRepositoryFolderHelper.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/util/MavenRepositoryFolderHelper.java index a5a990709..274ea98b6 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/util/MavenRepositoryFolderHelper.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/util/MavenRepositoryFolderHelper.java @@ -42,7 +42,8 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.elem.NEDesc; -import net.thevpc.nuts.env.NLocations; + + import net.thevpc.nuts.io.NIOException; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.id.util.CoreNIdUtils; @@ -64,12 +65,12 @@ public class MavenRepositoryFolderHelper { private NRepository repo; - private NWorkspace ws; + private NWorkspace workspace; private NPath rootPath; public MavenRepositoryFolderHelper(NRepository repo, NPath rootPath) { this.repo = repo; - this.ws = NWorkspace.get(); + this.workspace = NWorkspace.get(); this.rootPath = rootPath; } @@ -81,13 +82,13 @@ protected NLog _LOG() { return NLog.of(MavenRepositoryFolderHelper.class); } - public NPath getIdLocalFile(NId id, NSession session) { + public NPath getIdLocalFile(NId id) { return getStoreLocation().resolve(NRepositoryExt.of(repo).getIdBasedir(id)) - .resolve(NLocations.of().getDefaultIdFilename(id)); + .resolve(NWorkspace.get().getDefaultIdFilename(id)); } - public NPath fetchContentImpl(NId id, Path localPath, NSession session) { - NPath cacheContent = getIdLocalFile(id, session); + public NPath fetchContentImpl(NId id, Path localPath) { + NPath cacheContent = getIdLocalFile(id); if (cacheContent != null && cacheContent.exists()) { return cacheContent.setUserCache(true).setUserTemporary(false); } @@ -95,37 +96,37 @@ public NPath fetchContentImpl(NId id, Path localPath, NSession session) { } public NWorkspace getWorkspace() { - return ws; + return workspace; } - protected String getIdFilename(NId id, NSession session) { + protected String getIdFilename(NId id) { if (repo == null) { - return NLocations.of().getDefaultIdFilename(id); + return NWorkspace.get().getDefaultIdFilename(id); } return NRepositoryExt.of(repo).getIdFilename(id); } - public NPath getLocalGroupAndArtifactFile(NId id, NSession session) { + public NPath getLocalGroupAndArtifactFile(NId id) { CoreNIdUtils.checkShortId(id); return getStoreLocation().resolve(ExtraApiUtils.resolveIdPath(id.getShortId())); } - public Iterator searchVersions(NId id, final NIdFilter filter, boolean deep, NSession session) { + public Iterator searchVersions(NId id, final NIdFilter filter, boolean deep) { String singleVersion = id.getVersion().asSingleValue().orNull(); if (singleVersion != null) { NId id1 = id.builder().setVersion(singleVersion).setFaceDescriptor().build(); - NPath localFile = getIdLocalFile(id1, session); + NPath localFile = getIdLocalFile(id1); if (localFile != null && localFile.isRegularFile()) { return Collections.singletonList(id.builder().setRepository(repo == null ? null : repo.getName()).build()).iterator(); } return null; } - return searchInFolder(getLocalGroupAndArtifactFile(id, session), filter, - deep ? Integer.MAX_VALUE : 1, - session); + return searchInFolder(getLocalGroupAndArtifactFile(id), filter, + deep ? Integer.MAX_VALUE : 1 + ); } - public Iterator searchInFolder(NPath folder, final NIdFilter filter, int maxDepth, NSession session) { + public Iterator searchInFolder(NPath folder, final NIdFilter filter, int maxDepth) { return new NIdPathIterator(repo, rootPath.normalize(), folder, filter, new NIdPathIteratorBase() { @Override public NWorkspace getWorkspace() { @@ -153,9 +154,9 @@ public NPath getStoreLocation() { return rootPath; } - public NId searchLatestVersion(NId id, NIdFilter filter, NSession session) { + public NId searchLatestVersion(NId id, NIdFilter filter) { NId bestId = null; - NPath file = getLocalGroupAndArtifactFile(id, session); + NPath file = getLocalGroupAndArtifactFile(id); if (file.exists()) { NPath[] versionFolders = file.stream().filter(NPath::isDirectory).withDesc(NEDesc.of("isDirectory")) .toArray(NPath[]::new); @@ -169,11 +170,11 @@ public NId searchLatestVersion(NId id, NIdFilter filter, NSession session) { return bestId; } - public void reindexFolder(NSession session) { - reindexFolder(getStoreLocation(), true, session); + public void reindexFolder() { + reindexFolder(getStoreLocation(), true); } - private void reindexFolder(NPath path, boolean applyRawNavigation, NSession session) { + private void reindexFolder(NPath path, boolean applyRawNavigation) { try { Files.walkFileTree(path.toPath().get(), new FileVisitor() { @Override @@ -223,7 +224,7 @@ public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOEx MavenMetadata old = null; try { if (Files.exists(metadataxml)) { - old = new MavenMetadataParser(session).parseMavenMetaData(metadataxml); + old = new MavenMetadataParser().parseMavenMetaData(metadataxml); } } catch (Exception ex) { _LOGOP().level(Level.SEVERE).error(ex) @@ -257,7 +258,7 @@ public int compare(String o1, String o2) { m.setLastUpdated(new Date()); } // println(MavenMetadataParser.toXmlString(m)); - new MavenMetadataParser(session).writeMavenMetaData(m, metadataxml); + new MavenMetadataParser().writeMavenMetaData(m, metadataxml); String md5 = NDigestUtils.evalMD5Hex(metadataxml).toLowerCase(); Files.write(metadataxml.resolveSibling("maven-metadata.xml.md5"), md5.getBytes()); String sha1 = NDigestUtils.evalSHA1Hex(NPath.of(metadataxml)).toLowerCase(); @@ -285,7 +286,7 @@ public int compare(String o1, String o2) { // throw new NutsIOException(getWorkspace(),e); // } try (PrintStream p = new PrintStream(new File(folder, CoreNConstants.Files.DOT_FILES))) { - p.println("#version=" + ws.getApiVersion()); + p.println("#version=" + workspace.getApiVersion()); for (String file : folders) { p.println(file + "/"); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/util/MavenUtils.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/util/MavenUtils.java index 79821c0f1..d7a23db3c 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/util/MavenUtils.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/util/MavenUtils.java @@ -25,7 +25,6 @@ package net.thevpc.nuts.runtime.standalone.repository.impl.maven.util; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.*; import net.thevpc.nuts.runtime.standalone.*; import net.thevpc.nuts.text.NText; import net.thevpc.nuts.util.NBlankable; @@ -65,19 +64,19 @@ private MavenUtils() { } public static MavenUtils of() { - MavenUtils wp = (MavenUtils) NEnvs.of().getProperties().get(MavenUtils.class.getName()); + MavenUtils wp = (MavenUtils) NWorkspace.get().getProperties().get(MavenUtils.class.getName()); if (wp == null) { wp = new MavenUtils(); - NEnvs.of().setProperty(MavenUtils.class.getName(), wp); + NWorkspace.get().setProperty(MavenUtils.class.getName(), wp); } return wp; } public static NPomIdResolver createPomIdResolver(NWorkspace workspace) { - NPomIdResolver wp = (NPomIdResolver) NEnvs.of().getProperties().get(NPomIdResolver.class.getName()); + NPomIdResolver wp = (NPomIdResolver) NWorkspace.get().getProperties().get(NPomIdResolver.class.getName()); if (wp == null) { wp = new NPomIdResolver(workspace); - NEnvs.of().setProperty(NPomIdResolver.class.getName(), wp); + NWorkspace.get().setProperty(NPomIdResolver.class.getName(), wp); } return wp; } @@ -635,8 +634,8 @@ public NDescriptor parsePomXmlAndResolveParents(InputStream stream, NFetchMode f // session).map(NutsFunction.of(this::toNutsId, "PomId->NutsId")).build(); // } - public MavenMetadata parseMavenMetaData(InputStream metadataStream, NSession session) { - MavenMetadata s = new MavenMetadataParser(session).parseMavenMetaData(metadataStream); + public MavenMetadata parseMavenMetaData(InputStream metadataStream) { + MavenMetadata s = new MavenMetadataParser().parseMavenMetaData(metadataStream); if (s == null) { return s; } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/util/MvnClient.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/util/MvnClient.java index 4f914011e..9b0bdb71a 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/util/MvnClient.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/maven/util/MvnClient.java @@ -23,7 +23,6 @@ public MvnClient(NWorkspace workspace) { } protected NLog LOG() { - NSession session = workspace.currentSession(); return NLog.of(MvnClient.class); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/nuts/NFolderRepository.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/nuts/NFolderRepository.java index 9ec9e885c..d77c82a98 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/nuts/NFolderRepository.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/nuts/NFolderRepository.java @@ -26,7 +26,8 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NLocations; + + import net.thevpc.nuts.io.NIOException; import net.thevpc.nuts.io.NInputSource; import net.thevpc.nuts.io.NPath; @@ -47,12 +48,11 @@ * Created by vpc on 1/5/17. */ public class NFolderRepository extends NFolderRepositoryBase { - + private boolean userPom=false; public NFolderRepository(NAddRepositoryOptions options, NWorkspace workspace, NRepository parentRepository) { super(options, workspace, parentRepository, null, true, NConstants.RepoTypes.NUTS, true); repoIter = new NRepoIter(this); -// LOG = session.log().of(NutsFolderRepository.class); extensions.put("src", "-src.zip"); } @@ -62,7 +62,6 @@ public NId searchLatestVersionCore(NId id, NIdFilter filter, NFetchMode fetchMod } public String getIdExtension(NId id) { - NSession session=getWorkspace().currentSession(); Map q = id.getProperties(); String f = NStringUtils.trim(q.get(NConstants.IdProperties.FACE)); switch (f) { @@ -80,7 +79,7 @@ public String getIdExtension(NId id) { } case NConstants.QueryFaces.CONTENT: { String packaging = q.get(NConstants.IdProperties.PACKAGING); - return NLocations.of().getDefaultIdContentExtension(packaging); + return NWorkspace.get().getDefaultIdContentExtension(packaging); } default: { throw new NUnsupportedArgumentException(NMsg.ofC("unsupported fact %s", f)); @@ -89,7 +88,6 @@ public String getIdExtension(NId id) { } public NDescriptor fetchDescriptorCore(NId id, NFetchMode fetchMode) { - NSession session=getWorkspace().currentSession(); if (!acceptedFetchNoCache(fetchMode)) { throw new NNotFoundException(id, new NFetchModeNotSupportedException(this, fetchMode, id.toString(), null)); } @@ -134,47 +132,57 @@ public NDescriptor fetchDescriptorCore(NId id, NFetchMode fetchMode) { nutsPathEx = e; //ignore } - //now try pom file (maven!) - InputStream stream = null; - NPath pomURL = - config().getLocationPath().resolve( - getIdBasedir(id).resolve( - getIdFilename(id, ".pom") - ) - ); - try { - NDescriptor nutsDescriptor = null; - byte[] bytes = null; - String name = null; + if(userPom) { + //now try pom file (maven!) + InputStream stream = null; + NPath pomURL = + config().getLocationPath().resolve( + getIdBasedir(id).resolve( + getIdFilename(id, ".pom") + ) + ); try { - stream = openStream(id, pomURL, id, "artifact descriptor", "retrieve"); - bytes = NIOUtils.loadByteArray(stream, true); - name = NInputSource.of(stream).getMetaData().getName().orElse("no-name"); - nutsDescriptor = NDescriptorParser.of() - .setDescriptorStyle(NDescriptorStyle.NUTS) - .parse(CoreIOUtils.createBytesStream(bytes, NMsg.ofNtf(name), "text/xml", StandardCharsets.UTF_8.name(), "pom.xml")).get(); + NDescriptor nutsDescriptor = null; + byte[] bytes = null; + String name = null; + try { + stream = openStream(id, pomURL, id, "artifact descriptor", "retrieve"); + bytes = NIOUtils.loadByteArray(stream, true); + name = NInputSource.of(stream).getMetaData().getName().orElse("no-name"); + nutsDescriptor = NDescriptorParser.of() + .setDescriptorStyle(NDescriptorStyle.NUTS) + .parse(CoreIOUtils.createBytesStream(bytes, NMsg.ofNtf(name), "text/xml", StandardCharsets.UTF_8.name(), "pom.xml")).get(); - } finally { - if (stream != null) { - stream.close(); + } finally { + if (stream != null) { + stream.close(); + } } + checkSHA1Hash(id.builder().setFace(NConstants.QueryFaces.DESCRIPTOR_HASH).build(), + CoreIOUtils.createBytesStream(bytes, name == null ? null : NMsg.ofNtf(name), "text/xml", StandardCharsets.UTF_8.name(), "pom.xml") + , "artifact descriptor"); + return nutsDescriptor; + } catch (IOException | UncheckedIOException | NIOException ex) { + throw new NNotFoundException(id, + new NNotFoundException.NIdInvalidDependency[0], + new NNotFoundException.NIdInvalidLocation[]{ + new NNotFoundException.NIdInvalidLocation( + getName(), nutsPath.toString(), nutsPathEx.getMessage() + ), + new NNotFoundException.NIdInvalidLocation( + getName(), pomURL.toString(), ex.getMessage() + ) + }, + ex); } - checkSHA1Hash(id.builder().setFace(NConstants.QueryFaces.DESCRIPTOR_HASH).build(), - CoreIOUtils.createBytesStream(bytes, name == null ? null : NMsg.ofNtf(name), "text/xml", StandardCharsets.UTF_8.name(), "pom.xml") - , "artifact descriptor"); - return nutsDescriptor; - } catch (IOException | UncheckedIOException | NIOException ex) { - throw new NNotFoundException(id, - new NNotFoundException.NIdInvalidDependency[0], - new NNotFoundException.NIdInvalidLocation[]{ - new NNotFoundException.NIdInvalidLocation( - getName(), nutsPath.toString(), nutsPathEx.getMessage() - ), - new NNotFoundException.NIdInvalidLocation( - getName(), pomURL.toString(), ex.getMessage() - ) - }, - ex); } + throw new NNotFoundException(id, + new NNotFoundException.NIdInvalidDependency[0], + new NNotFoundException.NIdInvalidLocation[]{ + new NNotFoundException.NIdInvalidLocation( + getName(), nutsPath.toString(), nutsPathEx.getMessage() + ) + }, + nutsPathEx); } } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/nuts/NHttpSrvRepository.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/nuts/NHttpSrvRepository.java index 5fc0ce28d..bd34fee0e 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/nuts/NHttpSrvRepository.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/nuts/NHttpSrvRepository.java @@ -26,16 +26,15 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NSpeedQualifier; -import net.thevpc.nuts.env.NUser; -import net.thevpc.nuts.env.NUserConfig; +import net.thevpc.nuts.NSpeedQualifier; +import net.thevpc.nuts.NUser; +import net.thevpc.nuts.NUserConfig; import net.thevpc.nuts.format.NDescriptorFormat; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.elem.NElement; import net.thevpc.nuts.elem.NElements; import net.thevpc.nuts.io.*; import net.thevpc.nuts.runtime.standalone.repository.util.NIdLocationUtils; -import net.thevpc.nuts.runtime.standalone.session.NSessionUtils; import net.thevpc.nuts.util.NIteratorBase; import net.thevpc.nuts.runtime.standalone.id.filter.NExprIdFilter; import net.thevpc.nuts.runtime.standalone.repository.impl.NCachedRepository; @@ -83,8 +82,7 @@ public String getUrl(String path) { public NId getRemoteId() { if (remoteId == null) { try { - NSession session = getWorkspace().currentSession(); - remoteId = NId.of(httpGetString(getUrl("/version"), session)).get(); + remoteId = NId.of(httpGetString(getUrl("/version"))).get(); } catch (Exception ex) { LOG().with().level(Level.WARNING).verb(NLogVerb.FAIL) .log(NMsg.ofJ("unable to resolve Repository NutsId for remote repository {0}", config().getLocation())); @@ -95,18 +93,16 @@ public NId getRemoteId() { @Override public void pushImpl(NPushRepositoryCmd command) { - NSession session=getWorkspace().currentSession(); NPath content = lib.fetchContentImpl(command.getId()); NDescriptor desc = lib.fetchDescriptorImpl(command.getId()); if (content == null || desc == null) { throw new NNotFoundException(command.getId()); } - NSessionUtils.checkSession(getWorkspace(), session); ByteArrayOutputStream descStream = new ByteArrayOutputStream(); NDescriptorFormat.of(desc).print(new OutputStreamWriter(descStream)); NWebCli nWebCli = NWebCli.of(); nWebCli.req().post() - .setUrl(CoreIOUtils.buildUrl(config().getLocationPath().toString(), "/deploy?" + resolveAuthURLPart(session))) + .setUrl(CoreIOUtils.buildUrl(config().getLocationPath().toString(), "/deploy?" + resolveAuthURLPart())) .addPart("descriptor-hash", NDigest.of().sha1().setSource(desc).computeString()) .addPart("content-hash", NDigestUtils.evalSHA1Hex(content)) .addPart("force", NDigestUtils.evalSHA1Hex(content)) @@ -123,10 +119,10 @@ public NDescriptor fetchDescriptorCore(NId id, NFetchMode fetchMode) { } boolean transitive = session.isTransitive(); session.getTerminal().printProgress(NMsg.ofC("loading descriptor for %s", id.getLongId())); - try (InputStream stream = NPath.of(getUrl("/fetch-descriptor?id=" + CoreIOUtils.urlEncodeString(id.toString()) + (transitive ? ("&transitive") : "") + "&" + resolveAuthURLPart(session))).getInputStream()) { + try (InputStream stream = NPath.of(getUrl("/fetch-descriptor?id=" + CoreIOUtils.urlEncodeString(id.toString()) + (transitive ? ("&transitive") : "") + "&" + resolveAuthURLPart())).getInputStream()) { NDescriptor descriptor = NDescriptorParser.of().parse(stream).get(); if (descriptor != null) { - String hash = httpGetString(getUrl("/fetch-descriptor-hash?id=" + CoreIOUtils.urlEncodeString(id.toString()) + (transitive ? ("&transitive") : "") + "&" + resolveAuthURLPart(session)), session); + String hash = httpGetString(getUrl("/fetch-descriptor-hash?id=" + CoreIOUtils.urlEncodeString(id.toString()) + (transitive ? ("&transitive") : "") + "&" + resolveAuthURLPart())); if (hash.equals(descriptor.toString())) { return descriptor; } @@ -147,11 +143,11 @@ public NIterator searchVersionsCore(NId id, NIdFilter idFilter, NFetchMode InputStream ret = null; try { session.getTerminal().printProgress(NMsg.ofC("search version for %s", id.getLongId())); - ret = NPath.of(getUrl("/find-versions?id=" + CoreIOUtils.urlEncodeString(id.toString()) + (transitive ? ("&transitive") : "") + "&" + resolveAuthURLPart(session))).getInputStream(); + ret = NPath.of(getUrl("/find-versions?id=" + CoreIOUtils.urlEncodeString(id.toString()) + (transitive ? ("&transitive") : "") + "&" + resolveAuthURLPart())).getInputStream(); } catch (UncheckedIOException | NIOException e) { return NIteratorBuilder.emptyIterator(); } - NIterator it = new NamedNIdFromStreamIterator(ret, session); + NIterator it = new NamedNIdFromStreamIterator(ret); NIdFilter filter2 = NIdFilters.of().nonnull(idFilter).and( NIdFilters.of().byName(id.getShortName()) ); @@ -171,13 +167,13 @@ public NIterator searchCore(final NIdFilter filter, NPath[] basePaths, NId[ session.getTerminal().printProgress(NMsg.ofC("search into %s ", Arrays.toString(basePaths))); boolean transitive = session.isTransitive(); InputStream ret = null; - String[] ulp = resolveEncryptedAuth(session); + String[] ulp = resolveEncryptedAuth(); if (filter instanceof NExprIdFilter) { String js = ((NExprIdFilter) filter).toExpr(); if (js != null) { NWebCli nWebCli = NWebCli.of(); ret = nWebCli.req().post() - .setUrl(getUrl("/find?" + (transitive ? ("transitive") : "") + "&" + resolveAuthURLPart(session))) + .setUrl(getUrl("/find?" + (transitive ? ("transitive") : "") + "&" + resolveAuthURLPart())) .addPart("root", "/") .addPart("ul", ulp[0]) .addPart("up", ulp[1]) @@ -185,12 +181,12 @@ public NIterator searchCore(final NIdFilter filter, NPath[] basePaths, NId[ NInputSource.of(js.getBytes())).end() .run() .getContent().getInputStream(); - return NIteratorBuilder.of(new NamedNIdFromStreamIterator(ret, session)).filter(CoreFilterUtils.createFilter(filter)).iterator(); + return NIteratorBuilder.of(new NamedNIdFromStreamIterator(ret)).filter(CoreFilterUtils.createFilter(filter)).iterator(); } } else { NWebCli nWebCli = NWebCli.of(); ret = nWebCli.req().post() - .setUrl(getUrl("/find?" + (transitive ? ("transitive") : "") + "&" + resolveAuthURLPart(session))) + .setUrl(getUrl("/find?" + (transitive ? ("transitive") : "") + "&" + resolveAuthURLPart())) .addPart("root", "/") .addPart("ul", ulp[0]) .addPart("up", ulp[1]) @@ -200,9 +196,9 @@ public NIterator searchCore(final NIdFilter filter, NPath[] basePaths, NId[ .getContent().getInputStream(); } if (filter == null) { - return new NamedNIdFromStreamIterator(ret, session); + return new NamedNIdFromStreamIterator(ret); } - return NIteratorBuilder.of(new NamedNIdFromStreamIterator(ret, session)).filter(CoreFilterUtils.createFilter(filter)).iterator(); + return NIteratorBuilder.of(new NamedNIdFromStreamIterator(ret)).filter(CoreFilterUtils.createFilter(filter)).iterator(); } @@ -212,7 +208,7 @@ public NPath fetchContentCore(NId id, NDescriptor descriptor, NFetchMode fetchMo if (fetchMode != NFetchMode.REMOTE) { throw new NNotFoundException(id, new NFetchModeNotSupportedException(this, fetchMode, id.toString(), null)); } - NPath localPath=NIdLocationUtils.fetch(id, descriptor.getLocations(), this, session); + NPath localPath=NIdLocationUtils.fetch(id, descriptor.getLocations(), this); if (localPath!=null) { return localPath; } @@ -220,11 +216,11 @@ public NPath fetchContentCore(NId id, NDescriptor descriptor, NFetchMode fetchMo try { localPath = NPath.ofTempRepositoryFile(new File(this.getIdFilename(id)).getName(), this); - String location = getUrl("/fetch?id=" + CoreIOUtils.urlEncodeString(id.toString()) + (transitive ? ("&transitive") : "") + "&" + resolveAuthURLPart(session)); + String location = getUrl("/fetch?id=" + CoreIOUtils.urlEncodeString(id.toString()) + (transitive ? ("&transitive") : "") + "&" + resolveAuthURLPart()); NCp.of().from( NPath.of(location) ).to(localPath).addOptions(NPathOption.SAFE, NPathOption.LOG, NPathOption.TRACE).run(); - String rhash = httpGetString(getUrl("/fetch-hash?id=" + CoreIOUtils.urlEncodeString(id.toString()) + (transitive ? ("&transitive") : "") + "&" + resolveAuthURLPart(session)), session); + String rhash = httpGetString(getUrl("/fetch-hash?id=" + CoreIOUtils.urlEncodeString(id.toString()) + (transitive ? ("&transitive") : "") + "&" + resolveAuthURLPart())); String lhash = NDigestUtils.evalSHA1Hex(localPath); if (rhash.equalsIgnoreCase(lhash)) { return localPath.setUserCache(false); @@ -236,7 +232,7 @@ public NPath fetchContentCore(NId id, NDescriptor descriptor, NFetchMode fetchMo return null; } - private String httpGetString(String url, NSession session) { + private String httpGetString(String url) { LOG().with().level(Level.FINEST).verb(NLogVerb.START) .log(NMsg.ofJ("get URL{0}", url)); return NIOUtils.loadString(NPath.of(url).getInputStream(), true); @@ -247,7 +243,7 @@ public String toString() { return super.toString() + ((this.remoteId == null ? "" : " ; desc=" + this.remoteId)); } - private String[] resolveEncryptedAuth(NSession session) { + private String[] resolveEncryptedAuth() { String login = NWorkspaceSecurityManager.of().getCurrentUsername(); NUserConfig security = NRepositoryConfigManagerExt.of(config()).getModel().findUser(login).orNull(); String newLogin = ""; @@ -286,8 +282,8 @@ private String[] resolveEncryptedAuth(NSession session) { return new String[]{newLogin, new String(credentials)}; } - private String resolveAuthURLPart(NSession session) { - String[] auth = resolveEncryptedAuth(session); + private String resolveAuthURLPart() { + String[] auth = resolveEncryptedAuth(); return "ul=" + CoreIOUtils.urlEncodeString(auth[0]) + "&up=" + CoreIOUtils.urlEncodeString(auth[0]); } @@ -306,13 +302,11 @@ private class NamedNIdFromStreamIterator extends NIteratorBase { private final BufferedReader br; private String line; - private NSession session; private InputStream source0; - public NamedNIdFromStreamIterator(InputStream ret, NSession session) { + public NamedNIdFromStreamIterator(InputStream ret) { br = new BufferedReader(new InputStreamReader(ret)); line = null; - this.session = session; } @Override diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/util/CommonRootsByIdHelper.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/util/CommonRootsByIdHelper.java index 2fe3a67fb..71f7d1f57 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/util/CommonRootsByIdHelper.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/util/CommonRootsByIdHelper.java @@ -18,7 +18,7 @@ */ public class CommonRootsByIdHelper { - private static Set resolveRootIdAnd(Set a, Set b, NSession session) { + private static Set resolveRootIdAnd(Set a, Set b) { if (a == null) { return b; } @@ -36,7 +36,7 @@ private static Set resolveRootIdAnd(Set a, Set b, NSession sessio HashSet h = new HashSet<>(); for (NId path : aa) { for (NId nutsPath : bb) { - h.add(commonRoot(path, nutsPath, session)); + h.add(commonRoot(path, nutsPath)); } } //TODO @@ -108,7 +108,7 @@ private static Set resolveRootIdOr(Set a, Set b) { return new HashSet<>(x.values()); } - private static NId commonRoot(NId a, NId b, NSession session) { + private static NId commonRoot(NId a, NId b) { if (a.getShortName().equals(b.getShortName())) { return a; } @@ -126,19 +126,19 @@ private static NId commonRoot(NId a, NId b, NSession session) { return NId.of(sb.toString() + ":*").get(); } - private static Set resolveRootId(String groupId, String artifactId, String version, NSession session) { + private static Set resolveRootId(String groupId, String artifactId, String version) { return new HashSet<>(Collections.singletonList(NIdBuilder.of() .setGroupId(NBlankable.isBlank(groupId) ? "*" : groupId) .setArtifactId(NBlankable.isBlank(artifactId) ? "*" : artifactId) .build())); } - public static List resolveRootPaths(NIdFilter filter, NSession session) { - return new ArrayList<>(CommonRootsByIdHelper.resolveRootIds(filter, session)); + public static List resolveRootPaths(NIdFilter filter) { + return new ArrayList<>(CommonRootsByIdHelper.resolveRootIds(filter)); } - public static Set resolveRootIds(NIdFilter filter, NSession session) { - Set v = resolveRootId0(filter, session); + public static Set resolveRootIds(NIdFilter filter) { + Set v = resolveRootId0(filter); if (v == null) { HashSet s = new HashSet<>(); s.add(NId.of("*:*").get()); @@ -147,7 +147,7 @@ public static Set resolveRootIds(NIdFilter filter, NSession session) { return v; } - public static Set resolveRootId0(NIdFilter filter, NSession session) { + public static Set resolveRootId0(NIdFilter filter) { if (filter == null) { return null; } @@ -155,7 +155,7 @@ public static Set resolveRootId0(NIdFilter filter, NSession session) { NIdFilterAnd f = ((NIdFilterAnd) filter); Set xx = null; for (NIdFilter g : f.getChildren()) { - xx = resolveRootIdAnd(xx, resolveRootId0(g, session), session); + xx = resolveRootIdAnd(xx, resolveRootId0(g)); } return xx; } @@ -166,15 +166,15 @@ public static Set resolveRootId0(NIdFilter filter, NSession session) { if (y.length == 0) { return null; } - Set xx = resolveRootId0(y[0], session); + Set xx = resolveRootId0(y[0]); for (int i = 1; i < y.length; i++) { - xx = resolveRootIdOr(xx, resolveRootId0(y[i], session)); + xx = resolveRootIdOr(xx, resolveRootId0(y[i])); } return xx; } if (filter instanceof NPatternIdFilter) { NPatternIdFilter f = ((NPatternIdFilter) filter); - return resolveRootId(f.getId().getGroupId(), f.getId().getArtifactId(), f.getId().getVersion().toString(), session); + return resolveRootId(f.getId().getGroupId(), f.getId().getArtifactId(), f.getId().getVersion().toString()); } return null; } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/util/CommonRootsByPathHelper.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/util/CommonRootsByPathHelper.java index fe9ef8450..e0cd66093 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/util/CommonRootsByPathHelper.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/impl/util/CommonRootsByPathHelper.java @@ -9,7 +9,6 @@ import net.thevpc.nuts.NIdFilter; import net.thevpc.nuts.io.NPath; -import net.thevpc.nuts.NSession; import net.thevpc.nuts.runtime.standalone.id.filter.NIdFilterAnd; import net.thevpc.nuts.runtime.standalone.id.filter.NIdFilterOr; import net.thevpc.nuts.runtime.standalone.id.filter.NPatternIdFilter; @@ -19,7 +18,7 @@ */ public class CommonRootsByPathHelper { - private static Set resolveRootIdAnd(Set a, Set b, NSession session) { + private static Set resolveRootIdAnd(Set a, Set b) { if (a == null) { return b; } @@ -37,7 +36,7 @@ private static Set resolveRootIdAnd(Set a, Set b, NSession HashSet h = new HashSet<>(); for (NPath path : aa) { for (NPath nutsPath : bb) { - h.add(commonRoot(path, nutsPath, session)); + h.add(commonRoot(path, nutsPath)); } } //TODO @@ -94,7 +93,7 @@ private static Set resolveRootIdOr(Set a, Set b) { return new HashSet<>(x.values()); } - private static NPath commonRoot(NPath a, NPath b, NSession session) { + private static NPath commonRoot(NPath a, NPath b) { boolean a_deep; String a_path; boolean b_deep; @@ -130,7 +129,7 @@ private static NPath commonRoot(NPath a, NPath b, NSession session) { return NPath.of(sb.toString()); } - private static Set resolveRootId(String groupId, String artifactId, String version, NSession session) { + private static Set resolveRootId(String groupId, String artifactId, String version) { String g = groupId; if (g == null) { g = ""; @@ -169,12 +168,12 @@ private static Set resolveRootId(String groupId, String artifactId, Strin return new HashSet<>(Collections.singletonList(NPath.of(g.replace('.', '/')))); } - public static List resolveRootPaths(NIdFilter filter, NSession session) { - return new ArrayList<>(CommonRootsByPathHelper.resolveRootIds(filter, session)); + public static List resolveRootPaths(NIdFilter filter) { + return new ArrayList<>(CommonRootsByPathHelper.resolveRootIds(filter)); } - public static Set resolveRootIds(NIdFilter filter, NSession session) { - Set v = resolveRootId0(filter, session); + public static Set resolveRootIds(NIdFilter filter) { + Set v = resolveRootId0(filter); if (v == null) { HashSet s = new HashSet<>(); s.add(NPath.of("*")); @@ -183,7 +182,7 @@ public static Set resolveRootIds(NIdFilter filter, NSession session) { return v; } - public static Set resolveRootId0(NIdFilter filter, NSession session) { + public static Set resolveRootId0(NIdFilter filter) { if (filter == null) { return null; } @@ -191,7 +190,7 @@ public static Set resolveRootId0(NIdFilter filter, NSession session) { NIdFilterAnd f = ((NIdFilterAnd) filter); Set xx = null; for (NIdFilter g : f.getChildren()) { - xx = resolveRootIdAnd(xx, resolveRootId0(g, session), session); + xx = resolveRootIdAnd(xx, resolveRootId0(g)); } return xx; } @@ -202,15 +201,15 @@ public static Set resolveRootId0(NIdFilter filter, NSession session) { if (y.length == 0) { return null; } - Set xx = resolveRootId0(y[0], session); + Set xx = resolveRootId0(y[0]); for (int i = 1; i < y.length; i++) { - xx = resolveRootIdOr(xx, resolveRootId0(y[i], session)); + xx = resolveRootIdOr(xx, resolveRootId0(y[i])); } return xx; } if (filter instanceof NPatternIdFilter) { NPatternIdFilter f = ((NPatternIdFilter) filter); - return resolveRootId(f.getId().getGroupId(), f.getId().getArtifactId(), f.getId().getVersion().toString(),session); + return resolveRootId(f.getId().getGroupId(), f.getId().getArtifactId(), f.getId().getVersion().toString()); } return null; } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/index/ArtifactsIndexDB.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/index/ArtifactsIndexDB.java index 174518dd8..e4b8c8750 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/index/ArtifactsIndexDB.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/index/ArtifactsIndexDB.java @@ -1,6 +1,6 @@ package net.thevpc.nuts.runtime.standalone.repository.index; -import net.thevpc.nuts.env.NEnvs; + import net.thevpc.nuts.NId; import net.thevpc.nuts.NWorkspace; import net.thevpc.nuts.util.NStream; @@ -26,10 +26,10 @@ public ArtifactsIndexDB(String tableName, NanoDB db) { public static ArtifactsIndexDB of() { synchronized (NWorkspace.get()) { - ArtifactsIndexDB o = (ArtifactsIndexDB) NEnvs.of().getProperties().get(ArtifactsIndexDB.class.getName()); + ArtifactsIndexDB o = (ArtifactsIndexDB) NWorkspace.get().getProperties().get(ArtifactsIndexDB.class.getName()); if (o == null) { o = new ArtifactsIndexDB(DEFAULT_ARTIFACT_TABLE_NAME, CacheDB.of()); - NEnvs.of().getProperties().put(ArtifactsIndexDB.class.getName(), o); + NWorkspace.get().getProperties().put(ArtifactsIndexDB.class.getName(), o); } return o; } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/index/CacheDB.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/index/CacheDB.java index 49582594a..46ecf962c 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/index/CacheDB.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/index/CacheDB.java @@ -1,26 +1,26 @@ package net.thevpc.nuts.runtime.standalone.repository.index; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NEnvs; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; + + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.runtime.standalone.xtra.nanodb.NanoDB; public class CacheDB { public static NanoDB of() { NWorkspace workspace = NWorkspace.of().get(); synchronized (workspace) { - NanoDB o = (NanoDB) NEnvs.of().getProperties().get(CacheDB.class.getName()); + NanoDB o = (NanoDB) NWorkspace.get().getProperties().get(CacheDB.class.getName()); if (o == null) { o = new NanoDB( - NLocations.of().getStoreLocation( + NWorkspace.get().getStoreLocation( workspace.getApiId().builder().setVersion("SHARED").build() , NStoreType.CACHE ).resolve("cachedb").toFile().get() ); o.getSerializers().setSerializer(NId.class,()->new NanoDBNIdSerializer(workspace)); - NEnvs.of().getProperties().put(CacheDB.class.getName(), o); + NWorkspace.get().getProperties().put(CacheDB.class.getName(), o); } return o; } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/util/NIdLocationUtils.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/util/NIdLocationUtils.java index c6a5bb4e5..d654c7447 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/util/NIdLocationUtils.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/repository/util/NIdLocationUtils.java @@ -1,7 +1,7 @@ package net.thevpc.nuts.runtime.standalone.repository.util; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NIdLocation; +import net.thevpc.nuts.NIdLocation; import net.thevpc.nuts.io.NCp; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.io.NPathOption; @@ -15,7 +15,7 @@ import java.util.logging.Level; public class NIdLocationUtils { - public static NPath fetch(NId id, List locations, AbstractNRepository repository, NSession session) { + public static NPath fetch(NId id, List locations, AbstractNRepository repository) { for (NIdLocation location : locations) { if (CoreFilterUtils.acceptClassifier(location, id.getClassifier())) { try { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/DefaultNRepositorySecurityManager.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/DefaultNRepositorySecurityManager.java index 5904d2e7c..466a03526 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/DefaultNRepositorySecurityManager.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/DefaultNRepositorySecurityManager.java @@ -7,7 +7,7 @@ import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NUser; +import net.thevpc.nuts.NUser; import net.thevpc.nuts.runtime.standalone.session.NSessionUtils; import net.thevpc.nuts.security.NAuthenticationAgent; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/DefaultNRepositorySecurityModel.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/DefaultNRepositorySecurityModel.java index f2e422c14..154202d54 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/DefaultNRepositorySecurityModel.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/DefaultNRepositorySecurityModel.java @@ -7,13 +7,12 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NUser; -import net.thevpc.nuts.env.NUserConfig; +import net.thevpc.nuts.NUser; +import net.thevpc.nuts.NUserConfig; import net.thevpc.nuts.runtime.standalone.repository.config.DefaultNRepoConfigManager; -import net.thevpc.nuts.runtime.standalone.session.NSessionUtils; +import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; import net.thevpc.nuts.util.NCoreCollectionUtils; import net.thevpc.nuts.runtime.standalone.workspace.config.NRepositoryConfigManagerExt; -import net.thevpc.nuts.runtime.standalone.workspace.config.NConfigsExt; import net.thevpc.nuts.security.NAuthenticationAgent; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.util.NMsg; @@ -46,8 +45,6 @@ public void onConfigurationChanged(NRepositoryEvent event) { } public void checkAllowed(String right, String operationName) { - NSession session=repository.getWorkspace().currentSession(); - NSessionUtils.checkSession(repository.getWorkspace(), session); if (!isAllowed(right)) { if (NBlankable.isBlank(operationName)) { throw new NSecurityException(NMsg.ofC("%s not allowed!",right)); @@ -91,7 +88,6 @@ private NAuthorizations getAuthorizations(String n) { } public boolean isAllowed(String right) { - NSession session=repository.getWorkspace().currentSession(); NWorkspaceSecurityManager sec = NWorkspaceSecurityManager.of(); if (!sec.isSecure()) { return true; @@ -173,9 +169,8 @@ public NAuthenticationAgent getAuthenticationAgent(String id) { .getModel() .getStoredConfig().getAuthenticationAgent(); } - NSession session = getWorkspace().currentSession(); - NAuthenticationAgent a = NConfigsExt.of(NConfigs.of()) - .getModel() + NAuthenticationAgent a = NWorkspaceExt.of(getWorkspace()) + .getConfigModel() .createAuthenticationAgent(id); return a; } @@ -183,10 +178,9 @@ public NAuthenticationAgent getAuthenticationAgent(String id) { public void setAuthenticationAgent(String authenticationAgent) { // options = CoreNutsUtils.validate(options, repository.getWorkspace()); DefaultNRepoConfigManager cc = (DefaultNRepoConfigManager) repository.config(); - NSession session=repository.getWorkspace().currentSession(); - if (NConfigsExt.of(NConfigs.of()) - .getModel().createAuthenticationAgent(authenticationAgent) == null) { + if (NWorkspaceExt.of(getWorkspace()) + .getConfigModel().createAuthenticationAgent(authenticationAgent) == null) { throw new NIllegalArgumentException( NMsg.ofC("unsupported Authentication Agent %s", authenticationAgent) ); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/DefaultNUser.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/DefaultNUser.java index 6e82638cf..8bf996648 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/DefaultNUser.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/DefaultNUser.java @@ -6,8 +6,8 @@ package net.thevpc.nuts.runtime.standalone.security; import net.thevpc.nuts.util.NBlankable; -import net.thevpc.nuts.env.NUser; -import net.thevpc.nuts.env.NUserConfig; +import net.thevpc.nuts.NUser; +import net.thevpc.nuts.NUserConfig; import java.util.ArrayList; import java.util.List; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/DefaultNWorkspaceSecurityManager.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/DefaultNWorkspaceSecurityManager.java index 320dc62df..a42b080b3 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/DefaultNWorkspaceSecurityManager.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/DefaultNWorkspaceSecurityManager.java @@ -29,7 +29,7 @@ import javax.security.auth.callback.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NUser; +import net.thevpc.nuts.NUser; import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; import net.thevpc.nuts.security.NAuthenticationAgent; import net.thevpc.nuts.spi.NComponentScope; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/DefaultNWorkspaceSecurityModel.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/DefaultNWorkspaceSecurityModel.java index 6004c9e29..b291e8d3c 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/DefaultNWorkspaceSecurityModel.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/DefaultNWorkspaceSecurityModel.java @@ -27,17 +27,15 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NUser; -import net.thevpc.nuts.env.NUserConfig; + +import net.thevpc.nuts.NUser; +import net.thevpc.nuts.NUserConfig; import net.thevpc.nuts.runtime.standalone.util.CorePlatformUtils; import net.thevpc.nuts.runtime.standalone.util.CoreStringUtils; +import net.thevpc.nuts.runtime.standalone.workspace.config.*; import net.thevpc.nuts.util.NCoreCollectionUtils; import net.thevpc.nuts.runtime.standalone.workspace.DefaultNWorkspace; import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; -import net.thevpc.nuts.runtime.standalone.workspace.config.ConfigEventType; -import net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNWorkspaceConfigModel; -import net.thevpc.nuts.runtime.standalone.workspace.config.NConfigsExt; -import net.thevpc.nuts.runtime.standalone.workspace.config.NWorkspaceConfigSecurity; import net.thevpc.nuts.runtime.standalone.xtra.digest.NDigestUtils; import net.thevpc.nuts.security.NLoginException; import net.thevpc.nuts.security.NAuthenticationAgent; @@ -71,8 +69,8 @@ public class DefaultNWorkspaceSecurityModel { public DefaultNWorkspaceSecurityModel(final DefaultNWorkspace ws) { this.workspace = ws; - this.agent = new WrapperNAuthenticationAgent(ws, () -> NConfigs.of().getConfigMap(), (x) -> getAuthenticationAgent(x)); - NEvents.of().addWorkspaceListener(new ClearAuthOnWorkspaceChange()); + this.agent = new WrapperNAuthenticationAgent(ws, () -> NWorkspace.get().getConfigMap(), (x) -> getAuthenticationAgent(x)); + workspace.addWorkspaceListener(new ClearAuthOnWorkspaceChange()); } protected NLogOp _LOGOP() { @@ -122,9 +120,9 @@ public boolean switchUnsecureMode(char[] adminPassword) { _LOGOP().level(Level.CONFIG).verb(NLogVerb.WARNING) .log(NMsg.ofC("%s user has no credentials. reset to default", NConstants.Users.ADMIN)); } - NUserConfig u = NConfigsExt.of(NConfigs.of()).getModel().getUser(NConstants.Users.ADMIN); + NUserConfig u = NWorkspaceExt.of(workspace).getConfigModel().getUser(NConstants.Users.ADMIN); u.setCredentials(CoreStringUtils.chrToStr(createCredentials("admin".toCharArray(), false, null))); - NConfigsExt.of(NConfigs.of()).getModel().setUser(u); + NWorkspaceExt.of(workspace).getConfigModel().setUser(u); } char[] credentials = NDigestUtils.evalSHA1(adminPassword); @@ -135,7 +133,7 @@ public boolean switchUnsecureMode(char[] adminPassword) { Arrays.fill(credentials, '\0'); boolean activated = false; if (isSecure()) { - NConfigsExt.of(NConfigs.of()).getModel().setSecure(false); + NWorkspaceExt.of(workspace).getConfigModel().setSecure(false); activated = true; } return activated; @@ -153,7 +151,7 @@ public boolean switchSecureMode(char[] adminPassword) { } Arrays.fill(credentials, '\0'); if (!isSecure()) { - NConfigsExt.of(NConfigs.of()).getModel().setSecure(true); + NWorkspaceExt.of(workspace).getConfigModel().setSecure(true); deactivated = true; } return deactivated; @@ -180,7 +178,7 @@ public void logout() { public NUser findUser(String username) { - NUserConfig security = NConfigsExt.of(NConfigs.of()).getModel().getUser(username); + NUserConfig security = NWorkspaceExt.of(workspace).getConfigModel().getUser(username); Stack inherited = new Stack<>(); if (security != null) { Stack visited = new Stack<>(); @@ -190,7 +188,7 @@ public NUser findUser(String username) { while (!curr.empty()) { String s = curr.pop(); visited.add(s); - NUserConfig ss = NConfigsExt.of(NConfigs.of()).getModel().getUser(s); + NUserConfig ss = NWorkspaceExt.of(workspace).getConfigModel().getUser(s); if (ss != null) { inherited.addAll(ss.getPermissions()); for (String group : ss.getGroups()) { @@ -207,7 +205,7 @@ public NUser findUser(String username) { public List findUsers() { List all = new ArrayList<>(); - for (NUserConfig secu : NConfigsExt.of(NConfigs.of()).getModel().getUsers()) { + for (NUserConfig secu : NWorkspaceExt.of(workspace).getConfigModel().getUsers()) { all.add(findUser(secu.getUser())); } return all; @@ -244,7 +242,7 @@ private NAuthorizations getAuthorizations(String n) { if (aa != null) { return aa; } - NUserConfig s = NConfigsExt.of(NConfigs.of()).getModel().getUser(n); + NUserConfig s = NWorkspaceExt.of(workspace).getConfigModel().getUser(n); if (s != null) { List rr = s.getPermissions(); aa = new NAuthorizations(NCoreCollectionUtils.nonNullList(rr)); @@ -278,7 +276,7 @@ public boolean isAllowed(String permission) { if (ea != null) { return ea; } - NUserConfig uc = NConfigsExt.of(NConfigs.of()).getModel().getUser(n); + NUserConfig uc = NWorkspaceExt.of(workspace).getConfigModel().getUser(n); if (uc != null) { for (String g : uc.getGroups()) { if (!visitedGroups.contains(g)) { @@ -389,17 +387,17 @@ private LoginContext getLoginContext() { public NAuthenticationAgent getAuthenticationAgent(String authenticationAgentId) { authenticationAgentId = NStringUtils.trim(authenticationAgentId); if (NBlankable.isBlank(authenticationAgentId)) { - authenticationAgentId = NConfigsExt.of(NConfigs.of()) - .getModel().getStoredConfigSecurity().getAuthenticationAgent(); + authenticationAgentId = workspace + .getConfigModel().getStoredConfigSecurity().getAuthenticationAgent(); } - NAuthenticationAgent a = NConfigsExt.of(NConfigs.of()) - .getModel().createAuthenticationAgent(authenticationAgentId); + NAuthenticationAgent a = workspace + .getConfigModel().createAuthenticationAgent(authenticationAgentId); return a; } public void setAuthenticationAgent(String authenticationAgentId) { - DefaultNWorkspaceConfigModel cc = NConfigsExt.of(NConfigs.of()).getModel(); + DefaultNWorkspaceConfigModel cc = NWorkspaceExt.of(workspace).getConfigModel(); if (cc.createAuthenticationAgent(authenticationAgentId) == null) { throw new NIllegalArgumentException( @@ -416,7 +414,7 @@ public void setAuthenticationAgent(String authenticationAgentId) { public boolean isSecure() { - return NConfigsExt.of(NConfigs.of()).getModel().getStoredConfigSecurity().isSecure(); + return NWorkspaceExt.of(workspace).getConfigModel().getStoredConfigSecurity().isSecure(); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/NWorkspaceLoginModule.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/NWorkspaceLoginModule.java index 528379cf8..0d2f1519e 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/NWorkspaceLoginModule.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/NWorkspaceLoginModule.java @@ -27,10 +27,10 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NUserConfig; -import net.thevpc.nuts.runtime.standalone.workspace.config.NConfigsExt; +import net.thevpc.nuts.NUserConfig; import net.thevpc.nuts.runtime.standalone.util.CoreStringUtils; import com.sun.security.auth.UserPrincipal; +import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; import javax.security.auth.Subject; import javax.security.auth.callback.*; @@ -97,8 +97,8 @@ public boolean login() throws LoginException { this.login = name; return true; } - NUserConfig registeredUser = NConfigsExt.of(NConfigs.of()) - .getModel() + NUserConfig registeredUser = NWorkspaceExt.of() + .getConfigModel() .getUser(name); if (registeredUser != null) { try { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/WrapperNAuthenticationAgent.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/WrapperNAuthenticationAgent.java index 2ba74f4f4..68edf69d0 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/WrapperNAuthenticationAgent.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/security/WrapperNAuthenticationAgent.java @@ -5,7 +5,8 @@ import java.util.function.Supplier; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NBootManager; + + import net.thevpc.nuts.security.NAuthenticationAgent; import net.thevpc.nuts.util.NMsg; import net.thevpc.nuts.util.NStringUtils; @@ -48,7 +49,7 @@ protected String extractId(char[] a) { String b = new String(a); int x = b.indexOf(':'); if (x <= 0) { - if (NBootManager.of().getBootOptions().getRecover().orElse(false)) { + if (NWorkspace.get().getBootOptions().getRecover().orElse(false)) { //All stored passwords will be reset to 'secret' NSession.get().err().println("```error RECOVER MODE : Password could no be parsed due a change in encryption spec. WIll use new default agent```"); return null; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/session/DefaultNSession.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/session/DefaultNSession.java index 63a9762b4..2215aa554 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/session/DefaultNSession.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/session/DefaultNSession.java @@ -25,8 +25,9 @@ package net.thevpc.nuts.runtime.standalone.session; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NBootManager; -import net.thevpc.nuts.env.NBootOptions; + +import net.thevpc.nuts.NBootOptions; + import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.cmdline.*; import net.thevpc.nuts.elem.NArrayElementBuilder; @@ -103,7 +104,7 @@ public class DefaultNSession implements Cloneable, NSession { public DefaultNSession(NWorkspace workspace) { this.workspace = workspace; - setAll(NBootManager.of().getBootOptions().toWorkspaceOptions()); + setAll(NWorkspace.get().getBootOptions().toWorkspaceOptions()); } public DefaultNSession(NWorkspace workspace, NWorkspaceOptions options) { this.workspace = workspace; @@ -623,7 +624,7 @@ public boolean configureFirst(NCmdLine cmdLine) { @Override public NOptional getTrace() { - return NOptional.ofNamed(trace, "trace").withDefault(() -> NBootManager.of().getBootOptions().getTrace().orElse(true)); + return NOptional.ofNamed(trace, "trace").withDefault(() -> NWorkspace.get().getBootOptions().getTrace().orElse(true)); } @Override @@ -710,14 +711,14 @@ public boolean isPlainOut() { @Override public NOptional getBot() { return NOptional.ofNamed(bot, "bot").withDefault( - () -> NBootManager.of().getBootOptions().getBot().orElse(false) + () -> NWorkspace.get().getBootOptions().getBot().orElse(false) ); } @Override public NOptional getPreviewRepo() { return NOptional.ofNamed(previewRepo, "previewRepo").withDefault( - () -> NBootManager.of().getBootOptions().getPreviewRepo() + () -> NWorkspace.get().getBootOptions().getPreviewRepo() .orElse(NWorkspaceExt.of().getModel().configModel.getStoredConfigMain().isEnablePreviewRepositories()) ); } @@ -781,7 +782,7 @@ public boolean isAsk() { public NOptional getOutputFormat() { return NOptional.ofNamed(outputFormat, "outputFormat") .withDefault(() -> { - NContentType o = NBootManager.of().getBootOptions().getOutputFormat().orNull(); + NContentType o = NWorkspace.get().getBootOptions().getOutputFormat().orNull(); if (o != null) { return o; } @@ -946,7 +947,7 @@ public NSession setAll(NBootOptions options) { public NOptional getFetchStrategy() { return NOptional.ofNamed(fetchStrategy, "fetchStrategy") .withDefault(() -> { - NFetchStrategy wfetchStrategy = NBootManager.of().getBootOptions().getFetchStrategy().orNull(); + NFetchStrategy wfetchStrategy = NWorkspace.get().getBootOptions().getFetchStrategy().orNull(); if (wfetchStrategy != null) { return wfetchStrategy; } @@ -1115,7 +1116,7 @@ public Object getProperty(String key) { public NOptional getConfirm() { return NOptional.ofNamed(confirm, "confirm") .withDefault(() -> { - NConfirmationMode cm = NBootManager.of().getBootOptions().getConfirm().orNull(); + NConfirmationMode cm = NWorkspace.get().getBootOptions().getConfirm().orNull(); if (isBot()) { if (cm == null) { return NConfirmationMode.ERROR; @@ -1225,7 +1226,7 @@ public NWorkspace getWorkspace() { @Override public NOptional getTransitive() { return NOptional.ofNamed(transitive, "transitive") - .withDefault(() -> NBootManager.of().getBootOptions().getTransitive().orElse(true)); + .withDefault(() -> NWorkspace.get().getBootOptions().getTransitive().orElse(true)); } @Override @@ -1242,7 +1243,7 @@ public NSession setTransitive(Boolean value) { @Override public NOptional getCached() { return NOptional.ofNamed(cached, "cached") - .withDefault(() -> NBootManager.of().getBootOptions().getCached().orElse(true)); + .withDefault(() -> NWorkspace.get().getBootOptions().getCached().orElse(true)); } @Override @@ -1259,7 +1260,7 @@ public NSession setCached(Boolean value) { @Override public NOptional getIndexed() { return NOptional.ofNamed(indexed, "indexed") - .withDefault(() -> NBootManager.of().getBootOptions().getIndexed().orElse(false)) + .withDefault(() -> NWorkspace.get().getBootOptions().getIndexed().orElse(false)) ; } @@ -1315,7 +1316,7 @@ public NOptional getGui() { if (gui != null) { return gui; } - return NBootManager.of().getBootOptions().getGui().orElse(false); + return NWorkspace.get().getBootOptions().getGui().orElse(false); }); } @@ -1354,13 +1355,13 @@ public NSession setOutLinePrefix(String outLinePrefix) { @Override public NOptional getDry() { - return NOptional.ofNamed(dry, "dry").withDefault(() -> NBootManager.of().getBootOptions().getDry().orElse(false)); + return NOptional.ofNamed(dry, "dry").withDefault(() -> NWorkspace.get().getBootOptions().getDry().orElse(false)); } @Override public NOptional getShowStacktrace() { return NOptional.ofNamed(showStacktrace, "showStacktrace") - .withDefault(() -> NBootManager.of().getBootOptions().getShowStacktrace().orElse(false)); + .withDefault(() -> NWorkspace.get().getBootOptions().getShowStacktrace().orElse(false)); } @@ -1517,7 +1518,7 @@ public NSession flush() { @Override public NOptional getExecutionType() { return NOptional.ofNamed(executionType, "executionType") - .withDefault(() -> NBootManager.of().getBootOptions().getExecutionType().orElse(NExecutionType.SPAWN)) + .withDefault(() -> NWorkspace.get().getBootOptions().getExecutionType().orElse(NExecutionType.SPAWN)) ; } @@ -1545,7 +1546,7 @@ public NSession setExecutionType(NExecutionType executionType) { @Override public NOptional getDebug() { return NOptional.ofNamed(debug, "debug") - .withDefault(() -> NBootManager.of().getBootOptions().getDebug().orNull() + .withDefault(() -> NWorkspace.get().getBootOptions().getDebug().orNull() ); } @@ -1558,7 +1559,7 @@ public NSession setDebug(String debug) { @Override public NOptional getLocale() { return NOptional.ofNamed(locale, "locale") - .withDefault(() -> NBootManager.of().getBootOptions().getLocale().orNull()); + .withDefault(() -> NWorkspace.get().getBootOptions().getLocale().orNull()); } @Override @@ -1570,7 +1571,7 @@ public NSession setLocale(String locale) { public NOptional getRunAs() { return NOptional.ofNamed(runAs, "runAs") .withDefault(() -> { - NRunAs r = NBootManager.of().getBootOptions().getRunAs().orNull(); + NRunAs r = NWorkspace.get().getBootOptions().getRunAs().orNull(); if (r != null) { return r; } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/shell/AbstractScriptBuilder.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/shell/AbstractScriptBuilder.java index da620ffeb..fa277cced 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/shell/AbstractScriptBuilder.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/shell/AbstractScriptBuilder.java @@ -1,7 +1,7 @@ package net.thevpc.nuts.runtime.standalone.shell; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NShellFamily; +import net.thevpc.nuts.NShellFamily; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.io.NPathPermission; import net.thevpc.nuts.runtime.standalone.io.util.CoreIOUtils; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/shell/NShellHelper.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/shell/NShellHelper.java index bf1d7d9c5..bafbee58a 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/shell/NShellHelper.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/shell/NShellHelper.java @@ -1,7 +1,7 @@ package net.thevpc.nuts.runtime.standalone.shell; -import net.thevpc.nuts.env.NOsFamily; -import net.thevpc.nuts.env.NShellFamily; +import net.thevpc.nuts.NOsFamily; +import net.thevpc.nuts.NShellFamily; import net.thevpc.nuts.runtime.standalone.app.cmdline.NCmdLineShellOptions; public interface NShellHelper { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/shell/ScriptBuilder.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/shell/ScriptBuilder.java index bf5050472..274b53552 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/shell/ScriptBuilder.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/shell/ScriptBuilder.java @@ -1,7 +1,7 @@ package net.thevpc.nuts.runtime.standalone.shell; import net.thevpc.nuts.NId; -import net.thevpc.nuts.env.NShellFamily; +import net.thevpc.nuts.NShellFamily; import net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.util.PathInfo; import net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.ndi.NdiScriptOptions; import net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.ndi.base.BaseSystemNdi; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/DefaultNTextManagerModel.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/DefaultNTextManagerModel.java index 0186190f3..12a6ea32c 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/DefaultNTextManagerModel.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/DefaultNTextManagerModel.java @@ -25,9 +25,9 @@ package net.thevpc.nuts.runtime.standalone.text; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NBootOptions; -import net.thevpc.nuts.env.NEnvs; -import net.thevpc.nuts.env.NShellFamily; +import net.thevpc.nuts.NBootOptions; + +import net.thevpc.nuts.NShellFamily; import net.thevpc.nuts.ext.NExtensions; import net.thevpc.nuts.io.NIOException; import net.thevpc.nuts.runtime.standalone.elem.DefaultNElementFactoryService; @@ -48,7 +48,7 @@ import net.thevpc.nuts.text.NTextStyle; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.util.NMsg; -import net.thevpc.nuts.env.NOsFamily; +import net.thevpc.nuts.NOsFamily; import net.thevpc.nuts.util.NStringUtils; import java.io.BufferedReader; @@ -121,7 +121,7 @@ public NTextFormatTheme createTheme(String y) { if ("default".equals(y)) { //default always refers to this implementation if (defaultTheme == null) { - if (NEnvs.of().getOsFamily() == NOsFamily.WINDOWS) { + if (NWorkspace.get().getOsFamily() == NOsFamily.WINDOWS) { //dark blue and red are very ugly under windows, replace them with green tones ! defaultTheme = new NTextFormatThemeWrapper(new NTextFormatPropertiesTheme("grass", null, workspace)); } else { @@ -192,7 +192,7 @@ public NCodeHighlighter getCodeHighlighter(String highlighterId) { } } if ("system".equals(lc)) { - NShellFamily shellFamily = NEnvs.of().getShellFamily(); + NShellFamily shellFamily = NWorkspace.get().getShellFamily(); h = getCodeHighlighter(shellFamily.id()); _cachedHighlighters.put(lc, h); return h; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/DefaultNTextNodeBuilder.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/DefaultNTextNodeBuilder.java index 367011a06..d9dc36bef 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/DefaultNTextNodeBuilder.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/DefaultNTextNodeBuilder.java @@ -99,7 +99,6 @@ public NTextBuilder append(Object text, NTextStyle style) { @Override public NTextBuilder append(Object text, NTextStyles styles) { if (text != null) { - NSession session = workspace.currentSession(); if (styles.size() == 0) { append(NText.of(text)); } else { @@ -207,7 +206,6 @@ public NText subChildren(int from, int to) { } public NText substring(int from, int to) { - NSession session = workspace.currentSession(); if (to <= from) { return NText.ofPlain(""); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/DefaultNTexts.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/DefaultNTexts.java index dcc648e19..95dac3d8e 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/DefaultNTexts.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/DefaultNTexts.java @@ -1333,7 +1333,6 @@ public NOptional> createTextFormat(String type, String patter if (expectedType.isPrimitive()) { expectedType = (Class) NReflectUtils.toBoxedType(expectedType).get(); } - NSession session = workspace.currentSession(); switch (type.toLowerCase().trim()) { case "duration": { DefaultNDurationFormat2 d = new DefaultNDurationFormat2(workspace, pattern); @@ -1433,7 +1432,7 @@ public NText toText(Number object) { (NTextFormat) new NTextFormat() { @Override public NText toText(Number object) { - return d.format(object.doubleValue(), session); + return d.format(object.doubleValue()); } } ); @@ -1444,13 +1443,13 @@ public NText toText(Number object) { case "bytes": case "size": { String p = NStringUtils.trim(pattern); - BytesSizeFormat d = new BytesSizeFormat(null, session); + BytesSizeFormat d = new BytesSizeFormat(null); if (Number.class.isAssignableFrom(expectedType)) { return NOptional.of( (NTextFormat) new NTextFormat() { @Override public NText toText(Number object) { - return d.formatText(object.longValue(), session); + return d.formatText(object.longValue()); } } ); @@ -1467,7 +1466,7 @@ public NText toText(Number object) { (NTextFormat) new NTextFormat() { @Override public NText toText(Number object) { - return d.format(object.longValue(), session); + return d.format(object.longValue()); } } ); @@ -1482,7 +1481,7 @@ public NText toText(Number object) { (NTextFormat) new NTextFormat() { @Override public NText toText(Number object) { - return d.format(object.doubleValue(), session); + return d.format(object.doubleValue()); } } ); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/BashCodeHighlighter.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/BashCodeHighlighter.java index 80c7e9300..5177286d3 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/BashCodeHighlighter.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/BashCodeHighlighter.java @@ -2,7 +2,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NShellFamily; +import net.thevpc.nuts.NShellFamily; import net.thevpc.nuts.io.NIOException; import net.thevpc.nuts.runtime.standalone.xtra.expr.StringReaderExt; import net.thevpc.nuts.runtime.standalone.text.parser.DefaultNTextPlain; @@ -68,7 +68,7 @@ public NText tokenToText(String text, String nodeType, NTexts txt) { return txt.ofPlain(text); } - private NText[] parseCmdLine_readSimpleQuotes(StringReaderExt ar, NTexts txt, NSession session) { + private NText[] parseCmdLine_readSimpleQuotes(StringReaderExt ar, NTexts txt) { StringBuilder sb = new StringBuilder(); sb.append(ar.readChar()); //quote! List ret = new ArrayList<>(); @@ -100,7 +100,7 @@ private NText[] parseCmdLine_readSimpleQuotes(StringReaderExt ar, NTexts txt, NS return ret.toArray(new NText[0]); } - private NText[] parseCmdLine_readWord(StringReaderExt ar, NTexts txt, NSession session) { + private NText[] parseCmdLine_readWord(StringReaderExt ar, NTexts txt) { StringBuilder sb = new StringBuilder(); List ret = new ArrayList<>(); boolean inLoop = true; @@ -113,7 +113,7 @@ private NText[] parseCmdLine_readWord(StringReaderExt ar, NTexts txt, NSession s ret.add(txt.ofPlain(sb.toString())); sb.setLength(0); } - ret.addAll(Arrays.asList(parseCmdLine_readAntiSlash(ar, session))); + ret.addAll(Arrays.asList(parseCmdLine_readAntiSlash(ar))); break; } case ';': { @@ -172,7 +172,7 @@ private NText[] parseCmdLine_readWord(StringReaderExt ar, NTexts txt, NSession s return ret.toArray(new NText[0]); } - private static NText[] parseCmdLine_readAntiSlash(StringReaderExt ar, NSession session) { + private static NText[] parseCmdLine_readAntiSlash(StringReaderExt ar) { StringBuilder sb2 = new StringBuilder(); sb2.append(ar.readChar()); if (ar.hasNext()) { @@ -182,18 +182,18 @@ private static NText[] parseCmdLine_readAntiSlash(StringReaderExt ar, NSession s return new NText[]{factory.ofStyled(sb2.toString(), NTextStyle.separator())}; } - private NText[] parseCmdLine_readDollar(StringReaderExt ar, NTexts txt, NSession session) { + private NText[] parseCmdLine_readDollar(StringReaderExt ar, NTexts txt) { if (ar.peekChars("$((")) { - return parseCmdLine_readDollarPar2(ar, session, txt); + return parseCmdLine_readDollarPar2(ar, txt); } StringBuilder sb2 = new StringBuilder(); if (ar.hasNext(1)) { switch (ar.peekChar(1)) { case '(': { - return parseCmdLine_readDollarPar2(ar, session, txt); + return parseCmdLine_readDollarPar2(ar, txt); } case '{': { - return parseCmdLine_readDollarCurlyBrackets(ar, txt, session); + return parseCmdLine_readDollarCurlyBrackets(ar, txt); } case '*': case '?': @@ -232,7 +232,7 @@ private NText[] parseCmdLine_readDollar(StringReaderExt ar, NTexts txt, NSession txt.ofStyled("$", NTextStyle.separator()),}; } - private NText[] parseCmdLine_readDoubleQuotes(StringReaderExt ar, NTexts txt, NSession session) { + private NText[] parseCmdLine_readDoubleQuotes(StringReaderExt ar, NTexts txt) { List ret = new ArrayList<>(); StringBuilder sb = new StringBuilder(); @@ -244,13 +244,13 @@ private NText[] parseCmdLine_readDoubleQuotes(StringReaderExt ar, NTexts txt, NS ret.add(txt.ofStyled(sb.toString(), NTextStyle.string())); sb.setLength(0); } - ret.addAll(Arrays.asList(parseCmdLine_readAntiSlash(ar, session))); + ret.addAll(Arrays.asList(parseCmdLine_readAntiSlash(ar))); } else if (c == '$') { if (sb.length() > 0) { ret.add(txt.ofStyled(sb.toString(), NTextStyle.string())); sb.setLength(0); } - ret.addAll(Arrays.asList(parseCmdLine_readDollar(ar, txt, session))); + ret.addAll(Arrays.asList(parseCmdLine_readDollar(ar, txt))); } else if (c == '\"') { if (sb.length() > 0) { ret.add(txt.ofStyled(sb.toString(), NTextStyle.string())); @@ -345,7 +345,7 @@ private static int indexOfFirstWord(List all, int from) { return -1; } - private NText[] parseCmdLine_readAntiQuotes(StringReaderExt ar, NTexts txt, NSession session) { + private NText[] parseCmdLine_readAntiQuotes(StringReaderExt ar, NTexts txt) { List all = new ArrayList<>(); all.add(txt.ofStyled(String.valueOf(ar.readChar()), NTextStyle.separator())); boolean inLoop = true; @@ -360,14 +360,14 @@ private NText[] parseCmdLine_readAntiQuotes(StringReaderExt ar, NTexts txt, NSes break; } default: { - wasSpace = parseCmdLineStep(ar, all, 1, wasSpace, txt, session); + wasSpace = parseCmdLineStep(ar, all, 1, wasSpace, txt); } } } return all.toArray(new NText[0]); } - private NText[] parseCmdLine_readDollarPar(NWorkspace ws, StringReaderExt ar, NTexts txt, NSession session) { + private NText[] parseCmdLine_readDollarPar(NWorkspace ws, StringReaderExt ar, NTexts txt) { List all = new ArrayList<>(); all.add(txt.ofStyled(String.valueOf(ar.readChar()) + ar.readChar(), NTextStyle.separator())); boolean inLoop = true; @@ -381,14 +381,14 @@ private NText[] parseCmdLine_readDollarPar(NWorkspace ws, StringReaderExt ar, NT break; } default: { - wasSpace = parseCmdLineStep(ar, all, 2, wasSpace, txt, session); + wasSpace = parseCmdLineStep(ar, all, 2, wasSpace, txt); } } } return all.toArray(new NText[0]); } - private NText[] parseCmdLine_readDollarPar2(StringReaderExt ar, NSession session, NTexts txt) { + private NText[] parseCmdLine_readDollarPar2(StringReaderExt ar, NTexts txt) { List all = new ArrayList<>(); all.add(txt.ofStyled(String.valueOf(ar.readChar()) + ar.readChar() + ar.readChar(), NTextStyle.separator())); boolean inLoop = true; @@ -411,19 +411,19 @@ private NText[] parseCmdLine_readDollarPar2(StringReaderExt ar, NSession session all.add(txt.ofStyled(String.valueOf(ar.nextChars(2)), NTextStyle.separator())); inLoop = false; } else { - wasSpace = parseCmdLineStep(ar, all, 2, wasSpace, txt, session); + wasSpace = parseCmdLineStep(ar, all, 2, wasSpace, txt); } break; } default: { - wasSpace = parseCmdLineStep(ar, all, 2, wasSpace, txt, session); + wasSpace = parseCmdLineStep(ar, all, 2, wasSpace, txt); } } } return all.toArray(new NText[0]); } - private NText[] parseCmdLine_readDollarCurlyBrackets(StringReaderExt ar, NTexts txt, NSession session) { + private NText[] parseCmdLine_readDollarCurlyBrackets(StringReaderExt ar, NTexts txt) { List all = new ArrayList<>(); all.add(txt.ofStyled(String.valueOf(ar.readChar()) + ar.readChar(), NTextStyle.separator())); boolean inLoop = true; @@ -440,7 +440,7 @@ private NText[] parseCmdLine_readDollarCurlyBrackets(StringReaderExt ar, NTexts } default: { startIndex = all.size(); - wasSpace = parseCmdLineStep(ar, all, -1, wasSpace, txt, session); + wasSpace = parseCmdLineStep(ar, all, -1, wasSpace, txt); if (expectedName) { expectedName = false; if (all.size() > startIndex) { @@ -457,7 +457,7 @@ private NText[] parseCmdLine_readDollarCurlyBrackets(StringReaderExt ar, NTexts return all.toArray(new NText[0]); } - private NText[] parseCmdLine_readPar2(StringReaderExt ar, NTexts txt, NSession session) { + private NText[] parseCmdLine_readPar2(StringReaderExt ar, NTexts txt) { List all = new ArrayList<>(); all.add(txt.ofStyled(String.valueOf(ar.readChar()) + ar.readChar(), NTextStyle.separator())); boolean inLoop = true; @@ -470,12 +470,12 @@ private NText[] parseCmdLine_readPar2(StringReaderExt ar, NTexts txt, NSession s all.add(txt.ofStyled(String.valueOf(ar.nextChars(2)), NTextStyle.separator())); inLoop = false; } else { - wasSpace = parseCmdLineStep(ar, all, 2, wasSpace, txt, session); + wasSpace = parseCmdLineStep(ar, all, 2, wasSpace, txt); } break; } default: { - wasSpace = parseCmdLineStep(ar, all, 2, wasSpace, txt, session); + wasSpace = parseCmdLineStep(ar, all, 2, wasSpace, txt); } } } @@ -489,30 +489,30 @@ private NText[] parseCmdLine_readPar2(StringReaderExt ar, NTexts txt, NSession s * @param all all * @param startIndex startIndex * @param wasSpace wasSpace - * @param txt txt + * @param txt txt * @return is space */ - private boolean parseCmdLineStep(StringReaderExt ar, List all, int startIndex, boolean wasSpace, NTexts txt, NSession session) { + private boolean parseCmdLineStep(StringReaderExt ar, List all, int startIndex, boolean wasSpace, NTexts txt) { char c = ar.peekChar(); if (c <= 32) { - all.addAll(Arrays.asList(StringReaderExtUtils.readSpaces(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readSpaces(ar))); return true; } switch (c) { case '\'': { - all.addAll(Arrays.asList(parseCmdLine_readSimpleQuotes(ar, txt, session))); + all.addAll(Arrays.asList(parseCmdLine_readSimpleQuotes(ar, txt))); break; } case '`': { - all.addAll(Arrays.asList(parseCmdLine_readAntiQuotes(ar, txt, session))); + all.addAll(Arrays.asList(parseCmdLine_readAntiQuotes(ar, txt))); break; } case '"': { - all.addAll(Arrays.asList(parseCmdLine_readDoubleQuotes(ar, txt, session))); + all.addAll(Arrays.asList(parseCmdLine_readDoubleQuotes(ar, txt))); break; } case '$': { - all.addAll(Arrays.asList(parseCmdLine_readDollar(ar, txt, session))); + all.addAll(Arrays.asList(parseCmdLine_readDollar(ar, txt))); break; } case ';': { @@ -598,7 +598,7 @@ private boolean parseCmdLineStep(StringReaderExt ar, List all, int startI } case '(': { if (ar.peekChars("((")) { - all.addAll(Arrays.asList(parseCmdLine_readPar2(ar, txt, session))); + all.addAll(Arrays.asList(parseCmdLine_readPar2(ar, txt))); } else { all.add(txt.ofStyled(String.valueOf(ar.readChar()), NTextStyle.separator())); } @@ -641,7 +641,7 @@ private boolean parseCmdLineStep(StringReaderExt ar, List all, int startI default: { if (startIndex >= 0) { boolean first = all.size() == startIndex; - all.addAll(Arrays.asList(parseCmdLine_readWord(ar, txt, session))); + all.addAll(Arrays.asList(parseCmdLine_readWord(ar, txt))); if (first) { int i = indexOfFirstWord(all, startIndex); if (i >= 0) { @@ -649,19 +649,19 @@ private boolean parseCmdLineStep(StringReaderExt ar, List all, int startI } } } else { - all.addAll(Arrays.asList(parseCmdLine_readWord(ar, txt, session))); + all.addAll(Arrays.asList(parseCmdLine_readWord(ar, txt))); } } } return false; } - private NText[] parseCmdLine(String commandLineString, NTexts txt, NSession session) { + private NText[] parseCmdLine(String commandLineString, NTexts txt) { StringReaderExt ar = new StringReaderExt(commandLineString); List all = new ArrayList<>(); boolean wasSpace = true; while (ar.hasNext()) { - wasSpace = parseCmdLineStep(ar, all, 0, wasSpace, txt, session); + wasSpace = parseCmdLineStep(ar, all, 0, wasSpace, txt); } return all.toArray(new NText[0]); } @@ -712,7 +712,6 @@ private static boolean isSynopsisWord(String s) { @Override public NText stringToText(String text, NTexts txt) { - NSession session=workspace.currentSession(); List all = new ArrayList<>(); BufferedReader reader = new BufferedReader(new StringReader(text)); String line = null; @@ -730,12 +729,12 @@ public NText stringToText(String text, NTexts txt) { } else { all.add(txt.ofPlain("\n")); } - all.add(commandToNode(line, txt, session)); + all.add(commandToNode(line, txt)); } return txt.ofList(all).simplify(); } - public NText next(StringReaderExt reader, boolean exitOnClosedCurlBrace, boolean exitOnClosedPar, boolean exitOnDblQuote, boolean exitOnAntiQuote, NTexts txt, NSession session) { + public NText next(StringReaderExt reader, boolean exitOnClosedCurlBrace, boolean exitOnClosedPar, boolean exitOnDblQuote, boolean exitOnAntiQuote, NTexts txt) { boolean lineStart = true; List all = new ArrayList<>(); NTexts factory = NTexts.of(); @@ -883,7 +882,7 @@ public NText next(StringReaderExt reader, boolean exitOnClosedCurlBrace, boolean } case '\"': { lineStart = false; - all.add(nextDoubleQuotes(reader, session, txt)); + all.add(nextDoubleQuotes(reader, txt)); break; } case '`': { @@ -893,7 +892,7 @@ public NText next(StringReaderExt reader, boolean exitOnClosedCurlBrace, boolean } else { List a = new ArrayList<>(); a.add(factory.ofStyled(reader.nextChars(1), NTextStyle.string())); - a.add(next(reader, false, false, false, true, txt, session)); + a.add(next(reader, false, false, false, true, txt)); if (reader.hasNext() && reader.peekChar() == '`') { a.add(factory.ofStyled(reader.nextChars(1), NTextStyle.string())); } else { @@ -1087,7 +1086,7 @@ public NText next(StringReaderExt reader, boolean exitOnClosedCurlBrace, boolean return factory.ofList(all).simplify(); } - private NText nextDollar(StringReaderExt reader, NTexts txt, NSession session) { + private NText nextDollar(StringReaderExt reader, NTexts txt) { NTexts factory = NTexts.of(); if (reader.isAvailable(2)) { char c = reader.peekChar(1); @@ -1095,7 +1094,7 @@ private NText nextDollar(StringReaderExt reader, NTexts txt, NSession session) { case '(': { List a = new ArrayList<>(); a.add(factory.ofStyled(reader.nextChars(1), NTextStyle.separator())); - a.add(next(reader, false, true, false, false, txt, session)); + a.add(next(reader, false, true, false, false, txt)); if (reader.hasNext() && reader.peekChar() == ')') { a.add(factory.ofStyled(reader.nextChars(1), NTextStyle.separator())); } @@ -1104,7 +1103,7 @@ private NText nextDollar(StringReaderExt reader, NTexts txt, NSession session) { case '{': { List a = new ArrayList<>(); a.add(factory.ofStyled(reader.nextChars(1), NTextStyle.separator())); - a.add(next(reader, true, false, false, false, txt, session)); + a.add(next(reader, true, false, false, false, txt)); if (reader.hasNext() && reader.peekChar() == ')') { a.add(factory.ofStyled(reader.nextChars(1), NTextStyle.separator())); } @@ -1145,7 +1144,7 @@ private NText nextDollar(StringReaderExt reader, NTexts txt, NSession session) { } } - public NText nextDoubleQuotes(StringReaderExt reader, NSession session, NTexts txt) { + public NText nextDoubleQuotes(StringReaderExt reader, NTexts txt) { List all = new ArrayList<>(); boolean exit = false; StringBuilder sb = new StringBuilder(); @@ -1166,7 +1165,7 @@ public NText nextDoubleQuotes(StringReaderExt reader, NSession session, NTexts t all.add(txt.ofStyled(sb.toString(), NTextStyle.string())); sb.setLength(0); } - all.add(nextDollar(reader, txt, session)); + all.add(nextDollar(reader, txt)); } case '`': { if (sb.length() > 0) { @@ -1175,7 +1174,7 @@ public NText nextDoubleQuotes(StringReaderExt reader, NSession session, NTexts t } List a = new ArrayList<>(); a.add(txt.ofStyled(reader.nextChars(1), NTextStyle.string())); - a.add(next(reader, false, false, false, true, txt, session)); + a.add(next(reader, false, false, false, true, txt)); if (reader.hasNext() && reader.peekChar() == '`') { a.add(txt.ofStyled(reader.nextChars(1), NTextStyle.string())); } else { @@ -1196,8 +1195,8 @@ public NText nextDoubleQuotes(StringReaderExt reader, NSession session, NTexts t return txt.ofList(all).simplify(); } - public NText commandToNode(String text, NTexts txt, NSession session) { - return txt.ofList(parseCmdLine(text, txt, session)); + public NText commandToNode(String text, NTexts txt) { + return txt.ofList(parseCmdLine(text, txt)); } } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/CSharpCodeHighlighter.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/CSharpCodeHighlighter.java index b184a565d..8ce53423e 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/CSharpCodeHighlighter.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/CSharpCodeHighlighter.java @@ -52,7 +52,6 @@ public int getSupportLevel(NSupportLevelContext context) { public NText stringToText(String text, NTexts txt) { List all = new ArrayList<>(); StringReaderExt ar = new StringReaderExt(text); - NSession session=workspace.currentSession(); while (ar.hasNext()) { switch (ar.peekChar()) { case '{': @@ -76,11 +75,11 @@ public NText stringToText(String text, NTexts txt) { break; } case '\'': { - all.addAll(Arrays.asList(StringReaderExtUtils.readJSSimpleQuotes(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readJSSimpleQuotes(ar))); break; } case '"': { - all.addAll(Arrays.asList(StringReaderExtUtils.readJSDoubleQuotesString(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readJSDoubleQuotesString(ar))); break; } case '0': @@ -93,12 +92,12 @@ public NText stringToText(String text, NTexts txt) { case '7': case '8': case '9': { - all.addAll(Arrays.asList(StringReaderExtUtils.readNumber(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readNumber(ar))); break; } case '.': case '-': { - NText[] d = StringReaderExtUtils.readNumber(session, ar); + NText[] d = StringReaderExtUtils.readNumber(ar); if (d != null) { all.addAll(Arrays.asList(d)); } else { @@ -108,9 +107,9 @@ public NText stringToText(String text, NTexts txt) { } case '/': { if (ar.peekChars("//")) { - all.addAll(Arrays.asList(StringReaderExtUtils.readSlashSlashComments(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readSlashSlashComments(ar))); } else if (ar.peekChars("/*")) { - all.addAll(Arrays.asList(StringReaderExtUtils.readSlashStarComments(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readSlashStarComments(ar))); } else { all.add(txt.ofStyled(String.valueOf(ar.readChar()), NTextStyle.separator())); } @@ -118,9 +117,9 @@ public NText stringToText(String text, NTexts txt) { } default: { if (Character.isWhitespace(ar.peekChar())) { - all.addAll(Arrays.asList(StringReaderExtUtils.readSpaces(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readSpaces(ar))); } else { - NText[] d = StringReaderExtUtils.readJSIdentifier(session, ar); + NText[] d = StringReaderExtUtils.readJSIdentifier(ar); if (d != null) { if (d.length == 1 && d[0].getType() == NTextType.PLAIN) { String txt2 = ((NTextPlain) d[0]).getText(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/CppCodeHighlighter.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/CppCodeHighlighter.java index 6206b4dda..ba7f29b0b 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/CppCodeHighlighter.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/CppCodeHighlighter.java @@ -57,7 +57,6 @@ public int getSupportLevel(NSupportLevelContext context) { public NText stringToText(String text, NTexts txt) { List all = new ArrayList<>(); StringReaderExt ar = new StringReaderExt(text); - NSession session=workspace.currentSession(); while (ar.hasNext()) { switch (ar.peekChar()) { case '{': @@ -81,11 +80,11 @@ public NText stringToText(String text, NTexts txt) { break; } case '\'': { - all.addAll(Arrays.asList(StringReaderExtUtils.readJSSimpleQuotes(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readJSSimpleQuotes(ar))); break; } case '"': { - all.addAll(Arrays.asList(StringReaderExtUtils.readJSDoubleQuotesString(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readJSDoubleQuotesString(ar))); break; } case '0': @@ -98,12 +97,12 @@ public NText stringToText(String text, NTexts txt) { case '7': case '8': case '9': { - all.addAll(Arrays.asList(StringReaderExtUtils.readNumber(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readNumber(ar))); break; } case '.': case '-': { - NText[] d = StringReaderExtUtils.readNumber(session, ar); + NText[] d = StringReaderExtUtils.readNumber(ar); if (d != null) { all.addAll(Arrays.asList(d)); } else { @@ -113,9 +112,9 @@ public NText stringToText(String text, NTexts txt) { } case '/': { if (ar.peekChars("//")) { - all.addAll(Arrays.asList(StringReaderExtUtils.readSlashSlashComments(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readSlashSlashComments(ar))); } else if (ar.peekChars("/*")) { - all.addAll(Arrays.asList(StringReaderExtUtils.readSlashStarComments(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readSlashStarComments(ar))); } else { all.add(txt.ofStyled(String.valueOf(ar.readChar()), NTextStyle.separator())); } @@ -123,9 +122,9 @@ public NText stringToText(String text, NTexts txt) { } default: { if (Character.isWhitespace(ar.peekChar())) { - all.addAll(Arrays.asList(StringReaderExtUtils.readSpaces(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readSpaces(ar))); } else { - NText[] d = StringReaderExtUtils.readJSIdentifier(session, ar); + NText[] d = StringReaderExtUtils.readJSIdentifier(ar); if (d != null) { if (d.length == 1 && d[0].getType() == NTextType.PLAIN) { String txt2 = ((NTextPlain) d[0]).getText(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/FishCodeHighlighter.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/FishCodeHighlighter.java index e521590b2..13aac1bed 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/FishCodeHighlighter.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/FishCodeHighlighter.java @@ -2,7 +2,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NShellFamily; +import net.thevpc.nuts.NShellFamily; import net.thevpc.nuts.io.NIOException; import net.thevpc.nuts.runtime.standalone.xtra.expr.StringReaderExt; import net.thevpc.nuts.runtime.standalone.text.parser.DefaultNTextPlain; @@ -165,7 +165,6 @@ private NText[] parseCmdLine_readAntiSlash(StringReaderExt ar) { if (ar.hasNext()) { sb2.append(ar.readChar()); } - NSession session = workspace.currentSession(); NTexts txt = NTexts.of(); return new NText[]{txt.ofStyled(sb2.toString(), NTextStyle.separator())}; } @@ -480,10 +479,9 @@ private NText[] parseCmdLine_readPar2(StringReaderExt ar, NTexts txt) { * @return is space */ private boolean parseCmdLineStep(StringReaderExt ar, List all, int startIndex, boolean wasSpace, NTexts txt) { - NSession session = workspace.currentSession(); char c = ar.peekChar(); if (c <= 32) { - all.addAll(Arrays.asList(StringReaderExtUtils.readSpaces(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readSpaces(ar))); return true; } switch (c) { @@ -704,7 +702,6 @@ public NText stringToText(String text, NTexts txt) { BufferedReader reader = new BufferedReader(new StringReader(text)); String line = null; boolean first = true; - NSession session = workspace.currentSession(); while (true) { try { if ((line = reader.readLine()) == null) { @@ -726,7 +723,6 @@ public NText stringToText(String text, NTexts txt) { public NText next(StringReaderExt reader, boolean exitOnClosedCurlBrace, boolean exitOnClosedPar, boolean exitOnDblQuote, boolean exitOnAntiQuote) { boolean lineStart = true; List all = new ArrayList<>(); - NSession session = workspace.currentSession(); NTexts txt = NTexts.of(); boolean exit = false; while (!exit && reader.hasNext()) { @@ -1077,7 +1073,6 @@ public NText next(StringReaderExt reader, boolean exitOnClosedCurlBrace, boolean } private NText nextDollar(StringReaderExt reader) { - NSession session = workspace.currentSession(); NTexts txt = NTexts.of(); if (reader.isAvailable(2)) { char c = reader.peekChar(1); @@ -1137,7 +1132,6 @@ private NText nextDollar(StringReaderExt reader) { public NText nextDoubleQuotes(StringReaderExt reader) { List all = new ArrayList<>(); - NSession session = workspace.currentSession(); NTexts txt = NTexts.of(); boolean exit = false; StringBuilder sb = new StringBuilder(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/HadraCodeHighlighter.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/HadraCodeHighlighter.java index d2662eee9..e84c73007 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/HadraCodeHighlighter.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/HadraCodeHighlighter.java @@ -64,7 +64,6 @@ public NText tokenToText(String text, String nodeType, NTexts txt) { @Override public NText stringToText(String text, NTexts txt) { - NSession session=workspace.currentSession(); List all = new ArrayList<>(); StringReaderExt ar = new StringReaderExt(text); while (ar.hasNext()) { @@ -90,11 +89,11 @@ public NText stringToText(String text, NTexts txt) { break; } case '\'': { - all.addAll(Arrays.asList(StringReaderExtUtils.readJSSimpleQuotes(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readJSSimpleQuotes(ar))); break; } case '"': { - all.addAll(Arrays.asList(StringReaderExtUtils.readJSDoubleQuotesString(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readJSDoubleQuotesString(ar))); break; } case '0': @@ -107,12 +106,12 @@ public NText stringToText(String text, NTexts txt) { case '7': case '8': case '9': { - all.addAll(Arrays.asList(StringReaderExtUtils.readNumber(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readNumber(ar))); break; } case '.': case '-': { - NText[] d = StringReaderExtUtils.readNumber(session, ar); + NText[] d = StringReaderExtUtils.readNumber(ar); if (d != null) { all.addAll(Arrays.asList(d)); } else { @@ -122,9 +121,9 @@ public NText stringToText(String text, NTexts txt) { } case '/': { if (ar.peekChars("//")) { - all.addAll(Arrays.asList(StringReaderExtUtils.readSlashSlashComments(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readSlashSlashComments(ar))); } else if (ar.peekChars("/*")) { - all.addAll(Arrays.asList(StringReaderExtUtils.readSlashStarComments(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readSlashStarComments(ar))); } else { all.add(txt.ofStyled(String.valueOf(ar.readChar()), NTextStyle.separator())); } @@ -132,9 +131,9 @@ public NText stringToText(String text, NTexts txt) { } default: { if (Character.isWhitespace(ar.peekChar())) { - all.addAll(Arrays.asList(StringReaderExtUtils.readSpaces(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readSpaces(ar))); } else { - NText[] d = StringReaderExtUtils.readJSIdentifier(session, ar); + NText[] d = StringReaderExtUtils.readJSIdentifier(ar); if (d != null) { if (d.length == 1 && d[0].getType() == NTextType.PLAIN) { String txt2 = ((NTextPlain) d[0]).getText(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/JavaCodeHighlighter.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/JavaCodeHighlighter.java index a6960e33f..3863d215a 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/JavaCodeHighlighter.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/JavaCodeHighlighter.java @@ -50,7 +50,6 @@ public int getSupportLevel(NSupportLevelContext context) { @Override public NText stringToText(String text, NTexts txt) { - NSession session=workspace.currentSession(); List all = new ArrayList<>(); StringReaderExt ar = new StringReaderExt(text); while (ar.hasNext()) { @@ -76,11 +75,11 @@ public NText stringToText(String text, NTexts txt) { break; } case '\'': { - all.addAll(Arrays.asList(StringReaderExtUtils.readJSSimpleQuotes(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readJSSimpleQuotes(ar))); break; } case '"': { - all.addAll(Arrays.asList(StringReaderExtUtils.readJSDoubleQuotesString(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readJSDoubleQuotesString(ar))); break; } case '0': @@ -93,12 +92,12 @@ public NText stringToText(String text, NTexts txt) { case '7': case '8': case '9': { - all.addAll(Arrays.asList(StringReaderExtUtils.readNumber(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readNumber(ar))); break; } case '.': case '-': { - NText[] d = StringReaderExtUtils.readNumber(session, ar); + NText[] d = StringReaderExtUtils.readNumber(ar); if (d != null) { all.addAll(Arrays.asList(d)); } else { @@ -108,9 +107,9 @@ public NText stringToText(String text, NTexts txt) { } case '/': { if (ar.peekChars("//")) { - all.addAll(Arrays.asList(StringReaderExtUtils.readSlashSlashComments(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readSlashSlashComments(ar))); } else if (ar.peekChars("/*")) { - all.addAll(Arrays.asList(StringReaderExtUtils.readSlashStarComments(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readSlashStarComments(ar))); } else { all.add(txt.ofStyled(String.valueOf(ar.readChar()), NTextStyle.separator())); } @@ -118,9 +117,9 @@ public NText stringToText(String text, NTexts txt) { } default: { if (Character.isWhitespace(ar.peekChar())) { - all.addAll(Arrays.asList(StringReaderExtUtils.readSpaces(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readSpaces(ar))); } else { - NText[] d = StringReaderExtUtils.readJSIdentifier(session, ar); + NText[] d = StringReaderExtUtils.readJSIdentifier(ar); if (d != null) { if (d.length == 1 && d[0].getType() == NTextType.PLAIN) { String txt2 = ((NTextPlain) d[0]).getText(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/JsonCodeHighlighter.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/JsonCodeHighlighter.java index 46537698a..0648acffa 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/JsonCodeHighlighter.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/JsonCodeHighlighter.java @@ -48,7 +48,6 @@ public int getSupportLevel(NSupportLevelContext context) { @Override public NText stringToText(String text, NTexts txt) { - NSession session=workspace.currentSession(); List all = new ArrayList<>(); StringReaderExt ar = new StringReaderExt(text); while (ar.hasNext()) { @@ -62,11 +61,11 @@ public NText stringToText(String text, NTexts txt) { break; } case '\'': { - all.addAll(Arrays.asList(StringReaderExtUtils.readJSSimpleQuotes(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readJSSimpleQuotes(ar))); break; } case '"': { - all.addAll(Arrays.asList(StringReaderExtUtils.readJSDoubleQuotesString(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readJSDoubleQuotesString(ar))); break; } case '0': @@ -79,12 +78,12 @@ public NText stringToText(String text, NTexts txt) { case '7': case '8': case '9': { - all.addAll(Arrays.asList(StringReaderExtUtils.readNumber(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readNumber(ar))); break; } case '.': case '-':{ - NText[] d = StringReaderExtUtils.readNumber(session, ar); + NText[] d = StringReaderExtUtils.readNumber(ar); if(d!=null) { all.addAll(Arrays.asList(d)); }else{ @@ -94,9 +93,9 @@ public NText stringToText(String text, NTexts txt) { } case '/':{ if(ar.peekChars("//")) { - all.addAll(Arrays.asList(StringReaderExtUtils.readSlashSlashComments(session,ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readSlashSlashComments(ar))); }else if(ar.peekChars("/*")){ - all.addAll(Arrays.asList(StringReaderExtUtils.readSlashStarComments(session,ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readSlashStarComments(ar))); }else{ all.add(txt.ofStyled(String.valueOf(ar.readChar()), NTextStyle.separator())); } @@ -104,9 +103,9 @@ public NText stringToText(String text, NTexts txt) { } default: { if(Character.isWhitespace(ar.peekChar())){ - all.addAll(Arrays.asList(StringReaderExtUtils.readSpaces(session,ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readSpaces(ar))); }else { - NText[] d = StringReaderExtUtils.readJSIdentifier(session, ar); + NText[] d = StringReaderExtUtils.readJSIdentifier(ar); if (d != null) { if (d.length == 1 && d[0].getType() == NTextType.PLAIN) { String txt2 = ((NTextPlain) d[0]).getText(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/SqlCodeHighlighter.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/SqlCodeHighlighter.java index 6543bd32a..3e67f66a0 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/SqlCodeHighlighter.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/SqlCodeHighlighter.java @@ -51,7 +51,6 @@ public int getSupportLevel(NSupportLevelContext context) { @Override public NText stringToText(String text, NTexts txt) { - NSession session=workspace.currentSession(); List all = new ArrayList<>(); StringReaderExt ar = new StringReaderExt(text); while (ar.hasNext()) { @@ -77,11 +76,11 @@ public NText stringToText(String text, NTexts txt) { break; } case '\'': { - all.addAll(Arrays.asList(StringReaderExtUtils.readJSSimpleQuotes(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readJSSimpleQuotes(ar))); break; } case '"': { - all.addAll(Arrays.asList(StringReaderExtUtils.readJSDoubleQuotesString(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readJSDoubleQuotesString(ar))); break; } case '0': @@ -94,12 +93,12 @@ public NText stringToText(String text, NTexts txt) { case '7': case '8': case '9': { - all.addAll(Arrays.asList(StringReaderExtUtils.readNumber(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readNumber(ar))); break; } case '.': case '-': { - NText[] d = StringReaderExtUtils.readNumber(session, ar); + NText[] d = StringReaderExtUtils.readNumber(ar); if (d != null) { all.addAll(Arrays.asList(d)); } else { @@ -109,9 +108,9 @@ public NText stringToText(String text, NTexts txt) { } case '/': { if (ar.peekChars("//")) { - all.addAll(Arrays.asList(StringReaderExtUtils.readSlashSlashComments(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readSlashSlashComments(ar))); } else if (ar.peekChars("/*")) { - all.addAll(Arrays.asList(StringReaderExtUtils.readSlashStarComments(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readSlashStarComments(ar))); } else { all.add(txt.ofStyled(String.valueOf(ar.readChar()), NTextStyle.separator())); } @@ -119,9 +118,9 @@ public NText stringToText(String text, NTexts txt) { } default: { if (Character.isWhitespace(ar.peekChar())) { - all.addAll(Arrays.asList(StringReaderExtUtils.readSpaces(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readSpaces(ar))); } else { - NText[] d = StringReaderExtUtils.readJSIdentifier(session, ar); + NText[] d = StringReaderExtUtils.readJSIdentifier(ar); if (d != null) { if (d.length == 1 && d[0].getType() == NTextType.PLAIN) { String txt2 = ((NTextPlain) d[0]).getText(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/StringReaderExtUtils.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/StringReaderExtUtils.java index 0efa3b0eb..75852bfd7 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/StringReaderExtUtils.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/StringReaderExtUtils.java @@ -5,13 +5,13 @@ import java.util.ArrayList; import java.util.List; -import net.thevpc.nuts.NSession; + import net.thevpc.nuts.text.NTexts; import net.thevpc.nuts.text.NText; public class StringReaderExtUtils { - public static NText[] readSpaces(NSession session, StringReaderExt ar) { + public static NText[] readSpaces(StringReaderExt ar) { NTexts factory = NTexts.of(); StringBuilder sb = new StringBuilder(); while (ar.hasNext() && ar.peekChar() <= 32) { @@ -22,7 +22,7 @@ public static NText[] readSpaces(NSession session, StringReaderExt ar) { }; } - public static NText[] readSlashSlashComments(NSession session, StringReaderExt ar) { + public static NText[] readSlashSlashComments(StringReaderExt ar) { NTexts factory = NTexts.of(); StringBuilder sb = new StringBuilder(); if (!ar.peekChars("//")) { @@ -51,7 +51,7 @@ public static NText[] readSlashSlashComments(NSession session, StringReaderExt a }; } - public static NText[] readSlashStarComments(NSession session, StringReaderExt ar) { + public static NText[] readSlashStarComments(StringReaderExt ar) { NTexts factory = NTexts.of(); StringBuilder sb = new StringBuilder(); if (!ar.peekChars("/*")) { @@ -80,7 +80,7 @@ public static NText[] readSlashStarComments(NSession session, StringReaderExt ar }; } - public static NText[] readJSDoubleQuotesString(NSession session, StringReaderExt ar) { + public static NText[] readJSDoubleQuotesString(StringReaderExt ar) { NTexts factory = NTexts.of(); List all = new ArrayList<>(); boolean inLoop = true; @@ -130,7 +130,7 @@ public static NText[] readJSDoubleQuotesString(NSession session, StringReaderExt } } - public static NText[] readJSSimpleQuotes(NSession session, StringReaderExt ar) { + public static NText[] readJSSimpleQuotes(StringReaderExt ar) { NTexts factory = NTexts.of(); List all = new ArrayList<>(); boolean inLoop = true; @@ -180,7 +180,7 @@ public static NText[] readJSSimpleQuotes(NSession session, StringReaderExt ar) { } } - public static NText[] readJSIdentifier(NSession session, StringReaderExt ar) { + public static NText[] readJSIdentifier(StringReaderExt ar) { NTexts factory = NTexts.of(); List all = new ArrayList<>(); StringBuilder sb = new StringBuilder(); @@ -200,7 +200,7 @@ public static NText[] readJSIdentifier(NSession session, StringReaderExt ar) { } - public static NText[] readNumber(NSession session, StringReaderExt ar) { + public static NText[] readNumber(StringReaderExt ar) { NTexts factory = NTexts.of(); boolean nbrVisited = false; boolean minusVisited = false; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/TsonCodeHighlighter.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/TsonCodeHighlighter.java index 1935f21f9..ff8e51b86 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/TsonCodeHighlighter.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/TsonCodeHighlighter.java @@ -46,7 +46,6 @@ public int getSupportLevel(NSupportLevelContext context) { @Override public NText stringToText(String text, NTexts txt) { - NSession session=workspace.currentSession(); List all = new ArrayList<>(); StringReaderExt ar = new StringReaderExt(text); while (ar.hasNext()) { @@ -66,7 +65,7 @@ public NText stringToText(String text, NTexts txt) { case '\'': case '"': case '`': { - all.addAll(Arrays.asList(parseRawString(session, txt, ar))); + all.addAll(Arrays.asList(parseRawString(txt, ar))); break; } case '0': @@ -79,13 +78,13 @@ public NText stringToText(String text, NTexts txt) { case '7': case '8': case '9': { - all.addAll(Arrays.asList(readNumber(session, txt, ar))); + all.addAll(Arrays.asList(readNumber(txt, ar))); break; } case '.': case '-': case '+': { - NText[] d = readNumber(session, txt, ar); + NText[] d = readNumber(txt, ar); if (d != null) { all.addAll(Arrays.asList(d)); } else { @@ -95,9 +94,9 @@ public NText stringToText(String text, NTexts txt) { } case '/': { if (ar.peekChars("//")) { - all.addAll(Arrays.asList(StringReaderExtUtils.readSlashSlashComments(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readSlashSlashComments(ar))); } else if (ar.peekChars("/*")) { - all.addAll(Arrays.asList(StringReaderExtUtils.readSlashStarComments(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readSlashStarComments(ar))); } else { all.add(txt.ofStyled(String.valueOf(ar.readChar()), NTextStyle.separator())); } @@ -105,9 +104,9 @@ public NText stringToText(String text, NTexts txt) { } default: { if (Character.isWhitespace(ar.peekChar())) { - all.addAll(Arrays.asList(StringReaderExtUtils.readSpaces(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readSpaces(ar))); } else { - NText[] d = readIdentifier(session, txt, ar); + NText[] d = readIdentifier(txt, ar); if (d != null) { if (d.length == 1 && d[0].getType() == NTextType.PLAIN) { String txt2 = ((NTextPlain) d[0]).getText(); @@ -129,7 +128,7 @@ public NText stringToText(String text, NTexts txt) { } - public static String readNumberStr(NSession session, StringReaderExt ar) { + public static String readNumberStr(StringReaderExt ar) { ar.mark(); StringBuilder sb = new StringBuilder(); if (ar.readString("0u")) { @@ -230,8 +229,8 @@ public static String readNumberStr(NSession session, StringReaderExt ar) { return sb.toString(); } - public static NText[] readNumber(NSession session, NTexts txt, StringReaderExt ar) { - String s = readNumberStr(session, ar); + public static NText[] readNumber(NTexts txt, StringReaderExt ar) { + String s = readNumberStr(ar); if (s.length() > 0) { return new NText[]{ txt.ofStyled(s, NTextStyle.number()) @@ -269,7 +268,7 @@ protected boolean isJavaIdentifierPart(char c) { return Character.isJavaIdentifierStart(c); } - private NText[] readIdentifier(NSession session, NTexts txt, StringReaderExt ar) { + private NText[] readIdentifier(NTexts txt, StringReaderExt ar) { List all = new ArrayList<>(); StringBuilder sb = new StringBuilder(); if (!ar.hasNext() || !isIdentifierStart(ar.peekChar())) { @@ -296,7 +295,7 @@ private NText[] readIdentifier(NSession session, NTexts txt, StringReaderExt ar) return all.toArray(new NText[0]); } - public NText[] parseRawString(NSession session, NTexts txt, StringReaderExt chars) { + public NText[] parseRawString(NTexts txt, StringReaderExt chars) { List all = new ArrayList<>(); for (String border : new String[]{ "\"\"\"", diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/WinCmdBlocTextHighlighter.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/WinCmdBlocTextHighlighter.java index 24070c5e8..7f78c80a8 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/WinCmdBlocTextHighlighter.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/highlighter/WinCmdBlocTextHighlighter.java @@ -2,7 +2,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NShellFamily; +import net.thevpc.nuts.NShellFamily; import net.thevpc.nuts.io.NIOException; import net.thevpc.nuts.runtime.standalone.xtra.expr.StringReaderExt; import net.thevpc.nuts.runtime.standalone.text.parser.DefaultNTextPlain; @@ -26,7 +26,7 @@ public WinCmdBlocTextHighlighter(NWorkspace workspace) { this.workspace = workspace; } - private static NText[] parseCmdLine_readAntiSlash(StringReaderExt ar, NSession session) { + private static NText[] parseCmdLine_readAntiSlash(StringReaderExt ar) { StringBuilder sb2 = new StringBuilder(); sb2.append(ar.readChar()); if (ar.hasNext()) { @@ -158,7 +158,6 @@ public int getSupportLevel(NSupportLevelContext context) { @Override public NText stringToText(String text, NTexts txt) { - NSession session=workspace.currentSession(); List all = new ArrayList<>(); BufferedReader reader = new BufferedReader(new StringReader(text)); String line = null; @@ -176,7 +175,7 @@ public NText stringToText(String text, NTexts txt) { } else { all.add(txt.ofPlain("\n")); } - all.add(commandToNode(line, txt, session)); + all.add(commandToNode(line, txt)); } return txt.ofList(all).simplify(); } @@ -186,7 +185,7 @@ public NText tokenToText(String text, String nodeType, NTexts txt) { return txt.ofPlain(text); } - private NText[] parseCmdLine_readSimpleQuotes(StringReaderExt ar, NTexts txt, NSession session) { + private NText[] parseCmdLine_readSimpleQuotes(StringReaderExt ar, NTexts txt) { StringBuilder sb = new StringBuilder(); sb.append(ar.readChar()); //quote! List ret = new ArrayList<>(); @@ -219,7 +218,7 @@ private NText[] parseCmdLine_readSimpleQuotes(StringReaderExt ar, NTexts txt, NS return ret.toArray(new NText[0]); } - private NText[] parseCmdLine_readWord(StringReaderExt ar, NTexts txt, NSession session) { + private NText[] parseCmdLine_readWord(StringReaderExt ar, NTexts txt) { StringBuilder sb = new StringBuilder(); List ret = new ArrayList<>(); boolean inLoop = true; @@ -291,18 +290,18 @@ private NText[] parseCmdLine_readWord(StringReaderExt ar, NTexts txt, NSession s return ret.toArray(new NText[0]); } - private NText[] parseCmdLine_readDollar(StringReaderExt ar, NTexts txt, NSession session) { + private NText[] parseCmdLine_readDollar(StringReaderExt ar, NTexts txt) { if (ar.peekChars("$((")) { - return parseCmdLine_readDollarPar2(ar, txt, session); + return parseCmdLine_readDollarPar2(ar, txt); } StringBuilder sb2 = new StringBuilder(); if (ar.hasNext(1)) { switch (ar.peekChar(1)) { case '(': { - return parseCmdLine_readDollarPar2(ar, txt, session); + return parseCmdLine_readDollarPar2(ar, txt); } case '{': { - return parseCmdLine_readDollarCurlyBrackets(ar, txt, session); + return parseCmdLine_readDollarCurlyBrackets(ar, txt); } case '*': case '?': @@ -341,7 +340,7 @@ private NText[] parseCmdLine_readDollar(StringReaderExt ar, NTexts txt, NSession txt.ofStyled("$", NTextStyle.separator()),}; } - private NText[] parseCmdLine_readDoubleQuotes(StringReaderExt ar, NTexts txt, NSession session) { + private NText[] parseCmdLine_readDoubleQuotes(StringReaderExt ar, NTexts txt) { List ret = new ArrayList<>(); StringBuilder sb = new StringBuilder(); @@ -360,7 +359,7 @@ private NText[] parseCmdLine_readDoubleQuotes(StringReaderExt ar, NTexts txt, NS ret.add(txt.ofStyled(sb.toString(), NTextStyle.string())); sb.setLength(0); } - ret.addAll(Arrays.asList(parseCmdLine_readDollar(ar, txt, session))); + ret.addAll(Arrays.asList(parseCmdLine_readDollar(ar, txt))); } else if (c == '\"') { if (sb.length() > 0) { ret.add(txt.ofStyled(sb.toString(), NTextStyle.string())); @@ -379,7 +378,7 @@ private NText[] parseCmdLine_readDoubleQuotes(StringReaderExt ar, NTexts txt, NS return ret.toArray(new NText[0]); } - private NText[] parseCmdLine_readAntiQuotes(StringReaderExt ar, NTexts txt, NSession session) { + private NText[] parseCmdLine_readAntiQuotes(StringReaderExt ar, NTexts txt) { List all = new ArrayList<>(); all.add(txt.ofStyled(String.valueOf(ar.readChar()), NTextStyle.separator())); boolean inLoop = true; @@ -394,14 +393,14 @@ private NText[] parseCmdLine_readAntiQuotes(StringReaderExt ar, NTexts txt, NSes break; } default: { - wasSpace = parseCmdLineStep(ar, all, 1, wasSpace, txt, session); + wasSpace = parseCmdLineStep(ar, all, 1, wasSpace, txt); } } } return all.toArray(new NText[0]); } - private NText[] parseCmdLine_readDollarPar(NWorkspace ws, StringReaderExt ar, NTexts txt, NSession session) { + private NText[] parseCmdLine_readDollarPar(NWorkspace ws, StringReaderExt ar, NTexts txt) { List all = new ArrayList<>(); all.add(txt.ofStyled(String.valueOf(ar.readChar()) + ar.readChar(), NTextStyle.separator())); boolean inLoop = true; @@ -415,14 +414,14 @@ private NText[] parseCmdLine_readDollarPar(NWorkspace ws, StringReaderExt ar, NT break; } default: { - wasSpace = parseCmdLineStep(ar, all, 2, wasSpace, txt, session); + wasSpace = parseCmdLineStep(ar, all, 2, wasSpace, txt); } } } return all.toArray(new NText[0]); } - private NText[] parseCmdLine_readDollarPar2(StringReaderExt ar, NTexts txt, NSession session) { + private NText[] parseCmdLine_readDollarPar2(StringReaderExt ar, NTexts txt) { List all = new ArrayList<>(); all.add(txt.ofStyled(String.valueOf(ar.readChar()) + ar.readChar() + ar.readChar(), NTextStyle.separator())); boolean inLoop = true; @@ -445,19 +444,19 @@ private NText[] parseCmdLine_readDollarPar2(StringReaderExt ar, NTexts txt, NSes all.add(txt.ofStyled(String.valueOf(ar.nextChars(2)), NTextStyle.separator())); inLoop = false; } else { - wasSpace = parseCmdLineStep(ar, all, 2, wasSpace, txt, session); + wasSpace = parseCmdLineStep(ar, all, 2, wasSpace, txt); } break; } default: { - wasSpace = parseCmdLineStep(ar, all, 2, wasSpace, txt, session); + wasSpace = parseCmdLineStep(ar, all, 2, wasSpace, txt); } } } return all.toArray(new NText[0]); } - private NText[] parseCmdLine_readDollarCurlyBrackets(StringReaderExt ar, NTexts txt, NSession session) { + private NText[] parseCmdLine_readDollarCurlyBrackets(StringReaderExt ar, NTexts txt) { List all = new ArrayList<>(); all.add(txt.ofStyled(String.valueOf(ar.readChar()) + ar.readChar(), NTextStyle.separator())); boolean inLoop = true; @@ -474,7 +473,7 @@ private NText[] parseCmdLine_readDollarCurlyBrackets(StringReaderExt ar, NTexts } default: { startIndex = all.size(); - wasSpace = parseCmdLineStep(ar, all, -1, wasSpace, txt, session); + wasSpace = parseCmdLineStep(ar, all, -1, wasSpace, txt); if (expectedName) { expectedName = false; if (all.size() > startIndex) { @@ -490,7 +489,7 @@ private NText[] parseCmdLine_readDollarCurlyBrackets(StringReaderExt ar, NTexts return all.toArray(new NText[0]); } - private NText[] parseCmdLine_readPar2(StringReaderExt ar, NTexts txt, NSession session) { + private NText[] parseCmdLine_readPar2(StringReaderExt ar, NTexts txt) { List all = new ArrayList<>(); all.add(txt.ofStyled(String.valueOf(ar.readChar()) + ar.readChar(), NTextStyle.separator())); boolean inLoop = true; @@ -503,12 +502,12 @@ private NText[] parseCmdLine_readPar2(StringReaderExt ar, NTexts txt, NSession s all.add(txt.ofStyled(String.valueOf(ar.nextChars(2)), NTextStyle.separator())); inLoop = false; } else { - wasSpace = parseCmdLineStep(ar, all, 2, wasSpace, txt, session); + wasSpace = parseCmdLineStep(ar, all, 2, wasSpace, txt); } break; } default: { - wasSpace = parseCmdLineStep(ar, all, 2, wasSpace, txt, session); + wasSpace = parseCmdLineStep(ar, all, 2, wasSpace, txt); } } } @@ -524,27 +523,27 @@ private NText[] parseCmdLine_readPar2(StringReaderExt ar, NTexts txt, NSession s * @param wasSpace wasSpace * @return is space */ - private boolean parseCmdLineStep(StringReaderExt ar, List all, int startIndex, boolean wasSpace, NTexts txt, NSession session) { + private boolean parseCmdLineStep(StringReaderExt ar, List all, int startIndex, boolean wasSpace, NTexts txt) { char c = ar.peekChar(); if (c <= 32) { - all.addAll(Arrays.asList(StringReaderExtUtils.readSpaces(session, ar))); + all.addAll(Arrays.asList(StringReaderExtUtils.readSpaces(ar))); return true; } switch (c) { case '\'': { - all.addAll(Arrays.asList(parseCmdLine_readSimpleQuotes(ar, txt, session))); + all.addAll(Arrays.asList(parseCmdLine_readSimpleQuotes(ar, txt))); break; } case '`': { - all.addAll(Arrays.asList(parseCmdLine_readAntiQuotes(ar, txt, session))); + all.addAll(Arrays.asList(parseCmdLine_readAntiQuotes(ar, txt))); break; } case '"': { - all.addAll(Arrays.asList(parseCmdLine_readDoubleQuotes(ar, txt, session))); + all.addAll(Arrays.asList(parseCmdLine_readDoubleQuotes(ar, txt))); break; } case '$': { - all.addAll(Arrays.asList(parseCmdLine_readDollar(ar, txt, session))); + all.addAll(Arrays.asList(parseCmdLine_readDollar(ar, txt))); break; } case ';': { @@ -630,7 +629,7 @@ private boolean parseCmdLineStep(StringReaderExt ar, List all, int startI } case '(': { if (ar.peekChars("((")) { - all.addAll(Arrays.asList(parseCmdLine_readPar2(ar, txt, session))); + all.addAll(Arrays.asList(parseCmdLine_readPar2(ar, txt))); } else { all.add(txt.ofStyled(String.valueOf(ar.readChar()), NTextStyle.separator())); } @@ -673,7 +672,7 @@ private boolean parseCmdLineStep(StringReaderExt ar, List all, int startI default: { if (startIndex >= 0) { boolean first = all.size() == startIndex; - all.addAll(Arrays.asList(parseCmdLine_readWord(ar, txt, session))); + all.addAll(Arrays.asList(parseCmdLine_readWord(ar, txt))); if (first) { int i = indexOfFirstWord(all, startIndex); if (i >= 0) { @@ -681,24 +680,24 @@ private boolean parseCmdLineStep(StringReaderExt ar, List all, int startI } } } else { - all.addAll(Arrays.asList(parseCmdLine_readWord(ar, txt, session))); + all.addAll(Arrays.asList(parseCmdLine_readWord(ar, txt))); } } } return false; } - private NText[] parseCmdLine(String cmdLineString, NTexts txt, NSession session) { + private NText[] parseCmdLine(String cmdLineString, NTexts txt) { StringReaderExt ar = new StringReaderExt(cmdLineString); List all = new ArrayList<>(); boolean wasSpace = true; while (ar.hasNext()) { - wasSpace = parseCmdLineStep(ar, all, 0, wasSpace, txt, session); + wasSpace = parseCmdLineStep(ar, all, 0, wasSpace, txt); } return all.toArray(new NText[0]); } - public NText next(StringReaderExt reader, boolean exitOnClosedCurlBrace, boolean exitOnClosedPar, boolean exitOnDblQuote, boolean exitOnAntiQuote, NTexts txt, NSession session) { + public NText next(StringReaderExt reader, boolean exitOnClosedCurlBrace, boolean exitOnClosedPar, boolean exitOnDblQuote, boolean exitOnAntiQuote, NTexts txt) { boolean lineStart = true; List all = new ArrayList<>(); boolean exit = false; @@ -845,7 +844,7 @@ public NText next(StringReaderExt reader, boolean exitOnClosedCurlBrace, boolean } case '\"': { lineStart = false; - all.add(nextDoubleQuotes(reader, session)); + all.add(nextDoubleQuotes(reader)); break; } case '`': { @@ -855,7 +854,7 @@ public NText next(StringReaderExt reader, boolean exitOnClosedCurlBrace, boolean } else { List a = new ArrayList<>(); a.add(txt.ofStyled(reader.nextChars(1), NTextStyle.string())); - a.add(next(reader, false, false, false, true, txt, session)); + a.add(next(reader, false, false, false, true, txt)); if (reader.hasNext() && reader.peekChar() == '`') { a.add(txt.ofStyled(reader.nextChars(1), NTextStyle.string())); } else { @@ -1049,14 +1048,14 @@ public NText next(StringReaderExt reader, boolean exitOnClosedCurlBrace, boolean return txt.ofList(all).simplify(); } - private NText nextDollar(StringReaderExt reader, NTexts txt, NSession session) { + private NText nextDollar(StringReaderExt reader, NTexts txt) { if (reader.isAvailable(2)) { char c = reader.peekChar(1); switch (c) { case '(': { List a = new ArrayList<>(); a.add(txt.ofStyled(reader.nextChars(1), NTextStyle.separator())); - a.add(next(reader, false, true, false, false, txt, session)); + a.add(next(reader, false, true, false, false, txt)); if (reader.hasNext() && reader.peekChar() == ')') { a.add(txt.ofStyled(reader.nextChars(1), NTextStyle.separator())); } @@ -1065,7 +1064,7 @@ private NText nextDollar(StringReaderExt reader, NTexts txt, NSession session) { case '{': { List a = new ArrayList<>(); a.add(txt.ofStyled(reader.nextChars(1), NTextStyle.separator())); - a.add(next(reader, true, false, false, false, txt, session)); + a.add(next(reader, true, false, false, false, txt)); if (reader.hasNext() && reader.peekChar() == ')') { a.add(txt.ofStyled(reader.nextChars(1), NTextStyle.separator())); } @@ -1106,7 +1105,7 @@ private NText nextDollar(StringReaderExt reader, NTexts txt, NSession session) { } } - public NText nextDoubleQuotes(StringReaderExt reader, NSession session) { + public NText nextDoubleQuotes(StringReaderExt reader) { List all = new ArrayList<>(); NTexts txt = NTexts.of(); boolean exit = false; @@ -1128,7 +1127,7 @@ public NText nextDoubleQuotes(StringReaderExt reader, NSession session) { all.add(txt.ofStyled(sb.toString(), NTextStyle.string())); sb.setLength(0); } - all.add(nextDollar(reader, txt, session)); + all.add(nextDollar(reader, txt)); } case '`': { if (sb.length() > 0) { @@ -1137,7 +1136,7 @@ public NText nextDoubleQuotes(StringReaderExt reader, NSession session) { } List a = new ArrayList<>(); a.add(txt.ofStyled(reader.nextChars(1), NTextStyle.string())); - a.add(next(reader, false, false, false, true, txt, session)); + a.add(next(reader, false, false, false, true, txt)); if (reader.hasNext() && reader.peekChar() == '`') { a.add(txt.ofStyled(reader.nextChars(1), NTextStyle.string())); } else { @@ -1158,8 +1157,8 @@ public NText nextDoubleQuotes(StringReaderExt reader, NSession session) { return txt.ofList(all).simplify(); } - public NText commandToNode(String text, NTexts txt, NSession session) { - return txt.ofList(parseCmdLine(text, txt, session)); + public NText commandToNode(String text, NTexts txt) { + return txt.ofList(parseCmdLine(text, txt)); } } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/parser/v1/StyledParserStep.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/parser/v1/StyledParserStep.java index 049341334..67addea70 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/parser/v1/StyledParserStep.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/parser/v1/StyledParserStep.java @@ -2,7 +2,8 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NBootManager; + + import net.thevpc.nuts.runtime.standalone.text.parser.DefaultNTextPlain; import net.thevpc.nuts.runtime.standalone.util.CoreStringUtils; import net.thevpc.nuts.runtime.standalone.util.NDebugString; @@ -99,7 +100,7 @@ public void consume(char c, DefaultNTextNodeParser.State state, boolean wasNewLi case ')': { beforeChangingStep(); state.applyDropReplace(this, new TitleParserStep( - CoreStringUtils.fillString("#", sharpsStartCount) + ")", workspace.currentSession())); + CoreStringUtils.fillString("#", sharpsStartCount) + ")")); break; } case NConstants.Ntf.SILENT: { @@ -654,7 +655,7 @@ public boolean isComplete() { } private void logErr(String s) { - if(NDebugString.of(NBootManager.of().getBootOptions().getDebug().orNull()).isEnabled()) { + if(NDebugString.of(NWorkspace.get().getBootOptions().getDebug().orNull()).isEnabled()) { workspace.currentSession().err().println(s); } } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/parser/v1/TitleParserStep.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/parser/v1/TitleParserStep.java index 812bf7768..605a4b779 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/parser/v1/TitleParserStep.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/parser/v1/TitleParserStep.java @@ -1,6 +1,5 @@ package net.thevpc.nuts.runtime.standalone.text.parser.v1; -import net.thevpc.nuts.NSession; import net.thevpc.nuts.text.NTexts; import net.thevpc.nuts.util.NQuoteType; import net.thevpc.nuts.util.NStringUtils; @@ -14,10 +13,8 @@ public class TitleParserStep extends ParserStep { StringBuilder start = new StringBuilder(); List children = new ArrayList<>(); - private NSession session; - public TitleParserStep(String c, NSession session) { + public TitleParserStep(String c) { start.append(c); - this.session = session; } @Override diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/theme/NTextFormatPropertiesTheme.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/theme/NTextFormatPropertiesTheme.java index 7c0bf997b..74d844435 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/theme/NTextFormatPropertiesTheme.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/theme/NTextFormatPropertiesTheme.java @@ -1,8 +1,9 @@ package net.thevpc.nuts.runtime.standalone.text.theme; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; + + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NIOException; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.xtra.expr.StringReaderExt; @@ -26,7 +27,6 @@ public class NTextFormatPropertiesTheme implements NTextFormatTheme { public NTextFormatPropertiesTheme(String name, ClassLoader cls, NWorkspace workspace) { this.workspace = workspace; - NSession session = workspace.currentSession(); if (name.indexOf('/') >= 0 || name.indexOf('\\') >= 0) { try (InputStream is = NPath.of(name).getInputStream()) { props.load(is); @@ -54,7 +54,7 @@ public NTextFormatPropertiesTheme(String name, ClassLoader cls, NWorkspace works throw new NIOException(e); } } else { - NPath themeFile = NLocations.of().getStoreLocation( + NPath themeFile = NWorkspace.get().getStoreLocation( NId.ofRuntime("SHARED").get(), NStoreType.CONF ).resolve("themes").resolve(name); @@ -143,7 +143,6 @@ public NTextStyles toBasicStyles(NTextStyle style) { public NTextStyles toBasicStyles(NTextStyle style, int maxLoop) { if (maxLoop <= 0) { - NSession session = workspace.currentSession(); throw new NIllegalArgumentException( NMsg.ofC("invalid ntf theme for %s(%s). infinite loop", style.getType(), style.getVariant())); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/util/DefaultUnitFormat.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/util/DefaultUnitFormat.java index 2ca197393..785f5b454 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/util/DefaultUnitFormat.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/text/util/DefaultUnitFormat.java @@ -219,7 +219,7 @@ private String formatLeft(Object number, int size) { } public NText formatDouble(double value, NSession session) { - return format(value, session); + return format(value); } @@ -290,7 +290,7 @@ private String strUnit(int pow) { throw new IllegalArgumentException("Unsupported"); } - public NText format(double value, NSession session) { + public NText format(double value) { NTextBuilder sb = NTextBuilder.of(); boolean neg = value < 0; int sign = neg ? -1 : 1; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/BytesSizeFormat.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/BytesSizeFormat.java index 9c5b5189b..09c237358 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/BytesSizeFormat.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/BytesSizeFormat.java @@ -5,7 +5,6 @@ import net.thevpc.nuts.text.NText; import net.thevpc.nuts.text.NTextBuilder; import net.thevpc.nuts.text.NTextStyle; -import net.thevpc.nuts.text.NTexts; import net.thevpc.nuts.util.NMsg; import net.thevpc.nuts.util.NStringUtils; @@ -90,9 +89,8 @@ public class BytesSizeFormat { private long high = TERA; private long low = BYTE; private int depth = Integer.MAX_VALUE; - private NSession session; - public BytesSizeFormat(boolean leadingZeros, boolean intermediateZeros, boolean fixedLength, boolean binaryPrefix, long high, long low, int depth, NSession session) { + public BytesSizeFormat(boolean leadingZeros, boolean intermediateZeros, boolean fixedLength, boolean binaryPrefix, long high, long low, int depth) { this.leadingZeros = leadingZeros; this.intermediateZeros = intermediateZeros; this.fixedLength = fixedLength; @@ -100,7 +98,6 @@ public BytesSizeFormat(boolean leadingZeros, boolean intermediateZeros, boolean this.high = high; this.low = low; this.depth = depth <= 0 ? Integer.MAX_VALUE : depth; - this.session = session; } // public BytesSizeFormat() { @@ -162,12 +159,9 @@ public BytesSizeFormat(boolean leadingZeros, boolean intermediateZeros, boolean * * * - * - * @param format size format - * @param session session + * @param format size format */ - public BytesSizeFormat(String format, NSession session) { - this.session = session; + public BytesSizeFormat(String format) { leadingZeros = false; intermediateZeros = false; trailingZeros = false; @@ -293,10 +287,6 @@ private String formatLeft(Object number, int size) { } public String formatString(long bytes) { - return formatString(bytes,session); - } - - public String formatString(long bytes, NSession session) { StringBuilder sb = new StringBuilder(); boolean neg = bytes < 0; long v = bytes < 0 ? -bytes : bytes; @@ -487,7 +477,7 @@ public String formatString(long bytes, NSession session) { return sb.toString(); } - public NText formatText(long bytes, NSession session) { + public NText formatText(long bytes) { NTextBuilder sb = NTextBuilder.of(); boolean neg = bytes < 0; long v = bytes < 0 ? -bytes : bytes; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/CoreNUtils.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/CoreNUtils.java index 52bea322f..2c04ce77d 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/CoreNUtils.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/CoreNUtils.java @@ -25,16 +25,16 @@ package net.thevpc.nuts.runtime.standalone.util; import net.thevpc.nuts.*; -import net.thevpc.nuts.boot.NBootClassLoaderNode; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NBootManager; -import net.thevpc.nuts.env.NStoreType; + + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.format.NDescriptorFormat; import net.thevpc.nuts.runtime.standalone.descriptor.util.NDescriptorUtils; import net.thevpc.nuts.runtime.standalone.xtra.expr.StringPlaceHolderParser; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.util.NLiteral; -import net.thevpc.nuts.env.NOsFamily; +import net.thevpc.nuts.NOsFamily; import net.thevpc.nuts.util.NStringUtils; import java.io.File; @@ -529,9 +529,11 @@ public static NIdType detectIdType(NId depId) { if (rt.equals(depId.getShortName())) { return NIdType.RUNTIME; } else { - for (NBootClassLoaderNode n : NBootManager.of().getBootExtensionClassLoaderNode()) { - if (NId.of(n.getId()).orElse(NId.BLANK).equalsShortId(depId)) { - return NIdType.EXTENSION; + for (NClassLoaderNode n : NWorkspace.get().getBootExtensionClassLoaderNode()) { + if(n.getId()!=null) { + if (n.getId().equalsShortId(depId)) { + return NIdType.EXTENSION; + } } } return NIdType.REGULAR; @@ -599,14 +601,14 @@ public Thread newThread(Runnable r) { } public static boolean isCustomTrue(String name) { - return NBootManager.of().getCustomBootOption(name) + return NWorkspace.get().getCustomBootOption(name) .ifEmpty(NLiteral.of("true")) .flatMap(NLiteral::asBoolean) .orElse(false); } public static boolean isCustomFalse(String name) { - return NBootManager.of().getCustomBootOption(name) + return NWorkspace.get().getCustomBootOption(name) .flatMap(NLiteral::asBoolean) .orElse(false); } @@ -619,7 +621,7 @@ public static RuntimeException toUncheckedException(Throwable e) { } public static boolean isShowCommand() { - return NBootManager.of().getCustomBootOption("---show-command") + return NWorkspace.get().getCustomBootOption("---show-command") .flatMap(NLiteral::asBoolean) .orElse(false); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/CorePlatformUtils.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/CorePlatformUtils.java index c90d5ac49..795e6d949 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/CorePlatformUtils.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/CorePlatformUtils.java @@ -26,12 +26,12 @@ package net.thevpc.nuts.runtime.standalone.util; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NEnvCondition; +import net.thevpc.nuts.NEnvCondition; import net.thevpc.nuts.io.NTerminal; import net.thevpc.nuts.runtime.standalone.util.filters.CoreFilterUtils; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.util.NMsg; -import net.thevpc.nuts.env.NOsFamily; +import net.thevpc.nuts.NOsFamily; import net.thevpc.nuts.util.NRef; import java.io.*; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/DefaultSourceControlHelper.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/DefaultSourceControlHelper.java index f00009e38..b1955ee9c 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/DefaultSourceControlHelper.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/DefaultSourceControlHelper.java @@ -41,7 +41,6 @@ protected NLogOp _LOGOP() { } protected NLog _LOG() { - NSession session = workspace.currentSession(); return NLog.of(DefaultSourceControlHelper.class); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/ExtraApiUtils.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/ExtraApiUtils.java index b986f14b6..06d953f55 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/ExtraApiUtils.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/ExtraApiUtils.java @@ -1,9 +1,9 @@ package net.thevpc.nuts.runtime.standalone.util; +import net.thevpc.nuts.NClassLoaderNode; import net.thevpc.nuts.NId; import net.thevpc.nuts.NIllegalArgumentException; import net.thevpc.nuts.Nuts; -import net.thevpc.nuts.boot.NBootClassLoaderNode; import net.thevpc.nuts.log.NLog; import net.thevpc.nuts.log.NLogVerb; import net.thevpc.nuts.reserved.NReservedLangUtils; @@ -186,27 +186,39 @@ public static boolean isLoadedClassPath(URL url, ClassLoader contextClassLoader, return false; } - private static void fillBootDependencyNodes(NBootClassLoaderNode node, Set urls, Set visitedIds, + private static void fillBootDependencyNodes(NClassLoaderNode node, Set urls, Set visitedIds, NLog bLog) { - String shortName = NId.of(node.getId()).get().getShortName(); - if (!visitedIds.contains(shortName)) { - visitedIds.add(shortName); + if(node.getId()==null){ if (!node.isIncludedInClasspath()) { urls.add(node.getURL()); } else { bLog.with().level(Level.WARNING).verb(NLogVerb.CACHE).log( NMsg.ofC("url will not be loaded (already in classloader) : %s", node.getURL())); } - for (NBootClassLoaderNode dependency : node.getDependencies()) { + for (NClassLoaderNode dependency : node.getDependencies()) { fillBootDependencyNodes(dependency, urls, visitedIds, bLog); } + return; + }else { + String shortName = node.getId().getShortName(); + if (!visitedIds.contains(shortName)) { + visitedIds.add(shortName); + if (!node.isIncludedInClasspath()) { + urls.add(node.getURL()); + } else { + bLog.with().level(Level.WARNING).verb(NLogVerb.CACHE).log(NMsg.ofC("url will not be loaded (already in classloader) : %s", node.getURL())); + } + for (NClassLoaderNode dependency : node.getDependencies()) { + fillBootDependencyNodes(dependency, urls, visitedIds, bLog); + } + } } } - public static URL[] resolveClassWorldURLs(NBootClassLoaderNode[] nodes, ClassLoader contextClassLoader, + public static URL[] resolveClassWorldURLs(NClassLoaderNode[] nodes, ClassLoader contextClassLoader, NLog bLog) { LinkedHashSet urls = new LinkedHashSet<>(); Set visitedIds = new HashSet<>(); - for (NBootClassLoaderNode info : nodes) { + for (NClassLoaderNode info : nodes) { if(info!=null) { fillBootDependencyNodes(info, urls, visitedIds, bLog); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/NCachedValue.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/NCachedValue.java index 2878b7459..85667bf08 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/NCachedValue.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/NCachedValue.java @@ -56,7 +56,6 @@ public boolean isInvalid() { } public void updateAsync() { - NSession session = workspace.currentSession(); if (!updating) { new Thread() { @Override diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/NDefaultClassLoaderNode.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/NDefaultClassLoaderNode.java new file mode 100644 index 000000000..91ef2c6b9 --- /dev/null +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/NDefaultClassLoaderNode.java @@ -0,0 +1,102 @@ +/** + * ==================================================================== + * Nuts : Network Updatable Things Service + * (universal package manager) + *
+ * is a new Open Source Package Manager to help install packages and libraries + * for runtime execution. Nuts is the ultimate companion for maven (and other + * build managers) as it helps installing all package dependencies at runtime. + * Nuts is not tied to java and is a good choice to share shell scripts and + * other 'things' . Its based on an extensible architecture to help supporting a + * large range of sub managers / repositories. + *
+ *

+ * Copyright [2020] [thevpc] + * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 (the "License"); + * you may not use this file except in compliance with the License. You may obtain + * a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html + * 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 net.thevpc.nuts.runtime.standalone.util; + +import net.thevpc.nuts.NClassLoaderNode; +import net.thevpc.nuts.NId; +import net.thevpc.nuts.boot.reserved.util.NBootUtils; + +import java.net.URL; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; + +/** + * Loaded Package Information used to Boot + * + * @author thevpc + * @app.category Internal + */ +public class NDefaultClassLoaderNode implements NClassLoaderNode { + + private final NId id; + private final boolean includedInClasspath; + private final URL url; + private final boolean enabled; + private final List dependencies; + + public NDefaultClassLoaderNode(NId id, URL url, boolean enabled, boolean includedInClasspath, NClassLoaderNode... dependencies) { + this.id = id; + this.url = url; + this.enabled = enabled; + this.includedInClasspath = includedInClasspath; + this.dependencies = NBootUtils.nonNullList(Arrays.asList(dependencies)); + } + + public boolean isIncludedInClasspath() { + return includedInClasspath; + } + + public boolean isEnabled() { + return enabled; + } + + public NId getId() { + return id; + } + + public URL getURL() { + return url; + } + + public List getDependencies() { + return dependencies; + } + + @Override + public int hashCode() { + int result = Objects.hash(id, includedInClasspath, url, enabled,dependencies); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + NDefaultClassLoaderNode that = (NDefaultClassLoaderNode) o; + return includedInClasspath == that.includedInClasspath && enabled == that.enabled && Objects.equals(id, that.id) && Objects.equals(url, that.url) && Objects.equals(dependencies, that.dependencies); + } + + @Override + public String toString() { + return "NutsClassLoaderNode{" + + "id='" + id + '\'' + + ", loaded=" + includedInClasspath + + ", url=" + url + + ", enabled=" + enabled + + ", dependencies=" + dependencies + + '}'; + } +} diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/NSpeedQualifiers.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/NSpeedQualifiers.java index f67e03c0d..2d0e23180 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/NSpeedQualifiers.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/NSpeedQualifiers.java @@ -1,6 +1,6 @@ package net.thevpc.nuts.runtime.standalone.util; -import net.thevpc.nuts.env.NSpeedQualifier; +import net.thevpc.nuts.NSpeedQualifier; public class NSpeedQualifiers { public static NSpeedQualifier avg(NSpeedQualifier... all) { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/filters/CoreFilterUtils.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/filters/CoreFilterUtils.java index 1c85ca12e..b3b639bdd 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/filters/CoreFilterUtils.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/filters/CoreFilterUtils.java @@ -27,7 +27,6 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.*; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.ext.NExtensionInformation; import net.thevpc.nuts.spi.base.AbstractNPredicate; @@ -179,14 +178,14 @@ public static boolean acceptDependency(NDependency dep) { if (a.length > 0) { NOsFamily o = NOsFamily.parse(a[0]).orNull(); if (o != null) { - if (o != NEnvs.of().getOsFamily()) { + if (o != NWorkspace.get().getOsFamily()) { return false; } } if (a.length > 1) { NArchFamily af = NArchFamily.parse(a[1]).orNull(); if (af != null) { - if (af != NEnvs.of().getArchFamily()) { + if (af != NWorkspace.get().getArchFamily()) { return false; } } @@ -249,36 +248,35 @@ public static boolean acceptCondition(NEnvCondition envCond, boolean currentVMOn if (envCond == null || envCond.isBlank()) { return true; } - NEnvs env = NEnvs.of(); - NPlatforms platforms = NPlatforms.of(); + NWorkspace workspace = NWorkspace.get(); if (!matchesArch( - env.getArchFamily().id(), + workspace.getArchFamily().id(), envCond.getArch() )) { return false; } if (!matchesOs( - env.getOsFamily().id(), + workspace.getOsFamily().id(), envCond.getOs() )) { return false; } if (!matchesOsDist( - env.getOsDist().toString(), + workspace.getOsDist().toString(), envCond.getOsDist() )) { return false; } if (currentVMOnLy) { if (!matchesPlatform( - env.getPlatform().toString(), + workspace.getPlatform().toString(), envCond.getPlatform() )) { return false; } } else { if (!matchesPlatform( - platforms.findPlatforms().toList(), + workspace.findPlatforms().toList(), envCond.getPlatform() )) { return false; @@ -286,7 +284,7 @@ public static boolean acceptCondition(NEnvCondition envCond, boolean currentVMOn } if (!matchesDesktopEnvironment( - env.getDesktopEnvironments(), + workspace.getDesktopEnvironments(), envCond.getDesktopEnvironment() )) { return false; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/jclass/NClassLoaderNodeExt.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/jclass/NClassLoaderNodeExt.java index af9e0e939..d912028d6 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/jclass/NClassLoaderNodeExt.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/jclass/NClassLoaderNodeExt.java @@ -1,6 +1,6 @@ package net.thevpc.nuts.runtime.standalone.util.jclass; -import net.thevpc.nuts.boot.NBootClassLoaderNode; +import net.thevpc.nuts.NClassLoaderNode; import net.thevpc.nuts.NId; import net.thevpc.nuts.io.NPath; @@ -8,7 +8,7 @@ import java.util.List; public class NClassLoaderNodeExt { - public NBootClassLoaderNode node; + public NClassLoaderNode node; public NId id; public NPath path; public boolean jfx; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/jclass/NJavaSdkUtils.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/jclass/NJavaSdkUtils.java index 408c5acf7..e1057a72a 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/jclass/NJavaSdkUtils.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/util/jclass/NJavaSdkUtils.java @@ -1,8 +1,6 @@ package net.thevpc.nuts.runtime.standalone.util.jclass; import net.thevpc.nuts.*; -import net.thevpc.nuts.boot.NBootClassLoaderNode; -import net.thevpc.nuts.env.*; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.concurrent.NScheduler; import net.thevpc.nuts.io.NPath; @@ -23,6 +21,7 @@ import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Future; +import java.util.function.Predicate; import java.util.logging.Level; public class NJavaSdkUtils { @@ -43,18 +42,18 @@ public static NJavaSdkUtils of(NWorkspace ws) { // return wp; } - public static List loadNutsClassLoaderNodeExts(NBootClassLoaderNode[] n, boolean java9, NWorkspace workspace) { + public static List loadNutsClassLoaderNodeExts(NClassLoaderNode[] n, boolean java9, NWorkspace workspace) { List list = new ArrayList<>(); - for (NBootClassLoaderNode nn : n) { + for (NClassLoaderNode nn : n) { fillNodes(nn, list, java9, workspace); } return list; } - private static void fillNodes(NBootClassLoaderNode n, List list, boolean java9, NWorkspace workspace) { + private static void fillNodes(NClassLoaderNode n, List list, boolean java9, NWorkspace workspace) { NClassLoaderNodeExt k = new NClassLoaderNodeExt(); k.node = n; - k.id = NId.of(n.getId()).get(); + k.id = n.getId(); k.path = NPath.of(n.getURL()); if (java9) { k.moduleInfo = JavaJarUtils.parseModuleInfo(k.path, workspace); @@ -75,7 +74,7 @@ private static void fillNodes(NBootClassLoaderNode n, List k.id.getGroupId().startsWith("org.openjfx"); } list.add(k); - for (NBootClassLoaderNode d : n.getDependencies()) { + for (NClassLoaderNode d : n.getDependencies()) { fillNodes(d, list, java9, workspace); } } @@ -88,27 +87,58 @@ protected NLog _LOG() { return NLog.of(NJavaSdkUtils.class); } - public NPlatformLocation resolveJdkLocation(String requestedJavaVersion) { - String _requestedJavaVersion = requestedJavaVersion; + public Predicate createVersionFilterPredicate(String requestedJavaVersion){ + NVersionFilter versionFilter = createVersionFilter(requestedJavaVersion); + return createVersionFilterPredicate(versionFilter); + } + + public Predicate createVersionFilterPredicate(NVersionFilter versionFilter){ + return new Predicate() { + @Override + public boolean test(String sVersion) { + NVersion version = NVersion.of(sVersion).get(); + if (versionFilter.acceptVersion(version)) { + return true; + } + // replace 1.6 by 6, and 1.8 by 8 + int a = sVersion.indexOf('.'); + if (a > 0) { + NLiteral p = NLiteral.of(sVersion.substring(0, a)); + if (p.isInt() && p.asInt().get() == 1) { + String sVersion2 = sVersion.substring(a + 1); + NVersion version2 = NVersion.of(sVersion2).get(); + if (versionFilter.acceptVersion(version2)) { + return true; + } + } + } + return false; + } + }; + } + + public NVersionFilter createVersionFilter(String requestedJavaVersion){ requestedJavaVersion = NStringUtils.trim(requestedJavaVersion); NVersion vv = NVersion.of(requestedJavaVersion).get(); String singleVersion = vv.asSingleValue().orNull(); if (singleVersion != null) { requestedJavaVersion = "[" + singleVersion + ",["; } - NVersionFilter requestedVersionFilter = NVersionFilters.of().byValue(requestedJavaVersion).get(); - NPlatforms platforms = NPlatforms.of(); - NPlatformLocation bestJava = platforms + return NVersionFilters.of().byValue(requestedJavaVersion).get(); + } + public NPlatformLocation resolveJdkLocation(String requestedJavaVersion) { + NVersionFilter requestedVersionFilter = createVersionFilter(requestedJavaVersion); + NPlatformLocation bestJava = workspace .findPlatformByVersion(NPlatformFamily.JAVA, requestedVersionFilter).orNull(); if (bestJava == null) { - String appSuffix = NEnvs.of().getOsFamily() == NOsFamily.WINDOWS ? ".exe" : ""; + String appSuffix = NWorkspace.get().getOsFamily() == NOsFamily.WINDOWS ? ".exe" : ""; String packaging = "jre"; if (new File(System.getProperty("java.home"), "bin" + File.separator + "javac" + (appSuffix)).isFile()) { packaging = "jdk"; } String product = "JDK"; NPlatformLocation current = new NPlatformLocation( - NEnvs.of().getPlatform(), + NWorkspace.get().getPlatform(), product, product + "-" + System.getProperty("java.version"), System.getProperty("java.home"), @@ -117,7 +147,7 @@ public NPlatformLocation resolveJdkLocation(String requestedJavaVersion) { 0 ); current.setConfigVersion(DefaultNWorkspace.VERSION_SDK_LOCATION); - NVersionFilter requestedJavaVersionFilter = vv.filter(); + NVersionFilter requestedJavaVersionFilter = NVersion.of(NStringUtils.trim(requestedJavaVersion)).get().filter(); if (requestedJavaVersionFilter == null || requestedJavaVersionFilter.acceptVersion(NVersion.of(current.getVersion()).get())) { bestJava = current; } @@ -133,29 +163,17 @@ public NPlatformLocation resolveJdkLocation(String requestedJavaVersion) { } } String sVersion = bestJava.getVersion(); - if (requestedVersionFilter.acceptVersion(NVersion.of(sVersion).get())) { + if(createVersionFilterPredicate(requestedVersionFilter).test(sVersion)){ return bestJava; } - // replace 1.6 by 6, and 1.8 by 8 - int a = sVersion.indexOf('.'); - if (a > 0) { - NLiteral p = NLiteral.of(sVersion.substring(0, a)); - if (p.isInt() && p.asInt().get() == 1) { - String sVersion2 = sVersion.substring(a + 1); - NVersion version2 = NVersion.of(sVersion2).get(); - if (requestedVersionFilter.acceptVersion(version2)) { - return bestJava; - } - } - } _LOGOP().level(Level.FINE).verb(NLogVerb.WARNING) - .log(NMsg.ofJ("no valid JRE found for version {0}", _requestedJavaVersion)); + .log(NMsg.ofJ("no valid JRE found for version {0}", requestedJavaVersion)); return null; } - public NPlatformLocation[] searchJdkLocations(NSession session) { + public NPlatformLocation[] searchJdkLocations() { String[] conf = {}; - switch (NEnvs.of().getOsFamily()) { + switch (NWorkspace.get().getOsFamily()) { case LINUX: case UNIX: case UNKNOWN: { @@ -176,7 +194,7 @@ public NPlatformLocation[] searchJdkLocations(NSession session) { } List all = new ArrayList<>(); for (String s : conf) { - all.addAll(Arrays.asList(searchJdkLocations(NPath.of(s), session))); + all.addAll(Arrays.asList(searchJdkLocations(NPath.of(s)))); } return all.toArray(new NPlatformLocation[0]); } @@ -189,7 +207,7 @@ public Future searchJdkLocationsFuture() { if (base != null) { all.add(CompletableFuture.completedFuture(new NPlatformLocation[]{base})); } - switch (NEnvs.of().getOsFamily()) { + switch (NWorkspace.get().getOsFamily()) { case LINUX: case UNIX: case UNKNOWN: { @@ -224,20 +242,20 @@ public Future searchJdkLocationsFuture() { }); } - public NPlatformLocation[] searchJdkLocations(NPath loc, NSession session) { + public NPlatformLocation[] searchJdkLocations(NPath loc) { List all = new ArrayList<>(); if (loc.isDirectory()) { for (NPath d : loc.list()) { NPlatformLocation r = resolveJdkLocation(d, null); if (r != null) { all.add(r); - if (session != null && session.isPlainTrace()) { +// if (session != null && session.isPlainTrace()) { // NTexts factory = NTexts.of(session); // session.out().println(NMsg.ofC("detected java %s %s at %s", r.getPackaging(), // factory.ofStyled(r.getVersion(), NutsTextStyle.version()), // factory.ofStyled(r.getPath(), NutsTextStyle.path()) // ); - } +// } } } } @@ -316,7 +334,7 @@ public String detectJdkProvider(String name) { public NPlatformLocation resolveJdkLocation(NPath path, String preferredName) { NAssert.requireNonBlank(path, "path"); - String appSuffix = NEnvs.of().getOsFamily() == NOsFamily.WINDOWS ? ".exe" : ""; + String appSuffix = NWorkspace.get().getOsFamily() == NOsFamily.WINDOWS ? ".exe" : ""; NPath bin = path.resolve("bin"); NPath javaExePath = bin.resolve("java" + appSuffix); if (!javaExePath.isRegularFile()) { @@ -437,9 +455,9 @@ public String resolveJavaCommandByVersion(NPlatformLocation nutsPlatformLocation } String bestJavaPath = nutsPlatformLocation.getPath(); //if (bestJavaPath.contains("/") || bestJavaPath.contains("\\") || bestJavaPath.equals(".") || bestJavaPath.equals("..")) { - NPath file = NPath.of(bestJavaPath).toAbsolute(NLocations.of().getWorkspaceLocation()); + NPath file = NPath.of(bestJavaPath).toAbsolute(NWorkspace.get().getWorkspaceLocation()); //if (file.isDirectory() && file.resolve("bin").isDirectory()) { - boolean winOs = NEnvs.of().getOsFamily() == NOsFamily.WINDOWS; + boolean winOs = NWorkspace.get().getOsFamily() == NOsFamily.WINDOWS; if (winOs) { if (javaw) { bestJavaPath = file.resolve("bin").resolve("javaw.exe").toString(); @@ -455,7 +473,7 @@ public String resolveJavaCommandByVersion(NPlatformLocation nutsPlatformLocation } public String resolveJavaCommandByHome(String javaHome) { - String appSuffix = NEnvs.of().getOsFamily() == NOsFamily.WINDOWS ? ".exe" : ""; + String appSuffix = NWorkspace.get().getOsFamily() == NOsFamily.WINDOWS ? ".exe" : ""; String exe = "java" + appSuffix; if (javaHome == null || javaHome.isEmpty()) { javaHome = System.getProperty("java.home"); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/version/format/DefaultNVersionFormat.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/version/format/DefaultNVersionFormat.java index 7a63e30e9..fa921e9fd 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/version/format/DefaultNVersionFormat.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/version/format/DefaultNVersionFormat.java @@ -4,7 +4,7 @@ import net.thevpc.nuts.NConstants; import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NEnvs; + import net.thevpc.nuts.format.NVersionFormat; import net.thevpc.nuts.io.NPrintStream; import net.thevpc.nuts.io.NTerminalMode; @@ -135,12 +135,11 @@ public Map buildProps() { if (extraProperties != null) { extraKeys = new TreeSet(extraProperties.keySet()); } - NSession session=workspace.currentSession(); - props.put("nuts-api-version", session.getWorkspace().getApiVersion().toString()); - props.put("nuts-runtime-version", session.getWorkspace().getRuntimeId().getVersion().toString()); + props.put("nuts-api-version", workspace.getApiVersion().toString()); + props.put("nuts-runtime-version", workspace.getRuntimeId().getVersion().toString()); if (all) { props.put("java-version", System.getProperty("java.version")); - props.put("os-version", NEnvs.of().getOs().getVersion().toString()); + props.put("os-version", workspace.getOs().getVersion().toString()); } for (String extraKey : extraKeys) { props.put(extraKey, extraProperties.get(extraKey)); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/AbstractNWorkspace.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/AbstractNWorkspace.java index e857315ea..5806d4f3d 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/AbstractNWorkspace.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/AbstractNWorkspace.java @@ -27,10 +27,14 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; import net.thevpc.nuts.reserved.NScopedWorkspace; +import net.thevpc.nuts.runtime.standalone.event.DefaultNWorkspaceEventModel; import net.thevpc.nuts.spi.NSupportLevelContext; import net.thevpc.nuts.util.NCallable; +import net.thevpc.nuts.util.NObservableMapListener; import net.thevpc.nuts.util.NRunnable; +import java.util.List; + /** * Created by vpc on 1/6/17. */ @@ -74,4 +78,79 @@ public void setSharedInstance() { public boolean isSharedInstance() { return NScopedWorkspace.getSharedWorkspaceInstance()==this; } + + /// ////////////////////////////// + + private DefaultNWorkspaceEventModel eventsModel() { + return ((NWorkspaceExt)this).getModel().eventsModel; + } + + @Override + public NWorkspace removeRepositoryListener(NRepositoryListener listener) { + eventsModel().removeRepositoryListener(listener); + return this; + } + + @Override + public NWorkspace addRepositoryListener(NRepositoryListener listener) { + eventsModel().addRepositoryListener(listener); + return this; + } + + @Override + public List getRepositoryListeners() { + return eventsModel().getRepositoryListeners(); + } + + @Override + public NWorkspace addUserPropertyListener(NObservableMapListener listener) { + eventsModel().addUserPropertyListener(listener); + return this; + } + + @Override + public NWorkspace removeUserPropertyListener(NObservableMapListener listener) { + eventsModel().removeUserPropertyListener(listener); + return this; + } + + @Override + public List> getUserPropertyListeners() { + return eventsModel().getUserPropertyListeners(); + } + + @Override + public NWorkspace removeWorkspaceListener(NWorkspaceListener listener) { + eventsModel().removeWorkspaceListener(listener); + return this; + } + + @Override + public NWorkspace addWorkspaceListener(NWorkspaceListener listener) { + eventsModel().addWorkspaceListener(listener); + return this; + } + + @Override + public List getWorkspaceListeners() { + return eventsModel().getWorkspaceListeners(); + } + + @Override + public NWorkspace removeInstallListener(NInstallListener listener) { + eventsModel().removeInstallListener(listener); + return this; + } + + @Override + public NWorkspace addInstallListener(NInstallListener listener) { + eventsModel().addInstallListener(listener); + return this; + } + + @Override + public List getInstallListeners() { + return eventsModel().getInstallListeners(); + } + } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/DefaultNWorkspace.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/DefaultNWorkspace.java index a016a9f2c..86f2e6c83 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/DefaultNWorkspace.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/DefaultNWorkspace.java @@ -25,16 +25,21 @@ package net.thevpc.nuts.runtime.standalone.workspace; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NBootOptions; +import net.thevpc.nuts.NBootOptions; import net.thevpc.nuts.boot.NBootWorkspaceFactory; import net.thevpc.nuts.NConstants; import net.thevpc.nuts.boot.NBootWorkspaceAlreadyExistsException; import net.thevpc.nuts.boot.NBootWorkspaceNotFoundException; import net.thevpc.nuts.NWorkspaceTerminalOptions; -import net.thevpc.nuts.env.*; import net.thevpc.nuts.format.NDescriptorFormat; import net.thevpc.nuts.format.NVersionFormat; +import net.thevpc.nuts.runtime.standalone.boot.DefaultNBootModel; +import net.thevpc.nuts.runtime.standalone.executor.system.NSysExecUtils; +import net.thevpc.nuts.runtime.standalone.repository.config.DefaultNRepositoryModel; import net.thevpc.nuts.runtime.standalone.util.*; +import net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.ndi.NSettingsNdiSubCommand; +import net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.ndi.NdiScriptOptions; +import net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.ndi.SystemNdi; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; @@ -85,13 +90,19 @@ import net.thevpc.nuts.spi.*; import net.thevpc.nuts.util.*; -import java.io.IOException; -import java.io.Writer; +import java.io.*; import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; +import java.time.Duration; import java.time.Instant; import java.util.*; +import java.util.function.Function; +import java.util.function.Predicate; import java.util.logging.Level; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.stream.Collectors; /** @@ -99,6 +110,7 @@ */ @NComponentScope(NScopeType.PROTOTYPE) public class DefaultNWorkspace extends AbstractNWorkspace implements NWorkspaceExt { + public static final Pattern UNIX_USER_DIRS_PATTERN = Pattern.compile("^\\s*(?[A-Z_]+)\\s*=\\s*(?.*)$"); public static final NVersion VERSION_INSTALL_INFO_CONFIG = NVersion.of("0.8.0").get(); public static final NVersion VERSION_SDK_LOCATION = NVersion.of("0.8.0").get(); @@ -190,12 +202,9 @@ private static class InitWorkspaceData { String repositories; NTexts text; NElements elems; - NConfigs config; boolean justInstalled; NWorkspaceArchetypeComponent justInstalledArchetype; - NBootManager _boot; NBootConfig cfg; - NConfigs _config; NIO terminals; } @@ -219,11 +228,10 @@ private void initWorkspace(NBootOptions initialBootOptions0) { } catch (RuntimeException ex) { if (wsModel != null && wsModel.recomm != null) { try { - NSession s = currentSession(); NId runtimeId = getRuntimeId(); String sRuntimeId = runtimeId == null ? NId.ofRuntime("").get().toString() : runtimeId.toString(); this.runWith(() -> { - displayRecommendations(wsModel.recomm.getRecommendations(new RequestQueryInfo(sRuntimeId, ex), NRecommendationPhase.BOOTSTRAP, true), s); + displayRecommendations(wsModel.recomm.getRecommendations(new RequestQueryInfo(sRuntimeId, ex), NRecommendationPhase.BOOTSTRAP, true)); }); } catch (Exception ex2) { //just ignore @@ -257,8 +265,6 @@ private void _preloadWorkspace(InitWorkspaceData data) { this.wsModel.extensionModel.onInitializeWorkspace(data.effectiveBootOptions, bootClassLoader); this.wsModel.textModel.loadExtensions(); - data._config = NConfigs.of(); - data._boot = NBootManager.of(); data.cfg = new NBootConfig(); data.cfg.setWorkspace(workspaceLocation); data.cfg.setApiVersion(this.wsModel.askedApiVersion); @@ -272,7 +278,6 @@ private void _preloadWorkspace(InitWorkspaceData data) { NSystemTerminalBase termb = wsModel.extensions .createComponent(NSystemTerminalBase.class).get(); - data.config = NConfigs.of(); data.terminals = NIO.of(); data.terminals .setSystemTerminal(termb) @@ -301,7 +306,7 @@ private void _preloadWorkspace(InitWorkspaceData data) { wsModel.configModel.setStartCreateTime(data.effectiveBootOptions.getCreationTime().get()); } - boolean exists = NConfigsExt.of(data._config).getModel().isValidWorkspaceFolder(); + boolean exists = NWorkspaceExt.of().getConfigModel().isValidWorkspaceFolder(); NOpenMode openMode = data.effectiveBootOptions.getOpenMode().orNull(); if (openMode != null) { switch (openMode) { @@ -323,8 +328,8 @@ private void _preloadWorkspace(InitWorkspaceData data) { } private void _postCreateWorkspace(InitWorkspaceData data) { - if (!data._config.isReadOnly()) { - data._config.save(false); + if (!isReadOnly()) { + saveConfig(false); } wsModel.configModel.setEndCreateTime(Instant.now()); NSession session = currentSession(); @@ -344,7 +349,7 @@ private void _postCreateWorkspace(InitWorkspaceData data) { } data.justInstalledArchetype.startWorkspace(); DefaultNWorkspaceEvent workspaceCreatedEvent = new DefaultNWorkspaceEvent(session, null, null, null, null); - for (NWorkspaceListener workspaceListener : NEvents.of().getWorkspaceListeners()) { + for (NWorkspaceListener workspaceListener : getWorkspaceListeners()) { workspaceListener.onCreateWorkspace(workspaceCreatedEvent); } } @@ -360,7 +365,7 @@ private void _postCreateWorkspace(InitWorkspaceData data) { .log( NMsg.ofC("%s workspace loaded in %s", NMsg.ofCode("nuts"), - NDuration.ofDuration(data._boot.getCreationDuration()) + NDuration.ofDuration(getCreationDuration()) ) ); if (data.effectiveBootOptions.getSharedInstance().orElse(false)) { @@ -386,15 +391,15 @@ private void _postCreateWorkspace(InitWorkspaceData data) { if (session.isPlainOut()) { session.out().println(NMsg.ofC("%s workspace loaded in %s", NMsg.ofCode("nuts"), - data._boot.getCreationDuration() + getCreationDuration() )); } else { session.eout().add(data.elems.ofObject() .set("workspace-loaded-in", data.elems.ofObject() - .set("ms", data._boot.getCreationDuration().toMillis()) - .set("text", CoreTimeUtils.formatPeriodMilli(data._boot.getCreationDuration())) + .set("ms", this.getCreationDuration().toMillis()) + .set("text", CoreTimeUtils.formatPeriodMilli(this.getCreationDuration())) .build() ) @@ -429,7 +434,7 @@ private void _createWorkspaceNonFirstBoot(InitWorkspaceData data) { .log(NMsg.ofJ("reinstall artifacts failed : {0}", ex)); } } - if (NRepositories.of().getRepositories().isEmpty()) { + if (getRepositories().isEmpty()) { LOG.with().level(Level.CONFIG).verb(NLogVerb.FAIL) .log(NMsg.ofPlain("workspace has no repositories. Will re-create defaults")); data.justInstalledArchetype = initializeWorkspace(effectiveBootOptions.getArchetype().orNull()); @@ -450,7 +455,7 @@ private void _createWorkspaceNonFirstBoot(InitWorkspaceData data) { d.getConfig().setName(NBlankable.isBlank(n) ? ruuid : n); d.getConfig().setStoreStrategy(NStoreStrategy.STANDALONE); } - NRepositories.of().addRepository(d); + addRepository(d); } } @@ -466,7 +471,7 @@ private void _createWorkspaceFirstBoot(InitWorkspaceData data) { LOG.with().level(Level.CONFIG).verb(NLogVerb.SUCCESS) .log(NMsg.ofJ("creating {0} workspace at {1}", data.text.ofStyled("new", NTextStyle.info()), - NLocations.of().getWorkspaceLocation() + this.getWorkspaceLocation() )); NWorkspaceConfigBoot bconfig = new NWorkspaceConfigBoot(); //load from config with resolution applied @@ -506,7 +511,7 @@ private void _createWorkspaceFirstBoot(InitWorkspaceData data) { wsModel.configModel.setCurrentConfig(new DefaultNWorkspaceCurrentConfig(this) .merge(aconfig) .merge(bconfig) - .build(NLocations.of().getWorkspaceLocation())); + .build(this.getWorkspaceLocation())); wsModel.configModel.setConfigBoot(bconfig); wsModel.configModel.setConfigApi(aconfig); wsModel.configModel.setConfigRuntime(rconfig); @@ -515,7 +520,7 @@ private void _createWorkspaceFirstBoot(InitWorkspaceData data) { NArg a = NArg.of(customOption); if (a.getKey().asString().get().startsWith("config.")) { if (a.isActive()) { - data.config.setConfigProperty( + this.setConfigProperty( a.getKey().asString().orElse("").substring("config.".length()), a.getStringValue().orNull() ); @@ -530,7 +535,7 @@ private void _createWorkspaceFirstBoot(InitWorkspaceData data) { } //should install default NSession session = currentSession(); - if (session.isPlainTrace() && !data._boot.getBootOptions().getSkipWelcome().orElse(false)) { + if (session.isPlainTrace() && !this.getBootOptions().getSkipWelcome().orElse(false)) { NPrintStream out = session.out(); out.resetLine(); StringBuilder version = new StringBuilder(nutsVersion.toString()); @@ -548,7 +553,7 @@ private void _createWorkspaceFirstBoot(InitWorkspaceData data) { data.text.ofBuilder() .append("location", NTextStyle.underlined()) .append(":") - .append(NLocations.of().getWorkspaceLocation()) + .append(this.getWorkspaceLocation()) .append(" ") ); } else { @@ -556,7 +561,7 @@ private void _createWorkspaceFirstBoot(InitWorkspaceData data) { data.text.ofBuilder() .append("location", NTextStyle.underlined()) .append(":") - .append(NLocations.of().getWorkspaceLocation()) + .append(this.getWorkspaceLocation()) .append(" ") .append(" (") .append(getHashName()) @@ -689,7 +694,7 @@ private void _initLog(InitWorkspaceData data) { : NTextUtils.desc(text.of(NCmdLine.of(System.getProperty("nuts.args"), NShellFamily.SH)), text) )); LOGCRF.log(NMsg.ofJ(" nuts-open-mode : {0}", NTextUtils.formatLogValue(text, effectiveBootOptions.getOpenMode().orNull(), effectiveBootOptions.getOpenMode().orElse(NOpenMode.OPEN_OR_CREATE)))); - NEnvs senvs = NEnvs.of(); + NWorkspace senvs = this; LOGCRF.log(NMsg.ofJ(" java-home : {0}", System.getProperty("java.home"))); LOGCRF.log(NMsg.ofJ(" java-classpath : {0}", System.getProperty("java.class.path"))); LOGCRF.log(NMsg.ofJ(" java-library-path : {0}", System.getProperty("java.library.path"))); @@ -721,12 +726,10 @@ private void _initLog(InitWorkspaceData data) { } - private void displayRecommendations(Object r, NSession s) { - if (s != null) { - Map a = new HashMap<>(); - a.put("recommendations", r); - s.out().println(a); - } + private void displayRecommendations(Object r) { + Map a = new HashMap<>(); + a.put("recommendations", r); + NSession.get().out().println(a); } private URL getApiURL() { @@ -911,9 +914,9 @@ protected NWorkspaceArchetypeComponent initializeWorkspace(String archetype) { NWorkspaceSecurityManager.of().updateUser(NConstants.Users.ADMIN).setCredentials("admin".toCharArray()).run(); instance.initializeWorkspace(); - NConfigs nConfigs = NConfigs.of(); - if (!nConfigs.isReadOnly()) { - nConfigs.save(); + NWorkspace envs = this; + if (!envs.isReadOnly()) { + envs.saveConfig(); } return instance; } @@ -969,7 +972,7 @@ public void installOrUpdateImpl(NDefinition def, String[] args, boolean resolveI // reload def NFetchCmd fetch2 = NFetchCmd.of(def.getId()) .content() - .setRepositoryFilter(NRepositories.of().filter().installedRepo()) + .setRepositoryFilter(NRepositoryFilters.of().installedRepo()) .failFast(); if (def.getDependencies().isPresent()) { fetch2.setDependencyFilter(def.getDependencies().get().filter()); @@ -1070,7 +1073,7 @@ public void installOrUpdateImpl(NDefinition def, String[] args, boolean resolveI } } out.flush(); - NConfigs config = NConfigs.of(); + NWorkspace envs = this; if (def.getContent().isPresent() || NDescriptorUtils.isNoContent(def.getDescriptor())) { if (requireParents) { List requiredDefinitions = new ArrayList<>(); @@ -1159,7 +1162,7 @@ public void installOrUpdateImpl(NDefinition def, String[] args, boolean resolveI //now should reload definition NFetchCmd fetch2 = NFetchCmd.of(executionContext.getDefinition().getId()) .content() - .setRepositoryFilter(NRepositories.of().filter().installedRepo()) + .setRepositoryFilter(NRepositoryFilters.of().installedRepo()) .failFast(); if (def.getDependencies().isPresent()) { fetch2.setDependencyFilter(def.getDependencies().get().filter()); @@ -1171,7 +1174,7 @@ public void installOrUpdateImpl(NDefinition def, String[] args, boolean resolveI //update definition in the execution context cc.setDefinition(def2); executionContext = cc.build(); - NRepository rep = NRepositories.of().findRepository(def.getRepositoryUuid()).orNull(); + NRepository rep = findRepository(def.getRepositoryUuid()).orNull(); remoteRepo = rep == null || rep.isRemote(); if (strategy0 == InstallStrategy0.REQUIRE) { // @@ -1258,10 +1261,9 @@ public void installOrUpdateImpl(NDefinition def, String[] args, boolean resolveI } if (def.getDescriptor().getIdType() == NIdType.EXTENSION) { - NConfigsExt wcfg = NConfigsExt.of(config); NExtensionListHelper h = new NExtensionListHelper( session.getWorkspace().getApiId(), - wcfg.getModel().getStoredConfigBoot().getExtensions()) + this.getConfigModel().getStoredConfigBoot().getExtensions()) .save(); NDependencies nDependencies = null; if (!def.getDependencies().isPresent()) { @@ -1271,8 +1273,8 @@ public void installOrUpdateImpl(NDefinition def, String[] args, boolean resolveI nDependencies = def.getDependencies().get(); } h.add(def.getId(), nDependencies.transitiveWithSource().toList()); - wcfg.getModel().getStoredConfigBoot().setExtensions(h.getConfs()); - wcfg.getModel().fireConfigurationChanged("extensions", ConfigEventType.BOOT); + this.getConfigModel().getStoredConfigBoot().setExtensions(h.getConfs()); + this.getConfigModel().fireConfigurationChanged("extensions", ConfigEventType.BOOT); } } catch (RuntimeException ex) { try { @@ -1398,7 +1400,7 @@ public void installOrUpdateImpl(NDefinition def, String[] args, boolean resolveI public String resolveCommandName(NId id) { String nn = id.getArtifactId(); - NCommands aliases = NCommands.of(); + NWorkspace aliases = this; NCustomCmd c = aliases.findCommand(nn); if (c != null) { if (CoreFilterUtils.matchesSimpleNameStaticVersion(c.getOwner(), id)) { @@ -1441,8 +1443,7 @@ protected boolean loadWorkspace(List excludedExtensions, String[] exclud NFetchCmd.of() ); } - NUserConfig adminSecurity = NConfigsExt.of(NConfigs.of()) - .getModel() + NUserConfig adminSecurity = getConfigModel() .getUser(NConstants.Users.ADMIN); if (adminSecurity == null || NBlankable.isBlank(adminSecurity.getCredentials())) { if (LOG.isLoggable(Level.CONFIG)) { @@ -1453,16 +1454,16 @@ protected boolean loadWorkspace(List excludedExtensions, String[] exclud .updateUser(NConstants.Users.ADMIN).credentials("admin".toCharArray()) .run(); } - for (NCommandFactoryConfig commandFactory : NCommands.of().getCommandFactories()) { + for (NCommandFactoryConfig commandFactory : this.getCommandFactories()) { try { - NCommands.of().addCommandFactory(commandFactory); + this.addCommandFactory(commandFactory); } catch (Exception e) { LOG.with().level(Level.SEVERE).verb(NLogVerb.FAIL) .log(NMsg.ofJ("unable to instantiate Command Factory {0}", commandFactory)); } } DefaultNWorkspaceEvent workspaceReloadedEvent = new DefaultNWorkspaceEvent(currentSession(), null, null, null, null); - for (NWorkspaceListener listener : NEvents.of().getWorkspaceListeners()) { + for (NWorkspaceListener listener : getWorkspaceListeners()) { listener.onReloadWorkspace(workspaceReloadedEvent); } //if save is needed, will be applied @@ -1690,37 +1691,36 @@ public void uninstallImpl(NDefinition def, String[] args, getInstalledRepository().uninstall(def); NId id = def.getId(); if (deleteFiles) { - if (NLocations.of().getStoreLocation(id, NStoreType.BIN).exists()) { - NLocations.of().getStoreLocation(id, NStoreType.BIN).deleteTree(); + if (this.getStoreLocation(id, NStoreType.BIN).exists()) { + this.getStoreLocation(id, NStoreType.BIN).deleteTree(); } - if (NLocations.of().getStoreLocation(id, NStoreType.LIB).exists()) { - NLocations.of().getStoreLocation(id, NStoreType.LIB).deleteTree(); + if (this.getStoreLocation(id, NStoreType.LIB).exists()) { + this.getStoreLocation(id, NStoreType.LIB).deleteTree(); } - if (NLocations.of().getStoreLocation(id, NStoreType.LOG).exists()) { - NLocations.of().getStoreLocation(id, NStoreType.LOG).deleteTree(); + if (this.getStoreLocation(id, NStoreType.LOG).exists()) { + this.getStoreLocation(id, NStoreType.LOG).deleteTree(); } - if (NLocations.of().getStoreLocation(id, NStoreType.CACHE).exists()) { - NLocations.of().getStoreLocation(id, NStoreType.CACHE).deleteTree(); + if (this.getStoreLocation(id, NStoreType.CACHE).exists()) { + this.getStoreLocation(id, NStoreType.CACHE).deleteTree(); } if (eraseFiles) { - if (NLocations.of().getStoreLocation(id, NStoreType.VAR).exists()) { - NLocations.of().getStoreLocation(id, NStoreType.VAR).deleteTree(); + if (this.getStoreLocation(id, NStoreType.VAR).exists()) { + this.getStoreLocation(id, NStoreType.VAR).deleteTree(); } - if (NLocations.of().getStoreLocation(id, NStoreType.CONF).exists()) { - NLocations.of().getStoreLocation(id, NStoreType.CONF).deleteTree(); + if (this.getStoreLocation(id, NStoreType.CONF).exists()) { + this.getStoreLocation(id, NStoreType.CONF).deleteTree(); } } } if (def.getDescriptor().getIdType() == NIdType.EXTENSION) { - NConfigsExt wcfg = NConfigsExt.of(NConfigs.of()); NExtensionListHelper h = new NExtensionListHelper( this.getApiId(), - wcfg.getModel().getStoredConfigBoot().getExtensions()) + this.getConfigModel().getStoredConfigBoot().getExtensions()) .save(); h.remove(id); - wcfg.getModel().getStoredConfigBoot().setExtensions(h.getConfs()); - wcfg.getModel().fireConfigurationChanged("extensions", ConfigEventType.BOOT); + this.getConfigModel().getStoredConfigBoot().setExtensions(h.getConfs()); + this.getConfigModel().fireConfigurationChanged("extensions", ConfigEventType.BOOT); } if (traceBeforeEvent && NSession.get().isPlainTrace()) { out.println(NMsg.ofC("%s uninstalled %s", id, NText.ofStyled( @@ -1755,7 +1755,7 @@ public boolean requiresRuntimeExtension() { @Override public NDescriptor resolveEffectiveDescriptor(NDescriptor descriptor) { NPath eff = null; - NLocations loc = NLocations.of(); + NWorkspace loc = this; if (!descriptor.getId().getVersion().isBlank() && descriptor.getId().getVersion().isSingleValue() && descriptor.getId().toString().indexOf('$') < 0) { NPath l = loc.getStoreLocation(descriptor.getId(), NStoreType.CACHE); @@ -1779,7 +1779,7 @@ public NDescriptor resolveEffectiveDescriptor(NDescriptor descriptor) { NDescriptor effectiveDescriptor = _resolveEffectiveDescriptor(descriptor); NDescriptorUtils.checkValidEffectiveDescriptor(effectiveDescriptor); if (eff == null) { - NPath l = NLocations.of().getStoreLocation(effectiveDescriptor.getId(), NStoreType.CACHE); + NPath l = this.getStoreLocation(effectiveDescriptor.getId(), NStoreType.CACHE); String nn = loc.getDefaultIdFilename(effectiveDescriptor.getId().builder().setFace("eff-nuts.cache").build()); eff = l.resolve(nn); } @@ -1828,7 +1828,7 @@ public NExecutionContextBuilder createExecutionContext() { .setWorkspace(this) .setDry(session.isDry()) .setBot(session.isBot()) - .setExecutionType(NBootManager.of().getBootOptions().getExecutionType().orNull()) + .setExecutionType(this.getBootOptions().getExecutionType().orNull()) ; } @@ -1854,15 +1854,15 @@ public void deployBoot(NId id, boolean withDependencies) { } } for (NDefinition def : defs.values()) { - NPath bootstrapFolder = NLocations.of().getStoreLocation(NStoreType.LIB).resolve(NConstants.Folders.ID); + NPath bootstrapFolder = this.getStoreLocation(NStoreType.LIB).resolve(NConstants.Folders.ID); NId id2 = def.getId(); NCp.of().from(def.getContent().get()) - .to(bootstrapFolder.resolve(NLocations.of().getDefaultIdBasedir(id2)) - .resolve(NLocations.of().getDefaultIdFilename(id2.builder().setFaceContent().setPackaging("jar").build())) + .to(bootstrapFolder.resolve(this.getDefaultIdBasedir(id2)) + .resolve(this.getDefaultIdFilename(id2.builder().setFaceContent().setPackaging("jar").build())) ).run(); NDescriptorFormat.of(NFetchCmd.of(id2).getResultDescriptor()).setNtf(false) - .print(bootstrapFolder.resolve(NLocations.of().getDefaultIdBasedir(id2)) - .resolve(NLocations.of().getDefaultIdFilename(id2.builder().setFaceDescriptor().build()))); + .print(bootstrapFolder.resolve(this.getDefaultIdBasedir(id2)) + .resolve(this.getDefaultIdFilename(id2.builder().setFaceDescriptor().build()))); Map pr = new LinkedHashMap<>(); pr.put("file.updated.date", Instant.now().toString()); @@ -1888,7 +1888,7 @@ public void deployBoot(NId id, boolean withDependencies) { ) ); - try (Writer writer = bootstrapFolder.resolve(NLocations.of().getDefaultIdBasedir(def.getId().getLongId())) + try (Writer writer = bootstrapFolder.resolve(this.getDefaultIdBasedir(def.getId().getLongId())) .resolve("nuts.properties").getWriter() ) { CoreIOUtils.storeProperties(pr, writer, false); @@ -1958,7 +1958,7 @@ public NSession createSession() { return callWith(() -> { NSession nSession = new DefaultNSession(this); nSession.setTerminal(NTerminal.of()); - nSession.setExpireTime(NBootManager.of().getBootOptions().getExpireTime().orNull()); + nSession.setExpireTime(this.getBootOptions().getExpireTime().orNull()); return nSession; }); } @@ -1967,8 +1967,8 @@ public DefaultNWorkspaceEnvManagerModel getEnvModel() { return wsModel.envModel; } - public DefaultCustomCommandsModel getAliasesModel() { - return wsModel.aliasesModel; + public DefaultCustomCommandsModel getCommandModel() { + return wsModel.commandModel; } public DefaultNWorkspaceConfigModel getConfigModel() { @@ -2035,4 +2035,784 @@ public String id() { } } + public DefaultNRepositoryModel getRepositoryModel(){ + return wsModel.repositoryModel; + } + + + @Override + public List getRepositories() { + return Arrays.stream(getRepositoryModel().getRepositories()) + .collect(Collectors.toList()); + } + + @Override + public NOptional findRepositoryById(String repositoryNameOrId) { + return getRepositoryModel().findRepositoryById(repositoryNameOrId); + } + + @Override + public NOptional findRepositoryByName(String repositoryNameOrId) { + return getRepositoryModel().findRepositoryByName(repositoryNameOrId); + } + + @Override + public NOptional findRepository(String repositoryNameOrId) { + return getRepositoryModel().findRepository(repositoryNameOrId); + } + + @Override + public NWorkspace removeRepository(String repositoryId) { + getRepositoryModel().removeRepository(repositoryId); + return this; + } + + @Override + public NWorkspace removeAllRepositories() { + getRepositoryModel().removeAllRepositories(); + return this; + } + + @Override + public NRepository addRepository(NAddRepositoryOptions options) { + return getRepositoryModel().addRepository(options); + } + + @Override + public NRepository addRepository(String repositoryNamedUrl) { + return getRepositoryModel().addRepository(repositoryNamedUrl); + } + + + /// //////////////////////////// + + public DefaultNWorkspaceLocationModel getLocationsModel() { + return wsModel.locationsModel; + } + + public DefaultNPlatformModel getSdkModel() { + return wsModel.sdkModel; + } + + + @Override + public Map getProperties() { + return getEnvModel().getProperties(); + } + + @Override + public NOptional getProperty(String property) { + return getEnvModel().getProperty(property); + } + + @Override + public NWorkspace setProperty(String property, Object value) { + getEnvModel().setProperty(property, value); + return this; + } + + @Override + public NOsFamily getOsFamily() { +// checkSession(); + return getEnvModel().getOsFamily(); + } + + @Override + public String getHostName() { + return getEnvModel().getHostName(); + } + + @Override + public String getPid() { + return getEnvModel().getPid(); + } + + @Override + public Set getShellFamilies() { + return getEnvModel().getShellFamilies(); + } + + @Override + public NShellFamily getShellFamily() { + return getEnvModel().getShellFamily(); + } + + @Override + public NId getDesktopEnvironment() { + return getDesktopEnvironments().stream().findFirst().get(); + } + + @Override + public Set getDesktopEnvironments() { + return getEnvModel().getDesktopEnvironments(); + } + + @Override + public NDesktopEnvironmentFamily getDesktopEnvironmentFamily() { + return getEnvModel().getDesktopEnvironmentFamily(); + } + + @Override + public Set getDesktopEnvironmentFamilies() { + return getEnvModel().getDesktopEnvironmentFamilies(); + } + + @Override + public NId getPlatform() { +// checkSession(); + return getEnvModel().getPlatform(); + } + + @Override + public NId getOs() { +// checkSession(); + return getEnvModel().getOs(); + } + + public NId getOsDist() { +// checkSession(); + return getEnvModel().getOsDist(); + } + + @Override + public NId getArch() { +// checkSession(); + return getEnvModel().getArch(); + } + + @Override + public NArchFamily getArchFamily() { +// checkSession(); + return getEnvModel().getArchFamily(); + } + + @Override + public boolean isGraphicalDesktopEnvironment() { + return getEnvModel().isGraphicalDesktopEnvironment(); + } + + @Override + public NSupportMode getDesktopIntegrationSupport(NDesktopIntegrationItem item) { + NAssert.requireNonBlank(item, "item"); + switch (item) { + case DESKTOP: { + NSupportMode a = this.getBootOptions().getDesktopLauncher().orNull(); + if (a != null) { + return a; + } + break; + } + case MENU: { + NSupportMode a = this.getBootOptions().getMenuLauncher().orNull(); + if (a != null) { + return a; + } + break; + } + case USER: { + NSupportMode a = this.getBootOptions().getUserLauncher().orNull(); + if (a != null) { + return a; + } + break; + } + } + switch (getOsFamily()) { + case LINUX: { + switch (item) { + case DESKTOP: { + return NSupportMode.SUPPORTED; + } + case MENU: { + return NSupportMode.PREFERRED; + } + case USER: { + return NSupportMode.PREFERRED; + } + } + break; + } + case UNIX: { + return NSupportMode.NEVER; + } + case WINDOWS: { + switch (item) { + case DESKTOP: { + if (Files.isDirectory(getDesktopPath())) { + return NSupportMode.PREFERRED; + } + return NSupportMode.SUPPORTED; + } + case MENU: { + return NSupportMode.PREFERRED; + } + case USER: { + return NSupportMode.PREFERRED; + } + } + break; + } + case MACOS: { + return NSupportMode.NEVER; + } + case UNKNOWN: { + return NSupportMode.NEVER; + } + } + return NSupportMode.NEVER; + } + + public Path getDesktopPath() { + switch (getOsFamily()) { + case LINUX: + case UNIX: + case MACOS: { + File f = new File(System.getProperty("user.home"), ".config/user-dirs.dirs"); + if (f.exists()) { + try (BufferedReader r = new BufferedReader(new FileReader(f))) { + String line; + while ((line = r.readLine()) != null) { + line = line.trim(); + if (line.startsWith("#")) { + //ignore + } else { + Matcher m = UNIX_USER_DIRS_PATTERN.matcher(line); + if (m.find()) { + String k = m.group("k"); + if (k.equals("XDG_DESKTOP_DIR")) { + String v = m.group("v"); + v = v.trim(); + if (v.startsWith("\"")) { + int last = v.indexOf('\"', 1); + String s = v.substring(1, last); + s = s.replace("$HOME", System.getProperty("user.home")); + return Paths.get(s); + } else { + return Paths.get(v); + } + } + } else { + //this is unexpected format! + break; + } + } + } + } catch (IOException ex) { + //ignore + } + } + return new File(System.getProperty("user.home"), "Desktop").toPath(); + } + case WINDOWS: { + return new File(System.getProperty("user.home"), "Desktop").toPath(); + } + default: { + return new File(System.getProperty("user.home"), "Desktop").toPath(); + } + } + } + + public void addLauncher(NLauncherOptions launcher) { + //apply isolation! + NIsolationLevel isolation = this.getBootOptions().getIsolationLevel().orElse(NIsolationLevel.SYSTEM); + if (isolation.compareTo(NIsolationLevel.CONFINED) >= 0) { + launcher.setCreateDesktopLauncher(NSupportMode.NEVER); + launcher.setCreateMenuLauncher(NSupportMode.NEVER); + launcher.setCreateUserLauncher(NSupportMode.NEVER); + launcher.setSwitchWorkspace(false); + launcher.setSwitchWorkspaceLocation(null); + } + SystemNdi ndi = NSettingsNdiSubCommand.createNdi(this.getEnvModel().getWorkspace()); + if (ndi != null) { + ndi.addScript( + new NdiScriptOptions() + .setLauncher(launcher.copy()), + new String[]{launcher.getId().builder().getFullName()} + ); + } + } + + @Override + public List buildEffectiveCommand(String[] cmd, NRunAs runAsMode, Set de, Function sysWhich, Boolean gui, String rootName, String userName, String[] executorOptions) { + return NSysExecUtils.buildEffectiveCommand(cmd, runAsMode, de, sysWhich, gui, rootName, userName, executorOptions); + } + + @Override + public NPath getHomeLocation(NStoreType folderType) { + return getLocationModel().getHomeLocation(folderType); + } + + public DefaultNWorkspaceLocationModel getLocationModel() { + return NWorkspaceExt.of().getModel().locationsModel; + } + + + @Override + public NPath getStoreLocation(NStoreType folderType) { + return getLocationModel().getStoreLocation(folderType); + } + + @Override + public NPath getStoreLocation(NId id, NStoreType folderType) { + return getLocationModel().getStoreLocation(id, folderType); + } + + @Override + public NPath getStoreLocation(NStoreType folderType, String repositoryIdOrName) { + return getLocationModel().getStoreLocation(folderType, repositoryIdOrName); + } + + @Override + public NPath getStoreLocation(NId id, NStoreType folderType, String repositoryIdOrName) { + return getLocationModel().getStoreLocation(id, folderType, repositoryIdOrName); + } + + @Override + public NStoreStrategy getStoreStrategy() { + return getLocationModel().getStoreStrategy(); + } + + @Override + public NStoreStrategy getRepositoryStoreStrategy() { + return getLocationModel().getRepositoryStoreStrategy(); + } + + @Override + public NOsFamily getStoreLayout() { + return getLocationModel().getStoreLayout(); + } + + @Override + public Map getStoreLocations() { + return getLocationModel().getStoreLocations(); + } + + @Override + public String getDefaultIdFilename(NId id) { + return getLocationModel().getDefaultIdFilename(id); + } + + @Override + public NPath getDefaultIdBasedir(NId id) { + return getLocationModel().getDefaultIdBasedir(id); + } + + @Override + public String getDefaultIdContentExtension(String packaging) { + return getLocationModel().getDefaultIdContentExtension(packaging); + } + + @Override + public String getDefaultIdExtension(NId id) { + return getLocationModel().getDefaultIdExtension(id); + } + + @Override + public Map getHomeLocations() { + return getLocationModel().getHomeLocations(); + } + + @Override + public NPath getHomeLocation(NHomeLocation location) { + return getLocationModel().getHomeLocation(location); + } + + @Override + public NPath getWorkspaceLocation() { + return getLocationModel().getWorkspaceLocation(); + } + + @Override + public NWorkspace setStoreLocation(NStoreType folderType, String location) { + getLocationModel().setStoreLocation(folderType, location); + return this; + } + + + @Override + public NWorkspace setStoreStrategy(NStoreStrategy strategy) { + getLocationModel().setStoreStrategy(strategy); + return this; + } + + @Override + public NWorkspace setStoreLayout(NOsFamily storeLayout) { + getLocationModel().setStoreLayout(storeLayout); + return this; + } + + @Override + public NWorkspace setHomeLocation(NHomeLocation homeType, String location) { + getLocationModel().setHomeLocation(homeType, location); + return this; + } + + /// //////////// + + + + + @Override + public boolean addPlatform(NPlatformLocation location) { + return getSdkModel().addPlatform(location); + } + + @Override + public boolean updatePlatform(NPlatformLocation oldLocation, NPlatformLocation newLocation) { + return getSdkModel().updatePlatform(oldLocation, newLocation); + } + + @Override + public boolean removePlatform(NPlatformLocation location) { + return getSdkModel().removePlatform(location); + } + + @Override + public NOptional findPlatformByName(NPlatformFamily platformType, String locationName) { + return getSdkModel().findPlatformByName(platformType, locationName); + } + + @Override + public NOptional findPlatformByPath(NPlatformFamily platformType, NPath path) { + return getSdkModel().findPlatformByPath(platformType, path); + } + + @Override + public NOptional findPlatformByVersion(NPlatformFamily platformType, String version) { + return getSdkModel().findPlatformByVersion(platformType, version); + } + + @Override + public NOptional findPlatform(NPlatformLocation location) { + return getSdkModel().findPlatform(location); + } + + @Override + public NOptional findPlatformByVersion(NPlatformFamily platformType, NVersionFilter requestedVersion) { + return getSdkModel().findPlatformByVersion(platformType, requestedVersion); + } + + @Override + public NStream searchSystemPlatforms(NPlatformFamily platformFamily) { + return getSdkModel().searchSystemPlatforms(platformFamily); + } + + @Override + public NStream searchSystemPlatforms(NPlatformFamily platformFamily, NPath path) { + return getSdkModel().searchSystemPlatforms(platformFamily, path); + } + + @Override + public NOptional resolvePlatform(NPlatformFamily platformFamily, NPath path, String preferredName) { + return getSdkModel().resolvePlatform(platformFamily, path, preferredName); + } + + @Override + public NOptional findPlatform(NPlatformFamily platformFamily, Predicate filter) { + return getSdkModel().findOnePlatform(platformFamily, filter); + } + + @Override + public NStream findPlatforms(NPlatformFamily platformFamily, Predicate filter) { + return getSdkModel().findPlatforms(platformFamily, filter); + } + + @Override + public NStream findPlatforms() { + return findPlatforms(null,null); + } + + @Override + public NWorkspace addDefaultPlatforms(NPlatformFamily type) { + if(type==NPlatformFamily.JAVA) { + NWorkspaceUtils.of(this).installAllJVM(); + } + return this; + } + + @Override + public NWorkspace addDefaultPlatform(NPlatformFamily type) { + if(type==NPlatformFamily.JAVA) { + //at least add current vm + NWorkspaceUtils.of(this).installCurrentJVM(); + } + return this; + } + + @Override + public NStream findPlatforms(NPlatformFamily type) { + return getSdkModel().findPlatforms(type, null); + } + + @Override + public NWorkspace addImports(String... importExpressions) { + getImportModel().add(importExpressions); + return this; + } + + + @Override + public NWorkspace clearImports() { + getImportModel().removeAll(); + return this; + } + + @Override + public NWorkspace removeImports(String... importExpressions) { + getImportModel().remove(importExpressions); + return this; + } + + @Override + public NWorkspace updateImports(String[] imports) { + getImportModel().set(imports); + return this; + } + + @Override + public boolean isImportedGroupId(String groupId) { + return getImportModel().isImportedGroupId(groupId); + } + + @Override + public Set getAllImports() { + return getImportModel().getAll(); + } + + /// //////////////////////////////////// + + + @Override + public NWorkspaceStoredConfig getStoredConfig() { + return getConfigModel().stored(); + } + + @Override + public boolean isReadOnly() { + return getConfigModel().isReadOnly(); + } + + @Override + public boolean saveConfig(boolean force) { + return getConfigModel().save(force); + } + + @Override + public boolean saveConfig() { + return getConfigModel().save(); + } + + @Override + public NWorkspaceBootConfig loadBootConfig(String _ws, boolean global, boolean followLinks) { + return getConfigModel().loadBootConfig(_ws, global, followLinks); + } + + @Override + public boolean isSupportedRepositoryType(String repositoryType) { + return getConfigModel().isSupportedRepositoryType(repositoryType); + } + + @Override + public List getDefaultRepositories() { + return getConfigModel().getDefaultRepositories(); + } + + @Override + public Set getAvailableArchetypes() { + return getConfigModel().getAvailableArchetypes(); + } + + @Override + public NPath resolveRepositoryPath(String repositoryLocation) { + return getConfigModel().resolveRepositoryPath(NPath.of(repositoryLocation)); + } + + @Override + public NIndexStoreFactory getIndexStoreClientFactory() { + return getConfigModel().getIndexStoreClientFactory(); + } + + @Override + public String getJavaCommand() { + return getConfigModel().getJavaCommand(); + } + + @Override + public String getJavaOptions() { + return getConfigModel().getJavaOptions(); + } + + @Override + public boolean isSystemWorkspace() { + return getConfigModel().isSystem(); + } + + public List getDependencySolverNames() { + return getConfigModel().getDependencySolverNames(); + } + + public NDependencySolver createDependencySolver(String name) { + return getConfigModel().createDependencySolver(name); + } + + @Override + public Map getConfigMap() { + return getConfigModel().getConfigMap(); + } + + @Override + public NOptional getConfigProperty(String property) { + return getConfigModel().getConfigProperty(property); + } + + @Override + public NWorkspace setConfigProperty(String property, String value) { + getConfigModel().setConfigProperty(property, value); + getConfigModel().save(); + return this; + } + + /// /////////////////// + + @Override + public List getCommandFactories() { + return Arrays.asList(getCommandModel().getFactories()); + } + + @Override + public void addCommandFactory(NCommandFactoryConfig commandFactoryConfig) { + getCommandModel().addFactory(commandFactoryConfig); + } + + @Override + public void removeCommandFactory(String commandFactoryId) { + getCommandModel().removeFactory(commandFactoryId); + } + + @Override + public boolean removeCommandFactoryIfExists(String commandFactoryId) { + return getCommandModel().removeFactoryIfExists(commandFactoryId); + } + + @Override + public boolean commandExists(String command) { + return findCommand(command) != null; + } + + @Override + public boolean commandFactoryExists(String factoryId) { + return getCommandModel().commandFactoryExists(factoryId); + } + + @Override + public boolean addCommand(NCommandConfig command) { + return getCommandModel().add(command); + } + + @Override + public boolean updateCommand(NCommandConfig command) { + return getCommandModel().update(command); + } + + @Override + public void removeCommand(String command) { + getCommandModel().remove(command); + } + + @Override + public boolean removeCommandIfExists(String name) { + if (getCommandModel().find(name) != null) { + getCommandModel().remove(name); + return true; + } + return false; + } + + @Override + public NCustomCmd findCommand(String name, NId forId, NId forOwner) { + return getCommandModel().find(name, forId, forOwner); + } + + @Override + public NCustomCmd findCommand(String name) { + return getCommandModel().find(name); + } + + @Override + public List findAllCommands() { + return getCommandModel().findAll(); + } + + @Override + public List findCommandsByOwner(NId id) { + return getCommandModel().findByOwner(id); + } + + + /// /////////////////////// + + + public DefaultNBootModel getBootModel() { + return NWorkspaceExt.of().getModel().bootModel; + } + + @Override + public boolean isFirstBoot() { + return getBootModel().isFirstBoot(); + } + + @Override + public NOptional getCustomBootOption(String... names) { + return getBootModel().getCustomBootOption(names); + } + + + @Override + public NBootOptions getBootOptions() { + return getConfigModel().getBootModel().getBootEffectiveOptions(); + } + + @Override + public ClassLoader getBootClassLoader() { + return getConfigModel().getBootClassLoader(); + } + + @Override + public List getBootClassWorldURLs() { + return Collections.unmodifiableList(getConfigModel().getBootClassWorldURLs()); + } + + @Override + public String getBootRepositories() { + return getConfigModel().getBootRepositories(); + } + + @Override + public Instant getCreationStartTime() { + return getConfigModel().getCreationStartTime(); + } + + @Override + public Instant getCreationFinishTime() { + return getConfigModel().getCreationFinishTime(); + } + + @Override + public Duration getCreationDuration() { + return getConfigModel().getCreateDuration(); + } + + public NClassLoaderNode getBootRuntimeClassLoaderNode() { + return getBootModel().getBootUserOptions().getRuntimeBootDependencyNode().get(); + } + + public List getBootExtensionClassLoaderNode() { + return getBootModel().getBootUserOptions().getExtensionBootDependencyNodes().orElseGet(Collections::emptyList); + } + + @Override + public NWorkspaceTerminalOptions getBootTerminal() { + return getBootModel().getBootTerminal(); + } + } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/DefaultNWorkspaceFactory.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/DefaultNWorkspaceFactory.java index 44ca8a984..ba1bc570f 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/DefaultNWorkspaceFactory.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/DefaultNWorkspaceFactory.java @@ -26,23 +26,20 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.elem.NElementNotFoundException; -import net.thevpc.nuts.env.NImports; + import net.thevpc.nuts.ext.NFactoryException; import net.thevpc.nuts.format.NFormats; import net.thevpc.nuts.format.NPositionType; import net.thevpc.nuts.format.NVersionFormat; -import net.thevpc.nuts.io.NContentTypes; import net.thevpc.nuts.reserved.rpi.NCollectionsRPI; import net.thevpc.nuts.reserved.rpi.NIORPI; import net.thevpc.nuts.runtime.standalone.*; -import net.thevpc.nuts.runtime.standalone.boot.DefaultNBootManager; import net.thevpc.nuts.runtime.standalone.elem.DefaultNElements; import net.thevpc.nuts.runtime.standalone.format.DefaultNObjectFormat; import net.thevpc.nuts.runtime.standalone.format.NFormatsImpl; import net.thevpc.nuts.runtime.standalone.id.format.DefaultNIdFormat; import net.thevpc.nuts.runtime.standalone.io.inputstream.DefaultNIO; import net.thevpc.nuts.runtime.standalone.io.inputstream.DefaultNIORPI; -import net.thevpc.nuts.runtime.standalone.io.path.DefaultNPaths; import net.thevpc.nuts.runtime.standalone.log.DefaultNLogs; import net.thevpc.nuts.runtime.standalone.text.DefaultNTexts; import net.thevpc.nuts.runtime.standalone.util.CoreNUtils; @@ -53,12 +50,8 @@ import net.thevpc.nuts.runtime.standalone.version.format.DefaultNVersionFormat; import net.thevpc.nuts.runtime.standalone.web.DefaultNWebCli; import net.thevpc.nuts.runtime.standalone.workspace.cmd.exec.DefaultNExecCmd; -import net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNImports; -import net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNConfigs; -import net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNEnvs; import net.thevpc.nuts.runtime.standalone.workspace.factorycache.CachedConstructor; import net.thevpc.nuts.runtime.standalone.workspace.factorycache.NBeanCache; -import net.thevpc.nuts.runtime.standalone.xtra.contenttype.DefaultNContentTypes; import net.thevpc.nuts.runtime.standalone.xtra.digest.DefaultNDigest; import net.thevpc.nuts.io.NDigest; import net.thevpc.nuts.runtime.standalone.xtra.execentries.DefaultNLibPaths; @@ -129,18 +122,10 @@ public NOptional createComponent(Class type, Object DefaultNLogs p = session.getOrComputeProperty("fallback::" + type.getName(), NScopeType.SESSION, () -> new DefaultNLogs(session)); return NOptional.of((T) p); } - case "net.thevpc.nuts.io.NPaths": { - DefaultNPaths p = session.getOrComputeProperty("fallback::" + type.getName(), NScopeType.SESSION, () -> new DefaultNPaths(workspace)); - return NOptional.of((T) p); - } case "net.thevpc.nuts.text.NTexts": { DefaultNTexts p = session.getOrComputeProperty("fallback::" + type.getName(), NScopeType.SESSION, () -> new DefaultNTexts(workspace)); return NOptional.of((T) p); } - case "net.thevpc.nuts.env.NEnvs": { - DefaultNEnvs p = session.getOrComputeProperty("fallback::" + type.getName(), NScopeType.SESSION, () -> new DefaultNEnvs(workspace)); - return NOptional.of((T) p); - } case "net.thevpc.nuts.format.NObjectFormat": { DefaultNObjectFormat p = session.getOrComputeProperty("fallback::" + type.getName(), NScopeType.SESSION, () -> new DefaultNObjectFormat(workspace)); return NOptional.of((T) p); @@ -149,14 +134,6 @@ public NOptional createComponent(Class type, Object DefaultNIO p = session.getOrComputeProperty("fallback::" + type.getName(), NScopeType.WORKSPACE, () -> new DefaultNIO(workspace)); return NOptional.of((T) p); } - case "net.thevpc.nuts.NConfigs": { - DefaultNConfigs p = session.getOrComputeProperty("fallback::" + type.getName(), NScopeType.WORKSPACE, () -> new DefaultNConfigs(workspace)); - return NOptional.of((T) p); - } - case "net.thevpc.nuts.env.NBootManager": { - DefaultNBootManager p = session.getOrComputeProperty("fallback::" + type.getName(), NScopeType.SESSION, () -> new DefaultNBootManager(workspace)); - return NOptional.of((T) p); - } case "net.thevpc.nuts.elem.NElements": { DefaultNElements p = session.getOrComputeProperty("fallback::" + type.getName(), NScopeType.SESSION, () -> new DefaultNElements(workspace)); return NOptional.of((T) p); @@ -169,10 +146,6 @@ public NOptional createComponent(Class type, Object NDigest p = session.getOrComputeProperty("fallback::" + type.getName(), NScopeType.SESSION, () -> new DefaultNDigest(workspace)); return NOptional.of((T) p); } - case "net.thevpc.nuts.io.NContentTypes": { - NContentTypes p = session.getOrComputeProperty("fallback::" + type.getName(), NScopeType.SESSION, () -> new DefaultNContentTypes(session)); - return NOptional.of((T) p); - } case "net.thevpc.nuts.reserved.rpi.NIORPI": { NIORPI p = session.getOrComputeProperty("fallback::" + type.getName(), NScopeType.SESSION, () -> new DefaultNIORPI(workspace)); return NOptional.of((T) p); @@ -189,10 +162,6 @@ public NOptional createComponent(Class type, Object NVersionFormat p = session.getOrComputeProperty("fallback::" + type.getName(), NScopeType.SESSION, () -> new DefaultNVersionFormat(workspace)); return NOptional.of((T) p); } - case "net.thevpc.nuts.env.NImports": { - NImports p = session.getOrComputeProperty("fallback::" + type.getName(), NScopeType.SESSION, () -> new DefaultNImports(workspace)); - return NOptional.of((T) p); - } case "net.thevpc.nuts.NExecCmd": { NExecCmd p = session.getOrComputeProperty("fallback::" + type.getName(), NScopeType.SESSION, () -> new DefaultNExecCmd(workspace)); return NOptional.of((T) p); @@ -207,13 +176,13 @@ public NOptional createComponent(Class type, Object case "net.thevpc.nuts.NDependencyBuilder": { return NOptional.of((T) new DefaultNDependencyBuilder()); } - case "net.thevpc.nuts.env.NEnvConditionBuilder": { + case "net.thevpc.nuts.NEnvConditionBuilder": { return NOptional.of((T) new DefaultNEnvConditionBuilder()); } case "net.thevpc.nuts.NDescriptorBuilder": { return NOptional.of((T) new DefaultNDescriptorBuilder()); } - case "net.thevpc.nuts.env.NBootOptionsBuilder": { + case "net.thevpc.nuts.NBootOptionsBuilder": { return NOptional.of((T) new DefaultNBootOptionsBuilder()); } case "net.thevpc.nuts.NWorkspaceOptionsBuilder": { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/IdCache.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/IdCache.java index 8759c6a94..c8f45a27c 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/IdCache.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/IdCache.java @@ -100,19 +100,6 @@ private int _addOne(String className, ClassLoader bootClassLoader, Class[] ex return count; } - private NSession validLogSession(NSession session) { - if (session == null) { - //this is a bug - return workspace.currentSession(); - } - if (session.getTerminal() == null) { - //chances are that we are creating the session or the session's Terminal - return workspace.currentSession(); - } - return session; - } - - void add(Class extensionPoint, Class implementation) { NClassClassMap y = getClassClassMap(extensionPoint, true); if (!y.containsExactKey(implementation)) { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/NWorkspaceExt.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/NWorkspaceExt.java index 8b892b71e..f857d622b 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/NWorkspaceExt.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/NWorkspaceExt.java @@ -6,12 +6,15 @@ package net.thevpc.nuts.runtime.standalone.workspace; import net.thevpc.nuts.*; +import net.thevpc.nuts.runtime.standalone.repository.config.DefaultNRepositoryModel; import net.thevpc.nuts.runtime.standalone.repository.impl.main.NInstalledRepository; import net.thevpc.nuts.runtime.standalone.workspace.cmd.NExecutionContextBuilder; -import net.thevpc.nuts.runtime.standalone.workspace.config.NWorkspaceModel; +import net.thevpc.nuts.runtime.standalone.workspace.config.*; +import net.thevpc.nuts.spi.NDependencySolver; import net.thevpc.nuts.spi.NInstallerComponent; import net.thevpc.nuts.text.NText; +import java.util.List; import java.util.Stack; /** @@ -23,6 +26,9 @@ public interface NWorkspaceExt { static NWorkspaceExt of() { return ((NWorkspaceExt)NWorkspace.get()); } + static NWorkspaceExt of(NWorkspace ws) { + return ((NWorkspaceExt)ws); + } NText getWelcomeText(); @@ -79,5 +85,19 @@ static NWorkspaceExt of() { void setInstallationDigest(String value); Stack sessionScopes(); + DefaultNRepositoryModel getRepositoryModel(); + + public DefaultNWorkspaceEnvManagerModel getEnvModel(); + + public DefaultCustomCommandsModel getCommandModel() ; + + public DefaultNWorkspaceConfigModel getConfigModel(); + + public DefaultImportModel getImportModel(); + + NDependencySolver createDependencySolver(String solverName); + + List getDependencySolverNames(); + DefaultNWorkspaceLocationModel getLocationModel(); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/NWorkspaceUtils.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/NWorkspaceUtils.java index 7ea7628ee..b7012c6c3 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/NWorkspaceUtils.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/NWorkspaceUtils.java @@ -7,7 +7,6 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.*; import net.thevpc.nuts.ext.NExtensions; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.io.NPrintStream; @@ -22,7 +21,6 @@ import net.thevpc.nuts.runtime.standalone.format.NPrintIterator; import net.thevpc.nuts.runtime.standalone.repository.NRepositoryHelper; import net.thevpc.nuts.runtime.standalone.repository.cmd.NRepositorySupportedAction; -import net.thevpc.nuts.runtime.standalone.repository.config.DefaultNRepositories; import net.thevpc.nuts.runtime.standalone.repository.impl.main.NInstalledRepository; import net.thevpc.nuts.runtime.standalone.util.jclass.NJavaSdkUtils; import net.thevpc.nuts.runtime.standalone.util.reflect.*; @@ -76,20 +74,18 @@ protected NLog _LOG() { } public NRepositorySPI repoSPI(NRepository repo) { - DefaultNRepositories repos = (DefaultNRepositories) NRepositories.of(); - return repos.getModel().toRepositorySPI(repo); + return NWorkspaceExt.of().getRepositoryModel().toRepositorySPI(repo); } public NReflectRepository getReflectRepository() { - NEnvs env = NEnvs.of(); //do not call env.getProperty(...). It will end up with a stack overflow - NReflectRepository o = (NReflectRepository) (env.getProperties().get(NReflectRepository.class.getName())); + NReflectRepository o = (NReflectRepository) (workspace.getProperties().get(NReflectRepository.class.getName())); if (o == null) { o = new DefaultNReflectRepository(workspace,NReflectConfigurationBuilder.of() .setPropertyAccessStrategy(NReflectPropertyAccessStrategy.FIELD) .setPropertyDefaultValueStrategy(NReflectPropertyDefaultValueStrategy.PROPERTY_DEFAULT) .build()); - env.setProperty(NReflectRepository.class.getName(), o); + workspace.setProperty(NReflectRepository.class.getName(), o); } return o; } @@ -107,8 +103,8 @@ public NId createSdkId(String type, String version) { } public void checkReadOnly() { - if (NConfigs.of().isReadOnly()) { - throw new NReadOnlyException(NLocations.of().getWorkspaceLocation().toString()); + if (NWorkspace.get().isReadOnly()) { + throw new NReadOnlyException(NWorkspace.get().getWorkspaceLocation().toString()); } } @@ -123,17 +119,16 @@ public NId configureFetchEnv(NId id) { && qm.get(NConstants.IdProperties.PLATFORM) == null && qm.get(NConstants.IdProperties.DESKTOP) == null ) { - NEnvs env = NEnvs.of(); - qm.put(NConstants.IdProperties.ARCH, env.getArchFamily().id()); - qm.put(NConstants.IdProperties.OS, env.getOs().toString()); - if (env.getOsDist() != null) { - qm.put(NConstants.IdProperties.OS_DIST, env.getOsDist().toString()); + qm.put(NConstants.IdProperties.ARCH, workspace.getArchFamily().id()); + qm.put(NConstants.IdProperties.OS, workspace.getOs().toString()); + if (workspace.getOsDist() != null) { + qm.put(NConstants.IdProperties.OS_DIST, workspace.getOsDist().toString()); } - if (env.getPlatform() != null) { - qm.put(NConstants.IdProperties.PLATFORM, env.getPlatform().toString()); + if (workspace.getPlatform() != null) { + qm.put(NConstants.IdProperties.PLATFORM, workspace.getPlatform().toString()); } - if (env.getDesktopEnvironment() != null) { - qm.put(NConstants.IdProperties.DESKTOP, env.getDesktopEnvironment().toString()); + if (workspace.getDesktopEnvironment() != null) { + qm.put(NConstants.IdProperties.DESKTOP, workspace.getDesktopEnvironment().toString()); } return id.builder().setProperties(qm).build(); } @@ -165,7 +160,7 @@ private List filterRepositories(NRepositorySupportedAction fmode, N // List reposLevels = new ArrayList<>(); NSession session = workspace.currentSession(); - for (NRepository repository : NRepositories.of().getRepositories()) { + for (NRepository repository : workspace.getRepositories()) { /*repository.isAvailable()*/ if (repository.isEnabled() && (fmode == NRepositorySupportedAction.SEARCH || repository.isSupportedDeploy()) @@ -182,7 +177,7 @@ && repoSPI(repository).isAcceptFetchMode(mode) } NSpeedQualifier t = NSpeedQualifier.NORMAL; try { - t = NRepositoryHelper.getSupportSpeedLevel(repository, fmode, id, mode, session.isTransitive(), session); + t = NRepositoryHelper.getSupportSpeedLevel(repository, fmode, id, mode, session.isTransitive()); } catch (Exception ex) { _LOGOP().level(Level.FINE).error(ex) .log(NMsg.ofJ("unable to resolve support speed level for : {0}", repository.getName())); @@ -229,17 +224,14 @@ public Events events() { public void installAllJVM() { NSession session = workspace.currentSession(); - NEnvs env = NEnvs.of(); - NPlatforms platforms = NPlatforms.of(); - NConfigs config = NConfigs.of(); try { if (session.isPlainTrace()) { session.out().resetLine().println("looking for java installations in default locations..."); } - List found = platforms.searchSystemPlatforms(NPlatformFamily.JAVA).toList(); + List found = workspace.searchSystemPlatforms(NPlatformFamily.JAVA).toList(); int someAdded = 0; for (NPlatformLocation java : found) { - if (platforms.addPlatform(java)) { + if (workspace.addPlatform(java)) { someAdded++; } } @@ -253,8 +245,8 @@ public void installAllJVM() { } session.out().println("you can always add another installation manually using 'nuts settings add java' command."); } - if (!config.isReadOnly()) { - config.save(); + if (!workspace.isReadOnly()) { + workspace.saveConfig(); } } catch (Exception ex) { _LOG().with().level(Level.FINEST).verb(NLogVerb.WARNING).error(ex) @@ -270,20 +262,16 @@ public void installAllJVM() { } public void installCurrentJVM() { -//at least add current vm NSession session = workspace.currentSession(); - NEnvs env = NEnvs.of(); - NConfigs config = NConfigs.of(); - NPlatforms platforms = NPlatforms.of(); try { if (session.isPlainTrace()) { session.out().resetLine().println("configuring current JVM..."); } - NPlatformLocation found0 = platforms.resolvePlatform(NPlatformFamily.JAVA, NPath.of(System.getProperty("java.home")), null).orNull(); + NPlatformLocation found0 = workspace.resolvePlatform(NPlatformFamily.JAVA, NPath.of(System.getProperty("java.home")), null).orNull(); NPlatformLocation[] found = found0 == null ? new NPlatformLocation[0] : new NPlatformLocation[]{found0}; int someAdded = 0; for (NPlatformLocation java : found) { - if (platforms.addPlatform(java)) { + if (workspace.addPlatform(java)) { someAdded++; } } @@ -292,8 +280,8 @@ public void installCurrentJVM() { session.out().println(NMsg.ofC("%s java installation locations found...", NMsg.ofStyled("no new", NTextStyle.error()))); } } - if (!config.isReadOnly()) { - config.save(); + if (!workspace.isReadOnly()) { + workspace.saveConfig(); } } catch (Exception ex) { _LOG().with().level(Level.FINEST).verb(NLogVerb.WARNING).error(ex) @@ -307,14 +295,13 @@ public void installCurrentJVM() { public void installScriptsAndLaunchers(boolean includeGraphicalLaunchers) { NSession session = workspace.currentSession(); - NEnvs env = NEnvs.of(); try { - env.addLauncher( + workspace.addLauncher( new NLauncherOptions() .setId(session.getWorkspace().getApiId()) .setCreateScript(true) .setSwitchWorkspace( - NBootManager.of().getBootOptions().getSwitchWorkspace().orNull() + NWorkspace.get().getBootOptions().getSwitchWorkspace().orNull() ) .setCreateDesktopLauncher(includeGraphicalLaunchers ? NSupportMode.PREFERRED : NSupportMode.NEVER) .setCreateMenuLauncher(includeGraphicalLaunchers ? NSupportMode.SUPPORTED : NSupportMode.NEVER) @@ -359,7 +346,7 @@ public void installCompanions() { NMsg.ofStyled("unable to install companion tools", NTextStyle.error()), ex, text.ofBuilder().appendJoined(text.ofPlain(", "), - NRepositories.of().getRepositories().stream().map(x + workspace.getRepositories().stream().map(x -> text.ofBuilder().append(x.getName(), NTextStyle.primary3()) ).collect(Collectors.toList()) ) @@ -411,7 +398,7 @@ public Events(NWorkspaceUtils u) { public void fireOnInstall(NInstallEvent event) { u._LOGOP().level(Level.FINEST).verb(NLogVerb.ADD) .log(NMsg.ofJ("installed {0}", event.getDefinition().getId())); - for (NInstallListener listener : NEvents.of().getInstallListeners()) { + for (NInstallListener listener : event.getWorkspace().getInstallListeners()) { listener.onInstall(event); } for (NInstallListener listener : event.getSession().getListeners(NInstallListener.class)) { @@ -422,7 +409,7 @@ public void fireOnInstall(NInstallEvent event) { public void fireOnRequire(NInstallEvent event) { u._LOGOP().level(Level.FINEST).verb(NLogVerb.ADD) .log(NMsg.ofJ("required {0}", event.getDefinition().getId())); - for (NInstallListener listener : NEvents.of().getInstallListeners()) { + for (NInstallListener listener : event.getWorkspace().getInstallListeners()) { listener.onRequire(event); } for (NInstallListener listener : event.getSession().getListeners(NInstallListener.class)) { @@ -442,7 +429,7 @@ public void fireOnUpdate(NUpdateEvent event) { event.getNewValue().getId().getLongId())); } } - for (NInstallListener listener : NEvents.of().getInstallListeners()) { + for (NInstallListener listener : event.getWorkspace().getInstallListeners()) { listener.onUpdate(event); } for (NInstallListener listener : event.getSession().getListeners(NInstallListener.class)) { @@ -455,7 +442,7 @@ public void fireOnUninstall(NInstallEvent event) { u._LOGOP().level(Level.FINEST).verb(NLogVerb.REMOVE) .log(NMsg.ofJ("uninstalled {0}", event.getDefinition().getId())); } - for (NInstallListener listener : NEvents.of().getInstallListeners()) { + for (NInstallListener listener : event.getWorkspace().getInstallListeners()) { listener.onUninstall(event); } for (NInstallListener listener : event.getSession().getListeners(NInstallListener.class)) { @@ -469,7 +456,7 @@ public void fireOnAddRepository(NWorkspaceEvent event) { .log(NMsg.ofJ("added repo ##{0}##", event.getRepository().getName())); } - for (NWorkspaceListener listener : NEvents.of().getWorkspaceListeners()) { + for (NWorkspaceListener listener : event.getWorkspace().getWorkspaceListeners()) { listener.onAddRepository(event); } for (NWorkspaceListener listener : event.getSession().getListeners(NWorkspaceListener.class)) { @@ -482,7 +469,7 @@ public void fireOnRemoveRepository(NWorkspaceEvent event) { u._LOGOP().level(Level.FINEST).verb(NLogVerb.REMOVE) .log(NMsg.ofJ("removed repo ##{0}##", event.getRepository().getName())); } - for (NWorkspaceListener listener : NEvents.of().getWorkspaceListeners()) { + for (NWorkspaceListener listener : event.getWorkspace().getWorkspaceListeners()) { listener.onRemoveRepository(event); } for (NWorkspaceListener listener : event.getSession().getListeners(NWorkspaceListener.class)) { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/NWorkspaceVarExpansionFunction.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/NWorkspaceVarExpansionFunction.java index c7e832798..5872c158a 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/NWorkspaceVarExpansionFunction.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/NWorkspaceVarExpansionFunction.java @@ -2,9 +2,10 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NBootManager; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; + + + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.spi.NScopeType; import net.thevpc.nuts.text.NText; @@ -31,46 +32,46 @@ private String str(NPath p) { public String apply(String from) { switch (from) { case "home.conf": - return str(NLocations.of().getHomeLocation(NStoreType.CONF)); + return str(NWorkspace.get().getHomeLocation(NStoreType.CONF)); case "home.bin": - return str(NLocations.of().getHomeLocation(NStoreType.BIN)); + return str(NWorkspace.get().getHomeLocation(NStoreType.BIN)); case "home.lib": - return str(NLocations.of().getHomeLocation(NStoreType.LIB)); + return str(NWorkspace.get().getHomeLocation(NStoreType.LIB)); case "home.temp": - return str(NLocations.of().getHomeLocation(NStoreType.TEMP)); + return str(NWorkspace.get().getHomeLocation(NStoreType.TEMP)); case "home.var": - return str(NLocations.of().getHomeLocation(NStoreType.VAR)); + return str(NWorkspace.get().getHomeLocation(NStoreType.VAR)); case "home.cache": - return str(NLocations.of().getHomeLocation(NStoreType.CACHE)); + return str(NWorkspace.get().getHomeLocation(NStoreType.CACHE)); case "home.log": - return str(NLocations.of().getHomeLocation(NStoreType.LOG)); + return str(NWorkspace.get().getHomeLocation(NStoreType.LOG)); case "home.run": - return str(NLocations.of().getHomeLocation(NStoreType.RUN)); + return str(NWorkspace.get().getHomeLocation(NStoreType.RUN)); case "workspace.hash-name": return workspace.getHashName(); case "workspace.name": return workspace.getName(); case "workspace.location": case "workspace": - return NLocations.of().getWorkspaceLocation().toString(); + return NWorkspace.get().getWorkspaceLocation().toString(); case "user.home": return System.getProperty("user.home"); case "workspace.config": - return NLocations.of().getStoreLocation(NStoreType.CONF).toString(); + return NWorkspace.get().getStoreLocation(NStoreType.CONF).toString(); case "workspace.lib": - return NLocations.of().getStoreLocation(NStoreType.LIB).toString(); + return NWorkspace.get().getStoreLocation(NStoreType.LIB).toString(); case "workspace.apps": - return NLocations.of().getStoreLocation(NStoreType.BIN).toString(); + return NWorkspace.get().getStoreLocation(NStoreType.BIN).toString(); case "workspace.cache": - return NLocations.of().getStoreLocation(NStoreType.CACHE).toString(); + return NWorkspace.get().getStoreLocation(NStoreType.CACHE).toString(); case "workspace.run": - return NLocations.of().getStoreLocation(NStoreType.RUN).toString(); + return NWorkspace.get().getStoreLocation(NStoreType.RUN).toString(); case "workspace.temp": - return NLocations.of().getStoreLocation(NStoreType.TEMP).toString(); + return NWorkspace.get().getStoreLocation(NStoreType.TEMP).toString(); case "workspace.log": - return NLocations.of().getStoreLocation(NStoreType.LOG).toString(); + return NWorkspace.get().getStoreLocation(NStoreType.LOG).toString(); case "workspace.var": - return NLocations.of().getStoreLocation(NStoreType.VAR).toString(); + return NWorkspace.get().getStoreLocation(NStoreType.VAR).toString(); case "nuts.boot.version": return workspace.getApiVersion().toString(); case "nuts.boot.id": @@ -90,13 +91,13 @@ public String apply(String from) { case "nuts.workspace-boot.id": return NId.ofApi(Nuts.getVersion()).get().toString(); case "nuts.workspace-runtime.version": { - String rt = NBootManager.of().getBootOptions().getRuntimeId().map(Object::toString).orNull(); + String rt = NWorkspace.get().getBootOptions().getRuntimeId().map(Object::toString).orNull(); return rt == null ? workspace.getRuntimeId().getVersion().toString() : rt.contains("#") ? rt.substring(rt.indexOf("#") + 1) : rt; } case "nuts.workspace-runtime.id": { - String rt = NBootManager.of().getBootOptions().getRuntimeId().map(Object::toString).orNull(); + String rt = NWorkspace.get().getBootOptions().getRuntimeId().map(Object::toString).orNull(); return rt == null ? workspace.getRuntimeId().getVersion().toString() : rt.contains("#") ? rt : (NConstants.Ids.NUTS_RUNTIME + "#" + rt); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/archetype/DefaultNWorkspaceArchetypeComponent.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/archetype/DefaultNWorkspaceArchetypeComponent.java index 9b12f2108..570927d3d 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/archetype/DefaultNWorkspaceArchetypeComponent.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/archetype/DefaultNWorkspaceArchetypeComponent.java @@ -28,13 +28,13 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NBootManager; -import net.thevpc.nuts.env.NImports; + + + import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; import net.thevpc.nuts.spi.*; import net.thevpc.nuts.runtime.standalone.repository.NRepositorySelectorHelper; -import net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNConfigs; import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceUtils; import net.thevpc.nuts.util.NBlankable; @@ -56,12 +56,9 @@ public String getName() { @Override public void initializeWorkspace() { - NSession session=workspace.currentSession(); - NConfigs nConfigs = NConfigs.of(); - DefaultNConfigs rm = (DefaultNConfigs) nConfigs; LinkedHashMap def = new LinkedHashMap<>(); List defaults = new ArrayList<>(); - for (NAddRepositoryOptions d : rm.getDefaultRepositories()) { + for (NAddRepositoryOptions d : workspace.getDefaultRepositories()) { if (d.getConfig() != null) { def.put(NPath.of(d.getConfig().getLocation().getPath()).toAbsolute().toString(), d); } else { @@ -69,10 +66,10 @@ public void initializeWorkspace() { } defaults.add(NRepositoryLocation.of(d.getName(), (String)null)); } - NWorkspaceExt.of().getModel().configModel.getStoredConfigMain().setEnablePreviewRepositories(session.isPreviewRepo()); + NWorkspaceExt.of().getModel().configModel.getStoredConfigMain().setEnablePreviewRepositories(NSession.get().isPreviewRepo()); NWorkspaceExt.of().getModel().configModel.invalidateStoreModelMain(); defaults.add(NRepositoryLocation.ofName(NConstants.Names.DEFAULT_REPOSITORY_NAME)); - NRepositoryLocation[] br = rm.getModel().resolveBootRepositoriesList().resolve(defaults.toArray(new NRepositoryLocation[0]), NRepositoryDB.of()); + NRepositoryLocation[] br = NWorkspaceExt.of(workspace).getConfigModel().resolveBootRepositoriesList().resolve(defaults.toArray(new NRepositoryLocation[0]), NRepositoryDB.of()); for (NRepositoryLocation s : br) { NAddRepositoryOptions oo = NRepositorySelectorHelper.createRepositoryOptions(s, false); String sloc = NPath.of(oo.getConfig().getLocation().getPath()).toAbsolute().toString(); @@ -81,7 +78,7 @@ public void initializeWorkspace() { if (!NBlankable.isBlank(s.getName())) { r.setName(oo.getName()); } - NRepository nr = NRepositories.of().addRepository(r); + NRepository nr = workspace.addRepository(r); if ( "system".equals(nr.getName()) && "system".equals(nr.config().getGlobalName()) @@ -95,7 +92,7 @@ public void initializeWorkspace() { } def.remove(sloc); } else { - NRepositories.of().addRepository(oo + workspace.addRepository(oo //.setTemporary(!defaults.containsKey(oo.getName())) ); } @@ -103,10 +100,10 @@ public void initializeWorkspace() { // for (NutsAddRepositoryOptions d : def.values()) { // ws.repos().addRepository(d); // } - NImports.of().addImports(new String[]{ + NWorkspace.get().addImports( "net.thevpc.nuts.toolbox", "net.thevpc" - }); + ); NWorkspaceSecurityManager.of().updateUser(NConstants.Users.ANONYMOUS) .resetPermissions() @@ -128,12 +125,11 @@ public void initializeWorkspace() { @Override public void startWorkspace() { - NBootManager boot = NBootManager.of(); // boolean initializePlatforms = boot.getBootOptions().getInitPlatforms().ifEmpty(false).get(session); // boolean initializeJava = boot.getBootOptions().getInitJava().ifEmpty(initializePlatforms).get(session); - boolean initializeScripts = boot.getBootOptions().getInitScripts().orElse(true); - boolean initializeLaunchers = boot.getBootOptions().getInitLaunchers().orElse(true); - boolean installCompanions = boot.getBootOptions().getInstallCompanions().orElse(false); + boolean initializeScripts = workspace.getBootOptions().getInitScripts().orElse(true); + boolean initializeLaunchers = workspace.getBootOptions().getInitLaunchers().orElse(true); + boolean installCompanions = workspace.getBootOptions().getInstallCompanions().orElse(false); // if (initializeJava) { // NWorkspaceUtils.of(session).installAllJVM(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/archetype/MinimalNWorkspaceArchetypeComponent.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/archetype/MinimalNWorkspaceArchetypeComponent.java index 94b3c6d5c..e720a040e 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/archetype/MinimalNWorkspaceArchetypeComponent.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/archetype/MinimalNWorkspaceArchetypeComponent.java @@ -26,9 +26,10 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NBootManager; + + +import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; import net.thevpc.nuts.spi.*; -import net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNConfigs; import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceUtils; /** @@ -49,16 +50,11 @@ public String getName() { @Override public void initializeWorkspace() { - NSession session = workspace.currentSession(); -// NutsWorkspace ws = session.getWorkspace(); - - DefaultNConfigs rm = (DefaultNConfigs) NConfigs.of(); // defaults.put(NutsConstants.Names.DEFAULT_REPOSITORY_NAME, null); - NRepositoryLocation[] br = rm.getModel().resolveBootRepositoriesList().resolve( + NRepositoryLocation[] br = NWorkspaceExt.of(workspace).getConfigModel().resolveBootRepositoriesList().resolve( new NRepositoryLocation[0], NRepositoryDB.of()); - NRepositories repos = NRepositories.of(); for (NRepositoryLocation s : br) { - repos.addRepository(s.toString()); + workspace.addRepository(s.toString()); } //simple rights for minimal utilization NUpdateUserCmd uu = NWorkspaceSecurityManager.of() @@ -73,13 +69,11 @@ public void initializeWorkspace() { @Override public void startWorkspace() { - NSession session = workspace.currentSession(); - NBootManager boot = NBootManager.of(); // boolean initializePlatforms = boot.getBootOptions().getInitPlatforms().ifEmpty(false).get(session); // boolean initializeJava = boot.getBootOptions().getInitJava().ifEmpty(initializePlatforms).get(session); - boolean initializeScripts = boot.getBootOptions().getInitScripts().ifEmpty(true).get(); - boolean initializeLaunchers = boot.getBootOptions().getInitLaunchers().ifEmpty(true).get(); - Boolean installCompanions = NBootManager.of().getBootOptions().getInstallCompanions().orElse(false); + boolean initializeScripts = workspace.getBootOptions().getInitScripts().ifEmpty(true).get(); + boolean initializeLaunchers = workspace.getBootOptions().getInitLaunchers().ifEmpty(true).get(); + Boolean installCompanions = NWorkspace.get().getBootOptions().getInstallCompanions().orElse(false); // if (initializeJava) { // NWorkspaceUtils.of(session).installAllJVM(); @@ -87,15 +81,15 @@ public void startWorkspace() { // NWorkspaceUtils.of(session).installCurrentJVM(); // } if (initializeScripts || initializeLaunchers || installCompanions) { - NId api = NFetchCmd.of().setId(session.getWorkspace().getApiId()).setFailFast(false).getResultId(); + NId api = NFetchCmd.of().setId(workspace.getApiId()).setFailFast(false).getResultId(); if (api != null) { if (initializeScripts || initializeLaunchers) { //api would be null if running in fatjar and no internet/maven is available - NWorkspaceUtils.of(session.getWorkspace()).installScriptsAndLaunchers(initializeLaunchers); + NWorkspaceUtils.of(workspace).installScriptsAndLaunchers(initializeLaunchers); } if (installCompanions) { if (api != null) { - NWorkspaceUtils.of(session.getWorkspace()).installCompanions(); + NWorkspaceUtils.of(workspace).installCompanions(); } } } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/archetype/ServerNWorkspaceArchetypeComponent.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/archetype/ServerNWorkspaceArchetypeComponent.java index 822b51855..7b2b6306d 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/archetype/ServerNWorkspaceArchetypeComponent.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/archetype/ServerNWorkspaceArchetypeComponent.java @@ -27,9 +27,10 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NBootManager; + + +import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; import net.thevpc.nuts.spi.*; -import net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNConfigs; import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceUtils; /** @@ -50,9 +51,7 @@ public String getName() { @Override public void initializeWorkspace() { - NSession session = workspace.currentSession(); - DefaultNConfigs rm = (DefaultNConfigs) NConfigs.of(); - NRepositoryLocation[] br = rm.getModel().resolveBootRepositoriesList().resolve( + NRepositoryLocation[] br = NWorkspaceExt.of(workspace).getConfigModel().resolveBootRepositoriesList().resolve( new NRepositoryLocation[]{ NRepositoryLocation.ofName("maven-local"), NRepositoryLocation.ofName("maven-central"), @@ -60,9 +59,8 @@ public void initializeWorkspace() { }, NRepositoryDB.of() ); - NRepositories repos = NRepositories.of(); for (NRepositoryLocation s : br) { - repos.addRepository(s.toString()); + workspace.addRepository(s.toString()); } NWorkspaceSecurityManager sec = NWorkspaceSecurityManager.of(); @@ -85,13 +83,11 @@ public void initializeWorkspace() { @Override public void startWorkspace() { - NSession session = workspace.currentSession(); - NBootManager boot = NBootManager.of(); // boolean initializePlatforms = boot.getBootOptions().getInitPlatforms().ifEmpty(false).get(session); // boolean initializeJava = boot.getBootOptions().getInitJava().ifEmpty(initializePlatforms).get(session); - boolean initializeScripts = boot.getBootOptions().getInitScripts().ifEmpty(true).get(); - boolean initializeLaunchers = boot.getBootOptions().getInitLaunchers().ifEmpty(true).get(); - Boolean installCompanions = NBootManager.of().getBootOptions().getInstallCompanions().orElse(false); + boolean initializeScripts = workspace.getBootOptions().getInitScripts().ifEmpty(true).get(); + boolean initializeLaunchers = workspace.getBootOptions().getInitLaunchers().ifEmpty(true).get(); + Boolean installCompanions = NWorkspace.get().getBootOptions().getInstallCompanions().orElse(false); // if (initializeJava) { // NWorkspaceUtils.of(session).installAllJVM(); @@ -100,7 +96,7 @@ public void startWorkspace() { // NWorkspaceUtils.of(session).installCurrentJVM(); // } if (initializeScripts || initializeLaunchers || installCompanions) { - NId api = NFetchCmd.of().setId(session.getWorkspace().getApiId()).setFailFast(false).getResultId(); + NId api = NFetchCmd.of().setId(workspace.getApiId()).setFailFast(false).getResultId(); if (api != null) { if (initializeScripts || initializeLaunchers) { //api would be null if running in fatjar and no internet/maven is available diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/DefaultNQueryBaseOptions.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/DefaultNQueryBaseOptions.java index 4ddac93c7..6dee90b3c 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/DefaultNQueryBaseOptions.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/DefaultNQueryBaseOptions.java @@ -297,7 +297,6 @@ public boolean configureFirst(NCmdLine cmdLine) { if (getDisplayOptions().configureFirst(cmdLine)) { return true; } - NSession session = workspace.currentSession(); NArg a = cmdLine.peek().get(); if (a == null) { return false; @@ -353,11 +352,10 @@ public NRepositoryFilter getRepositoryFilter() { // @Override public T setRepositoryFilter(String filter) { - NSession session = workspace.currentSession(); if (NBlankable.isBlank(filter)) { this.repositoryFilter = null; } else { - this.repositoryFilter = NRepositories.of().filter().bySelector(filter); + this.repositoryFilter = NRepositoryFilters.of().bySelector(filter); } return (T) this; } @@ -409,7 +407,6 @@ public NDependencyFilter getDependencyFilter() { // @Override public T setDependencyFilter(String filter) { - NSession session = workspace.currentSession(); this.dependencyFilter = NDependencyFilters.of().parse(filter); return (T) this; } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/NWorkspaceCmdBase.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/NWorkspaceCmdBase.java index 112ff398d..4acbca06c 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/NWorkspaceCmdBase.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/NWorkspaceCmdBase.java @@ -40,7 +40,6 @@ protected NLogOp _LOGOP() { } protected NLog _LOG() { - NSession session = workspace.currentSession(); return NLog.of(getClass()); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/deploy/DefaultNDeployCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/deploy/DefaultNDeployCmd.java index 4592d853e..f8ae664c1 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/deploy/DefaultNDeployCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/deploy/DefaultNDeployCmd.java @@ -2,7 +2,8 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NLocations; + + import net.thevpc.nuts.format.NDescriptorFormat; import net.thevpc.nuts.io.*; import net.thevpc.nuts.runtime.standalone.descriptor.parser.NDescriptorContentResolver; @@ -163,7 +164,7 @@ private NDeployCmd runDeployFile(NInputSource content, Object descriptor0, Strin NAssert.requireNonBlank(characterizedFile.getDescriptor(), "descriptor"); descriptor = characterizedFile.getDescriptor(); } - String name = NLocations.of().getDefaultIdFilename(descriptor.getId().builder().setFaceDescriptor().build()); + String name = NWorkspace.get().getDefaultIdFilename(descriptor.getId().builder().setFaceDescriptor().build()); tempFile = NPath.ofTempFile(name).toPath().get(); NCp.of().from(contentSource.getInputStream()).to(tempFile).addOptions(NPathOption.SAFE).run(); contentFile2 = tempFile; @@ -241,7 +242,7 @@ private NDeployCmd runDeployFile(NInputSource content, Object descriptor0, Strin return this; } } else { - NRepository repo = NRepositories.of().findRepository(repository).get(); + NRepository repo = workspace.findRepository(repository).get(); if (!repo.isEnabled()) { throw new NRepositoryDisabledException(repository); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/DefaultNExecCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/DefaultNExecCmd.java index 2f256b0e0..056ebe7e5 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/DefaultNExecCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/DefaultNExecCmd.java @@ -2,9 +2,10 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NEnvs; -import net.thevpc.nuts.env.NIdLocation; -import net.thevpc.nuts.env.NLocations; + +import net.thevpc.nuts.NIdLocation; + +import net.thevpc.nuts.log.NLogVerb; import net.thevpc.nuts.runtime.standalone.DefaultNDescriptorBuilder; import net.thevpc.nuts.text.NText; import net.thevpc.nuts.util.NBlankable; @@ -70,6 +71,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.*; +import java.util.logging.Level; /** * type: Command Class @@ -460,15 +462,24 @@ private NExecutableInformationExt execEmbeddedOrExternal(String[] cmd, List 0) - , + descriptor, + NPath.of(c.getContentFile()).setUserCache(false).setUserTemporary(!c.getTemps().isEmpty()), DefaultNInstallInfo.notInstalled(_id), null, getWorkspace() ); @@ -481,7 +492,7 @@ null, getWorkspace() // .and(ff.byOptional(getOptional()) // ).and(getDependencyFilter()) ); - for (NDependency dependency : c.getDescriptor().getDependencies()) { + for (NDependency dependency : descriptor.getDependencies()) { resolver.add(dependency); } nutToRun.setDependencies(resolver.solve()); @@ -522,7 +533,7 @@ null, getWorkspace() if (remoteInfo0 != null) { NAssert.requireNonBlank(command, "command"); List ts = new ArrayList<>(command); - if (ts.size() == 0) { + if (ts.isEmpty()) { throw new NUnsupportedArgumentException(NMsg.ofPlain("missing command")); } String id = ts.get(0); @@ -707,7 +718,7 @@ null, getWorkspace() ); } NCustomCmd command = null; - command = NCommands.of().findCommand(goodKw); + command = NWorkspace.get().findCommand(goodKw); if (command != null) { NCmdExecOptions o = new NCmdExecOptions().setExecutorOptions(executorOptions).setDirectory(directory).setFailFast(failFast) .setExecutionType(executionType).setEnv(env); @@ -798,7 +809,7 @@ public boolean isUserCommand(String s) { char r = File.pathSeparatorChar; for (String z : p.split("" + r)) { Path t = Paths.get(z); - switch (NEnvs.of().getOsFamily()) { + switch (NWorkspace.get().getOsFamily()) { case WINDOWS: { if (Files.isRegularFile(t.resolve(s))) { return true; @@ -827,7 +838,6 @@ public boolean isUserCommand(String s) { protected NExecutableInformationExt ws_execId(NId goodId, String commandName, String[] appArgs, List executorOptions, List workspaceOptions, NExecutionType executionType, NRunAs runAs) { - NSession session=getWorkspace().currentSession(); NDefinition def = null; try { def = NFetchCmd.of(goodId) @@ -1040,7 +1050,7 @@ public static CharacterizedExecFile characterizeForExec(NInputSource contentFile URLBuilder ub = new URLBuilder(((NPath) c.getStreamOrPath()).toURL().toString()); try { c.setContentFile(CoreIOUtils.toPathInputSource( - NPath.of(ub.resolveSibling(NLocations.of().getDefaultIdFilename(c.getDescriptor().getId())).toURL()), + NPath.of(ub.resolveSibling(NWorkspace.get().getDefaultIdFilename(c.getDescriptor().getId())).toURL()), c.getTemps(), true)); } catch (Exception ex) { //TODO FIX ME @@ -1063,8 +1073,7 @@ public static CharacterizedExecFile characterizeForExec(NInputSource contentFile URLBuilder ub = new URLBuilder(((NPath) c.getStreamOrPath()).toURL().toString()); try { c.setContentFile(CoreIOUtils.toPathInputSource( - NPath.of(ub.resolveSibling(NLocations.of() - .getDefaultIdFilename(c.getDescriptor().getId())).toURL()), + NPath.of(ub.resolveSibling(NWorkspace.get().getDefaultIdFilename(c.getDescriptor().getId())).toURL()), c.getTemps(), true)); } catch (Exception ex) { //TODO add log here diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/DefaultNExecInternalExecutable.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/DefaultNExecInternalExecutable.java index 2c8d8e957..c0a923048 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/DefaultNExecInternalExecutable.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/DefaultNExecInternalExecutable.java @@ -25,7 +25,6 @@ public DefaultNExecInternalExecutable(NWorkspace workspace, String[] args, NExec @Override public int execute() { - NSession session = workspace.currentSession(); if (ExtraApiUtils.asBoolean(getExecCommand().getDry())) { dryExecute(); return NExecutionException.SUCCESS; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/local/alias/DefaultNAliasExecutable.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/local/alias/DefaultNAliasExecutable.java index 668974297..649c0ca8b 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/local/alias/DefaultNAliasExecutable.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/local/alias/DefaultNAliasExecutable.java @@ -37,14 +37,12 @@ public NId getId() { @Override public int execute() { - NSession session = workspace.currentSession(); return command.exec(args, o); } @Override public NText getHelpText() { - NSession session = workspace.currentSession(); NText t = command.getHelpText(); if (t != null) { return t; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/local/artifact/DefaultNArtifactExecutable.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/local/artifact/DefaultNArtifactExecutable.java index 5a345a69c..c203e145d 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/local/artifact/DefaultNArtifactExecutable.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/local/artifact/DefaultNArtifactExecutable.java @@ -41,7 +41,6 @@ public DefaultNArtifactExecutable(NWorkspace workspace,NDefinition def, String c super(workspace,commandName, def.getId().getLongName(), NExecutableType.ARTIFACT, execCommand); this.def = def; this.runAs = runAs; - NSession session = workspace.currentSession(); //all these information are available, an exception would be thrown if not! def.getContent().get(); def.getDependencies().get(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/local/open/DefaultNOpenExecutable.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/local/open/DefaultNOpenExecutable.java index 454684d56..3c643ce3b 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/local/open/DefaultNOpenExecutable.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/local/open/DefaultNOpenExecutable.java @@ -8,7 +8,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NEnvs; + import net.thevpc.nuts.runtime.standalone.executor.system.NSysExecUtils; import net.thevpc.nuts.runtime.standalone.workspace.cmd.exec.AbstractNExecutableInformationExt; import net.thevpc.nuts.text.NText; @@ -39,7 +39,6 @@ public DefaultNOpenExecutable(NWorkspace workspace,String[] cmd, this.cmd = cmd; this.executorOptions = executorOptions == null ? new String[0] : executorOptions; NCmdLine cmdLine = NCmdLine.of(this.executorOptions); - NSession session = workspace.currentSession(); while (cmdLine.hasNext()) { NArg aa = cmdLine.peek().get(); switch (aa.key()) { @@ -52,7 +51,7 @@ public DefaultNOpenExecutable(NWorkspace workspace,String[] cmd, } } } - switch (NEnvs.of().getOsFamily()) { + switch (NWorkspace.get().getOsFamily()) { case LINUX: { Path execPath = NSysExecUtils.sysWhich("xdg-open"); if (execPath != null) { @@ -92,7 +91,6 @@ public NId getId() { private NExecCmd resolveExecHelper() { if (effectiveOpenExecutable == null) { - NSession session = workspace.currentSession(); throw new NIllegalArgumentException(NMsg.ofC("unable to resolve viewer for %s", cmd[0])); } NExecCmd cc = getExecCommand().copy(); @@ -110,8 +108,7 @@ public int execute() { @Override public NText getHelpText() { - NSession session = workspace.currentSession(); - switch (NEnvs.of().getOsFamily()) { + switch (NWorkspace.get().getOsFamily()) { case WINDOWS: { return NText.ofStyled("No help available. Try " + getName() + " /help", NTextStyle.error()); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/local/path/DefaultNArtifactPathExecutable.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/local/path/DefaultNArtifactPathExecutable.java index 8bee4bbc0..818b19bcb 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/local/path/DefaultNArtifactPathExecutable.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/local/path/DefaultNArtifactPathExecutable.java @@ -86,7 +86,6 @@ public void close() { } private void dispose() { - NSession session = workspace.currentSession(); if (tempFolder != null) { try { NIOUtils.delete(Paths.get(tempFolder)); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/local/system/DefaultNSystemExecutable.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/local/system/DefaultNSystemExecutable.java index db7d03cfd..b3fdd6d03 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/local/system/DefaultNSystemExecutable.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/local/system/DefaultNSystemExecutable.java @@ -8,7 +8,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NEnvs; + import net.thevpc.nuts.runtime.standalone.executor.system.ProcessExecHelper; import net.thevpc.nuts.runtime.standalone.util.ExtraApiUtils; import net.thevpc.nuts.util.NCoreCollectionUtils; @@ -87,7 +87,7 @@ public int execute() { @Override public NText getHelpText() { - switch (NEnvs.of().getOsFamily()) { + switch (NWorkspace.get().getOsFamily()) { case WINDOWS: { return NText.ofStyled( "No help available. Try " + getName() + " /help", diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/remote/ssh/artifact/DefaultSpawnExecutableNutsRemote.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/remote/ssh/artifact/DefaultSpawnExecutableNutsRemote.java index 293e3c9d6..f06678a7d 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/remote/ssh/artifact/DefaultSpawnExecutableNutsRemote.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/remote/ssh/artifact/DefaultSpawnExecutableNutsRemote.java @@ -8,7 +8,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NEnvs; + import net.thevpc.nuts.io.NExecInput; import net.thevpc.nuts.io.NExecOutput; import net.thevpc.nuts.runtime.standalone.executor.AbstractSyncIProcessExecHelper; @@ -68,7 +68,6 @@ public DefaultSpawnExecutableNutsRemote(NWorkspace workspace,NExecCmdExtension c this.executorOptions = NCoreCollectionUtils.nonNullList(executorOptions); this.commExec = commExec; NCmdLine cmdLine = NCmdLine.of(this.executorOptions); - NSession session = workspace.currentSession(); while (cmdLine.hasNext()) { NArg aa = cmdLine.peek().get(); switch (aa.key()) { @@ -89,21 +88,20 @@ public NId getId() { } private AbstractSyncIProcessExecHelper resolveExecHelper() { - NSession session = workspace.currentSession(); return new AbstractSyncIProcessExecHelper(workspace) { @Override public int exec() { - return runOnce(ecmd, session); + return runOnce(ecmd); } }; } - private int runOnce(String[] cmd, NSession session) { + private int runOnce(String[] cmd) { int e; try (DefaultNExecCmdExtensionContext d = new DefaultNExecCmdExtensionContext( getExecCommand().getTarget(), - cmd, session, + cmd, workspace.currentSession(), in, out, err, @@ -124,8 +122,7 @@ public int execute() { @Override public NText getHelpText() { - NSession session = workspace.currentSession(); - switch (NEnvs.of().getOsFamily()) { + switch (NWorkspace.get().getOsFamily()) { case WINDOWS: { return NText.ofStyled( "No help available. Try " + getName() + " /help", diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/remote/ssh/system/DefaultNSystemExecutableRemote.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/remote/ssh/system/DefaultNSystemExecutableRemote.java index fa0428463..075d831e2 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/remote/ssh/system/DefaultNSystemExecutableRemote.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/exec/remote/ssh/system/DefaultNSystemExecutableRemote.java @@ -8,7 +8,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NEnvs; + import net.thevpc.nuts.io.NExecInput; import net.thevpc.nuts.io.NExecOutput; import net.thevpc.nuts.runtime.standalone.executor.AbstractSyncIProcessExecHelper; @@ -52,7 +52,6 @@ public DefaultNSystemExecutableRemote(NWorkspace workspace,NExecCmdExtension com this.executorOptions = NCoreCollectionUtils.nonNullList(executorOptions); this.commExec = commExec; NCmdLine cmdLine = NCmdLine.of(this.executorOptions); - NSession session = workspace.currentSession(); while (cmdLine.hasNext()) { NArg aa = cmdLine.peek().get(); switch (aa.key()) { @@ -121,8 +120,7 @@ public int execute() { @Override public NText getHelpText() { - NSession session = workspace.currentSession(); - switch (NEnvs.of().getOsFamily()) { + switch (NWorkspace.get().getOsFamily()) { case WINDOWS: { return NText.ofStyled( "No help available. Try " + getName() + " /help", diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/fetch/AbstractNFetchCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/fetch/AbstractNFetchCmd.java index 72fa587b7..2c9e599a7 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/fetch/AbstractNFetchCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/fetch/AbstractNFetchCmd.java @@ -26,22 +26,20 @@ public int getSupportLevel(NSupportLevelContext context) { @Override public NFetchCmd setId(String id) { - NSession session=getWorkspace().currentSession(); NId nid = NId.of(id).get(); return setId(nid); } @Override public NFetchCmd setId(NId id) { - NSession session=getWorkspace().currentSession(); if (id == null) { - throw new NParseException(NMsg.ofNtf("invalid Id format : null")); + throw new NParseException(NMsg.ofNtf("invalid Id format to fetch : null")); } if ( id.getVersion().isBlank() || !id.getVersion().isSingleValue() ) { - throw new NParseException(NMsg.ofC("invalid Id format : %s", id)); + throw new NParseException(NMsg.ofC("invalid Id format to fetch : %s", id)); } this.id = id; return this; @@ -70,7 +68,6 @@ public boolean configureFirst(NCmdLine cmdLine) { return false; } boolean enabled = a.isActive(); - NSession session=getWorkspace().currentSession(); switch (a.key()) { case "--not-installed": { cmdLine.skip(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/fetch/DefaultNFetchCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/fetch/DefaultNFetchCmd.java index 9e8d75712..7d521892d 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/fetch/DefaultNFetchCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/fetch/DefaultNFetchCmd.java @@ -3,8 +3,9 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; + + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NDigest; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.dependency.util.NDependencyUtils; @@ -43,7 +44,6 @@ public DefaultNFetchCmd(NWorkspace workspace) { @Override public NPath getResultContent() { try { - NSession session=getWorkspace().currentSession(); NDefinition def = fetchDefinition(getId(), copy().setContent(true).setEffective(false), true, false); return def.getContent().get(); } catch (NNotFoundException ex) { @@ -57,7 +57,6 @@ public NPath getResultContent() { @Override public NId getResultId() { try { - NSession session=getWorkspace().currentSession(); NDefinition def = fetchDefinition(getId(), this, false, false); if (isEffective()) { return NWorkspaceExt.of().resolveEffectiveId(def.getEffectiveDescriptor().get()); @@ -74,7 +73,6 @@ public NId getResultId() { @Override public String getResultContentHash() { try { - NSession session=getWorkspace().currentSession(); Path f = getResultDefinition().getContent().flatMap(NPath::toPath).get(); return NDigest.of().setSource(f).computeString(); } catch (NNotFoundException ex) { @@ -88,7 +86,6 @@ public String getResultContentHash() { @Override public String getResultDescriptorHash() { try { - NSession session=getWorkspace().currentSession(); return NDigest.of().setSource(getResultDescriptor()).computeString(); } catch (NNotFoundException ex) { if (!isFailFast()) { @@ -114,7 +111,6 @@ public NDefinition getResultDefinition() { public NDescriptor getResultDescriptor() { try { NDefinition def = fetchDefinition(getId(), copy().setContent(false), false, false); - NSession session=getWorkspace().currentSession(); if (isEffective()) { return def.getEffectiveDescriptor().get(); } @@ -129,7 +125,6 @@ public NDescriptor getResultDescriptor() { @Override public NInstallInformation getResultInstallInformation() { - NSession session=getWorkspace().currentSession(); NWorkspaceExt dws = NWorkspaceExt.of(); NInstallInformation ii = dws.getInstalledRepository().getInstallInformation(getId()); if (ii != null) { @@ -170,7 +165,7 @@ public NDefinition fetchDefinition(NId id, NFetchCmd options, boolean includeCon } public NDefinition fetchDefinitionNoCache(NId id, NFetchCmd options, boolean includeContent, boolean includeInstallInfo) { - long startTime = System.currentTimeMillis(); + long startTime = System.currentTimeMillis(); boolean idOptional=id.toDependency().isOptional(); NWorkspace workspace = getWorkspace(); NSession session= workspace.currentSession(); NWorkspaceUtils wu = NWorkspaceUtils.of(workspace); @@ -341,7 +336,6 @@ public NDefinition fetchDefinitionNoCache(NId id, NFetchCmd options, boolean inc } private NDependencyFilter buildActualDependencyFilter() { - NSession session=getWorkspace().currentSession(); NDependencyFilters ff = NDependencyFilters.of(); return ff.byScope(getScope()) .and(ff.byOptional(getOptional()) @@ -349,7 +343,6 @@ private NDependencyFilter buildActualDependencyFilter() { } protected NPath fetchContent(NId id1, DefaultNDefinition foundDefinition, NRepository repo0, NFetchStrategy nutsFetchModes, List reasons) { - NSession session=getWorkspace().currentSession(); NRepositorySPI repoSPI = NWorkspaceUtils.of(getWorkspace()).repoSPI(repo0); for (NFetchMode mode : nutsFetchModes) { try { @@ -375,7 +368,6 @@ protected NPath fetchContent(NId id1, DefaultNDefinition foundDefinition, NRepos } protected NPath fetchContent(NId id1, DefaultNDefinition foundDefinition, NRepositoryAndFetchMode repo, List reasons) { - NSession session=getWorkspace().currentSession(); NRepositorySPI repoSPI = NWorkspaceUtils.of(getWorkspace()).repoSPI(repo.getRepository()); try { NPath content = repoSPI.fetchContent() @@ -395,12 +387,11 @@ protected NPath fetchContent(NId id1, DefaultNDefinition foundDefinition, NRepos } protected NDescriptor resolveExecProperties(NDescriptor nutsDescriptor, NPath jar) { - NSession session=getWorkspace().currentSession(); boolean executable = nutsDescriptor.isExecutable(); boolean nutsApp = nutsDescriptor.isApplication(); if (jar.getName().toLowerCase().endsWith(".jar") && jar.isRegularFile()) { - NPath cachePath = NLocations.of().getStoreLocation(nutsDescriptor.getId(), NStoreType.CACHE) - .resolve(NLocations.of().getDefaultIdFilename(nutsDescriptor.getId() + NPath cachePath = NWorkspace.get().getStoreLocation(nutsDescriptor.getId(), NStoreType.CACHE) + .resolve(NWorkspace.get().getDefaultIdFilename(nutsDescriptor.getId() .builder() .setFace("info.cache") .build() @@ -461,8 +452,8 @@ protected DefaultNDefinition fetchDescriptorAsDefinition(NId id, NFetchStrategy NWorkspaceUtils wu = NWorkspaceUtils.of(getWorkspace()); NElements elem = NElements.of(); if (withCache) { - cachePath = NLocations.of().getStoreLocation(id, NStoreType.CACHE, repo.getUuid()) - .resolve(NLocations.of().getDefaultIdFilename(id.builder().setFace("def.cache").build())); + cachePath = NWorkspace.get().getStoreLocation(id, NStoreType.CACHE, repo.getUuid()) + .resolve(NWorkspace.get().getDefaultIdFilename(id.builder().setFace("def.cache").build())); if (cachePath.isRegularFile()) { try { if (CoreIOUtils.isObsoletePath(cachePath)) { @@ -472,9 +463,8 @@ protected DefaultNDefinition fetchDescriptorAsDefinition(NId id, NFetchStrategy DefaultNDefinition d = elem .json().parse(cachePath, DefaultNDefinition.class); if (d != null) { - NRepositories rr = NRepositories.of(); - NRepository repositoryById = rr.findRepositoryById(d.getRepositoryUuid()).orNull(); - NRepository repositoryByName = rr.findRepositoryByName(d.getRepositoryName()).orNull(); + NRepository repositoryById = workspace.findRepositoryById(d.getRepositoryUuid()).orNull(); + NRepository repositoryByName = workspace.findRepositoryByName(d.getRepositoryName()).orNull(); if (repositoryById == null || repositoryByName == null) { //this is invalid cache! cachePath.delete(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/info/DefaultNInfoCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/info/DefaultNInfoCmd.java index 9caae416b..50d42c437 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/info/DefaultNInfoCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/info/DefaultNInfoCmd.java @@ -17,7 +17,6 @@ import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; import net.thevpc.nuts.format.NCmdLineFormat; -import net.thevpc.nuts.env.*; import net.thevpc.nuts.format.NContentType; import net.thevpc.nuts.format.NObjectFormat; import net.thevpc.nuts.io.NPath; @@ -58,7 +57,7 @@ public class DefaultNInfoCmd extends DefaultFormatBase implements NInf Object oldRepos = s.map.get("repos"); if (oldRepos instanceof String) { Map repositories = new LinkedHashMap<>(); - for (NRepository repository : NRepositories.of().getRepositories()) { + for (NRepository repository : workspace.getRepositories()) { repositories.put(repository.getName(), buildRepoRepoMap(repository, true, null)); } return repositories; @@ -81,7 +80,7 @@ public Object apply(String s) { if(v!=null){ return v; } - NRepository repo = NRepositories.of().findRepository(s).orNull(); + NRepository repo = workspace.findRepository(s).orNull(); if (repo != null) { return buildRepoRepoMap(repo, true, null); } @@ -325,7 +324,7 @@ private Map> buildMapSupplier() { props.put("nuts-runtime-classpath", () -> { NTexts txt = NTexts.of(); - List cl = NBootManager.of().getBootClassWorldURLs(); + List cl = NWorkspace.get().getBootClassWorldURLs(); List runtimeClassPath = new ArrayList<>(); if (cl != null) { for (URL url : cl) { @@ -344,53 +343,53 @@ private Map> buildMapSupplier() { } ); props.put("nuts-workspace-id", () -> NText.ofStyledPath(stringValue(NWorkspace.of().get().getUuid()))); - props.put("nuts-store-layout", () -> NLocations.of().getStoreLayout()); - props.put("nuts-store-strategy", () -> NLocations.of().getStoreStrategy()); - props.put("nuts-repo-store-strategy", () -> NLocations.of().getRepositoryStoreStrategy()); - props.put("nuts-global", () -> NBootManager.of().getBootOptions().getSystem().orNull()); - props.put("nuts-workspace", () -> NLocations.of().getWorkspaceLocation()); + props.put("nuts-store-layout", () -> NWorkspace.get().getStoreLayout()); + props.put("nuts-store-strategy", () -> NWorkspace.get().getStoreStrategy()); + props.put("nuts-repo-store-strategy", () -> NWorkspace.get().getRepositoryStoreStrategy()); + props.put("nuts-global", () -> NWorkspace.get().getBootOptions().getSystem().orNull()); + props.put("nuts-workspace", () -> NWorkspace.get().getWorkspaceLocation()); for (NStoreType folderType : NStoreType.values()) { - props.put("nuts-workspace-" + folderType.id(), () -> NLocations.of().getStoreLocation(folderType)); + props.put("nuts-workspace-" + folderType.id(), () -> NWorkspace.get().getStoreLocation(folderType)); } - props.put("nuts-open-mode", () -> NBootManager.of().getBootOptions().getOpenMode().orNull()); - props.put("nuts-isolation-level", () -> NBootManager.of().getBootOptions().getIsolationLevel().orNull()); + props.put("nuts-open-mode", () -> NWorkspace.get().getBootOptions().getOpenMode().orNull()); + props.put("nuts-isolation-level", () -> NWorkspace.get().getBootOptions().getIsolationLevel().orNull()); props.put("nuts-secure", () -> (NWorkspaceSecurityManager.of().isSecure())); - props.put("nuts-gui", () -> NBootManager.of().getBootOptions().getGui().orNull()); - props.put("nuts-inherited", () -> NBootManager.of().getBootOptions().getInherited().orNull()); - props.put("nuts-recover", () -> NBootManager.of().getBootOptions().getRecover().orNull()); - props.put("nuts-reset", () -> NBootManager.of().getBootOptions().getReset().orNull()); - props.put("nuts-read-only", () -> NBootManager.of().getBootOptions().getReadOnly().orNull()); - props.put("nuts-debug", () -> NDebugString.of(NBootManager.of().getBootOptions().getDebug().orNull())); - props.put("nuts-bot", () -> NBootManager.of().getBootOptions().getBot().orNull()); - props.put("nuts-trace", () -> NBootManager.of().getBootOptions().getTrace().orNull()); - props.put("nuts-indexed", () -> NBootManager.of().getBootOptions().getIndexed().orNull()); - props.put("nuts-transitive", () -> NBootManager.of().getBootOptions().getTransitive().orNull()); - props.put("nuts-fetch-strategy", () -> NBootManager.of().getBootOptions().getFetchStrategy().orNull()); - props.put("nuts-execution-type", () -> NBootManager.of().getBootOptions().getExecutionType().orNull()); - props.put("nuts-dry", () -> NBootManager.of().getBootOptions().getDry().orNull()); - props.put("nuts-output-format", () -> NBootManager.of().getBootOptions().getOutputFormat().orNull()); - props.put("nuts-confirm", () -> NBootManager.of().getBootOptions().getConfirm().orNull()); - props.put("nuts-dependency-solver", () -> NBootManager.of().getBootOptions().getDependencySolver().orNull()); - props.put("nuts-progress-options", () -> NBootManager.of().getBootOptions().getProgressOptions().orNull()); + props.put("nuts-gui", () -> NWorkspace.get().getBootOptions().getGui().orNull()); + props.put("nuts-inherited", () -> NWorkspace.get().getBootOptions().getInherited().orNull()); + props.put("nuts-recover", () -> NWorkspace.get().getBootOptions().getRecover().orNull()); + props.put("nuts-reset", () -> NWorkspace.get().getBootOptions().getReset().orNull()); + props.put("nuts-read-only", () -> NWorkspace.get().getBootOptions().getReadOnly().orNull()); + props.put("nuts-debug", () -> NDebugString.of(NWorkspace.get().getBootOptions().getDebug().orNull())); + props.put("nuts-bot", () -> NWorkspace.get().getBootOptions().getBot().orNull()); + props.put("nuts-trace", () -> NWorkspace.get().getBootOptions().getTrace().orNull()); + props.put("nuts-indexed", () -> NWorkspace.get().getBootOptions().getIndexed().orNull()); + props.put("nuts-transitive", () -> NWorkspace.get().getBootOptions().getTransitive().orNull()); + props.put("nuts-fetch-strategy", () -> NWorkspace.get().getBootOptions().getFetchStrategy().orNull()); + props.put("nuts-execution-type", () -> NWorkspace.get().getBootOptions().getExecutionType().orNull()); + props.put("nuts-dry", () -> NWorkspace.get().getBootOptions().getDry().orNull()); + props.put("nuts-output-format", () -> NWorkspace.get().getBootOptions().getOutputFormat().orNull()); + props.put("nuts-confirm", () -> NWorkspace.get().getBootOptions().getConfirm().orNull()); + props.put("nuts-dependency-solver", () -> NWorkspace.get().getBootOptions().getDependencySolver().orNull()); + props.put("nuts-progress-options", () -> NWorkspace.get().getBootOptions().getProgressOptions().orNull()); props.put("nuts-progress", () -> NSession.of().get().isProgress()); - props.put("nuts-terminal-mode", () -> NBootManager.of().getBootOptions().getTerminalMode().orNull()); - props.put("nuts-cached", () -> NBootManager.of().getBootOptions().getCached().orNull()); - props.put("nuts-install-companions", () -> NBootManager.of().getBootOptions().getInstallCompanions().orNull()); - props.put("nuts-skip-welcome", () -> NBootManager.of().getBootOptions().getSkipWelcome().orNull()); - props.put("nuts-skip-boot", () -> NBootManager.of().getBootOptions().getSkipBoot().orNull()); - props.put("nuts-init-platforms", () -> NBootManager.of().getBootOptions().getInitPlatforms().orNull()); - props.put("nuts-init-java", () -> NBootManager.of().getBootOptions().getInitJava().orNull()); - props.put("nuts-init-launchers", () -> NBootManager.of().getBootOptions().getInitLaunchers().orNull()); - props.put("nuts-init-scripts", () -> NBootManager.of().getBootOptions().getInitScripts().orNull()); - props.put("nuts-desktop-launcher", () -> NBootManager.of().getBootOptions().getDesktopLauncher().orNull()); - props.put("nuts-menu-launcher", () -> NBootManager.of().getBootOptions().getMenuLauncher().orNull()); - props.put("nuts-user-launcher", () -> NBootManager.of().getBootOptions().getUserLauncher().orNull()); - props.put("nuts-locale", () -> NBootManager.of().getBootOptions().getLocale().orNull()); - props.put("nuts-theme", () -> NBootManager.of().getBootOptions().getTheme().orNull()); - props.put("nuts-username", () -> NBootManager.of().getBootOptions().getUserName().orNull()); + props.put("nuts-terminal-mode", () -> NWorkspace.get().getBootOptions().getTerminalMode().orNull()); + props.put("nuts-cached", () -> NWorkspace.get().getBootOptions().getCached().orNull()); + props.put("nuts-install-companions", () -> NWorkspace.get().getBootOptions().getInstallCompanions().orNull()); + props.put("nuts-skip-welcome", () -> NWorkspace.get().getBootOptions().getSkipWelcome().orNull()); + props.put("nuts-skip-boot", () -> NWorkspace.get().getBootOptions().getSkipBoot().orNull()); + props.put("nuts-init-platforms", () -> NWorkspace.get().getBootOptions().getInitPlatforms().orNull()); + props.put("nuts-init-java", () -> NWorkspace.get().getBootOptions().getInitJava().orNull()); + props.put("nuts-init-launchers", () -> NWorkspace.get().getBootOptions().getInitLaunchers().orNull()); + props.put("nuts-init-scripts", () -> NWorkspace.get().getBootOptions().getInitScripts().orNull()); + props.put("nuts-desktop-launcher", () -> NWorkspace.get().getBootOptions().getDesktopLauncher().orNull()); + props.put("nuts-menu-launcher", () -> NWorkspace.get().getBootOptions().getMenuLauncher().orNull()); + props.put("nuts-user-launcher", () -> NWorkspace.get().getBootOptions().getUserLauncher().orNull()); + props.put("nuts-locale", () -> NWorkspace.get().getBootOptions().getLocale().orNull()); + props.put("nuts-theme", () -> NWorkspace.get().getBootOptions().getTheme().orNull()); + props.put("nuts-username", () -> NWorkspace.get().getBootOptions().getUserName().orNull()); props.put("nuts-solver", () -> { - String ds = NDependencySolverUtils.resolveSolverName(NBootManager.of().getBootOptions().getDependencySolver().orNull()); + String ds = NDependencySolverUtils.resolveSolverName(NWorkspace.get().getBootOptions().getDependencySolver().orNull()); List allDs = NDependencySolver.getSolverNames(); return NText.ofStyled( ds, @@ -401,7 +400,7 @@ private Map> buildMapSupplier() { ); props.put("nuts-solver-list", () -> { - String ds = NDependencySolverUtils.resolveSolverName(NBootManager.of().getBootOptions().getDependencySolver().orNull()); + String ds = NDependencySolverUtils.resolveSolverName(NWorkspace.get().getBootOptions().getDependencySolver().orNull()); List allDs = NDependencySolver.getSolverNames(); NTexts txt = NTexts.of(); return txt.ofBuilder().appendJoined(";", @@ -411,10 +410,10 @@ private Map> buildMapSupplier() { ); } ); - props.put("sys-terminal-flags", () -> NBootManager.of().getBootTerminal().getFlags()); - props.put("sys-terminal-mode", () -> NBootManager.of().getBootOptions().getTerminalMode().orElse(NTerminalMode.DEFAULT)); + props.put("sys-terminal-flags", () -> NWorkspace.get().getBootTerminal().getFlags()); + props.put("sys-terminal-mode", () -> NWorkspace.get().getBootOptions().getTerminalMode().orElse(NTerminalMode.DEFAULT)); props.put("java-version", () -> NVersion.of(System.getProperty("java.version")).get()); - props.put("platform", () -> NEnvs.of().getPlatform()); + props.put("platform", () -> NWorkspace.get().getPlatform()); props.put("java-home", () -> NPath.of(System.getProperty("java.home"))); props.put("java-executable", () -> NPath.of(NJavaSdkUtils.of(NWorkspace.of().get()).resolveJavaCommandByHome(null))); props.put("java-classpath", @@ -431,36 +430,36 @@ private Map> buildMapSupplier() { .collect(Collectors.toList()) ) ); - props.put("os-name", () -> NEnvs.of().getOs()); - props.put("os-family", () -> NEnvs.of().getOsFamily()); - props.put("os-dist", () -> NEnvs.of().getOsDist()); - props.put("os-arch", () -> NEnvs.of().getArch()); - props.put("os-arch-family", () -> NEnvs.of().getArchFamily()); - props.put("os-desktop", () -> NEnvs.of().getDesktopEnvironment()); - props.put("os-desktops", () -> NEnvs.of().getDesktopEnvironments()); - props.put("os-desktop-family", () -> NEnvs.of().getDesktopEnvironmentFamily()); - props.put("os-desktop-families", () -> NEnvs.of().getDesktopEnvironmentFamilies()); - props.put("os-desktop-path", () -> NEnvs.of().getDesktopPath()); - props.put("os-desktop-launcher", () -> NEnvs.of().getDesktopIntegrationSupport(NDesktopIntegrationItem.DESKTOP)); - props.put("os-menu-launcher", () -> NEnvs.of().getDesktopIntegrationSupport(NDesktopIntegrationItem.MENU)); - props.put("os-user-launcher", () -> NEnvs.of().getDesktopIntegrationSupport(NDesktopIntegrationItem.USER)); - props.put("os-shell", () -> NEnvs.of().getShellFamily()); - props.put("os-shells", () -> NEnvs.of().getShellFamilies()); + props.put("os-name", () -> NWorkspace.get().getOs()); + props.put("os-family", () -> NWorkspace.get().getOsFamily()); + props.put("os-dist", () -> NWorkspace.get().getOsDist()); + props.put("os-arch", () -> NWorkspace.get().getArch()); + props.put("os-arch-family", () -> NWorkspace.get().getArchFamily()); + props.put("os-desktop", () -> NWorkspace.get().getDesktopEnvironment()); + props.put("os-desktops", () -> NWorkspace.get().getDesktopEnvironments()); + props.put("os-desktop-family", () -> NWorkspace.get().getDesktopEnvironmentFamily()); + props.put("os-desktop-families", () -> NWorkspace.get().getDesktopEnvironmentFamilies()); + props.put("os-desktop-path", () -> NWorkspace.get().getDesktopPath()); + props.put("os-desktop-launcher", () -> NWorkspace.get().getDesktopIntegrationSupport(NDesktopIntegrationItem.DESKTOP)); + props.put("os-menu-launcher", () -> NWorkspace.get().getDesktopIntegrationSupport(NDesktopIntegrationItem.MENU)); + props.put("os-user-launcher", () -> NWorkspace.get().getDesktopIntegrationSupport(NDesktopIntegrationItem.USER)); + props.put("os-shell", () -> NWorkspace.get().getShellFamily()); + props.put("os-shells", () -> NWorkspace.get().getShellFamilies()); props.put("os-username", () -> stringValue(System.getProperty("user.name"))); props.put("user-home", () -> NPath.ofUserHome()); props.put("user-dir", () -> NPath.ofUserDirectory()); props.put("command-line-long", - () -> NBootManager.of().getBootOptions().toCmdLine(new NWorkspaceOptionsConfig().setCompact(false)) + () -> NWorkspace.get().getBootOptions().toCmdLine(new NWorkspaceOptionsConfig().setCompact(false)) ); - props.put("command-line-short", () -> NBootManager.of().getBootOptions().toCmdLine(new NWorkspaceOptionsConfig().setCompact(true))); - props.put("inherited", () -> NBootManager.of().getBootOptions().getInherited().orElse(false)); + props.put("command-line-short", () -> NWorkspace.get().getBootOptions().toCmdLine(new NWorkspaceOptionsConfig().setCompact(true))); + props.put("inherited", () -> NWorkspace.get().getBootOptions().getInherited().orElse(false)); // nuts-boot-args must always be parsed in bash format props.put("inherited-nuts-boot-args", () -> NCmdLineFormat.of(NCmdLine.of(System.getProperty("nuts.boot.args"), NShellFamily.SH)).format()); props.put("inherited-nuts-args", () -> NCmdLineFormat.of(NCmdLine.of(System.getProperty("nuts.args"), NShellFamily.SH)).format()); - props.put("creation-started", () -> NBootManager.of().getCreationStartTime()); - props.put("creation-finished", () -> NBootManager.of().getCreationFinishTime()); - props.put("creation-within", () -> CoreTimeUtils.formatPeriodMilli(NBootManager.of().getCreationDuration()).trim()); - props.put("repositories-count", () -> (NRepositories.of().getRepositories().size())); + props.put("creation-started", () -> NWorkspace.get().getCreationStartTime()); + props.put("creation-finished", () -> NWorkspace.get().getCreationFinishTime()); + props.put("creation-within", () -> CoreTimeUtils.formatPeriodMilli(NWorkspace.get().getCreationDuration()).trim()); + props.put("repositories-count", () -> (workspace.getRepositories().size())); return props; } @@ -506,7 +505,7 @@ private Map buildWorkspaceMap(boolean deep) { String prefix = null; FilteredMap props = new FilteredMap(filter); NSession session = workspace.currentSession(); - NBootOptions options = NBootManager.of().getBootOptions(); + NBootOptions options = NWorkspace.get().getBootOptions(); Set extraKeys = new TreeSet<>(extraProperties.keySet()); props.put("name", stringValue(session.getWorkspace().getName())); @@ -515,7 +514,7 @@ private Map buildWorkspaceMap(boolean deep) { props.put("nuts-api-id", session.getWorkspace().getApiId()); props.put("nuts-runtime-id", session.getWorkspace().getRuntimeId()); props.put("nuts-app-id", NApp.of().getId().orNull()); - List cl = NBootManager.of().getBootClassWorldURLs(); + List cl = NWorkspace.get().getBootClassWorldURLs(); List runtimeClassPath = new ArrayList<>(); if (cl != null) { for (URL url : cl) { @@ -536,13 +535,13 @@ private Map buildWorkspaceMap(boolean deep) { txt.ofBuilder().appendJoined(";", runtimeClassPath) ); props.put("nuts-workspace-id", txt.ofStyled(stringValue(session.getWorkspace().getUuid()), NTextStyle.path())); - props.put("nuts-store-layout", NLocations.of().getStoreLayout()); - props.put("nuts-store-strategy", NLocations.of().getStoreStrategy()); - props.put("nuts-repo-store-strategy", NLocations.of().getRepositoryStoreStrategy()); + props.put("nuts-store-layout", NWorkspace.get().getStoreLayout()); + props.put("nuts-store-strategy", NWorkspace.get().getStoreStrategy()); + props.put("nuts-repo-store-strategy", NWorkspace.get().getRepositoryStoreStrategy()); props.put("nuts-global", options.getSystem().orNull()); - props.put("nuts-workspace", NLocations.of().getWorkspaceLocation()); + props.put("nuts-workspace", NWorkspace.get().getWorkspaceLocation()); for (NStoreType folderType : NStoreType.values()) { - props.put("nuts-workspace-" + folderType.id(), NLocations.of().getStoreLocation(folderType)); + props.put("nuts-workspace-" + folderType.id(), NWorkspace.get().getStoreLocation(folderType)); } props.put("nuts-open-mode", options.getOpenMode().orNull()); props.put("nuts-isolation-level", options.getIsolationLevel().orNull()); @@ -597,12 +596,12 @@ private Map buildWorkspaceMap(boolean deep) { ) ); - NWorkspaceTerminalOptions b = NBootManager.of().getBootTerminal(); + NWorkspaceTerminalOptions b = NWorkspace.get().getBootTerminal(); props.put("sys-terminal-flags", b.getFlags()); - NTerminalMode terminalMode = NBootManager.of().getBootOptions().getTerminalMode().orElse(NTerminalMode.DEFAULT); + NTerminalMode terminalMode = NWorkspace.get().getBootOptions().getTerminalMode().orElse(NTerminalMode.DEFAULT); props.put("sys-terminal-mode", terminalMode); props.put("java-version", NVersion.of(System.getProperty("java.version")).get()); - props.put("platform", NEnvs.of().getPlatform()); + props.put("platform", NWorkspace.get().getPlatform()); props.put("java-home", NPath.of(System.getProperty("java.home"))); props.put("java-executable", NPath.of(NJavaSdkUtils.of(NWorkspace.of().get()).resolveJavaCommandByHome(null))); props.put("java-classpath", @@ -619,46 +618,45 @@ private Map buildWorkspaceMap(boolean deep) { .collect(Collectors.toList()) ) ); - props.put("os-name", NEnvs.of().getOs()); - props.put("os-family", (NEnvs.of().getOsFamily())); - if (NEnvs.of().getOsDist() != null) { - props.put("os-dist", (NEnvs.of().getOsDist())); + props.put("os-name", NWorkspace.get().getOs()); + props.put("os-family", (NWorkspace.get().getOsFamily())); + if (NWorkspace.get().getOsDist() != null) { + props.put("os-dist", (NWorkspace.get().getOsDist())); } - NEnvs envs = NEnvs.of(); - props.put("os-arch", envs.getArch()); - props.put("os-arch-family", envs.getArchFamily()); - props.put("os-desktop", envs.getDesktopEnvironment()); - props.put("os-desktops", envs.getDesktopEnvironments()); - props.put("os-desktop-family", envs.getDesktopEnvironmentFamily()); - props.put("os-desktop-families", envs.getDesktopEnvironmentFamilies()); - props.put("os-desktop-path", envs.getDesktopPath()); - props.put("os-desktop-launcher", envs.getDesktopIntegrationSupport(NDesktopIntegrationItem.DESKTOP)); - props.put("os-menu-launcher", envs.getDesktopIntegrationSupport(NDesktopIntegrationItem.MENU)); - props.put("os-user-launcher", envs.getDesktopIntegrationSupport(NDesktopIntegrationItem.USER)); - props.put("os-shell", envs.getShellFamily()); - props.put("os-shells", envs.getShellFamilies()); + props.put("os-arch", workspace.getArch()); + props.put("os-arch-family", workspace.getArchFamily()); + props.put("os-desktop", workspace.getDesktopEnvironment()); + props.put("os-desktops", workspace.getDesktopEnvironments()); + props.put("os-desktop-family", workspace.getDesktopEnvironmentFamily()); + props.put("os-desktop-families", workspace.getDesktopEnvironmentFamilies()); + props.put("os-desktop-path", workspace.getDesktopPath()); + props.put("os-desktop-launcher", workspace.getDesktopIntegrationSupport(NDesktopIntegrationItem.DESKTOP)); + props.put("os-menu-launcher", workspace.getDesktopIntegrationSupport(NDesktopIntegrationItem.MENU)); + props.put("os-user-launcher", workspace.getDesktopIntegrationSupport(NDesktopIntegrationItem.USER)); + props.put("os-shell", workspace.getShellFamily()); + props.put("os-shells", workspace.getShellFamilies()); props.put("os-username", stringValue(System.getProperty("user.name"))); props.put("user-home", NPath.ofUserHome()); props.put("user-dir", NPath.ofUserDirectory()); props.put("command-line-long", - NBootManager.of().getBootOptions().toCmdLine(new NWorkspaceOptionsConfig().setCompact(false)) + NWorkspace.get().getBootOptions().toCmdLine(new NWorkspaceOptionsConfig().setCompact(false)) ); - props.put("command-line-short", NBootManager.of().getBootOptions().toCmdLine(new NWorkspaceOptionsConfig().setCompact(true))); - props.put("inherited", NBootManager.of().getBootOptions().getInherited().orElse(false)); + props.put("command-line-short", NWorkspace.get().getBootOptions().toCmdLine(new NWorkspaceOptionsConfig().setCompact(true))); + props.put("inherited", NWorkspace.get().getBootOptions().getInherited().orElse(false)); // nuts-boot-args must always be parsed in bash format props.put("inherited-nuts-boot-args", NCmdLineFormat.of(NCmdLine.of(System.getProperty("nuts.boot.args"), NShellFamily.SH)).format()); props.put("inherited-nuts-args", NCmdLineFormat.of(NCmdLine.of(System.getProperty("nuts.args"), NShellFamily.SH)).format()); - props.put("creation-started", NBootManager.of().getCreationStartTime()); - props.put("creation-finished", NBootManager.of().getCreationFinishTime()); - props.put("creation-within", CoreTimeUtils.formatPeriodMilli(NBootManager.of().getCreationDuration()).trim()); - props.put("repositories-count", (NRepositories.of().getRepositories().size())); + props.put("creation-started", NWorkspace.get().getCreationStartTime()); + props.put("creation-finished", NWorkspace.get().getCreationFinishTime()); + props.put("creation-within", CoreTimeUtils.formatPeriodMilli(NWorkspace.get().getCreationDuration()).trim()); + props.put("repositories-count", (workspace.getRepositories().size())); for (String extraKey : extraKeys) { props.put(extraKey, extraProperties.get(extraKey)); } if (deep) { Map repositories = new LinkedHashMap<>(); props.put("repos", repositories); - for (NRepository repository : NRepositories.of().getRepositories()) { + for (NRepository repository : workspace.getRepositories()) { repositories.put(repository.getName(), buildRepoRepoMap(repository, deep, prefix)); } } @@ -667,7 +665,6 @@ private Map buildWorkspaceMap(boolean deep) { } private Map buildRepoRepoMap(NRepository repo, boolean deep, String prefix) { - NSession session = workspace.currentSession(); FilteredMap props = new FilteredMap(filter); props.put(key(prefix, "name"), stringValue(repo.getName())); props.put(key(prefix, "global-name"), repo.config().getGlobalName()); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/install/AbstractNInstallCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/install/AbstractNInstallCmd.java index 04b6ae75a..05848ce52 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/install/AbstractNInstallCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/install/AbstractNInstallCmd.java @@ -85,7 +85,6 @@ public int getSupportLevel(NSupportLevelContext context) { @Override public NInstallCmd addId(String id) { - NSession session=getWorkspace().currentSession(); return addId(id == null ? null : NId.of(id).get()); } @@ -112,7 +111,6 @@ public NInstallCmd setIds(String... ids) { @Override public NInstallCmd addId(NId id) { if (id == null) { - NSession session=getWorkspace().currentSession(); throw new NNotFoundException(id); } else { ids.put(id, getStrategy()); @@ -146,7 +144,6 @@ public NInstallCmd removeId(NId id) { @Override public NInstallCmd removeId(String id) { - NSession session=getWorkspace().currentSession(); if (id != null) { this.ids.remove(NId.of(id).get()); } @@ -298,7 +295,6 @@ public NInstallStrategy getStrategy() { @Override public boolean configureFirst(NCmdLine cmdLine) { - NSession session=getWorkspace().currentSession(); NArg aa = cmdLine.peek().get(); if (aa == null) { return false; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/prepare/AbstractNPrepareCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/prepare/AbstractNPrepareCmd.java index 5cb2ab54f..b2bc55464 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/prepare/AbstractNPrepareCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/prepare/AbstractNPrepareCmd.java @@ -92,7 +92,6 @@ public String getVersion() { @Override public boolean configureFirst(NCmdLine cmdLine) { - NSession session=getWorkspace().currentSession(); NArg a = cmdLine.peek().get(); if (a == null) { return false; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/prepare/DefaultNPrepareCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/prepare/DefaultNPrepareCmd.java index bd8df85ea..71b36e8e2 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/prepare/DefaultNPrepareCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/prepare/DefaultNPrepareCmd.java @@ -57,7 +57,6 @@ public NPrepareCmd run() { } private void pushId(NId pid, NVersion apiIdVersion) { - NSession session=getWorkspace().currentSession(); NDefinition def = NSearchCmd.of().addId(pid).setOptional(false).setLatest(true).setContent(true).setTargetApiVersion(apiIdVersion).getResultDefinitions().findFirst().get(); NPath apiJar = def.getContent().get(); if (!runRemoteAsStringNoFail("ls " + remoteIdMavenJar(def.getApiId()))) { @@ -80,7 +79,6 @@ private String remoteIdMavenJar(NId apiId) { private NPath remoteJavaCommand(NVersion apiVersion) { //check JDK8 ? - NSession session=getWorkspace().currentSession(); return NPath.of("java"); } @@ -100,7 +98,6 @@ private NPath remoteNutsCommand() { } private NPath remoteHomeFile(String path) { - NSession session=getWorkspace().currentSession(); if (NBlankable.isBlank(targetHome)) { String user = getValidUser(); return NPath.of("/home/" + user + "/" + path); @@ -139,7 +136,6 @@ private void mkdirs(NPath path) { } private String runRemoteAsString(String... cmd) { - NSession session=getWorkspace().currentSession(); String remoteUser = getValidUser(); NExecCmd e = NExecCmd.of(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/push/AbstractDefaultNPushCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/push/AbstractDefaultNPushCmd.java index 2f471207a..f77dfd297 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/push/AbstractDefaultNPushCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/push/AbstractDefaultNPushCmd.java @@ -59,20 +59,17 @@ public int getSupportLevel(NSupportLevelContext context) { @Override public NPushCmd addId(String id) { - NSession session=getWorkspace().currentSession(); return addId(id == null ? null : NId.of(id).get()); } @Override public NPushCmd addLockedId(String id) { - NSession session=getWorkspace().currentSession(); return addLockedId(id == null ? null : NId.of(id).get()); } @Override public NPushCmd addId(NId id) { if (id == null) { - NSession session=getWorkspace().currentSession(); throw new NNotFoundException(id); } else { ids.add(id); @@ -91,7 +88,6 @@ public NPushCmd removeId(NId id) { @Override public NPushCmd removeId(String id) { if (id != null) { - NSession session=getWorkspace().currentSession(); ids.remove(NId.of(id).get()); } return this; @@ -109,7 +105,6 @@ public NPushCmd removeLockedId(NId id) { @Override public NPushCmd removeLockedId(String id) { - NSession session=getWorkspace().currentSession(); if (id != null) { if (lockedIds != null) { lockedIds.remove(NId.of(id).get()); @@ -121,7 +116,6 @@ public NPushCmd removeLockedId(String id) { @Override public NPushCmd addLockedId(NId id) { if (id == null) { - NSession session=getWorkspace().currentSession(); throw new NNotFoundException(id); } else { if (lockedIds == null) { @@ -259,7 +253,6 @@ public NPushCmd clearLockedIds() { @Override public boolean configureFirst(NCmdLine cmdLine) { - NSession session=getWorkspace().currentSession(); NArg a = cmdLine.peek().get(); if (a == null) { return false; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/push/DefaultNPushCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/push/DefaultNPushCmd.java index 2dc6fdb72..e7b3c04a3 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/push/DefaultNPushCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/push/DefaultNPushCmd.java @@ -54,7 +54,6 @@ public DefaultNPushCmd(NWorkspace workspace) { @Override public NPushCmd run() { - NSession session=getWorkspace().currentSession(); NRepositoryFilter repositoryFilter = null; Map toProcess = new LinkedHashMap<>(); for (NId id : this.getIds()) { @@ -110,7 +109,7 @@ public NPushCmd run() { )); } } else { - NRepository repo = NRepositories.of().findRepository(this.getRepository()).get(); + NRepository repo = workspace.findRepository(this.getRepository()).get(); if (!repo.config().isEnabled()) { throw new NIllegalArgumentException(NMsg.ofC("repository %s is disabled", repo.getName())); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/recom/AbstractRecommendationConnector.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/recom/AbstractRecommendationConnector.java index 163822633..8329b5790 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/recom/AbstractRecommendationConnector.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/recom/AbstractRecommendationConnector.java @@ -1,7 +1,7 @@ package net.thevpc.nuts.runtime.standalone.workspace.cmd.recom; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NEnvs; + import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.util.ExtraApiUtils; import net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.clinfo.NCliInfo; @@ -26,7 +26,6 @@ private String getLocalUserUUID() { if (localUserUUID != null) { return localUserUUID; } - NSession session= workspace.currentSession(); localUserUUID = NCliInfo.loadCliId(true); return localUserUUID; } @@ -38,7 +37,6 @@ public NWorkspace getWorkspace() { @Override public Map getRecommendations(RequestQueryInfo ri, NRecommendationPhase phase, boolean failure) { validateRequest(ri); - NSession session= workspace.currentSession(); NId id = NId.of(ri.q.getId()).ifBlankEmpty().get(); String name = phase.name().toLowerCase() + (failure ? "-failure" : "") + "-recommendations.json"; String url = "/repo/" + ExtraApiUtils.resolveIdPath(id) + '/' + name; @@ -50,19 +48,17 @@ public Map getRecommendations(RequestQueryInfo ri, NRecommendationPhase phase, b public void validateRequest(RequestQueryInfo ri) { NSession session= workspace.currentSession(); - NEnvs envs = NEnvs.of(); - NLiteral endPointURL = envs.getProperty("nuts-endpoint-url").orNull(); + NLiteral endPointURL = workspace.getProperty("nuts-endpoint-url").orNull(); if (NBlankable.isBlank(ri.server)) { if (endPointURL == null || endPointURL.isBlank()) { String defaultURL = resolveDefaultEndpointURL(); - envs.setProperty("nuts-endpoint-url", defaultURL); + workspace.setProperty("nuts-endpoint-url", defaultURL); } else { ri.server = endPointURL.asString().get(); } } - NEnvs env = envs; RequestAgent agent = ri.q.getAgent(); - NWorkspace ws = session.getWorkspace(); + NWorkspace ws = workspace; if (agent.getApiVersion() == null) { agent.setApiVersion(ws.getApiVersion().toString()); } @@ -70,22 +66,22 @@ public void validateRequest(RequestQueryInfo ri) { agent.setRuntimeId(ws.getRuntimeId().toString()); } if (agent.getArch() == null) { - agent.setArch(env.getArch().toString()); + agent.setArch(workspace.getArch().toString()); } if (agent.getOs() == null) { - agent.setOs(env.getOs().toString()); + agent.setOs(workspace.getOs().toString()); } if (agent.getOsDist() == null) { - agent.setOsDist(env.getOsDist().toString()); + agent.setOsDist(workspace.getOsDist().toString()); } if (agent.getDesktop() == null) { - agent.setDesktop(env.getDesktopEnvironment().toString()); + agent.setDesktop(workspace.getDesktopEnvironment().toString()); } if (agent.getPlatform() == null) { - agent.setPlatform(env.getPlatform().toString()); + agent.setPlatform(workspace.getPlatform().toString()); } if (agent.getShell() == null) { - agent.setShell(env.getShellFamily().toString()); + agent.setShell(workspace.getShellFamily().toString()); } if (agent.getUserDigest() == null) { agent.setUserDigest(getLocalUserUUID()); @@ -118,7 +114,6 @@ private String resolveDefaultEndpointURL() { } } else { try { - NSession session= workspace.currentSession(); String s = NStringUtils.trimToNull(NPath.of("https://raw.githubusercontent.com/thevpc/nuts/master/.endpoint").readString()); if (s != null && s.startsWith("https://")) { return s; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/search/AbstractNSearchCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/search/AbstractNSearchCmd.java index aaf8da425..68e6b682d 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/search/AbstractNSearchCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/search/AbstractNSearchCmd.java @@ -26,8 +26,9 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; + + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; @@ -95,7 +96,6 @@ public NSearchCmd clearIds() { @Override public NSearchCmd addId(String id) { - NSession session=getWorkspace().currentSession(); if (!NBlankable.isBlank(id)) { ids.add(NId.of(id).get()); } @@ -741,7 +741,7 @@ public NStream getResultInstallFolders() { @Override public NStream getResultStoreLocations(NStoreType location) { return postProcessResult(NIteratorBuilder.of(getResultDefinitionIteratorBase(isContent(), isEffective())) - .map(NFunction.of((NDefinition x) -> NLocations.of().getStoreLocation(x.getId(), location)) + .map(NFunction.of((NDefinition x) -> NWorkspace.get().getStoreLocation(x.getId(), location)) .withDesc(NEDesc.of("getStoreLocation(" + location.id() + ")")) ) .notNull()); @@ -1299,7 +1299,14 @@ public NIterator getResultDefinitionIteratorBase(boolean content, b .map(NFunction.of((NId next) -> { // NutsDefinition d = null; // if (isContent()) { - NDefinition d = fetch.setId(next).getResultDefinition(); + NDefinition d=null; + try { + d = fetch.setId(next).getResultDefinition(); + }catch (NNotFoundException e){ + if(next.toDependency().isOptional()){ + return null; + } + } if (d == null) { if (isFailFast()) { throw new NNotFoundException(next); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/search/DefaultNSearchCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/search/DefaultNSearchCmd.java index 028644569..5554f66e9 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/search/DefaultNSearchCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/search/DefaultNSearchCmd.java @@ -26,7 +26,8 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NImports; + + import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.elem.NEDesc; import net.thevpc.nuts.elem.NElements; @@ -71,7 +72,6 @@ public NSearchCmd copy() { @Override public NFetchCmd toFetch() { - NSession session=getWorkspace().currentSession(); NFetchCmd t = new DefaultNFetchCmd(getWorkspace()).copyFromDefaultNQueryBaseOptions(this) ; if (getDisplayOptions().isRequireDefinition()) { @@ -203,7 +203,7 @@ private DefaultNSearch build() { NDescriptorFilter _descriptorFilter = dfilter.always(); NIdFilter _idFilter = NIdFilters.of().always(); NDependencyFilter depFilter = NDependencyFilters.of().always(); - NRepositoryFilter rfilter = NRepositories.of().filter().always(); + NRepositoryFilter rfilter = NRepositoryFilters.of().always(); for (String j : this.getScripts()) { if (!NBlankable.isBlank(j)) { if (CoreStringUtils.containsTopWord(j, "descriptor")) { @@ -564,7 +564,7 @@ public NIterator getResultIdIteratorBase(Boolean forceInlineDependencies) { if (!installedIds.isEmpty()) { nutsId2.addAll(installedIds); } else { - for (String aImport : NImports.of().getAllImports()) { + for (String aImport : NWorkspace.get().getAllImports()) { //example import(net.thevpc),search(pnote) ==>net.thevpc:pnote nutsId2.add(nutsId.builder().setGroupId(aImport).build()); //example import(net.thevpc),search(pnote) ==>net.thevpc.pnote:pnote @@ -827,7 +827,6 @@ public NIterator getResultIdIteratorBase(Boolean forceInlineDependencies) { private NIterator filterLatestAndDuplicatesThenSort(NIterator baseIterator, boolean latest, boolean distinct, boolean sort) { //ff ft tt tf NIterator r; - NSession session=getWorkspace().currentSession(); if (!latest && !distinct) { r = baseIterator; } else if (!latest && distinct) { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/CommandNWorkspaceCommandFactory.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/CommandNWorkspaceCommandFactory.java index 846c6249e..6b22c90cb 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/CommandNWorkspaceCommandFactory.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/CommandNWorkspaceCommandFactory.java @@ -2,7 +2,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NShellFamily; +import net.thevpc.nuts.NShellFamily; import java.util.ArrayList; import java.util.Arrays; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ConfigNWorkspaceCommandFactory.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ConfigNWorkspaceCommandFactory.java index e920c4019..3689b9520 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ConfigNWorkspaceCommandFactory.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ConfigNWorkspaceCommandFactory.java @@ -3,11 +3,12 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; + + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.util.filters.CoreFilterUtils; -import net.thevpc.nuts.runtime.standalone.workspace.config.NConfigsExt; +import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; import net.thevpc.nuts.runtime.standalone.workspace.config.ConfigEventType; import net.thevpc.nuts.log.NLog; import net.thevpc.nuts.log.NLogOp; @@ -68,7 +69,7 @@ public List findCommands() { } public NPath getStoreLocation() { - return NLocations.of().getStoreLocation(workspace.getApiId(), NStoreType.BIN); + return NWorkspace.get().getStoreLocation(workspace.getApiId(), NStoreType.BIN); } private NPath getCommandsFolder() { @@ -81,7 +82,7 @@ public void uninstallCommand(String name) { NPath file = getCommandsFolder().resolve(name + NConstants.Files.NUTS_COMMAND_FILE_EXTENSION); if (file.exists()) { file.delete(); - NConfigsExt.of(NConfigs.of()).getModel().fireConfigurationChanged("command", ConfigEventType.MAIN); + NWorkspaceExt.of(workspace).getConfigModel().fireConfigurationChanged("command", ConfigEventType.MAIN); } } @@ -89,7 +90,7 @@ public void installCommand(NCommandConfig command) { NPath path = getCommandsFolder().resolve(command.getName() + NConstants.Files.NUTS_COMMAND_FILE_EXTENSION); NElements.of().json().setValue(command) .setNtf(false).print(path); - NConfigsExt.of(NConfigs.of()).getModel().fireConfigurationChanged("command", ConfigEventType.MAIN); + NWorkspaceExt.of(workspace).getConfigModel().fireConfigurationChanged("command", ConfigEventType.MAIN); } public List findCommands(NId id) { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/alias/NSettingsAliasSubCommand.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/alias/NSettingsAliasSubCommand.java index 7941a632e..ef08e3a8a 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/alias/NSettingsAliasSubCommand.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/alias/NSettingsAliasSubCommand.java @@ -8,7 +8,8 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NShellFamily; + +import net.thevpc.nuts.NShellFamily; import net.thevpc.nuts.format.NPropertiesFormat; import net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.AbstractNSettingsSubCommand; import net.thevpc.nuts.util.NLiteral; @@ -44,7 +45,7 @@ public boolean exec(NCmdLine cmdLine, Boolean autoSave) { } } if (cmdLine.isExecMode()) { - List r = NCommands.of().findAllCommands() + List r = NWorkspace.get().findAllCommands() .stream() .filter(new Predicate() { @Override @@ -91,9 +92,9 @@ public boolean test(NCustomCmd nutsWorkspaceCommandAlias) { } else if (cmdLine.next("remove alias","alias remove").isPresent()) { if (cmdLine.isExecMode()) { while (cmdLine.hasNext()) { - NCommands.of().removeCommand(cmdLine.next().get().toString()); + NWorkspace.get().removeCommand(cmdLine.next().get().toString()); } - NConfigs.of().save(); + NWorkspace.get().saveConfig(); } return true; } else if (cmdLine.next("add alias","alias add").isPresent()) { @@ -127,7 +128,7 @@ public boolean test(NCustomCmd nutsWorkspaceCommandAlias) { cmdLine.next().get(); } for (AliasInfo value : toAdd.values()) { - NCommands.of() + workspace .addCommand( new NCommandConfig() .setCommand(NCmdLine.of(value.command, NShellFamily.BASH).setExpandSimpleOptions(false).toStringArray()) @@ -137,7 +138,7 @@ public boolean test(NCustomCmd nutsWorkspaceCommandAlias) { .setExpandSimpleOptions(false).toStringList()) ); } - NConfigs.of().save(); + NWorkspace.get().saveConfig(); } return true; } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/archetype/NSettingsArchetypeSubCommand.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/archetype/NSettingsArchetypeSubCommand.java index b6c51e75c..41bd4037f 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/archetype/NSettingsArchetypeSubCommand.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/archetype/NSettingsArchetypeSubCommand.java @@ -5,10 +5,10 @@ */ package net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.archetype; -import net.thevpc.nuts.NConfigs; import net.thevpc.nuts.NSession; import net.thevpc.nuts.NWorkspace; import net.thevpc.nuts.cmdline.NCmdLine; + import net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.AbstractNSettingsSubCommand; /** @@ -25,7 +25,7 @@ public boolean exec(NCmdLine cmdLine, Boolean autoSave) { if (cmdLine.next("list archetypes","list archetype","archetype list", "la").isPresent()) { if (cmdLine.isExecMode()) { NSession session=workspace.currentSession(); - session.out().println(NConfigs.of().getAvailableArchetypes()); + session.out().println(NWorkspace.get().getAvailableArchetypes()); } return true; } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/backup/NSettingsBackupSubCommand.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/backup/NSettingsBackupSubCommand.java index 036291daa..cd42a7c7e 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/backup/NSettingsBackupSubCommand.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/backup/NSettingsBackupSubCommand.java @@ -10,15 +10,16 @@ import net.thevpc.nuts.cmdline.NCmdLine; import net.thevpc.nuts.elem.NElements; import net.thevpc.nuts.elem.NObjectElement; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; + + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NCompress; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.io.NUncompress; import net.thevpc.nuts.io.NUncompressVisitor; import net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.AbstractNSettingsSubCommand; import net.thevpc.nuts.util.NMsg; -import net.thevpc.nuts.env.NPlatformHome; +import net.thevpc.nuts.NPlatformHome; import java.io.File; import java.io.InputStream; @@ -53,11 +54,11 @@ public boolean exec(NCmdLine cmdLine, Boolean autoSave) { } if (cmdLine.isExecMode()) { List all = new ArrayList<>(); - all.add(NLocations.of().getWorkspaceLocation().toPath().get() + all.add(NWorkspace.get().getWorkspaceLocation().toPath().get() .resolve("nuts-workspace.json").toString() ); for (NStoreType value : NStoreType.values()) { - NPath r = NLocations.of().getStoreLocation(value); + NPath r = NWorkspace.get().getStoreLocation(value); if (r.isDirectory()) { all.add(r.toString()); } @@ -139,7 +140,7 @@ public boolean visitFile(String path, InputStream inputStream) { if (ws == null || ws.isEmpty()) { cmdLine.throwMissingArgument(NMsg.ofC("not a valid file : %s", file)); } - String platformHomeFolder = NPlatformHome.of(null, NConfigs.of().stored().isSystem()).getWorkspaceLocation(ws); + String platformHomeFolder = NPlatformHome.of(null, NWorkspace.get().getStoredConfig().isSystem()).getWorkspaceLocation(ws); NUncompress.of() .from(NPath.of(file)) .to(NPath.of(platformHomeFolder)) diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/clinfo/NCliInfo.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/clinfo/NCliInfo.java index 6986c0df0..a5be1bcdc 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/clinfo/NCliInfo.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/clinfo/NCliInfo.java @@ -2,7 +2,7 @@ import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NPlatformHome; +import net.thevpc.nuts.NPlatformHome; import net.thevpc.nuts.util.NStringUtils; import java.nio.file.Files; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/delete/NSettingsDeleteFoldersSubCommand.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/delete/NSettingsDeleteFoldersSubCommand.java index 1edab2ef3..33a87845f 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/delete/NSettingsDeleteFoldersSubCommand.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/delete/NSettingsDeleteFoldersSubCommand.java @@ -8,8 +8,9 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; + + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.AbstractNSettingsSubCommand; import net.thevpc.nuts.text.NText; @@ -88,7 +89,7 @@ public boolean exec(NCmdLine cmdLine, Boolean autoSave) { } private void deleteWorkspaceFolder(NStoreType folder, boolean force) { - NPath sstoreLocation = NLocations.of().getStoreLocation(folder); + NPath sstoreLocation = NWorkspace.get().getStoreLocation(folder); NSession session = workspace.currentSession(); if (sstoreLocation != null) { NTexts factory = NTexts.of(); @@ -105,13 +106,13 @@ private void deleteWorkspaceFolder(NStoreType folder, boolean force) { } } } - for (NRepository repository : NRepositories.of().getRepositories()) { + for (NRepository repository : workspace.getRepositories()) { deleteRepoFolder(repository, folder, force); } } private void deleteRepoFolder(NRepository repository, NStoreType folder, boolean force) { - NPath sstoreLocation = NLocations.of().getStoreLocation(folder); + NPath sstoreLocation = NWorkspace.get().getStoreLocation(folder); if (sstoreLocation != null) { NTexts factory = NTexts.of(); NSession session = workspace.currentSession(); @@ -136,13 +137,13 @@ private void deleteRepoFolder(NRepository repository, NStoreType folder, boolean } private void deleteCache(NSession session, boolean force) { - NPath sstoreLocation = NLocations.of().getStoreLocation(NStoreType.CACHE); + NPath sstoreLocation = NWorkspace.get().getStoreLocation(NStoreType.CACHE); if (sstoreLocation != null) { // File cache = new File(storeLocation); if (sstoreLocation.exists()) { sstoreLocation.delete(); } - for (NRepository repository : NRepositories.of().getRepositories()) { + for (NRepository repository : workspace.getRepositories()) { deleteRepoCache(repository, force); } } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/imports/NSettingsImportSubCommand.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/imports/NSettingsImportSubCommand.java index dead41fe8..26e4f1be6 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/imports/NSettingsImportSubCommand.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/imports/NSettingsImportSubCommand.java @@ -5,10 +5,9 @@ */ package net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.imports; -import net.thevpc.nuts.NConfigs; -import net.thevpc.nuts.env.NImports; import net.thevpc.nuts.NSession; import net.thevpc.nuts.NWorkspace; + import net.thevpc.nuts.util.NMsg; import net.thevpc.nuts.cmdline.NArgName; import net.thevpc.nuts.cmdline.NCmdLine; @@ -29,7 +28,7 @@ public boolean exec(NCmdLine cmdLine, Boolean autoSave) { if (cmdLine.next("list imports","list import","import list", "li").isPresent()) { cmdLine.setCommandName("config list imports").throwUnexpectedArgument(); if (cmdLine.isExecMode()) { - for (String imp : (NImports.of().getAllImports())) { + for (String imp : (NWorkspace.get().getAllImports())) { session.out().println(NMsg.ofPlain(imp)); } } @@ -37,8 +36,8 @@ public boolean exec(NCmdLine cmdLine, Boolean autoSave) { } else if (cmdLine.next("clear imports", "ci").isPresent()) { cmdLine.setCommandName("config clear imports").throwUnexpectedArgument(); if (cmdLine.isExecMode()) { - NImports.of().clearImports(); - NConfigs.of().save(); + NWorkspace.get().clearImports(); + NWorkspace.get().saveConfig(); } return true; } else if (cmdLine.next("import", "ia").isPresent()) { @@ -46,11 +45,11 @@ public boolean exec(NCmdLine cmdLine, Boolean autoSave) { String a = cmdLine.nextNonOption(NArgName.of("import")).get() .asString().get(); if (cmdLine.isExecMode()) { - NImports.of().addImports(new String[]{a}); + NWorkspace.get().addImports(new String[]{a}); } } while (cmdLine.hasNext()); if (cmdLine.isExecMode()) { - NConfigs.of().save(); + NWorkspace.get().saveConfig(); } return true; } else if (cmdLine.next("unimport", "ir").isPresent()) { @@ -58,11 +57,11 @@ public boolean exec(NCmdLine cmdLine, Boolean autoSave) { String ii = cmdLine.nextNonOption(NArgName.of("import")).get() .asString().get(); if (cmdLine.isExecMode()) { - NImports.of().removeImports(new String[]{ii}); + NWorkspace.get().removeImports(new String[]{ii}); } } if (cmdLine.isExecMode()) { - NConfigs.of().save(); + NWorkspace.get().saveConfig(); } return true; } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/index/NSettingsIndexSubCommand.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/index/NSettingsIndexSubCommand.java index 42cb4faba..3cb6bba2f 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/index/NSettingsIndexSubCommand.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/index/NSettingsIndexSubCommand.java @@ -5,7 +5,6 @@ */ package net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.index; -import net.thevpc.nuts.NConfigs; import net.thevpc.nuts.NWorkspace; import net.thevpc.nuts.util.NLiteral; import net.thevpc.nuts.NUpdateStatsCmd; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/java/NSettingsJavaSubCommand.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/java/NSettingsJavaSubCommand.java index e8d562779..2c6a14867 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/java/NSettingsJavaSubCommand.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/java/NSettingsJavaSubCommand.java @@ -7,13 +7,14 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.cmdline.NCmdLine; + import net.thevpc.nuts.format.NMutableTableModel; import net.thevpc.nuts.format.NTableFormat; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.io.NPrintStream; import net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.AbstractNSettingsSubCommand; import net.thevpc.nuts.util.NLiteral; -import net.thevpc.nuts.env.NPlatformFamily; +import net.thevpc.nuts.NPlatformFamily; import java.util.ArrayList; import java.util.Arrays; @@ -35,8 +36,6 @@ public boolean exec(NCmdLine cmdLine, Boolean autoSave) { } NSession session=workspace.currentSession(); NPrintStream out = session.out(); - NConfigs conf = NConfigs.of(); - NPlatforms platforms = NPlatforms.of(); if (cmdLine.next("add java","java add").isPresent()) { if (cmdLine.next("--search").isPresent()) { List extraLocations = new ArrayList<>(); @@ -44,30 +43,30 @@ public boolean exec(NCmdLine cmdLine, Boolean autoSave) { extraLocations.add(cmdLine.next().flatMap(NLiteral::asString).get()); } if (extraLocations.isEmpty()) { - for (NPlatformLocation loc : platforms.searchSystemPlatforms(NPlatformFamily.JAVA)) { - platforms.addPlatform(loc); + for (NPlatformLocation loc : workspace.searchSystemPlatforms(NPlatformFamily.JAVA)) { + workspace.addPlatform(loc); } } else { for (String extraLocation : extraLocations) { - for (NPlatformLocation loc : platforms.searchSystemPlatforms(NPlatformFamily.JAVA, NPath.of(extraLocation))) { - platforms.addPlatform(loc); + for (NPlatformLocation loc : workspace.searchSystemPlatforms(NPlatformFamily.JAVA, NPath.of(extraLocation))) { + workspace.addPlatform(loc); } } } cmdLine.setCommandName("config java").throwUnexpectedArgument(); if (autoSave) { - conf.save(false); + workspace.saveConfig(false); } } else { while (cmdLine.hasNext()) { - NPlatformLocation loc = platforms.resolvePlatform(NPlatformFamily.JAVA, + NPlatformLocation loc = workspace.resolvePlatform(NPlatformFamily.JAVA, NPath.of(cmdLine.next().flatMap(NLiteral::asString).get()), null).orNull(); if (loc != null) { - platforms.addPlatform(loc); + workspace.addPlatform(loc); } } if (autoSave) { - conf.save(false); + workspace.saveConfig(false); } } return true; @@ -75,19 +74,19 @@ public boolean exec(NCmdLine cmdLine, Boolean autoSave) { while (cmdLine.hasNext()) { String name = cmdLine.next() .flatMap(NLiteral::asString).get(); - NPlatformLocation loc = platforms.findPlatformByName(NPlatformFamily.JAVA, name).orNull(); + NPlatformLocation loc = workspace.findPlatformByName(NPlatformFamily.JAVA, name).orNull(); if (loc == null) { - loc = platforms.findPlatformByName(NPlatformFamily.JAVA, name).orNull(); + loc = workspace.findPlatformByName(NPlatformFamily.JAVA, name).orNull(); if (loc == null) { - loc = platforms.findPlatformByVersion(NPlatformFamily.JAVA, name).orNull(); + loc = workspace.findPlatformByVersion(NPlatformFamily.JAVA, name).orNull(); } } if (loc != null) { - platforms.removePlatform(loc); + workspace.removePlatform(loc); } } if (autoSave) { - conf.save(false); + workspace.saveConfig(false); } return true; } else if (cmdLine.next("list java","java list").isPresent()) { @@ -103,7 +102,7 @@ public boolean exec(NCmdLine cmdLine, Boolean autoSave) { } } if (cmdLine.isExecMode()) { - NPlatformLocation[] sdks = platforms.findPlatforms(NPlatformFamily.JAVA, null).toArray(NPlatformLocation[]::new); + NPlatformLocation[] sdks = workspace.findPlatforms(NPlatformFamily.JAVA, null).toArray(NPlatformLocation[]::new); Arrays.sort(sdks, new Comparator() { @Override public int compare(NPlatformLocation o1, NPlatformLocation o2) { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/NSettingsNdiSubCommand.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/NSettingsNdiSubCommand.java index f4102b745..7093f0113 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/NSettingsNdiSubCommand.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/NSettingsNdiSubCommand.java @@ -3,7 +3,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NEnvs; + import net.thevpc.nuts.ext.NExtensions; import net.thevpc.nuts.io.NIOException; import net.thevpc.nuts.runtime.standalone.io.util.CoreIOUtils; @@ -32,8 +32,7 @@ public NSettingsNdiSubCommand(NWorkspace workspace) { public static SystemNdi createNdi(NWorkspace workspace) { SystemNdi ndi = null; - NEnvs workspaceEnvManager = NEnvs.of(); - switch (workspaceEnvManager.getOsFamily()) { + switch (workspace.getOsFamily()) { case LINUX: case UNIX: { @@ -249,7 +248,7 @@ class Data { if (d.ignoreUnsupportedOs) { return; } - throw new NExecutionException(NMsg.ofC("platform not supported : %s", NEnvs.of().getOs()), NExecutionException.ERROR_2); + throw new NExecutionException(NMsg.ofC("platform not supported : %s", NWorkspace.get().getOs()), NExecutionException.ERROR_2); } if (!d.idsToInstall.isEmpty()) { printResults(ndi.addScript(d.options, d.idsToInstall.toArray(new String[0]))); @@ -314,7 +313,7 @@ public void runRemoveLauncher(NCmdLine cmdLine) { if (ignoreUnsupportedOs) { return; } - throw new NExecutionException(NMsg.ofC("platform not supported : %s", NEnvs.of().getOs()), NExecutionException.ERROR_2); + throw new NExecutionException(NMsg.ofC("platform not supported : %s", NWorkspace.get().getOs()), NExecutionException.ERROR_2); } boolean subTrace = session.isTrace(); if (!session.isPlainTrace()) { @@ -427,7 +426,7 @@ class Data { if (d.ignoreUnsupportedOs) { return; } - throw new NExecutionException(NMsg.ofC("platform not supported : %s ", NEnvs.of().getOs()), NExecutionException.ERROR_2); + throw new NExecutionException(NMsg.ofC("platform not supported : %s ", NWorkspace.get().getOs()), NExecutionException.ERROR_2); } if (d.switchWorkspaceLocation != null || d.switchWorkspaceApi != null) { NdiScriptOptions oo = new NdiScriptOptions(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/NdiScriptOptions.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/NdiScriptOptions.java index 4b785f0ae..8d4d02882 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/NdiScriptOptions.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/NdiScriptOptions.java @@ -2,9 +2,10 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NLauncherOptions; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; + +import net.thevpc.nuts.NLauncherOptions; + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NIOException; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.util.NAssert; @@ -132,7 +133,7 @@ public NPath resolveNutsApiJarPath() { } else { NWorkspaceBootConfig bootConfig = loadSwitchWorkspaceLocationConfig(getLauncher().getSwitchWorkspaceLocation()); nutsApiJarPath = NPath.of(bootConfig.getStoreLocation(nid, NStoreType.LIB)); - NLocations.of().getDefaultIdFilename(nid); + NWorkspace.get().getDefaultIdFilename(nid); } } return nutsApiJarPath; @@ -147,7 +148,7 @@ public NPath resolveNutsAppJarPath() { } else { NWorkspaceBootConfig bootConfig = loadSwitchWorkspaceLocationConfig(getLauncher().getSwitchWorkspaceLocation()); nutsAppJarPath = NPath.of(bootConfig.getStoreLocation(nid, NStoreType.LIB)); - NLocations.of().getDefaultIdFilename(nid); + NWorkspace.get().getDefaultIdFilename(nid); } } return nutsAppJarPath; @@ -170,7 +171,7 @@ public NPath resolveNutsBinFolder() { bootConfig.getStoreLocation(apiId, NStoreType.BIN) ); } else { - return NLocations.of().getStoreLocation(apiId, NStoreType.BIN); + return NWorkspace.get().getStoreLocation(apiId, NStoreType.BIN); } } @@ -185,7 +186,7 @@ public NPath resolveNutsApiBinFolder() { bootConfig = loadSwitchWorkspaceLocationConfig(getLauncher().getSwitchWorkspaceLocation()); return NPath.of(bootConfig.getStoreLocation(apiId, NStoreType.BIN)); } else { - return NLocations.of().getStoreLocation(apiId, NStoreType.BIN); + return NWorkspace.get().getStoreLocation(apiId, NStoreType.BIN); } } @@ -253,13 +254,13 @@ public Path getWorkspaceLocation() { NWorkspaceBootConfig bootConfig = loadSwitchWorkspaceLocationConfig(getLauncher().getSwitchWorkspaceLocation()); return Paths.get(bootConfig.getEffectiveWorkspace()); } else { - return NLocations.of().getWorkspaceLocation().toPath().get(); + return NWorkspace.get().getWorkspaceLocation().toPath().get(); } } public NWorkspaceBootConfig loadSwitchWorkspaceLocationConfig(String switchWorkspaceLocation) { if (workspaceBootConfig == null) { - workspaceBootConfig = NConfigs.of().loadBootConfig(switchWorkspaceLocation, false, true); + workspaceBootConfig = NWorkspace.get().loadBootConfig(switchWorkspaceLocation, false, true); if (workspaceBootConfig == null) { throw new NIllegalArgumentException(NMsg.ofC("invalid workspace: %s", switchWorkspaceLocation)); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/base/BaseSystemNdi.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/base/BaseSystemNdi.java index 4258048ec..2fe61e094 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/base/BaseSystemNdi.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/base/BaseSystemNdi.java @@ -2,7 +2,6 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.*; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.cmdline.NCmdLine; import net.thevpc.nuts.io.*; @@ -37,7 +36,7 @@ public BaseSystemNdi(NWorkspace workspace) { public NdiScriptInfo[] getSysRC(NdiScriptOptions options) { List scriptInfos = new ArrayList<>(); Set visited = new LinkedHashSet<>(); - for (NShellFamily sf : NEnvs.of().getShellFamilies()) { + for (NShellFamily sf : NWorkspace.get().getShellFamilies()) { String z = NShellHelper.of(sf).getSysRcName(); if (!visited.contains(z)) { visited.add(z); @@ -276,7 +275,7 @@ public boolean isNutsBootId(NId nid) { public PathInfo[] addScript(NdiScriptOptions options, String[] all) { List idsToInstall = Arrays.asList(all); NSession session = workspace.currentSession(); - Path workspaceLocation = NLocations.of().getWorkspaceLocation().toPath().get(); + Path workspaceLocation = NWorkspace.get().getWorkspaceLocation().toPath().get(); List result = new ArrayList<>(); Boolean systemWideConfig = options.getLauncher().getSwitchWorkspace(); if (!idsToInstall.isEmpty()) { @@ -422,7 +421,7 @@ private NDefinition loadIdDefinition(NId nid) { } public NSupportMode getDesktopIntegrationSupport(NDesktopIntegrationItem target) { - return NEnvs.of().getDesktopIntegrationSupport(target); + return NWorkspace.get().getDesktopIntegrationSupport(target); } protected boolean matchCondition(NSupportMode createDesktop, NSupportMode desktopIntegrationSupport) { @@ -437,7 +436,7 @@ public void onPostGlobal(NdiScriptOptions options, PathInfo[] updatedPaths) { } public NWorkspaceBootConfig loadSwitchWorkspaceLocationConfig(String switchWorkspaceLocation) { - NWorkspaceBootConfig bootConfig = NConfigs.of().loadBootConfig(switchWorkspaceLocation, false, true); + NWorkspaceBootConfig bootConfig = NWorkspace.get().loadBootConfig(switchWorkspaceLocation, false, true); if (bootConfig == null) { throw new NIllegalArgumentException(NMsg.ofC("invalid workspace: %s", switchWorkspaceLocation)); } @@ -760,7 +759,7 @@ public String getPreferredIconPath(NId appId) { NPath p0 = NPath.of(descAppIcon); descAppIcon=toAbsoluteIconPath(appId, descAppIcon); String bestName = descAppIconDigest + "." + p0.getLastExtension(); - NPath localIconPath = NLocations.of().getStoreLocation(appDef.getId(), NStoreType.CACHE) + NPath localIconPath = NWorkspace.get().getStoreLocation(appDef.getId(), NStoreType.CACHE) .resolve("icons") .resolve(bestName); if (localIconPath.isRegularFile()) { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/script/FromTemplateScriptBuilder.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/script/FromTemplateScriptBuilder.java index d60fa37c8..13d27e4e2 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/script/FromTemplateScriptBuilder.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/script/FromTemplateScriptBuilder.java @@ -1,9 +1,10 @@ package net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.ndi.script; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NShellFamily; -import net.thevpc.nuts.env.NStoreType; + + +import net.thevpc.nuts.NShellFamily; +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NIOException; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.shell.AbstractScriptBuilder; @@ -161,27 +162,27 @@ public String apply(String s) { case "NUTS_VERSION": return getWorkspace().getApiVersion().toString(); case "NUTS_WORKSPACE": - return NLocations.of().getWorkspaceLocation().toString(); + return NWorkspace.get().getWorkspaceLocation().toString(); case "NUTS_WORKSPACE_BIN": - return str(NLocations.of().getStoreLocation(NStoreType.BIN)); + return str(NWorkspace.get().getStoreLocation(NStoreType.BIN)); case "NUTS_WORKSPACE_CONF": - return str(NLocations.of().getStoreLocation(NStoreType.CONF)); + return str(NWorkspace.get().getStoreLocation(NStoreType.CONF)); case "NUTS_WORKSPACE_CACHE": - return str(NLocations.of().getStoreLocation(NStoreType.CACHE)); + return str(NWorkspace.get().getStoreLocation(NStoreType.CACHE)); case "NUTS_WORKSPACE_LIB": - return str(NLocations.of().getStoreLocation(NStoreType.LIB)); + return str(NWorkspace.get().getStoreLocation(NStoreType.LIB)); case "NUTS_WORKSPACE_LOG": - return str(NLocations.of().getStoreLocation(NStoreType.LOG)); + return str(NWorkspace.get().getStoreLocation(NStoreType.LOG)); case "NUTS_WORKSPACE_RUN": - return str(NLocations.of().getStoreLocation(NStoreType.RUN)); + return str(NWorkspace.get().getStoreLocation(NStoreType.RUN)); case "NUTS_WORKSPACE_TEMP": - return str(NLocations.of().getStoreLocation(NStoreType.TEMP)); + return str(NWorkspace.get().getStoreLocation(NStoreType.TEMP)); case "NUTS_WORKSPACE_VAR": - return str(NLocations.of().getStoreLocation(NStoreType.VAR)); + return str(NWorkspace.get().getStoreLocation(NStoreType.VAR)); case "NUTS_JAR_EXPR": { String NUTS_JAR_PATH = options.resolveNutsAppJarPath().toString(); - if (NUTS_JAR_PATH.startsWith(NLocations.of().getStoreLocation(NStoreType.LIB).toString())) { - String pp = NUTS_JAR_PATH.substring(NLocations.of().getStoreLocation(NStoreType.LIB).toString().length()); + if (NUTS_JAR_PATH.startsWith(NWorkspace.get().getStoreLocation(NStoreType.LIB).toString())) { + String pp = NUTS_JAR_PATH.substring(NWorkspace.get().getStoreLocation(NStoreType.LIB).toString().length()); return NShellHelper.of(getShellFamily()).varRef("NUTS_WORKSPACE_LIB") + pp; } else { return NUTS_JAR_PATH; @@ -190,7 +191,7 @@ public String apply(String s) { case "NUTS_WORKSPACE_BINDIR_EXPR": { //="${NUTS_WORKSPACE_BIN}/id/net/thevpc/nuts/nuts/0.8.2/bin" return NShellHelper.of(getShellFamily()).varRef("NUTS_WORKSPACE_BIN") + options.resolveBinFolder().toString().substring( - NLocations.of().getStoreLocation(NStoreType.BIN).toString().length() + NWorkspace.get().getStoreLocation(NStoreType.BIN).toString().length() ); } default: { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/script/SimpleScriptBuilder.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/script/SimpleScriptBuilder.java index 7d66cc394..f2e64cf90 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/script/SimpleScriptBuilder.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/script/SimpleScriptBuilder.java @@ -3,7 +3,7 @@ import net.thevpc.nuts.NWorkspace; import net.thevpc.nuts.io.NIOException; import net.thevpc.nuts.NId; -import net.thevpc.nuts.env.NShellFamily; +import net.thevpc.nuts.NShellFamily; import net.thevpc.nuts.runtime.standalone.shell.AbstractScriptBuilder; import net.thevpc.nuts.runtime.standalone.shell.NShellHelper; import net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.ndi.base.BaseSystemNdi; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/unix/AnyNixNdi.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/unix/AnyNixNdi.java index 7071a6f5e..adc44f05c 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/unix/AnyNixNdi.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/unix/AnyNixNdi.java @@ -1,9 +1,9 @@ package net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.ndi.unix; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NEnvs; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NShellFamily; + + +import net.thevpc.nuts.NShellFamily; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.io.NPrintStream; import net.thevpc.nuts.runtime.standalone.shell.NShellHelper; @@ -31,7 +31,7 @@ public AnyNixNdi(NWorkspace workspace) { } protected NShellFamily[] getShellGroups() { - Set all=new LinkedHashSet<>(NEnvs.of().getShellFamilies()); + Set all=new LinkedHashSet<>(NWorkspace.get().getShellFamilies()); all.retainAll(Arrays.asList(NShellFamily.SH, NShellFamily.FISH)); return all.toArray(new NShellFamily[0]); } @@ -68,10 +68,10 @@ public void onPostGlobal(NdiScriptOptions options, PathInfo[] updatedPaths) { factory.ofBuilder().appendJoined(", ", Arrays.stream(updatedPaths).map(x -> factory.ofStyled(x.getPath().getName(), NTextStyle.path())).collect(Collectors.toList())), - NLocations.of().getWorkspaceLocation() + NWorkspace.get().getWorkspaceLocation() )); } - final String sysRcName = NShellHelper.of(NEnvs.of().getShellFamily()).getSysRcName(); + final String sysRcName = NShellHelper.of(NWorkspace.get().getShellFamily()).getSysRcName(); NAsk.of() .forBoolean(NMsg.ofC( "```error ATTENTION``` You may need to re-run terminal or issue \"%s\" in your current terminal for new environment to take effect.%n" @@ -128,7 +128,7 @@ public String getExecFileName(String name) { @Override protected FreeDesktopEntryWriter createFreeDesktopEntryWriter() { return new UnixFreeDesktopEntryWriter(workspace, - NEnvs.of().getDesktopPath()==null?null: NPath.of(NEnvs.of().getDesktopPath()) + NWorkspace.get().getDesktopPath()==null?null: NPath.of(NWorkspace.get().getDesktopPath()) ); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/win/WindowsNdi.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/win/WindowsNdi.java index 2a6812a24..91ed8679e 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/win/WindowsNdi.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/ndi/win/WindowsNdi.java @@ -1,8 +1,8 @@ package net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.ndi.win; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NEnvs; -import net.thevpc.nuts.env.NShellFamily; + +import net.thevpc.nuts.NShellFamily; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.util.PathInfo; import net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.ndi.FreeDesktopEntryWriter; @@ -23,7 +23,7 @@ public WindowsNdi(NWorkspace workspace) { } protected NShellFamily[] getShellGroups() { - Set all=new LinkedHashSet<>(NEnvs.of().getShellFamilies()); + Set all=new LinkedHashSet<>(NWorkspace.get().getShellFamilies()); all.retainAll(Arrays.asList(NShellFamily.WIN_CMD, NShellFamily.WIN_POWER_SHELL)); return all.toArray(new NShellFamily[0]); } @@ -79,7 +79,7 @@ public String getExecFileName(String name) { @Override protected FreeDesktopEntryWriter createFreeDesktopEntryWriter() { return new WindowFreeDesktopEntryWriter( - NEnvs.of().getDesktopPath()==null?null: NPath.of(NEnvs.of().getDesktopPath()) + NWorkspace.get().getDesktopPath()==null?null: NPath.of(NWorkspace.get().getDesktopPath()) , workspace); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/repo/NSettingsRepositorySubCommand.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/repo/NSettingsRepositorySubCommand.java index bde3046ac..da8844919 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/repo/NSettingsRepositorySubCommand.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/repo/NSettingsRepositorySubCommand.java @@ -9,6 +9,7 @@ import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NArgName; import net.thevpc.nuts.cmdline.NCmdLine; + import net.thevpc.nuts.format.NContentType; import net.thevpc.nuts.format.NMutableTableModel; import net.thevpc.nuts.format.NTableFormat; @@ -20,7 +21,6 @@ import net.thevpc.nuts.spi.NRepositoryLocation; import net.thevpc.nuts.text.NText; import net.thevpc.nuts.text.NTextStyle; -import net.thevpc.nuts.text.NTexts; import net.thevpc.nuts.util.NLiteral; import net.thevpc.nuts.util.NMsg; import net.thevpc.nuts.util.NRef; @@ -111,27 +111,27 @@ public boolean exec(NCmdLine cmdLine, Boolean autoSave) { String repositoryName = cmdLine.nextNonOption(NArgName.of("NewRepositoryName")).flatMap(NLiteral::asString).get(); String location = cmdLine.nextNonOption(NArgName.of("folder")).flatMap(NLiteral::asString).get(); - NRepository editedRepo = NRepositories.of().findRepository(repoId).get(); + NRepository editedRepo = workspace.findRepository(repoId).get(); NRepository repo = editedRepo.config().addMirror(new NAddRepositoryOptions().setName(repositoryName).setLocation(repositoryName).setConfig(new NRepositoryConfig().setName(repositoryName).setLocation(NRepositoryLocation.of(location)))); - NConfigs.of().save(); + NWorkspace.get().saveConfig(); } else if (cmdLine.next("remove repo", "rr").isPresent()) { String location = cmdLine.nextNonOption(NArgName.of("RepositoryName")).flatMap(NLiteral::asString).get(); - NRepository editedRepo = NRepositories.of().findRepository(repoId).get(); + NRepository editedRepo = workspace.findRepository(repoId).get(); editedRepo.config().removeMirror(location); - NConfigs.of().save(); + NWorkspace.get().saveConfig(); } else if (cmdLine.next("enable", "br").isPresent()) { - NRepository editedRepo = NRepositories.of().findRepository(repoId).get(); + NRepository editedRepo = workspace.findRepository(repoId).get(); editedRepo.config().setEnabled(true); - NConfigs.of().save(); + NWorkspace.get().saveConfig(); } else if (cmdLine.next("disable", "dr").isPresent()) { - NRepository editedRepo = NRepositories.of().findRepository(repoId).get(); + NRepository editedRepo = workspace.findRepository(repoId).get(); editedRepo.config().setEnabled(true); - NConfigs.of().save(); + NWorkspace.get().saveConfig(); } else if (cmdLine.next("list repos","repo list", "list repo", "lr").isPresent()) { - NRepository editedRepo = NRepositories.of().findRepository(repoId).get(); + NRepository editedRepo = workspace.findRepository(repoId).get(); List linkRepositories = editedRepo.config().isSupportedMirroring() ? editedRepo.config().getMirrors() : Collections.emptyList(); out.println(NMsg.ofC("%s sub repositories.", linkRepositories.size())); NTableFormat t = NTableFormat.of(); @@ -152,7 +152,7 @@ public boolean exec(NCmdLine cmdLine, Boolean autoSave) { out.println(NMsg.ofC("edit repository %s remove repo ...", repoId)); out.println(NMsg.ofC("edit repository %s list repos ...", repoId)); } else { - NRepository editedRepo = NRepositories.of().findRepository(repoId).get(); + NRepository editedRepo = workspace.findRepository(repoId).get(); if (NSettingsUserSubCommand.exec(editedRepo, cmdLine, autoSave,workspace)) { //okkay } else { @@ -194,7 +194,7 @@ private void doListRepo(NCmdLine cmdLine, NPrintStream out) { } } if (cmdLine.isExecMode()) { - List r = parent.isNull() ? NRepositories.of().getRepositories() : NRepositories.of().findRepository(parent.get()) + List r = parent.isNull() ? workspace.getRepositories() : workspace.findRepository(parent.get()) .get().config().getMirrors(); out.println(r.stream().map(x -> repoInfo(x, session.getOutputFormat().orDefault() != NContentType.TABLE && session.getOutputFormat().orDefault() != NContentType.PLAIN, session)).toArray()); } @@ -235,12 +235,12 @@ private void doRemoveRepo(NCmdLine cmdLine, NPrintStream out) { } if (cmdLine.isExecMode()) { if (parent.isNull()) { - NRepositories.of().removeRepository(repositoryName.get()); + workspace.removeRepository(repositoryName.get()); } else { - NRepository p = NRepositories.of().findRepository(parent.get()).get(); + NRepository p = workspace.findRepository(parent.get()).get(); p.config().removeMirror(repositoryName.get()); } - NConfigs.of().save(); + NWorkspace.get().saveConfig(); } } @@ -310,13 +310,13 @@ class Data { NRepository repo = null; NAddRepositoryOptions o = new NAddRepositoryOptions().setName(d.repositoryName).setLocation(d.repositoryName).setConfig(d.location == null ? null : new NRepositoryConfig().setName(d.repositoryName).setLocation(NRepositoryLocation.of(d.location)).setEnv(d.env)); if (d.parent == null) { - repo = NRepositories.of().addRepository(o); + repo = workspace.addRepository(o); } else { - NRepository p = NRepositories.of().findRepository(d.parent).get(); + NRepository p = workspace.findRepository(d.parent).get(); repo = p.config().addMirror(o); } out.println(NMsg.ofC("repository %s added successfully", repo.getName())); - NConfigs.of().save(); + NWorkspace.get().saveConfig(); } cmdLine.setCommandName("config add repo").throwUnexpectedArgument(); @@ -350,9 +350,9 @@ private void enableRepo(NCmdLine cmdLine, Boolean autoSave, NSession session, bo cmdLine.peek().get(); } if (cmdLine.isExecMode()) { - NRepository editedRepo = NRepositories.of().findRepository(repositoryName.get()).get(); + NRepository editedRepo = workspace.findRepository(repositoryName.get()).get(); editedRepo.config().setEnabled(enableRepo); - NConfigs.of().save(); + NWorkspace.get().saveConfig(); } } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/updatestats/AbstractNUpdateStatsCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/updatestats/AbstractNUpdateStatsCmd.java index a9a762a43..c195971f7 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/updatestats/AbstractNUpdateStatsCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/updatestats/AbstractNUpdateStatsCmd.java @@ -129,7 +129,6 @@ public Path[] getPaths() { @Override public boolean configureFirst(NCmdLine cmdLine) { - NSession session=getWorkspace().currentSession(); NArg a = cmdLine.peek().get(); if (a == null) { return false; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/updatestats/DefaultNUpdateStatsCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/updatestats/DefaultNUpdateStatsCmd.java index d5424ef01..4445cf9bd 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/updatestats/DefaultNUpdateStatsCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/updatestats/DefaultNUpdateStatsCmd.java @@ -11,7 +11,8 @@ import java.nio.file.Paths; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NLocations; + + import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.repository.impl.NRepositoryFolderHelper; import net.thevpc.nuts.runtime.standalone.repository.impl.maven.util.MavenRepositoryFolderHelper; @@ -35,7 +36,7 @@ public NUpdateStatsCmd run() { NSession session=getWorkspace().currentSession(); for (String repository : getRepositories()) { processed = true; - NRepository repo = NRepositories.of().findRepository(repository).get(); + NRepository repo = workspace.findRepository(repository).get(); NRepositorySPI repoSPI = NWorkspaceUtils.of(workspace).repoSPI(repo); repoSPI.updateStatistics() // .setFetchMode(NutsFetchMode.LOCAL) @@ -59,9 +60,9 @@ public NUpdateStatsCmd run() { || x.getName().equals("project-summary.html") ); if (mavenRepoRootFiles != null && mavenRepoRootFiles.length > 3) { - new MavenRepositoryFolderHelper(null, NPath.of(repositoryPath)).reindexFolder(session); + new MavenRepositoryFolderHelper(null, NPath.of(repositoryPath)).reindexFolder(); if (session.isPlainTrace()) { - session.getTerminal().out().resetLine().println(NMsg.ofC("[%s] updated maven index %s", NLocations.of().getWorkspaceLocation(), repositoryPath)); + session.getTerminal().out().resetLine().println(NMsg.ofC("[%s] updated maven index %s", NWorkspace.get().getWorkspaceLocation(), repositoryPath)); } } else { File[] nutsRepoRootFiles = repositoryPath.toFile().listFiles(x @@ -73,17 +74,17 @@ public NUpdateStatsCmd run() { throw new NIllegalArgumentException(NMsg.ofPlain("unsupported repository folder")); } if (session.isPlainTrace()) { - session.out().resetLine().println(NMsg.ofC("[%s] updated stats %s", NLocations.of().getWorkspaceLocation(), repositoryPath)); + session.out().resetLine().println(NMsg.ofC("[%s] updated stats %s", NWorkspace.get().getWorkspaceLocation(), repositoryPath)); } } } if (!processed) { if (session.isPlainTrace()) { - session.out().resetLine().println(NMsg.ofC("%s updating workspace stats", NLocations.of().getWorkspaceLocation())); + session.out().resetLine().println(NMsg.ofC("%s updating workspace stats", NWorkspace.get().getWorkspaceLocation())); } - for (NRepository repo : NRepositories.of().getRepositories()) { + for (NRepository repo : workspace.getRepositories()) { if (session.isPlainTrace()) { - session.out().resetLine().println(NMsg.ofC("%s updating stats %s", NLocations.of().getWorkspaceLocation(), repo)); + session.out().resetLine().println(NMsg.ofC("%s updating stats %s", NWorkspace.get().getWorkspaceLocation(), repo)); } NWorkspaceUtils.of(workspace).repoSPI(repo).updateStatistics() // .setFetchMode(NutsFetchMode.LOCAL) diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/AbstractNAddUserCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/AbstractNAddUserCmd.java index 54369af95..d207aba63 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/AbstractNAddUserCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/AbstractNAddUserCmd.java @@ -214,7 +214,6 @@ public List getGroups() { @Override public boolean configureFirst(NCmdLine cmdLine) { - NSession session=getWorkspace().currentSession(); NArg a = cmdLine.peek().get(); if (a == null) { return false; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/AbstractNRemoveUserCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/AbstractNRemoveUserCmd.java index c1d7f4bdb..394c94ba5 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/AbstractNRemoveUserCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/AbstractNRemoveUserCmd.java @@ -35,7 +35,6 @@ public NRemoveUserCmd setUsername(String username) { @Override public boolean configureFirst(NCmdLine cmdLine) { - NSession session=getWorkspace().currentSession(); NArg a = cmdLine.peek().get(); if (a == null) { return false; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/AbstractNUpdateUserCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/AbstractNUpdateUserCmd.java index 759adf735..d525d9c30 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/AbstractNUpdateUserCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/AbstractNUpdateUserCmd.java @@ -410,7 +410,6 @@ public NUpdateUserCmd setResetGroups(boolean resetGroups) { @Override public boolean configureFirst(NCmdLine cmdLine) { - NSession session=getWorkspace().currentSession(); NArg a = cmdLine.peek().get(); if (a == null) { return false; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/DefaultNAddUserCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/DefaultNAddUserCmd.java index 6fd9c9977..41baf85c4 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/DefaultNAddUserCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/DefaultNAddUserCmd.java @@ -26,9 +26,9 @@ package net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.user; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NUserConfig; +import net.thevpc.nuts.NUserConfig; +import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; import net.thevpc.nuts.runtime.standalone.workspace.config.NRepositoryConfigManagerExt; -import net.thevpc.nuts.runtime.standalone.workspace.config.NConfigsExt; import net.thevpc.nuts.runtime.standalone.util.CoreStringUtils; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.util.NMsg; @@ -46,7 +46,6 @@ public DefaultNAddUserCmd(NWorkspace workspace) { @Override public NAddUserCmd run() { - NSession session=getWorkspace().currentSession(); if (NBlankable.isBlank(getUsername())) { throw new NIllegalArgumentException(NMsg.ofPlain("invalid user")); } @@ -68,7 +67,7 @@ public NAddUserCmd run() { getGroups(), getPermissions()); security.setRemoteIdentity(getRemoteIdentity()); security.setRemoteCredentials(CoreStringUtils.chrToStr(sec.createCredentials(getRemoteCredentials(), true, null))); - NConfigsExt.of(NConfigs.of()).getModel() + NWorkspaceExt.of(workspace).getConfigModel() .setUser(security); } return this; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/DefaultNRemoveUserCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/DefaultNRemoveUserCmd.java index 924d4ec49..7671333c7 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/DefaultNRemoveUserCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/DefaultNRemoveUserCmd.java @@ -5,12 +5,10 @@ */ package net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.user; -import net.thevpc.nuts.NConfigs; import net.thevpc.nuts.NRemoveUserCmd; -import net.thevpc.nuts.NSession; import net.thevpc.nuts.NWorkspace; +import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; import net.thevpc.nuts.runtime.standalone.workspace.config.NRepositoryConfigManagerExt; -import net.thevpc.nuts.runtime.standalone.workspace.config.NConfigsExt; /** * @@ -27,7 +25,7 @@ public NRemoveUserCmd run() { if (repository != null) { NRepositoryConfigManagerExt.of(repository.config()).getModel().removeUser(login); } else { - NConfigsExt.of(NConfigs.of()).getModel().removeUser(login); + NWorkspaceExt.of(workspace).getConfigModel().removeUser(login); } return this; } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/DefaultNUpdateUserCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/DefaultNUpdateUserCmd.java index 1f7448e82..a8b9b8c66 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/DefaultNUpdateUserCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/DefaultNUpdateUserCmd.java @@ -27,9 +27,9 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NUserConfig; +import net.thevpc.nuts.NUserConfig; +import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; import net.thevpc.nuts.runtime.standalone.workspace.config.NRepositoryConfigManagerExt; -import net.thevpc.nuts.runtime.standalone.workspace.config.NConfigsExt; import net.thevpc.nuts.runtime.standalone.util.CoreStringUtils; import java.util.*; @@ -70,7 +70,7 @@ public NUpdateUserCmd run() { rconf.setUser(u); } else { - DefaultNWorkspaceConfigModel wconf = NConfigsExt.of(NConfigs.of()).getModel(); + DefaultNWorkspaceConfigModel wconf = NWorkspaceExt.of(workspace).getConfigModel(); NUserConfig u = wconf.getUser(login); if (u == null) { throw new NIllegalArgumentException(NMsg.ofC("no such user %s", login)); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/NSettingsUserSubCommand.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/NSettingsUserSubCommand.java index aa2aeb35f..f5b55be11 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/NSettingsUserSubCommand.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/settings/user/NSettingsUserSubCommand.java @@ -10,7 +10,8 @@ import net.thevpc.nuts.cmdline.NArgName; import net.thevpc.nuts.cmdline.NCmdLine; import net.thevpc.nuts.elem.NElementNotFoundException; -import net.thevpc.nuts.env.NUser; + +import net.thevpc.nuts.NUser; import net.thevpc.nuts.io.NPrintStream; import net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.AbstractNSettingsSubCommand; import net.thevpc.nuts.util.NBlankable; @@ -40,7 +41,7 @@ public static boolean exec(NRepository editedRepo, NCmdLine cmdLine, Boolean aut repository = editedRepo; } else { if (cmdLine.next("--repo", "-r").isPresent()) { - repository = NRepositories.of().findRepository(cmdLine.nextNonOption(NArgName.of("RepositoryId")) + repository = workspace.findRepository(cmdLine.nextNonOption(NArgName.of("RepositoryId")) .flatMap(NLiteral::asString).get()) .get(); } @@ -65,7 +66,7 @@ public static boolean exec(NRepository editedRepo, NCmdLine cmdLine, Boolean aut } } if (cmdLine.isExecMode()) { - NConfigs.of().save(); + NWorkspace.get().saveConfig(); } return true; } else { @@ -77,7 +78,7 @@ public static boolean exec(NRepository editedRepo, NCmdLine cmdLine, Boolean aut repository = editedRepo; } else { if (cmdLine.next("--repo", "-r").isPresent()) { - repository = NRepositories.of() + repository = workspace .findRepository( cmdLine.nextNonOption(NArgName.of("repository")) .flatMap(NLiteral::asString).get() @@ -109,7 +110,7 @@ public static boolean exec(NRepository editedRepo, NCmdLine cmdLine, Boolean aut repository = editedRepo; } else { if (cmdLine.next("--repo", "-r").isPresent()) { - repository = NRepositories.of() + repository = workspace .findRepository(cmdLine.nextNonOption(NArgName.of("RepositoryId")).flatMap(NLiteral::asString).get() ).get(); } @@ -149,7 +150,7 @@ public static boolean exec(NRepository editedRepo, NCmdLine cmdLine, Boolean aut } else { repository.security().updateUser(user).setCredentials(password).setOldCredentials(oldPassword).run(); } - NConfigs.of().save(); + NWorkspace.get().saveConfig(); } return true; @@ -159,7 +160,7 @@ public static boolean exec(NRepository editedRepo, NCmdLine cmdLine, Boolean aut repository = editedRepo; } else { if (cmdLine.next("--repo", "-r").isPresent()) { - repository = NRepositories.of().findRepository( + repository = workspace.findRepository( cmdLine.nextNonOption(NArgName.of("RepositoryId")).flatMap(NLiteral::asString).get() ).get(); } @@ -279,7 +280,7 @@ public static boolean exec(NRepository editedRepo, NCmdLine cmdLine, Boolean aut } } if (cmdLine.isExecMode()) { - NConfigs.of().save(); + NWorkspace.get().saveConfig(); } return true; @@ -289,7 +290,7 @@ public static boolean exec(NRepository editedRepo, NCmdLine cmdLine, Boolean aut repository = editedRepo; } else { if (cmdLine.next("--repo", "-r").isPresent()) { - repository = NRepositories.of().findRepository( + repository = workspace.findRepository( cmdLine.nextNonOption(NArgName.of("RepositoryId")).flatMap(NLiteral::asString).get() ).get(); } @@ -309,7 +310,7 @@ public static boolean exec(NRepository editedRepo, NCmdLine cmdLine, Boolean aut Arrays.fill(credentials, '\0'); } } - NConfigs.of().save(); + NWorkspace.get().saveConfig(); return true; } else if (cmdLine.next("secure").isPresent()) { char[] credentials = null; @@ -321,7 +322,7 @@ public static boolean exec(NRepository editedRepo, NCmdLine cmdLine, Boolean aut repository = editedRepo; } else { if (cmdLine.next("--repo", "-r").isPresent()) { - repository = NRepositories.of().findRepository( + repository = workspace.findRepository( cmdLine.nextNonOption(NArgName.of("RepositoryId")).flatMap(NLiteral::asString).get() ).get(); } @@ -337,7 +338,7 @@ public static boolean exec(NRepository editedRepo, NCmdLine cmdLine, Boolean aut if (credentials != null) { Arrays.fill(credentials, '\0'); } - NConfigs.of().save(); + NWorkspace.get().saveConfig(); return true; } } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/undeploy/DefaultNUndeployCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/undeploy/DefaultNUndeployCmd.java index 97ff0712a..d92a33c63 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/undeploy/DefaultNUndeployCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/undeploy/DefaultNUndeployCmd.java @@ -26,12 +26,12 @@ public NUndeployCmd run() { .addRepositoryFilter(NRepositoryFilters.of().byName(getRepository())) //skip 'installed' repository .setRepositoryFilter( - NRepositories.of().filter().installedRepo().neg() + NRepositoryFilters.of().installedRepo().neg() ) .setDistinct(true) .failFast() .getResultDefinitions().findFirst().get(); - NRepository repository1 = NRepositories.of() + NRepository repository1 = workspace .findRepository(p.getRepositoryUuid()).get(); NRepositorySPI repoSPI = NWorkspaceUtils.of(workspace).repoSPI(repository1); repoSPI.undeploy() diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/update/DefaultNUpdateCmd.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/update/DefaultNUpdateCmd.java index bd979d38f..02ae35847 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/update/DefaultNUpdateCmd.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/update/DefaultNUpdateCmd.java @@ -13,6 +13,7 @@ import net.thevpc.nuts.elem.NEDesc; import net.thevpc.nuts.elem.NElement; import net.thevpc.nuts.elem.NElements; + import net.thevpc.nuts.ext.NExtensions; import net.thevpc.nuts.format.NPositionType; import net.thevpc.nuts.io.NIO; @@ -89,7 +90,6 @@ public int getResultCount() { @Override public NWorkspaceUpdateResult getResult() { - NSession session = getWorkspace().currentSession(); if (result == null) { checkUpdates(); } @@ -101,7 +101,6 @@ public NWorkspaceUpdateResult getResult() { @Override public boolean configureFirst(NCmdLine cmdLine) { - NSession session = getWorkspace().currentSession(); NArg a = cmdLine.peek().get(); if (a == null) { return false; @@ -131,7 +130,6 @@ public NUpdateCmd checkUpdates() { checkFixes(); traceFixes(); } - NSession session = getWorkspace().currentSession(); Instant now = expireTime == null ? Instant.now() : expireTime; NWorkspaceExt dws = NWorkspaceExt.of(); // NutsWorkspaceCurrentConfig actualBootConfig = ws.config().current(); @@ -140,7 +138,7 @@ public NUpdateCmd checkUpdates() { Map extUpdates = new LinkedHashMap<>(); Map regularUpdates = new HashMap<>(); NUpdateResult apiUpdate = null; - NVersion bootVersion0 = session.getWorkspace().getApiVersion(); + NVersion bootVersion0 = workspace.getApiVersion(); NVersion bootVersion = bootVersion0; if (!(this.getApiVersion() == null || this.getApiVersion().isBlank())) { bootVersion = this.getApiVersion(); @@ -158,7 +156,7 @@ public NUpdateCmd checkUpdates() { NUpdateResult runtimeUpdate = null; if (this.isRuntime()) { if (dws.requiresRuntimeExtension()) { - runtimeUpdate = checkCoreUpdate(NId.of(session.getWorkspace().getRuntimeId().getShortName()).get(), + runtimeUpdate = checkCoreUpdate(NId.of(workspace.getRuntimeId().getShortName()).get(), apiUpdate != null && apiUpdate.getAvailable() != null && apiUpdate.getAvailable().getId() != null ? apiUpdate.getAvailable().getId().getVersion() : bootVersion, Type.RUNTIME, now); if (runtimeUpdate.isUpdatable()) { @@ -217,7 +215,6 @@ public NUpdateCmd checkUpdates() { private Set getExtensionsToUpdate() { Set ext = new HashSet<>(); - NSession session = getWorkspace().currentSession(); for (NId extension : NExtensions.of().getConfigExtensions()) { ext.add(extension.getShortId()); } @@ -250,8 +247,6 @@ private Set getCompanionsToUpdate() { } private Set getRegularIds() { - NSession session = getWorkspace().currentSession(); - NWorkspace ws = session.getWorkspace(); HashSet extensions = new HashSet<>(); for (NId object : NExtensions.of().getConfigExtensions()) { extensions.add(object.getShortName()); @@ -276,7 +271,7 @@ private Set getRegularIds() { if (id.getShortName().equals(NConstants.Ids.NUTS_API)) { continue; } - if (id.getShortName().equals(session.getWorkspace().getRuntimeId().getShortName())) { + if (id.getShortName().equals(workspace.getRuntimeId().getShortName())) { continue; } if (extensions.contains(id.getShortName())) { @@ -289,8 +284,6 @@ private Set getRegularIds() { public NUpdateCmd checkFixes() { resultFixes = null; - NSession session = getWorkspace().currentSession(); - NWorkspace ws = session.getWorkspace(); NWorkspaceExt dws = NWorkspaceExt.of(); NInstalledRepository ir = dws.getInstalledRepository(); resultFixes = NIteratorUtils.toList(NIteratorUtils.convertNonNull(ir.searchInstallInformation(), new Function() { @@ -458,7 +451,6 @@ private NFetchCmd latestOnlineDependencies(NFetchCmd se) { } else { se.addScopes(scopes.toArray(new NDependencyScope[0])); } - NSession session = getWorkspace().currentSession(); se.setOptional(isOptional() ? null : false) //TODO //.setSession(se.session.copy().setFetchStrategy(NFetchStrategy.ONLINE)) @@ -467,7 +459,6 @@ private NFetchCmd latestOnlineDependencies(NFetchCmd se) { } protected NUpdateResult checkRegularUpdate(NId id, Type type, NVersion targetApiVersion, Instant now, boolean updateEvenIfExisting) { - NSession session = getWorkspace().currentSession(); NVersion version = id.getVersion(); if (!updateEvenIfExisting && version.isSingleValue()) { updateEvenIfExisting = NAsk.of() @@ -547,7 +538,6 @@ protected NUpdateResult checkRegularUpdate(NId id, Type type, NVersion targetApi } private NFetchCmd fetch0() { - NSession session = getWorkspace().currentSession(); return NFetchCmd.of().setContent(true).setEffective(true); } @@ -644,7 +634,7 @@ private void applyResult(NWorkspaceUpdateResult result) { applyRegularUpdate((DefaultNUpdateResult) component); } - if (NConfigs.of().save(requireSave)) { + if (NWorkspace.get().saveConfig(requireSave)) { if (_LOG().isLoggable(Level.INFO)) { _LOGOP().level(Level.INFO).verb(NLogVerb.WARNING) .log(NMsg.ofPlain("workspace is updated. Nuts should be restarted for changes to take effect.")); @@ -714,8 +704,8 @@ public NUpdateResult checkCoreUpdate(NId id, NVersion bootApiVersion, Type type, // NutsSession sessionOffline = session.copy().setFetchMode(NutsFetchMode.OFFLINE); switch (type) { case API: { - oldId = NConfigs.of().stored().getApiId(); - NId confId = NConfigs.of().stored().getApiId(); + oldId = NWorkspace.get().getStoredConfig().getApiId(); + NId confId = NWorkspace.get().getStoredConfig().getApiId(); if (confId != null) { oldId = confId; } @@ -751,7 +741,7 @@ public NUpdateResult checkCoreUpdate(NId id, NVersion bootApiVersion, Type type, } case RUNTIME: { oldId = ws.getRuntimeId(); - NId confId = NConfigs.of().stored().getRuntimeId(); + NId confId = NWorkspace.get().getStoredConfig().getRuntimeId(); if (confId != null) { oldId = confId; } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/welcome/DefaultNWelcomeInternalExecutable.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/welcome/DefaultNWelcomeInternalExecutable.java index 602f69f45..07a1f8bf2 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/welcome/DefaultNWelcomeInternalExecutable.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/welcome/DefaultNWelcomeInternalExecutable.java @@ -8,7 +8,8 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NLocations; + + import net.thevpc.nuts.format.NContentType; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.app.util.NAppUtils; @@ -69,7 +70,7 @@ public int execute() { welcome.put("api-version", session.getWorkspace().getApiVersion()); welcome.put("runtime-id", session.getWorkspace().getRuntimeId().builder().setVersion("").build()); welcome.put("runtime-version", session.getWorkspace().getRuntimeId().getVersion()); - welcome.put("workspace", NLocations.of().getWorkspaceLocation()); + welcome.put("workspace", NWorkspace.get().getWorkspaceLocation()); welcome.put("hash-name", NPath.of(session.getWorkspace().getHashName())); if (session.isPlainOut()) { session = session.copy().setOutputFormat(NContentType.PROPS); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/which/DefaultNWhichInternalExecutable.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/which/DefaultNWhichInternalExecutable.java index 219af3da5..c1e05d58e 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/which/DefaultNWhichInternalExecutable.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/cmd/which/DefaultNWhichInternalExecutable.java @@ -9,6 +9,7 @@ import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; import net.thevpc.nuts.elem.NElements; + import net.thevpc.nuts.io.NPrintStream; import net.thevpc.nuts.runtime.standalone.app.util.NAppUtils; import net.thevpc.nuts.runtime.standalone.util.ExtraApiUtils; @@ -89,7 +90,7 @@ public int execute() { factory.ofStyled(arg, NTextStyle.primary4()), factory.ofStyled("nuts alias", NTextStyle.primary6()), p.getId(), - NCmdLine.of(NCommands.of().findCommand(p.getName()).getCommand()) + NCmdLine.of(NWorkspace.get().findCommand(p.getName()).getCommand()) )); } else { session.out().println( diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/AbstractNIndexStore.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/AbstractNIndexStore.java index 424e50d3c..9039f96a8 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/AbstractNIndexStore.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/AbstractNIndexStore.java @@ -26,7 +26,7 @@ */ package net.thevpc.nuts.runtime.standalone.workspace.config; -import net.thevpc.nuts.env.NIndexStore; +import net.thevpc.nuts.NIndexStore; import net.thevpc.nuts.NRepository; import net.thevpc.nuts.NWorkspace; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultCommands.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultCommands.java deleted file mode 100644 index 55ed9f1a9..000000000 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultCommands.java +++ /dev/null @@ -1,100 +0,0 @@ -package net.thevpc.nuts.runtime.standalone.workspace.config; - -import net.thevpc.nuts.*; -import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; -import net.thevpc.nuts.spi.NSupportLevelContext; - -import java.util.Arrays; -import java.util.List; - -public class DefaultCommands implements NCommands { - - public DefaultCustomCommandsModel model; - public NWorkspace ws; - - public DefaultCommands(NWorkspace ws) { - this.ws = ws; - this.model = NWorkspaceExt.of().getModel().aliasesModel; - } - - @Override - public int getSupportLevel(NSupportLevelContext context) { - return NConstants.Support.DEFAULT_SUPPORT; - } - - @Override - public List getCommandFactories() { - return Arrays.asList(model.getFactories()); - } - - @Override - public void addCommandFactory(NCommandFactoryConfig commandFactoryConfig) { - model.addFactory(commandFactoryConfig); - } - - @Override - public void removeCommandFactory(String commandFactoryId) { - model.removeFactory(commandFactoryId); - } - - @Override - public boolean removeCommandFactoryIfExists(String commandFactoryId) { - return model.removeFactoryIfExists(commandFactoryId); - } - - @Override - public boolean commandExists(String command) { - return findCommand(command) != null; - } - - @Override - public boolean commandFactoryExists(String factoryId) { - return model.commandFactoryExists(factoryId); - } - - @Override - public boolean addCommand(NCommandConfig command) { - return model.add(command); - } - - @Override - public boolean updateCommand(NCommandConfig command) { - return model.update(command); - } - - @Override - public void removeCommand(String command) { - model.remove(command); - } - - @Override - public boolean removeCommandIfExists(String name) { - if (model.find(name) != null) { - model.remove(name); - return true; - } - return false; - } - - @Override - public NCustomCmd findCommand(String name, NId forId, NId forOwner) { - return model.find(name, forId, forOwner); - } - - @Override - public NCustomCmd findCommand(String name) { - return model.find(name); - } - - @Override - public List findAllCommands() { - return model.findAll(); - } - - @Override - public List findCommandsByOwner(NId id) { - return model.findByOwner(id); - } - -} diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultCustomCommandsModel.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultCustomCommandsModel.java index cc0bc63bb..2e4b79eef 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultCustomCommandsModel.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultCustomCommandsModel.java @@ -3,6 +3,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.io.NPrintStream; import net.thevpc.nuts.runtime.standalone.workspace.DefaultNWorkspace; +import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; import net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.CommandNWorkspaceCommandFactory; import net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.ConfigNWorkspaceCommandFactory; import net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.alias.DefaultNCustomCommand; @@ -82,8 +83,8 @@ public int compare(NWorkspaceCmdFactory o1, NWorkspaceCmdFactory o2) { oldCommandFactory.setParameters(commandFactoryConfig.getParameters() == null ? null : new LinkedHashMap<>(commandFactoryConfig.getParameters())); oldCommandFactory.setPriority(commandFactoryConfig.getPriority()); } - NConfigsExt.of(NConfigs.of()) - .getModel().fireConfigurationChanged("command", ConfigEventType.MAIN); + NWorkspaceExt.of(workspace) + .getConfigModel().fireConfigurationChanged("command", ConfigEventType.MAIN); } public boolean removeFactoryIfExists(String factoryId) { @@ -133,8 +134,8 @@ public boolean removeFactory(String factoryId, boolean error) { if (factoryId.equals(factory.getFactoryId())) { removeMe = factory; iterator.remove(); - NConfigsExt.of(NConfigs.of()) - .getModel() + NWorkspaceExt.of(workspace) + .getConfigModel() .fireConfigurationChanged("command", ConfigEventType.MAIN); break; } @@ -146,7 +147,7 @@ public boolean removeFactory(String factoryId, boolean error) { if (factoryId.equals(commandFactory.getFactoryId())) { removeMeConfig = commandFactory; iterator.remove(); - NConfigsExt.of(NConfigs.of()).getModel() + NWorkspaceExt.of(workspace).getConfigModel() .fireConfigurationChanged("command", ConfigEventType.MAIN); break; } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultImportModel.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultImportModel.java index f5e8053a9..f967587ff 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultImportModel.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultImportModel.java @@ -6,7 +6,9 @@ import java.util.Collections; import java.util.LinkedHashSet; import java.util.Set; + import net.thevpc.nuts.runtime.standalone.workspace.DefaultNWorkspace; +import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; import net.thevpc.nuts.runtime.standalone.xtra.expr.StringTokenizerUtils; public class DefaultImportModel { @@ -74,8 +76,8 @@ public void set(String[] imports) { } } getStoreModelMain().setImports(new ArrayList<>(simports)); - NConfigsExt.of(NConfigs.of()) - .getModel() + NWorkspaceExt.of(workspace) + .getConfigModel() .fireConfigurationChanged("import", ConfigEventType.MAIN); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNConfigs.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNConfigs.java deleted file mode 100755 index 2ec010249..000000000 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNConfigs.java +++ /dev/null @@ -1,189 +0,0 @@ -/** - * ==================================================================== - * Nuts : Network Updatable Things Service - * (universal package manager) - *
- * is a new Open Source Package Manager to help install packages and libraries - * for runtime execution. Nuts is the ultimate companion for maven (and other - * build managers) as it helps installing all package dependencies at runtime. - * Nuts is not tied to java and is a good choice to share shell scripts and - * other 'things' . Its based on an extensible architecture to help supporting a - * large range of sub managers / repositories. - *
- *

- * Copyright [2020] [thevpc] - * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 (the "License"); - * you may not use this file except in compliance with the License. You may obtain - * a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html - * 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 net.thevpc.nuts.runtime.standalone.workspace.config; - -import net.thevpc.nuts.*; -import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.io.NPath; -import net.thevpc.nuts.runtime.standalone.dependency.solver.NDependencySolverUtils; -import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; -import net.thevpc.nuts.spi.*; -import net.thevpc.nuts.util.NLiteral; -import net.thevpc.nuts.util.NOptional; - -import java.util.*; -import java.util.stream.Collectors; - -/** - * @author thevpc - */ -@NComponentScope(NScopeType.SESSION) -public class DefaultNConfigs implements NConfigs, NConfigsExt { - - private final DefaultNWorkspaceConfigModel cmodel; - - public DefaultNConfigs(NWorkspace ws) { - NWorkspaceExt e = NWorkspaceExt.of(); - this.cmodel = e.getModel().configModel; - } - - @Override - public int getSupportLevel(NSupportLevelContext context) { - return NConstants.Support.DEFAULT_SUPPORT; - } - - public DefaultNWorkspaceConfigModel getModel() { - return cmodel; - } - - @Override - public NWorkspaceStoredConfig stored() { - return cmodel.stored(); - } - - @Override - public boolean isReadOnly() { - return cmodel.isReadOnly(); - } - - @Override - public boolean save(boolean force) { - return cmodel.save(force); - } - - @Override - public boolean save() { - return cmodel.save(); - } - - @Override - public NWorkspaceBootConfig loadBootConfig(String _ws, boolean global, boolean followLinks) { - return cmodel.loadBootConfig(_ws, global, followLinks); - } - - @Override - public boolean isSupportedRepositoryType(String repositoryType) { - return cmodel.isSupportedRepositoryType(repositoryType); - } - - @Override - public List getDefaultRepositories() { - return cmodel.getDefaultRepositories(); - } - - @Override - public Set getAvailableArchetypes() { - return cmodel.getAvailableArchetypes(); - } - - @Override - public NPath resolveRepositoryPath(String repositoryLocation) { - return cmodel.resolveRepositoryPath(NPath.of(repositoryLocation)); - } - - @Override - public NIndexStoreFactory getIndexStoreClientFactory() { - return cmodel.getIndexStoreClientFactory(); - } - - @Override - public String getJavaCommand() { - return cmodel.getJavaCommand(); - } - - @Override - public String getJavaOptions() { - return cmodel.getJavaOptions(); - } - - @Override - public boolean isSystemWorkspace() { - return cmodel.isSystem(); - } - - - @Override - public String toString() { - String s1 = "NULL"; - String s2 = "NULL"; - s1 = String.valueOf(cmodel.getWorkspace().getApiId()); - s2 = String.valueOf(cmodel.getWorkspace().getRuntimeId()); - return "NutsWorkspaceConfig{" - + "workspaceBootId=" + s1 - + ", workspaceRuntimeId=" + s2 - + ", workspace=" + ((cmodel.getCurrentConfig() == null) ? "NULL" : ("'" + - NLocations.of() - .getWorkspaceLocation() + '\'')) - + '}'; - } - - public List getDependencySolverNames() { - // the first element is always the default one, - // the rest is lexicographically sorter - return Arrays.stream(cmodel.getDependencySolvers()) - .map(NDependencySolverFactory::getName) - .sorted(new Comparator() { - @Override - public int compare(String o1, String o2) { - if (!o1.equals(o2)) { - String n = NDependencySolverUtils.resolveSolverName(NSession.of().get().getDependencySolver()); - if (o1.equals(n)) { - return -1; - } - if (o2.equals(n)) { - return 1; - } - } - return o1.compareTo(o2); - } - }) - .collect(Collectors.toList()); - } - - public NDependencySolver createDependencySolver(String name) { - return cmodel.createDependencySolver(name); - } - - - - @Override - public Map getConfigMap() { - return cmodel.getConfigMap(); - } - - @Override - public NOptional getConfigProperty(String property) { - return cmodel.getConfigProperty(property); - } - - @Override - public NConfigs setConfigProperty(String property, String value) { - cmodel.setConfigProperty(property, value); - cmodel.save(); - return this; - } - -} diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNEnvs.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNEnvs.java deleted file mode 100644 index 369773166..000000000 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNEnvs.java +++ /dev/null @@ -1,476 +0,0 @@ -package net.thevpc.nuts.runtime.standalone.workspace.config; - -import net.thevpc.nuts.*; -import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.*; -import net.thevpc.nuts.runtime.standalone.executor.system.NSysExecUtils; -import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; -import net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.ndi.NdiScriptOptions; -import net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.ndi.NSettingsNdiSubCommand; -import net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.ndi.SystemNdi; -import net.thevpc.nuts.spi.NComponentScope; -import net.thevpc.nuts.spi.NScopeType; -import net.thevpc.nuts.spi.NSupportLevelContext; -import net.thevpc.nuts.util.*; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Function; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -@NComponentScope(NScopeType.SESSION) -public class DefaultNEnvs implements NEnvs { - - public static final Pattern UNIX_USER_DIRS_PATTERN = Pattern.compile("^\\s*(?[A-Z_]+)\\s*=\\s*(?.*)$"); - private final DefaultNWorkspaceEnvManagerModel model; - - protected DefaultNPlatformModel sdkModel; - - public DefaultNEnvs(NWorkspace ws) { - NWorkspaceExt e = NWorkspaceExt.of(); - this.model = e.getModel().envModel; - this.sdkModel = e.getModel().sdkModel; - } - - @Override - public int getSupportLevel(NSupportLevelContext context) { - return NConstants.Support.DEFAULT_SUPPORT; - } - - @Override - public Map getProperties() { - return model.getProperties(); - } - - @Override - public NOptional getProperty(String property) { - return model.getProperty(property); - } - - @Override - public NEnvs setProperty(String property, Object value) { - model.setProperty(property, value); - return this; - } - - @Override - public NOsFamily getOsFamily() { -// checkSession(); - return model.getOsFamily(); - } - - @Override - public String getHostName() { - return model.getHostName(); - } - - @Override - public String getPid() { - return model.getPid(); - } - - @Override - public Set getShellFamilies() { - return model.getShellFamilies(); - } - - @Override - public NShellFamily getShellFamily() { - return model.getShellFamily(); - } - - @Override - public NId getDesktopEnvironment() { - return getDesktopEnvironments().stream().findFirst().get(); - } - - @Override - public Set getDesktopEnvironments() { - return model.getDesktopEnvironments(); - } - - @Override - public NDesktopEnvironmentFamily getDesktopEnvironmentFamily() { - return model.getDesktopEnvironmentFamily(); - } - - @Override - public Set getDesktopEnvironmentFamilies() { - return model.getDesktopEnvironmentFamilies(); - } - - @Override - public NId getPlatform() { -// checkSession(); - return model.getPlatform(); - } - - @Override - public NId getOs() { -// checkSession(); - return model.getOs(); - } - - public NId getOsDist() { -// checkSession(); - return model.getOsDist(); - } - - @Override - public NId getArch() { -// checkSession(); - return model.getArch(); - } - - @Override - public NArchFamily getArchFamily() { -// checkSession(); - return model.getArchFamily(); - } - - @Override - public boolean isGraphicalDesktopEnvironment() { - return model.isGraphicalDesktopEnvironment(); - } - - @Override - public NSupportMode getDesktopIntegrationSupport(NDesktopIntegrationItem item) { - NAssert.requireNonBlank(item, "item"); - switch (item) { - case DESKTOP: { - NSupportMode a = NBootManager.of().getBootOptions().getDesktopLauncher().orNull(); - if (a != null) { - return a; - } - break; - } - case MENU: { - NSupportMode a = NBootManager.of().getBootOptions().getMenuLauncher().orNull(); - if (a != null) { - return a; - } - break; - } - case USER: { - NSupportMode a = NBootManager.of().getBootOptions().getUserLauncher().orNull(); - if (a != null) { - return a; - } - break; - } - } - switch (getOsFamily()) { - case LINUX: { - switch (item) { - case DESKTOP: { - return NSupportMode.SUPPORTED; - } - case MENU: { - return NSupportMode.PREFERRED; - } - case USER: { - return NSupportMode.PREFERRED; - } - } - break; - } - case UNIX: { - return NSupportMode.NEVER; - } - case WINDOWS: { - switch (item) { - case DESKTOP: { - if (Files.isDirectory(getDesktopPath())) { - return NSupportMode.PREFERRED; - } - return NSupportMode.SUPPORTED; - } - case MENU: { - return NSupportMode.PREFERRED; - } - case USER: { - return NSupportMode.PREFERRED; - } - } - break; - } - case MACOS: { - return NSupportMode.NEVER; - } - case UNKNOWN: { - return NSupportMode.NEVER; - } - } - return NSupportMode.NEVER; - } - - public Path getDesktopPath() { - switch (getOsFamily()) { - case LINUX: - case UNIX: - case MACOS: { - File f = new File(System.getProperty("user.home"), ".config/user-dirs.dirs"); - if (f.exists()) { - try (BufferedReader r = new BufferedReader(new FileReader(f))) { - String line; - while ((line = r.readLine()) != null) { - line = line.trim(); - if (line.startsWith("#")) { - //ignore - } else { - Matcher m = UNIX_USER_DIRS_PATTERN.matcher(line); - if (m.find()) { - String k = m.group("k"); - if (k.equals("XDG_DESKTOP_DIR")) { - String v = m.group("v"); - v = v.trim(); - if (v.startsWith("\"")) { - int last = v.indexOf('\"', 1); - String s = v.substring(1, last); - s = s.replace("$HOME", System.getProperty("user.home")); - return Paths.get(s); - } else { - return Paths.get(v); - } - } - } else { - //this is unexpected format! - break; - } - } - } - } catch (IOException ex) { - //ignore - } - } - return new File(System.getProperty("user.home"), "Desktop").toPath(); - } - case WINDOWS: { - return new File(System.getProperty("user.home"), "Desktop").toPath(); - } - default: { - return new File(System.getProperty("user.home"), "Desktop").toPath(); - } - } - } - - public void addLauncher(NLauncherOptions launcher) { - //apply isolation! - NIsolationLevel isolation = NBootManager.of().getBootOptions().getIsolationLevel().orElse(NIsolationLevel.SYSTEM); - if (isolation.compareTo(NIsolationLevel.CONFINED) >= 0) { - launcher.setCreateDesktopLauncher(NSupportMode.NEVER); - launcher.setCreateMenuLauncher(NSupportMode.NEVER); - launcher.setCreateUserLauncher(NSupportMode.NEVER); - launcher.setSwitchWorkspace(false); - launcher.setSwitchWorkspaceLocation(null); - } - SystemNdi ndi = NSettingsNdiSubCommand.createNdi(this.model.getWorkspace()); - if (ndi != null) { - ndi.addScript( - new NdiScriptOptions() - .setLauncher(launcher.copy()), - new String[]{launcher.getId().builder().getFullName()} - ); - } - } - - - public DefaultNWorkspaceEnvManagerModel getModel() { - return model; - } - - private DefaultNWorkspaceConfigModel _configModel() { - DefaultNConfigs config = (DefaultNConfigs) NConfigs.of(); - return config.getModel(); - } - -// public boolean matchCondition(NutsSupportCondition request, NutsSupportMode support) { -// checkSession(); -// if (request == null) { -// request = NutsSupportCondition.NEVER; -// } -// if (support == null) { -// support = NutsSupportMode.UNSUPPORTED; -// } -// switch (support) { -// case UNSUPPORTED: { -// return false; -// } -// case SUPPORTED: { -// switch (request) { -// case NEVER: -// return false; -// case ALWAYS: -// case SUPPORTED: { -// return true; -// } -// case PREFERRED: { -// return false; -// } -// default: { -// throw new NutsUnsupportedEnumException(getSession(), request); -// } -// } -// } -// case PREFERRED: { -// switch (request) { -// case NEVER: -// return false; -// case ALWAYS: -// case PREFERRED: { -// return true; -// } -// case SUPPORTED: { -// return false; -// } -// default: { -// throw new NutsUnsupportedEnumException(getSession(), request); -// } -// } -// } -// default: { -// throw new NutsUnsupportedEnumException(getSession(), support); -// } -// } -// } - -// public void addLauncherOld(NutsLauncherOptions launcher) { -// checkSession(); -// if (launcher == null) { -// throw new NutsIllegalArgumentException(getSession(), NMsg.ofC("missing launcher options")); -// } -// NutsId id = launcher.getId(); -// if (id == null) { -// throw new NutsIllegalArgumentException(getSession(), NMsg.ofC("missing id")); -// } -// -// NutsWorkspace ws = getSession().getWorkspace(); -// List cmdLine = new ArrayList<>(); -// cmdLine.add(id.getShortName()); -// if (launcher.getArgs() != null) { -// cmdLine.addAll(Arrays.asList(launcher.getArgs())); -// } -// String alias = launcher.getAlias(); -// if (alias == null || alias.isEmpty()) { -// alias = id.getArtifactId(); -// } -// if (launcher.isCreateAlias()) { -// if (!ws.commands().commandExists(alias)) { -// ws.commands() -// .addCommand( -// new NutsCommandConfig() -// .setName(alias) -// .setOwner(getSession().getAppId()) -// .setCommand(ws.commandLine().create(cmdLine.toString()).toString()) -// ); -// } -// } -// -// NutsExecCommand cmd = ws.exec().setCommand("settings", "add", "launcher"); -// if (alias != null) { -// cmd.addCommand("--name", alias); -// } -// if (!GraphicsEnvironment.isHeadless()) { -// if (launcher.getCreateDesktopShortcut() != null) { -// switch (launcher.getCreateDesktopShortcut()) { -// case NEVER: { -// break; -// } -// case ALWAYS: { -// cmd.addCommand("--desktop=always"); -// break; -// } -// case PREFERRED: { -// cmd.addCommand("--desktop=preferred"); -// break; -// } -// case SUPPORTED: { -// cmd.addCommand("--desktop=supported"); -// break; -// } -// default: { -// throw new NutsUnsupportedEnumException(getSession(), launcher.getCreateDesktopShortcut()); -// } -// } -// } -// if (launcher.getCreateMenuShortcut() != null) { -// switch (launcher.getCreateMenuShortcut()) { -// case NEVER: { -// break; -// } -// case ALWAYS: { -// cmd.addCommand("--menu=always"); -// break; -// } -// case PREFERRED: { -// cmd.addCommand("--menu=preferred"); -// break; -// } -// case SUPPORTED: { -// cmd.addCommand("--menu=supported"); -// break; -// } -// default: { -// throw new NutsUnsupportedEnumException(getSession(), launcher.getCreateMenuShortcut()); -// } -// } -// } -// if (launcher.getCreateCustomShortcut() != null) { -// switch (launcher.getCreateCustomShortcut()) { -// case NEVER: { -// break; -// } -// case ALWAYS: { -// cmd.addCommand("--shortcut=always"); -// break; -// } -// case PREFERRED: { -// cmd.addCommand("--shortcut=preferred"); -// break; -// } -// case SUPPORTED: { -// cmd.addCommand("--shortcut=supported"); -// break; -// } -// default: { -// throw new NutsUnsupportedEnumException(getSession(), launcher.getCreateCustomShortcut()); -// } -// } -// } -// if (launcher.getShortcutName() != null) { -// cmd.addCommand("--shortcut-name", launcher.getShortcutName()); -// } -// if (launcher.getCustomShortcutPath() != null) { -// cmd.addCommand("--shortcut-path", launcher.getCustomShortcutPath()); -// } -// if (launcher.getMenuCategory() != null) { -// cmd.addCommand("--menu-category", launcher.getMenuCategory()); -// } -// if (launcher.getIcon() != null) { -// cmd.addCommand("--icon", launcher.getMenuCategory()); -// } -// } -// if (launcher.isOpenTerminal()) { -// cmd.addCommand("--terminal"); -// } -// cmd.addCommand(id.getLongName()); -// cmd.setFailFast(true); -// cmd.setExecutionType(NutsExecutionType.EMBEDDED); -// cmd.run(); -// } - - - @Override - public List buildEffectiveCommand(String[] cmd, NRunAs runAsMode, Set de, Function sysWhich, Boolean gui, String rootName, String userName, String[] executorOptions) { - return NSysExecUtils.buildEffectiveCommand(cmd, runAsMode, de, sysWhich, gui, rootName, userName, executorOptions); - } -} diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNImports.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNImports.java deleted file mode 100644 index 1cb85eb69..000000000 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNImports.java +++ /dev/null @@ -1,64 +0,0 @@ -package net.thevpc.nuts.runtime.standalone.workspace.config; - -import net.thevpc.nuts.*; -import java.util.Set; - -import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NImports; -import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; -import net.thevpc.nuts.spi.NSupportLevelContext; - -public class DefaultNImports implements NImports { - - private DefaultImportModel model; - - public DefaultNImports(NWorkspace workspace) { - NWorkspaceExt e = NWorkspaceExt.of(); - this.model = e.getModel().importModel; - } - - @Override - public int getSupportLevel(NSupportLevelContext context) { - return NConstants.Support.DEFAULT_SUPPORT; - } - - @Override - public NImports addImports(String... importExpressions) { - model.add(importExpressions); - return this; - } - - - @Override - public NImports clearImports() { - model.removeAll(); - return this; - } - - @Override - public NImports removeImports(String... importExpressions) { - model.remove(importExpressions); - return this; - } - - @Override - public NImports updateImports(String[] imports) { - model.set(imports); - return this; - } - - @Override - public boolean isImportedGroupId(String groupId) { - return model.isImportedGroupId(groupId); - } - - @Override - public Set getAllImports() { - return model.getAll(); - } - - public DefaultImportModel getModel() { - return model; - } - -} diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNIndexStore.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNIndexStore.java index 527c5f8a7..3a50912b8 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNIndexStore.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNIndexStore.java @@ -30,8 +30,9 @@ import net.thevpc.nuts.NConstants; import net.thevpc.nuts.elem.NEDesc; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NIndexStore; -import net.thevpc.nuts.env.NLocations; + +import net.thevpc.nuts.NIndexStore; + import net.thevpc.nuts.io.NIOException; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.util.NIteratorBuilder; @@ -54,7 +55,6 @@ public DefaultNIndexStore(NRepository repository) { @Override public NIterator searchVersions(NId id) { - NSession session=getRepository().getWorkspace().currentSession(); return NIteratorBuilder.ofSupplier( () -> { if (isInaccessible()) { @@ -90,7 +90,6 @@ public NIterator searchVersions(NId id) { @Override public NIterator search(NIdFilter filter) { - NSession session=getWorkspace().currentSession(); NElements elems = NElements.of(); return NIteratorBuilder.ofSupplier( () -> { @@ -103,7 +102,7 @@ public NIterator search(NIdFilter filter) { Map[] array = elems.json().parse(new InputStreamReader(NPath.of(uu).getInputStream()), Map[].class); return Arrays.stream(array) .map(s -> NId.of(s.get("stringId").toString()).get()) - .filter(filter != null ? new NIdFilterToNIdPredicate(filter, session) : NPredicates.always()) + .filter(filter != null ? new NIdFilterToNIdPredicate(filter) : NPredicates.always()) .iterator(); } catch (UncheckedIOException | NIOException e) { setInaccessible(); @@ -120,7 +119,6 @@ public NIterator search(NIdFilter filter) { } private NPath getIndexURL() { - NSession session=getRepository().getWorkspace().currentSession(); return NPath.of("http://localhost:7070/indexer/"); } @@ -129,7 +127,6 @@ public NIndexStore invalidate(NId id) { if (isInaccessible()) { return this; } - NSession session=getRepository().getWorkspace().currentSession(); String uu = getIndexURL().resolve( NConstants.Folders.ID).resolve("delete") + String.format("?repositoryUuid=%s&name=%s&repo=%s&group=%s&version=%s" + "&os=%s&osdist=%s&arch=%s&face=%s"/*&alternative=%s*/, getRepository().getUuid(), @@ -154,7 +151,6 @@ public NIndexStore revalidate(NId id) { if (isInaccessible()) { return this; } - NSession session=getRepository().getWorkspace().currentSession(); String uu = getIndexURL().resolve(NConstants.Folders.ID).resolve("addData") + String.format("?repositoryUuid=%s&name=%s&repo=%s&group=%s&version=%s" + "&os=%s&osdist=%s&arch=%s&face=%s"/*&alternative=%s*/, getRepository().getUuid(), @@ -176,9 +172,8 @@ public NIndexStore revalidate(NId id) { @Override public NIndexStore subscribe() { - NSession session=getRepository().getWorkspace().currentSession(); String uu = "http://localhost:7070/indexer/subscription/subscribe?workspaceLocation=" - + CoreIOUtils.urlEncodeString(NLocations.of().getWorkspaceLocation().toString()) + + CoreIOUtils.urlEncodeString(NWorkspace.get().getWorkspaceLocation().toString()) + "&repositoryUuid=" + CoreIOUtils.urlEncodeString(getRepository().getUuid()); try { NPath.of(uu).getInputStream(); @@ -190,9 +185,8 @@ public NIndexStore subscribe() { @Override public NIndexStore unsubscribe() { - NSession session=getRepository().getWorkspace().currentSession(); String uu = "http://localhost:7070/indexer/subscription/unsubscribe?workspaceLocation=" - + CoreIOUtils.urlEncodeString(NLocations.of().getWorkspaceLocation().toString()) + + CoreIOUtils.urlEncodeString(NWorkspace.get().getWorkspaceLocation().toString()) + "&repositoryUuid=" + CoreIOUtils.urlEncodeString(getRepository().getUuid()); try { NPath.of(uu).getInputStream(); @@ -204,9 +198,8 @@ public NIndexStore unsubscribe() { @Override public boolean isSubscribed() { - NSession session = getRepository().getWorkspace().currentSession(); String uu = "http://localhost:7070/indexer/subscription/isSubscribed?workspaceLocation=" - + CoreIOUtils.urlEncodeString(NLocations.of().getWorkspaceLocation().toString()) + + CoreIOUtils.urlEncodeString(NWorkspace.get().getWorkspaceLocation().toString()) + "&repositoryUuid=" + CoreIOUtils.urlEncodeString(getRepository().getUuid()); try { return new Scanner(NPath.of(uu).getInputStream()).nextBoolean(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNIndexStoreFactory.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNIndexStoreFactory.java index 5a2f0d869..284abcb93 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNIndexStoreFactory.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNIndexStoreFactory.java @@ -27,7 +27,7 @@ package net.thevpc.nuts.runtime.standalone.workspace.config; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NIndexStore; +import net.thevpc.nuts.NIndexStore; import net.thevpc.nuts.spi.NIndexStoreFactory; import net.thevpc.nuts.NRepository; import net.thevpc.nuts.spi.NSupportLevelContext; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNLocations.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNLocations.java deleted file mode 100755 index 655e9f1fe..000000000 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNLocations.java +++ /dev/null @@ -1,135 +0,0 @@ -package net.thevpc.nuts.runtime.standalone.workspace.config; - -import java.util.Map; - -import net.thevpc.nuts.*; -import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.*; -import net.thevpc.nuts.io.NPath; -import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; -import net.thevpc.nuts.spi.NSupportLevelContext; - -public class DefaultNLocations implements NLocations { - - private DefaultNWorkspaceLocationModel model; - - public DefaultNLocations(NWorkspace workspace) { - this.model = NWorkspaceExt.of().getModel().locationsModel; - } - - @Override - public int getSupportLevel(NSupportLevelContext context) { - return NConstants.Support.DEFAULT_SUPPORT; - } - - @Override - public NPath getHomeLocation(NStoreType folderType) { - return model.getHomeLocation(folderType); - } - - public DefaultNWorkspaceLocationModel getModel() { - return model; - } - - - @Override - public NPath getStoreLocation(NStoreType folderType) { - return model.getStoreLocation(folderType); - } - - @Override - public NPath getStoreLocation(NId id, NStoreType folderType) { - return model.getStoreLocation(id, folderType); - } - - @Override - public NPath getStoreLocation(NStoreType folderType, String repositoryIdOrName) { - return model.getStoreLocation(folderType, repositoryIdOrName); - } - - @Override - public NPath getStoreLocation(NId id, NStoreType folderType, String repositoryIdOrName) { - return model.getStoreLocation(id, folderType, repositoryIdOrName); - } - - @Override - public NStoreStrategy getStoreStrategy() { - return model.getStoreStrategy(); - } - - @Override - public NStoreStrategy getRepositoryStoreStrategy() { - return model.getRepositoryStoreStrategy(); - } - - @Override - public NOsFamily getStoreLayout() { - return model.getStoreLayout(); - } - - @Override - public Map getStoreLocations() { - return model.getStoreLocations(); - } - - @Override - public String getDefaultIdFilename(NId id) { - return model.getDefaultIdFilename(id); - } - - @Override - public NPath getDefaultIdBasedir(NId id) { - return model.getDefaultIdBasedir(id); - } - - @Override - public String getDefaultIdContentExtension(String packaging) { - return model.getDefaultIdContentExtension(packaging); - } - - @Override - public String getDefaultIdExtension(NId id) { - return model.getDefaultIdExtension(id); - } - - @Override - public Map getHomeLocations() { - return model.getHomeLocations(); - } - - @Override - public NPath getHomeLocation(NHomeLocation location) { - return model.getHomeLocation(location); - } - - @Override - public NPath getWorkspaceLocation() { - return model.getWorkspaceLocation(); - } - - @Override - public NLocations setStoreLocation(NStoreType folderType, String location) { - model.setStoreLocation(folderType, location); - return this; - } - - - @Override - public NLocations setStoreStrategy(NStoreStrategy strategy) { - model.setStoreStrategy(strategy); - return this; - } - - @Override - public NLocations setStoreLayout(NOsFamily storeLayout) { - model.setStoreLayout(storeLayout); - return this; - } - - @Override - public NLocations setHomeLocation(NHomeLocation homeType, String location) { - model.setHomeLocation(homeType, location); - return this; - } - -} diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNPlatformModel.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNPlatformModel.java index 81b1d93a5..ccec34a9d 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNPlatformModel.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNPlatformModel.java @@ -1,14 +1,12 @@ package net.thevpc.nuts.runtime.standalone.workspace.config; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NPlatformFamily; +import net.thevpc.nuts.NPlatformFamily; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.util.jclass.NJavaSdkUtils; import net.thevpc.nuts.runtime.standalone.util.jclass.JavaClassUtils; +import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; import net.thevpc.nuts.text.NText; -import net.thevpc.nuts.text.NTextStyle; -import net.thevpc.nuts.text.NTextStyles; -import net.thevpc.nuts.text.NTexts; import net.thevpc.nuts.util.*; import java.util.*; @@ -73,8 +71,8 @@ public boolean add0(NPlatformLocation location, boolean notify) { NPath.of(location.getPath()) )); } - NConfigsExt.of(NConfigs.of()) - .getModel() + NWorkspaceExt.of(workspace) + .getConfigModel() .fireConfigurationChanged("platform", ConfigEventType.MAIN); } return true; @@ -95,9 +93,8 @@ public boolean removePlatform(NPlatformLocation location) { List list = getPlatforms().get(location.getPlatformType()); if (list != null) { if (list.remove(location)) { - NSession session=getWorkspace().currentSession(); - NConfigsExt.of(NConfigs.of()) - .getModel() + NWorkspaceExt.of(workspace) + .getConfigModel() .fireConfigurationChanged("platform", ConfigEventType.MAIN); return true; } @@ -144,7 +141,6 @@ public NOptional findPlatform(NPlatformLocation location) { } public NOptional findPlatformByVersion(NPlatformFamily type, NVersionFilter versionFilter) { - NSession session=getWorkspace().currentSession(); return findOnePlatform(type, location -> { @@ -187,15 +183,13 @@ public NStream searchSystemPlatforms(NPlatformFamily platform } public NStream searchSystemPlatforms(NPlatformFamily platformType, NPath path) { - NSession session=getWorkspace().currentSession(); if (platformType == NPlatformFamily.JAVA) { - return NStream.of(NJavaSdkUtils.of(workspace).searchJdkLocations(path, session)); + return NStream.of(NJavaSdkUtils.of(workspace).searchJdkLocations(path)); } return NStream.ofEmpty(); } public NOptional resolvePlatform(NPlatformFamily platformType, NPath path, String preferredName) { - NSession session=getWorkspace().currentSession(); if (platformType == NPlatformFamily.JAVA) { NPlatformLocation z = NJavaSdkUtils.of(workspace).resolveJdkLocation(path, preferredName); if (z == null) { @@ -227,7 +221,6 @@ public NOptional findOnePlatform(NPlatformFamily type, Predic return NOptional.of(r); } //find the best minimum version that is applicable! - NSession session=getWorkspace().currentSession(); NPlatformLocation best = a[0]; for (int i = 1; i < a.length; i++) { NVersion v1 = NVersion.of(best.getVersion()).get(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNPlatforms.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNPlatforms.java deleted file mode 100644 index b08653eaf..000000000 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNPlatforms.java +++ /dev/null @@ -1,124 +0,0 @@ -package net.thevpc.nuts.runtime.standalone.workspace.config; - -import java.util.function.Predicate; -import net.thevpc.nuts.*; -import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.io.NPath; -import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceExt; -import net.thevpc.nuts.runtime.standalone.workspace.NWorkspaceUtils; -import net.thevpc.nuts.spi.NSupportLevelContext; -import net.thevpc.nuts.util.NOptional; -import net.thevpc.nuts.env.NPlatformFamily; -import net.thevpc.nuts.util.NStream; - -public class DefaultNPlatforms implements NPlatforms { - - private DefaultNPlatformModel model; - private NWorkspace workspace; - - public DefaultNPlatforms(NWorkspace workspace) { - this.workspace = workspace; - NWorkspaceExt e = (NWorkspaceExt) workspace; - this.model = e.getModel().sdkModel; - } - - @Override - public int getSupportLevel(NSupportLevelContext context) { - return NConstants.Support.DEFAULT_SUPPORT; - } - - public DefaultNPlatformModel getModel() { - return model; - } - - - @Override - public boolean addPlatform(NPlatformLocation location) { - return model.addPlatform(location); - } - - @Override - public boolean updatePlatform(NPlatformLocation oldLocation, NPlatformLocation newLocation) { - return model.updatePlatform(oldLocation, newLocation); - } - - @Override - public boolean removePlatform(NPlatformLocation location) { - return model.removePlatform(location); - } - - @Override - public NOptional findPlatformByName(NPlatformFamily platformType, String locationName) { - return model.findPlatformByName(platformType, locationName); - } - - @Override - public NOptional findPlatformByPath(NPlatformFamily platformType, NPath path) { - return model.findPlatformByPath(platformType, path); - } - - @Override - public NOptional findPlatformByVersion(NPlatformFamily platformType, String version) { - return model.findPlatformByVersion(platformType, version); - } - - @Override - public NOptional findPlatform(NPlatformLocation location) { - return model.findPlatform(location); - } - - @Override - public NOptional findPlatformByVersion(NPlatformFamily platformType, NVersionFilter requestedVersion) { - return model.findPlatformByVersion(platformType, requestedVersion); - } - - @Override - public NStream searchSystemPlatforms(NPlatformFamily platformFamily) { - return model.searchSystemPlatforms(platformFamily); - } - - @Override - public NStream searchSystemPlatforms(NPlatformFamily platformFamily, NPath path) { - return model.searchSystemPlatforms(platformFamily, path); - } - - @Override - public NOptional resolvePlatform(NPlatformFamily platformFamily, NPath path, String preferredName) { - return model.resolvePlatform(platformFamily, path, preferredName); - } - - @Override - public NOptional findPlatform(NPlatformFamily platformFamily, Predicate filter) { - return model.findOnePlatform(platformFamily, filter); - } - - @Override - public NStream findPlatforms(NPlatformFamily platformFamily, Predicate filter) { - return model.findPlatforms(platformFamily, filter); - } - - @Override - public NStream findPlatforms() { - return findPlatforms(null,null); - } - - @Override - public void addDefaultPlatforms(NPlatformFamily type) { - if(type==NPlatformFamily.JAVA) { - NWorkspaceUtils.of(workspace).installAllJVM(); - } - } - - @Override - public void addDefaultPlatform(NPlatformFamily type) { - if(type==NPlatformFamily.JAVA) { - //at least add current vm - NWorkspaceUtils.of(workspace).installCurrentJVM(); - } - } - - @Override - public NStream findPlatforms(NPlatformFamily type) { - return model.findPlatforms(type, null); - } -} diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNWorkspaceBootConfig.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNWorkspaceBootConfig.java index fbb98bd06..5b656231d 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNWorkspaceBootConfig.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNWorkspaceBootConfig.java @@ -2,7 +2,6 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.*; import java.nio.file.Paths; import java.util.Collections; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNWorkspaceConfigModel.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNWorkspaceConfigModel.java index bec73fa67..9f85b8c95 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNWorkspaceConfigModel.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNWorkspaceConfigModel.java @@ -25,11 +25,9 @@ package net.thevpc.nuts.runtime.standalone.workspace.config; import net.thevpc.nuts.*; -import net.thevpc.nuts.boot.NBootClassLoaderNode; -import net.thevpc.nuts.env.NBootOptions; +import net.thevpc.nuts.NBootOptions; import net.thevpc.nuts.NConstants; import net.thevpc.nuts.boot.NBootDescriptor; -import net.thevpc.nuts.env.*; import net.thevpc.nuts.runtime.standalone.DefaultNDescriptorBuilder; import net.thevpc.nuts.runtime.standalone.util.*; import net.thevpc.nuts.util.NBlankable; @@ -202,15 +200,14 @@ public boolean save(boolean force) { if (!force && !isConfigurationChanged()) { return false; } - NSession session = getWorkspace().currentSession(); NWorkspaceUtils.of(getWorkspace()).checkReadOnly(); boolean ok = false; NWorkspaceSecurityManager.of().checkAllowed(NConstants.Permissions.SAVE, "save"); - NPath apiVersionSpecificLocation = NLocations.of().getStoreLocation(session.getWorkspace().getApiId(), NStoreType.CONF); + NPath apiVersionSpecificLocation = NWorkspace.get().getStoreLocation(getWorkspace().getApiId(), NStoreType.CONF); NElements elem = NElements.of(); if (force || storeModelBootChanged) { - Path file = NLocations.of().getWorkspaceLocation().toPath().get().resolve(NConstants.Files.WORKSPACE_CONFIG_FILE_NAME); + Path file = NWorkspace.get().getWorkspaceLocation().toPath().get().resolve(NConstants.Files.WORKSPACE_CONFIG_FILE_NAME); storeModelBoot.setConfigVersion(DefaultNWorkspace.VERSION_WS_CONFIG_BOOT); if (storeModelBoot.getExtensions() != null) { for (NWorkspaceConfigBoot.ExtensionConfig extension : storeModelBoot.getExtensions()) { @@ -224,7 +221,7 @@ public boolean save(boolean force) { ok = true; } - NPath configVersionSpecificLocation = NLocations.of().getStoreLocation(session.getWorkspace().getApiId(), NStoreType.CONF); + NPath configVersionSpecificLocation = NWorkspace.get().getStoreLocation(getWorkspace().getApiId(), NStoreType.CONF); if (force || storeModelSecurityChanged) { storeModelSecurity.setUsers(configUsers.isEmpty() ? null : configUsers.values().toArray(new NUserConfig[0])); @@ -244,10 +241,10 @@ public boolean save(boolean force) { if (force || storeModelMainChanged) { List plainSdks = new ArrayList<>(); - plainSdks.addAll(NPlatforms.of().findPlatforms().toList()); + plainSdks.addAll(NWorkspace.get().findPlatforms().toList()); storeModelMain.setPlatforms(plainSdks); storeModelMain.setRepositories( - NRepositories.of().getRepositories().stream().filter(x -> !x.config().isTemporary()) + workspace.getRepositories().stream().filter(x -> !x.config().isTemporary()) .map(x -> x.config().getRepositoryRef()).collect(Collectors.toList()) ); @@ -292,8 +289,8 @@ public boolean save(boolean force) { ok = true; } if (force || storeModelRuntimeChanged) { - NPath runtimeVersionSpecificLocation = NLocations.of().getStoreLocation(NStoreType.CONF) - .resolve(NConstants.Folders.ID).resolve(NLocations.of().getDefaultIdBasedir(session.getWorkspace().getRuntimeId())); + NPath runtimeVersionSpecificLocation = NWorkspace.get().getStoreLocation(NStoreType.CONF) + .resolve(NConstants.Folders.ID).resolve(NWorkspace.get().getDefaultIdBasedir(getWorkspace().getRuntimeId())); NPath afile = runtimeVersionSpecificLocation.resolve(NConstants.Files.RUNTIME_BOOT_CONFIG_FILE_NAME); storeModelRuntime.setConfigVersion(current().getApiVersion()); elem.json().setValue(storeModelRuntime) @@ -302,7 +299,7 @@ public boolean save(boolean force) { ok = true; } NException error = null; - for (NRepository repo : NRepositories.of().getRepositories()) { + for (NRepository repo : workspace.getRepositories()) { try { if (repo.config() instanceof NRepositoryConfigManagerExt) { ok |= ((NRepositoryConfigManagerExt) (repo.config())).getModel().save(force); @@ -329,7 +326,6 @@ public NWorkspaceBootConfig loadBootConfig(String _ws, boolean system, boolean f NWorkspaceConfigBoot lastConfigLoaded = null; boolean defaultLocation = false; NPlatformHome plocs = NPlatformHome.of(null, system); - NSession session = getWorkspace().currentSession(); if (_ws != null && _ws.matches("[a-z-]+://.*")) { //this is a protocol based workspace //String protocol=ws.substring(0,ws.indexOf("://")); @@ -384,7 +380,6 @@ public NWorkspaceBootConfig loadBootConfig(String _ws, boolean system, boolean f public boolean isExcludedExtension(String extensionId, NWorkspaceOptions options) { if (extensionId != null && options != null) { - NSession session = getWorkspace().currentSession(); NId pnid = NId.of(extensionId).get(); String shortName = pnid.getShortName(); String artifactId = pnid.getArtifactId(); @@ -416,7 +411,6 @@ public boolean isSupportedRepositoryType(String repositoryType) { } public List getDefaultRepositories() { -// session = NutsWorkspaceUtils.of(getWorkspace()).validateSession(session); List all = new ArrayList<>(); for (NRepositoryFactoryComponent provider : NExtensions.of() .createAll(NRepositoryFactoryComponent.class)) { @@ -436,7 +430,6 @@ public int compare(NAddRepositoryOptions o1, NAddRepositoryOptions o2) { public Set getAvailableArchetypes() { Set set = new HashSet<>(); set.add("default"); - NSession session = getWorkspace().currentSession(); for (NWorkspaceArchetypeComponent extension : NExtensions.of() .createComponents(NWorkspaceArchetypeComponent.class, null)) { set.add(extension.getName()); @@ -446,10 +439,9 @@ public Set getAvailableArchetypes() { public NPath resolveRepositoryPath(NPath repositoryLocation) { NPath root = this.getRepositoriesRoot(); - NSession session = getWorkspace().currentSession(); return repositoryLocation .toAbsolute(root != null ? root : - NLocations.of().getStoreLocation(NStoreType.CONF) + NWorkspace.get().getStoreLocation(NStoreType.CONF) .resolve(NConstants.Folders.REPOSITORIES)) ; } @@ -623,7 +615,7 @@ public boolean loadWorkspace() { } cConfig.merge(getBootUserOptions().toWorkspaceOptions()); - setCurrentConfig(cConfig.build(NLocations.of().getWorkspaceLocation())); + setCurrentConfig(cConfig.build(NWorkspace.get().getWorkspaceLocation())); NVersionCompat compat = createNutsVersionCompat(Nuts.getVersion()); NId apiId = workspace.getApiId(); @@ -684,7 +676,7 @@ public boolean loadWorkspace() { cConfig.setBootRepositories(effOptions.getBootRepositories().orNull()); } setCurrentConfig(cConfig - .build(NLocations.of().getWorkspaceLocation()) + .build(NWorkspace.get().getWorkspaceLocation()) ); if (aconfig == null) { aconfig = new NWorkspaceConfigApi(); @@ -707,7 +699,7 @@ public boolean loadWorkspace() { storeModelMainChanged = _storeModelMainChanged; return true; } catch (RuntimeException ex) { - if (NBootManager.of().getBootOptions().getRecover().orElse(false)) { + if (NWorkspace.get().getBootOptions().getRecover().orElse(false)) { onLoadWorkspaceError(ex); } else { throw ex; @@ -718,7 +710,7 @@ public boolean loadWorkspace() { private List findOlderNutsApiIds() { NId apiId = workspace.getApiId(); - NPath path = NLocations.of().getStoreLocation(apiId, NStoreType.CONF) + NPath path = NWorkspace.get().getStoreLocation(apiId, NStoreType.CONF) .getParent(); List olderIds = path.stream().filter(NPath::isDirectory) .withDesc(NEDesc.of("isDirectory")) @@ -774,8 +766,8 @@ public void setExtraBootExtensionId(NId apiId, NId extensionId, List de estoreModelApi.setApiVersion(apiId.getVersion()); estoreModelApi.setRuntimeId(runtimeId); estoreModelApi.setConfigVersion(current().getApiVersion()); - NPath apiVersionSpecificLocation = NLocations.of().getStoreLocation(apiId, NStoreType.CONF); + NPath apiVersionSpecificLocation = NWorkspace.get().getStoreLocation(apiId, NStoreType.CONF); NPath afile = apiVersionSpecificLocation.resolve(NConstants.Files.API_BOOT_CONFIG_FILE_NAME); NElements elems = NElements.of(); elems.json().setValue(estoreModelApi) @@ -817,8 +809,8 @@ public void setExtraBootRuntimeId(NId apiId, NId runtimeId, List de newDeps ); - NPath runtimeVersionSpecificLocation = NLocations.of().getStoreLocation(NStoreType.CONF) - .resolve(NConstants.Folders.ID).resolve(NLocations.of().getDefaultIdBasedir(runtimeId)); + NPath runtimeVersionSpecificLocation = NWorkspace.get().getStoreLocation(NStoreType.CONF) + .resolve(NConstants.Folders.ID).resolve(NWorkspace.get().getDefaultIdBasedir(runtimeId)); afile = runtimeVersionSpecificLocation.resolve(NConstants.Files.RUNTIME_BOOT_CONFIG_FILE_NAME); storeModelRuntime.setConfigVersion(current().getApiVersion()); elems.json().setValue(storeModelRuntime) @@ -853,7 +845,6 @@ public void setBootRepositories(String value) { } public NWorkspaceConfigBoot.ExtensionConfig getBootExtension(String value) { - NSession session = getWorkspace().currentSession(); NId newId = NId.of(value).get(); for (NWorkspaceConfigBoot.ExtensionConfig extension : storeModelBoot.getExtensions()) { NId id = extension.getId(); @@ -865,7 +856,6 @@ public NWorkspaceConfigBoot.ExtensionConfig getBootExtension(String value) { } public void setBootExtension(String value, String dependencies, boolean enabled) { - NSession session = getWorkspace().currentSession(); NId newId = NId.of(value).get(); for (NWorkspaceConfigBoot.ExtensionConfig extension : storeModelBoot.getExtensions()) { NId id = extension.getId(); @@ -919,9 +909,8 @@ public void setSecure(boolean secure) { } public void fireConfigurationChanged(String configName, ConfigEventType t) { -// session = NutsWorkspaceUtils.of(ws).validateSession(session); NSession session = getWorkspace().currentSession(); - ((DefaultNImports) NImports.of()).getModel().invalidateCache(); + workspace.getImportModel().invalidateCache(); switch (t) { case API: { storeModelApiChanged = true; @@ -945,7 +934,7 @@ public void fireConfigurationChanged(String configName, ConfigEventType t) { } } DefaultNWorkspaceEvent evt = new DefaultNWorkspaceEvent(session, null, "config." + configName, null, true); - for (NWorkspaceListener workspaceListener : NEvents.of().getWorkspaceListeners()) { + for (NWorkspaceListener workspaceListener : workspace.getWorkspaceListeners()) { workspaceListener.onConfigurationChanged(evt); } } @@ -975,7 +964,6 @@ public NWorkspace getWorkspace() { } public NDependencySolver createDependencySolver(String name) { - NSession session = getWorkspace().currentSession(); NDependencySolverFactory c = getSolversMap().get(NDependencySolverUtils.resolveSolverName(name)); if (c != null) { return c.create(); @@ -986,7 +974,6 @@ public NDependencySolver createDependencySolver(String name) { private Map getSolversMap() { if (dependencySolvers == null) { dependencySolvers = new LinkedHashMap<>(); - NSession session = getWorkspace().currentSession(); for (NDependencySolverFactory nutsDependencySolver : NExtensions.of().createComponents(NDependencySolverFactory.class, null)) { dependencySolvers.put(nutsDependencySolver.getName(), nutsDependencySolver); } @@ -998,20 +985,38 @@ public NDependencySolverFactory[] getDependencySolvers() { return getSolversMap().values().toArray(new NDependencySolverFactory[0]); } - + public List getDependencySolverNames() { + // the first element is always the default one, + // the rest is lexicographically sorter + return Arrays.stream(getDependencySolvers()) + .map(NDependencySolverFactory::getName) + .sorted(new Comparator() { + @Override + public int compare(String o1, String o2) { + if (!o1.equals(o2)) { + String n = NDependencySolverUtils.resolveSolverName(NSession.of().get().getDependencySolver()); + if (o1.equals(n)) { + return -1; + } + if (o2.equals(n)) { + return 1; + } + } + return o1.compareTo(o2); + } + }) + .collect(Collectors.toList()); + } public NPath getRepositoriesRoot() { - NSession session = getWorkspace().currentSession(); - return NLocations.of().getStoreLocation(NStoreType.CONF).resolve(NConstants.Folders.REPOSITORIES); + return NWorkspace.get().getStoreLocation(NStoreType.CONF).resolve(NConstants.Folders.REPOSITORIES); } public NPath getTempRepositoriesRoot() { - NSession session = getWorkspace().currentSession(); - return NLocations.of().getStoreLocation(NStoreType.TEMP).resolve(NConstants.Folders.REPOSITORIES); + return NWorkspace.get().getStoreLocation(NStoreType.TEMP).resolve(NConstants.Folders.REPOSITORIES); } public boolean isValidWorkspaceFolder() { - NSession session = getWorkspace().currentSession(); - Path file = NLocations.of().getWorkspaceLocation().toPath().get().resolve(NConstants.Files.WORKSPACE_CONFIG_FILE_NAME); + Path file = NWorkspace.get().getWorkspaceLocation().toPath().get().resolve(NConstants.Files.WORKSPACE_CONFIG_FILE_NAME); return Files.isRegularFile(file); } @@ -1059,7 +1064,6 @@ public NId createSdkId(String type, String version) { public void onExtensionsPrepared() { try { - NSession session = getWorkspace().currentSession(); indexStoreClientFactory = NExtensions.of().createComponent(NIndexStoreFactory.class).orNull(); } catch (Exception ex) { // @@ -1099,19 +1103,15 @@ private void setConfigSecurity(NWorkspaceConfigSecurity config, boolean fire) { private void setConfigMain(NWorkspaceConfigMain config, boolean fire) { this.storeModelMain = config == null ? new NWorkspaceConfigMain() : config; - NSession session = getWorkspace().currentSession(); - DefaultNPlatforms d = (DefaultNPlatforms) NPlatforms.of(); - d.getModel().setPlatforms(this.storeModelMain.getPlatforms().toArray(new NPlatformLocation[0])); - NRepositories repos = NRepositories.of(); - repos.removeAllRepositories(); + workspace.getSdkModel().setPlatforms(this.storeModelMain.getPlatforms().toArray(new NPlatformLocation[0])); + workspace.removeAllRepositories(); List refsToLoad = this.storeModelMain.getRepositories(); if (refsToLoad != null) { refsToLoad = new ArrayList<>(refsToLoad); //reset config because add will add it again... this.storeModelMain.setRepositories(new ArrayList<>()); for (NRepositoryRef ref : refsToLoad) { - repos - .addRepository( + workspace.addRepository( NRepositoryUtils.refToOptions(ref) ); } @@ -1144,22 +1144,20 @@ public String toString() { + ", workspaceRuntimeId=" + s2 + ", workspace=" + ((currentConfig == null) ? "NULL" : ("'" + - (workspace == null ? "?" : "" + ((DefaultNLocations) NLocations.of() - ).getModel().getWorkspaceLocation()) + '\'')) + (workspace == null ? "?" : "" + NWorkspaceExt.of(workspace).getLocationModel().getWorkspaceLocation()) + '\'')) + '}'; } - public void collect(NBootClassLoaderNode n, LinkedHashMap deps) { + public void collect(NClassLoaderNode n, LinkedHashMap deps) { if (!deps.containsKey(n.getId())) { deps.put(n.getId(), n); - for (NBootClassLoaderNode d : n.getDependencies()) { + for (NClassLoaderNode d : n.getDependencies()) { collect(d, deps); } } } public NBootDef fetchBootDef(NId id, boolean content) { - NSession session = getWorkspace().currentSession(); NDefinition nd = NFetchCmd.of(id) .setDependencies(true).setContent(content) .setDependencyFilter(NDependencyFilters.of().byRunnable()) @@ -1173,10 +1171,10 @@ public NBootDef fetchBootDef(NId id, boolean content) { (content && nd.getContent().isPresent()) ? nd.getContent().get() : null); } if (isFirstBoot()) { - NBootClassLoaderNode n = searchBootNode(id); + NClassLoaderNode n = searchBootNode(id); if (n != null) { - LinkedHashMap dm = new LinkedHashMap<>(); - for (NBootClassLoaderNode d : n.getDependencies()) { + LinkedHashMap dm = new LinkedHashMap<>(); + for (NClassLoaderNode d : n.getDependencies()) { collect(d, dm); } return new NBootDef( @@ -1217,7 +1215,6 @@ public NBootDef fetchBootDef(NId id, boolean content) { public void prepareBootClassPathConf(NIdType idType, NId id, NId forId, NId forceRuntimeId, boolean force, boolean processDependencies) { //do not create boot file for nuts (it has no dependencies anyways!) - NSession session = getWorkspace().currentSession(); switch (idType) { case API: { return; @@ -1264,7 +1261,6 @@ private boolean deployToInstalledRepository(Path tmp) { // .run(); // repo.install(id, session, forId); - NSession session = getWorkspace().currentSession(); NInstalledRepository ins = NWorkspaceExt.of().getInstalledRepository(); NDescriptor descriptor = NDescriptorContentResolver.resolveNutsDescriptorFromFileContent(tmp, null); if (descriptor != null) { @@ -1281,25 +1277,23 @@ null, getWorkspace() return false; } - private NBootClassLoaderNode searchBootNode(NId id) { - NSession session = getWorkspace().currentSession(); - NBootManager boot = NBootManager.of(); - List all = new ArrayList<>(); - all.add(boot.getBootRuntimeClassLoaderNode()); - all.addAll(boot.getBootExtensionClassLoaderNode()); + private NClassLoaderNode searchBootNode(NId id) { + List all = new ArrayList<>(); + all.add(workspace.getBootRuntimeClassLoaderNode()); + all.addAll(workspace.getBootExtensionClassLoaderNode()); return searchBootNode(id, all); } - private NBootClassLoaderNode searchBootNode(NId id, List into) { - for (NBootClassLoaderNode n : into) { + private NClassLoaderNode searchBootNode(NId id, List into) { + for (NClassLoaderNode n : into) { if (n != null) { - if (id.getLongName().equals(n.getId())) { + if (id.equalsLongId(n.getId())) { return n; } - } - NBootClassLoaderNode a = searchBootNode(id, n.getDependencies()); - if (a != null) { - return a; + NClassLoaderNode a = searchBootNode(id, n.getDependencies()); + if (a != null) { + return a; + } } } return null; @@ -1316,7 +1310,7 @@ public void onPostUpdateConfig(String confName) { DefaultNWorkspaceCurrentConfig d = currentConfig; d.setUserStoreLocations(new NStoreLocationsMap(storeModelBoot.getStoreLocations()).toMapOrNull()); d.setHomeLocations(new NHomeLocationsMap(storeModelBoot.getHomeLocations()).toMapOrNull()); - d.build(NLocations.of().getWorkspaceLocation()); + d.build(NWorkspace.get().getWorkspaceLocation()); NStoreLocationsMap newSL = new NStoreLocationsMap(currentConfig.getStoreLocations()); for (NStoreType sl : NStoreType.values()) { String oldPath = preUpdateConfigStoreLocations.get(sl); @@ -1333,15 +1327,14 @@ public void onPostUpdateConfig(String confName) { private void onLoadWorkspaceError(Throwable ex) { DefaultNWorkspaceConfigModel wconfig = this; - NSession session = getWorkspace().currentSession(); - Path file = NLocations.of().getWorkspaceLocation().toPath().get().resolve(NConstants.Files.WORKSPACE_CONFIG_FILE_NAME); + Path file = NWorkspace.get().getWorkspaceLocation().toPath().get().resolve(NConstants.Files.WORKSPACE_CONFIG_FILE_NAME); if (wconfig.isReadOnly()) { throw new NIOException(NMsg.ofC("unable to load config file %s", file), ex); } String fileSuffix = Instant.now().toString(); fileSuffix = fileSuffix.replace(':', '-'); String fileName = "nuts-workspace-" + fileSuffix; - NPath logError = NLocations.of().getStoreLocation(workspace.getApiId(), NStoreType.LOG).resolve("invalid-config"); + NPath logError = NWorkspace.get().getStoreLocation(workspace.getApiId(), NStoreType.LOG).resolve("invalid-config"); NPath logFile = logError.resolve(fileName + ".error"); _LOGOP().level(Level.SEVERE).verb(NLogVerb.FAIL) .log(NMsg.ofC("erroneous workspace config file. Unable to load file %s : %s", file, ex)); @@ -1362,7 +1355,7 @@ private void onLoadWorkspaceError(Throwable ex) { try (PrintStream o = new PrintStream(logFile.getOutputStream())) { o.println("workspace.path:"); - o.println(NLocations.of().getWorkspaceLocation()); + o.println(NWorkspace.get().getWorkspaceLocation()); o.println("workspace.options:"); o.println(wconfig.getBootUserOptions() .toCmdLine( @@ -1372,7 +1365,7 @@ private void onLoadWorkspaceError(Throwable ex) { ); for (NStoreType location : NStoreType.values()) { o.println("location." + location.id() + ":"); - o.println(NLocations.of().getStoreLocation(location)); + o.println(NWorkspace.get().getStoreLocation(location)); } o.println("java.class.path:"); o.println(System.getProperty("java.class.path")); @@ -1388,7 +1381,7 @@ public NUserConfig getSecurity(String id) { } private NWorkspaceConfigBoot parseBootConfig() { - return parseBootConfig(NLocations.of().getWorkspaceLocation()); + return parseBootConfig(NWorkspace.get().getWorkspaceLocation()); } private NWorkspaceConfigBoot parseBootConfig(NPath path) { @@ -1416,23 +1409,21 @@ private NWorkspaceConfigBoot parseBootConfig(NPath path) { } private NVersionCompat createNutsVersionCompat(NVersion apiVersion) { - NSession session = getWorkspace().currentSession(); int buildNumber = CoreNUtils.getApiVersionOrdinalNumber(apiVersion); if (buildNumber >= 803) { - return new NVersionCompat803(apiVersion); + return new NVersionCompat803(workspace,apiVersion); } else if (buildNumber >= 507) { - return new NVersionCompat507(apiVersion); + return new NVersionCompat507(workspace,apiVersion); } else if (buildNumber >= 506) { - return new NVersionCompat506(apiVersion); + return new NVersionCompat506(workspace,apiVersion); } else { - return new NVersionCompat502(apiVersion); + return new NVersionCompat502(workspace,apiVersion); } } public NRepositoryLocation[] resolveBootRepositoriesBootSelectionArray() { List defaults = new ArrayList<>(); - DefaultNConfigs rm = (DefaultNConfigs) NConfigs.of(); - for (NAddRepositoryOptions d : rm.getDefaultRepositories()) { + for (NAddRepositoryOptions d : workspace.getDefaultRepositories()) { defaults.add(NRepositoryLocation.of(d.getName(), (String)null)); } return resolveBootRepositoriesList().resolve(defaults.toArray(new NRepositoryLocation[0]), @@ -1467,11 +1458,10 @@ public NWorkspaceConfigSecurity getStoreModelSecurity() { } public ExecutorService executorService() { - NSession session = getWorkspace().currentSession(); if (executorService == null) { synchronized (this) { if (executorService == null) { - executorService = NBootManager.of().getBootOptions().getExecutorService().orNull(); + executorService = NWorkspace.get().getBootOptions().getExecutorService().orNull(); if (executorService == null) { int minPoolSize = getConfigProperty("nuts.threads.min").flatMap(NLiteral::asInt).orElse(2); @@ -1561,7 +1551,6 @@ public NPath resolve(String path, ClassLoader classLoader) { ClassLoader finalClassLoader = classLoader; Matcher m = PRELOAD_EXTENSION_PATH_PATTERN.matcher(path); - NSession session = getWorkspace().currentSession(); if (m.find()) { String protocol = m.group("protocol"); NId eid = protocolToExtensionMap.get(protocol); @@ -1623,13 +1612,11 @@ public NOptional getConfigProperty(String property) { public void setConfigProperty(String property, String value) { Map env = getStoreModelMain().getEnv(); -// session = CoreNutsUtils.validate(session, workspace); - NSession session = getWorkspace().currentSession(); if (NBlankable.isBlank(value)) { if (env != null && env.containsKey(property)) { env.remove(property); - NConfigsExt.of(NConfigs.of()) - .getModel() + workspace + .getConfigModel() .fireConfigurationChanged("env", ConfigEventType.MAIN); } } else { @@ -1640,8 +1627,8 @@ public void setConfigProperty(String property, String value) { String old = env.get(property); if (!value.equals(old)) { env.put(property, value); - NConfigsExt.of(NConfigs.of()) - .getModel() + workspace + .getConfigModel() .fireConfigurationChanged("env", ConfigEventType.MAIN); } } @@ -1732,10 +1719,6 @@ public String getRuntimeDependencies() { return getStoredConfigRuntime().getDependencies(); } - // @Override -// public String getExtensionDependencies() { -// return getStoredConfigApi().getExtensionDependencies(); -// } @Override public String getBootRepositories() { return getStoredConfigBoot().getBootRepositories(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNWorkspaceCurrentConfig.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNWorkspaceCurrentConfig.java index 9990303dc..3ca6e9151 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNWorkspaceCurrentConfig.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNWorkspaceCurrentConfig.java @@ -2,7 +2,6 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.*; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.DefaultNDescriptorBuilder; import net.thevpc.nuts.runtime.standalone.boot.NBootConfig; @@ -110,7 +109,6 @@ public DefaultNWorkspaceCurrentConfig build(NPath workspaceLocation) { if (repositoryStoreStrategy == null) { repositoryStoreStrategy = NStoreStrategy.EXPLODED; } - NSession session= workspace.currentSession(); Map storeLocations = NPlatformHome.of(getStoreLayout(),getSystem()).buildLocations(storeStrategy, getStoreLocations(), homeLocations, workspaceLocation.toString() @@ -124,7 +122,7 @@ public DefaultNWorkspaceCurrentConfig build(NPath workspaceLocation) { apiId = NId.ofApi(Nuts.getVersion()).get(); } if (storeLayout == null) { - storeLayout = NEnvs.of().getOsFamily(); + storeLayout = NWorkspace.get().getOsFamily(); } return this; } @@ -416,11 +414,11 @@ public NPath getStoreLocation(NId id, NStoreType storeType) { } switch (storeType) { case CACHE: - return storeLocation.resolve(NConstants.Folders.ID).resolve(NLocations.of().getDefaultIdBasedir(id)); + return storeLocation.resolve(NConstants.Folders.ID).resolve(NWorkspace.get().getDefaultIdBasedir(id)); case CONF: - return storeLocation.resolve(NConstants.Folders.ID).resolve(NLocations.of().getDefaultIdBasedir(id)); + return storeLocation.resolve(NConstants.Folders.ID).resolve(NWorkspace.get().getDefaultIdBasedir(id)); } - return storeLocation.resolve(NLocations.of().getDefaultIdBasedir(id)); + return storeLocation.resolve(NWorkspace.get().getDefaultIdBasedir(id)); } } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNWorkspaceEnvManagerModel.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNWorkspaceEnvManagerModel.java index deacd1869..b8e70c524 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNWorkspaceEnvManagerModel.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNWorkspaceEnvManagerModel.java @@ -25,7 +25,6 @@ package net.thevpc.nuts.runtime.standalone.workspace.config; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.*; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.elem.NElement; import net.thevpc.nuts.elem.NElements; @@ -285,7 +284,7 @@ protected Set getDesktopEnvironments0() { return Collections.singleton( NIdBuilder.of().setArtifactId(NDesktopEnvironmentFamily.HEADLESS.id()).build()); } - switch (NEnvs.of().getOsFamily()) { + switch (NWorkspace.get().getOsFamily()) { case WINDOWS: { return Collections.singleton(NIdBuilder.of().setArtifactId(NDesktopEnvironmentFamily.WINDOWS_SHELL.id()).build()); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNWorkspaceLocationModel.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNWorkspaceLocationModel.java index a06a21962..44db70bc6 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNWorkspaceLocationModel.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DefaultNWorkspaceLocationModel.java @@ -2,7 +2,6 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.*; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.id.util.CoreNIdUtils; @@ -66,7 +65,6 @@ public NPath getStoreLocation(NStoreType folderType) { public void setStoreLocation(NStoreType folderType, String location) { - NSession session = getWorkspace().currentSession(); NAssert.requireNonNull(folderType, "store root folder"); cfg().onPreUpdateConfig("store-location"); cfg().getStoreModelBoot().setStoreLocations(new NStoreLocationsMap(cfg().getStoreModelBoot().getStoreLocations()).set(folderType, location).toMapOrNull()); @@ -94,18 +92,16 @@ public void setStoreLayout(NOsFamily layout) { public NPath getStoreLocation(NStoreType folderType, String repositoryIdOrName) { - NSession session = getWorkspace().currentSession(); if (repositoryIdOrName == null) { return getStoreLocation(folderType); } - NRepository repositoryById = NRepositories.of().findRepository(repositoryIdOrName).get(); + NRepository repositoryById = workspace.findRepository(repositoryIdOrName).get(); NRepositorySPI nRepositorySPI = NWorkspaceUtils.of(getWorkspace()).repoSPI(repositoryById); return nRepositorySPI.config().getStoreLocation(folderType); } public NPath getStoreLocation(NId id, NStoreType folderType, String repositoryIdOrName) { - NSession session = getWorkspace().currentSession(); if (repositoryIdOrName == null) { return getStoreLocation(id, folderType); } @@ -119,7 +115,6 @@ public NPath getStoreLocation(NId id, NStoreType folderType) { if (storeLocation == null) { return null; } - NSession session = getWorkspace().currentSession(); return storeLocation.resolve(NConstants.Folders.ID).resolve(getDefaultIdBasedir(id)); // switch (folderType) { // case CACHE: @@ -180,7 +175,6 @@ public NPath getDefaultIdBasedir(NId id) { public String getDefaultIdFilename(NId id) { String classifier = ""; - NSession session = getWorkspace().currentSession(); String ext = getDefaultIdExtension(id); if (!ext.equals(NConstants.Files.DESCRIPTOR_FILE_EXTENSION) && !ext.equals(".pom")) { String c = id.getClassifier(); @@ -193,7 +187,6 @@ public String getDefaultIdFilename(NId id) { public String getDefaultIdContentExtension(String packaging) { - NSession session = getWorkspace().currentSession(); NAssert.requireNonBlank(packaging, "packaging"); switch (packaging) { case "jar": @@ -236,7 +229,6 @@ public String getDefaultIdContentExtension(String packaging) { public String getDefaultIdExtension(NId id) { - NSession session = getWorkspace().currentSession(); Map q = id.getProperties(); String f = NStringUtils.trim(q.get(NConstants.IdProperties.FACE)); switch (f) { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DummyNIndexStore.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DummyNIndexStore.java index ea95e5bf8..55956c4e7 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DummyNIndexStore.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DummyNIndexStore.java @@ -1,7 +1,7 @@ package net.thevpc.nuts.runtime.standalone.workspace.config; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NIndexStore; +import net.thevpc.nuts.NIndexStore; import net.thevpc.nuts.util.NIteratorBuilder; import net.thevpc.nuts.util.NIterator; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DummyNIndexStoreFactory.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DummyNIndexStoreFactory.java index 898675133..e75ea473b 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DummyNIndexStoreFactory.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/DummyNIndexStoreFactory.java @@ -1,7 +1,7 @@ package net.thevpc.nuts.runtime.standalone.workspace.config; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NIndexStore; +import net.thevpc.nuts.NIndexStore; import net.thevpc.nuts.spi.NIndexStoreFactory; import net.thevpc.nuts.NRepository; import net.thevpc.nuts.spi.NSupportLevelContext; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NConfigsExt.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NConfigsExt.java deleted file mode 100755 index 671fea378..000000000 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NConfigsExt.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.thevpc.nuts.runtime.standalone.workspace.config; - -import net.thevpc.nuts.*; - -public interface NConfigsExt extends NConfigs { - - static NConfigsExt of(NConfigs wsc) { - return (NConfigsExt) wsc; - } - - DefaultNWorkspaceConfigModel getModel(); -} diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NHomeLocationsMap.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NHomeLocationsMap.java index 8de5caa42..9fe5ef6a1 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NHomeLocationsMap.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NHomeLocationsMap.java @@ -28,10 +28,10 @@ import java.util.HashMap; import java.util.Map; -import net.thevpc.nuts.env.NHomeLocation; -import net.thevpc.nuts.env.NStoreType; +import net.thevpc.nuts.NHomeLocation; +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.util.NBlankable; -import net.thevpc.nuts.env.NOsFamily; +import net.thevpc.nuts.NOsFamily; /** * diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NIdFilterToNIdPredicate.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NIdFilterToNIdPredicate.java index fe0331ade..70bd136fd 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NIdFilterToNIdPredicate.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NIdFilterToNIdPredicate.java @@ -6,11 +6,9 @@ class NIdFilterToNIdPredicate extends AbstractNPredicate { private final NIdFilter filter; - private final NSession session; - public NIdFilterToNIdPredicate(NIdFilter filter, NSession session) { + public NIdFilterToNIdPredicate(NIdFilter filter) { this.filter = filter; - this.session = session; } @Override diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NStoreLocationsMap.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NStoreLocationsMap.java index a1c01143e..3d572a7b3 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NStoreLocationsMap.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NStoreLocationsMap.java @@ -29,7 +29,7 @@ import java.util.Map; import net.thevpc.nuts.util.NBlankable; -import net.thevpc.nuts.env.NStoreType; +import net.thevpc.nuts.NStoreType; /** * diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NWorkspaceConfigBoot.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NWorkspaceConfigBoot.java index a4cbbbc2b..2ac0246ec 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NWorkspaceConfigBoot.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NWorkspaceConfigBoot.java @@ -26,10 +26,10 @@ package net.thevpc.nuts.runtime.standalone.workspace.config; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NHomeLocation; -import net.thevpc.nuts.env.NOsFamily; -import net.thevpc.nuts.env.NStoreStrategy; -import net.thevpc.nuts.env.NStoreType; +import net.thevpc.nuts.NHomeLocation; +import net.thevpc.nuts.NOsFamily; +import net.thevpc.nuts.NStoreStrategy; +import net.thevpc.nuts.NStoreType; import java.util.*; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NWorkspaceConfigSecurity.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NWorkspaceConfigSecurity.java index a882bee24..c948b2bab 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NWorkspaceConfigSecurity.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NWorkspaceConfigSecurity.java @@ -1,7 +1,7 @@ package net.thevpc.nuts.runtime.standalone.workspace.config; import net.thevpc.nuts.NConfigItem; -import net.thevpc.nuts.env.NUserConfig; +import net.thevpc.nuts.NUserConfig; public class NWorkspaceConfigSecurity extends NConfigItem { private static final long serialVersionUID = 2; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NWorkspaceModel.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NWorkspaceModel.java index f0eac9396..9f70b0288 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NWorkspaceModel.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/NWorkspaceModel.java @@ -1,7 +1,7 @@ package net.thevpc.nuts.runtime.standalone.workspace.config; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NBootOptions; +import net.thevpc.nuts.NBootOptions; import net.thevpc.nuts.runtime.standalone.NWsConfDB; import net.thevpc.nuts.runtime.standalone.event.DefaultNWorkspaceEventModel; import net.thevpc.nuts.runtime.standalone.extension.DefaultNExtensions; @@ -47,7 +47,7 @@ public class NWorkspaceModel { public DefaultNWorkspaceEnvManagerModel envModel; public DefaultNPlatformModel sdkModel; public DefaultNWorkspaceExtensionModel extensionModel; - public DefaultCustomCommandsModel aliasesModel; + public DefaultCustomCommandsModel commandModel; public DefaultImportModel importModel; public String apiDigest; public String installationDigest; @@ -67,7 +67,7 @@ public NWorkspaceModel(NWorkspace workspace, NBootOptions bOption0) { this.confDB=new NWsConfDB(workspace); this.bOption0 = bOption0; // initialized here because they just do nothing... - this.aliasesModel = new DefaultCustomCommandsModel(workspace); + this.commandModel = new DefaultCustomCommandsModel(workspace); this.importModel = new DefaultImportModel(workspace); this.eventsModel = new DefaultNWorkspaceEventModel(workspace); this.repositoryModel = new DefaultNRepositoryModel(workspace); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/AbstractNVersionCompat.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/AbstractNVersionCompat.java index f7c620cc8..25803e034 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/AbstractNVersionCompat.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/AbstractNVersionCompat.java @@ -1,12 +1,15 @@ package net.thevpc.nuts.runtime.standalone.workspace.config.compat; import net.thevpc.nuts.NVersion; +import net.thevpc.nuts.NWorkspace; public abstract class AbstractNVersionCompat implements NVersionCompat { private NVersion apiVersion; private int apiOrdinalVersion; + protected NWorkspace workspace; - public AbstractNVersionCompat(NVersion apiVersion, int apiOrdinalVersion) { + public AbstractNVersionCompat(NWorkspace workspace,NVersion apiVersion, int apiOrdinalVersion) { + this.workspace = workspace; this.apiVersion = apiVersion; this.apiOrdinalVersion = apiOrdinalVersion; } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/CompatUtils.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/CompatUtils.java index abae24e88..7f181ae3d 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/CompatUtils.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/CompatUtils.java @@ -1,7 +1,7 @@ package net.thevpc.nuts.runtime.standalone.workspace.config.compat; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NUserConfig; +import net.thevpc.nuts.NUserConfig; import net.thevpc.nuts.io.NIOException; import net.thevpc.nuts.io.NPath; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v502/NRepositoryConfig502.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v502/NRepositoryConfig502.java index 46adad64b..209bc9d0e 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v502/NRepositoryConfig502.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v502/NRepositoryConfig502.java @@ -29,9 +29,9 @@ import java.util.*; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NStoreStrategy; -import net.thevpc.nuts.env.NStoreType; -import net.thevpc.nuts.env.NUserConfig; +import net.thevpc.nuts.NStoreStrategy; +import net.thevpc.nuts.NStoreType; +import net.thevpc.nuts.NUserConfig; import net.thevpc.nuts.runtime.standalone.workspace.config.NStoreLocationsMap; import net.thevpc.nuts.spi.NRepositoryLocation; import net.thevpc.nuts.util.NBlankable; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v502/NVersionCompat502.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v502/NVersionCompat502.java index c1d7c127b..1f2c870f8 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v502/NVersionCompat502.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v502/NVersionCompat502.java @@ -3,8 +3,9 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NUserConfig; + + +import net.thevpc.nuts.NUserConfig; import net.thevpc.nuts.runtime.standalone.workspace.config.*; import net.thevpc.nuts.runtime.standalone.workspace.config.compat.AbstractNVersionCompat; import net.thevpc.nuts.runtime.standalone.workspace.config.compat.CompatUtils; @@ -12,8 +13,8 @@ import java.util.List; public class NVersionCompat502 extends AbstractNVersionCompat { - public NVersionCompat502(NVersion apiVersion) { - super(apiVersion, 502); + public NVersionCompat502(NWorkspace workspace,NVersion apiVersion) { + super(workspace,apiVersion, 502); } @Override @@ -26,7 +27,7 @@ public NWorkspaceConfigApi parseApiConfig(NId nutsApiId) { NWorkspaceConfigApi cc = new NWorkspaceConfigApi(); cc.setApiVersion(getApiVersion()); NWorkspaceConfigBoot502 c = parseConfig502(CompatUtils.readAllBytes( - NLocations.of().getWorkspaceLocation().toPath().get() + NWorkspace.get().getWorkspaceLocation().toPath().get() .resolve(NConstants.Files.WORKSPACE_CONFIG_FILE_NAME))); if (c != null) { cc.setApiVersion(c.getBootApiVersion()); @@ -42,7 +43,7 @@ public NWorkspaceConfigRuntime parseRuntimeConfig() { NWorkspaceConfigRuntime cc = new NWorkspaceConfigRuntime(); // cc.setApiVersion(getApiVersion()); NWorkspaceConfigBoot502 c = parseConfig502(CompatUtils.readAllBytes( - NLocations.of().getWorkspaceLocation().toPath().get() + NWorkspace.get().getWorkspaceLocation().toPath().get() .resolve(NConstants.Files.WORKSPACE_CONFIG_FILE_NAME))); if (c != null) { cc.setDependencies(c.getBootRuntimeDependencies()); @@ -55,7 +56,7 @@ public NWorkspaceConfigRuntime parseRuntimeConfig() { public NWorkspaceConfigSecurity parseSecurityConfig(NId nutsApiId) { NWorkspaceConfigSecurity cc = new NWorkspaceConfigSecurity(); NWorkspaceConfigBoot502 c = parseConfig502(CompatUtils.readAllBytes( - NLocations.of().getWorkspaceLocation().toPath().get() + NWorkspace.get().getWorkspaceLocation().toPath().get() .resolve(NConstants.Files.WORKSPACE_CONFIG_FILE_NAME))); if (c != null) { cc.setSecure(c.isSecure()); @@ -70,7 +71,7 @@ public NWorkspaceConfigSecurity parseSecurityConfig(NId nutsApiId) { public NWorkspaceConfigMain parseMainConfig(NId nutsApiId) { NWorkspaceConfigMain cc = new NWorkspaceConfigMain(); NWorkspaceConfigBoot502 c = parseConfig502(CompatUtils.readAllBytes( - NLocations.of().getWorkspaceLocation().toPath().get() + NWorkspace.get().getWorkspaceLocation().toPath().get() .resolve(NConstants.Files.WORKSPACE_CONFIG_FILE_NAME))); if (c != null) { c.setRepositories(CompatUtils.copyNutsRepositoryRefList(c.getRepositories())); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v502/NWorkspaceConfigBoot502.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v502/NWorkspaceConfigBoot502.java index f5d02d244..f079fd2d4 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v502/NWorkspaceConfigBoot502.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v502/NWorkspaceConfigBoot502.java @@ -30,10 +30,10 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NPlatformLocation; -import net.thevpc.nuts.env.NStoreStrategy; -import net.thevpc.nuts.env.NUserConfig; +import net.thevpc.nuts.NStoreStrategy; +import net.thevpc.nuts.NUserConfig; import net.thevpc.nuts.runtime.standalone.workspace.config.NWorkspaceConfigBoot; -import net.thevpc.nuts.env.NOsFamily; +import net.thevpc.nuts.NOsFamily; /** * diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v506/NRepositoryConfig506.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v506/NRepositoryConfig506.java index 49cd6cffc..a345d0c9b 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v506/NRepositoryConfig506.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v506/NRepositoryConfig506.java @@ -27,8 +27,8 @@ import net.thevpc.nuts.NConfigItem; import net.thevpc.nuts.NRepositoryRef; -import net.thevpc.nuts.env.NStoreStrategy; -import net.thevpc.nuts.env.NUserConfig; +import net.thevpc.nuts.NStoreStrategy; +import net.thevpc.nuts.NUserConfig; import java.util.Arrays; import java.util.List; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v506/NVersionCompat506.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v506/NVersionCompat506.java index 9fb0ba809..437f4e96f 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v506/NVersionCompat506.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v506/NVersionCompat506.java @@ -3,8 +3,9 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NUserConfig; + + +import net.thevpc.nuts.NUserConfig; import net.thevpc.nuts.runtime.standalone.workspace.config.*; import net.thevpc.nuts.runtime.standalone.workspace.config.compat.AbstractNVersionCompat; import net.thevpc.nuts.runtime.standalone.workspace.config.compat.CompatUtils; @@ -12,8 +13,8 @@ import java.util.List; public class NVersionCompat506 extends AbstractNVersionCompat { - public NVersionCompat506(NVersion apiVersion) { - super(apiVersion, 506); + public NVersionCompat506(NWorkspace workspace,NVersion apiVersion) { + super(workspace,apiVersion, 506); } @Override @@ -26,7 +27,7 @@ public NWorkspaceConfigApi parseApiConfig(NId nutsApiId) { NWorkspaceConfigApi cc = new NWorkspaceConfigApi(); cc.setApiVersion(getApiVersion()); NWorkspaceConfigBoot506 c = parseConfig506(CompatUtils.readAllBytes( - NLocations.of().getWorkspaceLocation().toPath().get() + NWorkspace.get().getWorkspaceLocation().toPath().get() .resolve(NConstants.Files.WORKSPACE_CONFIG_FILE_NAME))); if (c != null) { // cc.setConfigVersion(???); @@ -44,7 +45,7 @@ public NWorkspaceConfigRuntime parseRuntimeConfig() { NWorkspaceConfigRuntime cc = new NWorkspaceConfigRuntime(); // cc.setApiVersion(getApiVersion()); NWorkspaceConfigBoot506 c = parseConfig506(CompatUtils.readAllBytes( - NLocations.of().getWorkspaceLocation().toPath().get() + NWorkspace.get().getWorkspaceLocation().toPath().get() .resolve(NConstants.Files.WORKSPACE_CONFIG_FILE_NAME))); if (c != null) { // cc.setConfigVersion(???); @@ -62,7 +63,7 @@ public NWorkspaceConfigRuntime parseRuntimeConfig() { public NWorkspaceConfigSecurity parseSecurityConfig(NId nutsApiId) { NWorkspaceConfigSecurity cc = new NWorkspaceConfigSecurity(); NWorkspaceConfigBoot506 c = parseConfig506(CompatUtils.readAllBytes( - NLocations.of().getWorkspaceLocation().toPath().get() + NWorkspace.get().getWorkspaceLocation().toPath().get() .resolve(NConstants.Files.WORKSPACE_CONFIG_FILE_NAME))); if (c != null) { // cc.setConfigVersion(???); @@ -78,7 +79,7 @@ public NWorkspaceConfigSecurity parseSecurityConfig(NId nutsApiId) { public NWorkspaceConfigMain parseMainConfig(NId nutsApiId) { NWorkspaceConfigMain cc = new NWorkspaceConfigMain(); NWorkspaceConfigBoot506 c = parseConfig506(CompatUtils.readAllBytes( - NLocations.of().getWorkspaceLocation().toPath().get() + NWorkspace.get().getWorkspaceLocation().toPath().get() .resolve(NConstants.Files.WORKSPACE_CONFIG_FILE_NAME))); if (c != null) { c.setRepositories(CompatUtils.copyNutsRepositoryRefList(c.getRepositories())); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v506/NWorkspaceConfigBoot506.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v506/NWorkspaceConfigBoot506.java index 05afe0eac..18ea0d90e 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v506/NWorkspaceConfigBoot506.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v506/NWorkspaceConfigBoot506.java @@ -26,7 +26,6 @@ package net.thevpc.nuts.runtime.standalone.workspace.config.compat.v506; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.*; import net.thevpc.nuts.runtime.standalone.workspace.config.NWorkspaceConfigBoot; import java.util.*; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v507/NRepositoryConfig507.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v507/NRepositoryConfig507.java index ff48d245e..4411cfb68 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v507/NRepositoryConfig507.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v507/NRepositoryConfig507.java @@ -26,9 +26,9 @@ package net.thevpc.nuts.runtime.standalone.workspace.config.compat.v507; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NStoreStrategy; -import net.thevpc.nuts.env.NStoreType; -import net.thevpc.nuts.env.NUserConfig; +import net.thevpc.nuts.NStoreStrategy; +import net.thevpc.nuts.NStoreType; +import net.thevpc.nuts.NUserConfig; import java.util.List; import java.util.Map; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v507/NVersionCompat507.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v507/NVersionCompat507.java index b27eeb4c4..be89334bf 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v507/NVersionCompat507.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v507/NVersionCompat507.java @@ -3,8 +3,9 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; + + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.workspace.config.*; import net.thevpc.nuts.runtime.standalone.util.CoreNConstants; @@ -15,8 +16,8 @@ public class NVersionCompat507 extends AbstractNVersionCompat { public static final NVersion CONFIG_VERSION_507 = NVersion.of("5.0.7").get(); - public NVersionCompat507(NVersion apiVersion) { - super(apiVersion, 507); + public NVersionCompat507(NWorkspace workspace,NVersion apiVersion) { + super(workspace,apiVersion, 507); } @Override @@ -26,7 +27,7 @@ public NWorkspaceConfigBoot parseConfig(byte[] bytes) { @Override public NWorkspaceConfigApi parseApiConfig(NId nutsApiId) { - NPath path = NLocations.of().getStoreLocation(nutsApiId, NStoreType.CONF) + NPath path = NWorkspace.get().getStoreLocation(nutsApiId, NStoreType.CONF) .resolve(NConstants.Files.API_BOOT_CONFIG_FILE_NAME); byte[] bytes = CompatUtils.readAllBytes(path); NWorkspaceConfigApi c = bytes==null?null: NElements.of() @@ -41,7 +42,7 @@ public NWorkspaceConfigApi parseApiConfig(NId nutsApiId) { @Override public NWorkspaceConfigRuntime parseRuntimeConfig() { - NPath path = NLocations.of().getStoreLocation(NWorkspace.get().getRuntimeId(), NStoreType.CONF) + NPath path = NWorkspace.get().getStoreLocation(workspace.getRuntimeId(), NStoreType.CONF) .resolve(NConstants.Files.RUNTIME_BOOT_CONFIG_FILE_NAME); byte[] bytes = CompatUtils.readAllBytes(path); NWorkspaceConfigRuntime c = bytes==null?null: NElements.of() @@ -51,7 +52,7 @@ public NWorkspaceConfigRuntime parseRuntimeConfig() { @Override public NWorkspaceConfigSecurity parseSecurityConfig(NId nutsApiId) { - NPath path = NLocations.of().getStoreLocation(nutsApiId + NPath path = NWorkspace.get().getStoreLocation(nutsApiId , NStoreType.CONF) .resolve(CoreNConstants.Files.WORKSPACE_SECURITY_CONFIG_FILE_NAME); byte[] bytes = CompatUtils.readAllBytes(path); @@ -62,7 +63,7 @@ public NWorkspaceConfigSecurity parseSecurityConfig(NId nutsApiId) { @Override public NWorkspaceConfigMain parseMainConfig(NId nutsApiId) { - NPath path = NLocations.of().getStoreLocation( + NPath path = NWorkspace.get().getStoreLocation( nutsApiId, NStoreType.CONF) .resolve(CoreNConstants.Files.WORKSPACE_MAIN_CONFIG_FILE_NAME); byte[] bytes = CompatUtils.readAllBytes(path); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v803/NRepositoryConfig803.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v803/NRepositoryConfig803.java index 82cc49fb2..4c90b6303 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v803/NRepositoryConfig803.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v803/NRepositoryConfig803.java @@ -26,9 +26,9 @@ package net.thevpc.nuts.runtime.standalone.workspace.config.compat.v803; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NStoreStrategy; -import net.thevpc.nuts.env.NStoreType; -import net.thevpc.nuts.env.NUserConfig; +import net.thevpc.nuts.NStoreStrategy; +import net.thevpc.nuts.NStoreType; +import net.thevpc.nuts.NUserConfig; import java.util.List; import java.util.Map; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v803/NVersionCompat803.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v803/NVersionCompat803.java index a9eafdae6..4b687365c 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v803/NVersionCompat803.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/config/compat/v803/NVersionCompat803.java @@ -3,8 +3,9 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; + + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.util.CoreNConstants; import net.thevpc.nuts.runtime.standalone.workspace.config.*; @@ -12,8 +13,8 @@ import net.thevpc.nuts.runtime.standalone.workspace.config.compat.CompatUtils; public class NVersionCompat803 extends AbstractNVersionCompat { - public NVersionCompat803(NVersion apiVersion) { - super(apiVersion, 507); + public NVersionCompat803(NWorkspace workspace,NVersion apiVersion) { + super(workspace,apiVersion, 507); } @Override @@ -23,7 +24,7 @@ public NWorkspaceConfigBoot parseConfig(byte[] bytes) { @Override public NWorkspaceConfigApi parseApiConfig(NId nutsApiId) { - NPath path = NLocations.of().getStoreLocation(nutsApiId, NStoreType.CONF) + NPath path = NWorkspace.get().getStoreLocation(nutsApiId, NStoreType.CONF) .resolve(NConstants.Files.API_BOOT_CONFIG_FILE_NAME); byte[] bytes = CompatUtils.readAllBytes(path); NWorkspaceConfigApi c = bytes==null?null: NElements.of() @@ -36,7 +37,7 @@ public NWorkspaceConfigApi parseApiConfig(NId nutsApiId) { @Override public NWorkspaceConfigRuntime parseRuntimeConfig() { - NPath path = NLocations.of().getStoreLocation(NWorkspace.get().getRuntimeId(), NStoreType.CONF) + NPath path = NWorkspace.get().getStoreLocation(workspace.getRuntimeId(), NStoreType.CONF) .resolve(NConstants.Files.RUNTIME_BOOT_CONFIG_FILE_NAME); byte[] bytes = CompatUtils.readAllBytes(path); NWorkspaceConfigRuntime c = bytes==null?null: NElements.of() @@ -46,7 +47,7 @@ public NWorkspaceConfigRuntime parseRuntimeConfig() { @Override public NWorkspaceConfigSecurity parseSecurityConfig(NId nutsApiId) { - NPath path = NLocations.of().getStoreLocation(nutsApiId + NPath path = NWorkspace.get().getStoreLocation(nutsApiId , NStoreType.CONF) .resolve(CoreNConstants.Files.WORKSPACE_SECURITY_CONFIG_FILE_NAME); byte[] bytes = CompatUtils.readAllBytes(path); @@ -57,7 +58,7 @@ public NWorkspaceConfigSecurity parseSecurityConfig(NId nutsApiId) { @Override public NWorkspaceConfigMain parseMainConfig(NId nutsApiId) { - NPath path = NLocations.of().getStoreLocation(nutsApiId + NPath path = NWorkspace.get().getStoreLocation(nutsApiId , NStoreType.CONF) .resolve(CoreNConstants.Files.WORKSPACE_MAIN_CONFIG_FILE_NAME); byte[] bytes = CompatUtils.readAllBytes(path); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/list/DefaultNWorkspaceList.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/list/DefaultNWorkspaceList.java index 4484bdd1b..d4f787d8d 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/list/DefaultNWorkspaceList.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/workspace/list/DefaultNWorkspaceList.java @@ -3,8 +3,9 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; + + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.spi.NSupportLevelContext; import net.thevpc.nuts.util.NBlankable; @@ -40,7 +41,7 @@ public DefaultNWorkspaceList() { new NWorkspaceLocation() .setUuid(ws.getUuid()) .setName(NConstants.Names.DEFAULT_WORKSPACE_NAME) - .setLocation(NLocations.of().getWorkspaceLocation().toString()) + .setLocation(NWorkspace.get().getWorkspaceLocation().toString()) ); this.save(); } @@ -59,7 +60,7 @@ public String getName() { } private NPath getConfigFile() { - return NLocations.of() + return NWorkspace.get() .getStoreLocation(NId.ofClass(DefaultNWorkspaceList.class).get(), NStoreType.CONF) .resolve(name + "-nuts-workspace-list.json"); @@ -89,11 +90,11 @@ public DefaultNWorkspaceList setConfig(NWorkspaceListConfig config) { @Override public NWorkspace addWorkspace(String path) { NWorkspace ss = this.createWorkspace(path); - NLocations locations = NLocations.of(); + NWorkspace workspace = NWorkspace.get(); NWorkspaceLocation workspaceLocation = new NWorkspaceLocation() .setUuid(ss.getUuid()) - .setName(locations.getWorkspaceLocation().getName()) - .setLocation(locations.getWorkspaceLocation().toString()); + .setName(workspace.getWorkspaceLocation().getName()) + .setLocation(workspace.getWorkspaceLocation().toString()); workspaces.put(ss.getUuid(), workspaceLocation); this.save(); return ss; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/compress/NUncompressZip.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/compress/NUncompressZip.java index 59f3c3227..a4a5f1a55 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/compress/NUncompressZip.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/compress/NUncompressZip.java @@ -28,7 +28,6 @@ public NUncompressZip(NWorkspace workspace) { } public void uncompressPackage(NUncompress uncompress, NInputSource source) { - NSession session = workspace.currentSession(); NOutputTarget target = uncompress.getTarget(); try { NPath _target = asValidTargetPath(target); @@ -98,7 +97,6 @@ public void uncompressPackage(NUncompress uncompress, NInputSource source) { } public void visitPackage(NUncompress uncompress, NInputSource source, NUncompressVisitor visitor) { - NSession session = workspace.currentSession(); try { //get the zip file content InputStream _in = source.getInputStream(); diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/contenttype/DefaultNContentTypes.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/contenttype/DefaultNContentTypes.java index fde9f1eea..1f04a5f15 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/contenttype/DefaultNContentTypes.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/contenttype/DefaultNContentTypes.java @@ -1,186 +1,186 @@ -package net.thevpc.nuts.runtime.standalone.xtra.contenttype; - -import net.thevpc.nuts.*; -import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.ext.NExtensions; -import net.thevpc.nuts.io.NContentTypes; -import net.thevpc.nuts.io.NPath; -import net.thevpc.nuts.spi.NCharsetResolver; -import net.thevpc.nuts.spi.NContentTypeResolver; -import net.thevpc.nuts.spi.NSupportLevelContext; -import net.thevpc.nuts.util.NBlankable; -import net.thevpc.nuts.util.NIOUtils; - -import java.io.File; -import java.io.InputStream; -import java.net.URL; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.stream.Collectors; - -public class DefaultNContentTypes implements NContentTypes { - private final NSession session; - private NWorkspace ws; - - public DefaultNContentTypes(NSession session) { - this.session = session; - this.ws = session.getWorkspace(); - } - - @Override - public String probeContentType(Path path) { - return probeContentType(path == null ? null : NPath.of(path)); - } - - @Override - public String probeContentType(File path) { - return probeContentType(path == null ? null : NPath.of(path)); - } - - @Override - public String probeContentType(URL path) { - return probeContentType(path == null ? null : NPath.of(path)); - } - - @Override - public String probeContentType(NPath path) { - List allSupported = NExtensions.of() - .createComponents(NContentTypeResolver.class, path); - NCallableSupport best = null; - for (NContentTypeResolver r : allSupported) { - NCallableSupport s = r.probeContentType(path); - if (s != null && s.isValid()) { - if (best == null || s.getSupportLevel() > best.getSupportLevel()) { - best = s; - } - } - } - if (best == null) { - return null; - } - return best.call(); - } - - @Override - public List findExtensionsByContentType(String contentType) { - List allSupported = NExtensions.of() - .createComponents(NContentTypeResolver.class, null); - LinkedHashSet all = new LinkedHashSet<>(); - for (NContentTypeResolver r : allSupported) { - List s = r.findExtensionsByContentType(contentType); - if (s != null) { - all.addAll(s.stream().filter(x->!NBlankable.isBlank(x)).collect(Collectors.toList())); - } - } - return new ArrayList<>(all); - } - - @Override - public List findContentTypesByExtension(String extension) { - List allSupported = NExtensions.of() - .createComponents(NContentTypeResolver.class, null); - LinkedHashSet all = new LinkedHashSet<>(); - for (NContentTypeResolver r : allSupported) { - List s = r.findContentTypesByExtension(extension); - if (s != null) { - all.addAll(s.stream().filter(NBlankable::isBlank).collect(Collectors.toList())); - } - } - return new ArrayList<>(all); - } - - @Override - public String probeContentType(InputStream stream) { - byte[] buffer = NIOUtils.readBestEffort(4096, stream); - return probeContentType(buffer); - } - - @Override - public String probeContentType(byte[] bytes) { - List allSupported = NExtensions.of() - .createComponents(NContentTypeResolver.class, bytes); - NCallableSupport best = null; - for (NContentTypeResolver r : allSupported) { - NCallableSupport s = r.probeContentType(bytes); - if (s != null && s.isValid()) { - if (best == null || s.getSupportLevel() > best.getSupportLevel()) { - best = s; - } - } - } - if (best == null) { - return null; - } - return best.call(); - } - - @Override - public String probeCharset(URL path) { - return probeCharset(path == null ? null : NPath.of(path)); - } - - @Override - public String probeCharset(File path) { - return probeCharset(path == null ? null : NPath.of(path)); - } - - @Override - public String probeCharset(Path path) { - return probeCharset(path == null ? null : NPath.of(path)); - } - - @Override - public String probeCharset(NPath path) { - List allSupported = NExtensions.of() - .createComponents(NCharsetResolver.class, path); - NCallableSupport best = null; - for (NCharsetResolver r : allSupported) { - NCallableSupport s = r.probeCharset(path); - if (s != null && s.isValid()) { - if (best == null || s.getSupportLevel() > best.getSupportLevel()) { - best = s; - } - } - } - if (best == null) { - return null; - } - return best.call(); - } - - @Override - public String probeCharset(InputStream stream) { - byte[] buffer = NIOUtils.readBestEffort(4096*10, stream); - return probeCharset(buffer); - } - - @Override - public String probeCharset(byte[] bytes) { - List allSupported = NExtensions.of() - .createComponents(NCharsetResolver.class, bytes); - NCallableSupport best = null; - for (NCharsetResolver r : allSupported) { - NCallableSupport s = r.probeCharset(bytes); - if (s != null && s.isValid()) { - if (best == null || s.getSupportLevel() > best.getSupportLevel()) { - best = s; - } - } - } - if (best == null) { - return null; - } - return best.call(); - } - - @Override - public int getSupportLevel(NSupportLevelContext context) { - return NConstants.Support.DEFAULT_SUPPORT; - } -// -// private static class Shared { -// -// } -} +//package net.thevpc.nuts.runtime.standalone.xtra.contenttype; +// +//import net.thevpc.nuts.*; +//import net.thevpc.nuts.NConstants; +//import net.thevpc.nuts.ext.NExtensions; +//import net.thevpc.nuts.io.NContentTypes; +//import net.thevpc.nuts.io.NPath; +//import net.thevpc.nuts.spi.NCharsetResolver; +//import net.thevpc.nuts.spi.NContentTypeResolver; +//import net.thevpc.nuts.spi.NSupportLevelContext; +//import net.thevpc.nuts.util.NBlankable; +//import net.thevpc.nuts.util.NIOUtils; +// +//import java.io.File; +//import java.io.InputStream; +//import java.net.URL; +//import java.nio.file.Path; +//import java.util.ArrayList; +//import java.util.LinkedHashSet; +//import java.util.List; +//import java.util.stream.Collectors; +// +//public class DefaultNContentTypes implements NContentTypes { +// private final NSession session; +// private NWorkspace ws; +// +// public DefaultNContentTypes(NSession session) { +// this.session = session; +// this.ws = session.getWorkspace(); +// } +// +// @Override +// public String probeContentType(Path path) { +// return probeContentType(path == null ? null : NPath.of(path)); +// } +// +// @Override +// public String probeContentType(File path) { +// return probeContentType(path == null ? null : NPath.of(path)); +// } +// +// @Override +// public String probeContentType(URL path) { +// return probeContentType(path == null ? null : NPath.of(path)); +// } +// +// @Override +// public String probeContentType(NPath path) { +// List allSupported = NExtensions.of() +// .createComponents(NContentTypeResolver.class, path); +// NCallableSupport best = null; +// for (NContentTypeResolver r : allSupported) { +// NCallableSupport s = r.probeContentType(path); +// if (s != null && s.isValid()) { +// if (best == null || s.getSupportLevel() > best.getSupportLevel()) { +// best = s; +// } +// } +// } +// if (best == null) { +// return null; +// } +// return best.call(); +// } +// +// @Override +// public List findExtensionsByContentType(String contentType) { +// List allSupported = NExtensions.of() +// .createComponents(NContentTypeResolver.class, null); +// LinkedHashSet all = new LinkedHashSet<>(); +// for (NContentTypeResolver r : allSupported) { +// List s = r.findExtensionsByContentType(contentType); +// if (s != null) { +// all.addAll(s.stream().filter(x->!NBlankable.isBlank(x)).collect(Collectors.toList())); +// } +// } +// return new ArrayList<>(all); +// } +// +// @Override +// public List findContentTypesByExtension(String extension) { +// List allSupported = NExtensions.of() +// .createComponents(NContentTypeResolver.class, null); +// LinkedHashSet all = new LinkedHashSet<>(); +// for (NContentTypeResolver r : allSupported) { +// List s = r.findContentTypesByExtension(extension); +// if (s != null) { +// all.addAll(s.stream().filter(NBlankable::isBlank).collect(Collectors.toList())); +// } +// } +// return new ArrayList<>(all); +// } +// +// @Override +// public String probeContentType(InputStream stream) { +// byte[] buffer = NIOUtils.readBestEffort(4096, stream); +// return probeContentType(buffer); +// } +// +// @Override +// public String probeContentType(byte[] bytes) { +// List allSupported = NExtensions.of() +// .createComponents(NContentTypeResolver.class, bytes); +// NCallableSupport best = null; +// for (NContentTypeResolver r : allSupported) { +// NCallableSupport s = r.probeContentType(bytes); +// if (s != null && s.isValid()) { +// if (best == null || s.getSupportLevel() > best.getSupportLevel()) { +// best = s; +// } +// } +// } +// if (best == null) { +// return null; +// } +// return best.call(); +// } +// +// @Override +// public String probeCharset(URL path) { +// return probeCharset(path == null ? null : NPath.of(path)); +// } +// +// @Override +// public String probeCharset(File path) { +// return probeCharset(path == null ? null : NPath.of(path)); +// } +// +// @Override +// public String probeCharset(Path path) { +// return probeCharset(path == null ? null : NPath.of(path)); +// } +// +// @Override +// public String probeCharset(NPath path) { +// List allSupported = NExtensions.of() +// .createComponents(NCharsetResolver.class, path); +// NCallableSupport best = null; +// for (NCharsetResolver r : allSupported) { +// NCallableSupport s = r.probeCharset(path); +// if (s != null && s.isValid()) { +// if (best == null || s.getSupportLevel() > best.getSupportLevel()) { +// best = s; +// } +// } +// } +// if (best == null) { +// return null; +// } +// return best.call(); +// } +// +// @Override +// public String probeCharset(InputStream stream) { +// byte[] buffer = NIOUtils.readBestEffort(4096*10, stream); +// return probeCharset(buffer); +// } +// +// @Override +// public String probeCharset(byte[] bytes) { +// List allSupported = NExtensions.of() +// .createComponents(NCharsetResolver.class, bytes); +// NCallableSupport best = null; +// for (NCharsetResolver r : allSupported) { +// NCallableSupport s = r.probeCharset(bytes); +// if (s != null && s.isValid()) { +// if (best == null || s.getSupportLevel() > best.getSupportLevel()) { +// best = s; +// } +// } +// } +// if (best == null) { +// return null; +// } +// return best.call(); +// } +// +// @Override +// public int getSupportLevel(NSupportLevelContext context) { +// return NConstants.Support.DEFAULT_SUPPORT; +// } +//// +//// private static class Shared { +//// +//// } +//} diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/cp/DefaultNCp.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/cp/DefaultNCp.java index 3116584f3..4688c41bf 100755 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/cp/DefaultNCp.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/cp/DefaultNCp.java @@ -346,7 +346,6 @@ public String getStringResult() { @Override public NCp run() { - NSession session = workspace.currentSession(); NAssert.requireNonBlank(source, "source"); NAssert.requireNonBlank(target, "target"); @@ -499,7 +498,6 @@ public FileVisitResult postVisitDirectory(Path dir, IOException exc) { } private void copyFolderWithMonitor(Path srcBase, Path targetBase, CopyData f) { - NSession session = workspace.currentSession(); long start = System.nanoTime(); Object origin = getSourceOrigin(); NProgressListener m = NProgressUtils.createProgressMonitor( @@ -512,7 +510,6 @@ private void copyFolderWithMonitor(Path srcBase, Path targetBase, CopyData f) { NMsg.ofNtf(srcBaseMessage) , f.files + f.folders)); try { - NSession finalSession = session; Files.walkFileTree(srcBase, new FileVisitor() { @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { @@ -636,7 +633,6 @@ private long transferTo(InputStream in, OutputStream out) throws IOException { } private void copyFolderNoMonitor(Path srcBase, Path targetBase, CopyData f) { - NSession session = workspace.currentSession(); try { Files.walkFileTree(srcBase, new FileVisitor() { @Override @@ -673,7 +669,6 @@ public FileVisitResult postVisitDirectory(Path dir, IOException exc) { } private void copyStream() { - NSession session = workspace.currentSession(); NAssert.requireNonBlank(source, "source"); NAssert.requireNonBlank(target, "target"); boolean safe = options.contains(NPathOption.SAFE); @@ -887,7 +882,6 @@ private void _validate(Path temp) { } catch (NCpValidatorException ex) { throw ex; } catch (Exception ex) { - NSession session = workspace.currentSession(); throw new NCpValidatorException(NMsg.ofC("validate file %s failed", temp), ex); } } @@ -900,7 +894,6 @@ private void _validate(byte[] temp) { } catch (NCpValidatorException ex) { throw ex; } catch (Exception ex) { - NSession session = workspace.currentSession(); throw new NCpValidatorException(NMsg.ofPlain("validate file failed"), ex); } } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/expr/NExprDeclarationsBase.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/expr/NExprDeclarationsBase.java index a957a9e4b..044127ad2 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/expr/NExprDeclarationsBase.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/expr/NExprDeclarationsBase.java @@ -31,7 +31,6 @@ public NOptional evalOperator(String opName, NExprOpType type, NExprNode } public NOptional evalSetVar(String varName, Object value) { - NSession session = workspace.currentSession(); return NOptional.of(getVar(varName).get().set(value, this)); } @@ -40,7 +39,6 @@ public NOptional evalGetVar(String varName) { if(!var.isPresent()){ return var.map(x->null); } - NSession session = workspace.currentSession(); return NOptional.ofNullable(var.get().get(this)); } diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/hashname/DefaultNHashName.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/hashname/DefaultNHashName.java index ac578edc2..846aa3f7d 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/hashname/DefaultNHashName.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/hashname/DefaultNHashName.java @@ -7,7 +7,7 @@ import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.runtime.standalone.util.CoreNUtils; import net.thevpc.nuts.spi.NSupportLevelContext; -import net.thevpc.nuts.env.NPlatformHome; +import net.thevpc.nuts.NPlatformHome; import java.nio.file.Path; import java.nio.file.Paths; diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/ps/DefaultNPs.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/ps/DefaultNPs.java index de1eb7e97..9a5198dfd 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/ps/DefaultNPs.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/ps/DefaultNPs.java @@ -2,12 +2,12 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.NConstants; -import net.thevpc.nuts.env.NEnvs; + import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.elem.NEDesc; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NOsFamily; -import net.thevpc.nuts.env.NPlatformFamily; +import net.thevpc.nuts.NOsFamily; +import net.thevpc.nuts.NPlatformFamily; import net.thevpc.nuts.io.NPsInfo; import net.thevpc.nuts.io.NPs; import net.thevpc.nuts.util.NIteratorBuilder; @@ -25,11 +25,11 @@ public class DefaultNPs implements NPs { private String processType; - private NWorkspace ws; + private NWorkspace workspace; private boolean failFast; - public DefaultNPs(NWorkspace ws) { - this.ws = ws; + public DefaultNPs(NWorkspace workspace) { + this.workspace = workspace; } @Override @@ -50,7 +50,7 @@ public NPs setFailFast(boolean failFast) { @Override public boolean isSupportedKillProcess() { - NOsFamily f = NEnvs.of().getOsFamily(); + NOsFamily f = NWorkspace.get().getOsFamily(); return f == NOsFamily.LINUX || f == NOsFamily.MACOS || f == NOsFamily.UNIX; } @@ -95,9 +95,9 @@ private static String getJpsJavaHome2(String version) { if (v != null) { return v; } - NPlatforms platforms = NPlatforms.of(); + NWorkspace workspace = NWorkspace.get(); NVersionFilter nvf = NBlankable.isBlank(version) ? null : NVersion.of(version).get().filter(); - NPlatformLocation[] availableJava = platforms.findPlatforms(NPlatformFamily.JAVA, + NPlatformLocation[] availableJava = workspace.findPlatforms(NPlatformFamily.JAVA, java -> "jdk".equals(java.getPackaging()) && (nvf == null || nvf.acceptVersion(NVersion.of(java.getVersion()).get())) ).toArray(NPlatformLocation[]::new); for (NPlatformLocation java : availableJava) { @@ -143,7 +143,7 @@ public NStream getResultList() { } private NStream getResultListJava(String version) { - NEnvs envs = NEnvs.of(); + NWorkspace workspace = NWorkspace.get(); NIterator it = NIteratorBuilder.ofSupplier(() -> { String cmd = "jps"; NExecCmd b = null; @@ -174,7 +174,7 @@ private NStream getResultListJava(String version) { String pid = line.substring(0, s1).trim(); String cls = line.substring(s1 + 1, s2 < 0 ? line.length() : s2).trim(); String cmdLineString = s2 >= 0 ? line.substring(s2 + 1).trim() : ""; - String[] parsedCmdLine = betterArgs(envs, pid); + String[] parsedCmdLine = betterArgs(pid); if (parsedCmdLine == null) { parsedCmdLine= NCmdLine.of(cmdLineString,null).toStringArray(); } @@ -185,8 +185,8 @@ private NStream getResultListJava(String version) { return new NStreamFromNIterator<>("process-" + getType(), it); } - private String[] betterArgs(NEnvs envs, String pid) { - switch (envs.getOsFamily()) { + private String[] betterArgs(String pid) { + switch (workspace.getOsFamily()) { case LINUX: case UNIX: case MACOS: { diff --git a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/throwables/DefaultNApplicationExceptionHandler.java b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/throwables/DefaultNApplicationExceptionHandler.java index 9cfe299f8..0f19f2e6a 100644 --- a/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/throwables/DefaultNApplicationExceptionHandler.java +++ b/core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/xtra/throwables/DefaultNApplicationExceptionHandler.java @@ -4,8 +4,8 @@ import net.thevpc.nuts.NConstants; import net.thevpc.nuts.elem.NArrayElementBuilder; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NBootManager; -import net.thevpc.nuts.env.NEnvs; + + import net.thevpc.nuts.format.NContentType; import net.thevpc.nuts.io.NIO; import net.thevpc.nuts.io.NPrintStream; @@ -37,8 +37,8 @@ public DefaultNApplicationExceptionHandler() { public int processThrowable(String[] args, Throwable throwable) { NSession session = NSession.get(); NWorkspaceOptionsBuilder bo = null; - bo = NBootManager.of().getBootOptions().toWorkspaceOptions().builder(); - if (!NEnvs.of().isGraphicalDesktopEnvironment()) { + bo = NWorkspace.get().getBootOptions().toWorkspaceOptions().builder(); + if (!NWorkspace.get().isGraphicalDesktopEnvironment()) { bo.setGui(false); } diff --git a/core/nuts-runtime/src/main/resources/META-INF/services/net.thevpc.nuts.spi.NComponent b/core/nuts-runtime/src/main/resources/META-INF/services/net.thevpc.nuts.spi.NComponent index 20a4451db..13ccc27ef 100755 --- a/core/nuts-runtime/src/main/resources/META-INF/services/net.thevpc.nuts.spi.NComponent +++ b/core/nuts-runtime/src/main/resources/META-INF/services/net.thevpc.nuts.spi.NComponent @@ -28,7 +28,6 @@ net.thevpc.nuts.runtime.standalone.executor.system.ProcessExecutorComponent net.thevpc.nuts.runtime.standalone.repository.impl.maven.MavenRepositoryFactoryComponent net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNIndexStoreFactory -net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNPlatforms net.thevpc.nuts.runtime.standalone.security.DefaultNAuthenticationAgent net.thevpc.nuts.runtime.standalone.log.DefaultNLogs net.thevpc.nuts.runtime.standalone.workspace.list.DefaultNWorkspaceList @@ -48,15 +47,7 @@ net.thevpc.nuts.runtime.standalone.installer.svc.DefaultInstallSvcCommand net.thevpc.nuts.runtime.standalone.workspace.cmd.uninstall.DefaultNUninstallCmd net.thevpc.nuts.runtime.standalone.workspace.cmd.update.DefaultNUpdateCmd net.thevpc.nuts.runtime.standalone.workspace.cmd.settings.updatestats.DefaultNUpdateStatsCmd -net.thevpc.nuts.runtime.standalone.boot.DefaultNBootManager -net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNEnvs -net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNLocations -net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNImports -net.thevpc.nuts.runtime.standalone.workspace.config.DefaultCommands -net.thevpc.nuts.runtime.standalone.event.DefaultNEvents net.thevpc.nuts.runtime.standalone.security.DefaultNWorkspaceSecurityManager -net.thevpc.nuts.runtime.standalone.repository.config.DefaultNRepositories -net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNConfigs net.thevpc.nuts.runtime.standalone.extension.DefaultNExtensions net.thevpc.nuts.runtime.standalone.web.DefaultNWebCli @@ -108,8 +99,6 @@ net.thevpc.nuts.runtime.standalone.text.highlighter.PlainCodeHighlighter net.thevpc.nuts.runtime.standalone.xtra.contenttype.DefaultNContentTypeResolver -net.thevpc.nuts.runtime.standalone.xtra.contenttype.DefaultNContentTypes -net.thevpc.nuts.runtime.standalone.io.path.DefaultNPaths net.thevpc.nuts.runtime.standalone.io.inputstream.DefaultNIO net.thevpc.nuts.runtime.standalone.io.inputstream.DefaultNIORPI net.thevpc.nuts.runtime.standalone.xtra.execentries.DefaultNLibPaths diff --git a/extensions/next-ssh/src/main/java/net/thevpc/nuts/ext/ssh/RemoteConnexionStringInfo.java b/extensions/next-ssh/src/main/java/net/thevpc/nuts/ext/ssh/RemoteConnexionStringInfo.java index 2c4e02e81..48783af4e 100644 --- a/extensions/next-ssh/src/main/java/net/thevpc/nuts/ext/ssh/RemoteConnexionStringInfo.java +++ b/extensions/next-ssh/src/main/java/net/thevpc/nuts/ext/ssh/RemoteConnexionStringInfo.java @@ -3,7 +3,6 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.elem.NElement; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.*; import net.thevpc.nuts.format.NDescriptorFormat; import net.thevpc.nuts.io.NIO; import net.thevpc.nuts.io.NPath; @@ -303,7 +302,7 @@ public String getSudoPath(NExecCmdExtension commExec, NSession session) { } public String[] buildEffectiveCommand(String[] cmd, NRunAs runAs, String[] executionOptions, NExecCmdExtension commExec, NSession session) { - return NEnvs.of().buildEffectiveCommand(cmd, runAs, + return NWorkspace.get().buildEffectiveCommand(cmd, runAs, new HashSet(), s -> { if (s == null) { diff --git a/extensions/next-term/src/main/java/net/thevpc/nuts/ext/term/NJLineTerminal.java b/extensions/next-term/src/main/java/net/thevpc/nuts/ext/term/NJLineTerminal.java index 6edfc625b..1e4b5861c 100644 --- a/extensions/next-term/src/main/java/net/thevpc/nuts/ext/term/NJLineTerminal.java +++ b/extensions/next-term/src/main/java/net/thevpc/nuts/ext/term/NJLineTerminal.java @@ -29,7 +29,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.cmdline.NCmdLineAutoCompleteResolver; import net.thevpc.nuts.cmdline.NCmdLineHistory; -import net.thevpc.nuts.env.NLocations; + import net.thevpc.nuts.io.*; import net.thevpc.nuts.spi.*; import net.thevpc.nuts.text.*; @@ -230,7 +230,7 @@ public void setErrorIndex(int i) { // .parse(parse) .build(); reader.unsetOpt(LineReader.Option.INSERT_TAB); - reader.setVariable(LineReader.HISTORY_FILE, NLocations.of().getWorkspaceLocation().resolve("history").normalize().toPath().get()); + reader.setVariable(LineReader.HISTORY_FILE, NWorkspace.get().getWorkspaceLocation().resolve("history").normalize().toPath().get()); if (reader instanceof LineReaderImpl) { ((LineReaderImpl) reader).setHistory(new NJLineHistory(reader, session, this)); } diff --git a/incubating/ndexer/src/main/java/net/thevpc/nuts/indexer/NIndexSubscriberListManager.java b/incubating/ndexer/src/main/java/net/thevpc/nuts/indexer/NIndexSubscriberListManager.java index 7ab790cbc..2b6b5adf6 100644 --- a/incubating/ndexer/src/main/java/net/thevpc/nuts/indexer/NIndexSubscriberListManager.java +++ b/incubating/ndexer/src/main/java/net/thevpc/nuts/indexer/NIndexSubscriberListManager.java @@ -2,8 +2,8 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NPath; import java.util.*; @@ -36,7 +36,7 @@ public NIndexSubscriberListManager(String name) { } private NPath getConfigFile() { - return NLocations.of() + return NWorkspace.get() .getStoreLocation(NId.ofClass(NIndexSubscriberListManager.class).get(), NStoreType.CONF).resolve( name + "-nuts-subscriber-list.json"); @@ -83,7 +83,7 @@ public NIndexSubscriber subscribe(String repositoryUuid, NWorkspaceLocation work } private String getRepositoryNameFromUuid(String repositoryUuid) { - List repositories = NRepositories.of().getRepositories(); + List repositories = NWorkspace.get().getRepositories(); for (NRepository repository : repositories) { if (repository.getUuid().equals(repositoryUuid)) { return repository.getName(); diff --git a/incubating/ndexer/src/main/java/net/thevpc/nuts/indexer/NIndexerUtils.java b/incubating/ndexer/src/main/java/net/thevpc/nuts/indexer/NIndexerUtils.java index 212ee716d..c0574ee21 100644 --- a/incubating/ndexer/src/main/java/net/thevpc/nuts/indexer/NIndexerUtils.java +++ b/incubating/ndexer/src/main/java/net/thevpc/nuts/indexer/NIndexerUtils.java @@ -2,10 +2,8 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NEnvConditionBuilder; -import net.thevpc.nuts.env.NEnvs; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; +import net.thevpc.nuts.NEnvConditionBuilder; +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.util.NLiteral; import net.thevpc.nuts.util.NStringUtils; import org.apache.lucene.index.Term; @@ -25,12 +23,12 @@ public class NIndexerUtils { public static Path getCacheDir(String entity) { String k = "NutsIndexerUtils.CACHE." + entity; - String m = NEnvs.of().getProperty(k).flatMap(NLiteral::asString).orNull(); + String m = NWorkspace.get().getProperty(k).flatMap(NLiteral::asString).orNull(); if (m == null) { - m = NLocations.of() + m = NWorkspace.get() .getStoreLocation(NId.ofClass(NIndexerUtils.class).get(), NStoreType.CACHE) + File.separator + entity; - NEnvs.of().setProperty(k, m); + NWorkspace.get().setProperty(k, m); } return new File(m).toPath(); } diff --git a/incubating/ndexer/src/main/java/net/thevpc/nuts/indexer/NWorkspacePool.java b/incubating/ndexer/src/main/java/net/thevpc/nuts/indexer/NWorkspacePool.java index 33cdc1510..a8bb213fa 100644 --- a/incubating/ndexer/src/main/java/net/thevpc/nuts/indexer/NWorkspacePool.java +++ b/incubating/ndexer/src/main/java/net/thevpc/nuts/indexer/NWorkspacePool.java @@ -1,6 +1,6 @@ package net.thevpc.nuts.indexer; -import net.thevpc.nuts.env.NLocations; + import net.thevpc.nuts.NWorkspace; import net.thevpc.nuts.NWorkspaceOptionsBuilder; import net.thevpc.nuts.Nuts; @@ -20,7 +20,7 @@ public class NWorkspacePool { public NWorkspace openWorkspace(String ws) { NWorkspace o = pool.get(ws); if (o == null) { - if (NLocations.of().getWorkspaceLocation().toString().equals(ws)) { + if (NWorkspace.get().getWorkspaceLocation().toString().equals(ws)) { o = workspace; } else { o = Nuts.openWorkspace(NWorkspaceOptionsBuilder.of() diff --git a/incubating/ndexer/src/main/java/net/thevpc/nuts/indexer/services/NComponentController.java b/incubating/ndexer/src/main/java/net/thevpc/nuts/indexer/services/NComponentController.java index 9cbcfe2ab..2db2f30ec 100644 --- a/incubating/ndexer/src/main/java/net/thevpc/nuts/indexer/services/NComponentController.java +++ b/incubating/ndexer/src/main/java/net/thevpc/nuts/indexer/services/NComponentController.java @@ -1,7 +1,7 @@ package net.thevpc.nuts.indexer.services; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NEnvConditionBuilder; +import net.thevpc.nuts.NEnvConditionBuilder; import net.thevpc.nuts.indexer.*; import net.thevpc.nuts.*; import net.thevpc.nuts.util.NRef; @@ -240,7 +240,7 @@ public ResponseEntity addDocument(@RequestParam("repositoryUuid") Strin if (list.isEmpty()) { Iterator it = NSearchCmd.of() .setRepositoryFilter( - NRepositories.of().filter().byUuid(subscriber.getUuid()) + NRepositoryFilters.of().byUuid(subscriber.getUuid()) ) .addId(id) .setFailFast(false) diff --git a/incubating/ndexer/src/main/java/net/thevpc/nuts/indexer/services/NSubscriptionController.java b/incubating/ndexer/src/main/java/net/thevpc/nuts/indexer/services/NSubscriptionController.java index c9b3219e0..12a86bfbf 100644 --- a/incubating/ndexer/src/main/java/net/thevpc/nuts/indexer/services/NSubscriptionController.java +++ b/incubating/ndexer/src/main/java/net/thevpc/nuts/indexer/services/NSubscriptionController.java @@ -39,7 +39,7 @@ private void init() { public ResponseEntity subscribe(@RequestParam("workspaceLocation") String workspaceLocation, @RequestParam("repositoryUuid") String repositoryUuid) { NWorkspace workspace = workspacePool.openWorkspace(workspaceLocation); - List repositories = NRepositories.of().getRepositories(); + List repositories = NWorkspace.get().getRepositories(); for (NRepository repository : repositories) { if (repository.getUuid().equals(repositoryUuid)) { this.subscriberManager.subscribe(repositoryUuid, @@ -55,7 +55,7 @@ public ResponseEntity subscribe(@RequestParam("workspaceLocation") String public ResponseEntity unsubscribe(@RequestParam("workspaceLocation") String workspaceLocation, @RequestParam("repositoryUuid") String repositoryUuid) { NWorkspace workspace = workspacePool.openWorkspace(workspaceLocation); - List repositories = NRepositories.of().getRepositories(); + List repositories = NWorkspace.get().getRepositories(); for (NRepository repository : repositories) { if (repository.getUuid().equals(repositoryUuid)) { this.subscriberManager.unsubscribe(repositoryUuid, @@ -71,7 +71,7 @@ public ResponseEntity isSubscribed(@RequestParam("workspaceLocation") S @RequestParam("repositoryUuid") String repositoryUuid) { System.out.println(workspaceLocation + " " + repositoryUuid); NWorkspace workspace = workspacePool.openWorkspace(workspaceLocation); - List repositories = NRepositories.of().getRepositories(); + List repositories = NWorkspace.get().getRepositories(); for (NRepository repository : repositories) { if (repository.getUuid().equals(repositoryUuid)) { boolean subscribed = this.subscriberManager.isSubscribed(repositoryUuid, diff --git a/incubating/ndexer/src/main/java/net/thevpc/nuts/indexer/services/RefreshDataService.java b/incubating/ndexer/src/main/java/net/thevpc/nuts/indexer/services/RefreshDataService.java index 91610ef44..8e8e0febc 100644 --- a/incubating/ndexer/src/main/java/net/thevpc/nuts/indexer/services/RefreshDataService.java +++ b/incubating/ndexer/src/main/java/net/thevpc/nuts/indexer/services/RefreshDataService.java @@ -56,7 +56,7 @@ private void refreshSubscriberData(NIndexSubscriber subscriber) { .stream() .collect(Collectors.toMap(map -> map.get("stringId"), map -> NIndexerUtils.mapToNutsId(map), (v1, v2) -> v1)); Iterator definitions = NSearchCmd.of() - .setRepositoryFilter(NRepositories.of().filter().byUuid(subscriber.getUuid())) + .setRepositoryFilter(NRepositoryFilters.of().byUuid(subscriber.getUuid())) .setFailFast(false) .setContent(false) .setEffective(true) diff --git a/incubating/nwork/src/main/java/net/thevpc/nuts/toolbox/nwork/ProjectService.java b/incubating/nwork/src/main/java/net/thevpc/nuts/toolbox/nwork/ProjectService.java index 2798d2c76..ead8c844f 100644 --- a/incubating/nwork/src/main/java/net/thevpc/nuts/toolbox/nwork/ProjectService.java +++ b/incubating/nwork/src/main/java/net/thevpc/nuts/toolbox/nwork/ProjectService.java @@ -2,8 +2,8 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.toolbox.nwork.config.ProjectConfig; import net.thevpc.nuts.toolbox.nwork.config.RepositoryAddress; @@ -191,7 +191,7 @@ public File detectRemoteVersionFile(String sid) { } try { NSession s = null; - if (a.getNutsWorkspace() != null && a.getNutsWorkspace().trim().length() > 0 && !a.getNutsWorkspace().equals(NLocations.of().getWorkspaceLocation().toString())) { + if (a.getNutsWorkspace() != null && a.getNutsWorkspace().trim().length() > 0 && !a.getNutsWorkspace().equals(NWorkspace.get().getWorkspaceLocation().toString())) { s = Nuts.openWorkspace( NWorkspaceOptionsBuilder.of() .setOpenMode(NOpenMode.OPEN_OR_ERROR) @@ -243,7 +243,7 @@ public String detectRemoteVersion() { .setDescriptorStyle(NDescriptorStyle.MAVEN) .parse(new File(f, "pom.xml")).get(); NSession s = null; - if (a.getNutsWorkspace() != null && a.getNutsWorkspace().trim().length() > 0 && !a.getNutsWorkspace().equals(NLocations.of().getWorkspaceLocation().toString())) { + if (a.getNutsWorkspace() != null && a.getNutsWorkspace().trim().length() > 0 && !a.getNutsWorkspace().equals(NWorkspace.get().getWorkspaceLocation().toString())) { s = Nuts.openWorkspace( NWorkspaceOptionsBuilder.of() .setOpenMode(NOpenMode.OPEN_OR_ERROR) diff --git a/incubating/nwork/src/main/java/net/thevpc/nuts/toolbox/nwork/WorkspaceService.java b/incubating/nwork/src/main/java/net/thevpc/nuts/toolbox/nwork/WorkspaceService.java index 8b34adcf8..9ba7d6291 100644 --- a/incubating/nwork/src/main/java/net/thevpc/nuts/toolbox/nwork/WorkspaceService.java +++ b/incubating/nwork/src/main/java/net/thevpc/nuts/toolbox/nwork/WorkspaceService.java @@ -5,7 +5,7 @@ import net.thevpc.nuts.cmdline.NArgName; import net.thevpc.nuts.cmdline.NCmdLine; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NStoreType; +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.format.NContentType; import net.thevpc.nuts.format.NObjectFormat; import net.thevpc.nuts.io.NPath; diff --git a/installers/nuts-portable/src/dist/META-INF/native-image/reflect-config.json b/installers/nuts-portable/src/dist/META-INF/native-image/reflect-config.json index 17b1c862f..fdc63215d 100644 --- a/installers/nuts-portable/src/dist/META-INF/native-image/reflect-config.json +++ b/installers/nuts-portable/src/dist/META-INF/native-image/reflect-config.json @@ -332,10 +332,6 @@ "name":"net.thevpc.nuts.runtime.standalone.io.inputstream.DefaultNIORPI", "methods":[{"name":"","parameterTypes":["net.thevpc.nuts.NSession"] }] }, -{ - "name":"net.thevpc.nuts.runtime.standalone.io.path.DefaultNPaths", - "methods":[{"name":"","parameterTypes":["net.thevpc.nuts.NSession"] }] -}, { "name":"net.thevpc.nuts.runtime.standalone.io.path.spi.ClassLoaderPath" }, @@ -598,21 +594,6 @@ { "name":"net.thevpc.nuts.runtime.standalone.workspace.cmd.update.DefaultNUpdateCmd" }, -{ - "name":"net.thevpc.nuts.runtime.standalone.workspace.config.DefaultCommands" -}, -{ - "name":"net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNConfigs", - "methods":[{"name":"","parameterTypes":["net.thevpc.nuts.NSession"] }] -}, -{ - "name":"net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNEnvs", - "methods":[{"name":"","parameterTypes":["net.thevpc.nuts.NSession"] }] -}, -{ - "name":"net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNImports", - "methods":[{"name":"","parameterTypes":["net.thevpc.nuts.NSession"] }] -}, { "name":"net.thevpc.nuts.runtime.standalone.workspace.config.DefaultNIndexStoreFactory", "methods":[{"name":"","parameterTypes":[] }, {"name":"","parameterTypes":["net.thevpc.nuts.NSession"] }, {"name":"","parameterTypes":["net.thevpc.nuts.NWorkspace"] }] @@ -672,10 +653,6 @@ "name":"net.thevpc.nuts.runtime.standalone.xtra.contenttype.DefaultNContentTypeResolver", "methods":[{"name":"","parameterTypes":["net.thevpc.nuts.NSession"] }] }, -{ - "name":"net.thevpc.nuts.runtime.standalone.xtra.contenttype.DefaultNContentTypes", - "methods":[{"name":"","parameterTypes":["net.thevpc.nuts.NSession"] }] -}, { "name":"net.thevpc.nuts.runtime.standalone.xtra.cp.DefaultNCp", "methods":[{"name":"","parameterTypes":["net.thevpc.nuts.NSession"] }] diff --git a/installers/nuts-release-tool/src/main/java/net/thevpc/nuts/build/builders/SiteRunner.java b/installers/nuts-release-tool/src/main/java/net/thevpc/nuts/build/builders/SiteRunner.java index 525cfd6f6..53e4f767b 100644 --- a/installers/nuts-release-tool/src/main/java/net/thevpc/nuts/build/builders/SiteRunner.java +++ b/installers/nuts-release-tool/src/main/java/net/thevpc/nuts/build/builders/SiteRunner.java @@ -10,7 +10,7 @@ import net.thevpc.nuts.build.util.MvnArtifactType; import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NBootManager; + import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.util.NMaps; import net.thevpc.nuts.text.NTextStyle; @@ -124,7 +124,7 @@ private void runSiteGithubDocumentation() { .setBuildWebSite(true) .setStartWebSite(false) .setBuildPdf(true) - .setAutoInstallNutsPackages(NBootManager.of() + .setAutoInstallNutsPackages(NWorkspace.get() .getBootOptions().getConfirm().orElse(NConfirmationMode.ASK) == NConfirmationMode.YES) .setVars(prepareVars()); diff --git a/installers/nuts-release-tool/src/main/java/net/thevpc/nuts/build/util/NativeBuilder.java b/installers/nuts-release-tool/src/main/java/net/thevpc/nuts/build/util/NativeBuilder.java index 45f3b7ca6..f3ee0f652 100644 --- a/installers/nuts-release-tool/src/main/java/net/thevpc/nuts/build/util/NativeBuilder.java +++ b/installers/nuts-release-tool/src/main/java/net/thevpc/nuts/build/util/NativeBuilder.java @@ -1,7 +1,7 @@ package net.thevpc.nuts.build.util; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NEnvs; + import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.util.NMaps; import net.thevpc.nuts.text.NTextStyle; @@ -211,7 +211,7 @@ private NPath zipFolder(NPath folder, BinPlatform platform, String discriminator } private BinPlatform currentPlatform() { - NEnvs e = NEnvs.of(); + NWorkspace e = NWorkspace.get(); switch (e.getOsFamily()) { case UNIX: case LINUX: { @@ -244,7 +244,7 @@ private BinPlatform currentPlatform() { } private BinPlatform evalCurrentBinPlatform() { - NEnvs z = NEnvs.of(); + NWorkspace z = NWorkspace.get(); switch (z.getOsFamily()) { case LINUX: { switch (z.getArchFamily()) { diff --git a/libraries/nlib-spring-boot/src/main/java/net/thevpc/nuts/lib/spring/boot/NutsSpringBootConfiguration.java b/libraries/nlib-spring-boot/src/main/java/net/thevpc/nuts/lib/spring/boot/NutsSpringBootConfiguration.java index 464414dcd..edde3d7f0 100644 --- a/libraries/nlib-spring-boot/src/main/java/net/thevpc/nuts/lib/spring/boot/NutsSpringBootConfiguration.java +++ b/libraries/nlib-spring-boot/src/main/java/net/thevpc/nuts/lib/spring/boot/NutsSpringBootConfiguration.java @@ -2,8 +2,18 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.cmdline.NCmdLine; +import net.thevpc.nuts.cmdline.NCmdLines; +import net.thevpc.nuts.concurrent.NLocks; +import net.thevpc.nuts.concurrent.NScheduler; + +import net.thevpc.nuts.expr.NExprs; +import net.thevpc.nuts.ext.NExtensions; +import net.thevpc.nuts.format.NFormats; +import net.thevpc.nuts.io.NIO; import net.thevpc.nuts.io.NPrintStream; import net.thevpc.nuts.io.NTerminal; +import net.thevpc.nuts.time.NProgressMonitors; +import net.thevpc.nuts.util.NGlob; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.CommandLineRunner; @@ -44,6 +54,87 @@ public NSession nutsSession(ApplicationArguments applicationArguments) { return nutsWorkspace(applicationArguments).currentSession(); } + + @Bean + public NTerminal nutsTerminal(ApplicationArguments applicationArguments) { + return nutsSession(applicationArguments).getTerminal(); + } + + @Bean + public NExprs nutsNExprs(ApplicationArguments applicationArguments) { + return nutsSession(applicationArguments).callWith(()->{ + return NExprs.of(); + }); + } + @Bean + public NIdFilters nutsIdFilters(ApplicationArguments applicationArguments) { + return nutsSession(applicationArguments).callWith(()->{ + return NIdFilters.of(); + }); + } + + @Bean + public NDependencyFilters nutsDependencyFilters(ApplicationArguments applicationArguments) { + return nutsSession(applicationArguments).callWith(()->{ + return NDependencyFilters.of(); + }); + } + + @Bean + public NDescriptorFilters nutsDescriptorFilters(ApplicationArguments applicationArguments) { + return nutsSession(applicationArguments).callWith(()->{ + return NDescriptorFilters.of(); + }); + } + @Bean + public NLibPaths nutsLibPaths(ApplicationArguments applicationArguments) { + return nutsSession(applicationArguments).callWith(()->{ + return NLibPaths.of(); + }); + } + + + @Bean + public NProgressMonitors nutsProgressMonitors(ApplicationArguments applicationArguments) { + return nutsSession(applicationArguments).callWith(()->{ + return NProgressMonitors.of(); + }); + } + @Bean + public NIO nutsIO(ApplicationArguments applicationArguments) { + return nutsSession(applicationArguments).callWith(()->{ + return NIO.of(); + }); + } + @Bean + public NFormats nutsFormats(ApplicationArguments applicationArguments) { + return nutsSession(applicationArguments).callWith(()->{ + return NFormats.of(); + }); + } + + @Bean + public NExtensions nutsExtensions(ApplicationArguments applicationArguments) { + return nutsSession(applicationArguments).callWith(()->{ + return NExtensions.of(); + }); + } + + @Bean + public NScheduler nutsScheduler(ApplicationArguments applicationArguments) { + return nutsSession(applicationArguments).callWith(()->{ + return NScheduler.of(); + }); + } + + @Bean + public NCmdLines nutsCmdLines(ApplicationArguments applicationArguments) { + return nutsSession(applicationArguments).callWith(()->{ + return NCmdLines.of(); + }); + } + + @Bean public NApplication nutsApplication() { Map bootApps = new HashMap<>(); diff --git a/test/nuts-runtime-test/src/test/java/net/thevpc/nuts/core/test/Test01_CreateTest.java b/test/nuts-runtime-test/src/test/java/net/thevpc/nuts/core/test/Test01_CreateTest.java index d429658fc..a87cc2c03 100755 --- a/test/nuts-runtime-test/src/test/java/net/thevpc/nuts/core/test/Test01_CreateTest.java +++ b/test/nuts-runtime-test/src/test/java/net/thevpc/nuts/core/test/Test01_CreateTest.java @@ -13,10 +13,6 @@ import net.thevpc.nuts.concurrent.NLocks; import net.thevpc.nuts.core.test.utils.TestUtils; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NHomeLocation; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NOsFamily; -import net.thevpc.nuts.env.NStoreType; import net.thevpc.nuts.expr.NExprs; import net.thevpc.nuts.format.*; import net.thevpc.nuts.io.*; @@ -24,7 +20,6 @@ import net.thevpc.nuts.log.NLogOp; import net.thevpc.nuts.io.NDigest; import net.thevpc.nuts.spi.NDependencySolver; -import net.thevpc.nuts.io.NPaths; import net.thevpc.nuts.text.NText; import net.thevpc.nuts.text.NTexts; import net.thevpc.nuts.util.*; @@ -55,8 +50,8 @@ public void minimal1() { ); Assertions.assertEquals( NPath.of(new File(wsPath, "cache")), - NLocations.of().getStoreLocation(NStoreType.CACHE)); - Assertions.assertEquals(0, NRepositories.of().getRepositories().size()); + NWorkspace.get().getStoreLocation(NStoreType.CACHE)); + Assertions.assertEquals(0, NWorkspace.get().getRepositories().size()); // Assertions.assertEquals(new File(wsPath, "cache/" + NutsConstants.Folders.REPOSITORIES + "/" + // NRepositories.of(session).getRepositories()[0].getName() + // "/" + NRepositories.of(session).getRepositories()[0].getUuid()).getPath(), @@ -135,14 +130,14 @@ public void default1() throws Exception { } Assertions.assertEquals( NPath.of(new File(base, new File(wsPath).getName())), - NLocations.of().getStoreLocation(NStoreType.CACHE)); + NWorkspace.get().getStoreLocation(NStoreType.CACHE)); Assertions.assertEquals( NPath.of(new File(base, new File(wsPath).getName() + "/" + NConstants.Folders.REPOSITORIES + "/" - + NRepositories.of().getRepositories().get(0).getName() - + "/" + NRepositories.of().getRepositories().get(0).getUuid() + + NWorkspace.get().getRepositories().get(0).getName() + + "/" + NWorkspace.get().getRepositories().get(0).getUuid() )), - NRepositories.of().getRepositories().get(0).config().getStoreLocation(NStoreType.CACHE)); + NWorkspace.get().getRepositories().get(0).config().getStoreLocation(NStoreType.CACHE)); } @Test @@ -241,10 +236,6 @@ public void createUtilTypes() { NLocks c = NLocks.of(); Assertions.assertNotNull(c); } - { - NPaths c = NPaths.of(); - Assertions.assertNotNull(c); - } { NCp c = NCp.of(); Assertions.assertNotNull(c); diff --git a/test/nuts-runtime-test/src/test/java/net/thevpc/nuts/core/test/Test03_CreateLayoutTest.java b/test/nuts-runtime-test/src/test/java/net/thevpc/nuts/core/test/Test03_CreateLayoutTest.java index 33705a7ec..2cec19a47 100755 --- a/test/nuts-runtime-test/src/test/java/net/thevpc/nuts/core/test/Test03_CreateLayoutTest.java +++ b/test/nuts-runtime-test/src/test/java/net/thevpc/nuts/core/test/Test03_CreateLayoutTest.java @@ -7,8 +7,8 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.core.test.utils.TestUtils; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.util.NMsg; import org.junit.jupiter.api.*; @@ -39,7 +39,7 @@ public void customLayout_reload() throws Exception { ) ); for (NStoreType value : NStoreType.values()) { - NSession.get().out().println(NMsg.ofC("%s %s", value, NLocations.of().getStoreLocation(value))); + NSession.get().out().println(NMsg.ofC("%s %s", value, NWorkspace.get().getStoreLocation(value))); } TestUtils.openExistingTestWorkspace( @@ -53,8 +53,8 @@ public void customLayout_reload() throws Exception { for (NStoreType value : NStoreType.values()) { Assertions.assertEquals( - NLocations.of().getStoreLocation(value), - NLocations.of().getStoreLocation(value) + NWorkspace.get().getStoreLocation(value), + NWorkspace.get().getStoreLocation(value) ); } } @@ -105,20 +105,20 @@ public void customLayout_use_standalone() { } Assertions.assertTrue(nshId.getVersion().getValue().startsWith(TestUtils.NUTS_VERSION + ".")); } - NPath c = NLocations.of().getStoreLocation(NStoreType.CONF); + NPath c = NWorkspace.get().getStoreLocation(NStoreType.CONF); TestUtils.println(c); File base = NWorkspace.get().getLocation().toFile().get(); TestUtils.println(new File(base, "config").getPath()); for (NStoreType value : NStoreType.values()) { - NSession.get().out().println(NMsg.ofC("%s %s", value, NLocations.of().getStoreLocation(value))); + NSession.get().out().println(NMsg.ofC("%s %s", value, NWorkspace.get().getStoreLocation(value))); } Assertions.assertEquals( NPath.of(base).resolve("bin"), - NLocations.of().getStoreLocation(NStoreType.BIN) + NWorkspace.get().getStoreLocation(NStoreType.BIN) ); Assertions.assertEquals( NPath.of(base).resolve("cache"), - NLocations.of().getStoreLocation(NStoreType.CACHE) + NWorkspace.get().getStoreLocation(NStoreType.CACHE) ); } @@ -147,76 +147,76 @@ public void customLayout() throws Exception { NInfoCmd.of().println(); TestUtils.println("=========================="); TestUtils.println(new File(base, "system.bin").getPath()); - NLocations locations = NLocations.of(); - TestUtils.println(locations.getStoreLocation(NStoreType.BIN)); + NWorkspace workspace = NWorkspace.get(); + TestUtils.println(workspace.getStoreLocation(NStoreType.BIN)); Assertions.assertEquals( NPath.of(new File(base, "system.bin")), - locations.getStoreLocation(NStoreType.BIN) + workspace.getStoreLocation(NStoreType.BIN) ); Assertions.assertEquals( NPath.of(new File(base, "system.conf")), - locations.getStoreLocation(NStoreType.CONF) + workspace.getStoreLocation(NStoreType.CONF) ); Assertions.assertEquals( NPath.of(new File(base, "system.var")), - locations.getStoreLocation(NStoreType.VAR) + workspace.getStoreLocation(NStoreType.VAR) ); Assertions.assertEquals( NPath.of(new File(base, "system.log")), - locations.getStoreLocation(NStoreType.LOG) + workspace.getStoreLocation(NStoreType.LOG) ); Assertions.assertEquals( NPath.of(new File(base, "system.temp")), - locations.getStoreLocation(NStoreType.TEMP) + workspace.getStoreLocation(NStoreType.TEMP) ); Assertions.assertEquals( NPath.of(new File(base, "system.cache")), - locations.getStoreLocation(NStoreType.CACHE) + workspace.getStoreLocation(NStoreType.CACHE) ); Assertions.assertEquals( NPath.of(new File(base, "system.lib")), - locations.getStoreLocation(NStoreType.LIB) + workspace.getStoreLocation(NStoreType.LIB) ); Assertions.assertEquals( NPath.of(new File(base, "system.run")), - locations.getStoreLocation(NStoreType.RUN) + workspace.getStoreLocation(NStoreType.RUN) ); TestUtils.openNewTestWorkspace(// "--workspace", "default-workspace", // "--workspace", new File(base, "system.config/default-workspace").getPath(), "info"); - TestUtils.println(locations.getStoreLocation(NStoreType.BIN)); + TestUtils.println(workspace.getStoreLocation(NStoreType.BIN)); Assertions.assertEquals( NPath.of(new File(base, "system.bin")), - locations.getStoreLocation(NStoreType.BIN) + workspace.getStoreLocation(NStoreType.BIN) ); Assertions.assertEquals( NPath.of(new File(base, "system.conf")), - locations.getStoreLocation(NStoreType.CONF) + workspace.getStoreLocation(NStoreType.CONF) ); Assertions.assertEquals( NPath.of(new File(base, "system.var")), - locations.getStoreLocation(NStoreType.VAR) + workspace.getStoreLocation(NStoreType.VAR) ); Assertions.assertEquals( NPath.of(new File(base, "system.log")), - locations.getStoreLocation(NStoreType.LOG) + workspace.getStoreLocation(NStoreType.LOG) ); Assertions.assertEquals( NPath.of(new File(base, "system.temp")), - locations.getStoreLocation(NStoreType.TEMP) + workspace.getStoreLocation(NStoreType.TEMP) ); Assertions.assertEquals( NPath.of(new File(base, "system.cache")), - locations.getStoreLocation(NStoreType.CACHE) + workspace.getStoreLocation(NStoreType.CACHE) ); Assertions.assertEquals( NPath.of(new File(base, "system.lib")), - locations.getStoreLocation(NStoreType.LIB) + workspace.getStoreLocation(NStoreType.LIB) ); Assertions.assertEquals( NPath.of(new File(base, "system.run")), - locations.getStoreLocation(NStoreType.RUN) + workspace.getStoreLocation(NStoreType.RUN) ); } diff --git a/test/nuts-runtime-test/src/test/java/net/thevpc/nuts/core/test/Test06_UpdateTest.java b/test/nuts-runtime-test/src/test/java/net/thevpc/nuts/core/test/Test06_UpdateTest.java index 55dda103f..babc4799e 100755 --- a/test/nuts-runtime-test/src/test/java/net/thevpc/nuts/core/test/Test06_UpdateTest.java +++ b/test/nuts-runtime-test/src/test/java/net/thevpc/nuts/core/test/Test06_UpdateTest.java @@ -8,9 +8,10 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.core.test.utils.TestUtils; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreStrategy; -import net.thevpc.nuts.env.NStoreType; + + +import net.thevpc.nuts.NStoreStrategy; +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.format.NDescriptorFormat; import net.thevpc.nuts.format.NExecCmdFormat; import net.thevpc.nuts.io.NIOException; @@ -119,13 +120,12 @@ private void prepareCustomUpdateRepository(boolean implOnly, Data data) { private void prepareWorkspaceToUpdate(boolean implOnly, Data data) { TestUtils.println("\n------------------------------------------"); - TestUtils.openNewTestWorkspace( + NWorkspace workspace=TestUtils.openNewTestWorkspace( "--standalone", "--standalone-repositories", "--yes", "--install-companions=false" ); - NRepositories repos = NRepositories.of(); NPath tempRepo = NPath.ofTempFolder(); data.updateRepoPath = tempRepo.toString(); data.apiDef1 = NFetchCmd.ofNutsApi().setContent(true).getResultDefinition(); @@ -133,16 +133,16 @@ private void prepareWorkspaceToUpdate(boolean implOnly, Data data) { data.rtDef1 = NFetchCmd.ofNutsRuntime().setContent(true).getResultDefinition(); data.rtId1 = data.rtDef1.getId().builder().setVersion(data.rtDef1.getId().getVersion()).build(); - repos.addRepository(new NAddRepositoryOptions().setTemporary(true).setName("temp").setLocation(data.updateRepoPath) + workspace.addRepository(new NAddRepositoryOptions().setTemporary(true).setName("temp").setLocation(data.updateRepoPath) .setConfig(new NRepositoryConfig().setStoreStrategy(NStoreStrategy.STANDALONE)) ); - TestUtils.println(repos.findRepository("temp").get().config().getStoreStrategy()); - TestUtils.println(repos.findRepository("temp").get().config().getStoreLocation()); - TestUtils.println(repos.findRepository("temp").get().config().getStoreLocation(NStoreType.LIB)); + TestUtils.println(workspace.findRepository("temp").get().config().getStoreStrategy()); + TestUtils.println(workspace.findRepository("temp").get().config().getStoreLocation()); + TestUtils.println(workspace.findRepository("temp").get().config().getStoreLocation(NStoreType.LIB)); NInfoCmd.of().configure(false, "--repos").setShowRepositories(true).println(); Assertions.assertEquals(data.updateRepoPath, - repos.findRepository("temp").get().config().getLocationPath().toString() + workspace.findRepository("temp").get().config().getLocationPath().toString() ); TestUtils.println(NSearchCmd.of().addId(data.api).getResultIds().toList()); TestUtils.println(NSearchCmd.of().addId(data.rt).getResultIds().toList()); @@ -189,10 +189,10 @@ private void testUpdate(boolean implOnly, String callerName) throws Exception { final String newRuntimeVersion = foundUpdates.getResult().getRuntime().getAvailable().getId().getVersion().toString(); // Path bootFolder=Paths.get(workspacePath).resolve(NutsConstants.Folders.BOOT); // Path bootCompFolder=Paths.get(workspacePath).resolve(NutsConstants.Folders.BOOT); - NLocations nwsLocations = NLocations.of(); - Path bootCacheFolder = (nwsLocations.getStoreLocation(NStoreType.CACHE)).resolve(NConstants.Folders.ID).toPath().get(); - Path libFolder = (nwsLocations.getStoreLocation(NStoreType.LIB)).resolve(NConstants.Folders.ID).toPath().get(); - Path configFolder = (nwsLocations.getStoreLocation(NStoreType.CONF)).resolve(NConstants.Folders.ID).toPath().get(); + NWorkspace newWorkspace = NWorkspace.get(); + Path bootCacheFolder = (newWorkspace.getStoreLocation(NStoreType.CACHE)).resolve(NConstants.Folders.ID).toPath().get(); + Path libFolder = (newWorkspace.getStoreLocation(NStoreType.LIB)).resolve(NConstants.Folders.ID).toPath().get(); + Path configFolder = (newWorkspace.getStoreLocation(NStoreType.CONF)).resolve(NConstants.Folders.ID).toPath().get(); Assertions.assertTrue(Files.exists(libFolder.resolve("net/thevpc/nuts/nuts/").resolve(newApiVersion) .resolve("nuts-" + newApiVersion + ".jar") )); diff --git a/test/nuts-runtime-test/src/test/java/net/thevpc/nuts/core/test/Test10_ExecURLTest.java b/test/nuts-runtime-test/src/test/java/net/thevpc/nuts/core/test/Test10_ExecURLTest.java index 931be7654..71ba788de 100755 --- a/test/nuts-runtime-test/src/test/java/net/thevpc/nuts/core/test/Test10_ExecURLTest.java +++ b/test/nuts-runtime-test/src/test/java/net/thevpc/nuts/core/test/Test10_ExecURLTest.java @@ -7,7 +7,8 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.core.test.utils.TestUtils; -import net.thevpc.nuts.env.NLocations; + + import net.thevpc.nuts.format.NVersionFormat; import net.thevpc.nuts.util.NAssert; import org.junit.jupiter.api.*; @@ -58,7 +59,7 @@ public void execURL() { String result = NExecCmd.of() .addWorkspaceOptions(NWorkspaceOptionsBuilder.of() .setBot(true) - .setWorkspace(NLocations.of().getWorkspaceLocation().resolve("temp-ws").toString()) + .setWorkspace(NWorkspace.get().getWorkspaceLocation().resolve("temp-ws").toString()) ) //.addExecutorOption("--main-class=Version") .addCommand( diff --git a/test/nuts-runtime-test/src/test/java/net/thevpc/nuts/core/test/Test29_DependencyTest.java b/test/nuts-runtime-test/src/test/java/net/thevpc/nuts/core/test/Test29_DependencyTest.java index 506d48404..562263af3 100755 --- a/test/nuts-runtime-test/src/test/java/net/thevpc/nuts/core/test/Test29_DependencyTest.java +++ b/test/nuts-runtime-test/src/test/java/net/thevpc/nuts/core/test/Test29_DependencyTest.java @@ -6,13 +6,18 @@ package net.thevpc.nuts.core.test; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NBootOptionsBuilder; -import net.thevpc.nuts.runtime.standalone.DefaultNBootOptionsBuilder; +import net.thevpc.nuts.NBootOptionsBuilder; import net.thevpc.nuts.core.test.utils.TestUtils; +import net.thevpc.nuts.runtime.standalone.DefaultNDependencyBuilder; +import net.thevpc.nuts.runtime.standalone.DefaultNEnvConditionBuilder; +import net.thevpc.nuts.util.NMaps; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import java.util.ArrayList; +import java.util.Arrays; + /** * @@ -49,4 +54,17 @@ public void testSearchDescriptor() { System.out.println("Okkay"); } + @Test + public void test2() { + DefaultNDependencyBuilder b=new DefaultNDependencyBuilder(); + b.setId(NId.of("a:b").get()); + DefaultNEnvConditionBuilder cond = new DefaultNEnvConditionBuilder(); + cond.setProfile(new ArrayList<>(Arrays.asList("felix"))); + cond.setProperties(NMaps.of("a","b")); + b.setCondition(cond); + System.out.println(b); + + + } + } diff --git a/test/nuts-runtime-test/src/test/java/net/thevpc/nuts/core/test/Test41_NPlatformHome.java b/test/nuts-runtime-test/src/test/java/net/thevpc/nuts/core/test/Test41_NPlatformHome.java index 80ead03fa..32096c33f 100644 --- a/test/nuts-runtime-test/src/test/java/net/thevpc/nuts/core/test/Test41_NPlatformHome.java +++ b/test/nuts-runtime-test/src/test/java/net/thevpc/nuts/core/test/Test41_NPlatformHome.java @@ -2,10 +2,6 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.core.test.utils.TestUtils; -import net.thevpc.nuts.env.NOsFamily; -import net.thevpc.nuts.env.NPlatformFamily; -import net.thevpc.nuts.env.NPlatformHome; -import net.thevpc.nuts.env.NStoreType; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -25,7 +21,7 @@ public void test01() { @Test public void test02() { - NPlatformLocation z = NPlatforms.of().findPlatformByVersion(NPlatformFamily.JAVA, "[1.8,6]").orNull(); + NPlatformLocation z = NWorkspace.get().findPlatformByVersion(NPlatformFamily.JAVA, "[1.8,6]").orNull(); System.out.println(z); } diff --git a/third-party-companions/ndb/src/main/java/net/thevpc/nuts/toolbox/ndb/base/NdbSupportBase.java b/third-party-companions/ndb/src/main/java/net/thevpc/nuts/toolbox/ndb/base/NdbSupportBase.java index 54117913d..27a5d41cc 100644 --- a/third-party-companions/ndb/src/main/java/net/thevpc/nuts/toolbox/ndb/base/NdbSupportBase.java +++ b/third-party-companions/ndb/src/main/java/net/thevpc/nuts/toolbox/ndb/base/NdbSupportBase.java @@ -4,7 +4,7 @@ import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NStoreType; +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.util.NConnexionString; import net.thevpc.nuts.util.NRef; diff --git a/third-party-companions/ndb/src/main/java/net/thevpc/nuts/toolbox/ndb/sql/derby/DerbyService.java b/third-party-companions/ndb/src/main/java/net/thevpc/nuts/toolbox/ndb/sql/derby/DerbyService.java index f7d53590b..d25eec2dc 100644 --- a/third-party-companions/ndb/src/main/java/net/thevpc/nuts/toolbox/ndb/sql/derby/DerbyService.java +++ b/third-party-companions/ndb/src/main/java/net/thevpc/nuts/toolbox/ndb/sql/derby/DerbyService.java @@ -26,9 +26,7 @@ package net.thevpc.nuts.toolbox.ndb.sql.derby; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NEnvs; -import net.thevpc.nuts.env.NLocations; -import net.thevpc.nuts.env.NStoreType; +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.log.NLog; import net.thevpc.nuts.log.NLogVerb; @@ -154,7 +152,7 @@ private Path download(String id, Path folder, boolean optional) { } public Set findVersions() { - NId java = NEnvs.of().getPlatform(); + NId java = NWorkspace.get().getPlatform(); List all = NSearchCmd.of().addId("org.apache.derby:derbynet").setDistinct(true) .setIdFilter( (java.getVersion().compareTo("1.9") < 0) ? NVersionFilters.of().byValue("[,10.15.1.3[").get().to(NIdFilter.class) : @@ -175,7 +173,7 @@ public NExecCmd command(NDerbyConfig options) { List executorOptions = new ArrayList<>(); String currentDerbyVersion = options.getDerbyVersion(); if (currentDerbyVersion == null) { - NId java = NEnvs.of().getPlatform(); + NId java = NWorkspace.get().getPlatform(); NId best = NSearchCmd.of().addId("org.apache.derby:derbynet").setDistinct(true).setLatest(true) .setIdFilter( (java.getVersion().compareTo("1.9") < 0) ? NVersionFilters.of().byValue("[,10.15.1.3[").get().to(NIdFilter.class) : @@ -196,7 +194,7 @@ public NExecCmd command(NDerbyConfig options) { } NPath derbyDataHomeRoot = derbyDataHome.getParent(); derbyDataHome.mkdirs(); - Path derbyBinHome = NLocations.of().getStoreLocation(NApp.of().getId().get(), NStoreType.BIN).resolve(currentDerbyVersion).toPath().get(); + Path derbyBinHome = NWorkspace.get().getStoreLocation(NApp.of().getId().get(), NStoreType.BIN).resolve(currentDerbyVersion).toPath().get(); Path derbyLibHome = derbyBinHome.resolve("lib"); Path derby = download("org.apache.derby:derby#" + currentDerbyVersion, derbyLibHome, false); Path derbynet = download("org.apache.derby:derbynet#" + currentDerbyVersion, derbyLibHome, false); diff --git a/third-party-companions/ndb/src/main/java/net/thevpc/nuts/toolbox/ndb/sql/nmysql/NMySqlService.java b/third-party-companions/ndb/src/main/java/net/thevpc/nuts/toolbox/ndb/sql/nmysql/NMySqlService.java index 2dc3e3020..df3d0de6d 100644 --- a/third-party-companions/ndb/src/main/java/net/thevpc/nuts/toolbox/ndb/sql/nmysql/NMySqlService.java +++ b/third-party-companions/ndb/src/main/java/net/thevpc/nuts/toolbox/ndb/sql/nmysql/NMySqlService.java @@ -2,7 +2,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.elem.NEDesc; -import net.thevpc.nuts.env.NStoreType; +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.toolbox.ndb.sql.nmysql.local.LocalMysqlConfigService; import net.thevpc.nuts.toolbox.ndb.sql.nmysql.local.config.LocalMysqlConfig; diff --git a/third-party-companions/ndb/src/main/java/net/thevpc/nuts/toolbox/ndb/sql/nmysql/local/LocalMysqlConfigService.java b/third-party-companions/ndb/src/main/java/net/thevpc/nuts/toolbox/ndb/sql/nmysql/local/LocalMysqlConfigService.java index 2de56a836..c08214c84 100644 --- a/third-party-companions/ndb/src/main/java/net/thevpc/nuts/toolbox/ndb/sql/nmysql/local/LocalMysqlConfigService.java +++ b/third-party-companions/ndb/src/main/java/net/thevpc/nuts/toolbox/ndb/sql/nmysql/local/LocalMysqlConfigService.java @@ -2,7 +2,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NStoreType; +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.toolbox.ndb.sql.nmysql.NMySqlConfigVersions; import net.thevpc.nuts.toolbox.ndb.sql.nmysql.local.config.LocalMysqlDatabaseConfig; diff --git a/third-party-companions/ndb/src/main/java/net/thevpc/nuts/toolbox/ndb/sql/nmysql/remote/RemoteMysqlConfigService.java b/third-party-companions/ndb/src/main/java/net/thevpc/nuts/toolbox/ndb/sql/nmysql/remote/RemoteMysqlConfigService.java index bf5b3f0cc..670917ba6 100644 --- a/third-party-companions/ndb/src/main/java/net/thevpc/nuts/toolbox/ndb/sql/nmysql/remote/RemoteMysqlConfigService.java +++ b/third-party-companions/ndb/src/main/java/net/thevpc/nuts/toolbox/ndb/sql/nmysql/remote/RemoteMysqlConfigService.java @@ -2,7 +2,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NStoreType; +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.toolbox.ndb.sql.nmysql.NMySqlConfigVersions; import net.thevpc.nuts.toolbox.ndb.sql.nmysql.remote.config.RemoteMysqlConfig; diff --git a/third-party-companions/ndocusaurus/src/main/java/net/thevpc/nuts/toolbox/docusaurus/NDocusaurusMain.java b/third-party-companions/ndocusaurus/src/main/java/net/thevpc/nuts/toolbox/docusaurus/NDocusaurusMain.java index 61d3c2774..fc6ba88f6 100644 --- a/third-party-companions/ndocusaurus/src/main/java/net/thevpc/nuts/toolbox/docusaurus/NDocusaurusMain.java +++ b/third-party-companions/ndocusaurus/src/main/java/net/thevpc/nuts/toolbox/docusaurus/NDocusaurusMain.java @@ -5,7 +5,7 @@ import net.thevpc.nuts.cmdline.NCmdLineRunner; import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NBootManager; + import net.thevpc.nuts.util.NMsg; import java.nio.file.Paths; @@ -79,7 +79,7 @@ public void run(NCmdLine cmdLine, NCmdLineContext context) { .setBuildWebSite(build) .setStartWebSite(start) .setBuildPdf(buildPdf) - .setAutoInstallNutsPackages(NBootManager.of().getBootOptions().getConfirm().orElse(NConfirmationMode.ASK) == NConfirmationMode.YES) + .setAutoInstallNutsPackages(NWorkspace.get().getBootOptions().getConfirm().orElse(NConfirmationMode.ASK) == NConfirmationMode.YES) .run(); } }); diff --git a/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/NTomcatMain.java b/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/NTomcatMain.java index bcfdd418c..f449dbbff 100644 --- a/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/NTomcatMain.java +++ b/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/NTomcatMain.java @@ -15,10 +15,10 @@ public static void main(String[] args) { @Override public void run() { - NRepository apacheRepo = NRepositories.of().findRepository("apache-tomcat").orNull(); + NRepository apacheRepo = NWorkspace.get().findRepository("apache-tomcat").orNull(); NSession session = NSession.of().get(); if (apacheRepo == null) { - NRepositories.of().addRepository( + NWorkspace.get().addRepository( new NAddRepositoryOptions() .setRepositoryModel(new ApacheTomcatRepositoryModel(session.getWorkspace())) .setTemporary(true) diff --git a/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/local/LocalTomcat.java b/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/local/LocalTomcat.java index a02e04b96..d57c31ff5 100644 --- a/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/local/LocalTomcat.java +++ b/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/local/LocalTomcat.java @@ -5,7 +5,7 @@ import net.thevpc.nuts.cmdline.NCmdLine; import net.thevpc.nuts.elem.NEDesc; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NStoreType; +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.format.NObjectFormat; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.io.NPrintStream; diff --git a/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/local/LocalTomcatAppConfigService.java b/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/local/LocalTomcatAppConfigService.java index f56bd8aa7..1d153acc4 100644 --- a/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/local/LocalTomcatAppConfigService.java +++ b/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/local/LocalTomcatAppConfigService.java @@ -2,7 +2,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NStoreType; +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NCp; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.io.NPathOption; diff --git a/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/local/LocalTomcatConfigService.java b/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/local/LocalTomcatConfigService.java index 51ef70169..976eeaf47 100644 --- a/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/local/LocalTomcatConfigService.java +++ b/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/local/LocalTomcatConfigService.java @@ -3,9 +3,9 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.elem.NEDesc; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NEnvConditionBuilder; -import net.thevpc.nuts.env.NEnvs; -import net.thevpc.nuts.env.NStoreType; +import net.thevpc.nuts.NEnvConditionBuilder; + +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.format.NObjectFormat; import net.thevpc.nuts.io.*; import net.thevpc.nuts.text.NText; @@ -18,7 +18,7 @@ import net.thevpc.nuts.toolbox.ntomcat.util.*; import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.util.NMsg; -import net.thevpc.nuts.env.NOsFamily; +import net.thevpc.nuts.NOsFamily; import net.thevpc.nuts.util.NPredicate; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -317,7 +317,7 @@ public boolean buildCatalinaBase() { NPath catalinaBase = getCatalinaBase(); boolean catalinaBaseUpdated = false; catalinaBaseUpdated |= mkdirs(catalinaBase); - String ext = NEnvs.of().getOsFamily() == NOsFamily.WINDOWS ? "bat" : "sh"; + String ext = NWorkspace.get().getOsFamily() == NOsFamily.WINDOWS ? "bat" : "sh"; catalinaBaseUpdated |= checkExec(catalinaHome.resolve("bin").resolve("catalina." + ext)); LocalTomcatConfig c = getConfig(); catalinaBaseUpdated |= mkdirs(catalinaBase.resolve("logs")); @@ -374,7 +374,7 @@ public NExecCmd invokeCatalina(String catalinaCommand) { NPath catalinaHome = getCatalinaHome(); NPath catalinaBase = getCatalinaBase(); NSession session = getSession(); - String ext = NEnvs.of().getOsFamily() == NOsFamily.WINDOWS ? "bat" : "sh"; + String ext = NWorkspace.get().getOsFamily() == NOsFamily.WINDOWS ? "bat" : "sh"; //b. // b.setOutput(context.getSession().out()); @@ -496,7 +496,7 @@ private NDefinition getCatalinaNutsDefinition() { catalinaVersion = catalinaVersion.trim(); NSession session = getSession(); if (catalinaVersion.isEmpty()) { - NVersion javaVersion = NEnvs.of().getPlatform().getVersion(); + NVersion javaVersion = NWorkspace.get().getPlatform().getVersion(); // http://tomcat.apache.org/whichversion.html if (javaVersion.compareTo("1.8") >= 0) { catalinaVersion = "[9,10.1["; @@ -524,7 +524,7 @@ private NDefinition getCatalinaNutsDefinition() { String cid="org.apache.catalina:apache-tomcat";//+"#"+cv; cid= NIdBuilder.of().setAll(NId.of(cid).get()).setCondition( NEnvConditionBuilder.of() - .addPlatform(NEnvs.of().getPlatform().toString()) + .addPlatform(NWorkspace.get().getPlatform().toString()) ).toString(); NSearchCmd searchLatestCommand = NSearchCmd.of().addId(cid) diff --git a/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/remote/RemoteTomcat.java b/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/remote/RemoteTomcat.java index 9c26d18a2..08859dc1f 100644 --- a/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/remote/RemoteTomcat.java +++ b/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/remote/RemoteTomcat.java @@ -4,7 +4,7 @@ import net.thevpc.nuts.cmdline.NArg; import net.thevpc.nuts.cmdline.NCmdLine; import net.thevpc.nuts.elem.NEDesc; -import net.thevpc.nuts.env.NStoreType; +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.text.NText; import net.thevpc.nuts.text.NTextStyle; diff --git a/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/remote/RemoteTomcatConfigService.java b/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/remote/RemoteTomcatConfigService.java index edc5c1e77..3bce3a912 100644 --- a/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/remote/RemoteTomcatConfigService.java +++ b/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/remote/RemoteTomcatConfigService.java @@ -2,7 +2,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NStoreType; +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.io.NPrintStream; import net.thevpc.nuts.toolbox.ntomcat.NTomcatConfigVersions; diff --git a/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/util/ApacheTomcatRepositoryModel.java b/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/util/ApacheTomcatRepositoryModel.java index f6d95defa..732a5ef3b 100644 --- a/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/util/ApacheTomcatRepositoryModel.java +++ b/third-party-companions/ntomcat/src/main/java/net/thevpc/nuts/toolbox/ntomcat/util/ApacheTomcatRepositoryModel.java @@ -2,8 +2,8 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.elem.NEDesc; -import net.thevpc.nuts.env.NEnvConditionBuilder; -import net.thevpc.nuts.env.NLocations; +import net.thevpc.nuts.NEnvConditionBuilder; + import net.thevpc.nuts.io.NCp; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.io.NPathOption; @@ -214,10 +214,9 @@ private String getUrl(NVersion version, String extension) { } public String getIdLocalFile(NId id, NFetchMode fetchMode, NRepository repository) { - NSession session = workspace.currentSession(); return repository.config().getStoreLocation() - .resolve(NLocations.of().getDefaultIdBasedir(id)) - .resolve(NLocations.of().getDefaultIdFilename(id)) + .resolve(NWorkspace.get().getDefaultIdBasedir(id)) + .resolve(NWorkspace.get().getDefaultIdFilename(id)) .toString(); } diff --git a/toolbox/ncode/src/main/java/net/thevpc/nuts/toolbox/ncode/NCodeMain.java b/toolbox/ncode/src/main/java/net/thevpc/nuts/toolbox/ncode/NCodeMain.java index 3d0c40e71..89c0d1539 100644 --- a/toolbox/ncode/src/main/java/net/thevpc/nuts/toolbox/ncode/NCodeMain.java +++ b/toolbox/ncode/src/main/java/net/thevpc/nuts/toolbox/ncode/NCodeMain.java @@ -6,6 +6,8 @@ package net.thevpc.nuts.toolbox.ncode; import net.thevpc.nuts.*; +import net.thevpc.nuts.cmdline.NArg; +import net.thevpc.nuts.cmdline.NCmdLine; /** * @author thevpc diff --git a/toolbox/njob/src/main/java/net/thevpc/nuts/toolbox/njob/JobAutoCompleter.java b/toolbox/njob/src/main/java/net/thevpc/nuts/toolbox/njob/JobAutoCompleter.java index 70542d53c..843d177f6 100644 --- a/toolbox/njob/src/main/java/net/thevpc/nuts/toolbox/njob/JobAutoCompleter.java +++ b/toolbox/njob/src/main/java/net/thevpc/nuts/toolbox/njob/JobAutoCompleter.java @@ -32,7 +32,7 @@ import net.thevpc.nuts.cmdline.NArgCandidate; import net.thevpc.nuts.cmdline.NCmdLine; import net.thevpc.nuts.cmdline.NCmdLineAutoCompleteResolver; -import net.thevpc.nuts.env.NEnvs; + /** * @@ -47,7 +47,7 @@ public JobAutoCompleter(NWorkspace workspace) { @Override public List resolveCandidates(NCmdLine cmdLine, int wordIndex) { NSession session=workspace.currentSession(); - JobServiceCmd fileContext = (JobServiceCmd) NEnvs.of().getProperties().get(JobServiceCmd.class.getName()); + JobServiceCmd fileContext = (JobServiceCmd) NWorkspace.get().getProperties().get(JobServiceCmd.class.getName()); DefaultNCmdLineAutoComplete autoComplete = new DefaultNCmdLineAutoComplete() .setCurrentWordIndex(wordIndex) .setLine(cmdLine.toString()).setWords( diff --git a/toolbox/njob/src/main/java/net/thevpc/nuts/toolbox/njob/JobServiceCmd.java b/toolbox/njob/src/main/java/net/thevpc/nuts/toolbox/njob/JobServiceCmd.java index a6827325c..4f6105b76 100644 --- a/toolbox/njob/src/main/java/net/thevpc/nuts/toolbox/njob/JobServiceCmd.java +++ b/toolbox/njob/src/main/java/net/thevpc/nuts/toolbox/njob/JobServiceCmd.java @@ -3,7 +3,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.cmdline.NCmdLine; import net.thevpc.nuts.cmdline.NCmdLineHistory; -import net.thevpc.nuts.env.NEnvs; + import net.thevpc.nuts.io.NIO; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.io.NSystemTerminal; @@ -309,7 +309,7 @@ public void runInteractive(NCmdLine cmdLine) { NCmdLineHistory.of() .setPath(NApp.of().getVarFolder().resolve("njob-history.hist")) ); - NEnvs.of().setProperty(JobServiceCmd.class.getName(), this); + NWorkspace.get().setProperty(JobServiceCmd.class.getName(), this); // session.setTerminal( // session.io().term().createTerminal( diff --git a/toolbox/njob/src/main/java/net/thevpc/nuts/toolbox/njob/NJobConfigStore.java b/toolbox/njob/src/main/java/net/thevpc/nuts/toolbox/njob/NJobConfigStore.java index e325e48d6..55931cd42 100644 --- a/toolbox/njob/src/main/java/net/thevpc/nuts/toolbox/njob/NJobConfigStore.java +++ b/toolbox/njob/src/main/java/net/thevpc/nuts/toolbox/njob/NJobConfigStore.java @@ -3,7 +3,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.elem.NEDesc; import net.thevpc.nuts.elem.NElements; -import net.thevpc.nuts.env.NStoreType; +import net.thevpc.nuts.NStoreType; import net.thevpc.nuts.io.NPath; import net.thevpc.nuts.toolbox.njob.model.Id; import net.thevpc.nuts.toolbox.njob.model.NJob; diff --git a/toolbox/nserver/src/main/java/net/thevpc/nuts/toolbox/nutsserver/admin/NAdminServerComponent.java b/toolbox/nserver/src/main/java/net/thevpc/nuts/toolbox/nutsserver/admin/NAdminServerComponent.java index 74dd56435..2d95522c8 100644 --- a/toolbox/nserver/src/main/java/net/thevpc/nuts/toolbox/nutsserver/admin/NAdminServerComponent.java +++ b/toolbox/nserver/src/main/java/net/thevpc/nuts/toolbox/nutsserver/admin/NAdminServerComponent.java @@ -26,7 +26,7 @@ package net.thevpc.nuts.toolbox.nutsserver.admin; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NLocations; + import net.thevpc.nuts.io.NPrintStream; import net.thevpc.nuts.spi.NSupportLevelContext; import net.thevpc.nuts.text.NTextStyle; @@ -95,7 +95,7 @@ public NServer start(ServerConfig config) { NPrintStream out = session.out(); NTexts factory = NTexts.of(); out.println((NMsg.ofC("Nuts Admin Service '%s' running %s at %s", serverId, factory.ofStyled("telnet nsh", NTextStyle.primary1()), inetSocketAddress))); - out.println((NMsg.ofC("Serving workspace : %s", NLocations.of().getWorkspaceLocation()))); + out.println((NMsg.ofC("Serving workspace : %s", NWorkspace.get().getWorkspaceLocation()))); AdminServerRunnable myNutsServer = new AdminServerRunnable(serverId, port, backlog, address, executor, session, session); executor.execute(myNutsServer); diff --git a/toolbox/nserver/src/main/java/net/thevpc/nuts/toolbox/nutsserver/http/NHttpServerComponent.java b/toolbox/nserver/src/main/java/net/thevpc/nuts/toolbox/nutsserver/http/NHttpServerComponent.java index 7f6e86a3f..3069eb329 100644 --- a/toolbox/nserver/src/main/java/net/thevpc/nuts/toolbox/nutsserver/http/NHttpServerComponent.java +++ b/toolbox/nserver/src/main/java/net/thevpc/nuts/toolbox/nutsserver/http/NHttpServerComponent.java @@ -28,7 +28,7 @@ import com.sun.net.httpserver.*; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NLocations; + import net.thevpc.nuts.io.NIOException; import net.thevpc.nuts.io.NPrintStream; import net.thevpc.nuts.spi.NSupportLevelContext; @@ -250,9 +250,9 @@ public void handle(final HttpExchange httpExchange) { NWorkspace ws2 = entry.getValue(); ws2.runWith(() -> { if ("".equals(k)) { - out.println(NLocations.of().getWorkspaceLocation()); + out.println(NWorkspace.get().getWorkspaceLocation()); } else { - out.println((NMsg.ofC("%s : %s", k, NLocations.of().getWorkspaceLocation()))); + out.println((NMsg.ofC("%s : %s", k, NWorkspace.get().getWorkspaceLocation()))); } }); } @@ -262,7 +262,7 @@ public void handle(final HttpExchange httpExchange) { String k = NStringUtils.firstNonBlank(entry.getKey(), ""); NWorkspace ws2 = entry.getValue(); ws2.runWith(() -> { - out.println(NMsg.ofC("\t%s : %s", k, NLocations.of().getWorkspaceLocation())); + out.println(NMsg.ofC("\t%s : %s", k, NWorkspace.get().getWorkspaceLocation())); }); } } diff --git a/toolbox/nserver/src/main/java/net/thevpc/nuts/toolbox/nutsserver/http/commands/DeployFacadeCommand.java b/toolbox/nserver/src/main/java/net/thevpc/nuts/toolbox/nutsserver/http/commands/DeployFacadeCommand.java index 0987cff91..94162e6df 100644 --- a/toolbox/nserver/src/main/java/net/thevpc/nuts/toolbox/nutsserver/http/commands/DeployFacadeCommand.java +++ b/toolbox/nserver/src/main/java/net/thevpc/nuts/toolbox/nutsserver/http/commands/DeployFacadeCommand.java @@ -1,7 +1,7 @@ package net.thevpc.nuts.toolbox.nutsserver.http.commands; import net.thevpc.nuts.*; -import net.thevpc.nuts.env.NLocations; + import net.thevpc.nuts.io.NCp; import net.thevpc.nuts.io.NDigest; import net.thevpc.nuts.io.NPath; @@ -57,7 +57,7 @@ public void executeImpl(FacadeCommandContext context) throws IOException { case "content": contentFile = NPath .ofTempFile( - NLocations.of().getDefaultIdFilename( + NWorkspace.get().getDefaultIdFilename( descriptor.getId().builder().setFaceDescriptor().build() )).toString(); NCp.of() diff --git a/tutorials/naf/remote-self-call-example/src/main/java/net/thevpc/nuts/tutorial/remoteselfcallexample/RemoteSelfCallApp.java b/tutorials/naf/remote-self-call-example/src/main/java/net/thevpc/nuts/tutorial/remoteselfcallexample/RemoteSelfCallApp.java index 9d4f869cc..8178e88a2 100644 --- a/tutorials/naf/remote-self-call-example/src/main/java/net/thevpc/nuts/tutorial/remoteselfcallexample/RemoteSelfCallApp.java +++ b/tutorials/naf/remote-self-call-example/src/main/java/net/thevpc/nuts/tutorial/remoteselfcallexample/RemoteSelfCallApp.java @@ -2,7 +2,7 @@ import net.thevpc.nuts.*; import net.thevpc.nuts.cmdline.NCmdLine; -import net.thevpc.nuts.env.NEnvs; + import net.thevpc.nuts.util.NBlankable; import net.thevpc.nuts.util.NMsg; import net.thevpc.nuts.util.NStringUtils; @@ -97,7 +97,7 @@ public void run() { NStringUtils.toStringOrEmpty(NApp.of().getId().orNull()), "--on-call-self" ) - .addCommand("from=" + NEnvs.of().getHostName()) + .addCommand("from=" + NWorkspace.get().getHostName()) .addCommand(options.nonOptions) .failFast() .getGrabbedAllString() @@ -119,7 +119,7 @@ public void run() { private void log(NMsg m) { NSession session = NSession.get(); - String hostName = NEnvs.of().getHostName(); + String hostName = NWorkspace.get().getHostName(); session.out().println(NMsg.ofC("[%s] %s", hostName, m)); }