use of org.olat.basesecurity.SecurityGroup in project OpenOLAT by OpenOLAT.
the class CatalogNodeManagerController method doEditOwners.
private void doEditOwners(UserRequest ureq) {
removeAsListenerAndDispose(groupCtrl);
removeAsListenerAndDispose(cmc);
// add ownership management
SecurityGroup secGroup = catalogEntry.getOwnerGroup();
if (secGroup == null) {
catalogEntry = catalogManager.loadCatalogEntry(catalogEntry);
secGroup = securityManager.createAndPersistSecurityGroup();
catalogEntry.setOwnerGroup(secGroup);
catalogEntry = catalogManager.saveCatalogEntry(catalogEntry);
}
groupCtrl = new GroupController(ureq, getWindowControl(), true, false, false, false, false, false, secGroup);
listenTo(groupCtrl);
// open form in dialog
removeAsListenerAndDispose(cmc);
cmc = new CloseableModalController(getWindowControl(), "close", groupCtrl.getInitialComponent(), true, translate("tools.edit.catalog.category.ownergroup"));
listenTo(cmc);
cmc.activate();
}
use of org.olat.basesecurity.SecurityGroup in project OpenOLAT by OpenOLAT.
the class CatalogNodeManagerController method doContact.
private void doContact(UserRequest ureq) {
removeAsListenerAndDispose(cmc);
removeAsListenerAndDispose(contactCtrl);
ContactList caretaker = new ContactList(translate("contact.to.groupname.caretaker"));
List<Identity> owners = new ArrayList<Identity>();
CatalogEntry parent = catalogEntry;
while (parent != null && owners.isEmpty()) {
SecurityGroup parentOwner = parent.getOwnerGroup();
if (parentOwner != null) {
owners = securityManager.getIdentitiesOfSecurityGroup(parentOwner);
}
parent = parent.getParent();
}
for (int i = owners.size(); i-- > 0; ) {
caretaker.add(owners.get(i));
}
// create e-mail Message
ContactMessage cmsg = new ContactMessage(ureq.getIdentity());
cmsg.addEmailTo(caretaker);
contactCtrl = new ContactFormController(ureq, getWindowControl(), true, false, false, cmsg);
listenTo(contactCtrl);
// open form in dialog
cmc = new CloseableModalController(getWindowControl(), "close", contactCtrl.getInitialComponent(), true, translate("contact.caretaker"));
listenTo(cmc);
cmc.activate();
}
use of org.olat.basesecurity.SecurityGroup in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_7_1_1 method createRepoEntrySecurityGroups.
private void createRepoEntrySecurityGroups(RepositoryEntryUpgrade entry) {
BaseSecurity securityManager = BaseSecurityManager.getInstance();
boolean save = false;
if (entry.getTutorGroup() == null) {
// security group for tutors / coaches
SecurityGroup tutorGroup = securityManager.createAndPersistSecurityGroup();
// member of this group may modify member's membership
securityManager.createAndPersistPolicy(tutorGroup, Constants.PERMISSION_ACCESS, entry.getOlatResource());
// members of this group are always tutors also
securityManager.createAndPersistPolicy(tutorGroup, Constants.PERMISSION_HASROLE, Constants.ORESOURCE_TUTOR);
entry.setTutorGroup(tutorGroup);
securityManager.createAndPersistPolicy(entry.getTutorGroup(), Constants.PERMISSION_COACH, entry.getOlatResource());
DBFactory.getInstance().commit();
save = true;
}
if (entry.getParticipantGroup() == null) {
// security group for participants
SecurityGroup participantGroup = securityManager.createAndPersistSecurityGroup();
// member of this group may modify member's membership
securityManager.createAndPersistPolicy(participantGroup, Constants.PERMISSION_ACCESS, entry.getOlatResource());
// members of this group are always participants also
securityManager.createAndPersistPolicy(participantGroup, Constants.PERMISSION_HASROLE, Constants.ORESOURCE_PARTICIPANT);
entry.setParticipantGroup(participantGroup);
securityManager.createAndPersistPolicy(entry.getParticipantGroup(), Constants.PERMISSION_PARTI, entry.getOlatResource());
DBFactory.getInstance().commit();
save = true;
}
if (save) {
DBFactory.getInstance().updateObject(entry);
}
}
use of org.olat.basesecurity.SecurityGroup in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_7_1_1 method migrateRepoEntrySecurityGroups.
private void migrateRepoEntrySecurityGroups(RepositoryEntryUpgrade entry) {
BaseSecurity securityManager = BaseSecurityManager.getInstance();
List<BGContextImpl> contexts = findBGContextsForResource(entry.getOlatResource(), true, true);
for (BGContextImpl context : contexts) {
List<BusinessGroupUpgrade> groups = getGroupsOfBGContext(context);
for (BusinessGroupUpgrade group : groups) {
// migrate tutors
if (group.getOwnerGroup() != null) {
int count = 0;
List<Identity> owners = securityManager.getIdentitiesOfSecurityGroup(group.getOwnerGroup());
SecurityGroup tutorGroup = entry.getTutorGroup();
for (Identity owner : owners) {
if (securityManager.isIdentityInSecurityGroup(owner, tutorGroup)) {
continue;
}
securityManager.addIdentityToSecurityGroup(owner, tutorGroup);
if (count++ % 20 == 0) {
DBFactory.getInstance().intermediateCommit();
}
}
DBFactory.getInstance().intermediateCommit();
}
// migrate participants
if (group.getPartipiciantGroup() != null) {
int count = 0;
List<Identity> participants = securityManager.getIdentitiesOfSecurityGroup(group.getPartipiciantGroup());
SecurityGroup participantGroup = entry.getParticipantGroup();
for (Identity participant : participants) {
if (securityManager.isIdentityInSecurityGroup(participant, participantGroup)) {
continue;
}
securityManager.addIdentityToSecurityGroup(participant, participantGroup);
if (count++ % 20 == 0) {
DBFactory.getInstance().intermediateCommit();
}
}
DBFactory.getInstance().intermediateCommit();
}
}
}
}
use of org.olat.basesecurity.SecurityGroup in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_10_0_0 method processMapPolicy.
private EPMapUpgradeToGroupRelation processMapPolicy(Policy policy, EPMapUpgrade element) {
String permission = policy.getPermission();
SecurityGroup secGroup = policy.getSecurityGroup();
Group group;
String role;
if (permission.startsWith(EPMapPolicy.Type.user.name())) {
group = groupDao.createGroup();
processSecurityGroup(group, GroupRoles.participant.name(), secGroup);
role = EPMapPolicy.Type.user.name();
} else if (permission.startsWith(EPMapPolicy.Type.group.name())) {
group = findGroupOfBusinessGroup(secGroup);
role = EPMapPolicy.Type.group.name();
} else if (permission.startsWith(EPMapPolicy.Type.invitation.name())) {
InvitationUpgrade invitation = findInvitation(policy.getSecurityGroup());
if (invitation == null) {
return null;
}
group = invitation.getBaseGroup();
role = EPMapPolicy.Type.invitation.name();
} else if (permission.startsWith(EPMapPolicy.Type.allusers.name())) {
group = groupDao.createGroup(EPMapPolicy.Type.allusers.name());
role = EPMapPolicy.Type.allusers.name();
} else {
return null;
}
if (group == null) {
log.error("Group not resolve for policy of map: " + element.getKey() + " and policy: " + policy.getKey());
return null;
}
EPMapUpgradeToGroupRelation relation = new EPMapUpgradeToGroupRelation();
relation.setDefaultGroup(false);
relation.setCreationDate(new Date());
relation.setEntry(element);
relation.setValidTo(policy.getTo());
relation.setValidFrom(policy.getFrom());
relation.setGroup(group);
relation.setRole(role);
return relation;
}
Aggregations