From a61a938100ef882c56104e4eb4ea18f7c786c3bc Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Mon, 27 Jun 2022 18:56:34 +0200 Subject: [PATCH] Improve initialisation. --- .../servlet/internal/jetty/JettyConfig.java | 14 + .../internal/jetty/JettyServiceFactory.java | 1 + org.argeo.cms/OSGI-INF/cmsDeployment.xml | 2 +- org.argeo.cms/OSGI-INF/cmsUserManager.xml | 3 +- .../cms/acr/AbstractContentRepository.java | 12 +- .../org/argeo/cms/acr/CmsContentTypes.java | 2 - .../argeo/cms/acr/schemas/xhtml11-model-1.xsd | 716 ------------------ .../cms/acr/schemas/xhtml11-modules-1.xsd | 605 --------------- .../src/org/argeo/cms/acr/schemas/xhtml11.xsd | 104 --- .../cms/internal/auth/CmsUserManagerImpl.java | 47 +- .../argeo/cms/internal/osgi/DeployConfig.java | 1 + .../internal/runtime/CmsDeploymentImpl.java | 26 +- .../cms/internal/runtime/CmsStateImpl.java | 20 +- .../cms/internal/runtime/CmsUserAdmin.java | 1 + .../runtime/DeployedContentRepository.java | 8 +- .../src/org/argeo/cms/runtime/StaticCms.java | 8 +- 16 files changed, 100 insertions(+), 1470 deletions(-) delete mode 100644 org.argeo.cms/src/org/argeo/cms/acr/schemas/xhtml11-model-1.xsd delete mode 100644 org.argeo.cms/src/org/argeo/cms/acr/schemas/xhtml11-modules-1.xsd delete mode 100644 org.argeo.cms/src/org/argeo/cms/acr/schemas/xhtml11.xsd diff --git a/eclipse/org.argeo.cms.servlet/src/org/argeo/cms/servlet/internal/jetty/JettyConfig.java b/eclipse/org.argeo.cms.servlet/src/org/argeo/cms/servlet/internal/jetty/JettyConfig.java index 026993eab..ad93fad61 100644 --- a/eclipse/org.argeo.cms.servlet/src/org/argeo/cms/servlet/internal/jetty/JettyConfig.java +++ b/eclipse/org.argeo.cms.servlet/src/org/argeo/cms/servlet/internal/jetty/JettyConfig.java @@ -70,6 +70,20 @@ public class JettyConfig { }; serverSt.open(); + + // check initialisation +// ServiceTracker httpSt = new ServiceTracker(bc, HttpService.class, null) { +// +// @Override +// public HttpService addingService(ServiceReference sr) { +// Object httpPort = sr.getProperty("http.port"); +// Object httpsPort = sr.getProperty("https.port"); +// log.info(httpPortsMsg(httpPort, httpsPort)); +// close(); +// return super.addingService(sr); +// } +// }; +// httpSt.open(); } public void stop() { diff --git a/eclipse/org.argeo.cms.servlet/src/org/argeo/cms/servlet/internal/jetty/JettyServiceFactory.java b/eclipse/org.argeo.cms.servlet/src/org/argeo/cms/servlet/internal/jetty/JettyServiceFactory.java index f1d9216c2..005af743c 100644 --- a/eclipse/org.argeo.cms.servlet/src/org/argeo/cms/servlet/internal/jetty/JettyServiceFactory.java +++ b/eclipse/org.argeo.cms.servlet/src/org/argeo/cms/servlet/internal/jetty/JettyServiceFactory.java @@ -21,6 +21,7 @@ import org.osgi.service.cm.ConfigurationException; import org.osgi.service.cm.ManagedServiceFactory; import org.osgi.util.tracker.ServiceTracker; +@Deprecated public class JettyServiceFactory implements ManagedServiceFactory { private final static CmsLog log = CmsLog.getLog(JettyServiceFactory.class); diff --git a/org.argeo.cms/OSGI-INF/cmsDeployment.xml b/org.argeo.cms/OSGI-INF/cmsDeployment.xml index 5f5ed5fcc..8495daad7 100644 --- a/org.argeo.cms/OSGI-INF/cmsDeployment.xml +++ b/org.argeo.cms/OSGI-INF/cmsDeployment.xml @@ -1,5 +1,5 @@ - + diff --git a/org.argeo.cms/OSGI-INF/cmsUserManager.xml b/org.argeo.cms/OSGI-INF/cmsUserManager.xml index 2e8f868ae..d22660c9f 100644 --- a/org.argeo.cms/OSGI-INF/cmsUserManager.xml +++ b/org.argeo.cms/OSGI-INF/cmsUserManager.xml @@ -1,10 +1,9 @@ - + - diff --git a/org.argeo.cms/src/org/argeo/cms/acr/AbstractContentRepository.java b/org.argeo.cms/src/org/argeo/cms/acr/AbstractContentRepository.java index 8ff141698..26ba6be2a 100644 --- a/org.argeo.cms/src/org/argeo/cms/acr/AbstractContentRepository.java +++ b/org.argeo.cms/src/org/argeo/cms/acr/AbstractContentRepository.java @@ -52,6 +52,7 @@ public abstract class AbstractContentRepository implements ProvidedRepository { // public final static String ACR_MOUNT_PATH_PROPERTY = "acr.mount.path"; public AbstractContentRepository() { + long begin = System.currentTimeMillis(); // types typesManager = new TypesManager(); typesManager.init(); @@ -60,7 +61,8 @@ public abstract class AbstractContentRepository implements ProvidedRepository { for (QName type : types) { log.trace(type + " - " + typesManager.getAttributeTypes(type)); } - + long duration = System.currentTimeMillis() - begin; + log.debug(() -> "CMS content types available (initialisation took " + duration + " ms)"); } protected abstract CmsContentSession newSystemSession(); @@ -81,10 +83,14 @@ public abstract class AbstractContentRepository implements ProvidedRepository { */ @Override public void addProvider(ContentProvider provider) { - if (mountManager == null) + if (mountManager == null) { providersToAdd.add(provider); - else + log.debug( + () -> "Will add provider " + provider.getMountPath() + " (" + provider.getClass().getName() + ")"); + } else { mountManager.addStructuralContentProvider(provider); + log.debug(() -> "Added provider " + provider.getMountPath() + " (" + provider.getClass().getName() + ")"); + } } public void registerTypes(String prefix, String namespaceURI, String schemaSystemId) { diff --git a/org.argeo.cms/src/org/argeo/cms/acr/CmsContentTypes.java b/org.argeo.cms/src/org/argeo/cms/acr/CmsContentTypes.java index 6a09a8987..3f8fd9568 100644 --- a/org.argeo.cms/src/org/argeo/cms/acr/CmsContentTypes.java +++ b/org.argeo.cms/src/org/argeo/cms/acr/CmsContentTypes.java @@ -30,8 +30,6 @@ public enum CmsContentTypes { SVG_1_1("svg", "http://www.w3.org/2000/svg", "SVG.xsd", "https://raw.githubusercontent.com/oreillymedia/HTMLBook/master/schema/svg/SVG.xsd"), // - XHTML_1_1("h", "http://www.w3.org/1999/xhtml", "xhtml11.xsd", "https://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd"), - // DOCBOOK_5_0_1("dbk", "http://docbook.org/ns/docbook", "docbook.xsd", "http://docbook.org/xml/5.0.1/xsd/docbook.xsd"), // diff --git a/org.argeo.cms/src/org/argeo/cms/acr/schemas/xhtml11-model-1.xsd b/org.argeo.cms/src/org/argeo/cms/acr/schemas/xhtml11-model-1.xsd deleted file mode 100644 index a1c138d84..000000000 --- a/org.argeo.cms/src/org/argeo/cms/acr/schemas/xhtml11-model-1.xsd +++ /dev/null @@ -1,716 +0,0 @@ - - - - - - This is the XML Schema module of common content models for XHTML11 - - $Id: xhtml11-model-1.xsd,v 1.9 2009/02/03 15:14:49 ahby Exp $ - - - - - - XHTML Document Model - This module describes the groupings of elements/attributes - that make up common content models for XHTML elements. - XHTML has following basic content models: - xhtml.Inline.mix; character-level elements - xhtml.Block.mix; block-like elements, e.g., paragraphs and lists - xhtml.Flow.mix; any block or inline elements - xhtml.HeadOpts.mix; Head Elements - xhtml.InlinePre.mix; Special class for pre content model - xhtml.InlineNoAnchor.mix; Content model for Anchor - - Any groups declared in this module may be used to create - element content models, but the above are considered 'global' - (insofar as that term applies here). XHTML has the - following Attribute Groups - xhtml.Core.extra.attrib - xhtml.I18n.extra.attrib - xhtml.Common.extra - - The above attribute Groups are considered Global - - - - - Extended I18n attribute - - - - - "dir" Attribute from Bi Directional Text (bdo) Module - - - - - - - - Extended Common Attributes - - - - - "style" attribute from Inline Style Module - - - - - - - Attributes from Events Module - - - - - - - Extend Core Attributes - - - - - Extended Global Core Attributes - - - - - Extended Global I18n attributes - - - - - Extended Global Common Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.argeo.cms/src/org/argeo/cms/acr/schemas/xhtml11-modules-1.xsd b/org.argeo.cms/src/org/argeo/cms/acr/schemas/xhtml11-modules-1.xsd deleted file mode 100644 index 676706760..000000000 --- a/org.argeo.cms/src/org/argeo/cms/acr/schemas/xhtml11-modules-1.xsd +++ /dev/null @@ -1,605 +0,0 @@ - - - - - - - This schema includes all modules for XHTML1.1 Document Type. - $Id: xhtml11-modules-1.xsd,v 1.10 2009/02/03 15:14:49 ahby Exp $ - - - - - - This schema includes all modules (and redefinitions) - for XHTML1.1 Document Type. - XHTML1.1 Document Type includes the following Modules - - XHTML Core modules (Required for XHTML Family Conformance) - + text - + hypertext - + lists - + structure - - Other XHTML modules - + Edit - + Bdo - + Presentational - + Link - + Meta - + Base - + Scripting - + Style - + Image - + Applet - + Object - + Param (Applet/Object modules require Param Module) - + Tables - + Target - + Forms - + Client side image maps - + Server side image maps - - - - - - - Schema Framework Component Modules: - + notations - + datatypes - + common attributes - + character entities - - - - - - - - Text module - - The Text module includes declarations for all core - text container elements and their attributes. - - + block phrasal - + block structural - + inline phrasal - + inline structural - - Elements defined here: - * address, blockquote, pre, h1, h2, h3, h4, h5, h6 - * div, p - * abbr, acronym, cite, code, dfn, em, kbd, q, samp, strong, var - * br, span - - - - - - - - Hypertext module - - Elements defined here: - * a - - - - - - - - - Redefinition by Client Side Image Map Module - - - - - - - Redefinition by XHTML Event Attribute Module - - - - - - - Target Module - A Attribute Additions - - - - - - - - - Lists module - - Elements defined here: - * dt, dd, dl, ol, ul, li - - - - - - - - Structural module - - Elements defined here: - * title, head, body, html - - - - - - - Redefinition by the XHTML11 Markup (for value of version attr) - - - - - - - - - Original Body Attlist - - - - - - - Redefinition by XHTML Event Attribute Module - - - - - - - - - Edit module - - Elements defined here: - * ins, del - - - - - - - - Bidirectional element module - - Elements defined here: - * bdo - - - - - - - - Presentational module - - Elements defined here: - * hr, b, big, i, small,sub, sup, tt - - - - - - - - Link module - - Elements defined here: - * link - - - - - - - Changes to XHTML Link Attlist - - - - - - Original Link Attributes (declared in Link Module) - - - - - - - XHTML Target Module - Attribute additions - - - - - - - - - Meta module - - Elements defined here: - * meta - - - - - - - - Base module - - Elements defined here: - * base - - - - - - - Changes to XHTML base Attlist - - - - - - Original Base Attributes (declared in Base Module) - - - - - - - XHTML Target Module - Attribute additions - - - - - - - - - Scripting module - - Elements defined here: - * script, noscript - - - - - - - - Style module - - Elements defined here: - * style - - - - - - - - Style attribute module - - Attribute defined here: - * style - - - - - - - - Image module - - Elements defined here: - * img - - - - - - - - Original Image Attributes (in Image Module) - - - - - - - Redefinition by Client Side Image Map Module - - - - - - - Redefinition by Server Side Image Module - - - - - - - - - Client-side mage maps module - - Elements defined here: - * area, map - - - - - - - - Original Area Attributes (in CSI Module) - - - - - - - Redefinition by Events Attribute Module - - - - - - - Target Module - Area Attribute Additions - - - - - - - - - Server-side image maps module - - Attributes defined here: - * ismap on img - - - - - - - - Object module - - Elements defined here: - * object - - - - - - - - Original Object Attlist - - - - - - - Redefinition by Client Image Map Module - - - - - - - - - Param module - - Elements defined here: - * param - - - - - - - Tables module - - Elements defined here: - * table, caption, thead, tfoot, tbody, colgroup, col, tr, th, td - - - - - - - - Forms module - - Elements defined here: - * form, label, input, select, optgroup, option, - * textarea, fieldset, legend, button - - - - - - - Changes to XHTML Form Attlist - - - - - - Original Form Attributes (declared in Forms Module) - - - - - - - XHTML Events Module - Attribute additions - - - - - - - XHTML Target Module - Attribute additions - - - - - - - - Changes to XHTML Form Input Element - - - - - - Original Input Attributes (in Forms Module) - - - - - - - Redefinition by Client Side Image Map Module - - - - - - - Redefinition by Server Side Image Map Module - - - - - - - Redefinition by Event Attribute Module - - - - - - - - - Original Label Attributes (in Forms Module) - - - - - - - Redefinition by Event Attribute Module - - - - - - - - - Original Select Attributes (in Forms Module) - - - - - - - Redefinition by Event Attribute Module - - - - - - - - - Original TextArea Attributes (in Forms Module) - - - - - - - Redefinition by Event Attribute Module - - - - - - - - - Original Button Attributes (in Forms Module) - - - - - - - Redefinition by Event Attribute Module - - - - - - - - - Ruby module - - Elements defined here: - * ruby, rbc, rtc, rb, rt, rp - - Note that either Ruby or Basic Ruby should be used but not both - - - - - - - - XHTML Events Modules - - Attributes defined here: - XHTML Event Types - - - - - - - - XHTML Target Attribute Module - - Attributes defined here: - target - - - - - diff --git a/org.argeo.cms/src/org/argeo/cms/acr/schemas/xhtml11.xsd b/org.argeo.cms/src/org/argeo/cms/acr/schemas/xhtml11.xsd deleted file mode 100644 index 341699935..000000000 --- a/org.argeo.cms/src/org/argeo/cms/acr/schemas/xhtml11.xsd +++ /dev/null @@ -1,104 +0,0 @@ - - - - - This is the XML Schema driver for XHTML 1.1. - Please use this namespace for XHTML elements: - - "http://www.w3.org/1999/xhtml" - - $Id: xhtml11.xsd,v 1.7 2009/02/03 15:14:49 ahby Exp $ - - - - - - This is XHTML, a reformulation of HTML as a modular XML application - The Extensible HyperText Markup Language (XHTML) - Copyright ©1998-2007 World Wide Web Consortium - (Massachusetts Institute of Technology, European Research Consortium - for Informatics and Mathematics, Keio University). - All Rights Reserved. - - Permission to use, copy, modify and distribute the XHTML Schema - modules and their accompanying xs:documentation for any purpose - and without fee is hereby granted in perpetuity, provided that the above - copyright notice and this paragraph appear in all copies. - The copyright holders make no representation about the suitability of - these XML Schema modules for any purpose. - - They are provided "as is" without expressed or implied warranty. - - - - - This is the Schema Driver file for XHTML1.1 - Document Type - - This schema - + imports external schemas (xml.xsd) - + refedines (and include)s schema modules for XHTML1.1 Document Type. - + includes Schema for Named content model for the - XHTML1.1 Document Type - - XHTML1.1 Document Type includes the following Modules - XHTML Core modules (Required for XHTML Family Conformance) - + text - + hypertext - + lists - + structure - Other XHTML modules - + Edit - + Bdo - + Presentational - + Link - + Meta - + Base - + Scripting - + Style - + Image - + Applet - + Object - + Param (Applet/Object modules require Param Module) - + Tables - + Forms - + Client side image maps - + Server side image maps - + Ruby - - - - - - This import brings in the XML namespace attributes - The XML attributes are used by various modules. - - - - - - - Document Model module for the XHTML1.1 Document Type. - This schema file defines all named models used by XHTML - Modularization Framework for XHTML1.1 Document Type - - - - - - - Schema that includes all modules (and redefinitions) - for XHTML1.1 Document Type. - - - - diff --git a/org.argeo.cms/src/org/argeo/cms/internal/auth/CmsUserManagerImpl.java b/org.argeo.cms/src/org/argeo/cms/internal/auth/CmsUserManagerImpl.java index 6e2c6c435..dfb0a56a2 100644 --- a/org.argeo.cms/src/org/argeo/cms/internal/auth/CmsUserManagerImpl.java +++ b/org.argeo.cms/src/org/argeo/cms/internal/auth/CmsUserManagerImpl.java @@ -8,12 +8,9 @@ import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.Dictionary; import java.util.HashMap; import java.util.HashSet; -import java.util.Hashtable; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.NavigableMap; @@ -31,6 +28,7 @@ import org.argeo.api.cms.CmsLog; import org.argeo.cms.CmsUserManager; import org.argeo.cms.auth.CurrentUser; import org.argeo.cms.auth.UserAdminUtils; +import org.argeo.osgi.useradmin.AggregatingUserAdmin; import org.argeo.osgi.useradmin.TokenUtils; import org.argeo.osgi.useradmin.UserDirectory; import org.argeo.util.directory.DirectoryConf; @@ -64,8 +62,18 @@ public class CmsUserManagerImpl implements CmsUserManager { // private Map serviceProperties; private WorkTransaction userTransaction; - private Map> userDirectories = Collections - .synchronizedMap(new LinkedHashMap<>()); +// private Map> userDirectories = Collections +// .synchronizedMap(new LinkedHashMap<>()); + + private Set userDirectories = new HashSet<>(); + + public void start() { + log.debug(() -> "CMS user manager available"); + } + + public void stop() { + + } @Override public String getMyMail() { @@ -230,7 +238,7 @@ public class CmsUserManagerImpl implements CmsUserManager { public Map getKnownBaseDns(boolean onlyWritable) { Map dns = new HashMap(); - for (UserDirectory userDirectory : userDirectories.keySet()) { + for (UserDirectory userDirectory : userDirectories) { Boolean readOnly = userDirectory.isReadOnly(); String baseDn = userDirectory.getContext(); @@ -240,7 +248,7 @@ public class CmsUserManagerImpl implements CmsUserManager { continue; if (baseDn.equalsIgnoreCase(CmsConstants.TOKENS_BASEDN)) continue; - dns.put(baseDn, DirectoryConf.propertiesAsUri(userDirectories.get(userDirectory)).toString()); + dns.put(baseDn, DirectoryConf.propertiesAsUri(userDirectory.getProperties()).toString()); } return dns; @@ -248,7 +256,7 @@ public class CmsUserManagerImpl implements CmsUserManager { public Set getUserDirectories() { TreeSet res = new TreeSet<>((o1, o2) -> o1.getContext().compareTo(o2.getContext())); - res.addAll(userDirectories.keySet()); + res.addAll(userDirectories); return res; } @@ -444,7 +452,7 @@ public class CmsUserManagerImpl implements CmsUserManager { public UserDirectory getDirectory(Role user) { String name = user.getName(); NavigableMap possible = new TreeMap<>(); - for (UserDirectory userDirectory : userDirectories.keySet()) { + for (UserDirectory userDirectory : userDirectories) { if (name.endsWith(userDirectory.getContext())) { possible.put(userDirectory.getContext(), userDirectory); } @@ -496,6 +504,13 @@ public class CmsUserManagerImpl implements CmsUserManager { /* DEPENDENCY INJECTION */ public void setUserAdmin(UserAdmin userAdmin) { this.userAdmin = userAdmin; + + if (userAdmin instanceof AggregatingUserAdmin) { + userDirectories = ((AggregatingUserAdmin) userAdmin).getUserDirectories(); + } else { + throw new IllegalArgumentException("Only " + AggregatingUserAdmin.class.getName() + " is supported."); + } + // this.serviceProperties = serviceProperties; } @@ -503,12 +518,12 @@ public class CmsUserManagerImpl implements CmsUserManager { this.userTransaction = userTransaction; } - public void addUserDirectory(UserDirectory userDirectory, Map properties) { - userDirectories.put(userDirectory, new Hashtable<>(properties)); - } - - public void removeUserDirectory(UserDirectory userDirectory, Map properties) { - userDirectories.remove(userDirectory); - } +// public void addUserDirectory(UserDirectory userDirectory, Map properties) { +// userDirectories.put(userDirectory, new Hashtable<>(properties)); +// } +// +// public void removeUserDirectory(UserDirectory userDirectory, Map properties) { +// userDirectories.remove(userDirectory); +// } } diff --git a/org.argeo.cms/src/org/argeo/cms/internal/osgi/DeployConfig.java b/org.argeo.cms/src/org/argeo/cms/internal/osgi/DeployConfig.java index 205ab35de..e5a504889 100644 --- a/org.argeo.cms/src/org/argeo/cms/internal/osgi/DeployConfig.java +++ b/org.argeo.cms/src/org/argeo/cms/internal/osgi/DeployConfig.java @@ -36,6 +36,7 @@ import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.cm.ConfigurationEvent; /** Manages the LDIF-based deployment configuration. */ +@Deprecated public class DeployConfig { private final CmsLog log = CmsLog.getLog(getClass()); diff --git a/org.argeo.cms/src/org/argeo/cms/internal/runtime/CmsDeploymentImpl.java b/org.argeo.cms/src/org/argeo/cms/internal/runtime/CmsDeploymentImpl.java index 5ba811c92..d01bc8554 100644 --- a/org.argeo.cms/src/org/argeo/cms/internal/runtime/CmsDeploymentImpl.java +++ b/org.argeo.cms/src/org/argeo/cms/internal/runtime/CmsDeploymentImpl.java @@ -1,13 +1,8 @@ package org.argeo.cms.internal.runtime; -import java.io.IOException; -import java.net.URL; -import java.util.Dictionary; - import org.argeo.api.cms.CmsDeployment; import org.argeo.api.cms.CmsLog; import org.argeo.api.cms.CmsState; -import org.argeo.cms.internal.osgi.DeployConfig; import org.osgi.service.http.HttpService; /** Implementation of a CMS deployment. */ @@ -26,6 +21,8 @@ public class CmsDeploymentImpl implements CmsDeployment { // if (deployConfig.hasDomain()) { // loadIpaJaasConfiguration(); // } + + log.debug(() -> "CMS deployment available"); } // public void addFactoryDeployConfig(String factoryPid, Dictionary props) { @@ -46,14 +43,14 @@ public class CmsDeploymentImpl implements CmsDeployment { return (httpExpected ? httpService != null : true); } - private void loadIpaJaasConfiguration() { - if (System.getProperty(KernelConstants.JAAS_CONFIG_PROP) == null) { - String jaasConfig = KernelConstants.JAAS_CONFIG_IPA; - URL url = getClass().getClassLoader().getResource(jaasConfig); - KernelUtils.setJaasConfiguration(url); - log.debug("Set IPA JAAS configuration."); - } - } +// private void loadIpaJaasConfiguration() { +// if (System.getProperty(KernelConstants.JAAS_CONFIG_PROP) == null) { +// String jaasConfig = KernelConstants.JAAS_CONFIG_IPA; +// URL url = getClass().getClassLoader().getResource(jaasConfig); +// KernelUtils.setJaasConfiguration(url); +// log.debug("Set IPA JAAS configuration."); +// } +// } public void stop() { // if (deployConfig != null) { @@ -67,6 +64,9 @@ public class CmsDeploymentImpl implements CmsDeployment { public void setCmsState(CmsState cmsState) { this.cmsState = cmsState; + String httpPort = this.cmsState.getDeployProperty("org.osgi.service.http.port"); + String httpsPort = this.cmsState.getDeployProperty("org.osgi.service.http.port.secure"); + httpExpected = httpPort != null || httpsPort != null; } public void setHttpService(HttpService httpService) { diff --git a/org.argeo.cms/src/org/argeo/cms/internal/runtime/CmsStateImpl.java b/org.argeo.cms/src/org/argeo/cms/internal/runtime/CmsStateImpl.java index ae85a2fc8..b3ef895f1 100644 --- a/org.argeo.cms/src/org/argeo/cms/internal/runtime/CmsStateImpl.java +++ b/org.argeo.cms/src/org/argeo/cms/internal/runtime/CmsStateImpl.java @@ -1,17 +1,23 @@ package org.argeo.cms.internal.runtime; +import java.io.IOException; +import java.io.InputStream; import java.net.InetAddress; import java.net.URL; import java.net.UnknownHostException; +import java.nio.file.Files; import java.nio.file.Path; +import java.util.TreeMap; import java.util.UUID; import javax.security.auth.login.Configuration; +import org.argeo.api.cms.CmsConstants; import org.argeo.api.cms.CmsLog; import org.argeo.api.cms.CmsState; import org.argeo.api.uuid.UuidFactory; import org.argeo.cms.auth.ident.IdentClient; +import org.argeo.util.directory.ldap.LdifParser; /** * Implementation of a {@link CmsState}, initialising the required services. @@ -54,10 +60,14 @@ public class CmsStateImpl implements CmsState { // (clean state) " : " ")); log.debug("## CMS starting... (" + uuid + ")"); + // initI18n(); // initServices(); + if (!Files.exists(getDataPath(CmsConstants.NODE))) {// first init + firstInit(); + } - } catch (RuntimeException e) { + } catch (RuntimeException | IOException e) { log.error("## FATAL: CMS activator failed", e); } } @@ -82,6 +92,12 @@ public class CmsStateImpl implements CmsState { log.info("## ARGEO CMS STOPPED after " + (duration / 60) + "h " + (duration % 60) + "min uptime ##"); } + private void firstInit() throws IOException { + log.info("## FIRST INIT ##"); + // FirstInit firstInit = new FirstInit(); + InitUtils.prepareFirstInitInstanceArea(); + } + @Override public String getDeployProperty(String key) { return KernelUtils.getFrameworkProp(key); @@ -89,7 +105,7 @@ public class CmsStateImpl implements CmsState { @Override public Path getDataPath(String relativePath) { - return KernelUtils.getOsgiInstancePath(relativePath); + return KernelUtils.getOsgiInstancePath(relativePath); } @Override diff --git a/org.argeo.cms/src/org/argeo/cms/internal/runtime/CmsUserAdmin.java b/org.argeo.cms/src/org/argeo/cms/internal/runtime/CmsUserAdmin.java index 18a880e31..e73d96f65 100644 --- a/org.argeo.cms/src/org/argeo/cms/internal/runtime/CmsUserAdmin.java +++ b/org.argeo.cms/src/org/argeo/cms/internal/runtime/CmsUserAdmin.java @@ -82,6 +82,7 @@ public class CmsUserAdmin extends AggregatingUserAdmin { if (userDirectory.getRealm().isPresent()) loadIpaJaasConfiguration(); } + log.debug(() -> "CMS user admin available"); } public void stop() { diff --git a/org.argeo.cms/src/org/argeo/cms/internal/runtime/DeployedContentRepository.java b/org.argeo.cms/src/org/argeo/cms/internal/runtime/DeployedContentRepository.java index 551062379..aa7d8f884 100644 --- a/org.argeo.cms/src/org/argeo/cms/internal/runtime/DeployedContentRepository.java +++ b/org.argeo.cms/src/org/argeo/cms/internal/runtime/DeployedContentRepository.java @@ -3,9 +3,8 @@ package org.argeo.cms.internal.runtime; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Map; -import org.argeo.api.acr.spi.ContentProvider; +import org.argeo.api.cms.CmsLog; import org.argeo.cms.CmsUserManager; import org.argeo.cms.acr.CmsContentRepository; import org.argeo.cms.acr.directory.DirectoryContentProvider; @@ -14,10 +13,13 @@ import org.argeo.cms.acr.fs.FsContentProvider; public class DeployedContentRepository extends CmsContentRepository { private final static String ROOT_XML = "cr:root.xml"; + private final static CmsLog log = CmsLog.getLog(DeployedContentRepository.class); + private CmsUserManager userManager; @Override public void start() { + long begin = System.currentTimeMillis(); try { super.start(); Path rootXml = KernelUtils.getOsgiInstancePath(ROOT_XML); @@ -40,6 +42,8 @@ public class DeployedContentRepository extends CmsContentRepository { } catch (IOException e) { throw new IllegalStateException("Cannot start content repository", e); } + long duration = System.currentTimeMillis()-begin; + log.debug(() -> "CMS content repository available (initialisation took "+duration+" ms)"); } @Override diff --git a/org.argeo.cms/src/org/argeo/cms/runtime/StaticCms.java b/org.argeo.cms/src/org/argeo/cms/runtime/StaticCms.java index 916a413a9..c88ebb8bd 100644 --- a/org.argeo.cms/src/org/argeo/cms/runtime/StaticCms.java +++ b/org.argeo.cms/src/org/argeo/cms/runtime/StaticCms.java @@ -93,10 +93,10 @@ public class StaticCms { // User manager CmsUserManagerImpl userManager = new CmsUserManagerImpl(); - for (UserDirectory userDirectory : userAdmin.getUserDirectories()) { - // FIXME deal with properties - userManager.addUserDirectory(userDirectory, new HashMap<>()); - } +// for (UserDirectory userDirectory : userAdmin.getUserDirectories()) { +// // FIXME deal with properties +// userManager.addUserDirectory(userDirectory, new HashMap<>()); +// } Component userManagerC = new Component.Builder<>(userManager) // .addType(CmsUserManager.class) // .addDependency(userAdminC.getType(UserAdmin.class), userManager::setUserAdmin, null) // -- 2.30.2