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);
}
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);
}
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);
}
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);
}
}
}
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.");
}
Aggregations