use of org.olat.fileresource.types.DocFileResource 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;
}
use of org.olat.fileresource.types.DocFileResource 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;
}
Aggregations