List of usage examples for org.apache.commons.vfs FileSystemException FileSystemException
public FileSystemException(final String code, final Object[] info, final Throwable throwable)
From source file:net.didion.loopy.vfs.provider.iso.IsoFileSystem.java
public void init() throws FileSystemException { super.init(); final File file = getParentLayer().getFileSystem().replicateFile(getParentLayer(), Selectors.SELECT_SELF); try {/*from www . j a va 2s.c o m*/ this.fileSystem = new ISO9660FileSystem(file, true); } catch (IOException ex) { throw new FileSystemException("vfs.provider.iso/open-iso-file.error", file, ex); } // Build the index final List strongRef = new ArrayList(100); final Enumeration entries = this.fileSystem.getEntries(); while (entries.hasMoreElements()) { final ISO9660FileEntry entry = (ISO9660FileEntry) entries.nextElement(); String name = entry.getPath(); // skip entries without names (should only be one - the root entry) if ("".equals(name)) { continue; } final FileName filename = getFileSystemManager().resolveName(getRootName(), UriParser.encode(name)); // Create the file IsoFileObject fileObj; if (entry.isDirectory() && getFileFromCache(filename) != null) { fileObj = (IsoFileObject) getFileFromCache(filename); fileObj.setIsoEntry(entry); continue; } fileObj = new IsoFileObject(filename, entry, this); putFileToCache(fileObj); strongRef.add(fileObj); fileObj.holdObject(strongRef); // Make sure all ancestors exist IsoFileObject parent; for (FileName parentName = filename .getParent(); parentName != null; fileObj = parent, parentName = parentName.getParent()) { // Locate the parent parent = (IsoFileObject) getFileFromCache(parentName); if (parent == null) { parent = new IsoFileObject(parentName, this); putFileToCache(parent); strongRef.add(parent); parent.holdObject(strongRef); } // Attach child to parent parent.attachChild(fileObj.getName()); } } }
From source file:com.github.stephenc.javaisotools.vfs.provider.iso.IsoFileSystem.java
public void init() throws FileSystemException { super.init(); final File file = getParentLayer().getFileSystem().replicateFile(getParentLayer(), Selectors.SELECT_SELF); try {/*from ww w .j av a 2s . c o m*/ this.fileSystem = new Iso9660FileSystem(file, true); } catch (IOException ex) { throw new FileSystemException("vfs.provider.iso/open-iso-file.error", file, ex); } // Build the index final List strongRef = new ArrayList(100); boolean skipRoot = false; for (Iso9660FileEntry entry : this.fileSystem) { String name = entry.getPath(); // skip entries without names (should only be one - the root entry) if ("".equals(name)) { if (!skipRoot) { skipRoot = true; } else { continue; } } final FileName filename = getFileSystemManager().resolveName(getRootName(), UriParser.encode(name)); // Create the file IsoFileObject fileObj; if (entry.isDirectory() && getFileFromCache(filename) != null) { fileObj = (IsoFileObject) getFileFromCache(filename); fileObj.setIsoEntry(entry); continue; } fileObj = new IsoFileObject(filename, entry, this); putFileToCache(fileObj); strongRef.add(fileObj); fileObj.holdObject(strongRef); // Make sure all ancestors exist IsoFileObject parent; for (FileName parentName = filename .getParent(); parentName != null; fileObj = parent, parentName = parentName.getParent()) { // Locate the parent parent = (IsoFileObject) getFileFromCache(parentName); if (parent == null) { parent = new IsoFileObject(parentName, this); putFileToCache(parent); strongRef.add(parent); parent.holdObject(strongRef); } // Attach child to parent parent.attachChild(fileObj.getName()); } } }
From source file:com.newatlanta.appengine.vfs.provider.GaeFileObject.java
public void endOutput() throws FileSystemException { try {/*from w w w . j a v a 2 s .c om*/ super.endOutput(); } catch (Exception e) { throw new FileSystemException("vfs.provider/close-outstr.error", this, e); } }
From source file:org.ofbiz.commons.vfs.ofbiz.OfbizComponentProvider.java
public FileObject findFile(FileObject base, String name, FileSystemOptions properties) throws FileSystemException { try {/* w ww . j av a2s . c o m*/ //name = name.replaceAll("^ofbiz-component://", ""); int nameLength = name.length(); int componentNameStart = 16; while (componentNameStart < nameLength && name.charAt(componentNameStart) == '/') componentNameStart++; if (componentNameStart == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")"); int componentNameEnd = componentNameStart; while (componentNameEnd < nameLength && name.charAt(componentNameEnd) != '/') componentNameEnd++; if (componentNameEnd == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")"); int restStart = componentNameEnd; while (restStart < nameLength && name.charAt(restStart) == '/') restStart++; if (restStart == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")"); String componentName = name.substring(componentNameStart, componentNameEnd); URL location = FlexibleLocation.resolveLocation("component://" + componentName + "/."); FileObject ofbizBase = getContext().resolveFile(location.toString(), properties); return VFSUtil.toFileObject(ofbizBase.getFileSystem().getFileSystemManager(), ofbizBase.resolveFile(name.substring(restStart)).getURL().toString(), properties); } catch (Exception e) { FileSystemException fse = new FileSystemException(e.getMessage(), null, e); fse.initCause(e); throw fse; } }
From source file:org.ofbiz.commons.vfs.ofbiz.OfbizHomeProvider.java
public FileObject findFile(FileObject base, String name, FileSystemOptions properties) throws FileSystemException { //new Exception("findFile(" + base + ", " + name + ")").printStackTrace(); try {//from w ww.jav a 2s.c o m URL location = FlexibleLocation.resolveLocation("ofbizhome://."); FileObject ofbizBase = getContext().resolveFile(location.toString(), properties); return VFSUtil.toFileObject(ofbizBase.getFileSystem().getFileSystemManager(), ofbizBase.resolveFile(name.substring(13)).getURL().toString(), properties); } catch (Exception e) { FileSystemException fse = new FileSystemException(e.getMessage(), null, e); fse.initCause(e); throw fse; } }