org.entityfs.cap.entityattrs.impl.metadata
Class AttributesEnablingDirectoryDelegateProxy<T extends EntityAttributes>

java.lang.Object
  extended by org.entityfs.support.lang.ObjectProxySupport<T>
      extended by org.entityfs.impl.AbstractEntityDelegateProxy<DirectoryDelegate,DirectoryAdapter>
          extended by org.entityfs.impl.AbstractDirectoryDelegateProxy
              extended by org.entityfs.cap.entityattrs.impl.metadata.AttributesEnablingDirectoryDelegateProxy<T>
All Implemented Interfaces:
AttributesEntityDelegate<T>, DirectoryDelegate, EntityDelegate

public class AttributesEnablingDirectoryDelegateProxy<T extends EntityAttributes>
extends AbstractDirectoryDelegateProxy
implements AttributesEntityDelegate<T>


Constructor Summary
AttributesEnablingDirectoryDelegateProxy(DirectoryDelegate proxied, AbstractEntityAttributesEnablingFileSystemDelegate<T> fsd, ChildEntityAttributeManager<T> parentAttr, LogAdapterHolder lah)
           
 
Method Summary
 void assertParentIsReadLocked()
           
 void assertParentIsWriteLocked()
           
 void copyAttributes(DirectoryImplementation targetParent, EntityImplementation target)
          This implementation does not copy any attributes.
 Set<EntityView> copyFromEntity(EntityImplementation ent, String targetName, boolean preserveAttrs, List<EntityAttributeSetter> asl, EntityLock[] setupLocks)
          Remove all NTFS attribute metadata files for copied directories.
 EntityDelegate createChildDelegate(FileSystemImplementation fs, EntityType et, String name, Object data, boolean createInBackend)
          Instead of overriding this method, subclasses may elect to override createFileDelegateProxy(FileDelegate) and createDirectoryDelegateProxy(DirectoryDelegate, LogAdapterHolder) instead.
protected  AttributesEntityDelegate<T> createDirectoryDelegateProxy(DirectoryDelegate proxied, LogAdapterHolder lah)
          Create a new DirectoryDelegate proxy.
protected  AttributesEntityDelegate<T> createFileDelegateProxy(FileDelegate proxied)
          Create a new FileDelegate proxy.
 void delete(Collection<String> cetd)
          Delete the directory.
 T getAttributes()
          Get the entity attributes.
 Class<T> getAttributesType()
          Get the type of entity attributes provided by this delegate.
 ChildEntityAttributeManager<T> getChildAttributes()
          Get the attribute collection for this directory's child entities.
protected  AbstractEntityAttributesEnablingFileSystemDelegate<T> getFileSystemDelegate()
           
static
<T extends EntityAttributes>
DirectoryDelegate
proxyRootDirectoryDelegate(DirectoryDelegate dd, AbstractEntityAttributesEnablingFileSystemDelegate<T> fsd, LogAdapterHolder lah)
           
 void rename(String oldName, DirectoryImplementation targetDir, String newName)
          Rename and/or move the entity.
 void setAttributes(T attrs)
          Set (and save) the entity attributes.
 void setDefaultAttributes(String name, ObjectFactory<T> defaultAttributesFactory)
          This sets attributes from the default attributes factory on the new entity if the file system delegate has an EntityAttributesPreparer set.
 void setParentAttributes(ChildEntityAttributeManager<T> attr)
           
 
Methods inherited from class org.entityfs.impl.AbstractDirectoryDelegateProxy
containsEntity, createEntity, getEntityNames, getEntityType
 
Methods inherited from class org.entityfs.impl.AbstractEntityDelegateProxy
canRead, canWrite, copy, exists, getDelegateOfTypeOrNull, getEntityAdapter, getFileSystem, getLastModified, getName, getOwner, init, isReadOnly, setLastModified, setOwner
 
Methods inherited from class org.entityfs.support.lang.ObjectProxySupport
equals, getProxied, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.entityfs.impl.EntityDelegate
canRead, canWrite, copy, exists, getDelegateOfTypeOrNull, getEntityAdapter, getFileSystem, getLastModified, getName, getOwner, init, isReadOnly, setLastModified, setOwner
 

Constructor Detail

AttributesEnablingDirectoryDelegateProxy

public AttributesEnablingDirectoryDelegateProxy(DirectoryDelegate proxied,
                                                AbstractEntityAttributesEnablingFileSystemDelegate<T> fsd,
                                                ChildEntityAttributeManager<T> parentAttr,
                                                LogAdapterHolder lah)
Method Detail

getAttributesType

public Class<T> getAttributesType()
Description copied from interface: AttributesEntityDelegate
Get the type of entity attributes provided by this delegate.

Specified by:
getAttributesType in interface AttributesEntityDelegate<T extends EntityAttributes>
Returns:
The type of entity attributes provided.

setParentAttributes

public void setParentAttributes(ChildEntityAttributeManager<T> attr)

getChildAttributes

public ChildEntityAttributeManager<T> getChildAttributes()
Get the attribute collection for this directory's child entities. NTFS attribute delegates use this to get the new parent directory's child attribute collection when they are moved.

Returns:
The child attribute collection.

getFileSystemDelegate

protected AbstractEntityAttributesEnablingFileSystemDelegate<T> getFileSystemDelegate()

createFileDelegateProxy

protected AttributesEntityDelegate<T> createFileDelegateProxy(FileDelegate proxied)
Create a new FileDelegate proxy. This is called from createChildDelegate(FileSystemImplementation, EntityType, String, Object, boolean) .

This implementation creates an AttributesEnablingFileDelegateProxy instance. Subclasses may override this method if they want to create proxies of another type.

Parameters:
proxied - The FileDelegate to proxy.
Returns:
A AttributesEnablingFileDelegateProxy

createDirectoryDelegateProxy

protected AttributesEntityDelegate<T> createDirectoryDelegateProxy(DirectoryDelegate proxied,
                                                                   LogAdapterHolder lah)
Create a new DirectoryDelegate proxy. This is called from createChildDelegate(FileSystemImplementation, EntityType, String, Object, boolean) .

This implementation creates an AttributesEnablingDirectoryDelegateProxy instance. Subclasses may override this method if they want to create proxies of another type.

Parameters:
proxied - The DirectoryDelegate to proxy.
Returns:
An AttributesEnablingDirectoryDelegateProxy

createChildDelegate

public EntityDelegate createChildDelegate(FileSystemImplementation fs,
                                          EntityType et,
                                          String name,
                                          Object data,
                                          boolean createInBackend)
Instead of overriding this method, subclasses may elect to override createFileDelegateProxy(FileDelegate) and createDirectoryDelegateProxy(DirectoryDelegate, LogAdapterHolder) instead.

Specified by:
createChildDelegate in interface DirectoryDelegate
data - Data used for creating the delegate. If the created entity is a file and the data contains a FileDelegate, the contents of the supplied FileDelegate is moved to the new delegate. The caller must ensure that the supplied FileDelegate object is discarded.
createInBackend - Should the entity be created in the backend? If false, the backend representation (the File, for instance) must already exist.

delete

public void delete(Collection<String> cetd)
Description copied from interface: DirectoryDelegate
Delete the directory.

Since capabilities may add files to a directory that are not visible to the client, this method takes a collection of names of child files that should be deleted before the directory is deleted. If the directory would not be deleted after all named files had been deleted, nothing should be deleted.

Specified by:
delete in interface DirectoryDelegate
Overrides:
delete in class AbstractDirectoryDelegateProxy
Parameters:
cetd - The names of child entities to delete before the directory is deleted. Capability delegates that use files in the directory add to this collection. If no names have been added yet, this argument may be null. Implementations have to check that. before calling their proxied delegate. (See comment above.)

rename

public void rename(String oldName,
                   DirectoryImplementation targetDir,
                   String newName)
            throws FileSystemException
Description copied from interface: EntityDelegate
Rename and/or move the entity.

Specified by:
rename in interface EntityDelegate
Overrides:
rename in class AbstractEntityDelegateProxy<DirectoryDelegate,DirectoryAdapter>
Parameters:
oldName - The old name,
targetDir - The new parent directory.
newName - The new name.
Throws:
FileSystemException - On errors.

assertParentIsReadLocked

public void assertParentIsReadLocked()

assertParentIsWriteLocked

public void assertParentIsWriteLocked()

getAttributes

public T getAttributes()
Description copied from interface: AttributesEntityDelegate
Get the entity attributes.

Specified by:
getAttributes in interface AttributesEntityDelegate<T extends EntityAttributes>
Returns:
The entity attributes.

setAttributes

public void setAttributes(T attrs)
Description copied from interface: AttributesEntityDelegate
Set (and save) the entity attributes.

Specified by:
setAttributes in interface AttributesEntityDelegate<T extends EntityAttributes>
Parameters:
attrs - The new attributes for the entity.

proxyRootDirectoryDelegate

public static <T extends EntityAttributes> DirectoryDelegate proxyRootDirectoryDelegate(DirectoryDelegate dd,
                                                                                        AbstractEntityAttributesEnablingFileSystemDelegate<T> fsd,
                                                                                        LogAdapterHolder lah)

copyFromEntity

public Set<EntityView> copyFromEntity(EntityImplementation ent,
                                      String targetName,
                                      boolean preserveAttrs,
                                      List<EntityAttributeSetter> asl,
                                      EntityLock[] setupLocks)
Remove all NTFS attribute metadata files for copied directories.

Specified by:
copyFromEntity in interface DirectoryDelegate
Overrides:
copyFromEntity in class AbstractDirectoryDelegateProxy
Parameters:
ent - The entity to copy.
targetName - The name of the entity to create.
preserveAttrs - Should entity attributes be copied to the target entity?
asl - A list of entity attribute setters that are run just after the target entity has been created and before the setup locks are released. The setters are run in the order that they are stored in the list. May be null. This may only be non-null when preserveAttrs is set to true.
setupLocks - Exception to the rule that the delegate should not bother with locking. This is here so that the delegate can release the lock needed for creating a new entity just after it has been created (but before data is copied to it). This method is responsible for unlocking this lock regardless of whether it is successful or fails.

copyAttributes

public void copyAttributes(DirectoryImplementation targetParent,
                           EntityImplementation target)
Description copied from class: AbstractEntityDelegateProxy
This implementation does not copy any attributes. Override to modify that behavior.

Specified by:
copyAttributes in interface EntityDelegate
Overrides:
copyAttributes in class AbstractEntityDelegateProxy<DirectoryDelegate,DirectoryAdapter>
Parameters:
targetParent - The parent directory of the target. This is null if target is a root directory of a file system. Otherwise it is locked for writing.
target - The target entity to copy attributes to. Locked for writing.

setDefaultAttributes

public void setDefaultAttributes(String name,
                                 ObjectFactory<T> defaultAttributesFactory)
This sets attributes from the default attributes factory on the new entity if the file system delegate has an EntityAttributesPreparer set. (Otherwise, the attributes will be set the first time that they are saved.)

Subclasses may override this if necessary.

Specified by:
setDefaultAttributes in interface AttributesEntityDelegate<T extends EntityAttributes>
Parameters:
name - The name of the new entity.
defaultAttributesFactory - Factory for the default entity attributes for the entity type of the delegate.