Search in sources :

Example 1 with RepositoryEntryImport

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;
}
Also used : ResourceEvaluation(org.olat.fileresource.types.ResourceEvaluation) Path(java.nio.file.Path) IOException(java.io.IOException) RepositoryEntryImport(org.olat.repository.RepositoryEntryImportExport.RepositoryEntryImport)

Example 2 with RepositoryEntryImport

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);
    }
}
Also used : ZipFile(java.util.zip.ZipFile) InputStream(java.io.InputStream) ZipEntry(java.util.zip.ZipEntry) RepositoryEntryImport(org.olat.repository.RepositoryEntryImportExport.RepositoryEntryImport) SchedulerException(org.quartz.SchedulerException) IOException(java.io.IOException)

Example 3 with RepositoryEntryImport

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);
    }
}
Also used : ZipFile(java.util.zip.ZipFile) InputStream(java.io.InputStream) ZipEntry(java.util.zip.ZipEntry) RepositoryEntryImport(org.olat.repository.RepositoryEntryImportExport.RepositoryEntryImport) SchedulerException(org.quartz.SchedulerException) IOException(java.io.IOException)

Example 4 with RepositoryEntryImport

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;
}
Also used : ResourceEvaluation(org.olat.fileresource.types.ResourceEvaluation) Path(java.nio.file.Path) IOException(java.io.IOException) RepositoryEntryImport(org.olat.repository.RepositoryEntryImportExport.RepositoryEntryImport)

Example 5 with RepositoryEntryImport

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;
}
Also used : ResourceEvaluation(org.olat.fileresource.types.ResourceEvaluation) Path(java.nio.file.Path) IOException(java.io.IOException) RepositoryEntryImport(org.olat.repository.RepositoryEntryImportExport.RepositoryEntryImport)

Aggregations

RepositoryEntryImport (org.olat.repository.RepositoryEntryImportExport.RepositoryEntryImport)8 IOException (java.io.IOException)6 Path (java.nio.file.Path)4 ResourceEvaluation (org.olat.fileresource.types.ResourceEvaluation)4 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 InputStream (java.io.InputStream)2 ZipEntry (java.util.zip.ZipEntry)2 ZipFile (java.util.zip.ZipFile)2 ICourse (org.olat.course.ICourse)2 Structure (org.olat.course.Structure)2 CourseEnvironmentMapper (org.olat.course.export.CourseEnvironmentMapper)2 CourseGroupManager (org.olat.course.groupsandrights.CourseGroupManager)2 PersistingCourseGroupManager (org.olat.course.groupsandrights.PersistingCourseGroupManager)2 CourseEditorTreeNode (org.olat.course.tree.CourseEditorTreeNode)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2 RepositoryEntryImportExport (org.olat.repository.RepositoryEntryImportExport)2 RepositoryService (org.olat.repository.RepositoryService)2 OLATResource (org.olat.resource.OLATResource)2