use of com.sun.syndication.feed.synd.SyndFeed in project jersey by jersey.
the class FeedEntriesAtomBodyWriter method writeTo.
@Override
public void writeTo(List<FeedEntry> entries, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {
List<SyndEntry> syndEntries = entries.parallelStream().map(entry -> {
SyndContent description = new SyndContentImpl();
description.setType(MediaType.TEXT_PLAIN);
description.setValue(entry.getDescription());
SyndEntry syndEntry = new SyndEntryImpl();
syndEntry.setTitle(entry.getTitle());
syndEntry.setLink(entry.getLink());
syndEntry.setPublishedDate(entry.getPublishDate());
syndEntry.setDescription(description);
return syndEntry;
}).collect(Collectors.toList());
SyndFeed feed = new SyndFeedImpl();
feed.setFeedType("atom_1.0");
feed.setTitle("Combined Feed");
feed.setDescription("Combined Feed created by a feed-combiner application");
feed.setPublishedDate(new Date());
feed.setEntries(syndEntries);
writeSyndFeed(entityStream, feed);
}
use of com.sun.syndication.feed.synd.SyndFeed in project camel by apache.
the class AggregateRssFeedStrategy method aggregate.
public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
if (oldExchange == null) {
return newExchange;
}
SyndFeed oldFeed = oldExchange.getIn().getBody(SyndFeed.class);
SyndFeed newFeed = newExchange.getIn().getBody(SyndFeed.class);
if (oldFeed != null && newFeed != null) {
List<SyndEntryImpl> oldEntries = CastUtils.cast(oldFeed.getEntries());
List<SyndEntryImpl> newEntries = CastUtils.cast(newFeed.getEntries());
List<SyndEntryImpl> mergedList = new ArrayList<SyndEntryImpl>(oldEntries.size() + newEntries.size());
mergedList.addAll(oldEntries);
mergedList.addAll(newEntries);
oldFeed.setEntries(mergedList);
} else {
log.debug("Could not merge exchanges. One body was null.");
}
return oldExchange;
}
use of com.sun.syndication.feed.synd.SyndFeed in project asterixdb by apache.
the class FetcherEventListenerImpl method fetchFeed.
@SuppressWarnings("unchecked")
private void fetchFeed() throws IllegalArgumentException, IOException, FeedException, FetcherException {
// Retrieve the feed.
// We will get a Feed Polled Event and then a
// Feed Retrieved event (assuming the feed is valid)
SyndFeed feed = fetcher.retrieveFeed(feedUrl);
if (modified) {
if (LOGGER.isInfoEnabled()) {
LOGGER.info(feedUrl + " retrieved");
LOGGER.info(feedUrl + " has a title: " + feed.getTitle() + " and contains " + feed.getEntries().size() + " entries.");
}
List<? extends SyndEntryImpl> fetchedFeeds = feed.getEntries();
rssFeedBuffer.addAll(fetchedFeeds);
}
}
use of com.sun.syndication.feed.synd.SyndFeed in project rhsm-qe by RedHatQE.
the class EventTests method assertTheNewConsumerFeed.
protected void assertTheNewConsumerFeed(String ownerKey, String consumerUuid, SyndFeed oldConsumerFeed, String[] newEventTitles) throws IllegalArgumentException, IOException, FeedException {
// assert the consumer feed...
SyndFeed newConsumerFeed = CandlepinTasks.getSyndFeedForConsumer(/*ownerKey,*/
consumerUuid, sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
Assert.assertEquals(newConsumerFeed.getTitle(), "Event feed for consumer " + consumerUuid);
assertFeedContainsNoUnknownEvents(newConsumerFeed);
log.info("Expecting the new feed for consumer (" + consumerUuid + ") to have grown by (" + newEventTitles.length + ") events:");
int e = 0;
for (String newEventTitle : newEventTitles) log.info(String.format(" Expecting entry[%d].title %s", e++, newEventTitle));
// Assert.assertEquals(newConsumerFeed.getEntries().size(), oldConsumerFeed_EntriesSize+newEventTitles.length, "The event feed for consumer "+consumerUuid+" has increased by "+newEventTitles.length+" entries.");
// if (oldConsumerFeed_EntriesSize+newEventTitles.length <= feedLimit) {
// Assert.assertEquals(newConsumerFeed.getEntries().size(), oldConsumerFeed_EntriesSize+newEventTitles.length, "The event feed for consumer "+consumerUuid+" has increased by "+newEventTitles.length+" entries.");
// } else {
// Assert.assertEquals(newConsumerFeed.getEntries().size(), feedLimit, "The event feed length for consumer '"+consumerUuid+"' has hit the max entry count as set by the Candlepin class AtomResource/ConsumerResource/OwnerResource hard-coded variable feedlimit.");
// }
Assert.assertEquals(getFeedGrowthCount(newConsumerFeed, oldConsumerFeed), newEventTitles.length, newEventTitles.length + " new event feed entries for consumer '" + consumerUuid + "' has been pushed onto the stack.");
int i = 0;
for (String newEventTitle : newEventTitles) {
String actualEventTitle = ((SyndEntryImpl) newConsumerFeed.getEntries().get(i)).getTitle();
Assert.assertEquals(actualEventTitle, newEventTitle, "The next (" + i + ") newest event feed entry for consumer " + consumerUuid + " is '" + newEventTitle + "'.");
i++;
}
}
use of com.sun.syndication.feed.synd.SyndFeed in project rhsm-qe by RedHatQE.
the class EventTests method testNegativeConsumerUserPassword.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21843", "RHEL7-51664" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.NEGATIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier3")
@Test(description = "subscription-manager: events: negative test for consumer user/password.", groups = { "Tier3Tests", "NegativeConsumerUserPassword_Test" }, dependsOnGroups = { "ConsumerCreated_Test" }, enabled = true)
@ImplementsNitrateTest(caseId = 50404)
public void testNegativeConsumerUserPassword() throws JSONException, Exception {
String authuser = "", authpwd = "";
ConsumerCert consumerCert = clienttasks.getCurrentConsumerCert();
String ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, consumerCert.consumerid);
try {
// enter the wrong user, correct passwd
authuser = sm_client1Username + getRandInt();
authpwd = sm_client1Password;
CandlepinTasks.getSyndFeedForConsumer(/*ownerKey,*/
consumerCert.consumerid, authuser, authpwd, sm_serverUrl);
Assert.fail("Expected the candlepin server request for a syndication feed to return an HTTP response code 401 Unauthorized due to invalid authorization credentials " + authuser + ":" + authpwd);
} catch (IOException e) {
Assert.assertContainsMatch(e.getMessage(), "HTTP response code: 401", "Atom feed is unauthorized when attempting to authorize with credentials " + authuser + ":" + authpwd);
}
try {
// enter the correct user, wrong passwd
authuser = sm_client1Username;
authpwd = sm_client1Password + getRandInt();
CandlepinTasks.getSyndFeedForConsumer(/*ownerKey,*/
consumerCert.consumerid, authuser, authpwd, sm_serverUrl);
Assert.fail("Expected the candlepin server request for a syndication feed to return an HTTP response code 401 Unauthorized due to invalid authorization credentials " + authuser + ":" + authpwd);
} catch (IOException e) {
Assert.assertContainsMatch(e.getMessage(), "HTTP response code: 401", "Atom feed is unauthorized when attempting to authorize with credentials " + authuser + ":" + authpwd);
}
try {
// enter the correct user, correct passwd for super admin atom
authuser = sm_client1Username;
authpwd = sm_client1Password;
CandlepinTasks.getSyndFeed(authuser, authpwd, sm_serverUrl);
Assert.fail("Expected the candlepin server request for a syndication feed to return an HTTP response code 401 Unauthorized due to invalid authorization credentials " + authuser + ":" + authpwd);
} catch (IOException e) {
Assert.assertContainsMatch(e.getMessage(), "HTTP response code: 403", "Atom feed is forbidden when attempting to authorize with credentials " + authuser + ":" + authpwd);
}
// finally assert success with valid credentials
authuser = sm_client1Username;
authpwd = sm_client1Password;
SyndFeed feed = CandlepinTasks.getSyndFeedForConsumer(/*ownerKey,*/
consumerCert.consumerid, authuser, authpwd, sm_serverUrl);
Assert.assertTrue(!feed.getEntries().isEmpty(), "Atom feed for consumer events is successful with valid credentials " + authuser + ":" + authpwd);
}
Aggregations