protected TenantServiceAccessor getTenantAccessor() { try { return TenantServiceSingleton.getInstance(getTenantId()); } catch (final Exception e) { throw new BonitaRuntimeException(e); } }
protected TenantServiceAccessor getTenantAccessor() { try { return TenantServiceSingleton.getInstance(getTenantId()); } catch (final Exception e) { throw new BonitaRuntimeException(e); } }
@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); } }
@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 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); } }