use of org.olat.modules.webFeed.model.ItemImpl in project OpenOLAT by OpenOLAT.
the class BlogArtefactHandler method getContent.
@Override
protected void getContent(AbstractArtefact artefact, StringBuilder sb, SearchResourceContext context, EPFrontendManager ePFManager) {
String content = ePFManager.getArtefactFullTextContent(artefact);
if (content != null) {
try {
XStream xstream = XStreamHelper.createXStreamInstance();
xstream.alias("item", ItemImpl.class);
ItemImpl item = (ItemImpl) xstream.fromXML(content);
String mapperBaseURL = "";
Filter mediaUrlFilter = FilterFactory.getBaseURLToMediaRelativeURLFilter(mapperBaseURL);
sb.append(mediaUrlFilter.filter(item.getDescription())).append(" ").append(mediaUrlFilter.filter(item.getContent()));
} catch (Exception e) {
log.warn("Cannot read an artefact of type blog while indexing", e);
}
}
}
use of org.olat.modules.webFeed.model.ItemImpl in project OpenOLAT by OpenOLAT.
the class ItemDAO method createItem.
/**
* Create a new Item and connect it with the feed.
*
* @param feed
* @return the created item
*/
public Item createItem(Feed feed) {
if (feed == null)
return null;
Item item = new ItemImpl(feed);
item.setCreationDate(new Date());
item.setLastModified(item.getCreationDate());
dbInstance.getCurrentEntityManager().persist(item);
return item;
}
use of org.olat.modules.webFeed.model.ItemImpl in project OpenOLAT by OpenOLAT.
the class RomeFeedFetcher method convertEntry.
/**
* Converts a <code>SyndEntry</code> into an <code>Item</code>
*
* @param entry
* @return
*/
protected Item convertEntry(Feed feed, SyndEntry entry) {
Item item = new ItemImpl(feed);
item.setAuthor(entry.getAuthor());
item.setExternalLink(entry.getLink());
item.setGuid(entry.getUri());
item.setLastModified(entry.getUpdatedDate());
item.setPublishDate(entry.getPublishedDate());
item.setTitle(entry.getTitle());
if (entry.getDescription() != null) {
item.setDescription(entry.getDescription().getValue());
}
List<SyndContent> contents = entry.getContents();
item.setContent(joinContents(contents));
List<SyndEnclosure> enclosures = entry.getEnclosures();
item.setEnclosure(convertEnclosures(enclosures));
return item;
}
use of org.olat.modules.webFeed.model.ItemImpl in project OpenOLAT by OpenOLAT.
the class FeedFileStorgeTest method saveItemAsXML_overwrite.
@Test
public void saveItemAsXML_overwrite() {
BlogFileResource resource = new BlogFileResource();
Feed feed = new FeedImpl(resource);
Item item = new ItemImpl(feed);
item.setGuid("123");
item.setAuthor("autor");
sut.saveItemAsXML(item);
item.setAuthor("secondAuthor");
sut.saveItemAsXML(item);
// check if there is one file in the item container
assertThat(sut.getOrCreateItemContainer(item).getItems().size()).isEqualTo(1);
fileResourceManager.deleteFileResource(resource);
}
use of org.olat.modules.webFeed.model.ItemImpl in project OpenOLAT by OpenOLAT.
the class FeedFileStorgeTest method getOrCreateItemMediaContainer_create.
@Test
public void getOrCreateItemMediaContainer_create() {
BlogFileResource resource = new BlogFileResource();
Feed feed = new FeedImpl(resource);
Item item = new ItemImpl(feed);
item.setGuid("guid");
VFSContainer itemMediaContainer = sut.getOrCreateItemMediaContainer(item);
assertThat(itemMediaContainer).isNotNull();
fileResourceManager.deleteFileResource(resource);
}
Aggregations