use of org.olat.repository.RepositoryService in project openolat by klemens.
the class SharedFolderHandler method createResource.
@Override
public RepositoryEntry createResource(Identity initialAuthor, String displayname, String description, Object createObject, Locale locale) {
RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
SharedFolderFileResource folderResource = SharedFolderManager.getInstance().createSharedFolder();
OLATResource resource = OLATResourceManager.getInstance().findOrPersistResourceable(folderResource);
RepositoryEntry re = repositoryService.create(initialAuthor, null, SharedFolderFileResource.RESOURCE_NAME, displayname, description, resource, RepositoryEntry.ACC_OWNERS);
DBFactory.getInstance().commit();
return re;
}
use of org.olat.repository.RepositoryService in project openolat by klemens.
the class JunitTestHelper method createAndPersistRepositoryEntry.
public static final RepositoryEntry createAndPersistRepositoryEntry(String initialAuthor, OLATResource r, boolean membersOnly) {
RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
RepositoryEntry re = repositoryService.create(initialAuthor, "Lernen mit OLAT", r.getResourceableTypeName(), null, r);
if (membersOnly) {
re.setAccess(RepositoryEntry.ACC_OWNERS);
re.setMembersOnly(true);
} else {
re.setAccess(RepositoryEntry.ACC_USERS);
}
repositoryService.update(re);
return re;
}
use of org.olat.repository.RepositoryService in project openolat by klemens.
the class BinderTemplateHandler method importResource.
@Override
public RepositoryEntry importResource(Identity initialAuthor, String initialAuthorAlt, String displayname, String description, boolean withReferences, Locale locale, File file, String filename) {
RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
try {
// create resource
OLATResource resource = portfolioService.createBinderTemplateResource();
OlatRootFolderImpl fResourceRootContainer = FileResourceManager.getInstance().getFileResourceRootImpl(resource);
File fResourceFileroot = fResourceRootContainer.getBasefile();
File zipRoot = new File(fResourceFileroot, FileResourceManager.ZIPDIR);
FileResource.copyResource(file, filename, zipRoot);
// create repository entry
RepositoryEntry re = repositoryService.create(initialAuthor, initialAuthorAlt, "", displayname, description, resource, RepositoryEntry.ACC_OWNERS);
// import binder
File binderFile = new File(zipRoot, BinderTemplateResource.BINDER_XML);
Binder transientBinder = BinderXStream.fromPath(binderFile.toPath());
File posterImage = null;
if (StringHelper.containsNonWhitespace(transientBinder.getImagePath())) {
posterImage = new File(zipRoot, transientBinder.getImagePath());
}
portfolioService.importBinder(transientBinder, re, posterImage);
RepositoryEntryImportExport rei = new RepositoryEntryImportExport(re, zipRoot);
if (rei.anyExportedPropertiesAvailable()) {
re = rei.importContent(re, fResourceRootContainer.createChildContainer("media"));
}
// delete the imported files
FileUtils.deleteDirsAndFiles(zipRoot, true, true);
return re;
} catch (IOException e) {
log.error("", e);
return null;
}
}
use of org.olat.repository.RepositoryService in project openolat by klemens.
the class BinderTemplateHandler method createResource.
@Override
public RepositoryEntry createResource(Identity initialAuthor, String displayname, String description, Object createObject, Locale locale) {
RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
OLATResource resource = portfolioService.createBinderTemplateResource();
RepositoryEntry re = repositoryService.create(initialAuthor, null, "", displayname, description, resource, RepositoryEntry.ACC_OWNERS);
portfolioService.createAndPersistBinderTemplate(initialAuthor, re, locale);
DBFactory.getInstance().commit();
return re;
}
use of org.olat.repository.RepositoryService in project openolat by klemens.
the class RepositoryEntriesResource method getRepositoryEntryResource.
@Path("{repoEntryKey}")
public RepositoryEntryResource getRepositoryEntryResource() {
RepositoryManager rm = RepositoryManager.getInstance();
BaseSecurity securityManager = BaseSecurityManager.getInstance();
RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
return new RepositoryEntryResource(rm, repositoryService, securityManager);
}
Aggregations