@AvailableWhenTenantIsPaused protected void pauseServicesForTenant(final PlatformServiceAccessor platformServiceAccessor, final long tenantId) throws UpdateException { // clustered services try { pauseScheduler(platformServiceAccessor, tenantId); deleteSessionsOfTenantExceptTechnicalUser(platformServiceAccessor, tenantId); // on all nodes setTenantClassloaderAndUpdateStateOfTenantServicesWithLifecycle(platformServiceAccessor, tenantId, new PauseServiceStrategy()); } catch (final SSchedulerException e) { throw new UpdateException("Unable to pause the scheduler.", e); } }
void setTenantClassloaderAndUpdateStateOfTenantServicesWithLifecycle(final PlatformServiceAccessor platformServiceAccessor, final long tenantId, final ServiceStrategy serviceStrategy) throws UpdateException { final BroadcastService broadcastService = platformServiceAccessor.getBroadcastService(); final SetServiceState setServiceState = new SetServiceState(tenantId, serviceStrategy); final Map<String, TaskResult<Void>> result; try { execute(setServiceState); result = broadcastService.executeOnOthersAndWait(setServiceState, tenantId); } catch (Exception e) { throw new UpdateException(e); } handleResult(result); }
@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 long getUserId() throws IllegalStateException { try { return getTenantAccessor().getSessionService().getSession(getSessionAccessor().getSessionId()).getUserId(); } catch (final Exception e) { throw new BonitaRuntimeException(e.getMessage()); } } }
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 resolveDependenciesForAllProcesses() { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); tenantAccessor.getBusinessArchiveArtifactsManager().resolveDependenciesForAllProcesses(tenantAccessor); }
@Override @AvailableWhenTenantIsPaused(only = true) public String installBusinessDataModel(final byte[] zip) throws InvalidBusinessDataModelException, BusinessDataRepositoryDeploymentException { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final long userId; try { userId = getUserId(); } catch (IllegalStateException e) { throw new BusinessDataRepositoryDeploymentException("Unable to determine user ID"); } try { final BusinessDataModelRepository bdmRepository = tenantAccessor.getBusinessDataModelRepository(); return bdmRepository.install(zip, tenantAccessor.getTenantId(), userId); } catch (final IllegalStateException e) { throw new InvalidBusinessDataModelException(e); } catch (final SBusinessDataRepositoryDeploymentException e) { throw new BusinessDataRepositoryDeploymentException(e); } }
protected TenantServiceAccessor getTenantAccessor() { try { return TenantServiceSingleton.getInstance(getTenantId()); } catch (final Exception e) { throw new BonitaRuntimeException(e); } }
@Override @AvailableWhenTenantIsPaused public TenantResource getBusinessDataModelResource() { return getTenantResource(TenantResourceType.BDM); }
protected long getTenantId() { try { return getSessionAccessor().getTenantId(); } catch (final Exception e) { throw new BonitaRuntimeException(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 resolveDependenciesForAllProcesses() { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); tenantAccessor.getBusinessArchiveArtifactsManager().resolveDependenciesForAllProcesses(tenantAccessor); }
protected long getUserId() throws IllegalStateException { try { return getTenantAccessor().getSessionService().getSession(getSessionAccessor().getSessionId()).getUserId(); } catch (final Exception e) { throw new BonitaRuntimeException(e.getMessage()); } } }
@Override @AvailableWhenTenantIsPaused(only = true) public String installBusinessDataModel(final byte[] zip) throws InvalidBusinessDataModelException, BusinessDataRepositoryDeploymentException { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final long userId; try { userId = getUserId(); } catch (IllegalStateException e) { throw new BusinessDataRepositoryDeploymentException("Unable to determine user ID"); } try { final BusinessDataModelRepository bdmRepository = tenantAccessor.getBusinessDataModelRepository(); return bdmRepository.install(zip, tenantAccessor.getTenantId(), userId); } catch (final IllegalStateException e) { throw new InvalidBusinessDataModelException(e); } catch (final SBusinessDataRepositoryDeploymentException e) { throw new BusinessDataRepositoryDeploymentException(e); } }
protected TenantServiceAccessor getTenantAccessor() { try { return TenantServiceSingleton.getInstance(getTenantId()); } catch (final Exception e) { throw new BonitaRuntimeException(e); } }
@Override @AvailableWhenTenantIsPaused public TenantResource getBusinessDataModelResource() { return getTenantResource(TenantResourceType.BDM); }
protected long getTenantId() { try { return getSessionAccessor().getTenantId(); } catch (final Exception e) { throw new BonitaRuntimeException(e); } }
@AvailableWhenTenantIsPaused protected void pauseServicesForTenant(final PlatformServiceAccessor platformServiceAccessor, final long tenantId) throws UpdateException { // clustered services try { pauseScheduler(platformServiceAccessor, tenantId); deleteSessionsOfTenantExceptTechnicalUser(platformServiceAccessor, tenantId); // on all nodes setTenantClassloaderAndUpdateStateOfTenantServicesWithLifecycle(platformServiceAccessor, tenantId, new PauseServiceStrategy()); } catch (final SSchedulerException e) { throw new UpdateException("Unable to pause the scheduler.", e); } }
@Override @AvailableWhenTenantIsPaused public byte[] getClientBDMZip() throws BusinessDataRepositoryException { final BusinessDataModelRepository bdmRepository = getTenantAccessor().getBusinessDataModelRepository(); try { return bdmRepository.getClientBDMZip(); } catch (final SBusinessDataRepositoryException e) { throw new BusinessDataRepositoryException(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); } }