use of org.olat.core.util.PathUtils.YesMatcher in project OpenOLAT by OpenOLAT.
the class QTIImportProcessor method processItemFiles.
/**
* Process the file of an item's package
* @param item
* @param itemInfos
*/
protected void processItemFiles(QuestionItemImpl item, DocInfos docInfos) {
// a package with an item
String dir = item.getDirectory();
String rootFilename = item.getRootFilename();
VFSContainer container = qpoolFileStorage.getContainer(dir);
if (docInfos != null && docInfos.getRoot() != null) {
try {
Path destDir = ((LocalImpl) container).getBasefile().toPath();
// unzip to container
Path path = docInfos.getRoot();
Files.walkFileTree(path, new CopyVisitor(path, destDir, new YesMatcher()));
} catch (IOException e) {
log.error("", e);
}
} else if (importedFilename.toLowerCase().endsWith(".zip")) {
ZipUtil.unzipStrict(importedFile, container);
} else {
VFSLeaf endFile = container.createChildLeaf(rootFilename);
OutputStream out = null;
FileInputStream in = null;
try {
out = endFile.getOutputStream(false);
in = new FileInputStream(importedFile);
IOUtils.copy(in, out);
} catch (IOException e) {
log.error("", e);
} finally {
IOUtils.closeQuietly(out);
IOUtils.closeQuietly(in);
}
}
}
use of org.olat.core.util.PathUtils.YesMatcher in project OpenOLAT by OpenOLAT.
the class EvaluationFormHandler method copyResource.
private boolean copyResource(File file, String filename, File targetDirectory) {
try {
Path path = FileResource.getResource(file, filename);
if (path == null) {
return false;
}
Path destDir = targetDirectory.toPath();
Files.walkFileTree(path, new CopyVisitor(path, destDir, new YesMatcher()));
PathUtils.closeSubsequentFS(path);
return true;
} catch (IOException e) {
log.error("", e);
return false;
}
}
use of org.olat.core.util.PathUtils.YesMatcher in project openolat by klemens.
the class EvaluationFormHandler method copyResource.
private boolean copyResource(File file, String filename, File targetDirectory) {
try {
Path path = FileResource.getResource(file, filename);
if (path == null) {
return false;
}
Path destDir = targetDirectory.toPath();
Files.walkFileTree(path, new CopyVisitor(path, destDir, new YesMatcher()));
PathUtils.closeSubsequentFS(path);
return true;
} catch (IOException e) {
log.error("", e);
return false;
}
}
use of org.olat.core.util.PathUtils.YesMatcher in project OpenOLAT by OpenOLAT.
the class QTI21AssessmentTestHandler method copyResource.
private boolean copyResource(File file, String filename, File targetDirectory) {
try {
Path path = FileResource.getResource(file, filename);
if (path == null) {
return false;
}
Path destDir = targetDirectory.toPath();
QTI21IMSManifestExplorerVisitor visitor = new QTI21IMSManifestExplorerVisitor();
Files.walkFileTree(path, visitor);
Files.walkFileTree(path, new CopyAndConvertVisitor(path, destDir, visitor.getInfos(), new YesMatcher()));
PathUtils.closeSubsequentFS(path);
return true;
} catch (IOException e) {
log.error("", e);
return false;
}
}
use of org.olat.core.util.PathUtils.YesMatcher in project OpenOLAT by OpenOLAT.
the class QTI21AssessmentTestHandler method copyOnyxResources.
/**
* Copy the Onyx assessmentTest, assessmentItems, attachments and media folder.
*
* @param onyxZippedDir
* @param targetDirectory
* @return true if the copy is successful
*/
private boolean copyOnyxResources(OLATResource onyxResource, File targetDirectory) {
try {
// copy files
File onyxResourceFileroot = FileResourceManager.getInstance().getFileResourceRootImpl(onyxResource).getBasefile();
File onyxZippedDir = new File(onyxResourceFileroot, FileResourceManager.ZIPDIR);
Path path = onyxZippedDir.toPath();
Path destDir = targetDirectory.toPath();
QTI21IMSManifestExplorerVisitor visitor = new QTI21IMSManifestExplorerVisitor();
Files.walkFileTree(path, visitor);
Files.walkFileTree(path, new CopyAndConvertVisitor(path, destDir, visitor.getInfos(), new YesMatcher()));
return true;
} catch (IOException e) {
log.error("", e);
return false;
}
}
Aggregations