use of com.sun.syndication.io.FeedException in project wildfly-camel by wildfly-extras.
the class RSSFeedServlet method doGet.
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
SyndFeed feed = new SyndFeedImpl();
feed.setFeedType("rss_2.0");
feed.setTitle("WildFly-Camel Test RSS Feed");
feed.setLink("http://localhost:8080/rss-tests");
feed.setDescription("Test RSS feed for the camel-rss component");
List<SyndEntry> entries = new ArrayList<>();
for (int i = 1; i <= 5; i++) {
entries.add(createFeedEntry("Test entry: ", "Test content: ", i));
}
feed.setEntries(entries);
SyndFeedOutput output = new SyndFeedOutput();
try {
output.output(feed, response.getWriter());
} catch (FeedException e) {
throw new IllegalStateException("Error generating RSS feed", e);
}
}
use of com.sun.syndication.io.FeedException in project archiva by apache.
the class NewArtifactsRssFeedProcessor method processNewArtifactsInRepo.
private SyndFeed processNewArtifactsInRepo(String repoId, MetadataRepository metadataRepository) throws FeedException {
Calendar greaterThanThisDate = Calendar.getInstance(GMT_TIME_ZONE);
greaterThanThisDate.add(Calendar.DATE, -(getNumberOfDaysBeforeNow()));
greaterThanThisDate.clear(Calendar.MILLISECOND);
List<ArtifactMetadata> artifacts;
try {
artifacts = metadataRepository.getArtifactsByDateRange(repoId, greaterThanThisDate.getTime(), null);
} catch (MetadataRepositoryException e) {
throw new FeedException("Unable to construct feed, metadata could not be retrieved: " + e.getMessage(), e);
}
long tmp = 0;
RssFeedEntry entry = null;
List<RssFeedEntry> entries = new ArrayList<>();
String description = "";
int idx = 0;
for (ArtifactMetadata artifact : artifacts) {
long whenGathered = artifact.getWhenGathered().getTime();
String id = artifact.getNamespace() + "/" + artifact.getProject() + "/" + artifact.getId();
if (tmp != whenGathered) {
if (entry != null) {
entry.setDescription(description);
entries.add(entry);
entry = null;
}
String repoId1 = artifact.getRepositoryId();
entry = new RssFeedEntry(this.getTitle() + "\'" + repoId1 + "\'" + " as of " + new Date(whenGathered));
entry.setPublishedDate(artifact.getWhenGathered());
description = this.getDescription() + "\'" + repoId1 + "\'" + ": \n" + id + " | ";
} else {
description = description + id + " | ";
}
if (idx == (artifacts.size() - 1)) {
entry.setDescription(description);
entries.add(entry);
}
tmp = whenGathered;
idx++;
}
return generator.generateFeed(getTitle() + "\'" + repoId + "\'", "New artifacts found in repository " + "\'" + repoId + "\'" + " during repository scan.", entries);
}
use of com.sun.syndication.io.FeedException in project archiva by apache.
the class NewVersionsOfArtifactRssFeedProcessor method processNewVersionsOfArtifact.
private SyndFeed processNewVersionsOfArtifact(String groupId, String artifactId, MetadataRepository metadataRepository) throws FeedException {
List<ArtifactMetadata> artifacts = new ArrayList<>();
try {
for (String repoId : metadataRepository.getRepositories()) {
Collection<String> versions = metadataRepository.getProjectVersions(repoId, groupId, artifactId);
for (String version : versions) {
artifacts.addAll(metadataRepository.getArtifacts(repoId, groupId, artifactId, version));
}
}
} catch (MetadataRepositoryException e) {
throw new FeedException("Unable to construct feed, metadata could not be retrieved: " + e.getMessage(), e);
} catch (MetadataResolutionException e) {
throw new FeedException("Unable to construct feed, metadata could not be retrieved: " + e.getMessage(), e);
}
long tmp = 0;
RssFeedEntry entry = null;
List<RssFeedEntry> entries = new ArrayList<>();
String description = "";
int idx = 0;
for (ArtifactMetadata artifact : artifacts) {
long whenGathered = artifact.getWhenGathered().getTime();
if (tmp != whenGathered) {
if (entry != null) {
entry.setDescription(description);
entries.add(entry);
entry = null;
}
entry = new RssFeedEntry(this.getTitle() + "\'" + groupId + ":" + artifactId + "\'" + " as of " + new Date(whenGathered));
entry.setPublishedDate(artifact.getWhenGathered());
description = this.getDescription() + "\'" + groupId + ":" + artifactId + "\'" + ": \n" + artifact.getId() + " | ";
} else {
description = description + artifact.getId() + " | ";
}
if (idx == (artifacts.size() - 1)) {
entry.setDescription(description);
entries.add(entry);
}
tmp = whenGathered;
idx++;
}
String key = groupId + ":" + artifactId;
return generator.generateFeed(getTitle() + "\'" + key + "\'", "New versions of artifact " + "\'" + key + "\' found during repository scan.", entries);
}
use of com.sun.syndication.io.FeedException in project ofbiz-framework by apache.
the class RomeEventHandler method invoke.
/**
* @see org.apache.ofbiz.webapp.event.EventHandler#invoke(ConfigXMLReader.Event, ConfigXMLReader.RequestMap, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public String invoke(Event event, RequestMap requestMap, HttpServletRequest request, HttpServletResponse response) throws EventHandlerException {
RequestHandler handler = (RequestHandler) request.getSession().getServletContext().getAttribute("_REQUEST_HANDLER_");
if (handler == null) {
throw new EventHandlerException("No request handler found in servlet context!");
}
// generate the main and entry links
String entryLinkReq = request.getParameter("entryLinkReq");
String mainLinkReq = request.getParameter("mainLinkReq");
// create the links; but the query string must be created by the service
String entryLink = handler.makeLink(request, response, entryLinkReq, true, false, false);
String mainLink = handler.makeLink(request, response, mainLinkReq, true, false, false);
request.setAttribute("entryLink", entryLink);
request.setAttribute("mainLink", mainLink);
String feedType = request.getParameter("feedType");
if (feedType == null) {
request.setAttribute("feedType", defaultFeedType);
}
// invoke the feed generator service (implements rssFeedInterface)
String respCode = service.invoke(event, requestMap, request, response);
// pull out the RSS feed from the request attributes
WireFeed wireFeed = (WireFeed) request.getAttribute("wireFeed");
response.setContentType(mime);
try {
out.output(wireFeed, response.getWriter());
} catch (IOException e) {
throw new EventHandlerException("Unable to get response writer", e);
} catch (FeedException e) {
throw new EventHandlerException("Unable to write RSS feed", e);
}
return respCode;
}
use of com.sun.syndication.io.FeedException in project eol-globi-data by jhpoelen.
the class StudyImporterForArthopodEasyCapture method getStudyImportersForRSSFeed.
public static List<StudyImporter> getStudyImportersForRSSFeed(Dataset datasetOrig, ParserFactory parserFactory, NodeFactory nodeFactory) throws StudyImporterException {
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed;
String rss = getRss(datasetOrig);
try {
feed = input.build(new XmlReader(new URL(rss)));
} catch (FeedException | IOException e) {
throw new StudyImporterException("failed to read rss feed [" + rss + "]", e);
}
List<StudyImporter> importers = new ArrayList<StudyImporter>();
final List entries = feed.getEntries();
for (Object entry : entries) {
if (entry instanceof SyndEntry) {
SyndEntry syndEntry = (SyndEntry) entry;
Dataset dataset = embeddedDatasetFor(datasetOrig, StringUtils.trim(syndEntry.getDescription().getValue()), URI.create(StringUtils.trim(syndEntry.getLink())));
final StudyImporterForSeltmann studyImporter = new StudyImporterForSeltmann(parserFactory, nodeFactory);
studyImporter.setDataset(dataset);
importers.add(studyImporter);
}
}
return importers;
}
Aggregations