Program: 160352
Project: 160352
Buggy source:
public void start() throws DatabaseInitException, BimserverDatabaseException, PluginException, DatabaseRestartRequiredException, ServerException {
  try {
    LOGGER.debug("String_Node_Str");
    SVersion localVersion=versionChecker.getLocalVersion();
    if (localVersion != null) {
      LOGGER.info("String_Node_Str" + localVersion.getFullString());
    }
 else {
      LOGGER.info("String_Node_Str");
    }
    try {
      pluginManager.setPluginChangeListener(new PluginChangeListener(){
        @Override public void pluginStateChanged(        PluginContext pluginContext,        boolean enabled){
          Condition pluginCondition=new AttributeCondition(StorePackage.eINSTANCE.getPluginDescriptor_PluginClassName(),new StringLiteral(pluginContext.getPlugin().getClass().getName()));
          DatabaseSession session=bimDatabase.createSession();
          try {
            Map<Long,PluginDescriptor> pluginsFound=session.query(pluginCondition,PluginDescriptor.class,OldQuery.getDefault());
            if (pluginsFound.size() == 0) {
              LOGGER.error("String_Node_Str" + pluginContext.getPlugin().getClass().getName() + "String_Node_Str");
            }
 else             if (pluginsFound.size() == 1) {
              PluginDescriptor pluginConfiguration=pluginsFound.values().iterator().next();
              pluginConfiguration.setEnabled(pluginContext.isEnabled());
              session.store(pluginConfiguration);
            }
 else {
              LOGGER.error("String_Node_Str" + pluginContext.getPlugin().getClass().getName());
            }
            session.commit();
          }
 catch (          BimserverDatabaseException e) {
            LOGGER.error("String_Node_Str",e);
          }
catch (          ServiceException e) {
            LOGGER.error("String_Node_Str",e);
          }
 finally {
            session.close();
          }
        }
        @Override public long pluginBundleUpdated(        PluginBundle pluginBundle){
          SPluginBundleVersion sPluginBundleVersion=pluginBundle.getPluginBundleVersion();
          try (DatabaseSession session=bimDatabase.createSession()){
            PluginBundleVersion current=null;
            IfcModelInterface allOfType=session.getAllOfType(StorePackage.eINSTANCE.getPluginBundleVersion(),OldQuery.getDefault());
            for (            PluginBundleVersion pbv : allOfType.getAll(PluginBundleVersion.class)) {
              if (pbv.getGroupId().equals(pluginBundle.getPluginBundleVersion().getGroupId()) && pbv.getArtifactId().equals(pluginBundle.getPluginBundleVersion().getArtifactId())) {
                current=pbv;
              }
            }
            if (current != null) {
              current.setDescription(sPluginBundleVersion.getArtifactId());
              current.setIcon(sPluginBundleVersion.getIcon());
              current.setMismatch(sPluginBundleVersion.isMismatch());
              current.setRepository(sPluginBundleVersion.getRepository());
              current.setType(getSConverter().convertFromSObject(sPluginBundleVersion.getType()));
              current.setVersion(sPluginBundleVersion.getVersion());
              current.setOrganization(sPluginBundleVersion.getOrganization());
              current.setName(sPluginBundleVersion.getName());
              session.store(current);
              session.commit();
            }
            return current.getOid();
          }
 catch (          BimserverDatabaseException e) {
            LOGGER.error("String_Node_Str",e);
          }
catch (          ServiceException e) {
            LOGGER.error("String_Node_Str",e);
          }
          return -1;
        }
        @Override public void pluginUpdated(        long pluginBundleVersionId,        PluginContext newPluginContext,        SPluginInformation sPluginInformation) throws BimserverDatabaseException {
          try (DatabaseSession session=bimDatabase.createSession()){
            Plugin plugin=newPluginContext.getPlugin();
            Condition pluginCondition=new AttributeCondition(StorePackage.eINSTANCE.getPluginDescriptor_Identifier(),new StringLiteral(newPluginContext.getIdentifier()));
            Map<Long,PluginDescriptor> pluginsFound=session.query(pluginCondition,PluginDescriptor.class,OldQuery.getDefault());
            for (            PluginDescriptor pluginDescriptor : pluginsFound.values()) {
              pluginDescriptor.setIdentifier(newPluginContext.getIdentifier());
              pluginDescriptor.setPluginClassName(plugin.getClass().getName());
              pluginDescriptor.setDescription(newPluginContext.getDescription());
              pluginDescriptor.setName(sPluginInformation.getName());
              pluginDescriptor.setLocation(newPluginContext.getLocation().toString());
              pluginDescriptor.setPluginInterfaceClassName(getPluginInterface(plugin.getClass()).getName());
              pluginDescriptor.setEnabled(sPluginInformation.isEnabled());
              pluginDescriptor.setInstallForNewUsers(sPluginInformation.isInstallForNewUsers());
              PluginBundleVersion value=session.get(pluginBundleVersionId,OldQuery.getDefault());
              pluginDescriptor.setPluginBundleVersion(value);
              session.store(pluginDescriptor);
              if (sPluginInformation.isInstallForAllUsers()) {
                IfcModelInterface allOfType=session.getAllOfType(StorePackage.eINSTANCE.getUser(),OldQuery.getDefault());
                for (                User user : allOfType.getAll(User.class)) {
                  if (user.getState() == ObjectState.ACTIVE) {
                    updateUserPlugin(session,user,pluginDescriptor,newPluginContext);
                  }
                }
              }
              if (newPluginContext.getPlugin() instanceof WebModulePlugin) {
                ServerSettings serverSettings=getServerSettingsCache().getServerSettings();
                WebModulePluginConfiguration webPluginConfiguration=find(serverSettings.getWebModules(),newPluginContext.getIdentifier());
                if (webPluginConfiguration == null) {
                  webPluginConfiguration=session.create(WebModulePluginConfiguration.class);
                  serverSettings.getWebModules().add(webPluginConfiguration);
                  genericPluginConversion(newPluginContext,session,webPluginConfiguration,pluginDescriptor);
                  String contextPath="String_Node_Str";
                  for (                  Parameter parameter : webPluginConfiguration.getSettings().getParameters()) {
                    if (parameter.getName().equals("String_Node_Str")) {
                      contextPath=((StringType)parameter.getValue()).getValue();
                    }
                  }
                  String identifier=webPluginConfiguration.getPluginDescriptor().getIdentifier();
                  webModules.put(contextPath,(WebModulePlugin)pluginManager.getPlugin(identifier,true));
                }
              }
            }
            try {
              session.commit();
            }
 catch (            ServiceException e) {
              LOGGER.error("String_Node_Str",e);
            }
          }
         }
        @Override public void pluginInstalled(        long pluginBundleVersionId,        PluginContext pluginContext,        SPluginInformation sPluginInformation) throws BimserverDatabaseException {
          try (DatabaseSession session=bimDatabase.createSession()){
            Plugin plugin=pluginContext.getPlugin();
            PluginDescriptor pluginDescriptor=session.create(PluginDescriptor.class);
            pluginDescriptor.setIdentifier(pluginContext.getIdentifier());
            pluginDescriptor.setPluginClassName(plugin.getClass().getName());
            pluginDescriptor.setDescription(pluginContext.getDescription());
            pluginDescriptor.setName(sPluginInformation.getName());
            pluginDescriptor.setLocation(pluginContext.getLocation().toString());
            pluginDescriptor.setPluginInterfaceClassName(getPluginInterface(plugin.getClass()).getName());
            pluginDescriptor.setEnabled(sPluginInformation.isEnabled());
            pluginDescriptor.setInstallForNewUsers(sPluginInformation.isInstallForNewUsers());
            pluginDescriptor.setPluginBundleVersion(session.get(pluginBundleVersionId,OldQuery.getDefault()));
            if (sPluginInformation.isInstallForAllUsers()) {
              IfcModelInterface allOfType=session.getAllOfType(StorePackage.eINSTANCE.getUser(),OldQuery.getDefault());
              for (              User user : allOfType.getAll(User.class)) {
                if (user.getState() == ObjectState.ACTIVE) {
                  updateUserPlugin(session,user,pluginDescriptor,pluginContext);
                }
              }
            }
            if (pluginContext.getPlugin() instanceof WebModulePlugin) {
              ServerSettings serverSettings=getServerSettingsCache().getServerSettings();
              WebModulePluginConfiguration webPluginConfiguration=find(serverSettings.getWebModules(),pluginContext.getIdentifier());
              if (webPluginConfiguration == null) {
                webPluginConfiguration=session.create(WebModulePluginConfiguration.class);
                serverSettings.getWebModules().add(webPluginConfiguration);
                genericPluginConversion(pluginContext,session,webPluginConfiguration,pluginDescriptor);
                session.store(serverSettings);
              }
              String contextPath="String_Node_Str";
              for (              Parameter parameter : webPluginConfiguration.getSettings().getParameters()) {
                if (parameter.getName().equals("String_Node_Str")) {
                  contextPath=((StringType)parameter.getValue()).getValue();
                }
              }
              webModules.put(contextPath,(WebModulePlugin)pluginManager.getPlugin(pluginContext.getIdentifier(),true));
            }
            try {
              session.commit();
            }
 catch (            ServiceException e) {
              LOGGER.error("String_Node_Str",e);
            }
          }
         }
        @Override public void pluginUninstalled(        PluginContext pluginContext){
          Condition pluginCondition=new AttributeCondition(StorePackage.eINSTANCE.getPluginDescriptor_Identifier(),new StringLiteral(pluginContext.getIdentifier()));
          DatabaseSession session=bimDatabase.createSession();
          try {
            Map<Long,PluginDescriptor> pluginsFound=session.query(pluginCondition,PluginDescriptor.class,OldQuery.getDefault());
            if (pluginsFound.size() == 0) {
              LOGGER.error("String_Node_Str" + pluginContext.getPlugin().getClass().getName() + "String_Node_Str");
            }
 else             if (pluginsFound.size() == 1) {
              PluginDescriptor pluginDescriptor=pluginsFound.values().iterator().next();
              for (              PluginConfiguration pluginConfiguration : pluginDescriptor.getConfigurations()) {
                pluginConfiguration.remove();
              }
              pluginDescriptor.remove();
              session.store(pluginDescriptor);
            }
 else {
              LOGGER.error("String_Node_Str" + pluginContext.getPlugin().getClass().getName());
            }
            session.commit();
          }
 catch (          BimserverDatabaseException e) {
            LOGGER.error("String_Node_Str",e);
          }
catch (          ServiceException e) {
            LOGGER.error("String_Node_Str",e);
          }
 finally {
            session.close();
          }
        }
        @Override public long pluginBundleInstalled(        PluginBundle pluginBundle){
          try (DatabaseSession session=bimDatabase.createSession()){
            PluginBundleVersion current=null;
            IfcModelInterface allOfType=session.getAllOfType(StorePackage.eINSTANCE.getPluginBundleVersion(),OldQuery.getDefault());
            for (            PluginBundleVersion pbv : allOfType.getAll(PluginBundleVersion.class)) {
              if (pbv.getGroupId().equals(pluginBundle.getPluginBundleVersion().getGroupId()) && pbv.getArtifactId().equals(pluginBundle.getPluginBundleVersion().getArtifactId())) {
                current=pbv;
              }
            }
            PluginBundleVersion pluginBundleVersion=null;
            if (current != null) {
              pluginBundleVersion=current;
              session.store(pluginBundleVersion);
            }
 else {
              pluginBundleVersion=session.create(PluginBundleVersion.class);
            }
            SPluginBundleVersion sPluginBundleVersion=pluginBundle.getPluginBundleVersion();
            pluginBundleVersion.setArtifactId(sPluginBundleVersion.getArtifactId());
            pluginBundleVersion.setDescription(sPluginBundleVersion.getArtifactId());
            pluginBundleVersion.setGroupId(sPluginBundleVersion.getGroupId());
            pluginBundleVersion.setIcon(sPluginBundleVersion.getIcon());
            pluginBundleVersion.setMismatch(sPluginBundleVersion.isMismatch());
            pluginBundleVersion.setRepository(sPluginBundleVersion.getRepository());
            pluginBundleVersion.setType(getSConverter().convertFromSObject(sPluginBundleVersion.getType()));
            pluginBundleVersion.setVersion(sPluginBundleVersion.getVersion());
            pluginBundleVersion.setOrganization(sPluginBundleVersion.getOrganization());
            pluginBundleVersion.setName(sPluginBundleVersion.getName());
            session.commit();
            return pluginBundleVersion.getOid();
          }
 catch (          BimserverDatabaseException e) {
            LOGGER.error("String_Node_Str",e);
          }
catch (          ServiceException e) {
            LOGGER.error("String_Node_Str",e);
          }
          return -1;
        }
        @Override public void pluginBundleUninstalled(        PluginBundle pluginBundle){
          try (DatabaseSession session=bimDatabase.createSession()){
          }
         }
      }
);
    }
 catch (    Exception e) {
      LOGGER.error("String_Node_Str",e);
    }
    try {
      metaDataManager.init();
      pluginManager.initAllLoadedPlugins();
    }
 catch (    PluginException e) {
      LOGGER.error("String_Node_Str",e);
    }
    serverStartTime=new GregorianCalendar();
    longActionManager=new LongActionManager();
    Set<EPackage> packages=new LinkedHashSet<>();
    packages.add(Ifc2x3tc1Package.eINSTANCE);
    packages.add(Ifc4Package.eINSTANCE);
    templateEngine=new TemplateEngine();
    URL emailTemplates=config.getResourceFetcher().getResource("String_Node_Str");
    if (emailTemplates != null) {
      templateEngine.init(emailTemplates);
    }
 else {
      LOGGER.info("String_Node_Str");
    }
    Path databaseDir=config.getHomeDir().resolve("String_Node_Str");
    BerkeleyKeyValueStore keyValueStore=new BerkeleyKeyValueStore(databaseDir);
    schemaConverterManager.registerConverter(new Ifc2x3tc1ToIfc4SchemaConverterFactory());
    schemaConverterManager.registerConverter(new Ifc4ToIfc2x3tc1SchemaConverterFactory());
    metricsRegistry=new MetricsRegistry();
    Path mavenPath=config.getHomeDir().resolve("String_Node_Str");
    if (!Files.exists(mavenPath)) {
      Files.createDirectories(mavenPath);
    }
    mavenPluginRepository=new MavenPluginRepository(mavenPath,"String_Node_Str");
    OldQuery.setPackageMetaDataForDefaultQuery(metaDataManager.getPackageMetaData("String_Node_Str"));
    bimDatabase=new Database(this,packages,keyValueStore,metaDataManager);
    try {
      bimDatabase.init();
    }
 catch (    DatabaseRestartRequiredException e) {
      bimDatabase.close();
      keyValueStore=new BerkeleyKeyValueStore(databaseDir);
      bimDatabase=new Database(this,packages,keyValueStore,metaDataManager);
      try {
        bimDatabase.init();
      }
 catch (      InconsistentModelsException e1) {
        LOGGER.error("String_Node_Str",e);
        serverInfoManager.setServerState(ServerState.FATAL_ERROR);
        serverInfoManager.setErrorMessage("String_Node_Str");
      }
    }
catch (    InconsistentModelsException e) {
      LOGGER.error("String_Node_Str",e);
      serverInfoManager.setServerState(ServerState.FATAL_ERROR);
      serverInfoManager.setErrorMessage("String_Node_Str");
    }
    DatabaseSession encsession=bimDatabase.createSession();
    try {
      byte[] encryptionkeyBytes=null;
      if (!bimDatabase.getRegistry().has(ENCRYPTIONKEY,encsession)) {
        encryptionkeyBytes=new byte[16];
        new SecureRandom().nextBytes(encryptionkeyBytes);
        bimDatabase.getRegistry().save(ENCRYPTIONKEY,encryptionkeyBytes,encsession);
        encsession.commit();
      }
 else {
        encryptionkeyBytes=bimDatabase.getRegistry().readByteArray(ENCRYPTIONKEY,encsession);
      }
      encryptionkey=new SecretKeySpec(encryptionkeyBytes,"String_Node_Str");
    }
  finally {
      encsession.close();
    }
    protocolBuffersMetaData=new ProtocolBuffersMetaData();
    protocolBuffersMetaData.load(servicesMap,ProtocolBuffersBimServerClientFactory.class);
    serverInfoManager.init(this);
    webModuleManager=new WebModuleManager(this);
    jsonHandler=new JsonHandler(this);
    serializerFactory=new SerializerFactory();
    serverSettingsCache=new ServerSettingsCache(bimDatabase);
    serverInfoManager.update();
    renderEnginePools=new RenderEnginePools(this);
    if (serverInfoManager.getServerState() == ServerState.MIGRATION_REQUIRED) {
      serverInfoManager.registerStateChangeListener(new StateChangeListener(){
        @Override public void stateChanged(        ServerState oldState,        ServerState newState){
          if (oldState == ServerState.MIGRATION_REQUIRED && newState == ServerState.RUNNING) {
            try {
              initDatabaseDependantItems();
            }
 catch (            BimserverDatabaseException e) {
              LOGGER.error("String_Node_Str",e);
            }
          }
        }
      }
);
    }
 else {
      initDatabaseDependantItems();
    }
    mailSystem=new MailSystem(this);
    diskCacheManager=new DiskCacheManager(this,config.getHomeDir().resolve("String_Node_Str"));
    newDiskCacheManager=new NewDiskCacheManager(this,config.getHomeDir().resolve("String_Node_Str"));
    mergerFactory=new MergerFactory(this);
    FileBasedReflectorFactoryBuilder factoryBuilder=new FileBasedReflectorFactoryBuilder();
    reflectorFactory=factoryBuilder.newReflectorFactory();
    if (reflectorFactory == null) {
      throw new RuntimeException("String_Node_Str");
    }
    servicesMap.setReflectorFactory(reflectorFactory);
    bimScheduler=new JobScheduler(this);
    bimScheduler.start();
    if (config.isStartEmbeddedWebServer()) {
      embeddedWebServer.start();
    }
    if (config.isStartCommandLine()) {
      commandLine=new CommandLine(this);
      commandLine.start();
    }
    try (DatabaseSession session=bimDatabase.createSession()){
      IfcModelInterface pluginBundleVersions=session.getAllOfType(StorePackage.eINSTANCE.getPluginBundleVersion(),OldQuery.getDefault());
      for (      PluginBundleVersion pluginBundleVersion : pluginBundleVersions.getAll(PluginBundleVersion.class)) {
        if (pluginBundleVersion.getType() == PluginBundleType.MAVEN) {
          PluginBundleVersionIdentifier pluginBundleVersionIdentifier=new PluginBundleVersionIdentifier(pluginBundleVersion.getGroupId(),pluginBundleVersion.getArtifactId(),pluginBundleVersion.getVersion());
          IfcModelInterface pluginDescriptors=session.getAllOfType(StorePackage.eINSTANCE.getPluginDescriptor(),OldQuery.getDefault());
          List<SPluginInformation> plugins=new ArrayList<>();
          for (          PluginDescriptor pluginDescriptor : pluginDescriptors.getAll(PluginDescriptor.class)) {
            if (pluginDescriptor.getPluginBundleVersion() == pluginBundleVersion && pluginDescriptor.getEnabled()) {
              SPluginInformation sPluginInformation=new SPluginInformation();
              sPluginInformation.setEnabled(true);
              sPluginInformation.setDescription(pluginDescriptor.getDescription());
              sPluginInformation.setIdentifier(pluginDescriptor.getIdentifier());
              sPluginInformation.setInstallForAllUsers(pluginDescriptor.isInstallForNewUsers());
              sPluginInformation.setInstallForNewUsers(pluginDescriptor.isInstallForNewUsers());
              sPluginInformation.setName(pluginDescriptor.getName());
              sPluginInformation.setType(pluginManager.getPluginTypeFromClass(pluginDescriptor.getPluginClassName()));
              plugins.add(sPluginInformation);
            }
          }
          pluginManager.loadFromPluginDir(pluginBundleVersionIdentifier,getSConverter().convertToSObject(pluginBundleVersion),plugins,serverSettingsCache.getServerSettings().isPluginStrictVersionChecking());
        }
      }
    }
   }
 catch (  Throwable e) {
    LOGGER.error("String_Node_Str",e);
    serverInfoManager.setErrorMessage(e.getMessage());
  }
}

Fixed version (ground truth):
public void start() throws DatabaseInitException, BimserverDatabaseException, PluginException, DatabaseRestartRequiredException, ServerException {
  try {
    LOGGER.debug("String_Node_Str");
    SVersion localVersion=versionChecker.getLocalVersion();
    if (localVersion != null) {
      LOGGER.info("String_Node_Str" + localVersion.getFullString());
    }
 else {
      LOGGER.info("String_Node_Str");
    }
    try {
      pluginManager.setPluginChangeListener(new PluginChangeListener(){
        @Override public void pluginStateChanged(        PluginContext pluginContext,        boolean enabled){
          Condition pluginCondition=new AttributeCondition(StorePackage.eINSTANCE.getPluginDescriptor_PluginClassName(),new StringLiteral(pluginContext.getPlugin().getClass().getName()));
          DatabaseSession session=bimDatabase.createSession();
          try {
            Map<Long,PluginDescriptor> pluginsFound=session.query(pluginCondition,PluginDescriptor.class,OldQuery.getDefault());
            if (pluginsFound.size() == 0) {
              LOGGER.error("String_Node_Str" + pluginContext.getPlugin().getClass().getName() + "String_Node_Str");
            }
 else             if (pluginsFound.size() == 1) {
              PluginDescriptor pluginConfiguration=pluginsFound.values().iterator().next();
              pluginConfiguration.setEnabled(pluginContext.isEnabled());
              session.store(pluginConfiguration);
            }
 else {
              LOGGER.error("String_Node_Str" + pluginContext.getPlugin().getClass().getName());
            }
            session.commit();
          }
 catch (          BimserverDatabaseException e) {
            LOGGER.error("String_Node_Str",e);
          }
catch (          ServiceException e) {
            LOGGER.error("String_Node_Str",e);
          }
 finally {
            session.close();
          }
        }
        @Override public long pluginBundleUpdated(        PluginBundle pluginBundle){
          SPluginBundleVersion sPluginBundleVersion=pluginBundle.getPluginBundleVersion();
          try (DatabaseSession session=bimDatabase.createSession()){
            PluginBundleVersion current=null;
            IfcModelInterface allOfType=session.getAllOfType(StorePackage.eINSTANCE.getPluginBundleVersion(),OldQuery.getDefault());
            for (            PluginBundleVersion pbv : allOfType.getAll(PluginBundleVersion.class)) {
              if (pbv.getGroupId().equals(pluginBundle.getPluginBundleVersion().getGroupId()) && pbv.getArtifactId().equals(pluginBundle.getPluginBundleVersion().getArtifactId())) {
                current=pbv;
              }
            }
            if (current != null) {
              current.setDescription(sPluginBundleVersion.getArtifactId());
              current.setIcon(sPluginBundleVersion.getIcon());
              current.setMismatch(sPluginBundleVersion.isMismatch());
              current.setRepository(sPluginBundleVersion.getRepository());
              current.setType(getSConverter().convertFromSObject(sPluginBundleVersion.getType()));
              current.setVersion(sPluginBundleVersion.getVersion());
              current.setOrganization(sPluginBundleVersion.getOrganization());
              current.setName(sPluginBundleVersion.getName());
              session.store(current);
              session.commit();
            }
            return current.getOid();
          }
 catch (          BimserverDatabaseException e) {
            LOGGER.error("String_Node_Str",e);
          }
catch (          ServiceException e) {
            LOGGER.error("String_Node_Str",e);
          }
          return -1;
        }
        @Override public void pluginUpdated(        long pluginBundleVersionId,        PluginContext newPluginContext,        SPluginInformation sPluginInformation) throws BimserverDatabaseException {
          try (DatabaseSession session=bimDatabase.createSession()){
            Plugin plugin=newPluginContext.getPlugin();
            Condition pluginCondition=new AttributeCondition(StorePackage.eINSTANCE.getPluginDescriptor_Identifier(),new StringLiteral(newPluginContext.getIdentifier()));
            Map<Long,PluginDescriptor> pluginsFound=session.query(pluginCondition,PluginDescriptor.class,OldQuery.getDefault());
            for (            PluginDescriptor pluginDescriptor : pluginsFound.values()) {
              pluginDescriptor.setIdentifier(newPluginContext.getIdentifier());
              pluginDescriptor.setPluginClassName(plugin.getClass().getName());
              pluginDescriptor.setDescription(newPluginContext.getDescription());
              pluginDescriptor.setName(sPluginInformation.getName());
              pluginDescriptor.setLocation(newPluginContext.getLocation().toString());
              pluginDescriptor.setPluginInterfaceClassName(getPluginInterface(plugin.getClass()).getName());
              pluginDescriptor.setEnabled(sPluginInformation.isEnabled());
              pluginDescriptor.setInstallForNewUsers(sPluginInformation.isInstallForNewUsers());
              PluginBundleVersion value=session.get(pluginBundleVersionId,OldQuery.getDefault());
              pluginDescriptor.setPluginBundleVersion(value);
              session.store(pluginDescriptor);
              if (sPluginInformation.isInstallForAllUsers()) {
                IfcModelInterface allOfType=session.getAllOfType(StorePackage.eINSTANCE.getUser(),OldQuery.getDefault());
                for (                User user : allOfType.getAll(User.class)) {
                  if (user.getState() == ObjectState.ACTIVE) {
                    updateUserPlugin(session,user,pluginDescriptor,newPluginContext);
                  }
                }
              }
              if (newPluginContext.getPlugin() instanceof WebModulePlugin) {
                ServerSettings serverSettings=getServerSettingsCache().getServerSettings();
                WebModulePluginConfiguration webPluginConfiguration=find(serverSettings.getWebModules(),newPluginContext.getIdentifier());
                if (webPluginConfiguration == null) {
                  webPluginConfiguration=session.create(WebModulePluginConfiguration.class);
                  serverSettings.getWebModules().add(webPluginConfiguration);
                  genericPluginConversion(newPluginContext,session,webPluginConfiguration,pluginDescriptor);
                  String contextPath="String_Node_Str";
                  for (                  Parameter parameter : webPluginConfiguration.getSettings().getParameters()) {
                    if (parameter.getName().equals("String_Node_Str")) {
                      contextPath=((StringType)parameter.getValue()).getValue();
                    }
                  }
                  String identifier=webPluginConfiguration.getPluginDescriptor().getIdentifier();
                  webModules.put(contextPath,(WebModulePlugin)pluginManager.getPlugin(identifier,true));
                }
              }
            }
            try {
              session.commit();
            }
 catch (            ServiceException e) {
              LOGGER.error("String_Node_Str",e);
            }
          }
         }
        @Override public void pluginInstalled(        long pluginBundleVersionId,        PluginContext pluginContext,        SPluginInformation sPluginInformation) throws BimserverDatabaseException {
          try (DatabaseSession session=bimDatabase.createSession()){
            Plugin plugin=pluginContext.getPlugin();
            Condition pluginCondition=new AttributeCondition(StorePackage.eINSTANCE.getPluginDescriptor_Identifier(),new StringLiteral(pluginContext.getIdentifier()));
            Map<Long,PluginDescriptor> pluginsFound=session.query(pluginCondition,PluginDescriptor.class,OldQuery.getDefault());
            PluginDescriptor pluginDescriptor=null;
            if (pluginsFound.size() > 0) {
              pluginDescriptor=pluginsFound.values().iterator().next();
            }
 else {
              pluginDescriptor=session.create(PluginDescriptor.class);
            }
            pluginDescriptor.setIdentifier(pluginContext.getIdentifier());
            pluginDescriptor.setPluginClassName(plugin.getClass().getName());
            pluginDescriptor.setDescription(pluginContext.getDescription());
            pluginDescriptor.setName(sPluginInformation.getName());
            pluginDescriptor.setLocation(pluginContext.getLocation().toString());
            pluginDescriptor.setPluginInterfaceClassName(getPluginInterface(plugin.getClass()).getName());
            pluginDescriptor.setEnabled(sPluginInformation.isEnabled());
            pluginDescriptor.setInstallForNewUsers(sPluginInformation.isInstallForNewUsers());
            pluginDescriptor.setPluginBundleVersion(session.get(pluginBundleVersionId,OldQuery.getDefault()));
            if (sPluginInformation.isInstallForAllUsers()) {
              IfcModelInterface allOfType=session.getAllOfType(StorePackage.eINSTANCE.getUser(),OldQuery.getDefault());
              for (              User user : allOfType.getAll(User.class)) {
                if (user.getState() == ObjectState.ACTIVE) {
                  updateUserPlugin(session,user,pluginDescriptor,pluginContext);
                }
              }
            }
            if (pluginContext.getPlugin() instanceof WebModulePlugin) {
              ServerSettings serverSettings=getServerSettingsCache().getServerSettings();
              WebModulePluginConfiguration webPluginConfiguration=find(serverSettings.getWebModules(),pluginContext.getIdentifier());
              if (webPluginConfiguration == null) {
                webPluginConfiguration=session.create(WebModulePluginConfiguration.class);
                serverSettings.getWebModules().add(webPluginConfiguration);
                genericPluginConversion(pluginContext,session,webPluginConfiguration,pluginDescriptor);
                session.store(serverSettings);
              }
              String contextPath="String_Node_Str";
              for (              Parameter parameter : webPluginConfiguration.getSettings().getParameters()) {
                if (parameter.getName().equals("String_Node_Str")) {
                  contextPath=((StringType)parameter.getValue()).getValue();
                }
              }
              webModules.put(contextPath,(WebModulePlugin)pluginManager.getPlugin(pluginContext.getIdentifier(),true));
            }
            try {
              session.commit();
            }
 catch (            ServiceException e) {
              LOGGER.error("String_Node_Str",e);
            }
          }
         }
        @Override public void pluginUninstalled(        PluginContext pluginContext){
          Condition pluginCondition=new AttributeCondition(StorePackage.eINSTANCE.getPluginDescriptor_Identifier(),new StringLiteral(pluginContext.getIdentifier()));
          DatabaseSession session=bimDatabase.createSession();
          try {
            Map<Long,PluginDescriptor> pluginsFound=session.query(pluginCondition,PluginDescriptor.class,OldQuery.getDefault());
            if (pluginsFound.size() == 0) {
              LOGGER.error("String_Node_Str" + pluginContext.getPlugin().getClass().getName() + "String_Node_Str");
            }
 else             if (pluginsFound.size() == 1) {
              PluginDescriptor pluginDescriptor=pluginsFound.values().iterator().next();
              for (              PluginConfiguration pluginConfiguration : pluginDescriptor.getConfigurations()) {
                pluginConfiguration.remove();
              }
              pluginDescriptor.remove();
              session.store(pluginDescriptor);
            }
 else {
              LOGGER.error("String_Node_Str" + pluginContext.getPlugin().getClass().getName());
            }
            session.commit();
          }
 catch (          BimserverDatabaseException e) {
            LOGGER.error("String_Node_Str",e);
          }
catch (          ServiceException e) {
            LOGGER.error("String_Node_Str",e);
          }
 finally {
            session.close();
          }
        }
        @Override public long pluginBundleInstalled(        PluginBundle pluginBundle){
          try (DatabaseSession session=bimDatabase.createSession()){
            PluginBundleVersion current=null;
            IfcModelInterface allOfType=session.getAllOfType(StorePackage.eINSTANCE.getPluginBundleVersion(),OldQuery.getDefault());
            for (            PluginBundleVersion pbv : allOfType.getAll(PluginBundleVersion.class)) {
              if (pbv.getGroupId().equals(pluginBundle.getPluginBundleVersion().getGroupId()) && pbv.getArtifactId().equals(pluginBundle.getPluginBundleVersion().getArtifactId())) {
                current=pbv;
              }
            }
            PluginBundleVersion pluginBundleVersion=null;
            if (current != null) {
              pluginBundleVersion=current;
              session.store(pluginBundleVersion);
            }
 else {
              pluginBundleVersion=session.create(PluginBundleVersion.class);
            }
            SPluginBundleVersion sPluginBundleVersion=pluginBundle.getPluginBundleVersion();
            pluginBundleVersion.setArtifactId(sPluginBundleVersion.getArtifactId());
            pluginBundleVersion.setDescription(sPluginBundleVersion.getArtifactId());
            pluginBundleVersion.setGroupId(sPluginBundleVersion.getGroupId());
            pluginBundleVersion.setIcon(sPluginBundleVersion.getIcon());
            pluginBundleVersion.setMismatch(sPluginBundleVersion.isMismatch());
            pluginBundleVersion.setRepository(sPluginBundleVersion.getRepository());
            pluginBundleVersion.setType(getSConverter().convertFromSObject(sPluginBundleVersion.getType()));
            pluginBundleVersion.setVersion(sPluginBundleVersion.getVersion());
            pluginBundleVersion.setOrganization(sPluginBundleVersion.getOrganization());
            pluginBundleVersion.setName(sPluginBundleVersion.getName());
            session.commit();
            return pluginBundleVersion.getOid();
          }
 catch (          BimserverDatabaseException e) {
            LOGGER.error("String_Node_Str",e);
          }
catch (          ServiceException e) {
            LOGGER.error("String_Node_Str",e);
          }
          return -1;
        }
        @Override public void pluginBundleUninstalled(        PluginBundle pluginBundle){
          try (DatabaseSession session=bimDatabase.createSession()){
          }
         }
      }
);
    }
 catch (    Exception e) {
      LOGGER.error("String_Node_Str",e);
    }
    try {
      metaDataManager.init();
      pluginManager.initAllLoadedPlugins();
    }
 catch (    PluginException e) {
      LOGGER.error("String_Node_Str",e);
    }
    serverStartTime=new GregorianCalendar();
    longActionManager=new LongActionManager();
    Set<EPackage> packages=new LinkedHashSet<>();
    packages.add(Ifc2x3tc1Package.eINSTANCE);
    packages.add(Ifc4Package.eINSTANCE);
    templateEngine=new TemplateEngine();
    URL emailTemplates=config.getResourceFetcher().getResource("String_Node_Str");
    if (emailTemplates != null) {
      templateEngine.init(emailTemplates);
    }
 else {
      LOGGER.info("String_Node_Str");
    }
    Path databaseDir=config.getHomeDir().resolve("String_Node_Str");
    BerkeleyKeyValueStore keyValueStore=new BerkeleyKeyValueStore(databaseDir);
    schemaConverterManager.registerConverter(new Ifc2x3tc1ToIfc4SchemaConverterFactory());
    schemaConverterManager.registerConverter(new Ifc4ToIfc2x3tc1SchemaConverterFactory());
    metricsRegistry=new MetricsRegistry();
    Path mavenPath=config.getHomeDir().resolve("String_Node_Str");
    if (!Files.exists(mavenPath)) {
      Files.createDirectories(mavenPath);
    }
    mavenPluginRepository=new MavenPluginRepository(mavenPath,"String_Node_Str");
    OldQuery.setPackageMetaDataForDefaultQuery(metaDataManager.getPackageMetaData("String_Node_Str"));
    bimDatabase=new Database(this,packages,keyValueStore,metaDataManager);
    try {
      bimDatabase.init();
    }
 catch (    DatabaseRestartRequiredException e) {
      bimDatabase.close();
      keyValueStore=new BerkeleyKeyValueStore(databaseDir);
      bimDatabase=new Database(this,packages,keyValueStore,metaDataManager);
      try {
        bimDatabase.init();
      }
 catch (      InconsistentModelsException e1) {
        LOGGER.error("String_Node_Str",e);
        serverInfoManager.setServerState(ServerState.FATAL_ERROR);
        serverInfoManager.setErrorMessage("String_Node_Str");
      }
    }
catch (    InconsistentModelsException e) {
      LOGGER.error("String_Node_Str",e);
      serverInfoManager.setServerState(ServerState.FATAL_ERROR);
      serverInfoManager.setErrorMessage("String_Node_Str");
    }
    DatabaseSession encsession=bimDatabase.createSession();
    try {
      byte[] encryptionkeyBytes=null;
      if (!bimDatabase.getRegistry().has(ENCRYPTIONKEY,encsession)) {
        encryptionkeyBytes=new byte[16];
        new SecureRandom().nextBytes(encryptionkeyBytes);
        bimDatabase.getRegistry().save(ENCRYPTIONKEY,encryptionkeyBytes,encsession);
        encsession.commit();
      }
 else {
        encryptionkeyBytes=bimDatabase.getRegistry().readByteArray(ENCRYPTIONKEY,encsession);
      }
      encryptionkey=new SecretKeySpec(encryptionkeyBytes,"String_Node_Str");
    }
  finally {
      encsession.close();
    }
    protocolBuffersMetaData=new ProtocolBuffersMetaData();
    protocolBuffersMetaData.load(servicesMap,ProtocolBuffersBimServerClientFactory.class);
    serverInfoManager.init(this);
    webModuleManager=new WebModuleManager(this);
    jsonHandler=new JsonHandler(this);
    serializerFactory=new SerializerFactory();
    serverSettingsCache=new ServerSettingsCache(bimDatabase);
    serverInfoManager.update();
    renderEnginePools=new RenderEnginePools(this);
    if (serverInfoManager.getServerState() == ServerState.MIGRATION_REQUIRED) {
      serverInfoManager.registerStateChangeListener(new StateChangeListener(){
        @Override public void stateChanged(        ServerState oldState,        ServerState newState){
          if (oldState == ServerState.MIGRATION_REQUIRED && newState == ServerState.RUNNING) {
            try {
              initDatabaseDependantItems();
            }
 catch (            BimserverDatabaseException e) {
              LOGGER.error("String_Node_Str",e);
            }
          }
        }
      }
);
    }
 else {
      initDatabaseDependantItems();
    }
    mailSystem=new MailSystem(this);
    diskCacheManager=new DiskCacheManager(this,config.getHomeDir().resolve("String_Node_Str"));
    newDiskCacheManager=new NewDiskCacheManager(this,config.getHomeDir().resolve("String_Node_Str"));
    mergerFactory=new MergerFactory(this);
    FileBasedReflectorFactoryBuilder factoryBuilder=new FileBasedReflectorFactoryBuilder();
    reflectorFactory=factoryBuilder.newReflectorFactory();
    if (reflectorFactory == null) {
      throw new RuntimeException("String_Node_Str");
    }
    servicesMap.setReflectorFactory(reflectorFactory);
    bimScheduler=new JobScheduler(this);
    bimScheduler.start();
    if (config.isStartEmbeddedWebServer()) {
      embeddedWebServer.start();
    }
    if (config.isStartCommandLine()) {
      commandLine=new CommandLine(this);
      commandLine.start();
    }
    try (DatabaseSession session=bimDatabase.createSession()){
      IfcModelInterface pluginBundleVersions=session.getAllOfType(StorePackage.eINSTANCE.getPluginBundleVersion(),OldQuery.getDefault());
      for (      PluginBundleVersion pluginBundleVersion : pluginBundleVersions.getAll(PluginBundleVersion.class)) {
        if (pluginBundleVersion.getType() == PluginBundleType.MAVEN) {
          PluginBundleVersionIdentifier pluginBundleVersionIdentifier=new PluginBundleVersionIdentifier(pluginBundleVersion.getGroupId(),pluginBundleVersion.getArtifactId(),pluginBundleVersion.getVersion());
          IfcModelInterface pluginDescriptors=session.getAllOfType(StorePackage.eINSTANCE.getPluginDescriptor(),OldQuery.getDefault());
          List<SPluginInformation> plugins=new ArrayList<>();
          for (          PluginDescriptor pluginDescriptor : pluginDescriptors.getAll(PluginDescriptor.class)) {
            if (pluginDescriptor.getPluginBundleVersion() == pluginBundleVersion && pluginDescriptor.getEnabled()) {
              SPluginInformation sPluginInformation=new SPluginInformation();
              sPluginInformation.setEnabled(true);
              sPluginInformation.setDescription(pluginDescriptor.getDescription());
              sPluginInformation.setIdentifier(pluginDescriptor.getIdentifier());
              sPluginInformation.setInstallForAllUsers(pluginDescriptor.isInstallForNewUsers());
              sPluginInformation.setInstallForNewUsers(pluginDescriptor.isInstallForNewUsers());
              sPluginInformation.setName(pluginDescriptor.getName());
              sPluginInformation.setType(pluginManager.getPluginTypeFromClass(pluginDescriptor.getPluginClassName()));
              plugins.add(sPluginInformation);
            }
          }
          pluginManager.loadFromPluginDir(pluginBundleVersionIdentifier,getSConverter().convertToSObject(pluginBundleVersion),plugins,serverSettingsCache.getServerSettings().isPluginStrictVersionChecking());
        }
      }
    }
   }
 catch (  Throwable e) {
    LOGGER.error("String_Node_Str",e);
    serverInfoManager.setErrorMessage(e.getMessage());
  }
}