use of org.olat.repository.ErrorList in project OpenOLAT by OpenOLAT.
the class ConfirmDeletePermanentlyController method deleteEntries.
private boolean deleteEntries(UserRequest ureq, List<RepositoryEntry> entries, List<ErrorList> errorList) {
boolean allOk = true;
Roles roles = ureq.getUserSession().getRoles();
for (RepositoryEntry entry : entries) {
RepositoryEntry reloadedEntry = repositoryService.loadByKey(entry.getKey());
if (reloadedEntry != null) {
ErrorList errors = repositoryService.deletePermanently(reloadedEntry, getIdentity(), roles, getLocale());
ThreadLocalUserActivityLogger.log(LearningResourceLoggingAction.LEARNING_RESOURCE_DELETE, getClass(), LoggingResourceable.wrap(reloadedEntry, OlatResourceableType.genRepoEntry));
if (errors.hasErrors()) {
allOk = false;
errorList.add(errors);
} else {
EntryChangedEvent e = new EntryChangedEvent(reloadedEntry, getIdentity(), Change.deleted, "delete");
ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(e, RepositoryService.REPOSITORY_EVENT_ORES);
}
}
}
return allOk;
}
use of org.olat.repository.ErrorList in project OpenOLAT by OpenOLAT.
the class RepositoryServiceImplTest method deleteCoursePermanently.
@Test
public void deleteCoursePermanently() {
Identity initialAuthor = JunitTestHelper.createAndPersistIdentityAsRndUser("auth-del-1");
RepositoryEntry re = JunitTestHelper.deployDemoCourse(initialAuthor);
dbInstance.commitAndCloseSession();
Roles roles = new Roles(false, false, false, true, false, false, false);
ErrorList errors = repositoryService.deletePermanently(re, initialAuthor, roles, Locale.ENGLISH);
Assert.assertNotNull(errors);
Assert.assertFalse(errors.hasErrors());
}
use of org.olat.repository.ErrorList in project openolat by klemens.
the class RepositoryServiceImplTest method deleteCoursePermanently.
@Test
public void deleteCoursePermanently() {
Identity initialAuthor = JunitTestHelper.createAndPersistIdentityAsRndUser("auth-del-1");
RepositoryEntry re = JunitTestHelper.deployDemoCourse(initialAuthor);
dbInstance.commitAndCloseSession();
Roles roles = new Roles(false, false, false, true, false, false, false);
ErrorList errors = repositoryService.deletePermanently(re, initialAuthor, roles, Locale.ENGLISH);
Assert.assertNotNull(errors);
Assert.assertFalse(errors.hasErrors());
}
use of org.olat.repository.ErrorList in project openolat by klemens.
the class RepositoryServiceImpl method deletePermanently.
@Override
public ErrorList deletePermanently(RepositoryEntry entry, Identity identity, Roles roles, Locale locale) {
ErrorList errors = new ErrorList();
boolean debug = log.isDebug();
// invoke handler delete callback
if (debug)
log.debug("deleteRepositoryEntry start entry=" + entry);
entry = (RepositoryEntry) dbInstance.loadObject(entry, true);
if (debug)
log.debug("deleteRepositoryEntry after load entry=" + entry);
RepositoryHandler handler = repositoryHandlerFactory.getRepositoryHandler(entry);
OLATResource resource = entry.getOlatResource();
// delete old context
if (!handler.readyToDelete(entry, identity, roles, locale, errors)) {
return errors;
}
userCourseInformationsManager.deleteUserCourseInformations(entry);
certificatesManager.deleteRepositoryEntry(entry);
// delete all bookmarks referencing deleted entry
CoreSpringFactory.getImpl(MarkManager.class).deleteMarks(entry);
// delete all catalog entries referencing deleted entry
catalogManager.resourceableDeleted(entry);
// delete assessment modes
assessmentModeDao.delete(entry);
// delete reminders
reminderDao.delete(entry);
// delete all policies
securityManager.deletePolicies(resource);
// delete reservations
reservationDao.deleteReservations(resource);
// delete references
referenceManager.deleteAllReferencesOf(resource);
// delete all pending tasks
persistentTaskDao.delete(resource);
dbInstance.commit();
// delete lectures
CoreSpringFactory.getImpl(LectureService.class).delete(entry);
dbInstance.commit();
// delete license
CoreSpringFactory.getImpl(LicenseService.class).delete(resource);
dbInstance.commit();
// detach portfolio if there are some lost
CoreSpringFactory.getImpl(PortfolioService.class).detachCourseFromBinders(entry);
dbInstance.commit();
// inform handler to do any cleanup work... handler must delete the
// referenced resourceable a swell.
handler.cleanupOnDelete(entry, resource);
dbInstance.commit();
// delete all test sessions
assessmentTestSessionDao.deleteAllUserTestSessionsByCourse(entry);
// nullify the reference
assessmentEntryDao.removeEntryForReferenceEntry(entry);
assessmentEntryDao.deleteEntryForRepositoryEntry(entry);
dbInstance.commit();
if (debug)
log.debug("deleteRepositoryEntry after reload entry=" + entry);
deleteRepositoryEntryAndBaseGroups(entry);
if (debug)
log.debug("deleteRepositoryEntry Done");
return errors;
}
use of org.olat.repository.ErrorList in project openolat by klemens.
the class ConfirmDeletePermanentlyController method doCompleteDelete.
private void doCompleteDelete(UserRequest ureq) {
List<ErrorList> errorList = new ArrayList<>();
boolean allOk = deleteEntries(ureq, rows, errorList);
if (allOk && deleteReferencesEl.isVisible() && deleteReferencesEl.isEnabled() && deleteReferencesEl.isOneSelected() && deleteReferencesEl.isSelected(0)) {
Map<Long, ReferenceInfos> referencesMap = new HashMap<>();
for (ReferenceInfos reference : references) {
referencesMap.put(reference.getEntry().getKey(), reference);
}
Collection<String> selectedKeys = referencesEl.getSelectedKeys();
List<RepositoryEntry> referencesToDelete = new ArrayList<>(selectedKeys.size());
for (String selectedRefKey : selectedKeys) {
Long key = new Long(selectedRefKey);
ReferenceInfos refInfos = referencesMap.get(key);
if (refInfos != null && refInfos.isOrphan() && refInfos.isOwner() && !refInfos.isManaged()) {
referencesToDelete.add(referencesMap.get(key).getEntry());
}
}
allOk &= deleteEntries(ureq, referencesToDelete, errorList);
}
if (allOk) {
showInfo("info.entry.deleted");
} else {
List<String> msgs = new ArrayList<>();
for (ErrorList error : errorList) {
if (StringHelper.containsNonWhitespace(error.getFirstError())) {
msgs.add(error.getFirstError());
}
}
if (msgs.size() == 1) {
getWindowControl().setWarning(msgs.get(0));
} else if (msgs.size() > 1) {
StringBuilder sb = new StringBuilder();
sb.append("<ul>");
for (String msg : msgs) {
sb.append("<li>").append(msg).append("</li>");
}
sb.append("</ul>");
getWindowControl().setWarning(sb.toString());
} else {
showWarning("info.could.not.delete.entry");
}
}
}
Aggregations