}
}
protected SyndFeed getFeed(HttpServletRequest req,String id,int numOfChanges,String feedId,ResourceBundle rb) //throws IOException, FeedException
{
SyndFeed feed = new SyndFeedImpl();
//determine the directory uri
//String servAddr =
StringBuilder sb = new StringBuilder();
//sb.append(SscfAjax.getServiceAddr(req)).append("/directory/").append(id);
//id is now the whole uri
String resUri = id;
XfoafSscfResource xfsr = XfoafSscfResource.getXfoafSscfResource(resUri);
if(xfsr!=null)
{
sb.setLength(0);
String labelOfFeed = xfsr.getLabel();
int type = 0; //1 for user feed;
System.out.println(resUri);
//in case we have top-level - user feed
if(xfsr.getId().length()<=8)
{
Person p = PersonFactory.findPerson(resUri);
if(p!=null) {
System.out.println(p.getName());
labelOfFeed = p.getName();
type = 1;
}
}
feed.setTitle(getFeedTitle(labelOfFeed, req.getLocalName(), rb, type));
//TODO: - resUri may point to different server/system
feed.setLink(resUri);
feed.setDescription(getFeedTitle(labelOfFeed, req.getLocalName(), rb, type)); //TODO
//get the changes
ChangelogDbHandler cdh = ChangelogDbHandler.getInstance();
List<ChangeBean> changes = new ArrayList<ChangeBean>();
List<SyndEntry> entries = new ArrayList<SyndEntry>();
if(cdh!=null)
{
changes = cdh.getLastChanges(resUri, numOfChanges);
}
for(ChangeBean change:changes)
{
SyndEntry entry;
SyndContent description;
entry = new SyndEntryImpl();
XfoafSscfResource changeRes = null;
XfoafSscfResource changedRes = null;
changedRes = XfoafSscfResource.getXfoafSscfResource(change.getChangedUri());
if((change.getChangeType()==ChangeTypes.ADDED.getChangeType()
||change.getChangeType()==ChangeTypes.REMOVED.getChangeType())
&&change.getChangeUri()!=null)
{
changeRes = XfoafSscfResource.getXfoafSscfResource(change.getChangeUri());
}
entry.setTitle(ChangeContent.getTitle(change.getChangeType(), change.getDepth(),rb,changeRes));
//TODO: generate unique link
StringBuilder changeUri = new StringBuilder();
changeUri.append(SscfAjax.getServiceAddr(req)).append('/').append(CH_DISP_SERVLET).append('/')
.append(feedId).append('/').append(change.getId()).append("-").append(change.getDepth());
entry.setLink(changeUri.toString());
entry.setPublishedDate(change.getTimestamp());
description = new SyndContentImpl();
description.setType("text/html");
description.setValue(ChangeContent.getMessage(change.getChangeType(), change.getDepth(),
change.getChangeValue(), labelOfFeed, change.getChangedUri(),changedRes,changeRes,rb));
entry.setDescription(description);
entries.add(entry);
}
feed.setEntries(entries);
}
return feed;
}