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);
}
}
}
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();
}
}
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);
}
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);
}
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);
}
Aggregations