@Override public Void run() { for(ThirdpartyBookmarkCollection t : collections) { if(!t.isInstalled()) { if(log.isInfoEnabled()) { log.info(String.format("No application installed for %s", t.getBundleIdentifier())); } continue; } try { t.load(); } catch(AccessDeniedException e) { log.warn(String.format("Failure %s loading bookmarks from %s", e, t)); } if(t.isEmpty()) { // Flag as imported preferences.setProperty(t.getConfiguration(), true); } } try { lock.await(); } catch(InterruptedException e) { log.error(String.format("Error awaiting bookmarks to load %s", e.getMessage())); } return null; }
public boolean isInstalled() { return StringUtils.isNotBlank(this.getName()); }
@Override public String toString() { final StringBuilder sb = new StringBuilder("ThirdpartyBookmarkCollection{"); sb.append("file=").append(this.getFile()); sb.append('}'); return sb.toString(); } }
@Override public void cleanup() { for(ThirdpartyBookmarkCollection t : collections) { t.filter(bookmarks); if(t.isEmpty()) { preferences.setProperty(t.getConfiguration(), true); continue; } final NSAlert alert = NSAlert.alert( MessageFormat.format(LocaleFactory.localizedString("Import {0} Bookmarks", "Configuration"), t.getName()), MessageFormat.format(LocaleFactory.localizedString("{0} bookmarks found. Do you want to add these to your bookmarks?", "Configuration"), t.size()), LocaleFactory.localizedString("Import", "Configuration"), //default null, //other LocaleFactory.localizedString("Cancel", "Configuration")); alert.setShowsSuppressionButton(true); alert.suppressionButton().setTitle(LocaleFactory.localizedString("Don't ask again", "Configuration")); alert.setAlertStyle(NSAlert.NSInformationalAlertStyle); int choice = new AlertSheetReturnCodeMapper().getOption(alert.runModal()); //alternate if(alert.suppressionButton().state() == NSCell.NSOnState) { // Never show again. preferences.setProperty(t.getConfiguration(), true); } if(choice == SheetCallback.DEFAULT_OPTION) { bookmarks.addAll(t); // Flag as imported preferences.setProperty(t.getConfiguration(), true); } } } }
@Override public void load() throws AccessDeniedException { final Local file = this.getFile(); if(file.exists()) { if(log.isInfoEnabled()) { log.warn(String.format("Failure obtaining checksum for %s", file)); if(preferences.getBoolean(this.getConfiguration())) { preferences.getProperty(String.format("%s.checksum", this.getConfiguration()))); if(log.isDebugEnabled()) { log.debug(String.format("Saved previous checksum %s for bookmark %s", previous, file)); this.parse(ProtocolFactory.get(), file); preferences.setProperty(String.format("%s.checksum", this.getConfiguration()), current.hash);
public String getConfiguration() { return String.format("bookmark.import.%s", this.getBundleIdentifier()); }
@Override public boolean add(final Host bookmark) { if(!StringUtils.equals(bookmark.getHostname(), PreferencesFactory.get().getProperty("connection.hostname.default"))) { return super.add(bookmark); } return false; } }
/** * Remove all that are contained within the collection passed */ public void filter(final AbstractHostCollection bookmarks) { for(Iterator<Host> iter = this.iterator(); iter.hasNext(); ) { final Host i = iter.next(); if(bookmarks.find(i)) { if(log.isInfoEnabled()) { log.info(String.format("Remove %s from import as we found it in bookmarks", i)); } iter.remove(); } } }
@Override public boolean add(Host bookmark) { if(bookmark == null) { return false; } if(bookmark.getHostname().equals( PreferencesFactory.get().getProperty("connection.hostname.default"))) { return false; } return super.add(bookmark); } }
this.getName())); bookmark.setComment(comment.toString()); if(log.isDebugEnabled()) {