Search in sources :

Example 6 with VFSStatus

use of org.olat.core.util.vfs.VFSStatus in project openolat by klemens.

the class VFSResourceRoot method canWrite.

@Override
public boolean canWrite(String name) {
    // resolve item if it already exists
    VFSItem item = resolveFile(name);
    if (item == null) {
        // try to resolve parent in case the item does not yet exist
        int lastSlash = name.lastIndexOf("/");
        if (lastSlash > 0) {
            String containerName = name.substring(0, lastSlash);
            item = resolveFile(containerName);
        }
    }
    if (item == null) {
        return false;
    }
    VFSStatus status;
    if (item instanceof VFSContainer) {
        status = item.canWrite();
    } else {
        // read/write is not defined on item level, only on directory level
        status = item.getParentContainer().canWrite();
    }
    return VFSConstants.YES.equals(status);
}
Also used : VFSStatus(org.olat.core.util.vfs.VFSStatus) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem)

Example 7 with VFSStatus

use of org.olat.core.util.vfs.VFSStatus in project OpenOLAT by OpenOLAT.

the class VideoManagerImpl method deleteVideoTranscodings.

@Override
public boolean deleteVideoTranscodings(OLATResource videoResource) {
    videoTranscodingDao.deleteVideoTranscodings(videoResource);
    VFSStatus deleteStatus = getTranscodingContainer(videoResource).delete();
    return (deleteStatus == VFSConstants.YES ? true : false);
}
Also used : VFSStatus(org.olat.core.util.vfs.VFSStatus)

Example 8 with VFSStatus

use of org.olat.core.util.vfs.VFSStatus in project OpenOLAT by OpenOLAT.

the class CmdMoveCopy method doMove.

private void doMove(UserRequest ureq) {
    FolderTreeModel ftm = (FolderTreeModel) selTree.getTreeModel();
    String selectedPath = ftm.getSelectedPath(selTree.getSelectedNode());
    if (selectedPath == null) {
        abortFailed(ureq, "failed");
        return;
    }
    VFSStatus vfsStatus = VFSConstants.SUCCESS;
    VFSContainer rootContainer = folderComponent.getRootContainer();
    VFSItem vfsItem = rootContainer.resolve(selectedPath);
    if (vfsItem == null || (vfsItem.canWrite() != VFSConstants.YES)) {
        abortFailed(ureq, "failed");
        return;
    }
    // copy the files
    VFSContainer target = (VFSContainer) vfsItem;
    List<VFSItem> sources = getSanityCheckedSourceItems(target, ureq);
    if (sources == null)
        return;
    boolean targetIsRelPath = (target instanceof OlatRelPathImpl);
    for (VFSItem vfsSource : sources) {
        if (targetIsRelPath && (target instanceof OlatRelPathImpl) && (vfsSource instanceof MetaTagged)) {
            // copy the metainfo first
            MetaInfo meta = ((MetaTagged) vfsSource).getMetaInfo();
            if (meta != null) {
                meta.moveCopyToDir((OlatRelPathImpl) target, move);
            }
        }
        VFSItem targetFile = target.resolve(vfsSource.getName());
        if (vfsSource instanceof VFSLeaf && targetFile != null && targetFile instanceof Versionable && ((Versionable) targetFile).getVersions().isVersioned()) {
            // add a new version to the file
            ((Versionable) targetFile).getVersions().addVersion(null, "", ((VFSLeaf) vfsSource).getInputStream());
        } else {
            vfsStatus = target.copyFrom(vfsSource);
        }
        if (vfsStatus != VFSConstants.SUCCESS) {
            String errorKey = "failed";
            if (vfsStatus == VFSConstants.ERROR_QUOTA_EXCEEDED)
                errorKey = "QuotaExceeded";
            abortFailed(ureq, errorKey);
            return;
        }
        if (move) {
            // if move, delete the source. Note that meta source
            // has already been delete (i.e. moved)
            vfsSource.delete();
        }
    }
    // after a copy or a move, notify the subscribers
    VFSSecurityCallback secCallback = VFSManager.findInheritedSecurityCallback(folderComponent.getCurrentContainer());
    if (secCallback != null) {
        SubscriptionContext subsContext = secCallback.getSubscriptionContext();
        if (subsContext != null) {
            NotificationsManager.getInstance().markPublisherNews(subsContext, ureq.getIdentity(), true);
        }
    }
    fireEvent(ureq, new FolderEvent(move ? FolderEvent.MOVE_EVENT : FolderEvent.COPY_EVENT, fileSelection.renderAsHtml()));
    notifyFinished(ureq);
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) FolderTreeModel(org.olat.core.gui.control.generic.folder.FolderTreeModel) OlatRelPathImpl(org.olat.core.util.vfs.OlatRelPathImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) MetaTagged(org.olat.core.commons.modules.bc.meta.tagged.MetaTagged) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo) VFSItem(org.olat.core.util.vfs.VFSItem) Versionable(org.olat.core.util.vfs.version.Versionable) VFSStatus(org.olat.core.util.vfs.VFSStatus) FolderEvent(org.olat.core.commons.modules.bc.FolderEvent) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback)

Example 9 with VFSStatus

use of org.olat.core.util.vfs.VFSStatus in project OpenOLAT by OpenOLAT.

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 10 with VFSStatus

use of org.olat.core.util.vfs.VFSStatus in project OpenOLAT by OpenOLAT.

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