use of org.olat.core.util.vfs.filters.SystemItemFilter in project openolat by klemens.
the class BCCourseNode method createPeekViewRunController.
/**
* @see org.olat.course.nodes.GenericCourseNode#createPeekViewRunController(org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.WindowControl,
* org.olat.course.run.userview.UserCourseEnvironment,
* org.olat.course.run.userview.NodeEvaluation)
*/
@Override
public Controller createPeekViewRunController(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne) {
if (ne.isAtLeastOneAccessible()) {
updateModuleConfigDefaults(false);
// Create a folder peekview controller that shows the latest two entries
VFSContainer rootFolder = null;
if (getModuleConfiguration().getBooleanSafe(BCCourseNodeEditController.CONFIG_AUTO_FOLDER)) {
rootFolder = getNodeFolderContainer(this, userCourseEnv.getCourseEnvironment());
} else {
String subPath = getModuleConfiguration().getStringValue(BCCourseNodeEditController.CONFIG_SUBPATH, "");
VFSItem item = userCourseEnv.getCourseEnvironment().getCourseFolderContainer().resolve(subPath);
if (item instanceof VFSContainer) {
rootFolder = (VFSContainer) item;
}
}
if (rootFolder == null) {
return super.createPeekViewRunController(ureq, wControl, userCourseEnv, ne);
}
rootFolder.setDefaultItemFilter(new SystemItemFilter());
return new BCPeekviewController(ureq, wControl, rootFolder, getIdent(), 4);
} else {
// use standard peekview
return super.createPeekViewRunController(ureq, wControl, userCourseEnv, ne);
}
}
use of org.olat.core.util.vfs.filters.SystemItemFilter in project OpenOLAT by OpenOLAT.
the class SharedFolderWebService method getFiles.
public Response getFiles(Long repoEntryKey, List<PathSegment> path, UriInfo uriInfo, HttpServletRequest httpRequest, Request request) {
RepositoryEntry re = repositoryManager.lookupRepositoryEntry(repoEntryKey);
if (re == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
VFSContainer container = SharedFolderManager.getInstance().getNamedSharedFolder(re, true);
if (container == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
if (!repositoryManager.isAllowedToLaunch(RestSecurityHelper.getIdentity(httpRequest), RestSecurityHelper.getRoles(httpRequest), re)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
VFSLeaf leaf = null;
for (PathSegment seg : path) {
VFSItem item = container.resolve(seg.getPath());
if (item instanceof VFSLeaf) {
leaf = (VFSLeaf) item;
break;
} else if (item instanceof VFSContainer) {
container = (VFSContainer) item;
}
}
if (leaf != null) {
Date lastModified = new Date(leaf.getLastModified());
Response.ResponseBuilder response = request.evaluatePreconditions(lastModified);
if (response == null) {
String mimeType = WebappHelper.getMimeType(leaf.getName());
if (mimeType == null)
mimeType = MediaType.APPLICATION_OCTET_STREAM;
response = Response.ok(leaf.getInputStream(), mimeType).lastModified(lastModified).cacheControl(cc);
}
return response.build();
}
List<VFSItem> items = container.getItems(new SystemItemFilter());
int count = 0;
LinkVO[] links = new LinkVO[items.size()];
for (VFSItem item : items) {
UriBuilder baseUriBuilder = uriInfo.getBaseUriBuilder();
UriBuilder repoUri = baseUriBuilder.path(SharedFolderWebService.class).path(repoEntryKey.toString()).path("files");
for (PathSegment pathSegment : path) {
repoUri.path(pathSegment.getPath());
}
String uri = repoUri.path(item.getName()).build().toString();
links[count++] = new LinkVO("self", uri, item.getName());
}
return Response.ok(links).build();
}
use of org.olat.core.util.vfs.filters.SystemItemFilter in project OpenOLAT by OpenOLAT.
the class ForumWebService method getAttachments.
private FileVO[] getAttachments(Message mess, UriInfo uriInfo) {
VFSContainer container = fom.getMessageContainer(mess.getForum().getKey(), mess.getKey());
List<FileVO> attachments = new ArrayList<FileVO>();
for (VFSItem item : container.getItems(new SystemItemFilter())) {
UriBuilder attachmentUri = uriInfo.getBaseUriBuilder().path("repo").path("forums").path(mess.getForum().getKey().toString()).path("posts").path(mess.getKey().toString()).path("attachments").path(format(item.getName()));
String uri = attachmentUri.build().toString();
if (item instanceof VFSLeaf) {
attachments.add(new FileVO("self", uri, item.getName(), ((VFSLeaf) item).getSize()));
} else {
attachments.add(new FileVO("self", uri, item.getName()));
}
}
FileVO[] attachmentArr = new FileVO[attachments.size()];
attachmentArr = attachments.toArray(attachmentArr);
return attachmentArr;
}
use of org.olat.core.util.vfs.filters.SystemItemFilter in project OpenOLAT by OpenOLAT.
the class VersionsFileManager method countDirectories.
private int countDirectories(VFSContainer container) {
// itself
int count = 1;
List<VFSItem> children = container.getItems(new SystemItemFilter());
for (VFSItem child : children) {
if (child instanceof VFSContainer) {
count += countDirectories((VFSContainer) child);
}
}
return count;
}
use of org.olat.core.util.vfs.filters.SystemItemFilter in project openolat by klemens.
the class AssignmentEditController method persistUploadedFiles.
private void persistUploadedFiles() {
if (tempUploadFolder == null)
return;
VFSContainer container = portfolioFileStorage.getAssignmentContainer(assignment);
if (container != null) {
List<VFSItem> tmpFList = tempUploadFolder.getItems(new SystemItemFilter());
for (VFSItem file : tmpFList) {
try {
VFSLeaf leaf = (VFSLeaf) file;
VFSLeaf storedFile = container.createChildLeaf(leaf.getName());
FileUtils.bcopy(leaf.getInputStream(), storedFile.getOutputStream(false), "");
} catch (Exception e) {
logError("", e);
}
}
}
}
Aggregations