Class URLProductStorage

    • Field Detail

      • URL_PROPERTY_NAME

        public static final java.lang.String URL_PROPERTY_NAME
        Property name representing base URL.
        See Also:
        Constant Field Values
      • STORAGE_FORMAT_PROPERTY

        public static final java.lang.String STORAGE_FORMAT_PROPERTY
        Property for storageFormat
        See Also:
        Constant Field Values
      • STORAGE_PATH_PROPERTY

        public static final java.lang.String STORAGE_PATH_PROPERTY
        Property for storagePath
        See Also:
        Constant Field Values
      • DEFAULT_STORAGE_PATH

        public static final java.lang.String DEFAULT_STORAGE_PATH
        Sets up default storage path
        See Also:
        Constant Field Values
      • BINARY_FORMAT_PROPERTY

        public static final java.lang.String BINARY_FORMAT_PROPERTY
        (Deprecated, use STORAGE_PATH) Property name to configure binary or xml format.
        See Also:
        Constant Field Values
      • BINARY_FORMAT_DEFAULT

        public static final java.lang.String BINARY_FORMAT_DEFAULT
        Default value for whether to use binary format.
        See Also:
        Constant Field Values
    • Constructor Detail

      • URLProductStorage

        public URLProductStorage()
        Constructor for the Configurable interface.
      • URLProductStorage

        public URLProductStorage​(java.io.File baseDirectory,
                                 java.net.URL baseURL)
        Construct a new ProductStorage object
        Parameters:
        baseDirectory - the storage directory where products are stored.
        baseURL - the url where storage directory is available.
    • Method Detail

      • configure

        public void configure​(Config config)
                       throws java.lang.Exception
        Load the baseURL from configuration.
        Specified by:
        configure in interface Configurable
        Overrides:
        configure in class FileProductStorage
        Parameters:
        config - the configuration object.
        Throws:
        java.lang.Exception - if configuration exceptions occur.
      • getProductURL

        public java.net.URL getProductURL​(ProductId id)
                                   throws java.lang.Exception
        Compute the URL to a product.
        Parameters:
        id - which product.
        Returns:
        the URL to a product.
        Throws:
        java.lang.Exception - if error occurs
      • getProductPath

        public java.lang.String getProductPath​(ProductId id)
        A method for subclasses to override the storage path. The returned path is appended to the base directory when storing and retrieving products.
        Overrides:
        getProductPath in class FileProductStorage
        Parameters:
        id - the product id to convert.
        Returns:
        the directory used to store id.
      • getProductHandlerFormat

        protected ProductHandler getProductHandlerFormat​(java.io.File file)
                                                  throws java.lang.Exception
        A method for subclasses to override the storage format. When overriding this method, the method getProductInputForFile should also be overridden.
        Overrides:
        getProductHandlerFormat in class FileProductStorage
        Parameters:
        file - a file that should be converted into a ProductOutput.
        Returns:
        the ProductOutput.
        Throws:
        java.lang.Exception - if error occurs
      • getProductSourceFormat

        protected ProductSource getProductSourceFormat​(java.io.File file)
                                                throws java.lang.Exception
        A method for subclasses to override the storage format. When overriding this method, the method getProductOutputForFile should also be overridden.
        Overrides:
        getProductSourceFormat in class FileProductStorage
        Parameters:
        file - a file that should be converted into a ProductInput.
        Returns:
        the ProductInput.
        Throws:
        java.lang.Exception - if error occurs
      • setStorageFormat

        public void setStorageFormat​(URLProductStorage.Format format)
        Parameters:
        format - set a storageFormat
      • getStoragePath

        public java.lang.String getStoragePath()
        Returns:
        storagePath
      • setStoragePath

        public void setStoragePath​(java.lang.String path)
        Parameters:
        path - set a string as the storagePath