@Override public void deleteTenantObjects(final long tenantId) throws STenantDeletionException, STenantNotFoundException, SDeletingActivatedTenantException { if (isTraced) { logger.log(this.getClass(), TechnicalLogSeverity.TRACE, LogUtil.getLogBeforeMethod(this.getClass(), LOG_DELETE_TENANT_OBJECTS)); } final STenant tenant = getTenant(tenantId); if (tenant.getStatus().equals(STenant.ACTIVATED)) { throw new SDeletingActivatedTenantException(); } final Map<String, String> replacements = buildReplacements(tenant); try { executeSQLResources(Collections.singletonList("deleteTenantObjects.sql"), replacements); } catch (final IOException | SQLException e) { throw new STenantDeletionException(e); } }
@Override public void deleteTenantObjects(final long tenantId) throws STenantDeletionException, STenantNotFoundException, SDeletingActivatedTenantException { if (isTraced) { logger.log(this.getClass(), TechnicalLogSeverity.TRACE, LogUtil.getLogBeforeMethod(this.getClass(), LOG_DELETE_TENANT_OBJECTS)); } final STenant tenant = getTenant(tenantId); if (tenant.getStatus().equals(STenant.ACTIVATED)) { throw new SDeletingActivatedTenantException(); } final Map<String, String> replacements = buildReplacements(tenant); try { executeSQLResources(Collections.singletonList("deleteTenantObjects.sql"), replacements); } catch (final IOException | SQLException e) { throw new STenantDeletionException(e); } }
@Override public void deleteTenant(final long tenantId) throws STenantDeletionException, STenantNotFoundException, SDeletingActivatedTenantException { if (isTraced) { logger.log(this.getClass(), TechnicalLogSeverity.TRACE, LogUtil.getLogBeforeMethod(this.getClass(), LOG_DELETE_TENANT)); } final STenant tenant = getTenant(tenantId); if (tenant.getStatus().equals(STenant.ACTIVATED)) { throw new SDeletingActivatedTenantException(); } try { platformPersistenceService.delete(tenant); } catch (final SPersistenceException e) { if (isTraced) { logger.log(this.getClass(), TechnicalLogSeverity.TRACE, LogUtil.getLogOnExceptionMethod(this.getClass(), LOG_DELETE_TENANT, e)); } throw new STenantDeletionException("Unable to delete the tenant : " + e.getMessage(), e); } }
@Override public void deleteTenant(final long tenantId) throws STenantDeletionException, STenantNotFoundException, SDeletingActivatedTenantException { if (isTraced) { logger.log(this.getClass(), TechnicalLogSeverity.TRACE, LogUtil.getLogBeforeMethod(this.getClass(), LOG_DELETE_TENANT)); } final STenant tenant = getTenant(tenantId); if (tenant.getStatus().equals(STenant.ACTIVATED)) { throw new SDeletingActivatedTenantException(); } try { platformPersistenceService.delete(tenant); } catch (final SPersistenceException e) { if (isTraced) { logger.log(this.getClass(), TechnicalLogSeverity.TRACE, LogUtil.getLogOnExceptionMethod(this.getClass(), LOG_DELETE_TENANT, e)); } throw new STenantDeletionException("Unable to delete the tenant : " + e.getMessage(), e); } }
private void setTenantPaused(final boolean shouldBePaused) throws UpdateException { final PlatformServiceAccessor platformServiceAccessor = getPlatformAccessorNoException(); final PlatformService platformService = platformServiceAccessor.getPlatformService(); final long tenantId = getTenantId(); try { final STenant tenant = platformService.getTenant(tenantId); if (shouldBePaused && !STenant.ACTIVATED.equals(tenant.getStatus()) || !shouldBePaused && !STenant.PAUSED.equals(tenant.getStatus())) { throw new UpdateException("Can't " + (shouldBePaused ? "pause" : "resume") + " a tenant in state " + tenant.getStatus()); } final STenantUpdateBuilderFactory updateBuilderFactory = BuilderFactory.get(STenantUpdateBuilderFactory.class); final STenantUpdateBuilder updateDescriptor = updateBuilderFactory.createNewInstance(); if (shouldBePaused) { updateDescriptor.setStatus(STenant.PAUSED); pauseServicesForTenant(platformServiceAccessor, tenantId); } else { updateDescriptor.setStatus(STenant.ACTIVATED); resumeServicesForTenant(platformServiceAccessor, tenantId); } updateTenant(platformService, updateDescriptor, tenant); } catch (final STenantNotFoundException e) { throw new UpdateException("Tenant does not exist", e); } }
private void setTenantPaused(final boolean shouldBePaused) throws UpdateException { final PlatformServiceAccessor platformServiceAccessor = getPlatformAccessorNoException(); final PlatformService platformService = platformServiceAccessor.getPlatformService(); final long tenantId = getTenantId(); try { final STenant tenant = platformService.getTenant(tenantId); if (shouldBePaused && !STenant.ACTIVATED.equals(tenant.getStatus()) || !shouldBePaused && !STenant.PAUSED.equals(tenant.getStatus())) { throw new UpdateException("Can't " + (shouldBePaused ? "pause" : "resume") + " a tenant in state " + tenant.getStatus()); } final STenantUpdateBuilderFactory updateBuilderFactory = BuilderFactory.get(STenantUpdateBuilderFactory.class); final STenantUpdateBuilder updateDescriptor = updateBuilderFactory.createNewInstance(); if (shouldBePaused) { updateDescriptor.setStatus(STenant.PAUSED); pauseServicesForTenant(platformServiceAccessor, tenantId); } else { updateDescriptor.setStatus(STenant.ACTIVATED); resumeServicesForTenant(platformServiceAccessor, tenantId); } updateTenant(platformService, updateDescriptor, tenant); } catch (final STenantNotFoundException e) { throw new UpdateException("Tenant does not exist", e); } }
@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 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); } }