Search in sources :

Example 1 with OrganizationRemovedEvent

use of org.eclipse.che.multiuser.organization.api.event.OrganizationRemovedEvent in project che-server by eclipse-che.

the class OrganizationManager method remove.

/**
 * Removes organization with given id
 *
 * @param organizationId organization id
 * @throws NullPointerException when {@code organizationId} is null
 * @throws ServerException when any other error occurs during organization removing
 */
@Transactional(rollbackOn = { RuntimeException.class, ApiException.class })
public void remove(String organizationId) throws ServerException {
    requireNonNull(organizationId, "Required non-null organization id");
    try {
        OrganizationImpl organization = organizationDao.getById(organizationId);
        eventService.publish(new BeforeAccountRemovedEvent(organization.getAccount())).propagateException();
        eventService.publish(new BeforeOrganizationRemovedEvent(organization)).propagateException();
        removeSuborganizations(organizationId);
        final List<String> members = removeMembers(organizationId);
        organizationDao.remove(organizationId);
        final String initiator = EnvironmentContext.getCurrent().getSubject().getUserName();
        eventService.publish(asDto(new OrganizationRemovedEvent(initiator, organization, members)));
    } catch (NotFoundException e) {
    // organization is already removed
    }
}
Also used : OrganizationRemovedEvent(org.eclipse.che.multiuser.organization.api.event.OrganizationRemovedEvent) BeforeOrganizationRemovedEvent(org.eclipse.che.multiuser.organization.api.event.BeforeOrganizationRemovedEvent) BeforeOrganizationRemovedEvent(org.eclipse.che.multiuser.organization.api.event.BeforeOrganizationRemovedEvent) NotFoundException(org.eclipse.che.api.core.NotFoundException) BeforeAccountRemovedEvent(org.eclipse.che.account.event.BeforeAccountRemovedEvent) OrganizationImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl) Transactional(com.google.inject.persist.Transactional)

Example 2 with OrganizationRemovedEvent

use of org.eclipse.che.multiuser.organization.api.event.OrganizationRemovedEvent in project devspaces-images by redhat-developer.

the class OrganizationManager method remove.

/**
 * Removes organization with given id
 *
 * @param organizationId organization id
 * @throws NullPointerException when {@code organizationId} is null
 * @throws ServerException when any other error occurs during organization removing
 */
@Transactional(rollbackOn = { RuntimeException.class, ApiException.class })
public void remove(String organizationId) throws ServerException {
    requireNonNull(organizationId, "Required non-null organization id");
    try {
        OrganizationImpl organization = organizationDao.getById(organizationId);
        eventService.publish(new BeforeAccountRemovedEvent(organization.getAccount())).propagateException();
        eventService.publish(new BeforeOrganizationRemovedEvent(organization)).propagateException();
        removeSuborganizations(organizationId);
        final List<String> members = removeMembers(organizationId);
        organizationDao.remove(organizationId);
        final String initiator = EnvironmentContext.getCurrent().getSubject().getUserName();
        eventService.publish(asDto(new OrganizationRemovedEvent(initiator, organization, members)));
    } catch (NotFoundException e) {
    // organization is already removed
    }
}
Also used : OrganizationRemovedEvent(org.eclipse.che.multiuser.organization.api.event.OrganizationRemovedEvent) BeforeOrganizationRemovedEvent(org.eclipse.che.multiuser.organization.api.event.BeforeOrganizationRemovedEvent) BeforeOrganizationRemovedEvent(org.eclipse.che.multiuser.organization.api.event.BeforeOrganizationRemovedEvent) NotFoundException(org.eclipse.che.api.core.NotFoundException) BeforeAccountRemovedEvent(org.eclipse.che.account.event.BeforeAccountRemovedEvent) OrganizationImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl) Transactional(com.google.inject.persist.Transactional)

Aggregations

Transactional (com.google.inject.persist.Transactional)2 BeforeAccountRemovedEvent (org.eclipse.che.account.event.BeforeAccountRemovedEvent)2 NotFoundException (org.eclipse.che.api.core.NotFoundException)2 BeforeOrganizationRemovedEvent (org.eclipse.che.multiuser.organization.api.event.BeforeOrganizationRemovedEvent)2 OrganizationRemovedEvent (org.eclipse.che.multiuser.organization.api.event.OrganizationRemovedEvent)2 OrganizationImpl (org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl)2