Search in sources :

Example 1 with PowerpointFileResource

use of org.olat.fileresource.types.PowerpointFileResource in project OpenOLAT by OpenOLAT.

the class WebDocumentHandler method importResource.

@Override
public RepositoryEntry importResource(Identity initialAuthor, String initialAuthorAlt, String displayname, String description, boolean withReferences, Locale locale, File file, String filename) {
    FileResource ores;
    if (DocFileResource.TYPE_NAME.equals(supportedType) && DocFileResource.validate(filename)) {
        ores = new DocFileResource();
    } else if (XlsFileResource.TYPE_NAME.equals(supportedType) && XlsFileResource.validate(filename)) {
        ores = new XlsFileResource();
    } else if (PowerpointFileResource.TYPE_NAME.equals(supportedType) && PowerpointFileResource.validate(filename)) {
        ores = new PowerpointFileResource();
    } else if (PdfFileResource.TYPE_NAME.equals(supportedType) && PdfFileResource.validate(filename)) {
        ores = new PdfFileResource();
    } else if (ImageFileResource.TYPE_NAME.equals(supportedType) && ImageFileResource.validate(filename)) {
        ores = new ImageFileResource();
    } else if (MovieFileResource.TYPE_NAME.equals(supportedType) && MovieFileResource.validate(filename)) {
        ores = new MovieFileResource();
    } else if (SoundFileResource.TYPE_NAME.equals(supportedType) && SoundFileResource.validate(filename)) {
        ores = new SoundFileResource();
    } else if (AnimationFileResource.TYPE_NAME.equals(supportedType) && AnimationFileResource.validate(filename)) {
        ores = new AnimationFileResource();
    } else {
        return null;
    }
    OLATResource resource = OLATResourceManager.getInstance().createAndPersistOLATResourceInstance(ores);
    File fResourceFileroot = FileResourceManager.getInstance().getFileResourceRootImpl(resource).getBasefile();
    File target = new File(fResourceFileroot, filename);
    try {
        Files.move(file.toPath(), target.toPath(), StandardCopyOption.REPLACE_EXISTING);
    } catch (IOException e) {
        log.error("", e);
    }
    RepositoryEntry re = CoreSpringFactory.getImpl(RepositoryService.class).create(initialAuthor, null, "", displayname, description, resource, RepositoryEntry.ACC_OWNERS);
    DBFactory.getInstance().commit();
    return re;
}
Also used : DocFileResource(org.olat.fileresource.types.DocFileResource) AnimationFileResource(org.olat.fileresource.types.AnimationFileResource) FileResource(org.olat.fileresource.types.FileResource) PdfFileResource(org.olat.fileresource.types.PdfFileResource) XlsFileResource(org.olat.fileresource.types.XlsFileResource) ImageFileResource(org.olat.fileresource.types.ImageFileResource) DocFileResource(org.olat.fileresource.types.DocFileResource) AnimationFileResource(org.olat.fileresource.types.AnimationFileResource) SoundFileResource(org.olat.fileresource.types.SoundFileResource) MovieFileResource(org.olat.fileresource.types.MovieFileResource) PowerpointFileResource(org.olat.fileresource.types.PowerpointFileResource) OLATResource(org.olat.resource.OLATResource) IOException(java.io.IOException) RepositoryEntry(org.olat.repository.RepositoryEntry) SoundFileResource(org.olat.fileresource.types.SoundFileResource) XlsFileResource(org.olat.fileresource.types.XlsFileResource) PowerpointFileResource(org.olat.fileresource.types.PowerpointFileResource) PdfFileResource(org.olat.fileresource.types.PdfFileResource) ImageFileResource(org.olat.fileresource.types.ImageFileResource) File(java.io.File) MovieFileResource(org.olat.fileresource.types.MovieFileResource) RepositoryService(org.olat.repository.RepositoryService)

Example 2 with PowerpointFileResource

use of org.olat.fileresource.types.PowerpointFileResource in project openolat by klemens.

the class WebDocumentHandler method importResource.

@Override
public RepositoryEntry importResource(Identity initialAuthor, String initialAuthorAlt, String displayname, String description, boolean withReferences, Locale locale, File file, String filename) {
    FileResource ores;
    if (DocFileResource.TYPE_NAME.equals(supportedType) && DocFileResource.validate(filename)) {
        ores = new DocFileResource();
    } else if (XlsFileResource.TYPE_NAME.equals(supportedType) && XlsFileResource.validate(filename)) {
        ores = new XlsFileResource();
    } else if (PowerpointFileResource.TYPE_NAME.equals(supportedType) && PowerpointFileResource.validate(filename)) {
        ores = new PowerpointFileResource();
    } else if (PdfFileResource.TYPE_NAME.equals(supportedType) && PdfFileResource.validate(filename)) {
        ores = new PdfFileResource();
    } else if (ImageFileResource.TYPE_NAME.equals(supportedType) && ImageFileResource.validate(filename)) {
        ores = new ImageFileResource();
    } else if (MovieFileResource.TYPE_NAME.equals(supportedType) && MovieFileResource.validate(filename)) {
        ores = new MovieFileResource();
    } else if (SoundFileResource.TYPE_NAME.equals(supportedType) && SoundFileResource.validate(filename)) {
        ores = new SoundFileResource();
    } else if (AnimationFileResource.TYPE_NAME.equals(supportedType) && AnimationFileResource.validate(filename)) {
        ores = new AnimationFileResource();
    } else {
        return null;
    }
    OLATResource resource = OLATResourceManager.getInstance().createAndPersistOLATResourceInstance(ores);
    File fResourceFileroot = FileResourceManager.getInstance().getFileResourceRootImpl(resource).getBasefile();
    File target = new File(fResourceFileroot, filename);
    try {
        Files.move(file.toPath(), target.toPath(), StandardCopyOption.REPLACE_EXISTING);
    } catch (IOException e) {
        log.error("", e);
    }
    RepositoryEntry re = CoreSpringFactory.getImpl(RepositoryService.class).create(initialAuthor, null, "", displayname, description, resource, RepositoryEntry.ACC_OWNERS);
    DBFactory.getInstance().commit();
    return re;
}
Also used : DocFileResource(org.olat.fileresource.types.DocFileResource) AnimationFileResource(org.olat.fileresource.types.AnimationFileResource) FileResource(org.olat.fileresource.types.FileResource) PdfFileResource(org.olat.fileresource.types.PdfFileResource) XlsFileResource(org.olat.fileresource.types.XlsFileResource) ImageFileResource(org.olat.fileresource.types.ImageFileResource) DocFileResource(org.olat.fileresource.types.DocFileResource) AnimationFileResource(org.olat.fileresource.types.AnimationFileResource) SoundFileResource(org.olat.fileresource.types.SoundFileResource) MovieFileResource(org.olat.fileresource.types.MovieFileResource) PowerpointFileResource(org.olat.fileresource.types.PowerpointFileResource) OLATResource(org.olat.resource.OLATResource) IOException(java.io.IOException) RepositoryEntry(org.olat.repository.RepositoryEntry) SoundFileResource(org.olat.fileresource.types.SoundFileResource) XlsFileResource(org.olat.fileresource.types.XlsFileResource) PowerpointFileResource(org.olat.fileresource.types.PowerpointFileResource) PdfFileResource(org.olat.fileresource.types.PdfFileResource) ImageFileResource(org.olat.fileresource.types.ImageFileResource) File(java.io.File) MovieFileResource(org.olat.fileresource.types.MovieFileResource) RepositoryService(org.olat.repository.RepositoryService)

Aggregations

File (java.io.File)2 IOException (java.io.IOException)2 AnimationFileResource (org.olat.fileresource.types.AnimationFileResource)2 DocFileResource (org.olat.fileresource.types.DocFileResource)2 FileResource (org.olat.fileresource.types.FileResource)2 ImageFileResource (org.olat.fileresource.types.ImageFileResource)2 MovieFileResource (org.olat.fileresource.types.MovieFileResource)2 PdfFileResource (org.olat.fileresource.types.PdfFileResource)2 PowerpointFileResource (org.olat.fileresource.types.PowerpointFileResource)2 SoundFileResource (org.olat.fileresource.types.SoundFileResource)2 XlsFileResource (org.olat.fileresource.types.XlsFileResource)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2 RepositoryService (org.olat.repository.RepositoryService)2 OLATResource (org.olat.resource.OLATResource)2