Search in sources :

Example 11 with VFSStatus

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;
}
Also used : VFSStatus(org.olat.core.util.vfs.VFSStatus) VFSItem(org.olat.core.util.vfs.VFSItem)

Example 12 with VFSStatus

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);
        }
    }
}
Also used : VFSStatus(org.olat.core.util.vfs.VFSStatus) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 13 with VFSStatus

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();
}
Also used : VFSStatus(org.olat.core.util.vfs.VFSStatus) VFSItem(org.olat.core.util.vfs.VFSItem) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces)

Example 14 with VFSStatus

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.");
}
Also used : TaskExecutorManager(org.olat.core.commons.services.taskexecutor.TaskExecutorManager) CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) PersistingCourseGroupManager(org.olat.course.groupsandrights.PersistingCourseGroupManager) TreeVisitor(org.olat.core.util.tree.TreeVisitor) Visitor(org.olat.core.util.tree.Visitor) OLATResourceable(org.olat.core.id.OLATResourceable) VFSContainer(org.olat.core.util.vfs.VFSContainer) InstantMessagingService(org.olat.instantMessaging.InstantMessagingService) ImportToCalendarManager(org.olat.commons.calendar.manager.ImportToCalendarManager) TreeVisitor(org.olat.core.util.tree.TreeVisitor) ImportToCalendarManager(org.olat.commons.calendar.manager.ImportToCalendarManager) CalendarManager(org.olat.commons.calendar.CalendarManager) VFSStatus(org.olat.core.util.vfs.VFSStatus) GTAManager(org.olat.course.nodes.gta.GTAManager) PersistingCoursePropertyManager(org.olat.course.properties.PersistingCoursePropertyManager) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Aggregations

VFSStatus (org.olat.core.util.vfs.VFSStatus)14 VFSItem (org.olat.core.util.vfs.VFSItem)8 VFSContainer (org.olat.core.util.vfs.VFSContainer)6 DELETE (javax.ws.rs.DELETE)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 CalendarManager (org.olat.commons.calendar.CalendarManager)2 ImportToCalendarManager (org.olat.commons.calendar.manager.ImportToCalendarManager)2 FolderEvent (org.olat.core.commons.modules.bc.FolderEvent)2 MetaInfo (org.olat.core.commons.modules.bc.meta.MetaInfo)2 MetaTagged (org.olat.core.commons.modules.bc.meta.tagged.MetaTagged)2 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)2 TaskExecutorManager (org.olat.core.commons.services.taskexecutor.TaskExecutorManager)2 FolderTreeModel (org.olat.core.gui.control.generic.folder.FolderTreeModel)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 TreeVisitor (org.olat.core.util.tree.TreeVisitor)2 Visitor (org.olat.core.util.tree.Visitor)2 OlatRelPathImpl (org.olat.core.util.vfs.OlatRelPathImpl)2 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)2 VFSSecurityCallback (org.olat.core.util.vfs.callbacks.VFSSecurityCallback)2