use of org.olat.repository.handlers.RepositoryHandler in project openolat by klemens.
the class ReferencableEntriesSearchController method event.
@Override
public void event(UserRequest ureq, Component source, Event event) {
if (source == segmentView) {
if (event instanceof SegmentViewEvent) {
SegmentViewEvent sve = (SegmentViewEvent) event;
String segmentCName = sve.getComponentName();
Component clickedLink = mainVC.getComponent(segmentCName);
if (clickedLink == myEntriesLink) {
searchCtr.doSearchByOwnerLimitType(ureq.getIdentity(), limitTypes);
} else if (clickedLink == allEntriesLink) {
switch(canBe) {
case referenceable:
searchCtr.doSearchForReferencableResourcesLimitType(ureq.getIdentity(), limitTypes, ureq.getUserSession().getRoles());
break;
case copyable:
searchCtr.doSearchForCopyableResourcesLimitType(ureq.getIdentity(), limitTypes, ureq.getUserSession().getRoles());
break;
case all:
searchCtr.doSearchByTypeLimitAccess(limitTypes, ureq);
break;
}
} else if (clickedLink == searchEntriesLink) {
searchCtr.displaySearchForm();
} else if (clickedLink == adminEntriesLink) {
searchCtr.displayAdminSearchForm();
}
mainVC.setDirty(true);
}
} else if (source == createRessourceCmp || (source instanceof Link && ((Link) source).getUserObject() instanceof RepositoryHandler)) {
removeAsListenerAndDispose(cmc);
removeAsListenerAndDispose(createController);
RepositoryHandler handler = (RepositoryHandler) ((Link) source).getUserObject();
createController = handler.createCreateRepositoryEntryController(ureq, getWindowControl());
listenTo(createController);
String title = translate(handler.getCreateLabelI18nKey());
cmc = new CloseableModalController(getWindowControl(), translate("close"), createController.getInitialComponent(), true, title);
cmc.setCustomWindowCSS("o_sel_author_create_popup");
listenTo(cmc);
cmc.activate();
} else if (source == importRessourceButton) {
removeAsListenerAndDispose(importController);
importController = new ImportRepositoryEntryController(ureq, getWindowControl(), limitTypes);
listenTo(importController);
removeAsListenerAndDispose(cmc);
cmc = new CloseableModalController(getWindowControl(), translate("close"), importController.getInitialComponent(), true, "");
listenTo(cmc);
cmc.activate();
}
}
use of org.olat.repository.handlers.RepositoryHandler in project openolat by klemens.
the class RepositoryEntryImportExport method exportDoExportContent.
/**
* Export a repository entry referenced by a course node to the given export directory.
* User importReferencedRepositoryEntry to import again.
* @return True upon success, false otherwise.
*/
public boolean exportDoExportContent() {
// export resource
RepositoryHandler rh = RepositoryHandlerFactory.getInstance().getRepositoryHandler(re);
MediaResource mr = rh.getAsMediaResource(re.getOlatResource(), false);
FileOutputStream fOut = null;
try {
fOut = new FileOutputStream(new File(baseDirectory, CONTENT_FILE));
InputStream in = mr.getInputStream();
if (in == null) {
HttpServletResponse hres = new HttpServletResponseOutputStream(fOut);
mr.prepare(hres);
} else {
IOUtils.copy(mr.getInputStream(), fOut);
}
fOut.flush();
} catch (IOException fnfe) {
return false;
} finally {
IOUtils.closeQuietly(fOut);
mr.release();
}
return true;
}
use of org.olat.repository.handlers.RepositoryHandler in project openolat by klemens.
the class RepositoryServiceImpl method copy.
@Override
public RepositoryEntry copy(RepositoryEntry sourceEntry, Identity author, String displayname) {
OLATResource sourceResource = sourceEntry.getOlatResource();
OLATResource copyResource = resourceManager.createOLATResourceInstance(sourceResource.getResourceableTypeName());
RepositoryEntry copyEntry = create(author, null, sourceEntry.getResourcename(), displayname, sourceEntry.getDescription(), copyResource, RepositoryEntry.ACC_OWNERS);
// copy all fields
copyEntry.setAuthors(sourceEntry.getAuthors());
copyEntry.setCredits(sourceEntry.getCredits());
copyEntry.setExpenditureOfWork(sourceEntry.getExpenditureOfWork());
copyEntry.setMainLanguage(sourceEntry.getMainLanguage());
copyEntry.setObjectives(sourceEntry.getObjectives());
copyEntry.setRequirements(sourceEntry.getRequirements());
copyEntry = dbInstance.getCurrentEntityManager().merge(copyEntry);
RepositoryHandler handler = RepositoryHandlerFactory.getInstance().getRepositoryHandler(sourceEntry);
copyEntry = handler.copy(author, sourceEntry, copyEntry);
// copy the license
licenseService.copy(sourceResource, copyResource);
// copy the image
RepositoryManager.getInstance().copyImage(sourceEntry, copyEntry);
// copy media container
VFSContainer sourceMediaContainer = handler.getMediaContainer(sourceEntry);
if (sourceMediaContainer != null) {
VFSContainer targetMediaContainer = handler.getMediaContainer(copyEntry);
VFSManager.copyContent(sourceMediaContainer, targetMediaContainer);
}
ThreadLocalUserActivityLogger.log(LearningResourceLoggingAction.LEARNING_RESOURCE_CREATE, getClass(), LoggingResourceable.wrap(copyEntry, OlatResourceableType.genRepoEntry));
lifeIndexer.indexDocument(RepositoryEntryDocument.TYPE, copyEntry.getKey());
return copyEntry;
}
use of org.olat.repository.handlers.RepositoryHandler in project openolat by klemens.
the class RepositoryServiceImpl method getIntroductionMovie.
@Override
public VFSLeaf getIntroductionMovie(RepositoryEntry re) {
RepositoryHandler handler = repositoryHandlerFactory.getRepositoryHandler(re);
VFSContainer mediaContainer = handler.getMediaContainer(re);
if (mediaContainer != null) {
List<VFSItem> items = mediaContainer.getItems();
for (VFSItem item : items) {
if (item instanceof VFSLeaf && item.getName().startsWith(re.getKey().toString()) && (item.getName().endsWith(".mp4") || item.getName().endsWith(".m4v") || item.getName().endsWith(".flv"))) {
return (VFSLeaf) item;
}
}
}
return null;
}
use of org.olat.repository.handlers.RepositoryHandler in project openolat by klemens.
the class RepositoryServiceImpl method deletePermanently.
@Override
public ErrorList deletePermanently(RepositoryEntry entry, Identity identity, Roles roles, Locale locale) {
ErrorList errors = new ErrorList();
boolean debug = log.isDebug();
// invoke handler delete callback
if (debug)
log.debug("deleteRepositoryEntry start entry=" + entry);
entry = (RepositoryEntry) dbInstance.loadObject(entry, true);
if (debug)
log.debug("deleteRepositoryEntry after load entry=" + entry);
RepositoryHandler handler = repositoryHandlerFactory.getRepositoryHandler(entry);
OLATResource resource = entry.getOlatResource();
// delete old context
if (!handler.readyToDelete(entry, identity, roles, locale, errors)) {
return errors;
}
userCourseInformationsManager.deleteUserCourseInformations(entry);
certificatesManager.deleteRepositoryEntry(entry);
// delete all bookmarks referencing deleted entry
CoreSpringFactory.getImpl(MarkManager.class).deleteMarks(entry);
// delete all catalog entries referencing deleted entry
catalogManager.resourceableDeleted(entry);
// delete assessment modes
assessmentModeDao.delete(entry);
// delete reminders
reminderDao.delete(entry);
// delete all policies
securityManager.deletePolicies(resource);
// delete reservations
reservationDao.deleteReservations(resource);
// delete references
referenceManager.deleteAllReferencesOf(resource);
// delete all pending tasks
persistentTaskDao.delete(resource);
dbInstance.commit();
// delete lectures
CoreSpringFactory.getImpl(LectureService.class).delete(entry);
dbInstance.commit();
// delete license
CoreSpringFactory.getImpl(LicenseService.class).delete(resource);
dbInstance.commit();
// detach portfolio if there are some lost
CoreSpringFactory.getImpl(PortfolioService.class).detachCourseFromBinders(entry);
dbInstance.commit();
// inform handler to do any cleanup work... handler must delete the
// referenced resourceable a swell.
handler.cleanupOnDelete(entry, resource);
dbInstance.commit();
// delete all test sessions
assessmentTestSessionDao.deleteAllUserTestSessionsByCourse(entry);
// nullify the reference
assessmentEntryDao.removeEntryForReferenceEntry(entry);
assessmentEntryDao.deleteEntryForRepositoryEntry(entry);
dbInstance.commit();
if (debug)
log.debug("deleteRepositoryEntry after reload entry=" + entry);
deleteRepositoryEntryAndBaseGroups(entry);
if (debug)
log.debug("deleteRepositoryEntry Done");
return errors;
}
Aggregations