Пример #1
0
 /*
  * Serializers, deserializers, renderengines etc... all have counterparts as
  * objects in the database for configuration purposes, this methods syncs
  * both versions
  */
 private void createDatabaseObjects(DatabaseSession session)
     throws BimserverLockConflictException, BimserverDatabaseException, PluginException,
         BimserverConcurrentModificationDatabaseException {
   IfcModelInterface allOfType =
       session.getAllOfType(StorePackage.eINSTANCE.getUser(), Query.getDefault());
   for (User user : allOfType.getAll(User.class)) {
     updateUserSettings(session, user);
   }
 }
Пример #2
0
 public void update() {
   try {
     serverInfo.setVersion(
         bimServer
             .getSConverter()
             .convertFromSObject(bimServer.getVersionChecker().getLocalVersion(), null));
   } catch (BimserverDatabaseException e) {
     LOGGER.error("", e);
   }
   if (bimServer.getDatabase().getMigrator().migrationRequired()) {
     setServerState(ServerState.MIGRATION_REQUIRED);
     if (bimServer.getConfig().isAutoMigrate()) {
       try {
         bimServer.getDatabase().getMigrator().migrate();
         setServerState(ServerState.RUNNING);
       } catch (MigrationException | InconsistentModelsException e) {
         LOGGER.error("", e);
       }
     }
   } else if (bimServer.getDatabase().getMigrator().migrationImpossible()) {
     setServerState(ServerState.MIGRATION_IMPOSSIBLE);
   } else {
     DatabaseSession session = bimServer.getDatabase().createSession();
     try {
       boolean adminFound = false;
       ServerSettings settings = bimServer.getServerSettingsCache().getServerSettings();
       IfcModelInterface users =
           session.getAllOfType(StorePackage.eINSTANCE.getUser(), Query.getDefault());
       for (IdEObject idEObject : users.getValues()) {
         if (idEObject instanceof User) {
           User user = (User) idEObject;
           if (user.getUserType() == UserType.ADMIN) {
             adminFound = true;
             break;
           }
         }
       }
       if (settings.getSiteAddress().isEmpty()
           || settings.getSmtpServer().isEmpty()
           || !adminFound) {
         setServerState(ServerState.NOT_SETUP);
       } else {
         setServerState(ServerState.RUNNING);
       }
     } catch (BimserverDatabaseException e) {
       LOGGER.error("", e);
     } finally {
       session.close();
     }
   }
 }