com.perforce.p4java.impl.mapbased.rpc.sys.helper
Class RpcSystemFileCommandsHelper

java.lang.Object
  extended by com.perforce.p4java.impl.mapbased.rpc.sys.helper.SymbolicLinkHelper
      extended by com.perforce.p4java.impl.mapbased.rpc.sys.helper.RpcSystemFileCommandsHelper
All Implemented Interfaces:
ISystemFileCommandsHelper

public class RpcSystemFileCommandsHelper
extends SymbolicLinkHelper
implements ISystemFileCommandsHelper

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.


Field Summary
static String IMPL_CLASS_NAME
           
 
Fields inherited from class com.perforce.p4java.impl.mapbased.rpc.sys.helper.SymbolicLinkHelper
COPY_OPTION_CLASS_NAME, FILE_ATTRIBUTE_CLASS_NAME, FILE_SYSTEM_CLASS_NAME, FILE_SYSTEM_GET_PATH_METHOD_NAME, FILE_SYSTEMS_CLASS_NAME, FILE_SYSTEMS_GET_DEFAULT_METHOD_NAME, FILE_TIME_CLASS_NAME, FILE_TIME_PATTERN, FILE_TIME_TO_MILLIS_METHOD_NAME, FILES_CLASS_NAME, FILES_CREATE_SYMBOLIC_LINK_METHOD_NAME, FILES_EXISTS_METHOD_NAME, FILES_GET_LAST_MODIFIED_TIME_METHOD_NAME, FILES_IS_SYMBOLIC_LINK_METHOD_NAME, FILES_MOVE_METHOD_NAME, FILES_READ_SYMBOLIC_LINK_METHOD_NAME, LINK_OPTION_CLASS_NAME, PATH_CLASS_NAME
 
Constructor Summary
RpcSystemFileCommandsHelper()
           
 
Method Summary
 boolean canExecute(String fileName)
          Return true iff the file exists and is executable.
 boolean isSymlink(String fileName)
          Return true iff the file exists and is a symbolic link.
 boolean setExecutable(String fileName, boolean executable, boolean ownerOnly)
          Set the file's permissions to allow or disallow it to be executed.
 boolean setOwnerReadOnly(String fileName)
          Set the file's read permissions only allow reading by owner.
 boolean setReadable(String fileName, boolean readable, boolean ownerOnly)
          Set the file's permissions to allow or disallow reading from it.
 boolean setWritable(String fileName, boolean writable)
          Set the file's permissions to allow or disallow writing to it.
 
Methods inherited from class com.perforce.p4java.impl.mapbased.rpc.sys.helper.SymbolicLinkHelper
createSymbolicLink, exists, getLastModifiedTime, isSymbolicLink, isSymbolicLinkCapable, move, readSymbolicLink
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IMPL_CLASS_NAME

public static final String IMPL_CLASS_NAME
See Also:
Constant Field Values
Constructor Detail

RpcSystemFileCommandsHelper

public RpcSystemFileCommandsHelper()
Method Detail

canExecute

public boolean canExecute(String fileName)
Description copied from interface: ISystemFileCommandsHelper
Return true iff the file exists and is executable.

Specified by:
canExecute in interface ISystemFileCommandsHelper
Parameters:
fileName - non-null path or name of the target file.
Returns:
true iff the file existed and is executable.
See Also:
ISystemFileCommandsHelper.canExecute(java.lang.String)

setExecutable

public boolean setExecutable(String fileName,
                             boolean executable,
                             boolean ownerOnly)
Description copied from interface: ISystemFileCommandsHelper
Set the file's permissions to allow or disallow it to be executed.

Specified by:
setExecutable in interface ISystemFileCommandsHelper
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.
See Also:
ISystemFileCommandsHelper.setExecutable(java.lang.String, boolean, boolean)

setWritable

public boolean setWritable(String fileName,
                           boolean writable)
Description copied from interface: ISystemFileCommandsHelper
Set the file's permissions to allow or disallow writing to it.

Specified by:
setWritable in interface ISystemFileCommandsHelper
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.
See Also:
ISystemFileCommandsHelper.setWritable(java.lang.String, boolean)

isSymlink

public boolean isSymlink(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.

Specified by:
isSymlink in interface ISystemFileCommandsHelper
Parameters:
fileName - non-null path or name of the target file.
Returns:
true iff the file exists and is a symbolic link.
See Also:
ISystemFileCommandsHelper.isSymlink(java.lang.String)

setReadable

public boolean setReadable(String fileName,
                           boolean readable,
                           boolean ownerOnly)
Description copied from interface: ISystemFileCommandsHelper
Set the file's permissions to allow or disallow reading from it.

Specified by:
setReadable in interface ISystemFileCommandsHelper
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.
See Also:
ISystemFileCommandsHelper.setReadable(java.lang.String, boolean, boolean)

setOwnerReadOnly

public boolean setOwnerReadOnly(String fileName)
Description copied from interface: ISystemFileCommandsHelper
Set the file's read permissions only allow reading by owner.

Specified by:
setOwnerReadOnly in interface ISystemFileCommandsHelper
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.
See Also:
ISystemFileCommandsHelper.setOwnerReadOnly(java.lang.String)


Copyright © 2015 Perforce Software. All Rights Reserved.