public void deleteOrganizationalUnit(CmsRequestContext context, CmsOrganizationalUnit organizationalUnit)
    throws CmsException {

        CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
        try {
            // check for root ou
            if (organizationalUnit.getParentFqn() == null) {
                throw new CmsDataAccessException(
                    org.opencms.security.Messages.get().container(
                        org.opencms.security.Messages.ERR_ORGUNIT_ROOT_EDITION_0));
            }

            checkRole(dbc, CmsRole.ADMINISTRATOR.forOrgUnit(getParentOrganizationalUnit(organizationalUnit.getName())));
            checkOfflineProject(dbc);
            m_driverManager.deleteOrganizationalUnit(dbc, organizationalUnit);
        } catch (Exception e) {
            dbc.report(null, Messages.get().container(Messages.ERR_DELETE_ORGUNIT_1, organizationalUnit.getName()), e);
        } finally {
            dbc.clear();
        }
    }
public void deleteOrganizationalUnit ( CmsRequestContext context , CmsOrganizationalUnit organizationalUnit ) throws CmsException { CmsDbContext dbc = m_dbContextFactory . getDbContext ( context ) ; try { if ( organizationalUnit . getParentFqn ( ) == null ) { throw new CmsDataAccessException ( org . opencms . security . Messages . get ( ) . container ( org . opencms . security . Messages . ERR_ORGUNIT_ROOT_EDITION_0 ) ) ; } checkRole ( dbc , CmsRole . ADMINISTRATOR . forOrgUnit ( getParentOrganizationalUnit ( organizationalUnit . getName ( ) ) ) ) ; checkOfflineProject ( dbc ) ; m_driverManager . deleteOrganizationalUnit ( dbc , organizationalUnit ) ; } catch ( Exception e ) { dbc . report ( null , Messages . get ( ) . container ( Messages . ERR_DELETE_ORGUNIT_1 , organizationalUnit . getName ( ) ) , e ) ; } finally { dbc . clear ( ) ; } }
Deletes an organizational unit.<p>

Only organizational units that contain no sub organizational unit can be deleted.<p>

The organizational unit can not be delete if it is used in the request context,
or if the current user belongs to it.<p>

All users and groups in the given organizational unit will be deleted.<p>

@param context the current request context
@param organizationalUnit the organizational unit to delete

@throws CmsException if operation was not successful

@see org.opencms.security.CmsOrgUnitManager#deleteOrganizationalUnit(CmsObject, String)