use of org.olat.fileresource.types.ResourceEvaluation in project OpenOLAT by OpenOLAT.
the class SurveyFileResource method evaluate.
public static ResourceEvaluation evaluate(File file, String filename) {
ResourceEvaluation eval = new ResourceEvaluation();
try {
QTIFileFilter visitor = new QTIFileFilter();
Path fPath = PathUtils.visit(file, filename, visitor);
if (visitor.isValid()) {
Path qtiPath = fPath.resolve(QTI_FILE);
Document doc = QTIHelper.getDocument(qtiPath);
validateQti(doc, eval);
} else {
eval.setValid(false);
}
PathUtils.closeSubsequentFS(fPath);
} catch (IOException | IllegalArgumentException e) {
log.error("", e);
eval.setValid(false);
}
return eval;
}
use of org.olat.fileresource.types.ResourceEvaluation in project OpenOLAT by OpenOLAT.
the class SurveyFileResource method validate.
/**
* @param unzippedDir
* @return True if is of type.
*/
public static boolean validate(File unzippedDir) {
VFSContainer vfsUnzippedRoot = new LocalFolderImpl(unzippedDir);
VFSItem vfsQTI = vfsUnzippedRoot.resolve("qti.xml");
// getDocument(..) ensures that InputStream is closed in every case.
Document doc = QTIHelper.getDocument((LocalFileImpl) vfsQTI);
return validateQti(doc, new ResourceEvaluation(false)).isValid();
}
use of org.olat.fileresource.types.ResourceEvaluation in project openolat by klemens.
the class CourseHandler method acceptImport.
@Override
public ResourceEvaluation acceptImport(File file, String filename) {
ResourceEvaluation eval = new ResourceEvaluation();
try {
IndexFileFilter visitor = new IndexFileFilter();
Path fPath = PathUtils.visit(file, filename, visitor);
if (visitor.isValid()) {
Path repoXml = fPath.resolve("export/repo.xml");
if (repoXml != null) {
eval.setValid(true);
RepositoryEntryImport re = RepositoryEntryImportExport.getConfiguration(repoXml);
if (re != null) {
eval.setDisplayname(re.getDisplayname());
eval.setDescription(re.getDescription());
}
eval.setReferences(hasReferences(fPath));
}
}
eval.setValid(visitor.isValid());
PathUtils.closeSubsequentFS(fPath);
} catch (IOException | IllegalArgumentException e) {
log.error("", e);
}
return eval;
}
use of org.olat.fileresource.types.ResourceEvaluation in project openolat by klemens.
the class WebDocumentHandler method acceptImport.
@Override
public ResourceEvaluation acceptImport(File file, String filename) {
if (!StringHelper.containsNonWhitespace(filename)) {
filename = file.getName();
}
ResourceEvaluation eval = new ResourceEvaluation(false);
String extension = FileUtils.getFileSuffix(filename);
if (StringHelper.containsNonWhitespace(extension)) {
if (DocFileResource.TYPE_NAME.equals(supportedType) && DocFileResource.validate(filename)) {
eval.setValid(true);
} else if (XlsFileResource.TYPE_NAME.equals(supportedType) && XlsFileResource.validate(filename)) {
eval.setValid(true);
} else if (PowerpointFileResource.TYPE_NAME.equals(supportedType) && PowerpointFileResource.validate(filename)) {
eval.setValid(true);
} else if (PdfFileResource.TYPE_NAME.equals(supportedType) && PdfFileResource.validate(filename)) {
eval.setValid(true);
} else if (ImageFileResource.TYPE_NAME.equals(supportedType) && ImageFileResource.validate(filename)) {
eval.setValid(true);
} else if (MovieFileResource.TYPE_NAME.equals(supportedType) && MovieFileResource.validate(filename)) {
eval.setValid(true);
} else if (SoundFileResource.TYPE_NAME.equals(supportedType) && SoundFileResource.validate(filename)) {
eval.setValid(true);
} else if (AnimationFileResource.TYPE_NAME.equals(supportedType) && AnimationFileResource.validate(filename)) {
eval.setValid(true);
}
}
return eval;
}
use of org.olat.fileresource.types.ResourceEvaluation in project openolat by klemens.
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