com.ibm.commerce.context.content.resources.file

Class ManagedFileDirectoryUtility

  • java.lang.Object
    • com.ibm.commerce.context.content.resources.file.ManagedFileDirectoryUtility


  • public class ManagedFileDirectoryUtility
    extends java.lang.Object
    This class contains the utilities for content managed file directories.
    • Constructor Summary

      Constructors 
      Constructor and Description
      ManagedFileDirectoryUtility(java.sql.Connection connection)
      This is the constructor for this class.
      ManagedFileDirectoryUtility(java.sql.Connection connection, boolean insideCommerceEnvironment)
      This is the constructor for this class.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.lang.Long createDirectory(java.lang.String astrStoreDirectory, java.lang.String astrPathName)
      This method will first check if the path name astrPathName already exists for the store directory astrStoreDirectory.
      int deleteDirectoryRecord(java.lang.Long aDirId)
      This method deletes one directory record in the CMFILEDIR table.
      java.util.ArrayList getAllSubDirectoryIds(java.lang.Long anParentDirectoryId)
      This method gets all the ids of all the sub directories for the given parent directory id.
      java.util.ArrayList getAllSubDirectoryIds(java.lang.String astrStoreDirectory, java.lang.String astrParentPath)
      This method gets all the ids of all the sub directories for the store directory and given parent directory full path.
      java.util.ArrayList getChildsFromParentId(java.lang.Long anParentId)
      This method returns the first level child directories of the given parent directory.
      java.lang.Long getIdFromParentIdAndDirectoryName(java.lang.Long anParentId, java.lang.String astrDirectoryName)
      This method gets the id a given parent directory id and directory name.
      java.lang.Long getIdFromStoreDirectoryAndPath(java.lang.String astrStoreDir, java.lang.String astrPathName)
      This method will return the content managed file directory id for a given store directory and path.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        IBM Copyright notice field.
        See Also:
        Constant Field Values
      • DEFAULT_STORE_DIRECTORY_PARENT_ID

        public static final java.lang.Long DEFAULT_STORE_DIRECTORY_PARENT_ID
        This is the store directory's parent id in the CMFILEDIR table.
      • DEFAULT_DIRECTORY_SEPARATOR

        public static final java.lang.String DEFAULT_DIRECTORY_SEPARATOR
        This is the directory separator used.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ManagedFileDirectoryUtility

        public ManagedFileDirectoryUtility(java.sql.Connection connection)
                                    throws java.sql.SQLException
        This is the constructor for this class. It assumes the utility is running outside Commerce environment
        Parameters:
        connection - The database connection to be set.
        Throws:
        java.sql.SQLException - This is thrown when an unexpected error occurs in the database.
      • ManagedFileDirectoryUtility

        public ManagedFileDirectoryUtility(java.sql.Connection connection,
                                           boolean insideCommerceEnvironment)
                                    throws java.sql.SQLException
        This is the constructor for this class.
        Parameters:
        connection - The database connection to be set.
        insideCommerceEnvironment - True if the utility is running inside Commerce environment
        Throws:
        java.sql.SQLException - This is thrown when an unexpected error occurs in the database.
    • Method Detail

      • getIdFromParentIdAndDirectoryName

        public java.lang.Long getIdFromParentIdAndDirectoryName(java.lang.Long anParentId,
                                                                java.lang.String astrDirectoryName)
                                                         throws java.sql.SQLException
        This method gets the id a given parent directory id and directory name. Note that the astrDirectoryName will be converted to lower case characters and use this string to search the IDENTIFIER column on the CMFILEDIR table.
        Parameters:
        anParentId - The parent directory id.
        astrDirectoryName - The directory name.
        Returns:
        The id of the given parent directory id and directory name.
        Throws:
        java.sql.SQLException - This is thrown when an unexpected error occurs in the database.
      • createDirectory

        public java.lang.Long createDirectory(java.lang.String astrStoreDirectory,
                                              java.lang.String astrPathName)
                                       throws java.sql.SQLException

        This method will first check if the path name astrPathName already exists for the store directory astrStoreDirectory.

        If the path name astrPathName already exists for the store directory astrStoreDirectory, this method will do nothing. It will simply return the content managed file directory id for this path.

        If the path name astrPathName does not exist for the store directory astrStoreDirectory, it will try to create the directory. If the store directory astrStoreDirectory is not found, this method will first create the store directory. This method will then check the directory astrPathName and its ancestor directories. If any directory on the path is not in the database, it will be created.

        Note that the astrPathName is the directory full path name which is the relative directory to the store directory name.

        The new directory name found on the astrPathName will be stored as the DISPLAYNAME field in the database. The code will convert the directory name to lower case letters and store it in the IDENTIFIER field.

        If the astrPathName is an empty string and the store directory does not exist in the database, the utility will do two things. It will create the store directory and return its directory id.

        If the astrPathName is an empty string and the store directory exists in the database, the utility will just return its directory id.

        Parameters:
        astrStoreDirectory - The store directory name.
        astrPathName - The directory full path name.
        Returns:
        The id of the input directory astrPathName.
        Throws:
        java.sql.SQLException - This is thrown when an unexpected error occurs in the database.
      • getIdFromStoreDirectoryAndPath

        public java.lang.Long getIdFromStoreDirectoryAndPath(java.lang.String astrStoreDir,
                                                             java.lang.String astrPathName)
                                                      throws java.sql.SQLException
        This method will return the content managed file directory id for a given store directory and path. If an id is not found, null will be returned.
        Parameters:
        astrStoreDir - The store directory.
        astrPathName - The directory full path name which is the relative path to the store directory.
        Returns:
        The content managed file directory id.
        Throws:
        java.sql.SQLException - This is thrown when an unexpected error occurs in the database.
      • getChildsFromParentId

        public java.util.ArrayList getChildsFromParentId(java.lang.Long anParentId)
                                                  throws java.sql.SQLException
        This method returns the first level child directories of the given parent directory. An ArrayList of CMFileDirectoryDataBean will be returned.
        Parameters:
        anParentId - The id of the parent directory.
        Returns:
        The first level child directories.
        Throws:
        java.sql.SQLException - This is thrown when an unexpected error occurs in the database.
      • getAllSubDirectoryIds

        public java.util.ArrayList getAllSubDirectoryIds(java.lang.Long anParentDirectoryId)
                                                  throws java.sql.SQLException
        This method gets all the ids of all the sub directories for the given parent directory id. This will return a list of Long objects which are content managed file directory ids of all the sub directories. These sub directories include all the children and grand children.
        Parameters:
        anParentDirectoryId - The id of the parent directory.
        Returns:
        The ids of all the sub directories.
        Throws:
        java.sql.SQLException - This is thrown when an unexpected error occurs in the database.
      • getAllSubDirectoryIds

        public java.util.ArrayList getAllSubDirectoryIds(java.lang.String astrStoreDirectory,
                                                         java.lang.String astrParentPath)
                                                  throws java.sql.SQLException
        This method gets all the ids of all the sub directories for the store directory and given parent directory full path. The astrPathName is the directory full path name which is the relative path to the store directory name. This will return list of Long objects which are content managed file directory ids of all the sub directories. These sub directories include all the children and grand children.
        Parameters:
        astrStoreDirectory - The store directory.
        astrParentPath - The parent directory full path.
        Returns:
        The ids of all the sub directories.
        Throws:
        java.sql.SQLException - This is thrown when an unexpected error occurs in the database.
      • deleteDirectoryRecord

        public int deleteDirectoryRecord(java.lang.Long aDirId)
                                  throws java.sql.SQLException
        This method deletes one directory record in the CMFILEDIR table.
        Parameters:
        aDirId - The directory id to be deleted.
        Returns:
        the row count to delete.
        Throws:
        java.sql.SQLException - This is thrown when an unexpected error occurs in the database.