Improve demo initialisation.
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / internal / kernel / InitUtils.java
index a4892503d3b0c64e73363bf958105b063e042d2c..ef6a267c6e85150c1e566905412ec8066436537d 100644 (file)
@@ -68,6 +68,8 @@ class InitUtils {
                /// TODO make it more generic
                String httpHost = getFrameworkProp(HttpConstants.JETTY_PROPERTY_PREFIX + HttpConstants.HTTP_HOST);
                String httpsHost = getFrameworkProp(HttpConstants.JETTY_PROPERTY_PREFIX + HttpConstants.HTTPS_HOST);
+               String webSocketEnabled = getFrameworkProp(
+                               HttpConstants.JETTY_PROPERTY_PREFIX + HttpConstants.WEB_SOCKET_ENABLED);
 
                final Hashtable<String, Object> props = new Hashtable<String, Object>();
                // try {
@@ -101,6 +103,10 @@ class InitUtils {
                        if (httpsHost != null)
                                props.put(HttpConstants.HTTPS_HOST, httpHost);
 
+                       if (webSocketEnabled != null)
+                               if (webSocketEnabled.equals("true"))
+                                       props.put(HttpConstants.WEB_SOCKET_ENABLED, true);
+
                        props.put(NodeConstants.CN, NodeConstants.DEFAULT);
                }
                return props;
@@ -151,12 +157,15 @@ class InitUtils {
                        String demoBaseDn = "dc=example,dc=com";
                        userAdminUris = demoBaseDn + ".ldif";
                        File businessRolesFile = new File(nodeBaseDir, userAdminUris);
+                       File systemRolesFile = new File(nodeBaseDir, "ou=roles,ou=node.ldif");
                        if (!businessRolesFile.exists())
                                try {
                                        FileUtils.copyInputStreamToFile(InitUtils.class.getResourceAsStream(demoBaseDn + ".ldif"),
                                                        businessRolesFile);
+                                       FileUtils.copyInputStreamToFile(
+                                                       InitUtils.class.getResourceAsStream("example-ou=roles,ou=node.ldif"), systemRolesFile);
                                } catch (IOException e) {
-                                       throw new CmsException("Cannot copy demo resource", e);
+                                       throw new CmsException("Cannot copy demo resources", e);
                                }
                        // userAdminUris = businessRolesFile.toURI().toString();
                        log.warn("## DEV Using dummy base DN " + demoBaseDn);