org.entityfs.cap.entityattrs.unix.util
Class ECUnixAttributesUtil

java.lang.Object
  extended by org.entityfs.cap.entityattrs.unix.util.ECUnixAttributesUtil

public final class ECUnixAttributesUtil
extends Object

This class contains static utility methods for working with the ECUnixAttributes capability.

Since:
1.0
Author:
Karl Gustafsson
In_jar:
entityfs-entity_attributes

Method Summary
static UnixAttributes getAttributes(EntityView ev)
          Get Unix attributes for an entity.
static ECUnixAttributes getCapability(EntityView ev)
          Get the ECUnixAttributes capability for an entity.
static long getCreationTime(EntityView ev)
          Get the creation time attribute.
static UidGid getUidGid(EntityView ev)
          Get the user and group id attributes for the entity.
static UnixEntityMode getUnixEntityMode(EntityView ev)
          Get the Unix entity permission mode for the entity.
static void setAttributes(EntityView ev, UnixAttributes attr)
          Set the Unix attributes for an entity.
static void setCreationTime(EntityView ev, long creationTime)
          Set the creation time attribute.
static void setGid(EntityView ev, int gid)
          Set the group id attribute for the entity.
static void setUid(EntityView ev, int uid)
          Set the user id attribute for the entity.
static void setUidGid(EntityView ev, UidGid ug)
          Set the user and group id attributes for the entity.
static void setUnixEntityMode(EntityView ev, int mode)
          Set the Unix entity permission mode for the entity.
static void setUnixEntityMode(EntityView ev, UnixEntityMode m)
          Set the Unix entity permission mode for the entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getCapability

public static ECUnixAttributes getCapability(EntityView ev)
                                      throws UnsupportedCapabilityException
Get the ECUnixAttributes capability for an entity.

Some capability implementations do not support entity attributes for all entities in a file system. Often, the root directory is not supported.

Parameters:
ev - The entity.
Returns:
The capability.
Throws:
UnsupportedCapabilityException - If the entity does not support the ECUnixAttributes capability.

getAttributes

public static UnixAttributes getAttributes(EntityView ev)
                                    throws UnsupportedCapabilityException
Get Unix attributes for an entity.

This method temporarily acquires a read lock on the entity's parent directory.

Parameters:
ev - The entity to get the attributes for.
Returns:
The Unix attributes for the entity.
Throws:
UnsupportedCapabilityException - If the entity does not support the ECUnixAttributes capability.
Permissions_required:
Execute access to the entity's parent directory.

setAttributes

public static void setAttributes(EntityView ev,
                                 UnixAttributes attr)
                          throws UnsupportedCapabilityException
Set the Unix attributes for an entity.

This method temporarily acquires a write lock on the entity's parent directory.

Parameters:
ev - The entity to set the attributes for.
attr - The attributes.
Throws:
UnsupportedCapabilityException - If the entity does not support the ECUnixAttributes capability.
Permissions_required:
Write and execute access to the entity's parent directory.

getCreationTime

public static long getCreationTime(EntityView ev)
                            throws UnsupportedCapabilityException,
                                   AccessDeniedException
Get the creation time attribute.

The entity's parent directory is temporarily locked for reading by this method.

Parameters:
ev - The entity to get the creation time for.
Returns:
The value of the creation time attribute.
Throws:
UnsupportedCapabilityException - If the entity does not support the ECUnixAttributes capability.
AccessDeniedException - If the client does not have read access to the entity's parent directory.
See Also:
setCreationTime(EntityView, long)
Permissions_required:
Execute access to the entity's parent directory.

setCreationTime

public static void setCreationTime(EntityView ev,
                                   long creationTime)
                            throws UnsupportedCapabilityException,
                                   AccessDeniedException,
                                   ReadOnlyException
Set the creation time attribute.

The entity's parent directory is temporarily locked for writing by this method.

Parameters:
ev - The entity to set the creation time for.
creationTime - The new value of the creation time attribute.
Throws:
UnsupportedCapabilityException - If the entity does not support the ECUnixAttributes capability.
AccessDeniedException - If the client does not have write access to the entity's parent directory.
ReadOnlyException - If the file system is read only.
See Also:
getCreationTime(EntityView)
Permissions_required:
Write and execute access to the entity's parent directory.

getUnixEntityMode

public static UnixEntityMode getUnixEntityMode(EntityView ev)
                                        throws UnsupportedCapabilityException,
                                               AccessDeniedException
Get the Unix entity permission mode for the entity.

The entity's parent directory is temporarily locked for reading by this method.

Parameters:
ev - The entity to get the Unix entity permission mode for.
Returns:
The Unix entity permission mode.
Throws:
UnsupportedCapabilityException - If the entity does not support the ECUnixAttributes capability.
AccessDeniedException - If the client does not have read access to the entity's parent directory.
See Also:
setUnixEntityMode(EntityView, int), setUnixEntityMode(EntityView, UnixEntityMode)
Permissions_required:
Execute access to the entity's parent directory.

setUnixEntityMode

public static void setUnixEntityMode(EntityView ev,
                                     UnixEntityMode m)
                              throws UnsupportedCapabilityException,
                                     AccessDeniedException,
                                     ReadOnlyException
Set the Unix entity permission mode for the entity.

The entity's parent directory is temporarily locked for writing by this method.

Parameters:
ev - The entity to set the Unix entity permission mode for.
m - The new Unix entity permission mode.
Throws:
UnsupportedCapabilityException - If the entity does not support the ECUnixAttributes capability.
AccessDeniedException - If the client does not have write access to the entity's parent directory.
ReadOnlyException - If the file system is read only.
See Also:
getUnixEntityMode(EntityView), setUnixEntityMode(EntityView, int)
Permissions_required:
Write and execute access to the entity's parent directory.

setUnixEntityMode

public static void setUnixEntityMode(EntityView ev,
                                     int mode)
                              throws UnsupportedCapabilityException,
                                     AccessDeniedException,
                                     ReadOnlyException
Set the Unix entity permission mode for the entity.

The entity's parent directory is temporarily locked for writing by this method.

Parameters:
ev - The entity to set the Unix entity permission mode for.
mode - Integer representation of the new Unix entity permission mode. See UnixEntityMode.
Throws:
UnsupportedCapabilityException - If the entity does not support the ECUnixAttributes capability.
AccessDeniedException - If the client does not have write access to the entity's parent directory.
ReadOnlyException - If the file system is read only.
See Also:
getUnixEntityMode(EntityView), setUnixEntityMode(EntityView, UnixEntityMode)
Permissions_required:
Write and execute access to the entity's parent directory.

getUidGid

public static UidGid getUidGid(EntityView ev)
                        throws UnsupportedCapabilityException,
                               AccessDeniedException
Get the user and group id attributes for the entity.

The entity's parent directory is temporarily locked for reading by this method.

Parameters:
ev - The entity to get the UID and GID for.
Returns:
The UID and GID attributes.
Throws:
UnsupportedCapabilityException - If the entity does not support the ECUnixAttributes capability.
AccessDeniedException - If the client does not have read access to the entity's parent directory.
See Also:
setUidGid(EntityView, UidGid), setUid(EntityView, int), setGid(EntityView, int)
Permissions_required:
Execute access to the entity's parent directory.

setUidGid

public static void setUidGid(EntityView ev,
                             UidGid ug)
                      throws UnsupportedCapabilityException,
                             AccessDeniedException,
                             ReadOnlyException
Set the user and group id attributes for the entity.

The entity's parent directory is temporarily locked for writing by this method.

Parameters:
ev - The entity to set the UID and GID attributes for.
ug - The new UID and GID values. The primary GID is used for the GID value.
Throws:
UnsupportedCapabilityException - If the entity does not support the ECUnixAttributes capability.
AccessDeniedException - If the client does not have write access to the entity's parent directory.
ReadOnlyException - If the file system is read only.
See Also:
getUidGid(EntityView), setUid(EntityView, int), setGid(EntityView, int)
Permissions_required:
Write and execute access to the entity's parent directory.

setUid

public static void setUid(EntityView ev,
                          int uid)
                   throws UnsupportedCapabilityException,
                          AccessDeniedException,
                          ReadOnlyException
Set the user id attribute for the entity.

The entity's parent directory is temporarily locked for writing by this method.

Parameters:
ev - The entity to set the UID attribute for.
uid - The new UID.
Throws:
UnsupportedCapabilityException - If the entity does not support the ECUnixAttributes capability.
AccessDeniedException - If the client does not have write access to the entity's parent directory.
ReadOnlyException - If the file system is read only.
See Also:
getUidGid(EntityView), setUidGid(EntityView, UidGid), setGid(EntityView, int)
Permissions_required:
Write and execute access to the entity's parent directory.

setGid

public static void setGid(EntityView ev,
                          int gid)
                   throws UnsupportedCapabilityException,
                          AccessDeniedException,
                          ReadOnlyException
Set the group id attribute for the entity.

The entity's parent directory is temporarily locked for writing by this method.

Parameters:
ev - The entity to set the GID attribute for.
gid - The new GID.
Throws:
UnsupportedCapabilityException - If the entity does not support the ECUnixAttributes capability.
AccessDeniedException - If the client does not have write access to the entity's parent directory.
ReadOnlyException - If the file system is read only.
See Also:
getUidGid(EntityView), setUidGid(EntityView, UidGid), setUid(EntityView, int)
Permissions_required:
Write and execute access to the entity's parent directory.