use of org.apache.archiva.rss.RssFeedEntry 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 org.apache.archiva.rss.RssFeedEntry 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);
}
Aggregations