}
}
/* Update BookMark */
else if (entity instanceof IBookMark) {
IBookMark bookmark = (IBookMark) entity;
/* Check for changed Name */
if (!bookmark.getName().equals(fNameInput.getText())) {
bookmark.setName(fNameInput.getText());
entitiesToSave.add(bookmark);
}
/* Append "http" to Link if missing */
String uriAsString = fFeedInput.getText();
if (URIUtils.looksLikeLink(uriAsString)) {
if (!uriAsString.contains("://"))
uriAsString = "http://" + uriAsString;
}
/* Check for changed Feed */
if (!bookmark.getFeedLinkReference().getLink().toString().equals(uriAsString)) {
try {
DAOService daoService = Owl.getPersistenceService().getDAOService();
/* Create URL */
URI newFeedLink = new URI(uriAsString.trim());
fReloadRequired = true;
/* Try to load this Feed from the DB (might be existing already) */
FeedReference feedRef = daoService.getFeedDAO().loadReference(newFeedLink);
/* This is a new Feed, so create it! */
if (feedRef == null) {
IFeed feed = Owl.getModelFactory().createFeed(null, newFeedLink);
feed = DynamicDAO.save(feed);
}
/* Remember the old Reference */
FeedLinkReference oldFeedRef = bookmark.getFeedLinkReference();
/* Apply the new Reference */
bookmark.setFeedLinkReference(new FeedLinkReference(newFeedLink));
entitiesToSave.add(bookmark);
/* Check if the old reference can be deleted now */
if (daoService.getBookMarkDAO().loadAll(oldFeedRef).size() == 1)
DynamicDAO.delete(oldFeedRef.resolve());
/* Delete the Favicon since the feed has changed */
OwlUI.deleteImage(bookmark.getId());
}
/* Supplied Feed Link not valid */
catch (URISyntaxException e) {
fSite.select(this);