use of org.olat.core.util.vfs.VFSStatus in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
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 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 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 klemens.
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);
}
Aggregations