use of org.olat.modules.webFeed.Item in project openolat by klemens.
the class FeedRepositoryIndexer method doIndex.
/**
* @see org.olat.search.service.indexer.Indexer#doIndex(org.olat.search.service.SearchResourceContext,
* java.lang.Object, org.olat.search.service.indexer.OlatFullIndexer)
*/
@Override
public void doIndex(SearchResourceContext searchResourceContext, Object parentObject, OlatFullIndexer indexer) throws IOException, InterruptedException {
RepositoryEntry repositoryEntry = (RepositoryEntry) parentObject;
// used for log messages
String repoEntryName = "*name not available*";
try {
repoEntryName = repositoryEntry.getDisplayname();
if (isLogDebugEnabled()) {
logDebug("Indexing: " + repoEntryName);
}
Feed feed = FeedManager.getInstance().loadFeed(repositoryEntry.getOlatResource());
if (feed != null) {
// Only index items. Feed itself is indexed by RepositoryEntryIndexer.
List<Item> publishedItems = FeedManager.getInstance().loadPublishedItems(feed);
if (isLogDebugEnabled()) {
logDebug("PublishedItems size=" + publishedItems.size());
}
for (Item item : publishedItems) {
SearchResourceContext feedContext = new SearchResourceContext(searchResourceContext);
feedContext.setDocumentType(getDocumentType());
OlatDocument itemDoc = new FeedItemDocument(item, feedContext);
indexer.addDocument(itemDoc.getLuceneDocument());
}
}
} catch (NullPointerException e) {
logError("Error indexing feed:" + repoEntryName, e);
}
}
use of org.olat.modules.webFeed.Item in project OpenOLAT by OpenOLAT.
the class RomeFeedFetcherTest method convertEntry_Description_null.
@Test
public void convertEntry_Description_null() {
when(syndEntryMock.getDescription()).thenReturn(null);
when(syndEntryMock.getContents()).thenReturn(null);
Item item = sut.convertEntry(feedMock, syndEntryMock);
assertThat(item.getDescription()).isNull();
}
use of org.olat.modules.webFeed.Item in project OpenOLAT by OpenOLAT.
the class RomeFeedFetcherTest method convertEntry.
@Test
public void convertEntry() {
// prepare the mock
String author = "author";
when(syndEntryMock.getAuthor()).thenReturn(author);
String description = "description";
when(syndEntryMock.getDescription().getValue()).thenReturn(description);
String link = "link";
when(syndEntryMock.getLink()).thenReturn(link);
String title = "title";
when(syndEntryMock.getTitle()).thenReturn(title);
String uri = "uri";
when(syndEntryMock.getUri()).thenReturn(uri);
Date publishedDate = new Date();
when(syndEntryMock.getPublishedDate()).thenReturn(publishedDate);
Date updatedDate = new Date();
when(syndEntryMock.getUpdatedDate()).thenReturn(updatedDate);
List<SyndContent> contents = Arrays.asList(syndContentMock);
when(syndEntryMock.getContents()).thenReturn(contents);
when(syndEnclosureMock.getUrl()).thenReturn("URL");
List<SyndEnclosure> enclosures = Arrays.asList(syndEnclosureMock);
when(syndEntryMock.getEnclosures()).thenReturn(enclosures);
// call the method
Item item = sut.convertEntry(feedMock, syndEntryMock);
// test
assertThat(item.getFeed()).isEqualTo(feedMock);
assertThat(item.getAuthor()).isEqualTo(author);
assertThat(item.getContent()).isNotNull();
assertThat(item.getDescription()).isEqualTo(description);
assertThat(item.getEnclosure()).isNotNull();
assertThat(item.getExternalLink()).isEqualTo(link);
assertThat(item.getTitle()).isEqualTo(title);
assertThat(item.getGuid()).isEqualTo(uri);
assertThat(item.getLastModified()).isEqualTo(updatedDate);
assertThat(item.getPublishDate()).isEqualTo(publishedDate);
}
use of org.olat.modules.webFeed.Item in project OpenOLAT by OpenOLAT.
the class BlogArtefactHandler method prefillArtefactAccordingToSource.
/**
* @see org.olat.portfolio.EPAbstractHandler#prefillArtefactAccordingToSource(org.olat.portfolio.model.artefacts.AbstractArtefact, java.lang.Object)
*/
@Override
public void prefillArtefactAccordingToSource(AbstractArtefact artefact, Object source) {
super.prefillArtefactAccordingToSource(artefact, source);
Feed feed = null;
if (source instanceof Feed) {
feed = (Feed) source;
String subPath = getItemUUID(artefact.getBusinessPath());
for (Item item : FeedManager.getInstance().loadItems(feed)) {
if (subPath.equals(item.getGuid())) {
prefillBlogArtefact(artefact, feed, item);
}
}
artefact.setSignature(70);
}
String origBPath = artefact.getBusinessPath();
String artSource = "";
BusinessControl bc = BusinessControlFactory.getInstance().createFromString(origBPath);
if (origBPath.contains(CourseNode.class.getSimpleName())) {
// blog-post from inside a course, rebuild "course-name - feed-name"
OLATResourceable ores = bc.popLauncherContextEntry().getOLATResourceable();
RepositoryEntry repoEntry = RepositoryManager.getInstance().lookupRepositoryEntry(ores.getResourceableId());
artSource = repoEntry.getDisplayname();
if (feed != null) {
artSource += " - " + feed.getTitle();
}
} else if (origBPath.contains(RepositoryEntry.class.getSimpleName())) {
// blog-post from blog-LR, only get name itself
if (feed != null) {
artSource = feed.getTitle();
}
} else {
// collecting a post from live-blog, [Identity:xy]
if (feed != null) {
artSource = feed.getTitle();
}
}
artefact.setSource(artSource);
}
use of org.olat.modules.webFeed.Item in project OpenOLAT by OpenOLAT.
the class FeedFileStorge method loadItemsFromXML.
/**
* Load the XML file of all items of a feed and convert them to items.
*
* @param ores
* @return
*/
public List<Item> loadItemsFromXML(OLATResourceable ores) {
List<Item> items = new ArrayList<>();
VFSContainer itemsContainer = getOrCreateFeedItemsContainer(ores);
if (itemsContainer != null) {
List<VFSItem> itemContainers = itemsContainer.getItems(new VFSItemMetaFilter());
if (itemContainers != null && !itemContainers.isEmpty()) {
for (VFSItem itemContainer : itemContainers) {
Item item = loadItemFromXML((VFSContainer) itemContainer);
if (item != null) {
shorteningItemToLengthOfDbAttributes(item);
items.add(item);
}
}
}
}
return items;
}
Aggregations