Search in sources :

Example 61 with RepositoryHandler

use of org.olat.repository.handlers.RepositoryHandler in project openolat by klemens.

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);
    }
}
Also used : ResourceEvaluation(org.olat.fileresource.types.ResourceEvaluation) ArrayList(java.util.ArrayList) RepositoryHandler(org.olat.repository.handlers.RepositoryHandler) File(java.io.File)

Example 62 with RepositoryHandler

use of org.olat.repository.handlers.RepositoryHandler in project openolat by klemens.

the class ImportRepositoryEntryController method doImport.

private void doImport() {
    RepositoryHandler handler;
    if (handlerForUploadedResources == null || handlerForUploadedResources.isEmpty()) {
        handler = null;
    } else if (handlerForUploadedResources.size() == 1) {
        handler = handlerForUploadedResources.get(0).getHandler();
    } else if (selectType.isOneSelected()) {
        String type = selectType.getSelectedKey();
        handler = repositoryHandlerFactory.getRepositoryHandler(type);
    } else {
        handler = null;
    }
    if (handler != null) {
        String displayname = displaynameEl.getValue();
        File uploadedFile = uploadFileEl.getUploadFile();
        String uploadedFilename = uploadFileEl.getUploadFileName();
        boolean withReferences = referencesEl.isAtLeastSelected(1);
        importedEntry = handler.importResource(getIdentity(), null, displayname, "", withReferences, getLocale(), uploadedFile, uploadedFilename);
        if (importedEntry == null) {
            showWarning("error.import");
        } else {
            ThreadLocalUserActivityLogger.log(LearningResourceLoggingAction.LEARNING_RESOURCE_CREATE, getClass(), LoggingResourceable.wrap(importedEntry, OlatResourceableType.genRepoEntry));
            repositoryManager.triggerIndexer(importedEntry);
        }
    }
}
Also used : RepositoryHandler(org.olat.repository.handlers.RepositoryHandler) File(java.io.File)

Example 63 with RepositoryHandler

use of org.olat.repository.handlers.RepositoryHandler in project openolat by klemens.

the class JunitTestHelper method deployDemoCourse.

/**
 * Deploys/imports the "Demo Course".
 * @return the created RepositoryEntry
 */
public static RepositoryEntry deployDemoCourse(Identity initialAuthor) {
    String displayname = "Demo-Kurs-7.1";
    String description = "";
    RepositoryEntry re = null;
    try {
        URL courseUrl = JunitTestHelper.class.getResource("file_resources/Demo-Kurs-7.1.zip");
        File courseFile = new File(courseUrl.toURI());
        RepositoryHandler courseHandler = RepositoryHandlerFactory.getInstance().getRepositoryHandler(CourseModule.getCourseTypeName());
        re = courseHandler.importResource(initialAuthor, null, displayname, description, true, Locale.ENGLISH, courseFile, null);
        ICourse course = CourseFactory.loadCourse(re);
        CourseFactory.publishCourse(course, RepositoryEntry.ACC_USERS, false, initialAuthor, Locale.ENGLISH);
    } catch (Exception e) {
        log.error("", e);
    }
    return re;
}
Also used : ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryHandler(org.olat.repository.handlers.RepositoryHandler) File(java.io.File) URL(java.net.URL)

Example 64 with RepositoryHandler

use of org.olat.repository.handlers.RepositoryHandler in project openolat by klemens.

the class JunitTestHelper method deployBasicCourse.

/**
 * Deploy a course with only a single page.
 * @param initialAuthor
 * @return
 */
public static RepositoryEntry deployBasicCourse(Identity initialAuthor) {
    String displayname = "Basic course (" + CodeHelper.getForeverUniqueID() + ")";
    String description = "A course with only a single page";
    RepositoryEntry re = null;
    try {
        URL courseUrl = JunitTestHelper.class.getResource("file_resources/Basic_course.zip");
        File courseFile = new File(courseUrl.toURI());
        RepositoryHandler courseHandler = RepositoryHandlerFactory.getInstance().getRepositoryHandler(CourseModule.getCourseTypeName());
        re = courseHandler.importResource(initialAuthor, null, displayname, description, true, Locale.ENGLISH, courseFile, null);
        ICourse course = CourseFactory.loadCourse(re);
        CourseFactory.publishCourse(course, RepositoryEntry.ACC_USERS, false, initialAuthor, Locale.ENGLISH);
    } catch (Exception e) {
        log.error("", e);
    }
    return re;
}
Also used : ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryHandler(org.olat.repository.handlers.RepositoryHandler) File(java.io.File) URL(java.net.URL)

Example 65 with RepositoryHandler

use of org.olat.repository.handlers.RepositoryHandler in project openolat by klemens.

the class JunitTestHelper method deployCourse.

/**
 * Deploy a course with only a single page.
 * @param initialAuthor
 * @return
 */
public static RepositoryEntry deployCourse(Identity initialAuthor, String displayname, File courseFile) {
    String description = "A course";
    RepositoryEntry re = null;
    try {
        RepositoryHandler courseHandler = RepositoryHandlerFactory.getInstance().getRepositoryHandler(CourseModule.getCourseTypeName());
        re = courseHandler.importResource(initialAuthor, null, displayname, description, true, Locale.ENGLISH, courseFile, null);
        ICourse course = CourseFactory.loadCourse(re);
        CourseFactory.publishCourse(course, RepositoryEntry.ACC_USERS, false, initialAuthor, Locale.ENGLISH);
    } catch (Exception e) {
        log.error("", e);
    }
    return re;
}
Also used : ICourse(org.olat.course.ICourse) 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