org.entityfs.cap.entityattrs.ntfs.metadata
Class MetadataNtfsAttributesCapabilityProvider

java.lang.Object
  extended by org.entityfs.cap.entityattrs.ntfs.metadata.MetadataNtfsAttributesCapabilityProvider
All Implemented Interfaces:
CapabilityProvider, CapabilityProviderImplementation

public class MetadataNtfsAttributesCapabilityProvider
extends Object
implements CapabilityProviderImplementation

This capability provider makes the entities in the file system (except for the root directory) support the ECNtfsAttributes capability. The entity attributes for an entity are kept in a named metadata file called ntfsattrs.dat in its parent directory, so this capability requires that the file system supports some kind of ECNamedMetadata capability for its directories. The file system is also required to support the FSCRandomAccessFiles capability.

New entities are created with a set of default attributes created by an EntityType-specific factory object. See setDefaultAttributesFactories(Map).

The capability can try to set the ownership attributes (UID and GID) of new entities when they are created. If the thread creating an entity has a Subject that is an UidGidSubject, that Subject is set as the owner of the new entity, otherwise the entity is set to be owned by the default UID and GID (see setDefaultAttributesFactories(Map), setDefaultUid(int) and setDefaultGid(int)). Ownership setting is enabled by default, but can be disabled by calling setSetEntityOwnership(boolean).

When using this capability, make sure that the file system contents are not modified from anywhere else than through the file system and entity methods. If it is, that can leave this capability seriously confused about the file system state.

The capability implementation does not honor the read only NTFS attribute. Clients must implement their own support for that if they need it.

For generic information about EntityAttributes capabilities, see the ECEntityAttributes documentation.

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

Constructor Summary
MetadataNtfsAttributesCapabilityProvider()
           
 
Method Summary
 Map<EntityType,ObjectFactory<NtfsAttributes>> getDefaultAttributesFactories()
          Get (a copy of) the map containing default attributes factories for each entity type.
 int getDefaultGid()
          Get the GID to set on a new entity if the ownership attributes should be set on new entities and the GID of the current Subject cannot be determined.
 int getDefaultUid()
          Get the UID to set on a new entity if the ownership attributes should be set on new entities and the UID of the current Subject cannot be determined.
 boolean isReadOnlyFileSystemSupported()
           
 boolean isReadWriteFileSystemSupported()
           
 boolean isSetEntityOwnership()
          Are the ownership attributes (UID and GID) set on new entities?
 AdapterFactory proxyAdapterFactory(AdapterFactory af, LogAdapterHolder lah)
          This is called to let the capability provider proxy the file system's adapter factory before the file system is created.
 FileSystemDelegate proxyFileSystemDelegate(FileSystemDelegate fsd, SupportObjects so, boolean readOnly)
          This is used when creating the file system to let the capability provider proxy the file system delegate.
 DirectoryDelegate proxyRootDirectoryDelegate(FileSystemImplementation fs, FileSystemDelegate fsd, DirectoryDelegate dd, LogAdapterHolder lah)
          This is used when creating a file system to let the capability provider proxy the root directory delegate.
 MetadataNtfsAttributesCapabilityProvider setDefaultAttributesFactories(Map<EntityType,? extends ObjectFactory<NtfsAttributes>> m)
          Set the default NTFS attributes factories.
 MetadataNtfsAttributesCapabilityProvider setDefaultAttributesFactory(EntityType et, ObjectFactory<NtfsAttributes> f)
          Set the default NTFS attributes factory for the specified entity type.
 MetadataNtfsAttributesCapabilityProvider setDefaultGid(int gid)
          Set the default GID to set if the ownership attributes should be set on new entities and the GID of the current Subject cannot be determined.
 MetadataNtfsAttributesCapabilityProvider setDefaultUid(int uid)
          Set the default UID to set if the ownership attributes should be set on new entities and the UID of the current Subject cannot be determined.
 MetadataNtfsAttributesCapabilityProvider setSetEntityOwnership(boolean b)
          Should the ownership attributes (UID and GID) be set on new entities? This is enabled by default.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetadataNtfsAttributesCapabilityProvider

public MetadataNtfsAttributesCapabilityProvider()
Method Detail

setSetEntityOwnership

public MetadataNtfsAttributesCapabilityProvider setSetEntityOwnership(boolean b)
Should the ownership attributes (UID and GID) be set on new entities? This is enabled by default.

Parameters:
b - Should the ownership attributes be set on new entities?
Returns:
this.

isSetEntityOwnership

public boolean isSetEntityOwnership()
Are the ownership attributes (UID and GID) set on new entities?

Returns:
true if the ownership attributes are set on new entities.

setDefaultUid

public MetadataNtfsAttributesCapabilityProvider setDefaultUid(int uid)
                                                       throws IllegalArgumentException
Set the default UID to set if the ownership attributes should be set on new entities and the UID of the current Subject cannot be determined.

Any value set here takes precedence over whatever set by the default attributes factory.

Parameters:
uid - The default owner UID for new entities. This is an integer equal to or greater than zero.
Returns:
this
Throws:
IllegalArgumentException - If the UID is invalid.
See Also:
setDefaultAttributesFactories(Map), setSetEntityOwnership(boolean), setDefaultGid(int)

getDefaultUid

public int getDefaultUid()
Get the UID to set on a new entity if the ownership attributes should be set on new entities and the UID of the current Subject cannot be determined.

Returns:
The default UID.

setDefaultGid

public MetadataNtfsAttributesCapabilityProvider setDefaultGid(int gid)
                                                       throws IllegalArgumentException
Set the default GID to set if the ownership attributes should be set on new entities and the GID of the current Subject cannot be determined.

Any value set here takes precedence over whatever set by the default attributes factory.

Parameters:
gid - The default owner GID for new entities. This is an integer equal to or greater than zero.
Returns:
this
Throws:
IllegalArgumentException - If the GID is invalid.
See Also:
setDefaultAttributesFactories(Map), setSetEntityOwnership(boolean), setDefaultUid(int)

getDefaultGid

public int getDefaultGid()
Get the GID to set on a new entity if the ownership attributes should be set on new entities and the GID of the current Subject cannot be determined.

Returns:
The default GID.

setDefaultAttributesFactory

public MetadataNtfsAttributesCapabilityProvider setDefaultAttributesFactory(EntityType et,
                                                                            ObjectFactory<NtfsAttributes> f)
Set the default NTFS attributes factory for the specified entity type.

The default default attribute factory for files gives files the UnixEntityMode 0640. The factory for directories gives directories the UnixEntityMode 0750.

Parameters:
et - The entity type.
f - The default attributes factory.
Returns:
this
See Also:
setDefaultAttributesFactories(Map)

setDefaultAttributesFactories

public MetadataNtfsAttributesCapabilityProvider setDefaultAttributesFactories(Map<EntityType,? extends ObjectFactory<NtfsAttributes>> m)
Set the default NTFS attributes factories.

The default default attribute factory for files gives files the UnixEntityMode 0640. The factory for directories gives directories the UnixEntityMode 0750.

Any previously set default attributes factories are discarded.

Parameters:
m - The mapping between entity types and attribute factories. The map should at least contain keys for the ETFile and ETDirectory entity types.
Returns:
this
See Also:
setDefaultAttributesFactory(EntityType, ObjectFactory)

getDefaultAttributesFactories

public Map<EntityType,ObjectFactory<NtfsAttributes>> getDefaultAttributesFactories()
Get (a copy of) the map containing default attributes factories for each entity type.

Returns:
A copy of the map containing default attributes factories for each entity type.

proxyAdapterFactory

public AdapterFactory proxyAdapterFactory(AdapterFactory af,
                                          LogAdapterHolder lah)
Description copied from interface: CapabilityProviderImplementation
This is called to let the capability provider proxy the file system's adapter factory before the file system is created.

Specified by:
proxyAdapterFactory in interface CapabilityProviderImplementation
Parameters:
af - The adapter factory.
lah - The (future) file system's log adapter holder.
Returns:
The (future) file system's adapter factory, possibly proxied. If the adapter factory should not be proxied, return the supplied factory, never return null.

proxyFileSystemDelegate

public FileSystemDelegate proxyFileSystemDelegate(FileSystemDelegate fsd,
                                                  SupportObjects so,
                                                  boolean readOnly)
Description copied from interface: CapabilityProviderImplementation
This is used when creating the file system to let the capability provider proxy the file system delegate.

This method can check that all capabilities that the capability provider require in order to work are present in the FileSystemDelegate to proxy. If not, the method throws an FileSystemConfigurationException.

When this method is called, no owning FileSystemImplementation is created yet, so a call to FileSystemDelegate.getOwner() will return null.

Specified by:
proxyFileSystemDelegate in interface CapabilityProviderImplementation
Parameters:
fsd - The file system delegate to proxy.
so - The file system's support objects. Maybe useful for implementations of this method, maybe not.
readOnly - Is the file system read only?
Returns:
A file system delegate. Either a proxy of fsd or fsd itself. Never null.

proxyRootDirectoryDelegate

public DirectoryDelegate proxyRootDirectoryDelegate(FileSystemImplementation fs,
                                                    FileSystemDelegate fsd,
                                                    DirectoryDelegate dd,
                                                    LogAdapterHolder lah)
Description copied from interface: CapabilityProviderImplementation
This is used when creating a file system to let the capability provider proxy the root directory delegate. Most capability providers do this.

Specified by:
proxyRootDirectoryDelegate in interface CapabilityProviderImplementation
Parameters:
fs - The file system object.
fsd - The file system delegate created by CapabilityProviderImplementation.proxyFileSystemDelegate(FileSystemDelegate, SupportObjects, boolean) .
dd - The root directory delegate.
Returns:
A directory delegate. Either a proxy of dd or dd itself. Never null.

isReadOnlyFileSystemSupported

public boolean isReadOnlyFileSystemSupported()
Specified by:
isReadOnlyFileSystemSupported in interface CapabilityProviderImplementation
Returns:
true, always.

isReadWriteFileSystemSupported

public boolean isReadWriteFileSystemSupported()
Specified by:
isReadWriteFileSystemSupported in interface CapabilityProviderImplementation
Returns:
true, always.