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); } }