use of org.olat.repository.RepositoryEntryImportExport.RepositoryEntryImport in project OpenOLAT by OpenOLAT.
the class BinderTemplateResource method evaluate.
public static ResourceEvaluation evaluate(File file, String filename) {
ResourceEvaluation eval = new ResourceEvaluation();
try {
BinderFileFilter visitor = new BinderFileFilter();
Path fPath = PathUtils.visit(file, filename, visitor);
if (visitor.isValid()) {
eval.setValid(true);
Path repoXml = fPath.resolve(RepositoryEntryImportExport.PROPERTIES_FILE);
if (Files.exists(repoXml)) {
RepositoryEntryImport re = RepositoryEntryImportExport.getConfiguration(repoXml);
if (re != null) {
eval.setDisplayname(re.getDisplayname());
eval.setDescription(re.getDescription());
}
}
} else {
eval.setValid(false);
}
PathUtils.closeSubsequentFS(fPath);
} catch (IOException | IllegalArgumentException e) {
log.error("", e);
eval.setValid(false);
}
return eval;
}
use of org.olat.repository.RepositoryEntryImportExport.RepositoryEntryImport in project OpenOLAT by OpenOLAT.
the class VideoManagerImpl method validateVideoExportArchive.
@Override
public void validateVideoExportArchive(File file, ResourceEvaluation eval) {
ZipFile zipFile;
try {
zipFile = new ZipFile(file);
ZipEntry repoMetadataEntry = zipFile.getEntry(DIRNAME_REPOENTRY + "/" + RepositoryEntryImportExport.PROPERTIES_FILE);
RepositoryEntryImport repoMetadata = null;
if (repoMetadataEntry != null) {
eval.setValid(true);
InputStream repoMetaDataStream = zipFile.getInputStream(repoMetadataEntry);
repoMetadata = RepositoryEntryImportExport.getConfiguration(repoMetaDataStream);
if (repoMetadata != null) {
eval.setDisplayname(repoMetadata.getDisplayname());
}
}
zipFile.close();
} catch (Exception e) {
log.error("Error while checking for video resource archive", e);
}
}
use of org.olat.repository.RepositoryEntryImportExport.RepositoryEntryImport in project openolat by klemens.
the class VideoManagerImpl method validateVideoExportArchive.
@Override
public void validateVideoExportArchive(File file, ResourceEvaluation eval) {
ZipFile zipFile;
try {
zipFile = new ZipFile(file);
ZipEntry repoMetadataEntry = zipFile.getEntry(DIRNAME_REPOENTRY + "/" + RepositoryEntryImportExport.PROPERTIES_FILE);
RepositoryEntryImport repoMetadata = null;
if (repoMetadataEntry != null) {
eval.setValid(true);
InputStream repoMetaDataStream = zipFile.getInputStream(repoMetadataEntry);
repoMetadata = RepositoryEntryImportExport.getConfiguration(repoMetaDataStream);
if (repoMetadata != null) {
eval.setDisplayname(repoMetadata.getDisplayname());
}
}
zipFile.close();
} catch (Exception e) {
log.error("Error while checking for video resource archive", e);
}
}
use of org.olat.repository.RepositoryEntryImportExport.RepositoryEntryImport in project openolat by klemens.
the class BinderTemplateResource method evaluate.
public static ResourceEvaluation evaluate(File file, String filename) {
ResourceEvaluation eval = new ResourceEvaluation();
try {
BinderFileFilter visitor = new BinderFileFilter();
Path fPath = PathUtils.visit(file, filename, visitor);
if (visitor.isValid()) {
eval.setValid(true);
Path repoXml = fPath.resolve(RepositoryEntryImportExport.PROPERTIES_FILE);
if (Files.exists(repoXml)) {
RepositoryEntryImport re = RepositoryEntryImportExport.getConfiguration(repoXml);
if (re != null) {
eval.setDisplayname(re.getDisplayname());
eval.setDescription(re.getDescription());
}
}
} else {
eval.setValid(false);
}
PathUtils.closeSubsequentFS(fPath);
} catch (IOException | IllegalArgumentException e) {
log.error("", e);
eval.setValid(false);
}
return eval;
}
use of org.olat.repository.RepositoryEntryImportExport.RepositoryEntryImport in project OpenOLAT by OpenOLAT.
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;
}
Aggregations