use of org.olat.upgrade.model.RepositoryEntryUpgrade in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_10_0_0 method upgradeRepositoryEntries.
private boolean upgradeRepositoryEntries(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
if (!uhd.getBooleanDataValue(TASK_REPOENTRIES)) {
int counter = 0;
List<RepositoryEntryUpgrade> repoEntries;
do {
repoEntries = findRepositoryEntries(counter, BATCH_SIZE);
for (RepositoryEntryUpgrade repoEntry : repoEntries) {
processRepositoryEntry(repoEntry);
}
counter += repoEntries.size();
log.audit("Repository entries processed: " + repoEntries.size() + ", total processed (" + counter + ")");
dbInstance.commitAndCloseSession();
} while (repoEntries.size() == BATCH_SIZE);
uhd.setBooleanDataValue(TASK_REPOENTRIES, true);
upgradeManager.setUpgradesHistory(uhd, VERSION);
}
return true;
}
use of org.olat.upgrade.model.RepositoryEntryUpgrade in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_10_0_0 method processRelationToRepo.
private void processRelationToRepo(BusinessGroupUpgrade businessGroup) {
try {
List<BGResourceRelation> relationsToRepo = findRelations(businessGroup);
if (relationsToRepo.size() > 0) {
Group refGroup = businessGroup.getBaseGroup();
for (BGResourceRelation relationToRepo : relationsToRepo) {
RepositoryEntryUpgrade entry = lookupRepositoryEntry(relationToRepo.getResource());
if (entry == null) {
continue;
}
boolean found = false;
Set<RepositoryEntryUpgradeToGroupRelation> groupRelations = entry.getGroups();
for (RepositoryEntryUpgradeToGroupRelation groupRelation : groupRelations) {
if (groupRelation.getGroup().equals(refGroup)) {
found = true;
}
}
if (!found) {
create(entry, refGroup, false);
}
}
}
dbInstance.commit();
} catch (Exception e) {
log.error("", e);
throw e;
}
}
use of org.olat.upgrade.model.RepositoryEntryUpgrade 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.upgrade.model.RepositoryEntryUpgrade 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);
}
}
}
use of org.olat.upgrade.model.RepositoryEntryUpgrade in project openolat by klemens.
the class OLATUpgrade_10_0_0 method processRelationToRepo.
private void processRelationToRepo(BusinessGroupUpgrade businessGroup) {
try {
List<BGResourceRelation> relationsToRepo = findRelations(businessGroup);
if (relationsToRepo.size() > 0) {
Group refGroup = businessGroup.getBaseGroup();
for (BGResourceRelation relationToRepo : relationsToRepo) {
RepositoryEntryUpgrade entry = lookupRepositoryEntry(relationToRepo.getResource());
if (entry == null) {
continue;
}
boolean found = false;
Set<RepositoryEntryUpgradeToGroupRelation> groupRelations = entry.getGroups();
for (RepositoryEntryUpgradeToGroupRelation groupRelation : groupRelations) {
if (groupRelation.getGroup().equals(refGroup)) {
found = true;
}
}
if (!found) {
create(entry, refGroup, false);
}
}
}
dbInstance.commit();
} catch (Exception e) {
log.error("", e);
throw e;
}
}
Aggregations