use of org.olat.core.util.vfs.LocalFolderImpl in project openolat by klemens.
the class RepositoryManager method setImage.
public boolean setImage(VFSLeaf newImageFile, RepositoryEntry re) {
VFSLeaf currentImage = getImage(re);
if (currentImage != null) {
if (currentImage instanceof MetaTagged) {
MetaInfo info = ((MetaTagged) currentImage).getMetaInfo();
if (info != null) {
info.clearThumbnails();
}
}
currentImage.delete();
}
if (newImageFile == null || !newImageFile.exists() || newImageFile.getSize() <= 0) {
return false;
}
String targetExtension = ".png";
String extension = FileUtils.getFileSuffix(newImageFile.getName());
if ("jpg".equalsIgnoreCase(extension) || "jpeg".equalsIgnoreCase(extension)) {
targetExtension = ".jpg";
}
VFSContainer repositoryHome = new LocalFolderImpl(new File(FolderConfig.getCanonicalRepositoryHome()));
VFSLeaf repoImage = repositoryHome.createChildLeaf(re.getResourceableId() + targetExtension);
if (targetExtension.equals(".png") || targetExtension.equals(".jpg")) {
Size newImageSize = imageHelper.getSize(newImageFile, extension);
if (newImageSize != null && newImageSize.getWidth() <= PICTURE_WIDTH && newImageSize.getHeight() <= PICTURE_HEIGHT) {
boolean success = VFSManager.copyContent(newImageFile, repoImage);
return success;
}
}
Size size = imageHelper.scaleImage(newImageFile, repoImage, PICTURE_WIDTH, PICTURE_WIDTH, false);
return size != null;
}
use of org.olat.core.util.vfs.LocalFolderImpl in project openolat by klemens.
the class RepositoryManager method copyImage.
/**
* Copy the repo entry image from the source to the target repository entry.
* If the source repo entry does not exists, nothing will happen
*
* @param src
* @param target
* @return
*/
public boolean copyImage(RepositoryEntry source, RepositoryEntry target) {
VFSLeaf srcFile = getImage(source);
if (srcFile == null) {
return false;
}
VFSLeaf targetFile = getImage(target);
if (targetFile != null) {
targetFile.delete();
}
String sourceImageSuffix = FileUtils.getFileSuffix(srcFile.getName());
VFSContainer repositoryHome = new LocalFolderImpl(new File(FolderConfig.getCanonicalRepositoryHome()));
VFSLeaf newImage = repositoryHome.createChildLeaf(target.getResourceableId() + "." + sourceImageSuffix);
if (newImage != null) {
return VFSManager.copyContent(srcFile, newImage);
}
return false;
}
use of org.olat.core.util.vfs.LocalFolderImpl in project openolat by klemens.
the class ScormRepositoryIndexer method doIndex.
protected void doIndex(SearchResourceContext resourceContext, OlatFullIndexer indexWriter, File cpRoot) throws IOException, InterruptedException {
VFSContainer container = new LocalFolderImpl(cpRoot);
VFSLeaf fManifest = (VFSLeaf) container.resolve("imsmanifest.xml");
if (fManifest != null) {
Element rootElement = IMSLoader.loadIMSDocument(fManifest).getRootElement();
Document manfiestDoc = createManifestDocument(fManifest, rootElement, resourceContext);
indexWriter.addDocument(manfiestDoc);
ScormFileAccess accessRule = new ScormFileAccess();
doIndexVFSContainer(resourceContext, container, indexWriter, "", accessRule);
}
}
use of org.olat.core.util.vfs.LocalFolderImpl in project openolat by klemens.
the class TACourseNodeIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
SearchResourceContext courseNodeResourceContext = createSearchResourceContext(repositoryResourceContext, courseNode, null);
Document nodeDocument = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode);
indexWriter.addDocument(nodeDocument);
// Index Task
File fTaskfolder = new File(FolderConfig.getCanonicalRoot() + TACourseNode.getTaskFolderPathRelToFolderRoot(course.getCourseEnvironment(), courseNode));
VFSContainer taskRootContainer = new LocalFolderImpl(fTaskfolder);
courseNodeResourceContext.setDocumentType(TYPE_TASK);
doIndexVFSContainer(courseNodeResourceContext, taskRootContainer, indexWriter, "", FolderIndexerAccess.FULL_ACCESS);
// Index Dropbox
String dropboxFilePath = FolderConfig.getCanonicalRoot() + DropboxController.getDropboxPathRelToFolderRoot(course.getCourseEnvironment(), courseNode);
File fDropboxFolder = new File(dropboxFilePath);
VFSContainer dropboxRootContainer = new LocalFolderImpl(fDropboxFolder);
courseNodeResourceContext.setDocumentType(TYPE_DROPBOX);
doIndexVFSContainer(courseNodeResourceContext, dropboxRootContainer, indexWriter, "", FolderIndexerAccess.FULL_ACCESS);
// Index Returnbox
String returnboxFilePath = FolderConfig.getCanonicalRoot() + ReturnboxController.getReturnboxPathRelToFolderRoot(course.getCourseEnvironment(), courseNode);
File fResturnboxFolder = new File(returnboxFilePath);
VFSContainer returnboxRootContainer = new LocalFolderImpl(fResturnboxFolder);
courseNodeResourceContext.setDocumentType(TYPE_RETURNBOX);
doIndexVFSContainer(courseNodeResourceContext, returnboxRootContainer, indexWriter, "", FolderIndexerAccess.FULL_ACCESS);
// Index Solutionbox
String solutionFilePath = FolderConfig.getCanonicalRoot() + SolutionController.getSolutionPathRelToFolderRoot(course.getCourseEnvironment(), courseNode);
File fSolutionFolder = new File(solutionFilePath);
VFSContainer solutionRootContainer = new LocalFolderImpl(fSolutionFolder);
courseNodeResourceContext.setDocumentType(TYPE_SOLUTIONBOX);
doIndexVFSContainer(courseNodeResourceContext, solutionRootContainer, indexWriter, "", FolderIndexerAccess.FULL_ACCESS);
}
use of org.olat.core.util.vfs.LocalFolderImpl in project openolat by klemens.
the class RepositoryServiceImpl method getIntroductionImage.
@Override
public VFSLeaf getIntroductionImage(RepositoryEntry re) {
VFSContainer repositoryHome = new LocalFolderImpl(new File(FolderConfig.getCanonicalRepositoryHome()));
String imageName = re.getResourceableId() + ".jpg";
VFSItem image = repositoryHome.resolve(imageName);
if (image instanceof VFSLeaf) {
return (VFSLeaf) image;
}
imageName = re.getResourceableId() + ".png";
image = repositoryHome.resolve(imageName);
if (image instanceof VFSLeaf) {
return (VFSLeaf) image;
}
return null;
}
Aggregations