use of org.olat.fileresource.types.ResourceEvaluation in project OpenOLAT by OpenOLAT.
the class FileResourceTest method scormPackage_invalid.
@Test
public void scormPackage_invalid() throws URISyntaxException {
URL fileUrl = FileResourceTest.class.getResource("invalid_scorm.zip");
File file = new File(fileUrl.toURI());
ResourceEvaluation eval = ScormCPFileResource.evaluate(file, file.getName());
Assert.assertFalse(eval.isValid());
}
use of org.olat.fileresource.types.ResourceEvaluation in project OpenOLAT by OpenOLAT.
the class FileResourceTest method scormPackage.
@Test
public void scormPackage() throws URISyntaxException {
URL fileUrl = FileResourceTest.class.getResource("very_simple_scorm.zip");
File file = new File(fileUrl.toURI());
ResourceEvaluation eval = ScormCPFileResource.evaluate(file, file.getName());
Assert.assertTrue(eval.isValid());
}
use of org.olat.fileresource.types.ResourceEvaluation in project OpenOLAT by OpenOLAT.
the class FileResourceTest method scormPackage_withinDirectory.
@Test
public void scormPackage_withinDirectory() throws URISyntaxException {
URL fileUrl = FileResourceTest.class.getResource("very_simple_scorm_in_directory.zip");
File file = new File(fileUrl.toURI());
ResourceEvaluation eval = ScormCPFileResource.evaluate(file, file.getName());
Assert.assertTrue(eval.isValid());
}
use of org.olat.fileresource.types.ResourceEvaluation in project OpenOLAT by OpenOLAT.
the class ImportRepositoryEntryController method doAnalyseUpload.
private void doAnalyseUpload() {
File uploadedFile = uploadFileEl.getUploadFile();
if (uploadedFile == null) {
// OO-1320
typeEl.setVisible(false);
selectType.setVisible(false);
uploadFileEl.reset();
importButton.setEnabled(false);
} else {
String uploadedFilename = uploadFileEl.getUploadFileName();
List<ResourceHandler> handlers = new ArrayList<>(3);
for (String type : repositoryHandlerFactory.getSupportedTypes()) {
RepositoryHandler handler = repositoryHandlerFactory.getRepositoryHandler(type);
ResourceEvaluation eval = handler.acceptImport(uploadedFile, uploadedFilename);
if (eval != null && eval.isValid()) {
handlers.add(new ResourceHandler(handler, eval));
}
}
updateResourceInfos(handlers);
validLimitationOnType(handlers);
}
}
use of org.olat.fileresource.types.ResourceEvaluation in project OpenOLAT by OpenOLAT.
the class EvaluationFormResource method evaluate.
public static ResourceEvaluation evaluate(File file, String filename) {
ResourceEvaluation eval = new ResourceEvaluation();
try {
FormFileFilter visitor = new FormFileFilter();
Path fPath = PathUtils.visit(file, filename, visitor);
if (visitor.isValid()) {
Path formPath = fPath.resolve(FORM_XML_FILE);
if (validateForm(formPath)) {
eval.setValid(true);
} else {
eval.setValid(false);
}
} else {
eval.setValid(false);
}
PathUtils.closeSubsequentFS(fPath);
} catch (IOException | IllegalArgumentException e) {
log.error("", e);
eval.setValid(false);
}
return eval;
}
Aggregations