use of org.olat.core.util.io.ShieldOutputStream in project OpenOLAT by OpenOLAT.
the class RepositoryEntryImportExport method exportDoExportProperties.
public void exportDoExportProperties(ZipOutputStream zout) throws IOException {
RepositoryEntryImport imp = new RepositoryEntryImport(re);
RepositoryManager rm = RepositoryManager.getInstance();
VFSLeaf image = rm.getImage(re);
if (image != null) {
imp.setImageName(image.getName());
zout.putNextEntry(new ZipEntry(image.getName()));
try (InputStream inImage = image.getInputStream()) {
FileUtils.copy(inImage, new ShieldOutputStream(zout));
} catch (Exception e) {
log.error("", e);
}
zout.closeEntry();
}
RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
VFSLeaf movie = repositoryService.getIntroductionMovie(re);
if (movie != null) {
imp.setMovieName(movie.getName());
zout.putNextEntry(new ZipEntry(movie.getName()));
try (InputStream inMovie = movie.getInputStream()) {
FileUtils.copy(inMovie, new ShieldOutputStream(zout));
} catch (Exception e) {
log.error("", e);
}
zout.closeEntry();
}
zout.putNextEntry(new ZipEntry(PROPERTIES_FILE));
getXStream().toXML(imp, new ShieldOutputStream(zout));
zout.closeEntry();
}
use of org.olat.core.util.io.ShieldOutputStream in project OpenOLAT by OpenOLAT.
the class ScoreAccountingHelper method createCourseResultsOverview.
public static void createCourseResultsOverview(List<Identity> identities, List<AssessableCourseNode> nodes, ICourse course, Locale locale, ZipOutputStream zout) {
try (OutputStream out = new ShieldOutputStream(zout)) {
zout.putNextEntry(new ZipEntry("Course_results.xlsx"));
createCourseResultsOverviewXMLTable(identities, nodes, course, locale, out);
zout.closeEntry();
} catch (IOException e) {
log.error("", e);
}
for (AssessableCourseNode node : nodes) {
String dir = "Assessment_documents/" + StringHelper.transformDisplayNameToFileSystemName(node.getShortName());
if (node instanceof IQTESTCourseNode || node.getModuleConfiguration().getBooleanSafe(MSCourseNode.CONFIG_KEY_HAS_INDIVIDUAL_ASSESSMENT_DOCS, false)) {
for (Identity assessedIdentity : identities) {
List<File> assessmentDocuments = course.getCourseEnvironment().getAssessmentManager().getIndividualAssessmentDocuments(node, assessedIdentity);
if (assessmentDocuments != null && !assessmentDocuments.isEmpty()) {
String name = assessedIdentity.getUser().getLastName() + "_" + assessedIdentity.getUser().getFirstName() + "_" + assessedIdentity.getName();
String userDirName = dir + "/" + StringHelper.transformDisplayNameToFileSystemName(name);
for (File document : assessmentDocuments) {
String path = userDirName + "/" + document.getName();
ZipUtil.addFileToZip(path, document, zout);
}
}
}
}
}
}
use of org.olat.core.util.io.ShieldOutputStream in project openolat by klemens.
the class CheckListExcelExport method exportAll.
public void exportAll(String filename, ZipOutputStream exportStream) {
List<AssessmentData> dataList = checkboxManager.getAssessmentDatas(course, courseNode.getIdent(), null, null);
try (OutputStream out = new ShieldOutputStream(exportStream)) {
exportStream.putNextEntry(new ZipEntry(filename + ".xlsx"));
exportWorkbook(dataList, out);
exportStream.closeEntry();
} catch (IOException e) {
log.error("", e);
}
}
use of org.olat.core.util.io.ShieldOutputStream in project openolat by klemens.
the class QTI21ExportProcessor method process.
public void process(QuestionItemFull qitem, ZipOutputStream zout) {
String dir = qitem.getDirectory();
File rootDirectory = qpoolFileStorage.getDirectory(dir);
String rootDir = "qitem_" + qitem.getKey();
File imsmanifest = new File(rootDirectory, "imsmanifest.xml");
ManifestBuilder manifestBuilder;
if (imsmanifest.exists()) {
manifestBuilder = ManifestBuilder.read(imsmanifest);
} else {
manifestBuilder = new ManifestBuilder();
}
File resourceFile = new File(rootDirectory, qitem.getRootFilename());
URI assessmentItemUri = resourceFile.toURI();
ResolvedAssessmentItem resolvedAssessmentItem = qtiService.loadAndResolveAssessmentItemForCopy(assessmentItemUri, rootDirectory);
enrichWithMetadata(qitem, resolvedAssessmentItem, manifestBuilder);
try {
zout.putNextEntry(new ZipEntry(rootDir + "/imsmanifest.xml"));
manifestBuilder.write(new ShieldOutputStream(zout));
zout.closeEntry();
} catch (Exception e) {
log.error("", e);
}
try {
Files.walkFileTree(rootDirectory.toPath(), new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
String filename = file.getFileName().toString();
if (!"imsmanifest.xml".equals(filename) && !filename.startsWith(".")) {
String relPath = rootDirectory.toPath().relativize(file).toString();
ZipUtil.addFileToZip(rootDir + "/" + relPath, file, zout);
}
return FileVisitResult.CONTINUE;
}
});
} catch (IOException e) {
log.error("", e);
}
}
use of org.olat.core.util.io.ShieldOutputStream in project openolat by klemens.
the class RepositoryEntryImportExport method exportDoExportProperties.
public void exportDoExportProperties(ZipOutputStream zout) throws IOException {
RepositoryEntryImport imp = new RepositoryEntryImport(re);
RepositoryManager rm = RepositoryManager.getInstance();
VFSLeaf image = rm.getImage(re);
if (image != null) {
imp.setImageName(image.getName());
zout.putNextEntry(new ZipEntry(image.getName()));
try (InputStream inImage = image.getInputStream()) {
FileUtils.copy(inImage, new ShieldOutputStream(zout));
} catch (Exception e) {
log.error("", e);
}
zout.closeEntry();
}
RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
VFSLeaf movie = repositoryService.getIntroductionMovie(re);
if (movie != null) {
imp.setMovieName(movie.getName());
zout.putNextEntry(new ZipEntry(movie.getName()));
try (InputStream inMovie = movie.getInputStream()) {
FileUtils.copy(inMovie, new ShieldOutputStream(zout));
} catch (Exception e) {
log.error("", e);
}
zout.closeEntry();
}
zout.putNextEntry(new ZipEntry(PROPERTIES_FILE));
getXStream().toXML(imp, new ShieldOutputStream(zout));
zout.closeEntry();
}
Aggregations