Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.knowgate.hipergate
Class ProductLocation

    java.lang.Object
      com.knowgate.dataobjs.DBPersist
          com.knowgate.hipergate.ProductLocation

All Implemented Interfaces:
  java.io.Serializable, java.util.Map

    public class ProductLocation

extends DBPersist

Product Location

Location semantics depend upon what Product is used for.

- For Downloadable Products, ProductLocations represent mirror download URLs.
- For Versioned Products, ProductLocations represent different versions of the same File.
- For Compound Products, ProductLocations represent parts of the Product each one being a File.
- For Physical Products, ProductLocations represent stock of Product at different warehouses.

See Also:
  Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from interface java.util.Map
`java.util.Map.Entry<K,V>`

Field Summary
`static short` | `ClassId`
`static int` | `CONTAINER_FILE`
`static int` | `CONTAINER_FTP`
`static int` | `CONTAINER_HTTP`
`static int` | `CONTAINER_HTTPS`
`static int` | `CONTAINER_JDBC`
`static int` | `CONTAINER_LOTUS`
`static int` | `CONTAINER_ODBC`
`static int` | `CONTAINER_WARE`

Fields inherited from class com.knowgate.dataobjs.DBPersist
`AllVals, sAuditCls, sAuditUsr, sTransactId`

Constructor Summary
`ProductLocation()`
`ProductLocation(JDCConnection oConn, java.lang.String iIdLocation)` Load ProductLocation from database

Method Summary
`boolean` | `delete(JDCConnection oConn)` Delete Productocation If ProductLocation URL point to a file that does not exist then an SQLException will be raised.
`int` | `getContainerType()` Get numeric identifier for container type.
`java.lang.String` | `getPath()` Get Path to URL or file
`java.lang.String` | `getProductType()` Get product type from file path.
`java.lang.String` | `getURL()` Get URL for ProductLocation
`boolean` | `rename(JDCConnection oConn, FileSystem oFileSys, java.lang.String sNewFile)` Rename a Product Location This method updates the xfile value from table k_prod_locats and changes the physical file name accordingly
`void` | `setLength(int iLen)` Set file length in bytes
`void` | `setLength(long lLen)` Set file length in bytes Max file length is 2147483647 bytes
`void` | `setPath(java.lang.String sHost, java.lang.String sLocalPath)` Set Local Path for ProductLocation File Separator is taken from System.getProperty("file.separator") method.
`void` | `setPath(java.lang.String sProtocol, java.lang.String sHost, java.lang.String sPath, java.lang.String sFile, java.lang.String sOriginalFile)` Set File Path
`void` | `setPath(java.lang.String sProtocol, java.lang.String sHost, java.lang.String sPath, java.lang.String sFile, java.lang.String sOriginalFile, java.lang.String sAnchor)` Set File Path
`void` | `setURL(java.lang.String sURL)` Set URL for ProductLocation
`boolean` | `store(JDCConnection oConn)` Store ProductLocation Properties gu_location, dt_uploaded, dt_modified, id_cont_type, id_prod_type, pg_prod_locat and status are automatically set if not present at internal properties colelction when calling store().
`void` | `upload(JDCConnection oConn, FileSystem oFileSys, java.lang.String sSourcePath, java.lang.String sSourceFile, java.lang.String sTargetPath, java.lang.String sTargetFile)` Move a File from a temporary directory up to the final location referenced by ProductLocation URL.

Methods inherited from class com.knowgate.dataobjs.DBPersist
`allcaps, allcaps, changelog, clear, clone, containsKey, containsValue, entrySet, exists, get, get, getAuditClassName, getCreationDate, getDate, getDateFormated, getDateShort, getDateTime, getDateTime24, getDecimal, getDecimalFormated, getDecimalFormated, getDouble, getDoubleFormated, getFloat, getFloatFormated, getInt, getInteger, getIntervalPart, getItemMap, getItems, getMoney, getShort, getSQLDate, getSQLTime, getString, getStringHtml, getStringNull, getTable, getTable, getTableName, getTime, getTimeOfDay, getTimestamp, getUIdFromName, isEmpty, isNull, iterator, keySet, load, load, parseXML, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, putAll, putAll, remove, remove, replace, replace, replace, replace, replace, replace, replace, replace, setAuditTransact, setAuditUser, setCreationDate, size, toLowerCase, toUpperCase, toXML, toXML, toXML, toXML, values`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface java.util.Map
`equals, hashCode`

Field Detail

### ClassId

    public static final short ClassId

See Also:
  Constant Field Values

### CONTAINER_FILE

    public static final int CONTAINER_FILE

See Also:
  Constant Field Values

### CONTAINER_HTTP

    public static final int CONTAINER_HTTP

See Also:
  Constant Field Values

### CONTAINER_HTTPS

    public static final int CONTAINER_HTTPS

See Also:
  Constant Field Values

### CONTAINER_FTP

    public static final int CONTAINER_FTP

See Also:
  Constant Field Values

### CONTAINER_ODBC

    public static final int CONTAINER_ODBC

See Also:
  Constant Field Values

### CONTAINER_LOTUS

    public static final int CONTAINER_LOTUS

See Also:
  Constant Field Values

### CONTAINER_JDBC

    public static final int CONTAINER_JDBC

See Also:
  Constant Field Values

### CONTAINER_WARE

    public static final int CONTAINER_WARE

See Also:
  Constant Field Values

Constructor Detail

### ProductLocation

    public ProductLocation()

### ProductLocation

    public ProductLocation(JDCConnection oConn,
                           java.lang.String iIdLocation)
                    throws java.sql.SQLException

  Load ProductLocation from database

  Parameters:
    `oConn` - Database Conenction
    `iIdLocation` - GUID of ProductLocation to be loaded
  Throws:
    `java.sql.SQLException`

Method Detail

### getPath

    public java.lang.String getPath()

  Get Path to URL or file

  Returns:
    xprotocol [xhost] [:xport] / xpath
    Example 1: file:///opt/knowgate/storage/userdata/
    Example 2: http://www.hipergate.org/es/
    Example 3: http://localhost:8080/

### getURL

    public java.lang.String getURL()

  Get URL for ProductLocation

  Returns:
    getPath() [xfile] [#xanchor]

### getContainerType

    public int getContainerType()

  Get numeric identifier for container type.

  Usually, container type is computed from protocol.

  Protocol | Container Type
  file:// | CONTAINER_FILE
  http:// | CONTAINER_HTTP
  https:// | CONTAINER_HTTPS
  ftp:// | CONTAINER_FTP
  odbc:// | CONTAINER_ODBC
  lotus:// | CONTAINER_LOTUS
  jdbc:// | CONTAINER_JDBC
  ware:// | CONTAINER_WARE

  Returns:
    Container Type. One of { CONTAINER_FILE, CONTAINER_HTTP, CONTAINER_HTTPS, CONTAINER_FTP, CONTAINER_ODBC, CONTAINER_JDBC, CONTAINER_LOTUS, CONTAINER_WARE }

### getProductType

    public java.lang.String getProductType()

  Get product type from file path.

  Returns:
    Product Type as listed in k_lu_prod_types table computed following these rules:
    If xfile is null and xpath is null and id_cont_type is not CONTAINER_HTTP or CONTAINER_HTTPS then "?" is returned.
    If xfile is null and xpath is null and id_cont_type is CONTAINER_HTTP or CONTAINER_HTTPS then "HTML" is returned.
    If xfile is not null and file name has at least one dot ('.') then last dot is considered the extension delimiter.
    Example 1:
    ProductLocation oLoca = new ProductLocation();
    oLoca.setURL("http://www.hipergate.org/index.jsp?lang=en");
    String sProdType = oLoca.getProductType();
    // sProdType == "JSP"
    Example 2:
    ProductLocation oLoca = new ProductLocation();
    oLoca.put(DB.id_cont_type, ProductLocation.CONTAINER_HTTP);
    oLoca.setURL("http://www.hipergate.org/");
    // sProdType == "HTML"

### setURL

    public void setURL(java.lang.String sURL)
                throws java.net.MalformedURLException

  Set URL for ProductLocation

  Throws:
    `java.net.MalformedURLException`

### setLength

    public void setLength(long lLen)
                   throws java.lang.IllegalArgumentException

  Set file length in bytes

  Max file length is 2147483647 bytes

  Parameters:
    `lLen` - Length of file pointed by ProductLocation URL
  Throws:
    `java.lang.IllegalArgumentException` - If lLen > 2147483647

### setLength

    public void setLength(int iLen)

  Set file length in bytes

  Parameters:
    `lLen` - Length of file pointed by ProductLocation URL

### setPath

    public void setPath(java.lang.String sProtocol,
                        java.lang.String sHost,
                        java.lang.String sPath,
                        java.lang.String sFile,
                        java.lang.String sOriginalFile)

  Set File Path

  Parameters:
    `sProtocol` - Protocol. One of { "file://", "http://", "https://", "ftp://", "odbc://", "jdbc://", "ware://" }
    `sHost` - Host Name for electronic Products or WareHouse Name for physical Products. Example: "www.hipergate.org"
    `sPath` - Absolute Access Path. Example: "/opt/knowgate/users/"
    `sFile` - Uploaded File Name
    `sOriginalFile` - Original File Name before uploading. In some cases, files may be renamed upon upload and then renamed again to their original names when downloaded.

### setPath

    public void setPath(java.lang.String sProtocol,
                        java.lang.String sHost,
                        java.lang.String sPath,
                        java.lang.String sFile,
                        java.lang.String sOriginalFile,
                        java.lang.String sAnchor)

  Set File Path

  Parameters:
    `sProtocol` - Protocol. One of { "file://", "http://", "https://", "ftp://", "odbc://", "jdbc://", "ware://" }
    `sHost` - Host Name for electronic Products or WareHouse Name for physical Products. Example: "www.hipergate.org"
    `sPath` - Absolute Access Path. Example: "/opt/knowgate/users/"
    `sFile` - Uploaded File Name
    `sOriginalFile` - Original File Name before uploading. In some cases, files may be renamed upon upload and then renamed again to their original names when downloaded.
    `sAnchor` - Anchor

### setPath

    public void setPath(java.lang.String sHost,
                        java.lang.String sLocalPath)

  Set Local Path for ProductLocation

  File Separator is taken from System.getProperty("file.separator") method.

  Parameters:
    `sHost` - Host Name
    `sLocalPath` - Full Local Path and File Name.
    Example 1: "file:///opt/knowgate/userfiles/logo.gif"
    Example 2: "file://C:\\TEMP\\UserGuide.doc"

### store

    public boolean store(JDCConnection oConn)
                  throws java.sql.SQLException

  Store ProductLocation

  Properties gu_location, dt_uploaded, dt_modified, id_cont_type, id_prod_type, pg_prod_locat and status are automatically set if not present at internal properties colelction when calling store().

  Overrides:
    `store` in class `DBPersist`
  Parameters:
    `oConn` - Database Connection
  Returns:
    boolean true if register was stored for the first time, false if register already existed.
  Throws:
    `java.sql.SQLException`

### rename

    public boolean rename(JDCConnection oConn,
                          FileSystem oFileSys,
                          java.lang.String sNewFile)
                   throws java.lang.Exception,
                          java.io.IOException,
                          java.sql.SQLException,
                          java.lang.SecurityException

  Rename a Product Location

  This method updates the xfile value from table k_prod_locats and changes the physical file name accordingly

  Parameters:
    `oConn` - Database connection
    `oFileSys` - FileSystem Object for accessing physical file
    `sNewFile` - New file name
  Returns:
    true if file was successfully renamed
  Throws:
    `java.lang.Exception`
    `java.io.IOException`
    `java.sql.SQLException`
    `java.lang.SecurityException`
  Since:
    2.1

### upload

    public void upload(JDCConnection oConn,
                       FileSystem oFileSys,
                       java.lang.String sSourcePath,
                       java.lang.String sSourceFile,
                       java.lang.String sTargetPath,
                       java.lang.String sTargetFile)
                throws java.lang.Exception,
                       java.io.IOException,
                       java.sql.SQLException

  Move a File from a temporary directory up to the final location referenced by ProductLocation URL.

  Parameters:
    `oConn` - Database Connection
    `oFileSys` - FileSystem object used for moving the file.
    If FileSystem requieres additional parameters (such as user authentification for FTP) it will be taken from hipergate.cnf file by using Environment singleton.
    `sSourcePath` - Source Directory. For example: "file:///tmp/archivos/"
    `sSourceFile` - Original File Name. For example: "notes.pdf"
    `sTargetPath` - Target Directory. For example: "ftp://saturno/opt/storage/"
    `sTargetFile` - Final File Name. For Example: "notes-13-05-03.pdf"
  Throws:
    `java.lang.Exception`
    `java.io.IOException`
    `java.sql.SQLException`
  See Also:
    `Environment`

### delete

    public boolean delete(JDCConnection oConn)
                   throws java.sql.SQLException

  Delete Productocation

  If ProductLocation URL point to a file that does not exist then an SQLException will be raised.
  Disk files are only deleted for CONTAINER_FILE and CONTAINER_FTP container types. Files pointed by other protocols (such as CONTAINER_HTTP) will not be deleted with by this method.

  Overrides:
    `delete` in class `DBPersist`
  Parameters:
    `oConn` - Database Connection
  Returns:
    true if register was successfully erased, false if not.
  Throws:
    `java.sql.SQLException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD