- throw new IllegalArgumentException(MessageManager.formatMessage(
- "exception.url_cannot_have_duplicate_id",
- names.elementAt(i)));
+ // don't allow duplicate key names as entries will be overwritten
+ if (unselurls.containsKey(link.getId())
+ || selurls.containsKey(link.getId()))
+ {
+ throw new IllegalArgumentException(MessageManager.formatMessage(
+ "exception.url_cannot_have_duplicate_id", link.getId()));
+ }
+ if (link.getIsSelected())
+ {
+ selurls.put(link.getId(), new UrlLink(link.getDescription(),
+ link.getUrl(), link.getDescription()));
+ }
+ else
+ {
+ unselurls.put(link.getId(), new UrlLink(link.getDescription(),
+ link.getUrl(), link.getDescription()));
+ }
+ // sort out primary and selected ids
+ if (link.getIsPrimary())
+ {
+ setPrimaryUrl(link.getId());
+ }