Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Work on automatic schema deployment, replaced bower gradle plugin with simple bower command calls

Christian Bauer73036a1cbe37
diff --git a/container/src/main/java/org/openremote/container/persistence/Database.java b/container/src/main/java/org/openremote/container/persistence/Database.java
index 14c71d364..c4fb1bafe 100644
--- a/container/src/main/java/org/openremote/container/persistence/Database.java
+++ b/container/src/main/java/org/openremote/container/persistence/Database.java
@@ -61,6 +61,7 @@ public interface Database {
hikariConfig.setThreadFactory(new ContainerThreadFactory("Database Connections"));
hikariConfig.setDataSourceClassName("org.postgresql.ds.PGSimpleDataSource");
hikariConfig.addDataSourceProperty("url", connectionUrl);
+ hikariConfig.addDataSourceProperty("currentSchema", "persistence");
hikariConfig.setUsername(username);
hikariConfig.setPassword(password);
hikariConfig.setConnectionTimeout(connectionTimeoutSeconds * 1000);
diff --git a/container/src/main/java/org/openremote/container/persistence/PersistenceService.java b/container/src/main/java/org/openremote/container/persistence/PersistenceService.java
index 8d0d42d4a..fedcba557 100644
--- a/container/src/main/java/org/openremote/container/persistence/PersistenceService.java
+++ b/container/src/main/java/org/openremote/container/persistence/PersistenceService.java
@@ -21,7 +21,6 @@ package org.openremote.container.persistence;
import org.flywaydb.core.Flyway;
import org.flywaydb.core.api.MigrationInfo;
-import org.flywaydb.core.api.MigrationVersion;
import org.hibernate.Session;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.openremote.container.Container;
@@ -32,7 +31,9 @@ import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
-import java.util.HashMap;
+import javax.ws.rs.core.UriBuilder;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -42,10 +43,22 @@ import java.util.logging.Logger;
import static org.openremote.container.util.MapAccess.getInteger;
import static org.openremote.container.util.MapAccess.getString;
+/**
+ * Uses the SQL database schema {@link #SCHEMA_NAME} for all operations.
+ */
public class PersistenceService implements ContainerService {
private static final Logger LOG = Logger.getLogger(PersistenceService.class.getName());
+ /**
+ * We must use a different schema than Keycloak to store our tables, or FlywayDB
+ * will wipe Keycloak tables. And since Keycloak doesn't call CREATE SCHEMA IF NOT EXISTS
+ * on startup (Liquibase is not as good as FlywayDB? They both seem to suck... can't exclude
+ * database artifacts from wipe/migrate in FlywayDB...) you must have it in the 'public'
+ * schema. Hence we need a different schema here.
+ */
+ public static final String SCHEMA_NAME = "openremote";
+
public static final String PERSISTENCE_UNIT_NAME = "PERSISTENCE_UNIT_NAME";
public static final String PERSISTENCE_UNIT_NAME_DEFAULT = "OpenRemotePU";
public static final String DATABASE_PRODUCT = "DATABASE_PRODUCT";
@@ -62,16 +75,16 @@ public class PersistenceService implements ContainerService {
public static final int DATABASE_MAX_POOL_SIZE_DEFAULT = 20;
public static final String DATABASE_CONNECTION_TIMEOUT_SECONDS = "DATABASE_CONNECTION_TIMEOUT_SECONDS";
public static final int DATABASE_CONNECTION_TIMEOUT_SECONDS_DEFAULT = 300;
- public static final String DATABASE_BASELINE = "DATABASE_BASELINE";
- public static final String DATABASE_BASELINE_DEFAULT = "1";
- public static final String DATABASE_BASELINE_DESCRIPTION = "<< OpenRemote BaseLine >>";
protected MessageBrokerService messageBrokerService;
protected Database database;
protected String persistenceUnitName;
protected Map<String, Object> persistenceUnitProperties;
protected EntityManagerFactory entityManagerFactory;
+
protected Flyway flyway;
+ protected boolean forceClean;
+ protected List<String> defaultSchemaLocations = new ArrayList<>();
@Override
public void init(Container container) throws Exception {
@@ -85,8 +98,6 @@ public class PersistenceService implements ContainerService {
persistenceUnitProperties = database.createProperties();
- openDatabase(container, database);
-
if (messageBrokerService != null) {
persistenceUnitProperties.put(
org.hibernate.cfg.AvailableSettings.SESSION_SCOPED_INTERCEPTOR,
@@ -99,6 +110,7 @@ public class PersistenceService implements ContainerService {
protected void openDatabase(Container container, Database database) {
String connectionUrl = getString(container.getConfig(), DATABASE_CONNECTION_URL, DATABASE_CONNECTION_URL_DEFAULT);
+ connectionUrl = UriBuilder.fromUri(connectionUrl).replaceQueryParam("currentSchema", SCHEMA_NAME).build().toString();
String databaseUsername = getString(container.getConfig(), DATABASE_USERNAME, DATABASE_USERNAME_DEFAULT);
String databasePassword = getString(container.getConfig(), DATABASE_PASSWORD, DATABASE_PASSWORD_DEFAULT);
int databaseMinPoolSize = getInteger(container.getConfig(), DATABASE_MIN_POOL_SIZE, DATABASE_MIN_POOL_SIZE_DEFAULT);
@@ -107,18 +119,12 @@ public class PersistenceService implements ContainerService {
LOG.info("Opening database connection: " + connectionUrl);
database.open(persistenceUnitProperties, connectionUrl, databaseUsername, databasePassword, connectionTimeoutSeconds, databaseMinPoolSize, databaseMaxPoolSize);
- String baselineVersion = getString(container.getConfig(), DATABASE_BASELINE, DATABASE_BASELINE_DEFAULT);
-
- flyway = new Flyway();
- flyway.setDataSource(connectionUrl, databaseUsername, databasePassword);
- flyway.setLocations("classpath:org/openremote/container/persistence/migrations");
- flyway.setBaselineVersion(MigrationVersion.fromVersion(baselineVersion));
- flyway.setBaselineDescription(DATABASE_BASELINE_DESCRIPTION);
- flyway.baseline();
+ prepareSchema(connectionUrl, databaseUsername, databasePassword);
}
@Override
public void start(Container container) throws Exception {
+ openDatabase(container, database);
this.entityManagerFactory =
Persistence.createEntityManagerFactory(persistenceUnitName, persistenceUnitProperties);
}
@@ -134,6 +140,13 @@ public class PersistenceService implements ContainerService {
}
}
+ public boolean isForceClean() {
+ return forceClean;
+ }
+
+ public void setForceClean(boolean forceClean) {
+ this.forceClean = forceClean;
+ }
public EntityManager createEntityManager() {
EntityManager entityManager = getEntityManagerFactory().createEntityManager();
@@ -150,23 +163,6 @@ public class PersistenceService implements ContainerService {
return entityManager;
}
- public void createSchema() {
-
- generateSchema("create");
- }
-
- public void updateSchema() {
- for (MigrationInfo i : flyway.info().all()) {
- LOG.info("Migrate task: " + i.getVersion() + " : "
- + i.getDescription() + " from file: " + i.getScript());
- }
- flyway.migrate();
- }
-
- public void dropSchema() {
- generateSchema("drop");
- }
-
public void doTransaction(Consumer<EntityManager> entityManagerConsumer) {
doReturningTransaction(entityManager -> {
entityManagerConsumer.accept(entityManager);
@@ -202,14 +198,36 @@ public class PersistenceService implements ContainerService {
return entityManagerFactory;
}
- protected void generateSchema(String action) {
- // Take exiting EMF properties, override the schema generation setting on a copy
- Map<String, Object> createSchemaProperties = new HashMap<>(persistenceUnitProperties);
- createSchemaProperties.put(
- "javax.persistence.schema-generation.database.action",
- action
- );
- Persistence.generateSchema(persistenceUnitName, createSchemaProperties);
+ public List<String> getDefaultSchemaLocations() {
+ return defaultSchemaLocations;
+ }
+
+ protected void prepareSchema(String connectionUrl, String databaseUsername, String databasePassword) {
+ LOG.fine("Preparing database schema");
+ flyway = new Flyway();
+ flyway.setDataSource(connectionUrl, databaseUsername, databasePassword);
+ flyway.setSchemas(SCHEMA_NAME);
+ List<String> locations = new ArrayList<>();
+ appendSchemaLocations(locations);
+ flyway.setLocations(locations.toArray(new String[locations.size()]));
+
+ if (forceClean) {
+ LOG.warning("!!! Cleaning database !!!");
+ flyway.clean();
+ } else {
+ LOG.fine("Not cleaning, using existing database");
+ }
+
+ for (MigrationInfo i : flyway.info().pending()) {
+ LOG.info("Pending task: " + i.getVersion() + ", " + i.getDescription() + ", " + i.getScript());
+ }
+ int applied = flyway.migrate();
+ LOG.info("Applied database schema migrations: " + applied);
+ flyway.validate();
+ }
+
+ protected void appendSchemaLocations(List<String> locations) {
+ locations.addAll(defaultSchemaLocations);
}
@Override
diff --git a/container/src/main/java/org/openremote/container/security/IdentityProvider.java b/container/src/main/java/org/openremote/container/security/IdentityProvider.java
index 4dd8d799f..8c1f20d23 100644
--- a/container/src/main/java/org/openremote/container/security/IdentityProvider.java
+++ b/container/src/main/java/org/openremote/container/security/IdentityProvider.java
@@ -26,6 +26,8 @@ import io.undertow.servlet.api.DeploymentInfo;
*/
public interface IdentityProvider {
+ void init();
+
void start();
void stop();
diff --git a/container/src/main/java/org/openremote/container/security/IdentityService.java b/container/src/main/java/org/openremote/container/security/IdentityService.java
index 06c70e7cd..003d03103 100644
--- a/container/src/main/java/org/openremote/container/security/IdentityService.java
+++ b/container/src/main/java/org/openremote/container/security/IdentityService.java
@@ -39,9 +39,12 @@ public abstract class IdentityService implements ContainerService {
public static final String IDENTITY_NETWORK_HOST_DEFAULT = "localhost";
public static final String IDENTITY_NETWORK_WEBSERVER_PORT = "IDENTITY_NETWORK_WEBSERVER_PORT";
public static final int IDENTITY_NETWORK_WEBSERVER_PORT_DEFAULT = 8080;
+ public static final String IDENTITY_PROVIDER = "IDENTITY_PROVIDER";
+ public static final String IDENTITY_PROVIDER_DEFAULT = "keycloak";
// The externally visible address of this installation
protected UriBuilder externalServerUri;
+ protected IdentityProvider identityProvider;
@Override
public void init(Container container) throws Exception {
@@ -59,16 +62,20 @@ public abstract class IdentityService implements ContainerService {
}
LOG.info("External system base URL: " + externalServerUri.build());
+
+ String identityProviderType = getString(container.getConfig(), IDENTITY_PROVIDER, IDENTITY_PROVIDER_DEFAULT);
+ identityProvider = createIdentityProvider(container, identityProviderType);
+ identityProvider.init();
}
@Override
public void start(Container container) throws Exception {
- getIdentityProvider().start();
+ identityProvider.start();
}
@Override
public void stop(Container container) throws Exception {
- getIdentityProvider().stop();
+ identityProvider.stop();
}
public UriBuilder getExternalServerUri() {
@@ -79,18 +86,18 @@ public abstract class IdentityService implements ContainerService {
LOG.info("Securing web deployment: " + deploymentInfo.getContextPath());
deploymentInfo.addOuterHandlerChainWrapper(AuthOverloadHandler::new);
deploymentInfo.setSecurityDisabled(false);
- getIdentityProvider().secureDeployment(deploymentInfo);
+ identityProvider.secureDeployment(deploymentInfo);
}
/**
* If Keycloak is enabled, support multi-tenancy.
*/
public boolean isKeycloakEnabled() {
- return getIdentityProvider() instanceof KeycloakIdentityProvider;
+ return identityProvider instanceof KeycloakIdentityProvider;
}
/**
- * To initialize the {@link IdentityProvider}, subclasses should override {@link #init(Container)}.
+ * To configure the {@link IdentityProvider}, subclasses should override {@link #init(Container)}.
*/
- abstract public IdentityProvider getIdentityProvider();
+ abstract public IdentityProvider createIdentityProvider(Container container, String type);
}
\ No newline at end of file
diff --git a/container/src/main/java/org/openremote/container/security/basic/BasicIdentityProvider.java b/container/src/main/java/org/openremote/container/security/basic/BasicIdentityProvider.java
index 6e1b26359..5dc0933f7 100644
--- a/container/src/main/java/org/openremote/container/security/basic/BasicIdentityProvider.java
+++ b/container/src/main/java/org/openremote/container/security/basic/BasicIdentityProvider.java
@@ -25,14 +25,34 @@ import io.undertow.security.idm.IdentityManager;
import io.undertow.security.idm.PasswordCredential;
import io.undertow.servlet.api.DeploymentInfo;
import io.undertow.servlet.api.LoginConfig;
+import org.openremote.container.persistence.PersistenceService;
import org.openremote.container.security.IdentityProvider;
+import org.openremote.model.Constants;
+import javax.persistence.NoResultException;
+import javax.persistence.NonUniqueResultException;
+import java.security.Principal;
+import java.util.Set;
import java.util.logging.Logger;
public abstract class BasicIdentityProvider implements IdentityProvider {
private static final Logger LOG = Logger.getLogger(BasicIdentityProvider.class.getName());
+ final protected PersistenceService persistenceService;
+
+ public BasicIdentityProvider(PersistenceService persistenceService) {
+ this.persistenceService = persistenceService;
+ this.persistenceService.getDefaultSchemaLocations().add(
+ "classpath:org/openremote/container/persistence/schema/basicidentityprovider"
+ );
+ }
+
+ @Override
+ public void init() {
+
+ }
+
@Override
public void start() {
@@ -71,5 +91,42 @@ public abstract class BasicIdentityProvider implements IdentityProvider {
});
}
- abstract protected Account verifyAccount(String username, char[] password);
+ protected Account verifyAccount(String username, char[] password) {
+ LOG.fine("Authentication attempt, querying user: " + username);
+ Object[] idAndPassword = persistenceService.doReturningTransaction(em -> {
+ try {
+ return (Object[]) em.createNativeQuery(
+ "select U.ID, U.PASSWORD from USER_ENTITY U where U.USERNAME = :username"
+ ).setParameter("username", username).getSingleResult();
+ } catch (NoResultException | NonUniqueResultException ex) {
+ return null;
+ }
+ }
+ );
+ if (idAndPassword == null) {
+ LOG.fine("Authentication failed, no such user: " + username);
+ return null;
+ }
+ LOG.fine("Authentication attempt, verifying password: " + username);
+ if (!PasswordStorage.verifyPassword(password, idAndPassword[1].toString())) {
+ LOG.fine("Authentication failed, invalid password: " + username);
+ return null;
+ }
+
+ LOG.fine("Authentication successful: " + username);
+ final BasicAuthContext principal = new BasicAuthContext(Constants.MASTER_REALM, idAndPassword[0].toString(), username);
+ return new Account() {
+ @Override
+ public Principal getPrincipal() {
+ return principal;
+ }
+
+ @Override
+ public Set<String> getRoles() {
+ return getDefaultRoles();
+ }
+ };
+ }
+
+ abstract protected Set<String> getDefaultRoles();
}
diff --git a/container/src/main/java/org/openremote/container/security/keycloak/KeycloakIdentityProvider.java b/container/src/main/java/org/openremote/container/security/keycloak/KeycloakIdentityProvider.java
index 991582c69..52e702889 100644
--- a/container/src/main/java/org/openremote/container/security/keycloak/KeycloakIdentityProvider.java
+++ b/container/src/main/java/org/openremote/container/security/keycloak/KeycloakIdentityProvider.java
@@ -166,12 +166,16 @@ public abstract class KeycloakIdentityProvider implements IdentityProvider{
}
@Override
- public void start() {
+ public void init() {
// TODO Not a great way to block startup while we wait for other services (Hystrix?)
waitForKeycloak();
LOG.info("Keycloak identity provider available: " + keycloakServiceUri.build());
}
+ @Override
+ public void start() {
+ }
+
@Override
public void stop() {
if (httpClient != null)
diff --git a/container/src/main/java/org/openremote/container/xml/DOM.java b/container/src/main/java/org/openremote/container/xml/DOM.java
index ba8b9d73f..5d1603c69 100644
--- a/container/src/main/java/org/openremote/container/xml/DOM.java
+++ b/container/src/main/java/org/openremote/container/xml/DOM.java
@@ -32,7 +32,7 @@ import java.net.URL;
public abstract class DOM {
public static final URI XML_SCHEMA_NAMESPACE = URI.create("http://www.w3.org/2001/xml.xsd");
- public static final URL XML_SCHEMA_RESOURCE = DOM.class.getResource("/org/openremote/schemas/xml.xsd");
+ public static final URL XML_SCHEMA_RESOURCE = DOM.class.getResource("/org/openremote/container/schema/xml.xsd");
public static final String CDATA_BEGIN = "<![CDATA[";
public static final String CDATA_END = "]]>";
diff --git a/container/src/main/resources/org/openremote/container/persistence/schema/basicidentityprovider/V20171031_02__BasicIdentityProvider.sql b/container/src/main/resources/org/openremote/container/persistence/schema/basicidentityprovider/V20171031_02__BasicIdentityProvider.sql
new file mode 100644
index 000000000..b51f8bb2b
--- /dev/null
+++ b/container/src/main/resources/org/openremote/container/persistence/schema/basicidentityprovider/V20171031_02__BasicIdentityProvider.sql
@@ -0,0 +1,29 @@
+drop table if exists PUBLIC.USER_ENTITY;
+drop table if exists PUBLIC.REALM_ATTRIBUTE;
+drop table if exists PUBLIC.REALM;
+
+create table PUBLIC.REALM (
+ ID varchar(36) not null primary key,
+ NAME varchar(255) unique not null,
+ ENABLED boolean default false not null,
+ NOT_BEFORE integer
+);
+
+create table PUBLIC.REALM_ATTRIBUTE (
+ NAME varchar(255) not null,
+ VALUE varchar(255),
+ REALM_ID varchar(36) not null references REALM,
+ primary key (NAME, REALM_ID)
+);
+
+create table PUBLIC.USER_ENTITY (
+ ID varchar(36) not null primary key,
+ REALM_ID varchar(255) not null,
+ USERNAME varchar(255) not null,
+ PASSWORD varchar(255) not null,
+ FIRST_NAME varchar(255),
+ LAST_NAME varchar(255),
+ EMAIL varchar(255),
+ ENABLED boolean default false not null,
+ constraint USER_ENTITY_UNIQUE unique (REALM_ID, USERNAME)
+);
diff --git a/container/src/main/resources/org/openremote/container/schema/xml.xsd b/container/src/main/resources/org/openremote/container/schema/xml.xsd
new file mode 100644
index 000000000..1163623f5
--- /dev/null
+++ b/container/src/main/resources/org/openremote/container/schema/xml.xsd
@@ -0,0 +1,287 @@
+<?xml version='1.0'?>
+<?xml-stylesheet href="../2008/09/xsd.xsl" type="text/xsl"?>
+<xs:schema targetNamespace="http://www.w3.org/XML/1998/namespace"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns ="http://www.w3.org/1999/xhtml"
+ xml:lang="en">
+
+ <xs:annotation>
+ <xs:documentation>
+ <div>
+ <h1>About the XML namespace</h1>
+
+ <div class="bodytext">
+ <p>
+ This schema document describes the XML namespace, in a form
+ suitable for import by other schema documents.
+ </p>
+ <p>
+ See <a href="http://www.w3.org/XML/1998/namespace.html">
+ http://www.w3.org/XML/1998/namespace.html</a> and
+ <a href="http://www.w3.org/TR/REC-xml">
+ http://www.w3.org/TR/REC-xml</a> for information
+ about this namespace.
+ </p>
+ <p>
+ Note that local names in this namespace are intended to be
+ defined only by the World Wide Web Consortium or its subgroups.
+ The names currently defined in this namespace are listed below.
+ They should not be used with conflicting semantics by any Working
+ Group, specification, or document instance.
+ </p>
+ <p>
+ See further below in this document for more information about <a
+ href="#usage">how to refer to this schema document from your own
+ XSD schema documents</a> and about <a href="#nsversioning">the
+ namespace-versioning policy governing this schema document</a>.
+ </p>
+ </div>
+ </div>
+ </xs:documentation>
+ </xs:annotation>
+
+ <xs:attribute name="lang">
+ <xs:annotation>
+ <xs:documentation>
+ <div>
+
+ <h3>lang (as an attribute name)</h3>
+ <p>
+ denotes an attribute whose value
+ is a language code for the natural language of the content of
+ any element; its value is inherited. This name is reserved
+ by virtue of its definition in the XML specification.</p>
+
+ </div>
+ <div>
+ <h4>Notes</h4>
+ <p>
+ Attempting to install the relevant ISO 2- and 3-letter
+ codes as the enumerated possible values is probably never
+ going to be a realistic possibility.
+ </p>
+ <p>
+ See BCP 47 at <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt">
+ http://www.rfc-editor.org/rfc/bcp/bcp47.txt</a>
+ and the IANA language subtag registry at
+ <a href="http://www.iana.org/assignments/language-subtag-registry">
+ http://www.iana.org/assignments/language-subtag-registry</a>
+ for further information.
+ </p>
+ <p>
+ The union allows for the 'un-declaration' of xml:lang with
+ the empty string.
+ </p>
+ </div>
+ </xs:documentation>
+ </xs:annotation>
+ <xs:simpleType>
+ <xs:union memberTypes="xs:language">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value=""/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:union>
+ </xs:simpleType>
+ </xs:attribute>
+
+ <xs:attribute name="space">
+ <xs:annotation>
+ <xs:documentation>
+ <div>
+
+ <h3>space (as an attribute name)</h3>
+ <p>
+ denotes an attribute whose
+ value is a keyword indicating what whitespace processing
+ discipline is intended for the content of the element; its
+ value is inherited. This name is reserved by virtue of its
+ definition in the XML specification.</p>
+
+ </div>
+ </xs:documentation>
+ </xs:annotation>
+ <xs:simpleType>
+ <xs:restriction base="xs:NCName">
+ <xs:enumeration value="default"/>
+ <xs:enumeration value="preserve"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+
+ <xs:attribute name="base" type="xs:anyURI"> <xs:annotation>
+ <xs:documentation>
+ <div>
+
+ <h3>base (as an attribute name)</h3>
+ <p>
+ denotes an attribute whose value
+ provides a URI to be used as the base for interpreting any
+ relative URIs in the scope of the element on which it
+ appears; its value is inherited. This name is reserved
+ by virtue of its definition in the XML Base specification.</p>
+
+ <p>
+ See <a
+ href="http://www.w3.org/TR/xmlbase/">http://www.w3.org/TR/xmlbase/</a>
+ for information about this attribute.
+ </p>
+ </div>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+
+ <xs:attribute name="id" type="xs:ID">
+ <xs:annotation>
+ <xs:documentation>
+ <div>
+
+ <h3>id (as an attribute name)</h3>
+ <p>
+ denotes an attribute whose value
+ should be interpreted as if declared to be of type ID.
+ This name is reserved by virtue of its definition in the
+ xml:id specification.</p>
+
+ <p>
+ See <a
+ href="http://www.w3.org/TR/xml-id/">http://www.w3.org/TR/xml-id/</a>
+ for information about this attribute.
+ </p>
+ </div>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+
+ <xs:attributeGroup name="specialAttrs">
+ <xs:attribute ref="xml:base"/>
+ <xs:attribute ref="xml:lang"/>
+ <xs:attribute ref="xml:space"/>
+ <xs:attribute ref="xml:id"/>
+ </xs:attributeGroup>
+
+ <xs:annotation>
+ <xs:documentation>
+ <div>
+
+ <h3>Father (in any context at all)</h3>
+
+ <div class="bodytext">
+ <p>
+ denotes Jon Bosak, the chair of
+ the original XML Working Group. This name is reserved by
+ the following decision of the W3C XML Plenary and
+ XML Coordination groups:
+ </p>
+ <blockquote>
+ <p>
+ In appreciation for his vision, leadership and
+ dedication the W3C XML Plenary on this 10th day of
+ February, 2000, reserves for Jon Bosak in perpetuity
+ the XML name "xml:Father".
+ </p>
+ </blockquote>
+ </div>
+ </div>
+ </xs:documentation>
+ </xs:annotation>
+
+ <xs:annotation>
+ <xs:documentation>
+ <div xml:id="usage" id="usage">
+ <h2><a name="usage">About this schema document</a></h2>
+
+ <div class="bodytext">
+ <p>
+ This schema defines attributes and an attribute group suitable
+ for use by schemas wishing to allow <code>xml:base</code>,
+ <code>xml:lang</code>, <code>xml:space</code> or
+ <code>xml:id</code> attributes on elements they define.
+ </p>
+ <p>
+ To enable this, such a schema must import this schema for
+ the XML namespace, e.g. as follows:
+ </p>
+ <pre>
+ &lt;schema . . .>
+ . . .
+ &lt;import namespace="http://www.w3.org/XML/1998/namespace"
+ schemaLocation="http://www.w3.org/2001/xml.xsd"/>
+ </pre>
+ <p>
+ or
+ </p>
+ <pre>
+ &lt;import namespace="http://www.w3.org/XML/1998/namespace"
+ schemaLocation="http://www.w3.org/2009/01/xml.xsd"/>
+ </pre>
+ <p>
+ Subsequently, qualified reference to any of the attributes or the
+ group defined below will have the desired effect, e.g.
+ </p>
+ <pre>
+ &lt;type . . .>
+ . . .
+ &lt;attributeGroup ref="xml:specialAttrs"/>
+ </pre>
+ <p>
+ will define a type which will schema-validate an instance element
+ with any of those attributes.
+ </p>
+ </div>
+ </div>
+ </xs:documentation>
+ </xs:annotation>
+
+ <xs:annotation>
+ <xs:documentation>
+ <div id="nsversioning" xml:id="nsversioning">
+ <h2><a name="nsversioning">Versioning policy for this schema document</a></h2>
+ <div class="bodytext">
+ <p>
+ In keeping with the XML Schema WG's standard versioning
+ policy, this schema document will persist at
+ <a href="http://www.w3.org/2009/01/xml.xsd">
+ http://www.w3.org/2009/01/xml.xsd</a>.
+ </p>
+ <p>
+ At the date of issue it can also be found at
+ <a href="http://www.w3.org/2001/xml.xsd">
+ http://www.w3.org/2001/xml.xsd</a>.
+ </p>
+ <p>
+ The schema document at that URI may however change in the future,
+ in order to remain compatible with the latest version of XML
+ Schema itself, or with the XML namespace itself. In other words,
+ if the XML Schema or XML namespaces change, the version of this
+ document at <a href="http://www.w3.org/2001/xml.xsd">
+ http://www.w3.org/2001/xml.xsd
+ </a>
+ will change accordingly; the version at
+ <a href="http://www.w3.org/2009/01/xml.xsd">
+ http://www.w3.org/2009/01/xml.xsd
+ </a>
+ will not change.
+ </p>
+ <p>
+ Previous dated (and unchanging) versions of this schema
+ document are at:
+ </p>
+ <ul>
+ <li><a href="http://www.w3.org/2009/01/xml.xsd">
+ http://www.w3.org/2009/01/xml.xsd</a></li>
+ <li><a href="http://www.w3.org/2007/08/xml.xsd">
+ http://www.w3.org/2007/08/xml.xsd</a></li>
+ <li><a href="http://www.w3.org/2004/10/xml.xsd">
+ http://www.w3.org/2004/10/xml.xsd</a></li>
+ <li><a href="http://www.w3.org/2001/03/xml.xsd">
+ http://www.w3.org/2001/03/xml.xsd</a></li>
+ </ul>
+ </div>
+ </div>
+ </xs:documentation>
+ </xs:annotation>
+
+</xs:schema>
+
diff --git a/deployment/manager/consoles/customerA/bower.json b/deployment/manager/consoles/customerA/bower.json
new file mode 100644
index 000000000..cc378fd07
--- /dev/null
+++ b/deployment/manager/consoles/customerA/bower.json
@@ -0,0 +1,23 @@
+{
+ "name": "customer-a-demo",
+ "version": "3.0.0",
+ "homepage": "http://openremote.com/",
+ "authors": [
+ "Christian Bauer <[email protected]>"
+ ],
+ "description": "OR Manager",
+ "main": "index.html",
+ "license": "APGLv3",
+ "ignore": [
+ "**/.*",
+ "node_modules",
+ "bower_components",
+ "test",
+ "tests"
+ ],
+ "dependencies": {
+ "polymer": "Polymer/polymer#^2.2.0",
+ "iron-flex-layout": "^2.0.0",
+ "font-awesome": "~4.7.0"
+ }
+}
\ No newline at end of file
diff --git a/deployment/manager/consoles/customerA/build.gradle b/deployment/manager/consoles/customerA/build.gradle
index ed6121b6a..4cc73aee0 100644
--- a/deployment/manager/consoles/customerA/build.gradle
+++ b/deployment/manager/consoles/customerA/build.gradle
@@ -1,30 +1,3 @@
-plugins {
- id 'com.craigburke.client-dependencies' version '1.4.0'
-}
-clientDependencies {
- cacheDir = "${System.getProperty('java.io.tmpdir')}/openremote-build-client-cache"
- installDir "bower_components"
- defaultCopy = {
- include '**'
- exclude "**/.*", "node_modules", "bower_components", "test", "tests", "src"
- }
- registry 'bowerIO', type: 'bower', url: 'https://registry.bower.io'
-
- // If you get git failures, you run into the request rate limit on github.com, to get a
- // better rate generate a personal access token and put it in ~/.gradle/gradle.properties
- githubToken = project.hasProperty('githubToken') ? project.githubToken : ''
- // which didn't work for me, so set it on ./gradlew -PgithubUsername=...
- githubUsername = project.hasProperty('githubUsername') ? project.githubUsername : '' // <1>
- githubPassword = project.hasProperty('githubPassword') ? project.githubPassword : '' // <2>
-
- bowerIO {
- "polymer"(project.property("polymerVersion"))
- "iron-flex-layout"(project.property("ironFlexLayoutVersion"))
- "font-awesome"(project.property("fontAwesomeVersion"))
- }
-}
-
task installDist {
- // Download JS dependencies
- dependsOn "clientRefresh"
-}
+ dependsOn bowerPrune, bowerUpdate
+}
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
index 5e0b3f1d4..e4a35b012 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -37,7 +37,3 @@ saxonHEVersion = 9.8.0-3
jmxtermVersion = 1.0.0
nettyVersion = 4.1.16.Final
flywaydbVersion = 4.2.0
-polymerVersion = ^2.2.0
-ironFlexLayoutVersion = ^2.0.0
-fontAwesomeVersion = ~4.7.0
-chartjsVersion = ^2.5.0
diff --git a/keycloak/changeDatabase.xsl b/keycloak/changeDatabase.xsl
index f7fffa79a..23f7147cb 100644
--- a/keycloak/changeDatabase.xsl
+++ b/keycloak/changeDatabase.xsl
@@ -8,7 +8,9 @@
<xsl:template match="//ds:subsystem/ds:datasources/ds:datasource[@jndi-name='java:jboss/datasources/KeycloakDS']">
<ds:datasource jndi-name="java:jboss/datasources/KeycloakDS" enabled="true" use-java-context="true" pool-name="KeycloakDS" use-ccm="true">
- <ds:connection-url>jdbc:postgresql://postgresql:5432/${env.POSTGRES_DATABASE:keycloak}</ds:connection-url>
+ <!-- Weird behavior of JBoss/Postgres: If you don't force schema 'public', it will use the last one? But
+ you really can't override it, a different realm doesn't work... -->
+ <ds:connection-url>jdbc:postgresql://postgresql:5432/${env.POSTGRES_DATABASE:keycloak}?currentSchema=public</ds:connection-url>
<ds:driver>postgresql</ds:driver>
<ds:security>
<ds:user-name>${env.POSTGRES_USER:keycloak}</ds:user-name>
diff --git a/manager/Dockerfile b/manager/Dockerfile
index 5ae3dfbeb..197f80487 100644
--- a/manager/Dockerfile
+++ b/manager/Dockerfile
@@ -9,13 +9,13 @@ ENV LOGGING_CONFIG_FILE /deployment/logging.properties
ENV MAP_TILES_PATH /deployment/mapdata.mbtiles
ENV MAP_SETTINGS_PATH /deployment/mapsettings.json
-ADD server /opt/app
-ADD client /opt/app
-
EXPOSE 8080
+HEALTHCHECK --interval=3s --timeout=3s --start-period=2s --retries=30 CMD curl --fail http://localhost:8080 || exit 1
+
WORKDIR /opt/app
-HEALTHCHECK --interval=3s --timeout=3s --start-period=2s --retries=30 CMD curl --fail http://localhost:8080 || exit 1
+ADD server /opt/app
+ADD client /opt/app
ENTRYPOINT ["java", "-cp", "/opt/app/lib/*", "org.openremote.manager.server.Main"]
diff --git a/manager/client/build.gradle b/manager/client/build.gradle
index 39ed40064..8e9f2130f 100644
--- a/manager/client/build.gradle
+++ b/manager/client/build.gradle
@@ -1,7 +1,3 @@
-plugins {
- id 'com.craigburke.client-dependencies' version '1.4.0'
-}
-
evaluationDependsOn(resolveProject(":manager:shared").path)
apply plugin: "java"
@@ -26,34 +22,6 @@ dependencies {
gwtDev "com.google.gwt:gwt-dev:$gwtVersion"
}
-clientDependencies {
- cacheDir = "${System.getProperty('java.io.tmpdir')}/openremote-build-client-cache"
- installDir "src/main/webapp/bower_components"
- defaultCopy = {
- include '**'
- exclude "**/.*", "node_modules", "bower_components", "test", "tests", "src"
- }
- registry 'bowerIO', type: 'bower', url: 'https://registry.bower.io'
-
- // If you get git failures, you run into the request rate limit on github.com, to get a
- // better rate generate a personal access token and put it in ~/.gradle/gradle.properties
- githubToken = project.hasProperty('githubToken') ? project.githubToken : ''
- // which didn't work for me, so set it on ./gradlew -PgithubUsername=...
- githubUsername = project.hasProperty('githubUsername') ? project.githubUsername : '' // <1>
- githubPassword = project.hasProperty('githubPassword') ? project.githubPassword : '' // <2>
-
- bowerIO {
- "polymer"(project.property("polymerVersion"))
- "iron-flex-layout"(project.property("ironFlexLayoutVersion"))
- "font-awesome"(project.property("fontAwesomeVersion"))
- "chart.js"(project.property("chartjsVersion"))
- // TODO No idea why this doesn't work
- // "sprintf"("^1.1.1")
- // TODO They don't publish to bower
- // "mapbox-gl-js"("^0.35.0")
- }
-}
-
def gwtOutputDir = "${project.buildDir}/gwt/out"
def gwtExtraDir = "${project.buildDir}/gwt/extra"
def gwtWorkDir = "${project.buildDir}/gwt/work"
@@ -185,15 +153,12 @@ distributions {
into "webapp"
exclude "gwt"
}
+ /* You can comment out this block to skip GWT compilation for testing the build
+ */
from(compileGwt.outputs) {
into "webapp/gwt"
exclude "WEB-INF"
}
}
}
-}
-
-installDist {
- // Download JS dependencies
- dependsOn "clientRefresh"
-}
+}
\ No newline at end of file
diff --git a/manager/client/src/main/webapp/bower.json b/manager/client/src/main/webapp/bower.json
new file mode 100644
index 000000000..830bb95f0
--- /dev/null
+++ b/manager/client/src/main/webapp/bower.json
@@ -0,0 +1,24 @@
+{
+ "name": "manager",
+ "version": "3.0.0",
+ "homepage": "http://openremote.com/",
+ "authors": [
+ "Christian Bauer <[email protected]>"
+ ],
+ "description": "OR Manager",
+ "main": "index.html",
+ "license": "APGLv3",
+ "ignore": [
+ "**/.*",
+ "node_modules",
+ "bower_components",
+ "test",
+ "tests"
+ ],
+ "dependencies": {
+ "polymer": "Polymer/polymer#^2.2.0",
+ "iron-flex-layout": "^2.0.0",
+ "font-awesome": "~4.7.0",
+ "chart.js": "^2.5.0"
+ }
+}
\ No newline at end of file
diff --git a/manager/client/src/main/webapp/build.gradle b/manager/client/src/main/webapp/build.gradle
new file mode 100644
index 000000000..4cc73aee0
--- /dev/null
+++ b/manager/client/src/main/webapp/build.gradle
@@ -0,0 +1,3 @@
+task installDist {
+ dependsOn bowerPrune, bowerUpdate
+}
\ No newline at end of file
diff --git a/manager/client/src/main/webapp/css/theme.html b/manager/client/src/main/webapp/css/theme.html
index 4474f1836..f2013d924 100644
--- a/manager/client/src/main/webapp/css/theme.html
+++ b/manager/client/src/main/webapp/css/theme.html
@@ -147,11 +147,13 @@
.or-FormGroup {
background-image: -webkit-linear-gradient(45deg, var(--theme-brightgrey) 0%, var(--theme-white) 100%);
background-image: -moz-linear-gradient(45deg, var(--theme-brightgrey) 0%, var(--theme-white) 100%);
+ background-image: linear-gradient(45deg, var(--theme-brightgrey) 0%, var(--theme-white) 100%);
}
.or-PopupPanelContent .or-FormGroup {
background-image: -webkit-linear-gradient(45deg, var(--theme-lightergrey) 0%, var(--theme-brightgrey) 100%);
background-image: -moz-linear-gradient(45deg, var(--theme-lightergrey) 0%, var(--theme-brightgrey) 100%);
+ background-image: linear-gradient(45deg, var(--theme-lightergrey) 0%, var(--theme-brightgrey) 100%);
}
.or-FormGroup.expanded {
@@ -160,6 +162,7 @@
.or-FormSection .or-FormSection {
background-image: -webkit-linear-gradient(45deg, var(--theme-lightergrey) 0%, var(--theme-white) 100%);
background-image: -moz-linear-gradient(45deg, var(--theme-lightergrey) 0%, var(--theme-white) 100%);
+ background-image: linear-gradient(45deg, var(--theme-lightergrey) 0%, var(--theme-white) 100%);
}
.or-FormSection .or-FormSection .or-FormGroup {
@@ -266,6 +269,7 @@
.or-Divider {
background-image: -webkit-linear-gradient(left, var(--theme-white), var(--theme-lightgreen), var(--theme-white));
background-image: -moz-linear-gradient(left, var(--theme-white), var(--theme-lightgreen), var(--theme-white));
+ background-image: linear-gradient(left, var(--theme-white), var(--theme-lightgreen), var(--theme-white));
}
.or-PushButton-up-disabled:focus {
diff --git a/manager/rpi3.Dockerfile b/manager/rpi3.Dockerfile
index c37e7f7db..85994f9a6 100644
--- a/manager/rpi3.Dockerfile
+++ b/manager/rpi3.Dockerfile
@@ -29,13 +29,13 @@ ENV LOGGING_CONFIG_FILE /deployment/logging.properties
ENV MAP_TILES_PATH /deployment/mapdata.mbtiles
ENV MAP_SETTINGS_PATH /deployment/mapsettings.json
-ADD server /opt/app
-ADD client /opt/app
-
EXPOSE 8080
+HEALTHCHECK --interval=3s --timeout=3s --start-period=2s --retries=30 CMD curl --fail http://localhost:8080 || exit 1
+
WORKDIR /opt/app
-HEALTHCHECK --interval=3s --timeout=3s --start-period=2s --retries=30 CMD curl --fail http://localhost:8080 || exit 1
+ADD server /opt/app
+ADD client /opt/app
ENTRYPOINT ["java", "-cp", "/opt/app/lib/*", "org.openremote.manager.server.Main"]
diff --git a/manager/server/src/main/java/org/openremote/manager/server/asset/AssetProcessingService.java b/manager/server/src/main/java/org/openremote/manager/server/asset/AssetProcessingService.java
index 802cf0a05..a02ff8fba 100644
--- a/manager/server/src/main/java/org/openremote/manager/server/asset/AssetProcessingService.java
+++ b/manager/server/src/main/java/org/openremote/manager/server/asset/AssetProcessingService.java
@@ -229,6 +229,30 @@ public class AssetProcessingService extends RouteBuilder implements ContainerSer
.to(ASSET_QUEUE);
// Process attribute events
+ /* TODO This message consumer should be transactionally consistent with the database, this is currenlty not the case
+
+ Our "if I have not processed this message before" duplicate detection:
+
+ - discard events with source time greater than server processing time (future events)
+ - discard events with source time less than last applied/stored event source time
+ - allow the rest (also events with same source time, order of application undefined)
+
+ Possible improvements moving towards at-least-once:
+
+ - Hibernate ThreadLocal Session & Transaction for the whole Camel Exchange/route
+ 0. Receive attribute event, security/404 checks
+ 1. Open DB local transaction
+ 2. Read last asset state
+ 3. Write non-duplicate attribute event
+ 4. Commit DB local transaction
+ 5. Commit reception on message broker
+
+ - See pseudocode here: http://activemq.apache.org/should-i-use-xa.html
+
+ - Replace at-most-once ClientEventService with at-least-once capable, embeddable message broker/protocol
+
+ - Do we want JMS/AMQP/WSS or SOME_API/MQTT/WSS? ActiveMQ or Moquette?
+ */
from(ASSET_QUEUE)
.routeId("AssetUpdates")
.filter(body().isInstanceOf(AttributeEvent.class))
diff --git a/manager/server/src/main/java/org/openremote/manager/server/asset/AssetStorageService.java b/manager/server/src/main/java/org/openremote/manager/server/asset/AssetStorageService.java
index 5a6d272d3..a07f24fec 100644
--- a/manager/server/src/main/java/org/openremote/manager/server/asset/AssetStorageService.java
+++ b/manager/server/src/main/java/org/openremote/manager/server/asset/AssetStorageService.java
@@ -703,8 +703,8 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic
query.select.include != AssetQuery.Include.ONLY_ID_AND_NAME_AND_ATTRIBUTES;
if ((!recursive || level == 3) && (includeRealmInfo || query.tenantPredicate != null)) {
- sb.append("join REALM R on R.ID = A.REALM_ID ");
- sb.append("join REALM_ATTRIBUTE RA on RA.REALM_ID = R.ID and RA.NAME = 'displayName' ");
+ sb.append("join PUBLIC.REALM R on R.ID = A.REALM_ID ");
+ sb.append("join PUBLIC.REALM_ATTRIBUTE RA on RA.REALM_ID = R.ID and RA.NAME = 'displayName' ");
}
if ((!recursive || level == 3) && query.id == null && query.userId != null) {
diff --git a/manager/server/src/main/java/org/openremote/manager/server/persistence/ManagerPersistenceService.java b/manager/server/src/main/java/org/openremote/manager/server/persistence/ManagerPersistenceService.java
index 0ed83ec29..d65bdc258 100644
--- a/manager/server/src/main/java/org/openremote/manager/server/persistence/ManagerPersistenceService.java
+++ b/manager/server/src/main/java/org/openremote/manager/server/persistence/ManagerPersistenceService.java
@@ -19,35 +19,14 @@
*/
package org.openremote.manager.server.persistence;
-import org.openremote.container.Container;
import org.openremote.container.persistence.PersistenceService;
-import org.openremote.manager.server.security.ManagerIdentityService;
-import org.openremote.model.util.TextUtil;
-import java.util.ArrayList;
import java.util.List;
public class ManagerPersistenceService extends PersistenceService {
@Override
- public void start(Container container) throws Exception {
-
- // Before schema is generated, execute this
- persistenceUnitProperties.put("javax.persistence.schema-generation.create-source", "script-then-metadata");
- persistenceUnitProperties.put("javax.persistence.schema-generation.create-script-source", "Extensions.sql");
-
- // After schema is generated, execute this
- List<String> importFiles = new ArrayList<>();
- if (!container.getService(ManagerIdentityService.class).isKeycloakEnabled()) {
- importFiles.add("BasicIdentityProvider.sql");
- }
- importFiles.add("GetAssetTreePath.sql");
- importFiles.add("Constraints.sql");
- persistenceUnitProperties.put(
- "hibernate.hbm2ddl.import_files",
- TextUtil.toCommaSeparated(importFiles.toArray(new String[importFiles.size()]))
- );
-
- super.start(container);
+ protected void appendSchemaLocations(List<String> locations) {
+ locations.add("classpath:org/openremote/manager/server/setup/database");
}
}
diff --git a/manager/server/src/main/java/org/openremote/manager/server/rules/RulesEngine.java b/manager/server/src/main/java/org/openremote/manager/server/rules/RulesEngine.java
index 6388f5878..dd8851820 100644
--- a/manager/server/src/main/java/org/openremote/manager/server/rules/RulesEngine.java
+++ b/manager/server/src/main/java/org/openremote/manager/server/rules/RulesEngine.java
@@ -259,7 +259,6 @@ public class RulesEngine<T extends Ruleset> {
// If compilation failed, remove rules from FileSystem so it won't fail on next pass here if any
kfs.delete("src/main/resources/" + ruleset.getId());
} else {
- LOG.info("Added ruleset: " + ruleset);
addSuccessful = true;
}
} catch (Exception e) {
diff --git a/manager/server/src/main/java/org/openremote/manager/server/security/ManagerBasicIdentityProvider.java b/manager/server/src/main/java/org/openremote/manager/server/security/ManagerBasicIdentityProvider.java
index a21c24e14..c89c0011a 100644
--- a/manager/server/src/main/java/org/openremote/manager/server/security/ManagerBasicIdentityProvider.java
+++ b/manager/server/src/main/java/org/openremote/manager/server/security/ManagerBasicIdentityProvider.java
@@ -19,12 +19,9 @@
*/
package org.openremote.manager.server.security;
-import io.undertow.security.idm.Account;
import org.openremote.container.Container;
import org.openremote.container.security.AuthContext;
-import org.openremote.container.security.basic.BasicAuthContext;
import org.openremote.container.security.basic.BasicIdentityProvider;
-import org.openremote.container.security.basic.PasswordStorage;
import org.openremote.container.web.ClientRequestInfo;
import org.openremote.manager.server.persistence.ManagerPersistenceService;
import org.openremote.manager.shared.security.*;
@@ -32,61 +29,20 @@ import org.openremote.model.Constants;
import org.openremote.model.asset.Asset;
import org.openremote.model.event.shared.TenantFilter;
-import javax.persistence.NoResultException;
-import javax.persistence.NonUniqueResultException;
-import java.security.Principal;
import java.util.Objects;
import java.util.Set;
-import java.util.logging.Logger;
public class ManagerBasicIdentityProvider extends BasicIdentityProvider implements ManagerIdentityProvider {
- private static final Logger LOG = Logger.getLogger(ManagerBasicIdentityProvider.class.getName());
-
- final protected ManagerPersistenceService persistenceService;
-
final protected Tenant masterTenant = new Tenant(Constants.MASTER_REALM, Constants.MASTER_REALM, "Master", true);
public ManagerBasicIdentityProvider(Container container) {
- this.persistenceService = container.getService(ManagerPersistenceService.class);
- }
-
- @Override
- protected Account verifyAccount(String username, char[] password) {
- LOG.fine("Authentication attempt, querying user: " + username);
- Object[] idAndPassword = persistenceService.doReturningTransaction(em -> {
- try {
- return (Object[]) em.createNativeQuery(
- "select U.ID, U.PASSWORD from USER_ENTITY U where U.USERNAME = :username"
- ).setParameter("username", username).getSingleResult();
- } catch (NoResultException | NonUniqueResultException ex) {
- return null;
- }
- }
- );
- if (idAndPassword == null) {
- LOG.fine("Authentication failed, no such user: " + username);
- return null;
- }
- LOG.fine("Authentication attempt, verifying password: " + username);
- if (!PasswordStorage.verifyPassword(password, idAndPassword[1].toString())) {
- LOG.fine("Authentication failed, invalid password: " + username);
- return null;
- }
-
- LOG.fine("Authentication successful: " + username);
- final BasicAuthContext principal = new BasicAuthContext(Constants.MASTER_REALM, idAndPassword[0].toString(), username);
- return new Account() {
- @Override
- public Principal getPrincipal() {
- return principal;
- }
-
- @Override
- public Set<String> getRoles() {
- return ClientRole.ALL_ROLES;
- }
- };
+ super(container.getService(ManagerPersistenceService.class));
+ }
+
+ @Override
+ protected Set<String> getDefaultRoles() {
+ return ClientRole.ALL_ROLES;
}
@Override
diff --git a/manager/server/src/main/java/org/openremote/manager/server/security/ManagerIdentityService.java b/manager/server/src/main/java/org/openremote/manager/server/security/ManagerIdentityService.java
index f380820e7..7e1619ac4 100644
--- a/manager/server/src/main/java/org/openremote/manager/server/security/ManagerIdentityService.java
+++ b/manager/server/src/main/java/org/openremote/manager/server/security/ManagerIdentityService.java
@@ -20,7 +20,6 @@
package org.openremote.manager.server.security;
import org.openremote.container.Container;
-import org.openremote.container.persistence.PersistenceService;
import org.openremote.container.security.IdentityService;
import org.openremote.container.timer.TimerService;
import org.openremote.container.web.WebService;
@@ -28,24 +27,16 @@ import org.openremote.container.web.WebService;
import java.util.Locale;
import java.util.logging.Logger;
-import static org.openremote.container.util.MapAccess.getString;
-
public class ManagerIdentityService extends IdentityService {
private static final Logger LOG = Logger.getLogger(ManagerIdentityService.class.getName());
- public static final String MANAGER_IDENTITY_PROVIDER = "MANAGER_IDENTITY_PROVIDER";
- public static final String MANAGER_IDENTITY_PROVIDER_DEFAULT = "keycloak";
-
- protected PersistenceService persistenceService;
protected ManagerIdentityProvider identityProvider;
@Override
public void init(Container container) throws Exception {
super.init(container);
- this.persistenceService = container.getService(PersistenceService.class);
-
container.getService(WebService.class).getApiSingletons().add(
new TenantResourceImpl(container.getService(TimerService.class), this)
);
@@ -53,26 +44,31 @@ public class ManagerIdentityService extends IdentityService {
new UserResourceImpl(container.getService(TimerService.class), this)
);
- String identityProviderType = getString(container.getConfig(), MANAGER_IDENTITY_PROVIDER, MANAGER_IDENTITY_PROVIDER_DEFAULT);
- switch (identityProviderType.toLowerCase(Locale.ROOT)) {
- case "keycloak":
- LOG.info("Enabling Keycloak identity provider");
- this.identityProvider = new ManagerKeycloakIdentityProvider(getExternalServerUri(), container);
- break;
- case "basic":
- LOG.info("Enabling basic identity provider");
- this.identityProvider = new ManagerBasicIdentityProvider(container);
- break;
- default:
- throw new UnsupportedOperationException("Unknown identity provider: " + identityProviderType);
- }
}
- @Override
public ManagerIdentityProvider getIdentityProvider() {
return identityProvider;
}
+ @Override
+ public ManagerIdentityProvider createIdentityProvider(Container container, String identityProviderType) {
+ if (identityProvider == null) {
+ switch (identityProviderType.toLowerCase(Locale.ROOT)) {
+ case "keycloak":
+ LOG.info("Enabling Keycloak identity provider");
+ this.identityProvider = new ManagerKeycloakIdentityProvider(getExternalServerUri(), container);
+ break;
+ case "basic":
+ LOG.info("Enabling basic identity provider");
+ this.identityProvider = new ManagerBasicIdentityProvider(container);
+ break;
+ default:
+ throw new UnsupportedOperationException("Unknown identity provider: " + identityProviderType);
+ }
+ }
+ return identityProvider;
+ }
+
@Override
public String toString() {
return getClass().getSimpleName() + "{" +
diff --git a/manager/server/src/main/java/org/openremote/manager/server/security/RealmView.java b/manager/server/src/main/java/org/openremote/manager/server/security/RealmView.java
index 956ee523d..921e7d04e 100644
--- a/manager/server/src/main/java/org/openremote/manager/server/security/RealmView.java
+++ b/manager/server/src/main/java/org/openremote/manager/server/security/RealmView.java
@@ -30,7 +30,7 @@ import javax.persistence.Id;
* Use this to query the Keycloak REALM table in JPA queries.
*/
@Entity
-@Subselect("select * from REALM") // Map this immutable to an SQL view, don't use/create table
+@Subselect("select * from PUBLIC.REALM") // Map this immutable to an SQL view, don't use/create table
public class RealmView {
protected String id;
diff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/AbstractKeycloakSetup.java b/manager/server/src/main/java/org/openremote/manager/server/setup/AbstractKeycloakSetup.java
index aec778651..300ec7ced 100644
--- a/manager/server/src/main/java/org/openremote/manager/server/setup/AbstractKeycloakSetup.java
+++ b/manager/server/src/main/java/org/openremote/manager/server/setup/AbstractKeycloakSetup.java
@@ -40,8 +40,8 @@ public abstract class AbstractKeycloakSetup implements Setup {
// demo data as needed.
public static final String ADMIN_CLI_CLIENT_ID = "admin-cli";
- public static final String SETUP_KEYCLOAK_ADMIN_PASSWORD = "SETUP_KEYCLOAK_ADMIN_PASSWORD";
- public static final String SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT = "secret";
+ public static final String KEYCLOAK_PASSWORD = "KEYCLOAK_PASSWORD";
+ public static final String KEYCLOAK_PASSWORD_DEFAULT = "secret";
public static final String SETUP_KEYCLOAK_EMAIL_HOST = "SETUP_KEYCLOAK_EMAIL_HOST";
public static final String SETUP_KEYCLOAK_EMAIL_HOST_DEFAULT = "smtp-host.demo.tld";
public static final String SETUP_KEYCLOAK_EMAIL_USER = "SETUP_KEYCLOAK_EMAIL_USER";
@@ -57,31 +57,22 @@ public abstract class AbstractKeycloakSetup implements Setup {
public static final String SETUP_KEYCLOAK_EMAIL_FROM = "SETUP_KEYCLOAK_EMAIL_FROM";
public static final String SETUP_KEYCLOAK_EMAIL_FROM_DEFAULT = "[email protected]";
+ final protected Container container;
final protected ManagerIdentityService identityService;
final protected ManagerKeycloakIdentityProvider keycloakProvider;
final protected SetupService setupService;
- final protected String accessToken;
- final protected RealmResource masterRealmResource;
- final protected ClientsResource masterClientsResource;
- final protected UsersResource masterUsersResource;
final protected TenantEmailConfig emailConfig;
+ protected String accessToken;
+ protected RealmResource masterRealmResource;
+ protected ClientsResource masterClientsResource;
+ protected UsersResource masterUsersResource;
public AbstractKeycloakSetup(Container container) {
+ this.container = container;
this.identityService = container.getService(ManagerIdentityService.class);
this.keycloakProvider = ((ManagerKeycloakIdentityProvider)identityService.getIdentityProvider());
this.setupService = container.getService(SetupService.class);
-
- // Use direct access grant feature of Keycloak Admin CLI to get superuser access token
- String demoAdminPassword = container.getConfig().getOrDefault(SETUP_KEYCLOAK_ADMIN_PASSWORD, SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT);
- this.accessToken = keycloakProvider.getKeycloak().getAccessToken(
- MASTER_REALM, new AuthForm(ADMIN_CLI_CLIENT_ID, MASTER_REALM_ADMIN_USER, demoAdminPassword)
- ).getToken();
-
- masterRealmResource = keycloakProvider.getRealms(accessToken).realm(MASTER_REALM);
- masterClientsResource = keycloakProvider.getRealms(accessToken).realm(MASTER_REALM).clients();
- masterUsersResource = keycloakProvider.getRealms(accessToken).realm(MASTER_REALM).users();
-
// Configure SMTP
if (container.getConfig().containsKey(SETUP_KEYCLOAK_EMAIL_HOST)) {
emailConfig = new TenantEmailConfig();
@@ -101,6 +92,19 @@ public abstract class AbstractKeycloakSetup implements Setup {
return keycloakProvider;
}
+ @Override
+ public void onStart() throws Exception {
+ // Use direct access grant feature of Keycloak Admin CLI to get superuser access token
+ String keycloakAdminPassword = container.getConfig().getOrDefault(KEYCLOAK_PASSWORD, KEYCLOAK_PASSWORD_DEFAULT);
+ this.accessToken = keycloakProvider.getKeycloak().getAccessToken(
+ MASTER_REALM, new AuthForm(ADMIN_CLI_CLIENT_ID, MASTER_REALM_ADMIN_USER, keycloakAdminPassword)
+ ).getToken();
+
+ masterRealmResource = keycloakProvider.getRealms(accessToken).realm(MASTER_REALM);
+ masterClientsResource = keycloakProvider.getRealms(accessToken).realm(MASTER_REALM).clients();
+ masterUsersResource = keycloakProvider.getRealms(accessToken).realm(MASTER_REALM).users();
+ }
+
protected String getClientObjectId(ClientsResource clientsResource) {
return clientsResource.findByClientId(KEYCLOAK_CLIENT_ID)
.stream()
diff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/AbstractManagerSetup.java b/manager/server/src/main/java/org/openremote/manager/server/setup/AbstractManagerSetup.java
index 383f579a8..29cfbad9e 100644
--- a/manager/server/src/main/java/org/openremote/manager/server/setup/AbstractManagerSetup.java
+++ b/manager/server/src/main/java/org/openremote/manager/server/setup/AbstractManagerSetup.java
@@ -24,10 +24,10 @@ import org.openremote.agent.protocol.macro.MacroAction;
import org.openremote.agent.protocol.macro.MacroProtocol;
import org.openremote.agent.protocol.timer.TimerValue;
import org.openremote.container.Container;
-import org.openremote.container.persistence.PersistenceService;
import org.openremote.manager.server.asset.AssetStorageService;
import org.openremote.manager.server.asset.ServerAsset;
import org.openremote.manager.server.datapoint.AssetDatapointService;
+import org.openremote.manager.server.persistence.ManagerPersistenceService;
import org.openremote.manager.server.rules.RulesetStorageService;
import org.openremote.manager.server.security.ManagerIdentityService;
import org.openremote.model.asset.AssetAttribute;
@@ -51,7 +51,7 @@ import static org.openremote.model.attribute.AttributeType.*;
public abstract class AbstractManagerSetup implements Setup {
- final protected PersistenceService persistenceService;
+ final protected ManagerPersistenceService persistenceService;
final protected ManagerIdentityService identityService;
final protected AssetStorageService assetStorageService;
final protected AssetDatapointService assetDatapointService;
@@ -60,7 +60,7 @@ public abstract class AbstractManagerSetup implements Setup {
final protected SetupService setupService;
public AbstractManagerSetup(Container container) {
- this.persistenceService = container.getService(PersistenceService.class);
+ this.persistenceService = container.getService(ManagerPersistenceService.class);
this.identityService = container.getService(ManagerIdentityService.class);
this.assetStorageService = container.getService(AssetStorageService.class);
this.assetDatapointService = container.getService(AssetDatapointService.class);
diff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/SchemaExporter.java b/manager/server/src/main/java/org/openremote/manager/server/setup/SchemaExporter.java
index edd5ae148..444840cbd 100644
--- a/manager/server/src/main/java/org/openremote/manager/server/setup/SchemaExporter.java
+++ b/manager/server/src/main/java/org/openremote/manager/server/setup/SchemaExporter.java
@@ -22,6 +22,7 @@ package org.openremote.manager.server.setup;
import org.openremote.container.Container;
import org.openremote.container.persistence.Database;
import org.openremote.container.persistence.PersistenceService;
+import org.openremote.manager.server.concurrent.ManagerExecutorService;
import org.openremote.manager.server.persistence.ManagerPersistenceService;
import javax.persistence.Persistence;
@@ -45,6 +46,7 @@ public class SchemaExporter {
File schemaFile = new File(args[0]);
Container container = new Container(
+ new ManagerExecutorService(),
new ManagerPersistenceService() {
@Override
diff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/Setup.java b/manager/server/src/main/java/org/openremote/manager/server/setup/Setup.java
index 511d84534..ef1da1166 100644
--- a/manager/server/src/main/java/org/openremote/manager/server/setup/Setup.java
+++ b/manager/server/src/main/java/org/openremote/manager/server/setup/Setup.java
@@ -29,5 +29,7 @@ package org.openremote.manager.server.setup;
*/
public interface Setup {
- void execute() throws Exception;
+ default void onInit() throws Exception {}
+
+ default void onStart() throws Exception {}
}
diff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/SetupService.java b/manager/server/src/main/java/org/openremote/manager/server/setup/SetupService.java
index 1306477eb..92dbc30fc 100644
--- a/manager/server/src/main/java/org/openremote/manager/server/setup/SetupService.java
+++ b/manager/server/src/main/java/org/openremote/manager/server/setup/SetupService.java
@@ -47,16 +47,10 @@ public class SetupService implements ContainerService {
final protected List<Setup> setupList = new ArrayList<>();
// Make demo/test data accessible from Groovy/Java code
- protected SetupTasks setupTasks;
+ public SetupTasks setupTasks;
@Override
public void init(Container container) throws Exception {
- // Setup runs last, when everything is initialized and started
- }
-
- @Override
- public void start(Container container) {
-
ServiceLoader.load(SetupTasks.class).forEach(
discoveredSetupTasks -> {
if (setupTasks != null) {
@@ -66,7 +60,7 @@ public class SetupService implements ContainerService {
+ discoveredSetupTasks.getClass().getName()
);
}
- LOG.info("Enabling setup tasks: " + discoveredSetupTasks.getClass().getName());
+ LOG.info("Found setup tasks: " + discoveredSetupTasks.getClass().getName());
setupTasks = discoveredSetupTasks;
}
);
@@ -80,11 +74,27 @@ public class SetupService implements ContainerService {
try {
if (setupList.size() > 0) {
- LOG.info("--- EXECUTING SETUP TASKS ---");
+ LOG.info("--- EXECUTING INIT TASKS ---");
+ for (Setup setup : setupList) {
+ setup.onInit();
+ }
+ LOG.info("--- INIT TASKS COMPLETED SUCCESSFULLY ---");
+ }
+ } catch (Exception ex) {
+ throw new RuntimeException("Error setting up application", ex);
+ }
+ }
+
+ @Override
+ public void start(Container container) {
+
+ try {
+ if (setupList.size() > 0) {
+ LOG.info("--- EXECUTING START TASKS ---");
for (Setup setup : setupList) {
- setup.execute();
+ setup.onStart();
}
- LOG.info("--- SETUP TASKS COMPLETED SUCCESSFULLY ---");
+ LOG.info("--- START TASKS COMPLETED SUCCESSFULLY ---");
}
} catch (Exception ex) {
throw new RuntimeException("Error setting up application", ex);
diff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/BasicIdentityDemoSetup.java b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/BasicIdentityDemoSetup.java
index 7ba8b7ce9..849579975 100644
--- a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/BasicIdentityDemoSetup.java
+++ b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/BasicIdentityDemoSetup.java
@@ -56,7 +56,7 @@ public class BasicIdentityDemoSetup implements Setup {
}
@Override
- public void execute() throws Exception {
+ public void onStart() throws Exception {
// Tenants
masterTenant = identityService.getIdentityProvider().getTenantForRealm(Constants.MASTER_REALM);
diff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/BasicIdentityInitSetup.java b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/BasicIdentityInitSetup.java
index 70ad37b24..d36a26718 100644
--- a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/BasicIdentityInitSetup.java
+++ b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/BasicIdentityInitSetup.java
@@ -35,7 +35,7 @@ public class BasicIdentityInitSetup implements Setup {
}
@Override
- public void execute() {
+ public void onStart() {
// Configure the master realm
persistenceService.doTransaction(em -> em.unwrap(Session.class).doWork(connection -> {
String sql = "insert into REALM(ID, NAME, ENABLED) values ('master', 'master', true)";
diff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/BuiltinSetupTasks.java b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/BuiltinSetupTasks.java
index 44d77fc18..22865d4e3 100644
--- a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/BuiltinSetupTasks.java
+++ b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/BuiltinSetupTasks.java
@@ -43,7 +43,7 @@ import static org.openremote.container.util.MapAccess.getBoolean;
* Setup tasks are configured via the config hash map supplied in the
* {@link Container} constructor. Available config options are:
* <ul>
- * <li>{@link #SETUP_INIT_CLEAN_DATABASE}</li>
+ * <li>{@link #SETUP_WIPE_CLEAN_INSTALL}</li>
* <li>{@link #SETUP_IMPORT_DEMO_USERS}</li>
* <li>{@link #SETUP_IMPORT_DEMO_ASSETS} depends on {@link #SETUP_IMPORT_DEMO_USERS}</li>
* <li>{@link #SETUP_IMPORT_DEMO_SCENES} depends on {@link #SETUP_IMPORT_DEMO_ASSETS}</li>
@@ -52,15 +52,15 @@ import static org.openremote.container.util.MapAccess.getBoolean;
*/
public class BuiltinSetupTasks extends AbstractSetupTasks {
- public static final String SETUP_INIT_CLEAN_DATABASE = "SETUP_INIT_CLEAN_DATABASE";
+ public static final String SETUP_WIPE_CLEAN_INSTALL = "SETUP_WIPE_CLEAN_INSTALL";
public static final String SETUP_IMPORT_DEMO_USERS = "SETUP_IMPORT_DEMO_USERS";
public static final String SETUP_IMPORT_DEMO_ASSETS = "SETUP_IMPORT_DEMO_ASSETS";
public static final String SETUP_IMPORT_DEMO_SCENES = "SETUP_IMPORT_DEMO_SCENES";
public static final String SETUP_IMPORT_DEMO_RULES = "SETUP_IMPORT_DEMO_RULES";
public static final String SETUP_IMPORT_DEMO_AGENT = "SETUP_IMPORT_DEMO_AGENT";
- protected boolean isCleanDatabase(Container container) {
- return getBoolean(container.getConfig(), SETUP_INIT_CLEAN_DATABASE, container.isDevMode());
+ protected boolean isSetupWipeCleanInstall(Container container) {
+ return getBoolean(container.getConfig(), SETUP_WIPE_CLEAN_INSTALL, container.isDevMode());
}
// Demo agent to demo protocols.
@@ -93,11 +93,10 @@ public class BuiltinSetupTasks extends AbstractSetupTasks {
// Basic vs Keycloak identity provider
if (container.getService(ManagerIdentityService.class).isKeycloakEnabled()) {
- if (isCleanDatabase(container)) {
+ if (isSetupWipeCleanInstall(container)) {
addTask(new ManagerCleanSetup(container));
addTask(new KeycloakCleanSetup(container));
addTask(new KeycloakInitSetup(container));
- addTask(new ManagerInitSetup(container));
}
if (isImportDemoUsers(container)) {
@@ -116,9 +115,8 @@ public class BuiltinSetupTasks extends AbstractSetupTasks {
addTask(new ManagerDemoAgentSetup(container));
}
} else {
- if (isCleanDatabase(container)) {
+ if (isSetupWipeCleanInstall(container)) {
addTask(new ManagerCleanSetup(container));
- addTask(new ManagerInitSetup(container));
addTask(new BasicIdentityInitSetup(container));
}
diff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/KeycloakCleanSetup.java b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/KeycloakCleanSetup.java
index 18dd15568..024f64f4f 100644
--- a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/KeycloakCleanSetup.java
+++ b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/KeycloakCleanSetup.java
@@ -40,7 +40,8 @@ public class KeycloakCleanSetup extends AbstractKeycloakSetup {
}
@Override
- public void execute() {
+ public void onStart() throws Exception {
+ super.onStart();
// Delete all realms that are not the master realm
LOG.info("Deleting all non-master realms");
diff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/KeycloakDemoSetup.java b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/KeycloakDemoSetup.java
index acb8a65b3..a194fb81a 100644
--- a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/KeycloakDemoSetup.java
+++ b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/KeycloakDemoSetup.java
@@ -59,7 +59,8 @@ public class KeycloakDemoSetup extends AbstractKeycloakSetup {
}
@Override
- public void execute() throws Exception {
+ public void onStart() throws Exception {
+ super.onStart();
// Tenants
masterTenant = identityService.getIdentityProvider().getTenantForRealm(Constants.MASTER_REALM);
diff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/KeycloakInitSetup.java b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/KeycloakInitSetup.java
index 67253e76f..1fbce3c4a 100644
--- a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/KeycloakInitSetup.java
+++ b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/KeycloakInitSetup.java
@@ -43,7 +43,9 @@ public class KeycloakInitSetup extends AbstractKeycloakSetup {
}
@Override
- public void execute() {
+ public void onStart() throws Exception {
+ super.onStart();
+
// Configure the master realm
RealmRepresentation masterRealm = masterRealmResource.toRepresentation();
diff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerCleanSetup.java b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerCleanSetup.java
index 6dd19a1d0..e3c88dc5c 100644
--- a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerCleanSetup.java
+++ b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerCleanSetup.java
@@ -20,22 +20,20 @@
package org.openremote.manager.server.setup.builtin;
import org.openremote.container.Container;
+import org.openremote.manager.server.persistence.ManagerPersistenceService;
import org.openremote.manager.server.setup.AbstractManagerSetup;
-import java.util.logging.Logger;
-
public class ManagerCleanSetup extends AbstractManagerSetup {
- private static final Logger LOG = Logger.getLogger(ManagerCleanSetup.class.getName());
+ final protected ManagerPersistenceService persistenceService;
public ManagerCleanSetup(Container container) {
super(container);
+ this.persistenceService = container.getService(ManagerPersistenceService.class);
}
@Override
- public void execute() throws Exception {
- LOG.info("Dropping database schema and all data");
- persistenceService.dropSchema();
- LOG.info("### NOTE: The message 'relation ... does not exist' is normal and can be ignored!");
+ public void onInit() throws Exception {
+ persistenceService.setForceClean(true);
}
-}
+}
\ No newline at end of file
diff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerDemoAgentSetup.java b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerDemoAgentSetup.java
index de69bd223..b271d1129 100644
--- a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerDemoAgentSetup.java
+++ b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerDemoAgentSetup.java
@@ -77,7 +77,7 @@ public class ManagerDemoAgentSetup extends AbstractManagerSetup {
}
@Override
- public void execute() throws Exception {
+ public void onStart() throws Exception {
KeycloakDemoSetup keycloakDemoSetup = setupService.getTaskOfType(KeycloakDemoSetup.class);
Tenant masterTenant = keycloakDemoSetup.masterTenant;
diff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerDemoSetup.java b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerDemoSetup.java
index 377907e03..192b28980 100644
--- a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerDemoSetup.java
+++ b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerDemoSetup.java
@@ -88,7 +88,7 @@ public class ManagerDemoSetup extends AbstractManagerSetup {
}
@Override
- public void execute() throws Exception {
+ public void onStart() throws Exception {
KeycloakDemoSetup keycloakDemoSetup = setupService.getTaskOfType(KeycloakDemoSetup.class);
Tenant masterTenant = keycloakDemoSetup.masterTenant;
diff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerInitSetup.java b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerInitSetup.java
deleted file mode 100644
index e011a66cc..000000000
--- a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerInitSetup.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2016, OpenRemote Inc.
- *
- * See the CONTRIBUTORS.txt file in the distribution for a
- * full listing of individual contributors.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.openremote.manager.server.setup.builtin;
-
-import org.openremote.container.Container;
-import org.openremote.manager.server.setup.AbstractManagerSetup;
-
-import java.util.logging.Logger;
-
-public class ManagerInitSetup extends AbstractManagerSetup {
-
- private static final Logger LOG = Logger.getLogger(ManagerInitSetup.class.getName());
-
- public ManagerInitSetup(Container container) {
- super(container);
- }
-
- @Override
- public void execute() throws Exception {
- LOG.info("Creating database schema");
- persistenceService.createSchema();
- }
-}
diff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/RulesDemoSetup.java b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/RulesDemoSetup.java
index 4772e0caa..cdb7940ef 100644
--- a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/RulesDemoSetup.java
+++ b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/RulesDemoSetup.java
@@ -40,7 +40,7 @@ public class RulesDemoSetup extends AbstractManagerSetup {
public Long apartmentActionsRulesetId;
@Override
- public void execute() throws Exception {
+ public void onStart() throws Exception {
KeycloakDemoSetup keycloakDemoSetup = setupService.getTaskOfType(KeycloakDemoSetup.class);
ManagerDemoSetup managerDemoSetup = setupService.getTaskOfType(ManagerDemoSetup.class);
diff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerUpdateSetup.java b/manager/server/src/main/java/org/openremote/manager/server/setup/database/Disabled_V20171031_03__Migration.java
similarity index 54%
rename from manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerUpdateSetup.java
rename to manager/server/src/main/java/org/openremote/manager/server/setup/database/Disabled_V20171031_03__Migration.java
index 08c769827..cdb277057 100644
--- a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerUpdateSetup.java
+++ b/manager/server/src/main/java/org/openremote/manager/server/setup/database/Disabled_V20171031_03__Migration.java
@@ -17,24 +17,26 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-package org.openremote.manager.server.setup.builtin;
+package org.openremote.manager.server.setup.database;
-import org.openremote.container.Container;
-import org.openremote.manager.server.setup.AbstractManagerSetup;
+import org.flywaydb.core.api.migration.jdbc.JdbcMigration;
-import java.util.logging.Logger;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
-public class ManagerUpdateSetup extends AbstractManagerSetup {
-
- private static final Logger LOG = Logger.getLogger(ManagerUpdateSetup.class.getName());
-
- public ManagerUpdateSetup(Container container) {
- super(container);
- }
+/**
+ * TODO An example in the right place
+ */
+public class Disabled_V20171031_03__Migration { // implements JdbcMigration {
- @Override
- public void execute() throws Exception {
- LOG.info("Updating database schema");
- persistenceService.updateSchema();
+ // @Override
+ public void migrate(Connection connection) throws Exception {
+ /* TODO: Enable to migrate beyond 3.0.0 when SQL files are not good enough
+ try (PreparedStatement statement = connection.prepareStatement(
+ "alter table openremote.ASSET add column TEST_COLUMN varchar(50)"
+ )) {
+ statement.execute();
+ }
+ */
}
}
diff --git a/manager/server/src/main/resources/Constraints.sql b/manager/server/src/main/resources/Constraints.sql
deleted file mode 100644
index 1308cbb8f..000000000
--- a/manager/server/src/main/resources/Constraints.sql
+++ /dev/null
@@ -1,29 +0,0 @@
-alter table ASSET
- add foreign key (PARENT_ID) references ASSET (ID);
-
-alter table ASSET
- add foreign key (REALM_ID) references REALM (ID);
-
-alter table ASSET_DATAPOINT
- add foreign key (ENTITY_ID) references ASSET (ID) on delete cascade;
-
-alter table TENANT_RULESET
- add foreign key (REALM_ID) references REALM (ID);
-
-alter table ASSET_RULESET
- add foreign key (ASSET_ID) references ASSET (ID) on delete cascade;
-
-alter table DEVICE_NOTIFICATION_TOKEN
- add foreign key (USER_ID) references USER_ENTITY (ID) on delete cascade;
-
-alter table USER_CONFIGURATION
- add foreign key (USER_ID) references USER_ENTITY (ID) on delete cascade;
-
-alter table USER_ASSET
- add foreign key (USER_ID) references USER_ENTITY (ID) on delete cascade;
-
-alter table USER_ASSET
- add foreign key (ASSET_ID) references ASSET (ID) on delete cascade;
-
-alter table USER_ASSET
- add foreign key (REALM_ID) references REALM (ID) on delete cascade;
diff --git a/manager/server/src/main/resources/Extensions.sql b/manager/server/src/main/resources/Extensions.sql
deleted file mode 100644
index 469c5cbd3..000000000
--- a/manager/server/src/main/resources/Extensions.sql
+++ /dev/null
@@ -1,3 +0,0 @@
-create extension if not exists postgis;
-create extension if not exists postgis_topology;
-create extension if not exists fuzzystrmatch;
diff --git a/manager/server/src/main/resources/GetAssetTreePath.sql b/manager/server/src/main/resources/GetAssetTreePath.sql
deleted file mode 100644
index dea70de7c..000000000
--- a/manager/server/src/main/resources/GetAssetTreePath.sql
+++ /dev/null
@@ -1,15 +0,0 @@
--- importOneStatementOnly
-create or replace function GET_ASSET_TREE_PATH(ASSET_ID text)
- returns text [] as
-$$
-begin
- return (with recursive ASSET_TREE(ID, PARENT_ID, PATH) as (
- select A1.ID, A1.PARENT_ID, array [text(A1.ID)] from ASSET A1 where A1.ID = ASSET_ID
- union all
- select A2.ID, A2.PARENT_ID, array_append(AT.PATH, text(A2.ID))
- from ASSET A2, ASSET_TREE AT
- where A2.ID = AT.PARENT_ID and AT.PARENT_ID is not null
- ) select PATH from ASSET_TREE where PARENT_ID is null);
-end;
-$$
-language plpgsql;
diff --git a/manager/server/src/main/resources/org/openremote/manager/server/setup/database/V20171031_01__Schema.sql b/manager/server/src/main/resources/org/openremote/manager/server/setup/database/V20171031_01__Schema.sql
new file mode 100644
index 000000000..a802b6e66
--- /dev/null
+++ b/manager/server/src/main/resources/org/openremote/manager/server/setup/database/V20171031_01__Schema.sql
@@ -0,0 +1,184 @@
+/*
+ ############################# EXTENSIONS #############################
+ */
+create extension if not exists POSTGIS;
+create extension if not exists POSTGIS_TOPOLOGY;
+create extension if not exists FUZZYSTRMATCH;
+
+/*
+ ############################# SEQUENCES #############################
+ */
+create sequence OPENREMOTE_SEQUENCE
+ start 1000
+ increment 1;
+
+/*
+ ############################# TABLES #############################
+ */
+
+create table ALERT_NOTIFICATION (
+ ID int8 not null,
+ ACTIONS jsonb,
+ APP_URL varchar(255) not null,
+ CREATED_ON timestamp with time zone not null,
+ DELIVERY_STATUS varchar(255),
+ MESSAGE varchar(255) not null,
+ TITLE varchar(255) not null,
+ USER_ID varchar(255),
+ primary key (ID)
+);
+
+create table ASSET (
+ ID varchar(43) not null,
+ ATTRIBUTES jsonb,
+ CREATED_ON timestamp with time zone not null,
+ NAME varchar(1023) not null,
+ PARENT_ID varchar(36),
+ REALM_ID varchar(255) not null,
+ ASSET_TYPE varchar(255) not null,
+ OBJ_VERSION int8 not null,
+ LOCATION geometry,
+ primary key (ID),
+ check (ID != PARENT_ID)
+);
+
+create table ASSET_DATAPOINT (
+ VALUE jsonb not null,
+ TIMESTAMP int8 not null,
+ ENTITY_ID varchar(36) not null,
+ ATTRIBUTE_NAME varchar(255) not null,
+ primary key (VALUE, TIMESTAMP, ENTITY_ID, ATTRIBUTE_NAME)
+);
+
+create table ASSET_RULESET (
+ ID int8 not null,
+ CREATED_ON timestamp with time zone not null,
+ ENABLED boolean not null,
+ LAST_MODIFIED timestamp with time zone not null,
+ NAME varchar(255) not null,
+ RULES text not null,
+ TEMPLATE_ASSET_ID varchar(255),
+ OBJ_VERSION int8 not null,
+ ASSET_ID varchar(255) not null,
+ primary key (ID)
+);
+
+create table DEVICE_NOTIFICATION_TOKEN (
+ DEVICE_ID varchar(255) not null,
+ USER_ID varchar(36) not null,
+ DEVICE_TYPE varchar(255),
+ TOKEN varchar(4096) not null,
+ UPDATED_ON timestamp with time zone not null,
+ primary key (DEVICE_ID, USER_ID)
+);
+
+create table GLOBAL_RULESET (
+ ID int8 not null,
+ CREATED_ON timestamp with time zone not null,
+ ENABLED boolean not null,
+ LAST_MODIFIED timestamp with time zone not null,
+ NAME varchar(255) not null,
+ RULES text not null,
+ TEMPLATE_ASSET_ID varchar(255),
+ OBJ_VERSION int8 not null,
+ primary key (ID)
+);
+
+create table SYSLOG_EVENT (
+ ID int8 not null,
+ TIMESTAMP int8 not null,
+ CATEGORY varchar(255) not null,
+ LEVEL int4 not null,
+ MESSAGE varchar(131072),
+ SUBCATEGORY varchar(1024),
+ primary key (ID)
+);
+
+create table TENANT_RULESET (
+ ID int8 not null,
+ CREATED_ON timestamp with time zone not null,
+ ENABLED boolean not null,
+ LAST_MODIFIED timestamp with time zone not null,
+ NAME varchar(255) not null,
+ RULES text not null,
+ TEMPLATE_ASSET_ID varchar(255),
+ OBJ_VERSION int8 not null,
+ REALM_ID varchar(255) not null,
+ primary key (ID)
+);
+
+create table USER_ASSET (
+ ASSET_ID varchar(36) not null,
+ REALM_ID varchar(36) not null,
+ USER_ID varchar(36) not null,
+ CREATED_ON timestamp with time zone not null,
+ primary key (ASSET_ID, REALM_ID, USER_ID)
+);
+
+create table USER_CONFIGURATION (
+ USER_ID varchar(36) not null,
+ RESTRICTED boolean not null,
+ primary key (USER_ID)
+);
+
+/*
+ ############################# FUNCTIONS #############################
+ */
+create or replace function GET_ASSET_TREE_PATH(ASSET_ID text)
+ returns text [] as
+$$
+begin
+ return (with recursive ASSET_TREE(ID, PARENT_ID, PATH) as (
+ select
+ A1.ID,
+ A1.PARENT_ID,
+ array [text(A1.ID)]
+ from ASSET A1
+ where A1.ID = ASSET_ID
+ union all
+ select
+ A2.ID,
+ A2.PARENT_ID,
+ array_append(AT.PATH, text(A2.ID))
+ from ASSET A2, ASSET_TREE AT
+ where A2.ID = AT.PARENT_ID and AT.PARENT_ID is not null
+ ) select PATH
+ from ASSET_TREE
+ where PARENT_ID is null);
+end;
+$$
+language plpgsql;
+
+/*
+ ############################# CONSTRAINTS #############################
+ */
+
+alter table ASSET
+ add foreign key (PARENT_ID) references ASSET (ID);
+
+alter table ASSET
+ add foreign key (REALM_ID) references PUBLIC.REALM (ID);
+
+alter table ASSET_DATAPOINT
+ add foreign key (ENTITY_ID) references ASSET (ID) on delete cascade;
+
+alter table TENANT_RULESET
+ add foreign key (REALM_ID) references PUBLIC.REALM (ID);
+
+alter table ASSET_RULESET
+ add foreign key (ASSET_ID) references ASSET (ID) on delete cascade;
+
+alter table DEVICE_NOTIFICATION_TOKEN
+ add foreign key (USER_ID) references PUBLIC.USER_ENTITY (ID) on delete cascade;
+
+alter table USER_CONFIGURATION
+ add foreign key (USER_ID) references PUBLIC.USER_ENTITY (ID) on delete cascade;
+
+alter table USER_ASSET
+ add foreign key (USER_ID) references PUBLIC.USER_ENTITY (ID) on delete cascade;
+
+alter table USER_ASSET
+ add foreign key (ASSET_ID) references ASSET (ID) on delete cascade;
+
+alter table USER_ASSET
+ add foreign key (REALM_ID) references PUBLIC.REALM (ID) on delete cascade;
diff --git a/manager/server/src/main/resources/org/openremote/manager/server/setup/database/beforeClean.sql b/manager/server/src/main/resources/org/openremote/manager/server/setup/database/beforeClean.sql
new file mode 100644
index 000000000..a44e44770
--- /dev/null
+++ b/manager/server/src/main/resources/org/openremote/manager/server/setup/database/beforeClean.sql
@@ -0,0 +1,3 @@
+drop extension if exists POSTGIS cascade;
+drop extension if exists CITEXT cascade;
+drop extension if exists FUZZYSTRMATCH cascade;
\ No newline at end of file
diff --git a/manager/shared/src/main/java/org/openremote/manager/shared/asset/AssetResource.java b/manager/shared/src/main/java/org/openremote/manager/shared/asset/AssetResource.java
index d9e70393a..a3e9830ef 100644
--- a/manager/shared/src/main/java/org/openremote/manager/shared/asset/AssetResource.java
+++ b/manager/shared/src/main/java/org/openremote/manager/shared/asset/AssetResource.java
@@ -19,7 +19,6 @@
*/
package org.openremote.manager.shared.asset;
-import jsinterop.annotations.JsIgnore;
import jsinterop.annotations.JsType;
import org.openremote.manager.shared.http.RequestParams;
import org.openremote.manager.shared.http.SuccessStatusCode;
diff --git a/manager/shared/src/main/java/org/openremote/manager/shared/security/Tenant.java b/manager/shared/src/main/java/org/openremote/manager/shared/security/Tenant.java
index 6e8a5f422..d671fc349 100644
--- a/manager/shared/src/main/java/org/openremote/manager/shared/security/Tenant.java
+++ b/manager/shared/src/main/java/org/openremote/manager/shared/security/Tenant.java
@@ -34,7 +34,7 @@ import javax.validation.constraints.Size;
* This can be used (among other things) to query the REALM table in JPA queries.
*/
@Entity
-@Subselect("select * from REALM") // Map this immutable to an SQL view, don't use/create table
+@Subselect("select * from PUBLIC.REALM") // Map this immutable to an SQL view, don't use/create table
public class Tenant {
@Id
@@ -43,7 +43,7 @@ public class Tenant {
@Column(name = "NAME")
protected String realm;
- @Formula("(select ra.VALUE from REALM_ATTRIBUTE ra where ra.REALM_ID = ID and ra.name = 'displayName')")
+ @Formula("(select ra.VALUE from PUBLIC.REALM_ATTRIBUTE ra where ra.REALM_ID = ID and ra.name = 'displayName')")
protected String displayName;
@Column(name = "ENABLED")
diff --git a/manager/shared/src/main/java/org/openremote/manager/shared/security/User.java b/manager/shared/src/main/java/org/openremote/manager/shared/security/User.java
index 8aae49f19..69bd67b29 100644
--- a/manager/shared/src/main/java/org/openremote/manager/shared/security/User.java
+++ b/manager/shared/src/main/java/org/openremote/manager/shared/security/User.java
@@ -34,10 +34,10 @@ import javax.validation.constraints.Size;
* This can be used (among other things) to query the USER_ENTITY table in JPA queries.
*/
@Entity
-@Subselect("select * from USER_ENTITY") // Map this immutable to an SQL view, don't use/create table
+@Subselect("select * from PUBLIC.USER_ENTITY") // Map this immutable to an SQL view, don't use/create table
public class User {
- @Formula("(select r.NAME from REALM r where r.ID = REALM_ID)")
+ @Formula("(select r.NAME from PUBLIC.REALM r where r.ID = REALM_ID)")
protected String realm;
@Column(name = "REALM_ID")
diff --git a/model/src/main/java/org/openremote/model/asset/UserAsset.java b/model/src/main/java/org/openremote/model/asset/UserAsset.java
index ffb3cb840..6d50c6ecf 100644
--- a/model/src/main/java/org/openremote/model/asset/UserAsset.java
+++ b/model/src/main/java/org/openremote/model/asset/UserAsset.java
@@ -123,7 +123,7 @@ public class UserAsset {
@Formula("(select pa.NAME from ASSET a left outer join ASSET pa on a.PARENT_ID = pa.ID where a.ID = ASSET_ID)")
protected String parentAssetName;
- @Formula("(select u.USERNAME || ' (' || u.FIRST_NAME || ' ' || u.LAST_NAME || ')' from USER_ENTITY u where u.ID = USER_ID)")
+ @Formula("(select u.USERNAME || ' (' || u.FIRST_NAME || ' ' || u.LAST_NAME || ')' from PUBLIC.USER_ENTITY u where u.ID = USER_ID)")
protected String userFullName;
protected UserAsset() {
diff --git a/platform/rpi3/pi64/openremote-run.sh b/platform/rpi3/pi64/openremote-run.sh
index 900e21d9a..0af960dd0 100755
--- a/platform/rpi3/pi64/openremote-run.sh
+++ b/platform/rpi3/pi64/openremote-run.sh
@@ -10,14 +10,14 @@ export DEV_MODE=true
# If you are not running in developer mode, and this is the first time you are starting
# the application, you can configure which setup tasks you want to execute. Careful,
# these tasks will clean and populate the Manager database with demo data!
-export SETUP_INIT_CLEAN_DATABASE=true
+export SETUP_WIPE_CLEAN_INSTALL=true
export SETUP_BASIC_IDENTITY_ADMIN_PASSWORD=${SETUP_BASIC_IDENTITY_ADMIN_PASSWORD:-"secret"}
export SETUP_IMPORT_DEMO_USERS=true
export SETUP_IMPORT_DEMO_ASSETS=true
export SETUP_IMPORT_DEMO_RULES=true
# Use basic identity service instead of Keycloak, set master admin password
-export MANAGER_IDENTITY_PROVIDER=basic
+export IDENTITY_PROVIDER=basic
# The public host name of this OpenRemote installation. This name must be the name you
# access the web services under.
diff --git a/profile/demo.yml b/profile/demo.yml
index 83c5307d7..d11995533 100644
--- a/profile/demo.yml
+++ b/profile/demo.yml
@@ -5,38 +5,43 @@
#
# Install Docker Community edition (https://docker.com/) on Windows, macOS, or Linux.
#
-# Start the stack with:
+# Start a transient demo stack with:
#
# docker-compose -p openremote -f profile/demo.yml up
#
# For full documentation, see deploy.yml
#
-# This configuration does not store SSL certificate data and allow changes to the
-# proxy configuration. You can map a Docker volume or host directory to access/store
-# these files.
+# Steps to create a permanent installation:
#
-# This configuration expects manager deployment-specific data such as map tiles, console
-# application static resources (HTML, JS, CSS), and other configuration files
-# to be available in the '../deployment' directory. To set a custom deployment
-# directory, use env variable DEPLOYMENT_DIRECTORY.
+# 1. DO NOT FORGET TO CHANGE KEYCLOAK_PASSWORD!
+# 2. Consider setting a custom DOMAINNAME, see deploy.yml
+# 3. Understand how persistent data and volume mappings work, see below
+# 4. Execute once:
#
-# This configuration stores postgresql data in a Docker volume. You manage this volume
-# independently from your stack with with 'docker volume ls', 'docker volume rm', etc.
-# Alternatively, you can store postgresql data in a directory on your host.
+# SETUP_WIPE_CLEAN_INSTALL=true \
+# KEYCLOAK_PASSWORD=secret \
+# docker-compose -p openremote -f profile/demo.yml up
+#
+# This creates the initial database and optionally imports some examples. Inspect the
+# running installation and ensure it's working. You are now ready to restart the stack
+# without the clean wipe option. Passwords can be changed in the application.
+#
+# Database schemas will be upgraded to new versions of the services automatically, you do
+# not have to wipe all data to install a new version of OpenRemote.
#
version: '2.2'
# If you enable volume mappings in services, you need this. Otherwise, remove the volumes
volumes:
-# proxy-data:
-# name: proxy-data
-# manager-data:
-# name: manager-data
+ #proxy-data:
+ #manager-data:
postgresql-data:
- name: postgresql-data
services:
+ # This configuration does not store SSL certificate data and allow changes to the
+ # proxy configuration, it is configured for deployment on localhost. You can map a
+ # Docker volume or host directory to access/store these files.
proxy:
extends:
file: deploy.yml
@@ -49,6 +54,10 @@ services:
# - ${DEPLOYMENT_DIRECTORY:-../deployment}/proxy:/deployment
# - proxy-data:/deployment
+ # This configuration expects manager deployment-specific data such as map tiles,
+ # console application static resources (HTML, JS, CSS), and other configuration files
+ # to be available in the '../deployment' directory. To set a custom deployment
+ # directory, use env variable DEPLOYMENT_DIRECTORY.
manager:
extends:
file: deploy.yml
@@ -60,6 +69,12 @@ services:
# Store data either in host-mapped directory or a named Docker volume
- ${DEPLOYMENT_DIRECTORY:-../deployment}/manager:/deployment
# - manager-data:/deployment
+ environment:
+ # This switch can wipe all your Manager and Keycloak data, this is the factory reset!
+ SETUP_WIPE_CLEAN_INSTALL: 'true'
+ # When you are ready to permanently install your project, replace it with the next lines...
+ # SETUP_WIPE_CLEAN_INSTALL: # Allow override on CLI
+ # KEYCLOAK_PASSWORD: # Allow override on CLI
keycloak:
extends:
@@ -68,7 +83,15 @@ services:
depends_on:
postgresql:
condition: service_healthy
+ environment:
+ # CHANGE THIS PASSWORD BEFORE STARTING THE STACK! THIS IS ONLY FOR DEMO!
+ KEYCLOAK_PASSWORD: secret
+ # When you are ready to permanently install your project, replace it with the next line ...
+ # KEYCLOAK_PASSWORD: # Allow override on CLI
+ # This configuration stores postgresql data in a Docker volume. You manage this volume
+ # independently from your stack with with 'docker volume ls', 'docker volume rm', etc.
+ # Alternatively, you can store postgresql data in a directory on your host.
postgresql:
extends:
file: deploy.yml
diff --git a/profile/deploy-rpi.yml b/profile/deploy-rpi.yml
index 2e11ba1ab..7ef15c5e7 100644
--- a/profile/deploy-rpi.yml
+++ b/profile/deploy-rpi.yml
@@ -20,6 +20,21 @@ services:
service: manager
image: openremote/rpi-manager:latest
environment:
+ # This switch can wipe all your Manager and Keycloak data! Typically you would only run the
+ # stack once with this switch enabled to create the initial database and optionally import
+ # some examples. To go into production, ensure the postgresql service's data is permanently
+ # stored in a volume. Then disable the force clean switch, so you can restart services without
+ # wiping the database. The database schemas will be upgraded to new versions of the services
+ # automatically, you do not have to wipe all data to install a new version of OpenRemote.
+ SETUP_WIPE_CLEAN_INSTALL: 'true'
+
+ # If you force clean, a new master admin user will be created with this password.
+ SETUP_BASIC_IDENTITY_ADMIN_PASSWORD: secret
+
+ # Other demo data can be imported as needed, these examples only use the simulator protocol.
+ SETUP_IMPORT_DEMO_USERS: 'true'
+ SETUP_IMPORT_DEMO_ASSETS: 'true'
+ SETUP_IMPORT_DEMO_RULES: 'true'
+
# Use basic identity service instead of Keycloak, set master admin password
- MANAGER_IDENTITY_PROVIDER: basic
- SETUP_BASIC_IDENTITY_ADMIN_PASSWORD: 'secret'
\ No newline at end of file
+ IDENTITY_PROVIDER: basic
diff --git a/profile/deploy.yml b/profile/deploy.yml
index fce10e8a3..2d88e4a10 100644
--- a/profile/deploy.yml
+++ b/profile/deploy.yml
@@ -77,14 +77,11 @@ services:
# data. Some caching and other runtime performance-optimizations will also be disabled.
DEV_MODE: 'false'
- # If you are not running in developer mode, and this is the first time you are starting
- # the application, you can configure which setup tasks you want to execute. Careful,
- # these tasks will clean and populate Keycloak and the Manager database with demo data!
- SETUP_INIT_CLEAN_DATABASE: 'true'
- SETUP_KEYCLOAK_ADMIN_PASSWORD: secret
- SETUP_IMPORT_DEMO_USERS: 'true'
- SETUP_IMPORT_DEMO_ASSETS: 'true'
- SETUP_IMPORT_DEMO_RULES: 'true'
+ # This switch can wipe all your Manager and Keycloak data, this is the factory reset!
+ SETUP_WIPE_CLEAN_INSTALL: 'true'
+ # When you are ready to permanently install your project, replace it with the next lines...
+ # SETUP_WIPE_CLEAN_INSTALL: # Allow override on CLI
+ # KEYCLOAK_PASSWORD: # Allow override on CLI
# Optional: Configure SMTP smart host for Keycloak, to send password reset emails etc.
#SETUP_KEYCLOAK_EMAIL_HOST: smtp-host.demo.tld
@@ -95,6 +92,26 @@ services:
#SETUP_KEYCLOAK_EMAIL_TLS: 'true'
#SETUP_KEYCLOAK_EMAIL_FROM: '[email protected]'
+ # Other demo data can be imported as needed, these examples only use the simulator protocol.
+ SETUP_IMPORT_DEMO_USERS: 'true'
+ SETUP_IMPORT_DEMO_ASSETS: 'true'
+ SETUP_IMPORT_DEMO_RULES: 'true'
+
+ # Create a demo agent with example configurations for all built-in protocols:
+ #
+ # - KNX IP gateway
+ # - Velbus IP gateway or serial bridge
+ # - UPnP (asset discovery only)
+ #
+ SETUP_IMPORT_DEMO_AGENT: 'true'
+ SETUP_IMPORT_DEMO_AGENT_KNX: 'false'
+ #SETUP_IMPORT_DEMO_AGENT_KNX_GATEWAY_IP: '10.0.0.11'
+ #SETUP_IMPORT_DEMO_AGENT_KNX_LOCAL_IP: '10.0.0.12'
+ SETUP_IMPORT_DEMO_AGENT_VELBUS: 'false'
+ #SETUP_IMPORT_DEMO_AGENT_VELBUS_COM_PORT: 'COM3'
+ SETUP_IMPORT_DEMO_AGENT_UPNP: 'false'
+ # TODO: Additional docker settings are necessary to use com ports and multicast from within containers
+
# The public host name of this OpenRemote installation. This name is used in bearer tokens
# and must be the name you access the web services under. If you change proxy#DOMAINNAME, also
# change this to match.
@@ -156,7 +173,7 @@ services:
# access authorization. The default is Keycloak, which requires a separate service but
# provides full multi-tenancy identity and role management. The basic provider supports
# only superusers and their text passwords, managed in a simple database table.
- # MANAGER_IDENTITY_PROVIDER: 'basic'
+ # IDENTITY_PROVIDER: 'basic'
# SETUP_BASIC_IDENTITY_ADMIN_PASSWORD: 'secret'
# Location of the static manager (UI and API) resources, you don't need to override this
@@ -203,10 +220,10 @@ services:
# The master realm superuser, you should not change this.
KEYCLOAK_USER: admin
- # Change the admin root password if you make this application publicly accessible! Note
- # that imported demo data uses the admin account and also creates test users. Importing will
- # be broken if you change the password only here! Demo data should not be imported in production.
+ # CHANGE THIS PASSWORD BEFORE STARTING THE STACK! THIS IS ONLY FOR DEMO!
KEYCLOAK_PASSWORD: secret
+ # When you are ready to permanently install your project, replace it with the next line ...
+ # KEYCLOAK_PASSWORD: # Allow override on CLI
# Configure how Keycloak connects to the database
POSTGRES_DATABASE: openremote
@@ -235,7 +252,8 @@ services:
# Create database and user if there is no data. For production, run
# this once with your volume mapping for the data directory (see demo.yml),
- # then remove the variables and restart to preserve the stored data
+ # then remove the variables and restart to preserve the stored data. It
+ # doesn't hurt if you don't remove it, an existing will never be reconfigured.
POSTGRES_DB: openremote
POSTGRES_USER: openremote
POSTGRES_PASSWORD: CHANGE_ME_DB_USER_PASSWORD
diff --git a/profile/dev-console.yml b/profile/dev-console.yml
index 01e4539f7..09c0b44da 100644
--- a/profile/dev-console.yml
+++ b/profile/dev-console.yml
@@ -1,6 +1,12 @@
# Profile for doing development on the consoles and keycloak theme only.
# Starts haproxy, letsencrypt, keycloak with theme volumed mapped and postgres and exposes haproxy to localhost.
version: '2.2'
+
+volumes:
+ proxy-data:
+ #manager-data:
+ postgresql-data:
+
services:
proxy:
@@ -10,13 +16,13 @@ services:
depends_on:
manager:
condition: service_healthy
+ volumes:
+ - proxy-data:/deployment
manager:
extends:
file: deploy.yml
service: manager
- volumes:
- - ../deployment/manager:/deployment
environment:
DEV_MODE: 'true'
depends_on:
@@ -41,3 +47,5 @@ services:
extends:
file: deploy.yml
service: postgresql
+ volumes:
+ - postgresql-data:/deployment
diff --git a/project.gradle b/project.gradle
index 1c641f7c0..fd694c1b6 100644
--- a/project.gradle
+++ b/project.gradle
@@ -23,6 +23,17 @@ apply plugin: "eclipse"
// subproject, not for its children!)
version = hasProperty("openremoteVersion") ? openremoteVersion : projectVersion
+// Add bower tasks
+task bowerPrune(type: Exec){
+ commandLine "bower", "prune"
+ standardOutput = new ByteArrayOutputStream()
+}
+
+task bowerUpdate(type: Exec){
+ commandLine "bower", "update"
+ standardOutput = new ByteArrayOutputStream()
+}
+
// Configure Java build
plugins.withType(JavaPlugin).whenPluginAdded {
@@ -30,8 +41,8 @@ plugins.withType(JavaPlugin).whenPluginAdded {
tasks.withType(JavaCompile) {
sourceCompatibility = "1.8"
def warnLogFile = file("$buildDir/${name}Warnings.log")
- logging.addStandardErrorListener(new StandardOutputListener(){
- void onOutput(CharSequence output){
+ logging.addStandardErrorListener(new StandardOutputListener() {
+ void onOutput(CharSequence output) {
warnLogFile << output
}
})
@@ -61,3 +72,4 @@ ext {
resolveProject = this.&resolveProject
resolveTask = this.&resolveTask
}
+
diff --git a/test/src/test/groovy/org/openremote/test/admin/AdminTenantsActivityTest.groovy b/test/src/test/groovy/org/openremote/test/admin/AdminTenantsActivityTest.groovy
index 34b6ba8b0..2aa36d6bd 100644
--- a/test/src/test/groovy/org/openremote/test/admin/AdminTenantsActivityTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/admin/AdminTenantsActivityTest.groovy
@@ -37,8 +37,8 @@ import spock.lang.Specification
import spock.util.concurrent.PollingConditions
import static org.openremote.container.util.MapAccess.getString
-import static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD
-import static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT
+import static org.openremote.manager.server.setup.AbstractKeycloakSetup.KEYCLOAK_PASSWORD
+import static org.openremote.manager.server.setup.AbstractKeycloakSetup.KEYCLOAK_PASSWORD_DEFAULT
import static org.openremote.model.Constants.*
class AdminTenantsActivityTest extends Specification implements ManagerContainerTrait, GwtClientTrait {
@@ -64,7 +64,7 @@ class AdminTenantsActivityTest extends Specification implements ManagerContainer
realm,
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
- getString(container.getConfig(), SETUP_KEYCLOAK_ADMIN_PASSWORD, SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT)
+ getString(container.getConfig(), KEYCLOAK_PASSWORD, KEYCLOAK_PASSWORD_DEFAULT)
).token
}
def securityService = new ClientSecurityService(keycloakProvider.getKeycloakDeployment(realm, KEYCLOAK_CLIENT_ID), accessToken)
diff --git a/test/src/test/groovy/org/openremote/test/admin/AdminUsersActivityTest.groovy b/test/src/test/groovy/org/openremote/test/admin/AdminUsersActivityTest.groovy
index 9e293b3ed..ac0471d09 100644
--- a/test/src/test/groovy/org/openremote/test/admin/AdminUsersActivityTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/admin/AdminUsersActivityTest.groovy
@@ -41,8 +41,8 @@ import spock.util.concurrent.BlockingVariables
import spock.util.concurrent.PollingConditions
import static org.openremote.container.util.MapAccess.getString
-import static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD
-import static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT
+import static org.openremote.manager.server.setup.AbstractKeycloakSetup.KEYCLOAK_PASSWORD
+import static org.openremote.manager.server.setup.AbstractKeycloakSetup.KEYCLOAK_PASSWORD_DEFAULT
import static org.openremote.model.Constants.*
class AdminUsersActivityTest extends Specification implements ManagerContainerTrait, GwtClientTrait {
@@ -70,7 +70,7 @@ class AdminUsersActivityTest extends Specification implements ManagerContainerTr
realm,
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
- getString(container.getConfig(), SETUP_KEYCLOAK_ADMIN_PASSWORD, SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT)
+ getString(container.getConfig(), KEYCLOAK_PASSWORD, KEYCLOAK_PASSWORD_DEFAULT)
).token
}
def securityService = new ClientSecurityService(keycloakProvider.getKeycloakDeployment(realm, KEYCLOAK_CLIENT_ID), accessToken)
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetBrowserPresenterTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetBrowserPresenterTest.groovy
index 53efbb749..521096640 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetBrowserPresenterTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetBrowserPresenterTest.groovy
@@ -39,8 +39,8 @@ import spock.util.concurrent.PollingConditions
import static org.openremote.container.util.MapAccess.getString
import static org.openremote.manager.server.event.ClientEventService.WEBSOCKET_EVENTS
-import static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD
-import static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT
+import static org.openremote.manager.server.setup.AbstractKeycloakSetup.KEYCLOAK_PASSWORD
+import static org.openremote.manager.server.setup.AbstractKeycloakSetup.KEYCLOAK_PASSWORD_DEFAULT
import static org.openremote.model.Constants.*
class AssetBrowserPresenterTest extends Specification implements ManagerContainerTrait, GwtClientTrait {
@@ -64,11 +64,11 @@ class AssetBrowserPresenterTest extends Specification implements ManagerContaine
realm,
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
- getString(container.getConfig(), SETUP_KEYCLOAK_ADMIN_PASSWORD, SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT)
+ getString(container.getConfig(), KEYCLOAK_PASSWORD, KEYCLOAK_PASSWORD_DEFAULT)
).token
}
def securityService = new ClientSecurityService(keycloakProvider.getKeycloakDeployment(realm, KEYCLOAK_CLIENT_ID), accessToken)
- def currentTenant = identityService.identityProvider.getTenantForRealm(realm)
+ def currentTenant = identityService.initIdentityProvider.getTenantForRealm(realm)
and: "a client request service and target"
def constraintViolationReader = new ClientObjectMapper(container.JSON, ConstraintViolationReport.class) as EntityReader<ConstraintViolationReport>
@@ -267,7 +267,7 @@ class AssetBrowserPresenterTest extends Specification implements ManagerContaine
).token
}
def securityService = new ClientSecurityService(keycloakProvider.getKeycloakDeployment(realm, KEYCLOAK_CLIENT_ID), accessToken)
- def currentTenant = identityService.identityProvider.getTenantForRealm(realm)
+ def currentTenant = identityService.initIdentityProvider.getTenantForRealm(realm)
and: "a client request service and target"
def constraintViolationReader = new ClientObjectMapper(container.JSON, ConstraintViolationReport.class) as EntityReader<ConstraintViolationReport>
@@ -446,7 +446,7 @@ class AssetBrowserPresenterTest extends Specification implements ManagerContaine
).token
}
def securityService = new ClientSecurityService(keycloakProvider.getKeycloakDeployment(realm, KEYCLOAK_CLIENT_ID), accessToken)
- def currentTenant = identityService.identityProvider.getTenantForRealm(realm)
+ def currentTenant = identityService.initIdentityProvider.getTenantForRealm(realm)
and: "a client request service and target"
def constraintViolationReader = new ClientObjectMapper(container.JSON, ConstraintViolationReport.class) as EntityReader<ConstraintViolationReport>
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetIntegrityTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetIntegrityTest.groovy
index 0a915e58d..c652d5b5a 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetIntegrityTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetIntegrityTest.groovy
@@ -17,8 +17,8 @@ import spock.util.concurrent.PollingConditions
import javax.ws.rs.WebApplicationException
import static org.openremote.container.util.MapAccess.getString
-import static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD
-import static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT
+import static org.openremote.manager.server.setup.AbstractKeycloakSetup.KEYCLOAK_PASSWORD
+import static org.openremote.manager.server.setup.AbstractKeycloakSetup.KEYCLOAK_PASSWORD_DEFAULT
import static org.openremote.model.Constants.*
class AssetIntegrityTest extends Specification implements ManagerContainerTrait {
@@ -36,7 +36,7 @@ class AssetIntegrityTest extends Specification implements ManagerContainerTrait
MASTER_REALM,
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
- getString(container.getConfig(), SETUP_KEYCLOAK_ADMIN_PASSWORD, SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT)
+ getString(container.getConfig(), KEYCLOAK_PASSWORD, KEYCLOAK_PASSWORD_DEFAULT)
).token
and: "the asset resource"
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy
index be7918d90..c2c34637a 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy
@@ -17,8 +17,8 @@ import spock.util.concurrent.PollingConditions
import javax.ws.rs.WebApplicationException
import static org.openremote.container.util.MapAccess.getString
-import static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD
-import static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT
+import static org.openremote.manager.server.setup.AbstractKeycloakSetup.KEYCLOAK_PASSWORD
+import static org.openremote.manager.server.setup.AbstractKeycloakSetup.KEYCLOAK_PASSWORD_DEFAULT
import static org.openremote.model.Constants.*
import static org.openremote.model.asset.AssetMeta.LABEL
import static org.openremote.model.attribute.AttributeType.NUMBER
@@ -41,7 +41,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
MASTER_REALM,
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
- getString(container.getConfig(), SETUP_KEYCLOAK_ADMIN_PASSWORD, SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT)
+ getString(container.getConfig(), KEYCLOAK_PASSWORD, KEYCLOAK_PASSWORD_DEFAULT)
).token
and: "the asset resource"
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetUserLinkingTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetUserLinkingTest.groovy
index e2735bf84..89d96976e 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetUserLinkingTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetUserLinkingTest.groovy
@@ -13,8 +13,8 @@ import spock.lang.Specification
import javax.ws.rs.WebApplicationException
import static org.openremote.container.util.MapAccess.getString
-import static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD
-import static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT
+import static org.openremote.manager.server.setup.AbstractKeycloakSetup.KEYCLOAK_PASSWORD
+import static org.openremote.manager.server.setup.AbstractKeycloakSetup.KEYCLOAK_PASSWORD_DEFAULT
import static org.openremote.model.Constants.*
class AssetUserLinkingTest extends Specification implements ManagerContainerTrait {
@@ -34,7 +34,7 @@ class AssetUserLinkingTest extends Specification implements ManagerContainerTrai
MASTER_REALM,
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
- getString(container.getConfig(), SETUP_KEYCLOAK_ADMIN_PASSWORD, SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT)
+ getString(container.getConfig(), KEYCLOAK_PASSWORD, KEYCLOAK_PASSWORD_DEFAULT)
).token
and: "the asset resource"
@@ -43,9 +43,9 @@ class AssetUserLinkingTest extends Specification implements ManagerContainerTrai
/* ############################################## READ ####################################### */
expect: "some users to be restricted"
- !identityService.identityProvider.isRestrictedUser(keycloakDemoSetup.testuser1Id)
- !identityService.identityProvider.isRestrictedUser(keycloakDemoSetup.testuser2Id)
- identityService.identityProvider.isRestrictedUser(keycloakDemoSetup.testuser3Id)
+ !identityService.initIdentityProvider.isRestrictedUser(keycloakDemoSetup.testuser1Id)
+ !identityService.initIdentityProvider.isRestrictedUser(keycloakDemoSetup.testuser2Id)
+ identityService.initIdentityProvider.isRestrictedUser(keycloakDemoSetup.testuser3Id)
when: "all user assets are retrieved of a realm"
def userAssets = assetResource.getUserAssetLinks(null, keycloakDemoSetup.customerATenant.id, null, null)
@@ -147,7 +147,7 @@ class AssetUserLinkingTest extends Specification implements ManagerContainerTrai
userAssets = assetResource.getUserAssetLinks(null, keycloakDemoSetup.customerATenant.id, keycloakDemoSetup.testuser2Id, null)
then: "result should match"
- identityService.identityProvider.isRestrictedUser(keycloakDemoSetup.testuser2Id)
+ identityService.initIdentityProvider.isRestrictedUser(keycloakDemoSetup.testuser2Id)
userAssets.length == 1
userAssets.any {
it.id.realmId == keycloakDemoSetup.customerATenant.id &&
@@ -164,7 +164,7 @@ class AssetUserLinkingTest extends Specification implements ManagerContainerTrai
userAssets = assetResource.getUserAssetLinks(null, keycloakDemoSetup.customerATenant.id, keycloakDemoSetup.testuser2Id, null)
then: "result should match"
- !identityService.identityProvider.isRestrictedUser(keycloakDemoSetup.testuser2Id)
+ !identityService.initIdentityProvider.isRestrictedUser(keycloakDemoSetup.testuser2Id)
userAssets.length == 0
cleanup: "the server should be stopped"
diff --git a/test/src/test/groovy/org/openremote/test/map/MapResourceTest.groovy b/test/src/test/groovy/org/openremote/test/map/MapResourceTest.groovy
index c51c8c650..c70b2f345 100644
--- a/test/src/test/groovy/org/openremote/test/map/MapResourceTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/map/MapResourceTest.groovy
@@ -23,7 +23,7 @@ class MapResourceTest extends Specification implements ManagerContainerTrait {
realm,
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
- getString(container.getConfig(), SETUP_KEYCLOAK_ADMIN_PASSWORD, SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT)
+ getString(container.getConfig(), KEYCLOAK_PASSWORD, KEYCLOAK_PASSWORD_DEFAULT)
).token
and: "a test client target"
diff --git a/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy
index 3b878e65c..fc007b7d7 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy
@@ -42,8 +42,8 @@ import spock.util.concurrent.PollingConditions
import static org.openremote.container.util.MapAccess.getString
import static org.openremote.manager.server.event.ClientEventService.WEBSOCKET_EVENTS
-import static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD
-import static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT
+import static org.openremote.manager.server.setup.AbstractKeycloakSetup.KEYCLOAK_PASSWORD
+import static org.openremote.manager.server.setup.AbstractKeycloakSetup.KEYCLOAK_PASSWORD_DEFAULT
import static org.openremote.model.Constants.KEYCLOAK_CLIENT_ID
import static org.openremote.model.Constants.MASTER_REALM
import static org.openremote.model.Constants.MASTER_REALM_ADMIN_USER
@@ -176,7 +176,7 @@ class BasicProtocolTest extends Specification implements ManagerContainerTrait,
MASTER_REALM,
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
- getString(container.getConfig(), SETUP_KEYCLOAK_ADMIN_PASSWORD, SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT)
+ getString(container.getConfig(), KEYCLOAK_PASSWORD, KEYCLOAK_PASSWORD_DEFAULT)
).token
}
List<SharedEvent> collectedSharedEvents = []
diff --git a/test/src/test/groovy/org/openremote/test/protocol/KNXImportTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/KNXImportTest.groovy
index d6839422a..6e2ba60c9 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/KNXImportTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/KNXImportTest.groovy
@@ -20,8 +20,8 @@
package org.openremote.test.protocol
import static org.openremote.model.Constants.*
-import static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD
-import static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT
+import static org.openremote.manager.server.setup.AbstractKeycloakSetup.KEYCLOAK_PASSWORD
+import static org.openremote.manager.server.setup.AbstractKeycloakSetup.KEYCLOAK_PASSWORD_DEFAULT
import static org.openremote.container.util.MapAccess.getString
import org.openremote.agent.protocol.knx.KNXProtocol
@@ -81,7 +81,7 @@ class KNXImportTest extends Specification implements ManagerContainerTrait {
MASTER_REALM,
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
- getString(container.getConfig(), SETUP_KEYCLOAK_ADMIN_PASSWORD, SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT)
+ getString(container.getConfig(), KEYCLOAK_PASSWORD, KEYCLOAK_PASSWORD_DEFAULT)
).token
and: "the agent resource"
diff --git a/test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusProtocolTest.groovy
index 912882025..1fc566ce6 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusProtocolTest.groovy
@@ -28,8 +28,8 @@ import spock.lang.Specification
import spock.util.concurrent.PollingConditions
import static org.openremote.container.util.MapAccess.getString
-import static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD
-import static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT
+import static org.openremote.manager.server.setup.AbstractKeycloakSetup.KEYCLOAK_PASSWORD
+import static org.openremote.manager.server.setup.AbstractKeycloakSetup.KEYCLOAK_PASSWORD_DEFAULT
import static org.openremote.model.Constants.*
import static org.openremote.model.asset.agent.ProtocolConfiguration.initProtocolConfiguration
@@ -177,7 +177,7 @@ class VelbusProtocolTest extends Specification implements ManagerContainerTrait
MASTER_REALM,
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
- getString(container.getConfig(), SETUP_KEYCLOAK_ADMIN_PASSWORD, SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT)
+ getString(container.getConfig(), KEYCLOAK_PASSWORD, KEYCLOAK_PASSWORD_DEFAULT)
).token
and: "the agent resource"
diff --git a/test/src/test/groovy/org/openremote/test/rules/BasicRulesDeploymentTest.groovy b/test/src/test/groovy/org/openremote/test/rules/BasicRulesDeploymentTest.groovy
index c2018ddc6..613299c0c 100644
--- a/test/src/test/groovy/org/openremote/test/rules/BasicRulesDeploymentTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/BasicRulesDeploymentTest.groovy
@@ -16,8 +16,8 @@ import spock.lang.Specification
import spock.util.concurrent.PollingConditions
import static org.openremote.container.util.MapAccess.getString
-import static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD
-import static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT
+import static org.openremote.manager.server.setup.AbstractKeycloakSetup.KEYCLOAK_PASSWORD
+import static org.openremote.manager.server.setup.AbstractKeycloakSetup.KEYCLOAK_PASSWORD_DEFAULT
import static org.openremote.model.Constants.*
class BasicRulesDeploymentTest extends Specification implements ManagerContainerTrait {
@@ -45,7 +45,7 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
MASTER_REALM,
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
- getString(container.getConfig(), SETUP_KEYCLOAK_ADMIN_PASSWORD, SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT)
+ getString(container.getConfig(), KEYCLOAK_PASSWORD, KEYCLOAK_PASSWORD_DEFAULT)
).token
expect: "the rules engines to be ready"
@@ -210,7 +210,7 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
def apartment3Engine = rulesService.assetEngines.get(managerDemoSetup.apartment3Id)
def customerATenant = keycloakDemoSetup.customerATenant
customerATenant.setEnabled(false)
- identityService.identityProvider.updateTenant(new ClientRequestInfo(null, accessToken), customerATenant.getRealm(), customerATenant)
+ identityService.initIdentityProvider.updateTenant(new ClientRequestInfo(null, accessToken), customerATenant.getRealm(), customerATenant)
then: "the tenants rule engine should stop and all asset rule engines in this realm should also stop"
conditions.eventually {
@@ -236,7 +236,7 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
when: "the disabled tenant is re-enabled"
customerATenant.setEnabled(true)
- identityService.identityProvider.updateTenant(new ClientRequestInfo(null, accessToken), customerATenant.getRealm(), customerATenant)
+ identityService.initIdentityProvider.updateTenant(new ClientRequestInfo(null, accessToken), customerATenant.getRealm(), customerATenant)
then: "the tenants rule engine should start and all asset rule engines from this realm should also start"
conditions.eventually {
diff --git a/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovy b/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovy
index aedcd8931..5dd22eca9 100644
--- a/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovy
@@ -16,8 +16,8 @@ import spock.util.concurrent.PollingConditions
import javax.ws.rs.WebApplicationException
import static org.openremote.container.util.MapAccess.getString
-import static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD
-import static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT
+import static org.openremote.manager.server.setup.AbstractKeycloakSetup.KEYCLOAK_PASSWORD
+import static org.openremote.manager.server.setup.AbstractKeycloakSetup.KEYCLOAK_PASSWORD_DEFAULT
import static org.openremote.model.Constants.*
class BasicRulesetResourceTest extends Specification implements ManagerContainerTrait {
@@ -40,7 +40,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
MASTER_REALM,
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
- getString(container.getConfig(), SETUP_KEYCLOAK_ADMIN_PASSWORD, SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT)
+ getString(container.getConfig(), KEYCLOAK_PASSWORD, KEYCLOAK_PASSWORD_DEFAULT)
).token
and: "the ruleset resource"
diff --git a/test/src/test/groovy/org/openremote/test/user/NotificationServiceTest.groovy b/test/src/test/groovy/org/openremote/test/user/NotificationServiceTest.groovy
index 485f0d837..a7f59ac0d 100644
--- a/test/src/test/groovy/org/openremote/test/user/NotificationServiceTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/user/NotificationServiceTest.groovy
@@ -18,8 +18,8 @@ import spock.lang.Specification
import javax.ws.rs.WebApplicationException
import static org.openremote.container.util.MapAccess.getString
-import static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD
-import static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT
+import static org.openremote.manager.server.setup.AbstractKeycloakSetup.KEYCLOAK_PASSWORD
+import static org.openremote.manager.server.setup.AbstractKeycloakSetup.KEYCLOAK_PASSWORD_DEFAULT
import static org.openremote.model.Constants.KEYCLOAK_CLIENT_ID
import static org.openremote.model.Constants.MASTER_REALM
import static org.openremote.model.Constants.MASTER_REALM_ADMIN_USER
@@ -67,7 +67,7 @@ class NotificationServiceTest extends Specification implements ManagerContainerT
MASTER_REALM,
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
- getString(container.getConfig(), SETUP_KEYCLOAK_ADMIN_PASSWORD, SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT)
+ getString(container.getConfig(), KEYCLOAK_PASSWORD, KEYCLOAK_PASSWORD_DEFAULT)
).token
def notification = new AlertNotification(