/** * Attaches to the file. * * @throws FileSystemException if an error occurs. */ private void attach() throws FileSystemException { synchronized (monitorLock) { if (isAttached()) { return; } try { // Attach and determine the file type doAttach(); setAttached(true); // now the type could already be injected by doAttach (e.g from parent to child) /* * VFS-210: determine the type when really asked fore if (type == null) { setFileType(doGetType()); } if * (type == null) { setFileType(FileType.IMAGINARY); } */ } catch (final Exception exc) { throw new FileSystemException("vfs.provider/get-type.error", exc, fileName); } // fs.fileAttached(this); } }
/** * Detaches this file, invalidating all cached info. This will force a call to {@link #doAttach} next time this file * is used. * * @throws Exception if an error occurs. */ private void detach() throws Exception { synchronized (monitorLock) { if (isAttached()) { try { doDetach(); } finally { setAttached(false); injectType(null); parent = null; // fs.fileDetached(this); removeChildrenCache(); // children = null; } } } }
/** * Called when this file is deleted. Updates cached info and notifies subclasses, parent and file system. * * @throws Exception if an error occurs. */ protected void handleDelete() throws Exception { synchronized (monitorLock) { if (isAttached()) { // Fix up state injectType(FileType.IMAGINARY); removeChildrenCache(); // Notify subclass onChange(); } // Notify parent that its child list may no longer be valid notifyParent(this.getName(), FileType.IMAGINARY); // Notify the file system fs.fireFileDeleted(this); } }
/** * Called when this file is created. Updates cached info and notifies the parent and file system. * * @param newType The type of the file. * @throws Exception if an error occurs. */ protected void handleCreate(final FileType newType) throws Exception { synchronized (monitorLock) { if (isAttached()) { // Fix up state injectType(newType); removeChildrenCache(); // Notify subclass onChange(); } // Notify parent that its child list may no longer be valid notifyParent(this.getName(), newType); // Notify the file system fs.fireFileCreated(this); } }