use of org.olat.basesecurity.Group in project openolat by klemens.
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;
}
use of org.olat.basesecurity.Group in project openolat by klemens.
the class OLATUpgrade_10_0_0 method processInvitation.
private void processInvitation(InvitationUpgrade invitation) {
if (invitation.getBaseGroup() == null) {
Group invitationGroup = groupDao.createGroup();
invitation.setBaseGroup(invitationGroup);
dbInstance.getCurrentEntityManager().merge(invitation);
}
}
use of org.olat.basesecurity.Group in project openolat by klemens.
the class BusinessGroupDAO method createAndPersist.
public BusinessGroup createAndPersist(Identity creator, String name, String description, String externalId, String managedFlags, Integer minParticipants, Integer maxParticipants, boolean waitingListEnabled, boolean autoCloseRanksEnabled, boolean showOwners, boolean showParticipants, boolean showWaitingList) {
BusinessGroupImpl businessgroup = new BusinessGroupImpl(name, description);
if (minParticipants != null && minParticipants.intValue() >= 0) {
businessgroup.setMinParticipants(minParticipants);
}
if (maxParticipants != null && maxParticipants.intValue() >= 0) {
businessgroup.setMaxParticipants(maxParticipants);
}
if (StringHelper.containsNonWhitespace(externalId)) {
businessgroup.setExternalId(externalId);
}
if (StringHelper.containsNonWhitespace(managedFlags)) {
businessgroup.setManagedFlagsString(managedFlags);
}
businessgroup.setOwnersVisibleIntern(showOwners);
businessgroup.setParticipantsVisibleIntern(showParticipants);
businessgroup.setWaitingListVisibleIntern(showWaitingList);
// group members visibility
businessgroup.setOwnersVisiblePublic(false);
businessgroup.setParticipantsVisiblePublic(false);
businessgroup.setWaitingListVisiblePublic(false);
businessgroup.setDownloadMembersLists(false);
if (creator == null) {
businessgroup.setAllowToLeave(businessGroupModule.isAllowLeavingGroupCreatedByAuthors());
} else {
Roles roles = securityManager.getRoles(creator);
if (roles.isAuthor()) {
businessgroup.setAllowToLeave(businessGroupModule.isAllowLeavingGroupCreatedByAuthors());
} else {
businessgroup.setAllowToLeave(businessGroupModule.isAllowLeavingGroupCreatedByLearners());
}
}
businessgroup.setWaitingListEnabled(waitingListEnabled);
businessgroup.setAutoCloseRanksEnabled(autoCloseRanksEnabled);
Group group = groupDao.createGroup();
businessgroup.setBaseGroup(group);
if (creator != null) {
groupDao.addMembershipTwoWay(group, creator, GroupRoles.coach.name());
}
EntityManager em = dbInstance.getCurrentEntityManager();
em.persist(businessgroup);
OLATResource businessgroupOlatResource = olatResourceManager.createOLATResourceInstance(businessgroup);
olatResourceManager.saveOLATResource(businessgroupOlatResource);
businessgroup.setResource(businessgroupOlatResource);
businessgroup = em.merge(businessgroup);
// per default all collaboration-tools are disabled
return businessgroup;
}
use of org.olat.basesecurity.Group in project openolat by klemens.
the class BusinessGroupRelationDAO method addRole.
public void addRole(Identity identity, BusinessGroup businessGroup, String role) {
Group group = null;
try {
group = businessGroup.getBaseGroup();
if (group == null) {
group = getGroup(businessGroup);
}
} catch (Exception e) {
log.warn("", e);
group = getGroup(businessGroup);
}
groupDao.addMembershipOneWay(group, identity, role);
}
use of org.olat.basesecurity.Group in project openolat by klemens.
the class BGRightManagerImpl method findBGRights.
@Override
public List<BGRights> findBGRights(List<Group> baseGroups, OLATResource resource) {
List<Grant> grants = groupDao.getGrants(baseGroups, resource);
List<BGRights> rights = new ArrayList<>();
Map<BGRights, BGRights> rightsMap = new HashMap<>();
for (Grant grant : grants) {
String right = grant.getPermission();
if (right.indexOf(BG_RIGHT_PREFIX) == 0 && grant.getResource().equals(resource)) {
BGRightsRole role = null;
if (GroupRoles.participant.name().equals(grant.getRole())) {
role = BGRightsRole.participant;
} else if (GroupRoles.coach.name().equals(grant.getRole())) {
role = BGRightsRole.tutor;
}
BGRights wrapper = new BGRightsImpl(grant.getGroup(), role);
wrapper = rightsMap.computeIfAbsent(wrapper, w -> w);
wrapper.getRights().add(right);
rights.add(wrapper);
}
}
return rights;
}
Aggregations