use of models.HistoricalEvent in project modules.playframework.org by playframework.
the class FeedCreationActor method onReceive.
@Override
public void onReceive(Object o) throws Exception {
List<HistoricalEvent> historicalEvents = HistoricalEvent.findMostRecent(10);
File feedDir = Play.application().getFile("public/feeds");
boolean directoryExists = feedDir.exists();
if (!directoryExists) {
directoryExists = feedDir.mkdir();
Logger.debug(String.format("Create feed directory [%s]", directoryExists ? "OK" : "Failed"));
}
if (directoryExists) {
for (Map.Entry<String, String> entry : feedDetails.entrySet()) {
createFeed(historicalEvents, entry.getKey(), feedDir, entry.getValue());
}
}
}
use of models.HistoricalEvent in project modules.playframework.org by playframework.
the class AbstractController method createHistoricalEvent.
public static void createHistoricalEvent(String category, String message) {
HistoricalEvent historicalEvent = new HistoricalEvent();
historicalEvent.creationDate = new Date();
historicalEvent.category = category;
historicalEvent.message = message;
ActorSystem actorSystem = Akka.system();
ActorRef actor = actorSystem.actorOf(new Props(HistoricalEventActor.class));
actor.tell(historicalEvent);
}
use of models.HistoricalEvent in project modules.playframework.org by playframework.
the class FeedCreationActor method createFeed.
private void createFeed(List<HistoricalEvent> historicalEvents, String feedType, File outputDirectory, String classifier) {
SyndFeed feed = new SyndFeedImpl();
feed.setFeedType(feedType);
feed.setTitle("Play! Modules");
feed.setLink("http://modules.playframework.org");
feed.setUri("http://modules.playframework.org");
feed.setPublishedDate(new Date());
feed.setDescription("The Play! Framework's module repository feed");
List<SyndEntry> entries = new ArrayList<SyndEntry>(historicalEvents.size());
for (HistoricalEvent historicalEvent : historicalEvents) {
SyndEntry entry = new SyndEntryImpl();
entry.setTitle(historicalEvent.category);
entry.setAuthor("Play framework modules");
entry.setPublishedDate(historicalEvent.creationDate);
// todo this will be the url of the module
entry.setLink("http://modules.playframework.org");
entry.setUri("mpo-he-" + historicalEvent.id);
SyndContent description = new SyndContentImpl();
description.setType("text/plain");
description.setValue(historicalEvent.message);
entry.setDescription(description);
entries.add(entry);
}
feed.setEntries(entries);
Writer writer = null;
try {
File outputFile = new File(outputDirectory, String.format("mpo.%s.xml", classifier));
writer = new FileWriter(outputFile);
SyndFeedOutput output = new SyndFeedOutput();
output.output(feed, writer);
writer.close();
} catch (IOException e) {
Logger.error(String.format("A problem occurred when generating the %s feed", classifier), e);
} catch (FeedException e) {
Logger.error(String.format("A problem occurred when generating the %s feed", classifier), e);
} finally {
IOUtils.close(writer);
}
}
Aggregations