use of org.olat.core.util.vfs.VFSStatus in project openolat by klemens.
the class VFSResourceRoot method delete.
@Override
public boolean delete(WebResource resource) {
boolean deleted = false;
if (resource instanceof VFSResource) {
VFSResource vfsResource = (VFSResource) resource;
VFSItem item = vfsResource.getItem();
if (item != null && VFSConstants.YES.equals(item.canDelete())) {
VFSStatus status = item.delete();
deleted = (status == VFSConstants.YES || status == VFSConstants.SUCCESS);
}
}
return deleted;
}
use of org.olat.core.util.vfs.VFSStatus in project openolat by klemens.
the class IQConfigurationController method event.
@Override
public void event(UserRequest urequest, Controller source, Event event) {
if (source == searchController) {
if (event == ReferencableEntriesSearchController.EVENT_REPOSITORY_ENTRY_SELECTED) {
// repository search controller done
cmc.deactivate();
RepositoryEntry re = searchController.getSelectedEntry();
doConfirmChangeTestAndSurvey(urequest, re);
}
} else if (source == confirmChangeResourceCtrl) {
if (event == Event.DONE_EVENT) {
RepositoryEntry newEntry = confirmChangeResourceCtrl.getNewTestEntry();
doChangeResource(urequest, newEntry);
}
cmc.deactivate();
} else if (source == replaceWizard) {
if (event == Event.CANCELLED_EVENT) {
cmc.deactivate();
} else if (event == Event.DONE_EVENT) {
cmc.deactivate();
String repositorySoftKey = (String) moduleConfiguration.get(IQEditController.CONFIG_KEY_REPOSITORY_SOFTKEY);
Long repKey = repositoryManager.lookupRepositoryEntryBySoftkey(repositorySoftKey, true).getKey();
QTIResultManager.getInstance().deleteAllResults(course.getResourceableId(), courseNode.getIdent(), repKey);
IQEditController.removeIQReference(moduleConfiguration);
VFSStatus isDeleted = iqManager.removeQtiSerFiles(course.getResourceableId(), courseNode.getIdent());
if (!isDeleted.equals(VFSConstants.YES)) {
// couldn't removed qtiser files
logWarn("Couldn't removed course node folder! Course resourceable id: " + course.getResourceableId() + ", Course node ident: " + courseNode.getIdent(), null);
}
RepositoryEntry re = replaceWizard.getSelectedRepositoryEntry();
boolean needManualCorrection = checkManualCorrectionNeeded(re);
doIQReference(urequest, re, needManualCorrection);
fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
}
} else if (source == mod12ConfigForm) {
if (event == Event.DONE_EVENT) {
fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
}
} else if (source == mod21ConfigForm) {
if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
}
}
}
use of org.olat.core.util.vfs.VFSStatus in project openolat by klemens.
the class VFSWebservice method deleteItem.
@DELETE
@Path("{path:.*}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response deleteItem(@PathParam("path") List<PathSegment> path) {
if (container.getLocalSecurityCallback() != null && !container.getLocalSecurityCallback().canDelete()) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
VFSItem item = resolveFile(path);
if (item == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
VFSStatus status = item.delete();
if (status == VFSConstants.YES) {
return Response.ok().build();
}
// need something better
return Response.ok().build();
}
use of org.olat.core.util.vfs.VFSStatus in project openolat by klemens.
the class ModifyCourseEvent method deleteCourse.
/**
* Delete a course including its course folder and all references to resources
* this course holds.
*
* @param res
*/
public static void deleteCourse(RepositoryEntry entry, OLATResource res) {
final long start = System.currentTimeMillis();
log.info("deleteCourse: starting to delete course. res=" + res);
PersistingCourseImpl course = null;
try {
course = (PersistingCourseImpl) loadCourse(res);
} catch (CorruptedCourseException e) {
log.error("Try to delete a corrupted course, I make want I can.");
}
// call cleanupOnDelete for nodes
if (course != null) {
Visitor visitor = new NodeDeletionVisitor(course);
TreeVisitor tv = new TreeVisitor(visitor, course.getRunStructure().getRootNode(), true);
tv.visitAll();
}
// delete assessment notifications
OLATResourceable assessmentOres = OresHelper.createOLATResourceableInstance(CourseModule.ORES_COURSE_ASSESSMENT, res.getResourceableId());
NotificationsManager.getInstance().deletePublishersOf(assessmentOres);
// delete all course notifications
NotificationsManager.getInstance().deletePublishersOf(res);
// delete calendar subscription
clearCalenderSubscriptions(res, course);
// the course folder which is deleted right after)
if (course != null) {
CourseConfigManagerImpl.getInstance().deleteConfigOf(course);
}
CoreSpringFactory.getImpl(TaskExecutorManager.class).delete(res);
// delete course group- and rightmanagement
CourseGroupManager courseGroupManager = PersistingCourseGroupManager.getInstance(res);
courseGroupManager.deleteCourseGroupmanagement();
// delete all remaining course properties
CoursePropertyManager propertyManager = PersistingCoursePropertyManager.getInstance(res);
propertyManager.deleteAllCourseProperties();
// delete course calendar
CoreSpringFactory.getImpl(ImportToCalendarManager.class).deleteCourseImportedCalendars(res);
CoreSpringFactory.getImpl(CalendarManager.class).deleteCourseCalendar(res);
// delete IM messages
CoreSpringFactory.getImpl(InstantMessagingService.class).deleteMessages(res);
// delete tasks
CoreSpringFactory.getImpl(GTAManager.class).deleteAllTaskLists(entry);
// cleanup cache
removeFromCache(res.getResourceableId());
// TODO: ld: broadcast event: DeleteCourseEvent
// Everything is deleted, so we could get rid of course logging
// with the change in user audit logging - which now all goes into a DB
// we no longer do this though!
// delete course directory
VFSContainer fCourseBasePath = getCourseBaseContainer(res.getResourceableId());
VFSStatus status = fCourseBasePath.deleteSilently();
boolean deletionSuccessful = (status == VFSConstants.YES || status == VFSConstants.SUCCESS);
log.info("deleteCourse: finished deletion. res=" + res + ", deletion successful: " + deletionSuccessful + ", duration: " + (System.currentTimeMillis() - start) + " ms.");
}
Aggregations