Ontimize 5.2072EN

com.ontimize.db
Class StandardAttachmentEntity

java.lang.Object
  extended byjava.rmi.server.RemoteObject
      extended byjava.rmi.server.RemoteServer
          extended byjava.rmi.server.UnicastRemoteObject
              extended bycom.ontimize.db.TableEntity
                  extended bycom.ontimize.db.DefaultTableEntity
                      extended bycom.ontimize.db.StandardAttachmentEntity
All Implemented Interfaces:
AdvancedEntity, AdvancedQueryEntity, Entity, EntityDataChangeNotifier, FileManagementEntity, IdentifiedEntity, PrivilegedSecurityEntity, java.rmi.Remote, SecureEntity, java.io.Serializable, TransactionalEntity

public class StandardAttachmentEntity
extends DefaultTableEntity

Class that must be inherit to be able to use the functionality of attaching files for each application form. In order that this entity works correctly, it is necessary to define a properties file for this entity. This file must contain the following parameters:
- AttachmentFileNameColumn: name of the column, in which the name of the attached file is stored
- AttachmentFileOriginalNameColumn: name of the column, in which the name of the file (before its attachment) is stored.
- AttachmentFileDescriptionColumn: name of the column, in which the description, that is added at this file, is stored.
- AttachmentFilePath: path, in which the attached files are stored.
- AttachmentFileNameKeys: columns that are used to created the name of the attached file
- InsertAutomaticlyAttachment: it must be fixed to 'yes'.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class com.ontimize.db.TableEntity
TableEntity.AttachmentReceiving, TableEntity.Receiving
 
Field Summary
protected  java.lang.String attachmentDate
           
protected  java.lang.String attachmentId
           
protected  java.lang.String attachmentKeys
           
protected  java.lang.String attachmentKeysColumns
           
protected  java.lang.String attachmentPrivate
           
protected  java.lang.String attachmentUser
           
protected  boolean checkPermissions
           
protected  java.lang.String dataBaseTable
           
static boolean DEBUG
           
static java.lang.String DEFAULT_ATTACHMENT_DATABASE_TABLE
           
protected  java.lang.String fileDescription
           
protected  java.lang.String fileName
           
protected static java.lang.String KEY_NAME_COLUMN
           
protected static java.lang.String KEY_VALUE_COLUMN
           
protected  java.lang.String originalFileName
           
protected  java.lang.String size
           
protected  java.lang.String sourceAttachmentTable
           
 
Fields inherited from class com.ontimize.db.DefaultTableEntity
props
 
Fields inherited from class com.ontimize.db.TableEntity
alias, aliasPropertiesParser, aliasReverse, ASTERISK, ATTACHMENT_FILE_DESCRIPTION_COLUMN, ATTACHMENT_FILE_NAME_COLUMN, ATTACHMENT_FILE_NAME_KEYS, ATTACHMENT_FILE_ORIGINAL_NAME_COLUMN, ATTACHMENT_FILE_ORIGINAL_PATH_COLUMN, ATTACHMENT_FILE_PATH, ATTACHMENT_FILE_SIZE_COLUMN, ATTACHMENT_SEPARATOR, ATTACHMENT_TABLE, attachmentFileNameColumn, attachmentFileNameKeys, attachmentFilePath, attachmentFileSizeColumn, attachTable, AUTOCONFIGURATION, AUTONUMERICAL, autonumericalColumn, calendar, checkOperationResult, columnNames, COLUMNS, connectionRequestTime, dataChangeListeners, dBLocalErrorMessage, DEBUG_DETAILS, DEBUG_TIMES, DEFAULT_MAX_CONNECTION_WAIT_TIME, defaultEntityScriptManagerClassName, DELETE_ACTION, DELETE_KEYS, deleteKeys, descendantColumnsOrder, descriptionAttachmentFileColumn, enableScripting, entitiesPropertiesParser, entitiesTableAttribute, entityName, entityScripting, FETCH_SIZE, fetchSize, FILE_COLUMNS, fileInfoList, FORCE_DISTINCT, forceDistinct, INSERT_ACTION, INSERT_AUTOMATICLY_ATTACHMENT, INSERT_COLUMNS, INSERT_KEYS, insertAttachmentAutomatically, insertColumn, insertKeys, INTERROG, keys, KEYS, LIMIT_QUERY_OTHERS_ENTITIES, limitQueryOthersEntities, locator, LOG_KEYS, logDelete, logInsert, logkeys, logQuery, logUpdate, M_ERROR_OPERATION, M_IT_HAS_NOT_CHANGED_ANY_RECORD, M_LICENSE_PERMISSION_ERROR, M_TEMPORALY_RESTRICTED_BY_PERMISSION_ACTION, M_YOU_DO_NOT_HAVE_PERMISSION_TO_EXECUTE_ACTION, manager, maxConnectionWaitTime, oneToOneMode, orderColumns, originalAttachmentFileNameColumn, originalAttachmentFilePathColumn, OTHER_ENTITIES, othersEntities, PERCENT, PRINCIPAL_COLUMNS, PRINCIPAL_KEYS, PRINCIPAL_TABLE, principalColumnNames, principalKeyName, principalTable, privilegedId, properties, propertiesPath, QUERY_ACTION, QUERY_TABLE, queryTable, receivedAttachmentFile, receivedTempFiles, RECORD_OPERATIONS, registeredDispatcher, REPORT_ADVANCED_QUERY_COLUMNS, REPORT_ADVANCED_QUERY_TYPES, reportAvancedQueryColumns, reportAvancedQueryTypes, SECONDARY_COLUMNS, SECONDARY_KEYS, SECONDARY_TABLE, secondaryColumnsNames, secondaryKeyName, secondaryTable, sendAttachmentFile, SORT, SORT_DESC, table, TABLE, TABLE_ATTRIBUTE_ENTITIES, tempFiles, TIME_BETWEEN_DEFAULT_CONNECTION_REQUEST, TRUNCATE_DATE_DEFAULT_VALUE, TRUNCATE_DATES, truncateDates, UNDERSCORE, UPDATE_ACTION, UPDATE_COLUMNS, UPDATE_KEYS, updateColumn, updateKeys, USE_SETSTRING_LONG_STRINGS, useAlwaysTableAttributeEntities, WILDCARD_COLUMNS, wildcardColumns
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
StandardAttachmentEntity(EntityReferenceLocator referenceLocator, DatabaseConnectionManager dbConnectionManager, int port, java.lang.String properties)
           
 
Method Summary
 void checkPermissions(int sessionId, java.lang.String action)
          Checks if the user/session identified by sessionId has the permission defined by action This method calls ServerManager.getServerSecurityManager() and then, if a manager exists, calls manager.checkActionPermission(int, String, String)
 java.util.Hashtable createAttachmentKeys(java.util.Hashtable kv)
           
protected  void createProperties()
           
protected  java.lang.Integer increment()
           
protected  void initAlias()
           
protected  void initId()
           
protected  void loadAliasFile(java.lang.String path)
          Loads the alias properties file in path.
protected  void loadAttachmentAliasFile(java.lang.String path)
           
 java.lang.String prepareToReceive(java.util.Hashtable keys, java.lang.String fileName, java.lang.String fileDescription, int sessionId)
          This method calls prepareToReceive(Hashtable, String, String, String, int) with null argument for originalFilePath
 java.lang.String prepareToReceive(java.util.Hashtable keys, java.lang.String fileName, java.lang.String originalFilePath, java.lang.String fileDescription, int sessionId)
          Indicates to this entity that must be ready for receiving the contents of a file.
 EntityResult query(java.util.Hashtable keys, java.util.Vector values, int sessionId, java.sql.Connection con)
          Executes a query operation using the provided Connection, with the conditions and attributes required.
protected  EntityResult queryNoPrivate(java.util.Hashtable keys, java.util.Vector values, int sessionId, java.sql.Connection con)
           
protected  EntityResult queryPrivate(java.util.Hashtable keys, java.util.Vector values, int sessionId, java.sql.Connection con)
           
protected  void readAdditionalProperties()
           
protected  void readAttachmentProperties(java.lang.String path)
           
protected  void readProperties(java.util.Properties prop, java.net.URL urlProp)
          Loads and analyzes the properties prop.
protected  void readProperties(java.lang.String path)
          Loads a Properties object located in path using this.getClass().getClassLoader().getResource(path).
 void setPathAttachment(java.lang.String path)
           
 
Methods inherited from class com.ontimize.db.DefaultTableEntity
getExtendedAliasPropertiesName, getExtendedPropertiesName, loadAliasFile, readProperties, setName
 
Methods inherited from class com.ontimize.db.TableEntity
addEntityDataChangeListener, buildConditionsString, cancelReceiving, checkDeleteKeys, checkFinishedSession, checkInsertKeys, checkOrderColumns, checkUpdateKeys, configureReverseAlias, connect, connect, createAdvancedEntityResultForSessionId, createAdvancedEntityResultForSessionId, createEntityResultForSessionId, createEntityResultForSessionId, createEntityResultForSessionId, createEntityResultForSessionId, createEntityResultForSessionId, createEntityScriptManager, delete, delete, deleteAttachmentFile, deleteAttachmentFile, deleteMultipleTableAttributesColumns, disconnect, disconnect, dispatcherAttribute, executePreparedStatement, executePreparedStatement, executePreparedStatement, executePreparedStatement, executePreparedStatement, executePreparedStatement, executePreparedStatement, executeStatement, finishReceiving, fireDataChangeEvent, fireDataChangeEvent, fireTransactionDataChangeEvent, fireTransactionDataChangeEvent, generateRandomId, getActions, getAliasForColumn, getAttachmentFileNameForKeys, getAttachmentFilePath, getAttachmentFilePath, getAutonumericalColumn, getBytes, getColumnForAlias, getColumnListForAvancedQuery, getColumns, getDatabaseConnectionManager, getDescOrderColumns, getDescription, getEntityPrivilegedId, getEntityReference, getErrorMessage, getExtension, getName, getOrderColumns, getPrivilegedId, getPropertiesPath, getQueryRecordNumber, getQueryTable, getSize, getSQLTypesFromMetaData, getStringsOn, getSubGroupValues, getSubGroupValues, getTable, getUpdateColumns, getUser, getValidAttributes, getValidDeletingKeysValues, getValidInsertingAttributesValues, getValidQueryingKeysValues, getValidUpdatingAttributesValues, getValidUpdatingKeysValues, getWildCardColumns, insert, insert, insertAutonumericalAlias, isBinaryType, logToLogKeys, logUpdate, parseStringValue, performExtendedAliasProperties, performExtendedProperties, postDelete, postInsert, postUpdate, preDelete, preInsert, prepareToReceive, prepareToTransfer, prepareToTransfer, preUpdate, processFileColumnsAttributes, processFileColumnsAttributes, processFileResults, processingMultipleValueAttributes, processingReferenceDataFieldAttributes, processingReferenceDataFieldAttributes, processMultipleAttributeKey, processMultipleTableAttribute, processMultipleTableAttribute, putBytes, query, query, query, query, queryOtherEntities, registerAttributeDispatcher, reloadScripts, removeEntityDataChangeListener, replaceAliasByColumn, replaceAliasByColumn, replaceAliasByColumn, replaceAliasByColumn, replaceAliasByColumn, replaceColumnByAlias, replaceColumnByAlias, replaceColumnByAlias, replaceColumnByAlias, replaceColumnByAliasKeepColumns, resultSetToEntityResult, resultSetToEntityResult, resultSetToEntityResult, setLimitQueryOthersEntities, setObject, setObject, setPrivilegedId, toVectorOfBooleans, truncateDataToHour_00_00_00, truncateDateToMinutes, update, update, updateAttachmentValues, vectorToStringSeparateBySemicolon
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEBUG

public static boolean DEBUG

KEY_VALUE_COLUMN

protected static final java.lang.String KEY_VALUE_COLUMN
See Also:
Constant Field Values

KEY_NAME_COLUMN

protected static final java.lang.String KEY_NAME_COLUMN
See Also:
Constant Field Values

DEFAULT_ATTACHMENT_DATABASE_TABLE

public static final java.lang.String DEFAULT_ATTACHMENT_DATABASE_TABLE
See Also:
Constant Field Values

dataBaseTable

protected java.lang.String dataBaseTable

attachmentId

protected java.lang.String attachmentId

attachmentKeys

protected java.lang.String attachmentKeys

attachmentKeysColumns

protected java.lang.String attachmentKeysColumns

sourceAttachmentTable

protected java.lang.String sourceAttachmentTable

attachmentDate

protected java.lang.String attachmentDate

attachmentPrivate

protected java.lang.String attachmentPrivate

attachmentUser

protected java.lang.String attachmentUser

fileName

protected java.lang.String fileName

originalFileName

protected java.lang.String originalFileName

fileDescription

protected java.lang.String fileDescription

size

protected java.lang.String size

checkPermissions

protected boolean checkPermissions
Constructor Detail

StandardAttachmentEntity

public StandardAttachmentEntity(EntityReferenceLocator referenceLocator,
                                DatabaseConnectionManager dbConnectionManager,
                                int port,
                                java.lang.String properties)
                         throws java.lang.Exception
Method Detail

readProperties

protected void readProperties(java.lang.String path)
                       throws java.lang.Exception
Description copied from class: TableEntity
Loads a Properties object located in path using this.getClass().getClassLoader().getResource(path).
Then calls TableEntity.readProperties(Properties, URL)

Overrides:
readProperties in class TableEntity
Parameters:
path - path from which the properties will be loaded
Throws:
java.lang.Exception

readAttachmentProperties

protected void readAttachmentProperties(java.lang.String path)
                                 throws java.lang.Exception
Throws:
java.lang.Exception

setPathAttachment

public void setPathAttachment(java.lang.String path)

createProperties

protected void createProperties()

readProperties

protected void readProperties(java.util.Properties prop,
                              java.net.URL urlProp)
                       throws java.lang.Exception
Description copied from class: TableEntity
Loads and analyzes the properties prop. The parameters for this entity are read from the properties and this entity is configured according to them.
If the 'autoconfiguration' parameter is specified and the uRLProp protocol is 'file', then a properties file is generated located in uRLProp.getPath()

Overrides:
readProperties in class TableEntity
Parameters:
prop - the properties object
urlProp - the properties file URL
Throws:
java.lang.Exception

loadAliasFile

protected void loadAliasFile(java.lang.String path)
Description copied from class: TableEntity
Loads the alias properties file in path.

If file does not exist, no error is produced. If file exists, resulting alias are loaded in alias and aliasReverse fields.

Overrides:
loadAliasFile in class TableEntity
Parameters:
path - the file location, relative to this entity's class file.

loadAttachmentAliasFile

protected void loadAttachmentAliasFile(java.lang.String path)

initAlias

protected void initAlias()

readAdditionalProperties

protected void readAdditionalProperties()
                                 throws java.lang.Exception
Throws:
java.lang.Exception

initId

protected void initId()

increment

protected java.lang.Integer increment()

prepareToReceive

public java.lang.String prepareToReceive(java.util.Hashtable keys,
                                         java.lang.String fileName,
                                         java.lang.String fileDescription,
                                         int sessionId)
                                  throws java.lang.Exception
Description copied from class: TableEntity
This method calls TableEntity.prepareToReceive(Hashtable, String, String, String, int) with null argument for originalFilePath

Specified by:
prepareToReceive in interface FileManagementEntity
Overrides:
prepareToReceive in class TableEntity
Throws:
java.lang.Exception

prepareToReceive

public java.lang.String prepareToReceive(java.util.Hashtable keys,
                                         java.lang.String fileName,
                                         java.lang.String originalFilePath,
                                         java.lang.String fileDescription,
                                         int sessionId)
                                  throws java.lang.Exception
Description copied from class: TableEntity
Indicates to this entity that must be ready for receiving the contents of a file. The file will be associated (linked) to the record identified by keysValues. The method returns a String identifier for use when sending new bytes.

This method performs a query, so QUERY_ACTION must be granted to the caller.

If insertAttachmentAutomatically is true, then a new record is automatically inserted using the values contained in keysValues. (So, INSERT_ACTION must be granted.)

The supplied fileName, originalFilePath and fileDescription will be used when inserting if not null and TableEntity.attachmentFileNameColumn, TableEntity.originalAttachmentFileNameColumn and TableEntity.descriptionAttachmentFileColumn are not null.

If insertAttachmentAutomatically is false, a record must exist.

Specified by:
prepareToReceive in interface FileManagementEntity
Overrides:
prepareToReceive in class TableEntity
Parameters:
keys - the keys-values that identify the record or the new values for the new record
fileName - the attachment file name. The resulting file name will be the generated by a call to getAttachmentFileNameForKeys. May be null
originalFilePath - may be null
fileDescription - an optional file description. May be null
sessionId - the caller id
Returns:
a identifier for the transfer
Throws:
java.lang.Exception - if attachment file path or attachment filename column are null for this entity, or an error ocurrs

createAttachmentKeys

public java.util.Hashtable createAttachmentKeys(java.util.Hashtable kv)
                                         throws java.lang.Exception
Throws:
java.lang.Exception

query

public EntityResult query(java.util.Hashtable keys,
                          java.util.Vector values,
                          int sessionId,
                          java.sql.Connection con)
                   throws java.lang.Exception
Description copied from class: TableEntity
Executes a query operation using the provided Connection, with the conditions and attributes required.

This method calls TableEntity.query(Hashtable, Vector, int, Connection, Vector, boolean) using null and true as the last two parameters.

Specified by:
query in interface TransactionalEntity
Overrides:
query in class TableEntity
Parameters:
keys -
values -
sessionId -
con -
Returns:
Throws:
java.lang.Exception - if an error ocurrs

queryNoPrivate

protected EntityResult queryNoPrivate(java.util.Hashtable keys,
                                      java.util.Vector values,
                                      int sessionId,
                                      java.sql.Connection con)
                               throws java.lang.Exception
Throws:
java.lang.Exception

queryPrivate

protected EntityResult queryPrivate(java.util.Hashtable keys,
                                    java.util.Vector values,
                                    int sessionId,
                                    java.sql.Connection con)
                             throws java.lang.Exception
Throws:
java.lang.Exception

checkPermissions

public void checkPermissions(int sessionId,
                             java.lang.String action)
                      throws NotInPeriodException,
                             GeneralSecurityException
Description copied from class: TableEntity
Checks if the user/session identified by sessionId has the permission defined by action

This method calls ServerManager.getServerSecurityManager() and then, if a manager exists, calls manager.checkActionPermission(int, String, String)

Overrides:
checkPermissions in class TableEntity
Parameters:
sessionId - the identifier to check
action - the action to check
Throws:
NotInPeriodException - if the action is restricted by time constraints
GeneralSecurityException - it the action is not allowed

Ontimize