public FolderWatcher ( final String... path ) { this.location = new Location ( path ); }
public Entry[] call () throws Exception { if ( this.folder == null ) { throw new NoSuchFolderException ( this.location.asArray () ); } return this.folder.list ( this.location.getPathStack () ); }
throw new NoSuchFolderException ( location.asArray () ); final Stack<String> pathStack = location.getPathStack (); sessionCommon.getData ().addPath ( tag, new Location ( location ) ); this.subscriberMap.put ( tag, sessionCommon ); sessionCommon.getData ().removePath ( new Location ( location ) ); this.subscriberMap.remove ( tag );
private void unsubscribePath ( final SessionCommon session, final Location location ) throws NoSuchFolderException { final Object tag = session.getData ().getTag ( new Location ( location ) ); if ( tag != null ) { session.getData ().removePath ( location ); synchronized ( this.subscriberMap ) { this.subscriberMap.remove ( tag ); } final Stack<String> pathStack = location.getPathStack (); getRootFolder ().unsubscribe ( pathStack, tag ); } }
@Override public void subscribeFolder ( final Location location ) throws NoConnectionException, OperationException { sendMessage ( new SubscribeFolder ( location.asList () ) ); }
public void setFolderListener ( final Location location, final FolderListener listener ) { logger.debug ( "Setting folder listener - location: {}, listener: {}", location, listener ); this.folderListeners.put ( location, listener ); final Folder folder = this.rootFolder.findFolder ( location.getPathStack (), false ); if ( folder != null ) { folder.setListener ( listener ); } }
@Override public void unsubscribe ( final Session session, final Location location ) throws NoSuchFolderException, InvalidSessionException { this.hive.validateSession ( session ); if ( getRootFolder () == null ) { logger.warn ( "Having a brower interface without root folder" ); throw new NoSuchFolderException ( location.asArray () ); } unsubscribePath ( (SessionCommon)session, location ); }
@Override public void unsubscribeFolder ( final Location location ) throws NoConnectionException, OperationException { sendMessage ( new UnsubscribeFolder ( location.asList () ) ); }
public void addEntry ( final Location location, final String name, final String itemId, final String description ) { final Folder folder = this.rootFolder.findFolder ( location.getPathStack (), true ); folder.addItemEntry ( name, itemId, description ); }
public FolderWatcher ( final String... path ) { this.location = new Location ( path ); }
protected void handleFolderChanged ( final Location location, final Collection<Entry> added, final Set<String> removed, final boolean full ) { sendMessage ( new FolderDataUpdate ( location.asList (), convertEntries ( added ), removed, full ) ); }
public void removeEntry ( final Location location, final String name ) { final Folder folder = this.rootFolder.findFolder ( location.getPathStack (), false ); if ( folder == null ) { return; } folder.removeItemEntry ( name ); }
public void addFolderListener ( final FolderListener listener, final Location location ) { synchronized ( this.folderListeners ) { if ( !this.folderListeners.containsKey ( location ) ) { this.folderListeners.put ( location, new FolderSyncController ( this.connection, new Location ( location ) ) ); } final FolderSyncController controller = this.folderListeners.get ( location ); controller.addListener ( listener ); } }
protected void handleFolderChanged ( final Location location, final Collection<Entry> added, final Set<String> removed, final boolean full ) { sendMessage ( new FolderDataUpdate ( location.asList (), convertEntries ( added ), removed, full ) ); }
public void addFolderListener ( final FolderListener listener, final Location location ) { synchronized ( this.folderListeners ) { if ( !this.folderListeners.containsKey ( location ) ) { this.folderListeners.put ( location, new FolderSyncController ( this.connection, new Location ( location ) ) ); } final FolderSyncController controller = this.folderListeners.get ( location ); controller.addListener ( listener ); } }
public synchronized NotifyFuture<Entry[]> browse ( final Location location ) { return new BrowseFuture ( this.executor, sendRequestMessage ( new BrowseFolder ( nextRequest (), location.asList () ) ) ); }
private void handleFolderDataUpdate ( final FolderDataUpdate message ) { final FolderListener listener = this.folderListeners.get ( new Location ( message.getLocation () ) ); if ( listener != null ) { this.executor.execute ( new Runnable () { @Override public void run () { listener.folderChanged ( convert ( message.getAddedOrModified () ), message.getRemoved (), message.isFull () ); } } ); } }
private void handelSubscribeFolder ( final SubscribeFolder message ) { try { this.service.getBrowser ().subscribe ( this.session, new Location ( message.getLocation () ) ); } catch ( final Exception e ) { logger.warn ( "Failed to subscribe", e ); } }
private void handelSubscribeFolder ( final SubscribeFolder message ) { try { this.service.getBrowser ().subscribe ( this.session, new Location ( message.getLocation () ) ); } catch ( final Exception e ) { logger.warn ( "Failed to subscribe", e ); } }
private void handelUnsubscribeFolder ( final UnsubscribeFolder message ) { try { this.service.getBrowser ().unsubscribe ( this.session, new Location ( message.getLocation () ) ); } catch ( final NoSuchFolderException e ) { logger.debug ( "Folder was already gone", e ); } catch ( final Exception e ) { logger.warn ( "Failed to unsubscribe", e ); } }