use of org.olat.modules.webFeed.model.ItemImpl in project openolat by klemens.
the class ItemDAOTest method createItem_Feed_Null.
@Test
public void createItem_Feed_Null() {
Item tempItem = new ItemImpl(null);
Item item = itemDao.createItem(null, tempItem);
dbInstance.commitAndCloseSession();
// check values
assertThat(item).isNull();
}
use of org.olat.modules.webFeed.model.ItemImpl in project openolat by klemens.
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 klemens.
the class ItemDAO method copyItem.
/**
* Copy an Item to an other (or the same) feed.<br>
* The attributes creationDate and lastModified are mandatory. If one of
* these is null, no new item is created and the method returns null.
*
* @param feed
* @param item
* @return the created item or null
*/
public Item copyItem(Feed feed, Item item) {
if (item == null) {
return null;
}
Long key = item.getKey();
Date creationDate = item.getCreationDate();
Date lastModified = item.getLastModified();
if (feed == null || key == null || creationDate == null || lastModified == null) {
return null;
}
ItemImpl itemImpl = (ItemImpl) loadItem(item.getKey());
dbInstance.getCurrentEntityManager().detach(itemImpl);
itemImpl.setKey(null);
itemImpl.setFeed(feed);
dbInstance.getCurrentEntityManager().persist(itemImpl);
return itemImpl;
}
use of org.olat.modules.webFeed.model.ItemImpl in project openolat by klemens.
the class ItemDAO method createItem.
/**
* Saves a new Item in the database. The Item has to have a Feed. Otherwise
* the Item is not saved an the method returns null.
*
* @param feed
* @param item
* @return the created item or null
*/
public Item createItem(Feed feed, Item item) {
if (feed == null)
return null;
ItemImpl itemImpl = (ItemImpl) item;
itemImpl.setFeed(feed);
if (itemImpl.getCreationDate() == null) {
itemImpl.setCreationDate(new Date());
}
if (itemImpl.getLastModified() == null) {
itemImpl.setLastModified(itemImpl.getCreationDate());
}
dbInstance.getCurrentEntityManager().persist(itemImpl);
return itemImpl;
}
use of org.olat.modules.webFeed.model.ItemImpl in project openolat by klemens.
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;
}
Aggregations