Search in sources :

Example 31 with SecurityGroup

use of org.olat.basesecurity.SecurityGroup in project OpenOLAT by OpenOLAT.

the class CatalogManager method deleteCatalogEntry.

public void deleteCatalogEntry(RepositoryEntryRef entry, CatalogEntry parent) {
    CatalogEntry ce = getCatalogEntryBy(entry, parent);
    if (ce != null) {
        SecurityGroup owner = ce.getOwnerGroup();
        dbInstance.getCurrentEntityManager().remove(ce);
        if (owner != null) {
            log.debug("deleteCatalogEntry case_1: delete owner-group=" + owner);
            securityManager.deleteSecurityGroup(owner);
        }
    }
}
Also used : CatalogEntry(org.olat.repository.CatalogEntry) SecurityGroup(org.olat.basesecurity.SecurityGroup)

Example 32 with SecurityGroup

use of org.olat.basesecurity.SecurityGroup in project OpenOLAT by OpenOLAT.

the class CatalogManager method afterPropertiesSet.

@Override
public void afterPropertiesSet() throws Exception {
    List<CatalogEntry> roots = getRootCatalogEntries();
    if (roots.isEmpty()) {
        // not initialized yet
        /*
			 * copy a snapshot of olatAdmins into catalogAdmins do not put
			 * secMgr.findSecurityGroupByName(Constants.GROUP_ADMIN) directly into a
			 * CatalogEntry!!
			 */
        SecurityGroup olatAdmins = securityManager.findSecurityGroupByName(Constants.GROUP_ADMIN);
        List<Identity> olatAdminIdents = securityManager.getIdentitiesOfSecurityGroup(olatAdmins);
        SecurityGroup catalogAdmins = securityManager.createAndPersistSecurityGroup();
        for (int i = 0; i < olatAdminIdents.size(); i++) {
            securityManager.addIdentityToSecurityGroup(olatAdminIdents.get(i), catalogAdmins);
        }
        /*
			 * start with something called CATALOGROOT, you can rename it to whatever
			 * name you like later as OLATAdmin
			 */
        // parent == null -> no parent -> I am a root node.
        saveCatEntry(CATALOGROOT, null, CatalogEntry.TYPE_NODE, catalogAdmins, null, null);
        dbInstance.intermediateCommit();
    }
}
Also used : CatalogEntry(org.olat.repository.CatalogEntry) SecurityGroup(org.olat.basesecurity.SecurityGroup) Identity(org.olat.core.id.Identity)

Example 33 with SecurityGroup

use of org.olat.basesecurity.SecurityGroup in project OpenOLAT by OpenOLAT.

the class CatalogManager method deleteCatalogSubtree.

/**
 * recursively delete the structure starting from the catalog entry.
 *
 * @param ce
 */
private void deleteCatalogSubtree(CatalogEntry ce, List<SecurityGroup> secGroupsToBeDeleted) {
    List<CatalogEntry> children = getChildrenOf(ce);
    for (CatalogEntry nextCe : children) {
        deleteCatalogSubtree(nextCe, secGroupsToBeDeleted);
    }
    ce = dbInstance.getCurrentEntityManager().find(CatalogEntryImpl.class, ce.getKey());
    // mark owner group for deletion.
    SecurityGroup owner = ce.getOwnerGroup();
    if (owner != null) {
        secGroupsToBeDeleted.add(owner);
    }
    // TODO delete marks
    dbInstance.getCurrentEntityManager().remove(ce);
}
Also used : CatalogEntry(org.olat.repository.CatalogEntry) SecurityGroup(org.olat.basesecurity.SecurityGroup) CatalogEntryImpl(org.olat.repository.model.CatalogEntryImpl)

Example 34 with SecurityGroup

use of org.olat.basesecurity.SecurityGroup in project OpenOLAT by OpenOLAT.

the class CatalogManager method getOwnersOfParentLine.

public List<Identity> getOwnersOfParentLine(CatalogEntry entry) {
    List<CatalogEntry> parentLine = getCategoryParentLine(entry);
    List<SecurityGroup> secGroups = new ArrayList<SecurityGroup>();
    for (CatalogEntry parent : parentLine) {
        if (parent.getOwnerGroup() != null) {
            secGroups.add(parent.getOwnerGroup());
        }
    }
    return securityManager.getIdentitiesOfSecurityGroups(secGroups);
}
Also used : CatalogEntry(org.olat.repository.CatalogEntry) ArrayList(java.util.ArrayList) SecurityGroup(org.olat.basesecurity.SecurityGroup)

Example 35 with SecurityGroup

use of org.olat.basesecurity.SecurityGroup in project OpenOLAT by OpenOLAT.

the class EPShareListController method validateFormLogic.

@Override
protected boolean validateFormLogic(UserRequest ureq) {
    boolean allOk = true;
    // process all form-input fields and update data-model
    secureListBox();
    String genericError = null;
    for (EPSharePolicyWrapper policyWrapper : policyWrappers) {
        Type type = policyWrapper.getType();
        if (type == null) {
            // tutor implicit rule
            continue;
        }
        TextElement mailEl = policyWrapper.getMailEl();
        if (mailEl != null) {
            String mail = mailEl.getValue();
            if (StringHelper.containsNonWhitespace(mail)) {
                if (MailHelper.isValidEmailAddress(mail)) {
                    SecurityGroup allUsers = securityManager.findSecurityGroupByName(Constants.GROUP_OLATUSERS);
                    List<Identity> shareWithIdentities = userManager.findIdentitiesByEmail(Collections.singletonList(mail));
                    if (isAtLeastOneInSecurityGroup(shareWithIdentities, allUsers)) {
                        mailEl.setErrorKey("error.invitation.mail.used", new String[] { mail });
                        allOk &= false;
                    }
                } else {
                    mailEl.setErrorKey("map.share.with.mail.error", null);
                    allOk &= false;
                }
            } else if (type.equals(Type.invitation)) {
                genericError = translate("map.share.error.invite");
                allOk &= false;
            }
        } else if (type.equals(Type.group)) {
            List<BusinessGroup> groups = policyWrapper.getGroups();
            if (groups.size() == 0) {
                genericError = translate("map.share.error.group");
                allOk &= false;
            }
        } else if (type.equals(Type.user)) {
            List<Identity> idents = policyWrapper.getIdentities();
            if (idents.size() == 0) {
                genericError = translate("map.share.error.user");
                allOk &= false;
            }
        }
        if ((policyWrapper.getFromChooser() != null && policyWrapper.getFromChooser().hasError()) || (policyWrapper.getToChooser() != null && policyWrapper.getToChooser().hasError())) {
            genericError = translate("map.share.date.invalid");
            allOk &= false;
        }
        if (policyWrapper.getFrom() != null && policyWrapper.getTo() != null && policyWrapper.getFrom().after(policyWrapper.getTo())) {
            // show invalid date warning
            policyWrapper.getFromChooser().setErrorKey("from.date.behind.to", null);
            policyWrapper.getFromChooser().showError(true);
            genericError = translate("from.date.behind.to");
            allOk &= false;
        }
        StaticTextElement errTextEl = policyWrapper.getErrorEl();
        if (genericError != null && errTextEl != null) {
            errTextEl.setValue(genericError);
        }
    }
    return allOk && super.validateFormLogic(ureq);
}
Also used : Type(org.olat.portfolio.manager.EPMapPolicy.Type) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) ContactList(org.olat.core.util.mail.ContactList) List(java.util.List) ArrayList(java.util.ArrayList) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) SecurityGroup(org.olat.basesecurity.SecurityGroup) Identity(org.olat.core.id.Identity)

Aggregations

SecurityGroup (org.olat.basesecurity.SecurityGroup)142 Identity (org.olat.core.id.Identity)104 ArrayList (java.util.ArrayList)36 Test (org.junit.Test)24 BaseSecurity (org.olat.basesecurity.BaseSecurity)20 User (org.olat.core.id.User)20 CatalogEntry (org.olat.repository.CatalogEntry)18 RepositoryEntry (org.olat.repository.RepositoryEntry)16 Path (javax.ws.rs.Path)14 Date (java.util.Date)12 UserVO (org.olat.user.restapi.UserVO)10 URI (java.net.URI)8 Calendar (java.util.Calendar)8 HashMap (java.util.HashMap)8 HttpResponse (org.apache.http.HttpResponse)8 IdentitiesAddEvent (org.olat.admin.securitygroup.gui.IdentitiesAddEvent)8 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)8 LDAPUser (org.olat.ldap.model.LDAPUser)7 HashSet (java.util.HashSet)6 NamingException (javax.naming.NamingException)6