protected String getUriTrailer() { return getType().hasChildren() ? "/" : ""; }
protected void ensureFileHasContent(final FileObject file) throws FileSystemException { assert file != null; if (!file.getType().hasContent()) { FileObjects.close(file); throw new ResultNotification("File has no content: " + file.getName(), Result.FAILURE); } }
/** * Returns a read-only map of this file's attributes. */ public Map getAttributes() throws FileSystemException { if (!file.getType().hasAttributes()) { throw new FileSystemException("vfs.provider/get-attributes-no-exist.error", file); } if (roAttrs == null) { try { attrs = file.doGetAttributes(); roAttrs = Collections.unmodifiableMap(attrs); } catch (final Exception e) { throw new FileSystemException("vfs.provider/get-attributes.error", file, e); } } return roAttrs; }
msg.append(file.getType().getName()); msg.append(")"); if (file.getType().hasContent()) if (file.getType().hasChildren())
if (srcFile.getType().hasContent()) else if (srcFile.getType().hasChildren())
if (((destFile.getType().hasContent() && destFile.getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FILE)) || (destFile.getType().hasChildren() && destFile.getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FOLDER))) && getFileSystem().hasCapability(Capability.GET_LAST_MODIFIED))
public static boolean hasChildren(final FileObject file) throws FileSystemException { assert file != null; if (file.getType().hasChildren()) { FileObject[] children = file.getChildren(); if (children != null && children.length != 0) { return true; } } return false; }
protected void ensureFileHasContent(final FileObject file) throws FileSystemException { assert file != null; if (!file.getType().hasContent()) { FileObjects.close(file); throw new ResultNotification("File has no content: " + file.getName(), Result.FAILURE); } }
/** * Sets the value of an attribute. */ public void setAttribute(final String attrName, final Object value) throws FileSystemException { if (!file.getType().hasAttributes()) { throw new FileSystemException("vfs.provider/set-attribute-no-exist.error", new Object[]{attrName, file}); } try { file.doSetAttribute(attrName, value); } catch (final Exception e) { throw new FileSystemException("vfs.provider/set-attribute.error", new Object[]{attrName, file}, e); } if (attrs != null) { attrs.put(attrName, value); } }
public static boolean hasChildren(final FileObject file) throws FileSystemException { assert file != null; if (file.getType().hasChildren()) { FileObject[] children = file.getChildren(); if (children != null && children.length != 0) { return true; } } return false; }
protected void ensureFileHasContent(final FileObject file) throws FileSystemException { assert file != null; if (!file.getType().hasContent()) { FileObjects.close(file); throw new ResultNotification("File has no content: " + file.getName(), Result.FAILURE); } } }
/** * Returns the last-modified timestamp. */ public long getLastModifiedTime() throws FileSystemException { /* if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS) { throw new FileSystemException("vfs.provider/get-last-modified-writing.error", file); } */ if (!file.getType().hasAttributes()) { throw new FileSystemException("vfs.provider/get-last-modified-no-exist.error", file); } try { return file.doGetLastModifiedTime(); } catch (final Exception e) { throw new FileSystemException("vfs.provider/get-last-modified.error", file, e); } }
public static boolean hasChildren(final FileObject file) throws FileSystemException { assert file != null; if (file.getType().hasChildren()) { FileObject[] children = file.getChildren(); if (children != null && children.length != 0) { return true; } } return false; }
/** * Returns the size of the content (in bytes). */ public long getSize() throws FileSystemException { // Do some checking if (!file.getType().hasContent()) { throw new FileSystemException("vfs.provider/get-size-not-file.error", file); } /* if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS) { throw new FileSystemException("vfs.provider/get-size-write.error", file); } */ try { // Get the size return file.doGetContentSize(); } catch (final Exception exc) { throw new FileSystemException("vfs.provider/get-size.error", new Object[]{file}, exc); } }
/** * Sets the last-modified timestamp. */ public void setLastModifiedTime(final long modTime) throws FileSystemException { /* if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS) { throw new FileSystemException("vfs.provider/set-last-modified-writing.error", file); } */ if (!file.getType().hasAttributes()) { throw new FileSystemException("vfs.provider/set-last-modified-no-exist.error", file); } try { file.doSetLastModifiedTime(modTime); } catch (final Exception e) { throw new FileSystemException("vfs.provider/set-last-modified.error", file, e); } }
private void resetChildrenList() { try { if (this.file.getType().hasChildren()) { this.children = new HashMap(); FileObject[] childrenList = this.file.getChildren(); for (int i = 0; i < childrenList.length; i++) { this.children.put(childrenList[i].getName(), new Object()); // null? } } } catch (FileSystemException fse) { this.children = null; } }
return Result.FAILURE; else if (!file.getType().hasContent()) { io.error("File has no content: {}", file.getName()); return Result.FAILURE;
public void setCurrentDirectory(final Variables vars, final FileObject dir) throws FileSystemException { assert vars != null; assert dir != null; log.trace("Setting CWD: {}", dir); // Make sure that the given file object exists and is really a directory if (!dir.exists()) { throw new RuntimeException("Directory not found: " + dir.getName()); } else if (!dir.getType().hasChildren()) { throw new RuntimeException("File can not contain children: " + dir.getName()); } vars.parent().set(CWD, dir); }
/** * Returns an input stream to use to read the content of the file. */ public InputStream getInputStream() throws FileSystemException { if (!getType().hasContent()) { throw new FileSystemException("vfs.provider/read-not-file.error", name); } if (!isReadable()) { throw new FileSystemException("vfs.provider/read-not-readable.error", name); } // Get the raw input stream try { return doGetInputStream(); } catch (final Exception exc) { throw new FileSystemException("vfs.provider/read.error", name, exc); } }
public void setCurrentDirectory(final Variables vars, final FileObject dir) throws FileSystemException { assert vars != null; assert dir != null; log.trace("Setting CWD: {}", dir); // Make sure that the given file object exists and is really a directory if (!dir.exists()) { throw new RuntimeException("Directory not found: " + dir.getName()); } else if (!dir.getType().hasChildren()) { throw new RuntimeException("File can not contain children: " + dir.getName()); } vars.parent().set(CWD, dir); }