public static Platform toPlatform(final SPlatform sPlatform) { return new PlatformImpl(sPlatform.getVersion(), sPlatform.getPreviousVersion(), sPlatform.getInitialVersion(), sPlatform.getCreatedBy(), sPlatform.getCreated()); }
private Map<String, String> buildReplacements(final STenant tenant) { return singletonMap("\\$\\{tenantid\\}", Long.toString(tenant.getId())); }
protected void checkThatWeCanLogin(final String userName, final STenant sTenant, TechnicalUser technicalUser) throws LoginException { if (!sTenant.isActivated()) { throw new LoginException("Tenant " + sTenant.getName() + " is not activated !!"); } if (sTenant.isPaused()) { final String technicalUserName = technicalUser.getUserName(); if (!technicalUserName.equals(userName)) { throw new TenantStatusException("Tenant with ID " + sTenant.getId() + " is in pause, unable to login with other user than the technical user."); } } }
@Override public void run() { final TechnicalLoggerService technicalLoggerService = tenantServiceAccessor.getTechnicalLoggerService(); try { final long tenantId = tenantServiceAccessor.getTenantId(); SessionAccessor sessionAccessor = tenantServiceAccessor.getSessionAccessor(); STenant tenant = getTenant(tenantId); technicalLoggerService.log(getClass(), TechnicalLogSeverity.INFO, "Restarting elements of tenant " + tenant.getId() + " that were not finished at the last shutdown"); if (tenant.isPaused() || !tenant.isActivated()) { technicalLoggerService.log(getClass(), TechnicalLogSeverity.WARNING, "Unable to restart elements of tenant " + tenant.getStatus()); return; } executeHandlers(tenantId, sessionAccessor); } catch (Exception e) { technicalLoggerService.log(StarterThread.class, TechnicalLogSeverity.ERROR, "Error while restarting elements", e); } }
@Override public Boolean call() throws SBonitaException { // the database version platform = platformService.getPlatform(); final String dbVersion = platform.getVersion(); // the version in jars platformProperties = platformService.getSPlatformProperties(); final String jarVersion = platformProperties.getPlatformVersion(); // the version in bonita home final String platformMinorVersion = format(dbVersion); final String propertiesMinorVersion = format(jarVersion); boolean same = platformMinorVersion.equals(propertiesMinorVersion); if (!same) { errorMessage = "The version of the platform in database is not the same as expected: bonita-server version is <" + jarVersion + "> and database version is <" + dbVersion + ">"; } return same; }
private void checkIfTenantAlreadyExists(final STenant tenant) throws STenantAlreadyExistException { try { final String tenantName = tenant.getName(); final STenant existingTenant = getTenantByName(tenantName); if (existingTenant != null) { throw new STenantAlreadyExistException("Unable to create the tenant " + tenantName + " : it already exists."); } } catch (final STenantNotFoundException e) { if (isTraced) { logger.log(this.getClass(), TechnicalLogSeverity.TRACE, LogUtil.getLogOnExceptionMethod(this.getClass(), LOG_CREATE_TENANT, e)); } // OK } }
@Override @AvailableWhenTenantIsPaused public boolean isPaused() { final long tenantId = getTenantId(); try { return getPlatformAccessorNoException().getPlatformService().getTenant(tenantId).isPaused(); } catch (final SBonitaException e) { throw new RetrieveException("Unable to retrieve the tenant with id " + tenantId, e); } }
protected void checkThatWeCanLogin(final String userName, final STenant sTenant, TechnicalUser technicalUser) throws LoginException { if (!sTenant.isActivated()) { throw new LoginException("Tenant " + sTenant.getName() + " is not activated !!"); } if (sTenant.isPaused()) { final String technicalUserName = technicalUser.getUserName(); if (!technicalUserName.equals(userName)) { throw new TenantStatusException("Tenant with ID " + sTenant.getId() + " is in pause, unable to login with other user than the technical user."); } } }
@Override public void run() { final TechnicalLoggerService technicalLoggerService = tenantServiceAccessor.getTechnicalLoggerService(); try { final long tenantId = tenantServiceAccessor.getTenantId(); SessionAccessor sessionAccessor = tenantServiceAccessor.getSessionAccessor(); STenant tenant = getTenant(tenantId); technicalLoggerService.log(getClass(), TechnicalLogSeverity.INFO, "Restarting elements of tenant " + tenant.getId() + " that were not finished at the last shutdown"); if (tenant.isPaused() || !tenant.isActivated()) { technicalLoggerService.log(getClass(), TechnicalLogSeverity.WARNING, "Unable to restart elements of tenant " + tenant.getStatus()); return; } executeHandlers(tenantId, sessionAccessor); } catch (Exception e) { technicalLoggerService.log(StarterThread.class, TechnicalLogSeverity.ERROR, "Error while restarting elements", e); } }
public static Platform toPlatform(final SPlatform sPlatform) { return new PlatformImpl(sPlatform.getVersion(), sPlatform.getPreviousVersion(), sPlatform.getInitialVersion(), sPlatform.getCreatedBy(), sPlatform.getCreated()); }
private Map<String, String> buildReplacements(final STenant tenant) { return singletonMap("\\$\\{tenantid\\}", Long.toString(tenant.getId())); }
@Override public Boolean call() throws SBonitaException { // the database version platform = platformService.getPlatform(); final String dbVersion = platform.getVersion(); // the version in jars platformProperties = platformService.getSPlatformProperties(); final String jarVersion = platformProperties.getPlatformVersion(); // the version in bonita home final String platformMinorVersion = format(dbVersion); final String propertiesMinorVersion = format(jarVersion); boolean same = platformMinorVersion.equals(propertiesMinorVersion); if (!same) { errorMessage = "The version of the platform in database is not the same as expected: bonita-server version is <" + jarVersion + "> and database version is <" + dbVersion + ">"; } return same; }
private void checkIfTenantAlreadyExists(final STenant tenant) throws STenantAlreadyExistException { try { final String tenantName = tenant.getName(); final STenant existingTenant = getTenantByName(tenantName); if (existingTenant != null) { throw new STenantAlreadyExistException("Unable to create the tenant " + tenantName + " : it already exists."); } } catch (final STenantNotFoundException e) { if (isTraced) { logger.log(this.getClass(), TechnicalLogSeverity.TRACE, LogUtil.getLogOnExceptionMethod(this.getClass(), LOG_CREATE_TENANT, e)); } // OK } }
@Override @AvailableWhenTenantIsPaused public boolean isPaused() { final long tenantId = getTenantId(); try { return getPlatformAccessorNoException().getPlatformService().getTenant(tenantId).isPaused(); } catch (final SBonitaException e) { throw new RetrieveException("Unable to retrieve the tenant with id " + tenantId, e); } }
private void addTenantJobListeners(PlatformServiceAccessor platformAccessor, final List<STenant> tenants, final SchedulerService schedulerService) throws SBonitaException, BonitaHomeNotSetException, IOException, BonitaHomeConfigurationException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException { for (STenant tenant : tenants) { addTenantJobListener(platformAccessor, schedulerService, tenant.getId()); } }
private void addTenantJobListeners(PlatformServiceAccessor platformAccessor, final List<STenant> tenants, final SchedulerService schedulerService) throws SBonitaException, BonitaHomeNotSetException, IOException, BonitaHomeConfigurationException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException { for (STenant tenant : tenants) { addTenantJobListener(platformAccessor, schedulerService, tenant.getId()); } }
@Override public void execute() throws SBonitaException { List<STenant> tenants; do { tenants = platformService.getTenants(new QueryOptions(0, 100, STenant.class, "id", OrderByType.ASC)); for (final STenant sTenant : tenants) { platformService.deactiveTenant(sTenant.getId()); platformService.deleteTenant(sTenant.getId()); } } while (tenants.size() > 0); } }
@Override public void execute() throws SBonitaException { List<STenant> tenants; do { tenants = platformService.getTenants(new QueryOptions(0, 100, STenant.class, "id", OrderByType.ASC)); for (final STenant sTenant : tenants) { platformService.deactiveTenant(sTenant.getId()); platformService.deleteTenant(sTenant.getId()); } } while (tenants.size() > 0); } }
void afterServicesStartOfRestartHandlersOfTenant(final PlatformServiceAccessor platformAccessor, final Map<STenant, List<TenantRestartHandler>> tenantRestartHandlersOfTenants) { final NodeConfiguration platformConfiguration = platformAccessor.getPlatformConfiguration(); if (platformConfiguration.shouldResumeElements()) { // Here get all elements that are not "finished" // * FlowNodes that have flag: stateExecuting to true: call execute on them (connectors were executing) // * Process instances with token count == 0 (either not started again or finishing) -> same thing connectors were executing // * transitions that are in state created: call execute on them // * flow node that are completed and not deleted : call execute to make it create transitions and so on // * all element that are in not stable state for (Entry<STenant, List<TenantRestartHandler>> tenantRestartHandlers : tenantRestartHandlersOfTenants.entrySet()) { TenantServiceAccessor tenantServiceAccessor = platformAccessor.getTenantServiceAccessor(tenantRestartHandlers.getKey().getId()); new TenantRestarter(platformAccessor, tenantServiceAccessor).executeAfterServicesStart(tenantRestartHandlers.getValue()); } } }
void afterServicesStartOfRestartHandlersOfTenant(final PlatformServiceAccessor platformAccessor, final Map<STenant, List<TenantRestartHandler>> tenantRestartHandlersOfTenants) { final NodeConfiguration platformConfiguration = platformAccessor.getPlatformConfiguration(); if (platformConfiguration.shouldResumeElements()) { // Here get all elements that are not "finished" // * FlowNodes that have flag: stateExecuting to true: call execute on them (connectors were executing) // * Process instances with token count == 0 (either not started again or finishing) -> same thing connectors were executing // * transitions that are in state created: call execute on them // * flow node that are completed and not deleted : call execute to make it create transitions and so on // * all element that are in not stable state for (Entry<STenant, List<TenantRestartHandler>> tenantRestartHandlers : tenantRestartHandlersOfTenants.entrySet()) { TenantServiceAccessor tenantServiceAccessor = platformAccessor.getTenantServiceAccessor(tenantRestartHandlers.getKey().getId()); new TenantRestarter(platformAccessor, tenantServiceAccessor).executeAfterServicesStart(tenantRestartHandlers.getValue()); } } }