@Override public boolean addAll(java.util.Collection<? extends Host> c) { final List<Host> temporary = new ArrayList<Host>(); for(Host host : c) { if(temporary.contains(host)) { log.warn(String.format("Reset UUID of duplicate in collection for %s", host)); host.setUuid(null); } temporary.add(host); } return super.addAll(temporary); }
@Override public void collectionItemRemoved(final Host bookmark) { try { preferences.deleteProperty(String.format("%s%s", prefix, bookmark.getUuid())); } finally { super.collectionItemRemoved(bookmark); } }
@Override public void collectionItemRemoved(final Host bookmark) { try { this.lock(); final Local file = this.getFile(bookmark); file.delete(); } catch(AccessDeniedException | NotfoundException e) { log.error(String.format("Failure removing bookmark %s", e.getMessage())); } finally { this.unlock(); super.collectionItemRemoved(bookmark); } }
protected void save(final Host bookmark) { if(this.isLocked()) { log.debug(String.format("Skip saving bookmark %s while loading", bookmark)); } else { this.lock(); try { if(!folder.exists()) { new DefaultLocalDirectoryFeature().mkdir(folder); } final Local f = this.getFile(bookmark); if(log.isInfoEnabled()) { log.info(String.format("Save bookmark %s", f)); } writer.write(bookmark, f); } catch(AccessDeniedException e) { log.warn(String.format("Failure saving item in collection %s", e.getMessage())); } finally { this.unlock(); } } }
@Override public void collectionItemAdded(final Host bookmark) { this.save(bookmark); super.collectionItemAdded(bookmark); }
/** * Does not allow duplicate entries. * * @param row Row number * @param bookmark Bookmark */ @Override public void add(final int row, final Host bookmark) { if(this.contains(bookmark)) { this.remove(bookmark); } super.add(row, bookmark); }
@Override public void collectionItemAdded(final Host bookmark) { try { if(this.isLocked()) { log.debug("Skip indexing collection while loading"); } else { this.index(); } } finally { super.collectionItemAdded(bookmark); } }
/** * Importer for legacy bookmarks. * * @param c Existing collection */ @Override protected void load(final Collection<Host> c) { super.load(c); // Create index for imported collection this.index(); this.sort(); for(Host bookmark : this) { this.save(bookmark); } this.collectionLoaded(); }
@Override public void collectionItemChanged(final Host bookmark) { this.save(bookmark); super.collectionItemChanged(bookmark); }
/** * Does not allow duplicate entries. * * @param bookmark Bookmark * @return Always true */ @Override public boolean add(final Host bookmark) { if(this.contains(bookmark)) { this.remove(bookmark); } return super.add(bookmark); }