use of org.olat.core.dispatcher.mapper.Mapper in project OpenOLAT by OpenOLAT.
the class EdubaseViewerController method createMapperUri.
private String createMapperUri(UserRequest ureq) {
String launchUrl = edubaseManager.getLtiLaunchUrl(bookSection);
String baseUrl = edubaseModule.getLtiBaseUrl();
String oauthConsumerKey = edubaseModule.getOauthKey();
String oauthSecret = edubaseModule.getOauthSecret();
LTIContext context = new EdubaseContext(ureq.getUserSession().getIdentityEnvironment(), bookSection.getPageTo());
Map<String, String> unsignedProps = ltiManager.forgeLTIProperties(getIdentity(), getLocale(), context, true, true, false);
Mapper contentMapper = new PostDataMapper(unsignedProps, launchUrl, baseUrl, oauthConsumerKey, oauthSecret, false);
String mapperUri = registerMapper(ureq, contentMapper);
mapperUri = mapperUri + "/";
return mapperUri;
}
use of org.olat.core.dispatcher.mapper.Mapper in project OpenOLAT by OpenOLAT.
the class WikiMarkupComponent method setImageMapperUri.
/**
* if the wiki need to serve images you have to set the image mapper uri first!
* The mapper creates an user session based mapper for the media files which can be requested by calling @see getImageBaseUri()
* @param ureq
* @param wikiContainer
*/
public void setImageMapperUri(UserRequest ureq, final VFSContainer wikiContainer) {
// get a usersession-local mapper for images in this wiki
Mapper contentMapper = new VFSContainerMapper(wikiContainer);
// Register mapper as cacheable
String mapperID = VFSManager.getRealPath(wikiContainer);
if (mapperID == null) {
// Can't cache mapper, no cacheable context available
mapperKey = CoreSpringFactory.getImpl(MapperService.class).register(ureq.getUserSession(), contentMapper);
} else {
// Add classname to the file path to remove conflicts with other
// usages of the same file path
mapperID = this.getClass().getSimpleName() + ":" + mapperID;
mapperKey = CoreSpringFactory.getImpl(MapperService.class).register(ureq.getUserSession(), mapperID, contentMapper);
}
imageBaseUri = mapperKey.getUrl() + "/" + WikiContainer.MEDIA_FOLDER_NAME + "/";
}
use of org.olat.core.dispatcher.mapper.Mapper in project OpenOLAT by OpenOLAT.
the class Card2BrainRunController method runCard2Brain.
private void runCard2Brain(UserRequest ureq) {
VelocityContainer container = createVelocityContainer("run");
String url = String.format(card2BrainModule.getBaseUrl(), config.getStringValue(Card2BrainCourseNode.CONFIG_FLASHCARD_ALIAS));
String oauth_consumer_key;
String oauth_secret;
if (config.getBooleanSafe(Card2BrainCourseNode.CONFIG_ENABLE_PRIVATE_LOGIN)) {
oauth_consumer_key = (String) config.get(Card2BrainCourseNode.CONFIG_PRIVATE_KEY);
oauth_secret = (String) config.get(Card2BrainCourseNode.CONFIG_PRIVATE_SECRET);
} else {
oauth_consumer_key = card2BrainModule.getEnterpriseKey();
oauth_secret = card2BrainModule.getEnterpriseSecret();
}
LTIContext context = new Card2BrainContext();
Map<String, String> unsignedProps = ltiManager.forgeLTIProperties(getIdentity(), getLocale(), context, true, true, false);
Mapper contentMapper = new PostDataMapper(unsignedProps, url, oauth_consumer_key, oauth_secret, false);
String mapperUri = registerMapper(ureq, contentMapper);
container.contextPut("mapperUri", mapperUri + "/");
JSAndCSSComponent js = new JSAndCSSComponent("js", new String[] { "js/iframeResizer/iframeResizer.min.js" }, null);
container.put("js", js);
main.setContent(container);
}
use of org.olat.core.dispatcher.mapper.Mapper in project OpenOLAT by OpenOLAT.
the class FileArtefactDetailsController method initFileView.
private void initFileView(VFSItem file, UserRequest ureq) {
vC = createVelocityContainer("fileDetails");
DownloadComponent downlC = new DownloadComponent("download", (VFSLeaf) file);
vC.put("download", downlC);
vC.contextPut("filename", fArtefact.getFilename());
if (file instanceof MetaTagged) {
MetaInfo meta = ((MetaTagged) file).getMetaInfo();
vC.contextPut("meta", meta);
// show a preview thumbnail if possible
if (meta.isThumbnailAvailable()) {
VFSLeaf thumb = meta.getThumbnail(200, 200, false);
if (thumb != null) {
mr = new VFSMediaResource(thumb);
}
if (mr != null) {
String thumbMapper = registerMapper(ureq, new Mapper() {
@Override
public MediaResource handle(String relPath, HttpServletRequest request) {
return mr;
}
});
vC.contextPut("thumbMapper", thumbMapper);
}
}
}
if (!readOnlyMode) {
// allow to delete
delLink = LinkFactory.createLink("delete.file", vC, this);
delLink.setUserObject(file);
}
viewPanel.setContent(vC);
}
use of org.olat.core.dispatcher.mapper.Mapper in project OpenOLAT by OpenOLAT.
the class MapperDAO method retrieveMapperById.
public Mapper retrieveMapperById(String mapperId) {
List<PersistedMapper> mappers = dbInstance.getCurrentEntityManager().createNamedQuery("loadMapperByKey", PersistedMapper.class).setParameter("mapperId", mapperId).getResultList();
PersistedMapper pm = mappers.isEmpty() ? null : mappers.get(0);
if (pm != null && StringHelper.containsNonWhitespace(pm.getXmlConfiguration())) {
String configuration = pm.getXmlConfiguration();
Object obj = XStreamHelper.createXStreamInstance().fromXML(configuration);
if (obj instanceof Mapper) {
return (Mapper) obj;
}
}
return null;
}
Aggregations