org.entityfs.cap.metadata.util
Class ECNamedMetadataUtil

java.lang.Object
  extended by org.entityfs.cap.metadata.util.ECNamedMetadataUtil

public final class ECNamedMetadataUtil
extends Object

This utility class contains static methods for working with entities that support the ECNamedMetadata capability.

The methods in this class will use the locking strategy for utility classes described in EntityLock.

Since:
1.0
Author:
Karl Gustafsson
See Also:
ECMetadataUtil
In_jar:
entityfs-metadata

Method Summary
static void deleteMetadataFile(EntityView ev, String name)
          Delete the metadata file for the entity.
static ECNamedMetadata getCapability(EntityView ev)
          Get the ECNamedMetadata capability for an entity.
static ReadWritableFile getMetadataFile(EntityView ev, String name)
          Get the named metadata file for the entity.
static Set<String> getMetadataFileNames(EntityView ev)
          Get all metadata file names for the entity.
static boolean hasMetadataFile(EntityView ev, String name)
          Check if the entity has a metadata file with the given name.
static ReadWritableFile newMetadataFile(EntityView ev, String name)
          Create a new metadata file for the entity.
static boolean supportsMetadata(EntityView ev)
          Check if the entity supports the ECNamedMetadata capability.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getCapability

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

Parameters:
ev - The entity to get the capability for.
Returns:
The capability.
Throws:
UnsupportedCapabilityException - If the entity does not support the ECNamedMetadata capability.

supportsMetadata

public static boolean supportsMetadata(EntityView ev)
Check if the entity supports the ECNamedMetadata capability.

Parameters:
ev - The entity to investigate.
Returns:
true if the entity supports the capability, false otherwise.

getMetadataFileNames

public static Set<String> getMetadataFileNames(EntityView ev)
                                        throws UnsupportedCapabilityException
Get all metadata file names for the entity.

The returned set is a read only view of the internal file name set, so updates in that set (by metadata files being created or deleted), are reflected in the set that is returned by this method.

This method will lock the entity for reading while executing.

Parameters:
ev - The entity.
Returns:
A set of all metadata file names. If the entity does not have any metadata, an empty set is returned.
Throws:
UnsupportedCapabilityException - If the entity does not support the ECNamedMetadata capability.
See Also:
ECNamedMetadata.getMetadataFileNames()

hasMetadataFile

public static boolean hasMetadataFile(EntityView ev,
                                      String name)
                               throws UnsupportedCapabilityException
Check if the entity has a metadata file with the given name.

This method will lock the entity for reading while executing.

Parameters:
ev - The entity to investigate.
name - The name of the metadata file.
Returns:
true if the entity has a metadata file of the given name, false if not.
Throws:
UnsupportedCapabilityException - If the entity does not support the ECNamedMetadata capability.
See Also:
ECNamedMetadata.hasMetadataFile(String)

getMetadataFile

public static ReadWritableFile getMetadataFile(EntityView ev,
                                               String name)
                                        throws EntityNotFoundException,
                                               UnsupportedCapabilityException
Get the named metadata file for the entity.

This method will lock the entity for reading while executing.

Parameters:
ev - The entity.
name - The name of the metadata file. This must be a valid file name in the backing file system.
Returns:
The metadata file with the supplied name,
Throws:
EntityNotFoundException - If the entity does not have a metadata file with the supplied name.
UnsupportedCapabilityException - If the entity does not support the ECNamedMetadata capability.
See Also:
ECNamedMetadata.getMetadataFile(String)

newMetadataFile

public static ReadWritableFile newMetadataFile(EntityView ev,
                                               String name)
                                        throws EntityFoundException,
                                               ReadOnlyException,
                                               UnsupportedCapabilityException
Create a new metadata file for the entity.

This method will lock the entity for writing while executing.

Parameters:
ev - The entity.
name - The name of the metadata file. This must be a valid file name in the backing file system.
Returns:
The new metadata file.
Throws:
EntityFoundException - If the entity already has a metadata file with the supplied name.
ReadOnlyException - If the file system is read only.
UnsupportedCapabilityException - If the entity does not support the ECNamedMetadata capability.
See Also:
ECNamedMetadata.newMetadataFile(String)

deleteMetadataFile

public static void deleteMetadataFile(EntityView ev,
                                      String name)
                               throws EntityNotFoundException,
                                      ReadOnlyException,
                                      UnsupportedCapabilityException
Delete the metadata file for the entity.

This method will lock the entity for writing while executing.

Parameters:
ev - The entity.
name - The name of the metadata file to delete.
Throws:
EntityNotFoundException - If no such metadata file exists.
ReadOnlyException - If the file system is read only.
UnsupportedCapabilityException - If the entity does not support the ECNamedMetadata capability.
See Also:
ECNamedMetadata.deleteMetadataFile(String)