use of org.olat.modules.webFeed.Item in project OpenOLAT by OpenOLAT.
the class ItemsController method activate.
@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
if (entries == null || entries.isEmpty() || feedResource == null)
return;
Item item = null;
String itemId = entries.get(0).getOLATResourceable().getResourceableTypeName();
if (itemId != null && itemId.startsWith("item=")) {
itemId = itemId.substring(5, itemId.length());
try {
Long itemKey = Long.parseLong(itemId);
item = FeedManager.getInstance().loadItem(itemKey);
} catch (Exception e) {
item = FeedManager.getInstance().loadItemByGuid(itemId);
}
}
if (item != null) {
activate(ureq, item);
}
}
use of org.olat.modules.webFeed.Item in project OpenOLAT by OpenOLAT.
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 FeedMainController method activate.
@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
if (entries == null || entries.isEmpty())
return;
Item item = null;
String itemId = entries.get(0).getOLATResourceable().getResourceableTypeName();
if (itemId != null && itemId.startsWith("item=")) {
itemId = itemId.substring(5, itemId.length());
try {
Long itemKey = Long.parseLong(itemId);
item = FeedManager.getInstance().loadItem(itemKey);
} catch (Exception e) {
item = FeedManager.getInstance().loadItemByGuid(itemId);
}
}
if (item != null) {
itemsCtr.activate(ureq, item);
}
}
use of org.olat.modules.webFeed.Item in project OpenOLAT by OpenOLAT.
the class FeedCourseNodeIndexer 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 courseResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexer) throws IOException, InterruptedException {
SearchResourceContext courseNodeResourceContext = createSearchResourceContext(courseResourceContext, courseNode, getDocumentType());
Document document = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode);
indexer.addDocument(document);
RepositoryEntry repositoryEntry = courseNode.getReferencedRepositoryEntry();
if (repositoryEntry != null) {
// used for log messages
String repoEntryName = "*name not available*";
try {
repoEntryName = repositoryEntry.getDisplayname();
if (log.isDebug()) {
log.info("Indexing: " + repoEntryName);
}
Feed feed = FeedManager.getInstance().loadFeed(repositoryEntry.getOlatResource());
List<Item> publishedItems = FeedManager.getInstance().loadPublishedItems(feed);
// Create the olatDocument for the feed course node itself
OlatDocument feedNodeDoc = new FeedNodeDocument(feed, courseNodeResourceContext);
indexer.addDocument(feedNodeDoc.getLuceneDocument());
// Only index items. FeedImpl itself is indexed by RepositoryEntryIndexer.
for (Item item : publishedItems) {
OlatDocument itemDoc = new FeedItemDocument(item, courseNodeResourceContext);
indexer.addDocument(itemDoc.getLuceneDocument());
}
} catch (NullPointerException e) {
log.error("Error indexing feed:" + repoEntryName, e);
}
}
}
use of org.olat.modules.webFeed.Item in project OpenOLAT by OpenOLAT.
the class FeedFileStorgeTest method loadItemsFromXML_shortening.
@Test
public void loadItemsFromXML_shortening() {
StringBuffer sb = new StringBuffer(5000);
for (int i = 0; i < 5000; i++) {
sb.append("A");
}
String stringWith5000Chars = sb.toString();
BlogFileResource resource = new BlogFileResource();
Feed feed = new FeedImpl(resource);
Item item = new ItemImpl(feed);
String guid1 = "guid 1";
item.setGuid(guid1);
item.setAuthor(stringWith5000Chars);
item.setExternalLink(stringWith5000Chars);
item.setTitle(stringWith5000Chars);
sut.saveItemAsXML(item);
List<Item> items = sut.loadItemsFromXML(feed);
Item reloadedItem = items.get(0);
assertThat(reloadedItem.getAuthor()).hasSize(255);
assertThat(reloadedItem.getExternalLink()).isNull();
assertThat(reloadedItem.getTitle()).hasSize(1024);
fileResourceManager.deleteFileResource(resource);
}
Aggregations