Class RpcSystemFileCommandsHelper

  • All Implemented Interfaces:
    ISystemFileCommandsHelper

    public class RpcSystemFileCommandsHelper
    extends SymbolicLinkHelper
    Default JDK 6 implementation of the ISystemFileCommandsHelper interface. Uses introspection so it can be compiled (if not actually work) on JDK 5 systems. Actual use of this on JDK 5 systems is OK to the extent that things like edit or sync may end up with the wrong permissions on the client, but much else will work just fine.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canExecute​(java.lang.String fileName)
      Return true iff the file exists and is executable.
      boolean isSymlink​(java.lang.String fileName)
      Return true iff the file exists and is a symbolic link.
      boolean setExecutable​(java.lang.String fileName, boolean executable, boolean ownerOnly)
      Set the file's permissions to allow or disallow it to be executed.
      boolean setOwnerReadOnly​(java.lang.String fileName)
      Set the file's read permissions only allow reading by owner.
      boolean setReadable​(java.lang.String fileName, boolean readable, boolean ownerOnly)
      Set the file's permissions to allow or disallow reading from it.
      boolean setWritable​(java.lang.String fileName, boolean writable)
      Set the file's permissions to allow or disallow writing to it.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RpcSystemFileCommandsHelper

        public RpcSystemFileCommandsHelper()
    • Method Detail

      • setWritable

        public boolean setWritable​(java.lang.String fileName,
                                   boolean writable)
        Description copied from interface: ISystemFileCommandsHelper
        Set the file's permissions to allow or disallow writing to it.
        Parameters:
        fileName - non-null path or name of the target file.
        writable - if true, allow the file to be written to; if false, set the file read-only (or, more accurately, not writable).
        Returns:
        true iff the set permission operation succeeded. May return false if the file didn't exist or the operation failed or an exception was caught, etc.
      • setReadable

        public boolean setReadable​(java.lang.String fileName,
                                   boolean readable,
                                   boolean ownerOnly)
        Description copied from interface: ISystemFileCommandsHelper
        Set the file's permissions to allow or disallow reading from it.
        Parameters:
        fileName - non-null path or name of the target file. set the file read-only.
        readable - if true, allow the file to be read; if false, set the file to not be readable
        ownerOnly - true to only set the read-only bit for the owner
        Returns:
        true iff the set permission operation succeeded. May return false if the file didn't exist or the operation failed or an exception was caught, etc.
      • setOwnerReadOnly

        public boolean setOwnerReadOnly​(java.lang.String fileName)
        Description copied from interface: ISystemFileCommandsHelper
        Set the file's read permissions only allow reading by owner.
        Parameters:
        fileName - non-null path or name of the target file. set the file read-only.
        Returns:
        true iff the set permission operation succeeded. May return false if the file didn't exist or the operation failed or an exception was caught, etc.
      • setExecutable

        public boolean setExecutable​(java.lang.String fileName,
                                     boolean executable,
                                     boolean ownerOnly)
        Description copied from interface: ISystemFileCommandsHelper
        Set the file's permissions to allow or disallow it to be executed.
        Parameters:
        fileName - non-null path or name of the target file.
        executable - if true, allow the file to be executed; if false, set the file not executable.
        ownerOnly - true to only set the executable bit for the owner
        Returns:
        true iff the set permission operation succeeded. May return false if the file didn't exist or the operation failed or an exception was caught, etc.
      • canExecute

        public boolean canExecute​(java.lang.String fileName)
        Description copied from interface: ISystemFileCommandsHelper
        Return true iff the file exists and is executable.
        Parameters:
        fileName - non-null path or name of the target file.
        Returns:
        true iff the file existed and is executable.
      • isSymlink

        public boolean isSymlink​(java.lang.String fileName)
        Description copied from interface: ISystemFileCommandsHelper
        Return true iff the file exists and is a symbolic link.

        This method is guaranteed to only be called when we suspect a specific file may be a symbolic link (i.e. we've exhausted other possibilities) and it is safe for this method to return false if it can't implement the associated plumbing or it simply can't tell whether the file is a symlink or not.

        Parameters:
        fileName - non-null path or name of the target file.
        Returns:
        true iff the file exists and is a symbolic link.