if (bmark.getTags() == null) {
bmark.setTags("");
}
User user = bmark.getUser();
Link link = bmark.getLink();
// we assume the user already exists in the DB
// if it doesn't exist, an exception will be thrown
GnizrDaoUtil.fillId(userDao, user);
// if no link.id is specified, check if it already exists
// by lookup a link record of the specified URL
if (GnizrDaoUtil.hasMissingId(link) == true) {
link = GnizrDaoUtil.getLink(linkDao, link.getUrl());
// if doesn't already exists, create a new link based
// the information defined in the bookmark
if (link == null) {
link = new Link();
int linkId = createNewLinkFromBookmark(bmark);
if (linkId > 0) {
// if a new link is created successfully,
// fetch the link object
link = linkDao.getLink(linkId);
}
}
bmark.setLink(link);
}else{
link = linkDao.getLink(link.getId());
bmark.setLink(link);
}
// if no date properties set, we will set them as of now.
if (bmark.getCreatedOn() == null) {
bmark.setCreatedOn(GnizrDaoUtil.getNow());