keyword = keywordsMap.get(key);
if (keyword == null) {
throw new InstanceNotFoundException("", null);
}
// If the keyword already exists is modified
KeywordWeight kw = keywordWeightsMap
.get(keyword.getKeywordId());
if (kw == null) {
throw new InstanceNotFoundException("", null);
}
if (kw.getUsers().contains(user)) {
if (!user.admin()) {
throw new DuplicateInstanceException(key,
KeywordWeight.class.getName());
}
}
weight = entry.getValue();
weight += kw.getWeight();
kw.setWeight(weight);
kw.addUser(user);
} catch (InstanceNotFoundException e) {
keyword = new Keyword(key);
weight = entry.getValue();
KeywordWeight kw = new KeywordWeight(weight, user, keyword);
KeywordWeightJournal kwj = new KeywordWeightJournal(kw, journal);
createKeywordWeightJournal(kwj);
}
}
}