use of org.olat.basesecurity.Policy in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_10_0_3 method findBGRights.
private List<String> findBGRights(SecurityGroup secGroup) {
List<Policy> results = securityManager.getPoliciesOfSecurityGroup(secGroup);
// filter all business group rights permissions. group right permissions
// start with bgr.
List<String> rights = new ArrayList<String>();
for (Policy rightPolicy : results) {
String right = rightPolicy.getPermission();
if (right.indexOf("bgr.") == 0)
rights.add(right);
}
return rights;
}
use of org.olat.basesecurity.Policy in project OpenOLAT by OpenOLAT.
the class EPFrontendManagerTest method deleteMap_withOldPolicy.
@Test
public void deleteMap_withOldPolicy() {
// create map
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("frtuse-7");
PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioDefaultMap(id, "Delete map", "Description");
PortfolioStructure page = epFrontendManager.createAndPersistPortfolioPage(map, "Page while be deleted", "Page description");
AbstractArtefact artefact = epFrontendManager.createAndPersistArtefact(id, "Forum");
epFrontendManager.addArtefactToStructure(id, artefact, page);
dbInstance.commit();
// create an old policy manually
SecurityGroup secGroup = securityManager.createAndPersistSecurityGroup();
Policy policy = securityManager.createAndPersistPolicy(secGroup, "allusers_" + Constants.PERMISSION_READ, map.getOlatResource());
Assert.assertNotNull(policy);
dbInstance.commitAndCloseSession();
// delete the map
PortfolioStructure reloadedMap = epFrontendManager.loadPortfolioStructureByKey(map.getKey());
epFrontendManager.deletePortfolioStructure(reloadedMap);
dbInstance.commit();
}
use of org.olat.basesecurity.Policy in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_10_0_0 method processMap.
private void processMap(EPMapUpgrade map) {
if (hasGroupsRelations(map)) {
return;
}
Set<EPMapUpgradeToGroupRelation> relations = new HashSet<>();
SecurityGroup ownerGroup = map.getOwnerGroup();
if (ownerGroup != null) {
// create default group
RepositoryEntryUpgrade re = findMapRepoEntry(ownerGroup);
if (re != null) {
Group reGroup = repositoryEntryToGroupDAO.getDefaultGroup(re);
if (reGroup != null) {
relations.add(createDefaultGroup(map, reGroup));
}
}
if (relations.isEmpty()) {
Group group = groupDao.createGroup();
relations.add(createDefaultGroup(map, group));
processSecurityGroup(group, GroupRoles.owner.name(), ownerGroup);
}
// create policy -> relation
List<Policy> policies = securityManager.getPoliciesOfResource(map.getOlatResource(), null);
for (Policy policy : policies) {
if (policy.getPermission().contains(Constants.PERMISSION_READ)) {
EPMapUpgradeToGroupRelation policyRelation = processMapPolicy(policy, map);
if (policyRelation != null) {
relations.add(policyRelation);
}
}
}
for (EPMapUpgradeToGroupRelation relation : relations) {
dbInstance.getCurrentEntityManager().persist(relation);
}
}
}
use of org.olat.basesecurity.Policy in project openolat by klemens.
the class EPFrontendManagerTest method deleteMap_withOldPolicy.
@Test
public void deleteMap_withOldPolicy() {
// create map
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("frtuse-7");
PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioDefaultMap(id, "Delete map", "Description");
PortfolioStructure page = epFrontendManager.createAndPersistPortfolioPage(map, "Page while be deleted", "Page description");
AbstractArtefact artefact = epFrontendManager.createAndPersistArtefact(id, "Forum");
epFrontendManager.addArtefactToStructure(id, artefact, page);
dbInstance.commit();
// create an old policy manually
SecurityGroup secGroup = securityManager.createAndPersistSecurityGroup();
Policy policy = securityManager.createAndPersistPolicy(secGroup, "allusers_" + Constants.PERMISSION_READ, map.getOlatResource());
Assert.assertNotNull(policy);
dbInstance.commitAndCloseSession();
// delete the map
PortfolioStructure reloadedMap = epFrontendManager.loadPortfolioStructureByKey(map.getKey());
epFrontendManager.deletePortfolioStructure(reloadedMap);
dbInstance.commit();
}
use of org.olat.basesecurity.Policy in project openolat by klemens.
the class OLATUpgrade_10_0_0 method processMap.
private void processMap(EPMapUpgrade map) {
if (hasGroupsRelations(map)) {
return;
}
Set<EPMapUpgradeToGroupRelation> relations = new HashSet<>();
SecurityGroup ownerGroup = map.getOwnerGroup();
if (ownerGroup != null) {
// create default group
RepositoryEntryUpgrade re = findMapRepoEntry(ownerGroup);
if (re != null) {
Group reGroup = repositoryEntryToGroupDAO.getDefaultGroup(re);
if (reGroup != null) {
relations.add(createDefaultGroup(map, reGroup));
}
}
if (relations.isEmpty()) {
Group group = groupDao.createGroup();
relations.add(createDefaultGroup(map, group));
processSecurityGroup(group, GroupRoles.owner.name(), ownerGroup);
}
// create policy -> relation
List<Policy> policies = securityManager.getPoliciesOfResource(map.getOlatResource(), null);
for (Policy policy : policies) {
if (policy.getPermission().contains(Constants.PERMISSION_READ)) {
EPMapUpgradeToGroupRelation policyRelation = processMapPolicy(policy, map);
if (policyRelation != null) {
relations.add(policyRelation);
}
}
}
for (EPMapUpgradeToGroupRelation relation : relations) {
dbInstance.getCurrentEntityManager().persist(relation);
}
}
}
Aggregations