Search in sources :

Example 46 with RepositoryHandler

use of org.olat.repository.handlers.RepositoryHandler in project OpenOLAT by OpenOLAT.

the class ModifyCourseEvent method deployCourseFromZIP.

/**
 * Deploys a course from an exported course ZIP file. This process is unatended and
 * therefore relies on some default assumptions on how to setup the entry and add
 * any referenced resources to the repository.
 *
 * @param exportedCourseZIPFile
 */
public static RepositoryEntry deployCourseFromZIP(File exportedCourseZIPFile, String softKey, int access) {
    RepositoryEntryImportExport importExport = new RepositoryEntryImportExport(exportedCourseZIPFile);
    if (!StringHelper.containsNonWhitespace(softKey)) {
        softKey = importExport.getSoftkey();
    }
    RepositoryEntry existingEntry = repositoryManager.lookupRepositoryEntryBySoftkey(softKey, false);
    if (existingEntry != null) {
        log.info("RepositoryEntry with softkey " + softKey + " already exists. Course will not be deployed.");
        return existingEntry;
    }
    RepositoryHandler courseHandler = RepositoryHandlerFactory.getInstance().getRepositoryHandler(CourseModule.getCourseTypeName());
    RepositoryEntry re = courseHandler.importResource(null, importExport.getInitialAuthor(), importExport.getDisplayName(), importExport.getDescription(), true, Locale.ENGLISH, exportedCourseZIPFile, exportedCourseZIPFile.getName());
    re.setSoftkey(softKey);
    repositoryService.update(re);
    ICourse course = loadCourse(re);
    publishCourse(course, access, false, null, Locale.ENGLISH);
    return re;
}
Also used : RepositoryEntryImportExport(org.olat.repository.RepositoryEntryImportExport) RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryHandler(org.olat.repository.handlers.RepositoryHandler)

Example 47 with RepositoryHandler

use of org.olat.repository.handlers.RepositoryHandler in project OpenOLAT by OpenOLAT.

the class IQTESTCourseNode method importNode.

@Override
public void importNode(File importDirectory, ICourse course, Identity owner, Locale locale, boolean withReferences) {
    RepositoryEntryImportExport rie = new RepositoryEntryImportExport(importDirectory, getIdent());
    if (withReferences && rie.anyExportedPropertiesAvailable()) {
        File file = rie.importGetExportedFile();
        RepositoryHandler handlerQTI21 = RepositoryHandlerFactory.getInstance().getRepositoryHandler(ImsQTI21Resource.TYPE_NAME);
        RepositoryEntry re;
        if (handlerQTI21.acceptImport(file, "repo.zip").isValid()) {
            re = handlerQTI21.importResource(owner, rie.getInitialAuthor(), rie.getDisplayName(), rie.getDescription(), false, locale, rie.importGetExportedFile(), null);
            getModuleConfiguration().set(IQEditController.CONFIG_KEY_TYPE_QTI, IQEditController.CONFIG_VALUE_QTI21);
        } else {
            RepositoryHandler handlerQTI = RepositoryHandlerFactory.getInstance().getRepositoryHandler(TestFileResource.TYPE_NAME);
            re = handlerQTI.importResource(owner, rie.getInitialAuthor(), rie.getDisplayName(), rie.getDescription(), false, locale, rie.importGetExportedFile(), null);
        }
        IQEditController.setIQReference(re, getModuleConfiguration());
    } else {
        IQEditController.removeIQReference(getModuleConfiguration());
    }
}
Also used : RepositoryEntryImportExport(org.olat.repository.RepositoryEntryImportExport) RepositoryHandler(org.olat.repository.handlers.RepositoryHandler) RepositoryEntry(org.olat.repository.RepositoryEntry) File(java.io.File)

Example 48 with RepositoryHandler

use of org.olat.repository.handlers.RepositoryHandler in project OpenOLAT by OpenOLAT.

the class VideoCourseNode method importNode.

@Override
public void importNode(File importDirectory, ICourse course, Identity owner, Locale locale, boolean withReferences) {
    RepositoryEntryImportExport rie = new RepositoryEntryImportExport(importDirectory, getIdent());
    if (withReferences && rie.anyExportedPropertiesAvailable()) {
        // TODO: test
        RepositoryHandler handler = RepositoryHandlerFactory.getInstance().getRepositoryHandler(VideoFileResource.TYPE_NAME);
        RepositoryEntry re = handler.importResource(owner, rie.getInitialAuthor(), rie.getDisplayName(), rie.getDescription(), false, locale, rie.importGetExportedFile(), null);
        VideoEditController.setVideoReference(re, getModuleConfiguration());
    } else {
        VideoEditController.removeVideoReference(getModuleConfiguration());
    }
}
Also used : RepositoryEntryImportExport(org.olat.repository.RepositoryEntryImportExport) RepositoryHandler(org.olat.repository.handlers.RepositoryHandler) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 49 with RepositoryHandler

use of org.olat.repository.handlers.RepositoryHandler in project OpenOLAT by OpenOLAT.

the class WikiCourseNode method importNode.

@Override
public void importNode(File importDirectory, ICourse course, Identity owner, Locale locale, boolean withReferences) {
    RepositoryEntryImportExport rie = new RepositoryEntryImportExport(importDirectory, getIdent());
    if (withReferences && rie.anyExportedPropertiesAvailable()) {
        RepositoryHandler handler = RepositoryHandlerFactory.getInstance().getRepositoryHandler(WikiResource.TYPE_NAME);
        RepositoryEntry re = handler.importResource(owner, rie.getInitialAuthor(), rie.getDisplayName(), rie.getDescription(), false, locale, rie.importGetExportedFile(), null);
        WikiEditController.setWikiRepoReference(re, getModuleConfiguration());
    } else {
        WikiEditController.removeWikiReference(getModuleConfiguration());
    }
}
Also used : RepositoryEntryImportExport(org.olat.repository.RepositoryEntryImportExport) RepositoryHandler(org.olat.repository.handlers.RepositoryHandler) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 50 with RepositoryHandler

use of org.olat.repository.handlers.RepositoryHandler in project OpenOLAT by OpenOLAT.

the class CourseNodeFactory method launchReferencedRepoEntryEditor.

/**
 * Launch an editor for the repository entry which is referenced in the given
 * course node. The editor is launched in a new tab.
 *
 * @param ureq
 * @param node
 */
public boolean launchReferencedRepoEntryEditor(UserRequest ureq, WindowControl wControl, CourseNode node) {
    RepositoryEntry repositoryEntry = node.getReferencedRepositoryEntry();
    if (repositoryEntry == null) {
        // do nothing
        return false;
    }
    RepositoryHandler typeToEdit = RepositoryHandlerFactory.getInstance().getRepositoryHandler(repositoryEntry);
    if (typeToEdit.supportsEdit(repositoryEntry.getOlatResource()) == EditionSupport.no) {
        log.error("Trying to edit repository entry which has no associated editor: " + typeToEdit);
        return false;
    }
    try {
        String businessPath = "[RepositoryEntry:" + repositoryEntry.getKey() + "][Editor:0]";
        NewControllerFactory.getInstance().launch(businessPath, ureq, wControl);
        return true;
    } catch (CorruptedCourseException e) {
        log.error("Course corrupted: " + repositoryEntry.getKey() + " (" + repositoryEntry.getOlatResource().getResourceableId() + ")", e);
        return false;
    }
}
Also used : CorruptedCourseException(org.olat.course.CorruptedCourseException) RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryHandler(org.olat.repository.handlers.RepositoryHandler)

Aggregations

RepositoryHandler (org.olat.repository.handlers.RepositoryHandler)74 RepositoryEntry (org.olat.repository.RepositoryEntry)42 RepositoryEntryImportExport (org.olat.repository.RepositoryEntryImportExport)18 OLATResource (org.olat.resource.OLATResource)16 File (java.io.File)14 ICourse (org.olat.course.ICourse)10 RepositoryService (org.olat.repository.RepositoryService)10 ArrayList (java.util.ArrayList)8 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)8 MediaResource (org.olat.core.gui.media.MediaResource)8 OLATResourceable (org.olat.core.id.OLATResourceable)8 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)6 LockResult (org.olat.core.util.coordinate.LockResult)6 VFSContainer (org.olat.core.util.vfs.VFSContainer)6 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)6 OrderedRepositoryHandler (org.olat.repository.handlers.RepositoryHandlerFactory.OrderedRepositoryHandler)6 URL (java.net.URL)4 GET (javax.ws.rs.GET)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4