Search in sources :

Example 11 with BwAdminGroup

use of org.bedework.calfacade.svc.BwAdminGroup in project bw-calendar-engine by Bedework.

the class ProcessCreate method createAdminGroup.

private boolean createAdminGroup(final String account) throws Throwable {
    if (debug) {
        debug("About to create admin group " + account);
    }
    if (account == null) {
        addError("Must supply account");
        return false;
    }
    try {
        open();
        final BwAdminGroup grp = new BwAdminGroup();
        grp.setAccount(account);
        final DirectoryInfo di = getDirectoryInfo();
        String href = di.getBwadmingroupPrincipalRoot();
        if (!href.endsWith("/")) {
            href += "/";
        }
        grp.setPrincipalRef(href + account);
        grp.setDescription(quotedVal());
        if (grp.getDescription() == null) {
            addError("Must supply admin group description");
            return false;
        }
        final String adgGroupOwner = word();
        if (adgGroupOwner == null) {
            addError("Must supply admin group owner");
            return false;
        }
        final BwPrincipal adgPr = getUserAlways(adgGroupOwner);
        if (adgPr == null) {
            return false;
        }
        grp.setGroupOwnerHref(adgPr.getPrincipalRef());
        String adgEventOwner = word();
        if (adgEventOwner == null) {
            adgEventOwner = "agrp_" + account;
        }
        final BwPrincipal adePr = getUserAlways(adgEventOwner);
        if (adePr == null) {
            return false;
        }
        grp.setOwnerHref(adePr.getPrincipalRef());
        getSvci().getAdminDirectories().addGroup(grp);
        return true;
    } finally {
        close();
    }
}
Also used : BwPrincipal(org.bedework.calfacade.BwPrincipal) DirectoryInfo(org.bedework.calfacade.DirectoryInfo) BwAdminGroup(org.bedework.calfacade.svc.BwAdminGroup)

Aggregations

BwAdminGroup (org.bedework.calfacade.svc.BwAdminGroup)11 BwPrincipal (org.bedework.calfacade.BwPrincipal)10 BwCalendar (org.bedework.calfacade.BwCalendar)3 ArrayList (java.util.ArrayList)2 Ace (org.bedework.access.Ace)2 Acl (org.bedework.access.Acl)2 Privilege (org.bedework.access.Privilege)2 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)2 BwCalSuiteWrapper (org.bedework.calfacade.svc.wrappers.BwCalSuiteWrapper)2 URI (java.net.URI)1 AccessException (org.bedework.access.AccessException)1 AceWho (org.bedework.access.AceWho)1 CurrentAccess (org.bedework.access.Acl.CurrentAccess)1 BwGroup (org.bedework.calfacade.BwGroup)1 BwOrganizer (org.bedework.calfacade.BwOrganizer)1 DirectoryInfo (org.bedework.calfacade.DirectoryInfo)1 BwOwnedDbentity (org.bedework.calfacade.base.BwOwnedDbentity)1 BwAuthUser (org.bedework.calfacade.svc.BwAuthUser)1 BwCalSuite (org.bedework.calfacade.svc.BwCalSuite)1 BwPreferences (org.bedework.calfacade.svc.BwPreferences)1