java.lang.Object
org.gcube.informationsystem.resourceregistry.dbinitialization.DatabaseEnvironment

public class DatabaseEnvironment extends Object
Static, class-loading-time bootstrap of the OrientDB connection and, on a genuinely fresh database, of the whole security-partition and type-schema layout.

Configuration (the database section of "service.yaml" on the classpath) is loaded once into static final fields the first time this class is loaded. The same static initializer then calls initGraphDB(): if the configured OrientDB database does not exist yet, it is created, Record-Level Security is enabled (setRecordLevelSecurity(OMetadata)), and the administrative user/password are set up; only in that case (created == true) does the initializer go on to create the AdminEnvironment, QueryTemplateEnvironment, TypeEnvironment, and the Context partition tree (ContextEnvironment parent, then its LiveContextEnvironment and CemeteryContextEnvironment children — the parent must exist first so hierarchical role propagation applies at child creation), and finally runs IsModelBootstrap.bootstrap(boolean) to register every information-system-model type. On every subsequent JVM start against an already-initialized database, none of that one-time setup runs again.

Author:
Luca Frosini (ISTI - CNR)
  • Field Details

    • DISCOVER_ALL_REGISTRATION_PROVIDERS

      public static final boolean DISCOVER_ALL_REGISTRATION_PROVIDERS
      Whether bootstrap Discovery scans packages contributed by external RegistrationProvider SPI implementations (e.g. gcube-model's), in addition to information-system-model's own intrinsic packages (always scanned regardless). Defaults to false when absent from "service.yaml" — harmless in production, where no such SPI-contributed provider is ever present on the classpath; test environments that rely on an external provider's types (e.g. gcube-model) must set this explicitly to true. It also decides whether the domain provider identifies the model (ModelIdentityResolver) and whether a migration realigns its types.
    • RUNTIME_MODEL_NAME

      public static final String RUNTIME_MODEL_NAME
      Operator-declared name of the runtime model, the one holding the types created through REST (see ModelIdentityResolver). null when absent from "service.yaml": the resolver's default applies.
    • DEFAULT_ADMIN_ROLE

      public static final String DEFAULT_ADMIN_ROLE
      The default administrative role name.
      See Also:
    • DEFAULT_PASSWORDS

      public static final Map<Environment.PermissionMode,String> DEFAULT_PASSWORDS
      Default passwords for the read/write database accounts.
    • DB_URI

      public static final String DB_URI
      The database server URI.
    • CONNECTION_STRATEGY_PARAMETER

      public static final com.orientechnologies.orient.client.remote.OStorageRemote.CONNECTION_STRATEGY CONNECTION_STRATEGY_PARAMETER
      The connection strategy parameter to use.
    • DB_KEY_FILENAME_VARNAME

      protected static final String DB_KEY_FILENAME_VARNAME
      INI variable name for key file.
      See Also:
    • DB_KEY_ALGORITHM_VARNAME

      protected static final String DB_KEY_ALGORITHM_VARNAME
      INI variable name for key algorithm.
      See Also:
    • VERTEX_CLASS_NAME

      public static final String VERTEX_CLASS_NAME
      OrientDB standard Vertex class name.
      See Also:
    • EDGE_CLASS_NAME

      public static final String EDGE_CLASS_NAME
      OrientDB standard Edge class name.
      See Also:
  • Constructor Details

    • DatabaseEnvironment

      public DatabaseEnvironment()
  • Method Details

    • initDbKey

      protected static Key initDbKey(Map<String,String> dbSection)
      Initializes the database key.
      Parameters:
      dbSection - the database section of the configuration profile
      Returns:
      the initialized key
    • setDateTimeFormat

      protected static void setDateTimeFormat(com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument)
      Sets the datetime format attribute for the given database connection.
      Parameters:
      oDatabaseDocument - the OrientDB database connection
    • setRecordLevelSecurity

      @Deprecated protected static void setRecordLevelSecurity(com.orientechnologies.orient.core.metadata.OMetadata oMetadata)
      Deprecated.
      This code must be removed for OrientDB versions higher than 3.2.X
      Configures Record-Level Security (RLS) on Vertex and Edge classes.
      Parameters:
      oMetadata - the OrientDB schema metadata
    • getDatabaseKey

      public static Key getDatabaseKey()
      Returns the initialized database cryptographic symmetric key.
      Returns:
      the symmetric database key
    • changeDefaultAdminPassword

      @Deprecated public static void changeDefaultAdminPassword(com.orientechnologies.orient.core.metadata.security.OSecurity oSecurity)
      Deprecated.
      This code must be removed for OrientDB versions higher than 3.2.X
      Changes the default passwords for database administrative accounts.
      Parameters:
      oSecurity - the OrientDB security context