use of org.olat.basesecurity.Group in project OpenOLAT by OpenOLAT.
the class LecturesBlocksTest method removeRepositoryEntryDefaultGroupToLectureBlock.
@Test
public void removeRepositoryEntryDefaultGroupToLectureBlock() throws IOException, URISyntaxException {
Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("lect-1");
ICourse course = CoursesWebService.createEmptyCourse(author, "Course with absence config", "Course with absence configuration", new CourseConfigVO());
RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
LectureBlock block = createLectureBlock(entry);
Group defGroup = repositoryService.getDefaultGroup(entry);
lectureService.save(block, Collections.singletonList(defGroup));
dbInstance.commit();
RestConnection conn = new RestConnection();
Assert.assertTrue(conn.login("administrator", "openolat"));
URI uri = UriBuilder.fromUri(getContextURI()).path("repo").path("entries").path(entry.getKey().toString()).path("lectureblocks").path(block.getKey().toString()).path("participants").path("repositoryentry").build();
HttpDelete method = conn.createDelete(uri, MediaType.APPLICATION_JSON);
HttpResponse response = conn.execute(method);
// check the response
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
EntityUtils.consume(response.getEntity());
// check the database
List<Group> groups = lectureService.getLectureBlockToGroups(block);
Assert.assertNotNull(groups);
Assert.assertEquals(0, groups.size());
}
use of org.olat.basesecurity.Group in project OpenOLAT by OpenOLAT.
the class LecturesBlocksTest method addRepositoryEntryDefaultGroupToLectureBlock.
@Test
public void addRepositoryEntryDefaultGroupToLectureBlock() throws IOException, URISyntaxException {
Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("lect-1");
ICourse course = CoursesWebService.createEmptyCourse(author, "Course with absence config", "Course with absence configuration", new CourseConfigVO());
RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
LectureBlock block = createLectureBlock(entry);
dbInstance.commit();
RestConnection conn = new RestConnection();
Assert.assertTrue(conn.login("administrator", "openolat"));
URI uri = UriBuilder.fromUri(getContextURI()).path("repo").path("entries").path(entry.getKey().toString()).path("lectureblocks").path(block.getKey().toString()).path("participants").path("repositoryentry").build();
HttpPut method = conn.createPut(uri, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
// check the response
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
EntityUtils.consume(response.getEntity());
// check the database
List<Group> groups = lectureService.getLectureBlockToGroups(block);
Assert.assertNotNull(groups);
Assert.assertEquals(1, groups.size());
Group defGroup = repositoryService.getDefaultGroup(entry);
Assert.assertEquals(defGroup, groups.get(0));
}
use of org.olat.basesecurity.Group in project OpenOLAT by OpenOLAT.
the class EPPolicyManager method applyPolicyToInvitation.
private EPStructureElementToGroupRelation applyPolicyToInvitation(Invitation invitation, EPMapPolicy policy, PortfolioStructureMap map) {
invitation = dbInstance.getCurrentEntityManager().merge(invitation);
Group secGroup = invitation.getBaseGroup();
Collection<EPStructureElementToGroupRelation> currentRelations = map.getGroups();
for (EPStructureElementToGroupRelation currentRelation : currentRelations) {
if (secGroup.equals(currentRelation.getGroup())) {
updatePolicy(currentRelation, policy.getFrom(), policy.getTo());
return currentRelation;
}
}
return createBaseRelation(map, secGroup, EPMapPolicy.Type.invitation.name(), policy.getFrom(), policy.getTo());
}
use of org.olat.basesecurity.Group in project OpenOLAT by OpenOLAT.
the class EPStructureManager method removeBaseGroup.
private void removeBaseGroup(EPAbstractMap map) {
Set<EPStructureElementToGroupRelation> relations = map.getGroups();
if (relations != null) {
for (EPStructureElementToGroupRelation relation : relations) {
Group group = relation.getGroup();
if (relation.isDefaultGroup()) {
groupDao.removeMemberships(group);
groupDao.removeGroup(group);
}
}
}
}
use of org.olat.basesecurity.Group in project OpenOLAT by OpenOLAT.
the class EPStructureManager method createBaseGroup.
private EPStructureElementToGroupRelation createBaseGroup(EPStructureElement element, Identity author) {
// create security group
Group ownerGroup = groupDao.createGroup();
EPStructureElementToGroupRelation relation = new EPStructureElementToGroupRelation();
relation.setDefaultGroup(true);
relation.setCreationDate(new Date());
relation.setGroup(ownerGroup);
relation.setStructureElement(element);
groupDao.addMembershipTwoWay(ownerGroup, author, GroupRoles.owner.name());
return relation;
}
Aggregations