Asset Resource Storage
The Publisher and Store both use a storage mechanism to serve files and images. These resources are stored in a database and its access is controlled using configurations found in the RXT extension files.
The storage mechanism can currently handle only images and PDF files. If more file types need to be handled, then the getContentType function (utility.js:643:getContentType)
in the <ES_HOME>/repository/deployment/server/jaggeryapps/publisher/modules/utility.js
file needs to be modified.
Changing the storage location
The datasource defines where the database tables reside. The datasource definition is defined in the master-datasources.xml
file, which is in the <ES_HOME>/repository/resources/conf/datasources/
directory. The default datasource used for the Publisher and Store in ES is JAGH2
.
The storage mechanism uses the master-datasources.xml
 file to obtain the datasource information. Since there are multiple datasources defined in the master-datasources.xml
 file, the storage system checked the respective storage.json
 file in the Publisher and Store configuration directories.
- Store configuration directory:Â
<ES_HOME>/repository/deployment/server/jaggeryapps/store/config/
- Publisher configuration directory:Â
<ES_HOME>/repository/deployment/server/jaggeryapps/publisher/config/
{ "driverPath":"/drivers/", "driverUsed":"default", "dataSource":"JAGH2", "storageUrlPattern":"/{context}/storage/{type}/{id}/{uuid}", "storeFields":["images_banner","images_thumbnail","overview_url"], "context":"publisher" }
To change the storage location:
- Define the new datasource in theÂ
master-datasources.xml
 file, which is in theÂ<ES_HOME>/repository/conf/datasources/
 directory. - Navigate to the
storage.json
file in the respective configuration directory.- Store:Â
<ES_HOME>/repository/deployment/server/jaggeryapps/store/config/storage.json
- Publisher:Â
<ES_HOME>/repository/deployment/server/jaggeryapps/publisher/config/storage.json
- Store:Â
- Update theÂ
dataSource
property with the newly defined datasource. - Create the corresponding DB scripts, which will define the create directive for a tables to hold the resources. Name the DB scripts as follows:Â
resource.sql
- Save the newly created DB scripts in the
<ES_HOME>/dbscripts/storage/<DBMS_NAME>
directory.
For example:<ES_HOME>/dbscripts/storage/mysql
At any given time the the storage mechanism can only interact with one relational database.
Storing a field in storage
All fields in the RXT can be stored in the storage by changing the type of the field to file
. When a user changes the field type to file
, the UI generated will contain a browse button next to the field.
To store a field in storage:
- Navigate to theÂ
<ES_HOME>/repository/deployment/server/jaggeryapps/publisher/config/ext/
directory. - Open the JSON file that corresponds to your asset.
Change the
type
parameter tofile
.{ "name": "banner", "table": "images", "type": "file" }, { "name": "thumbnail", "table": "images", "type": "file" },
Securing resources stored in a DB
If required, the user can set access levels for each state of an asset.
Follow the instructions below to secure an asset:
- Navigate to the
/config/ext/
directory corresponding to the Publisher or Store.
Publisher:<PRODUCT_HOME>/repository/deployment/server/jaggeryapps/publisher/config/ext/
directory.
Store:Â<PRODUCT_HOME>/repository/deployment/server/jaggeryapps/store/config/ext/
 directory. - Open the JSON file corresponding to the asset.
Update the permissions specified for each state of an asset in the Storage function.
"storage": { "images_banner": { "lifecycle": { "created": ["Internal/private_{overview_provider}"], "in-review": ["Internal/reviewer", "Internal/private_{overview_provider}"], "published": ["Internal/everyone", "Internal/private_{overview_provider}", "Internal/reviewer", "anon"], "unpublished": ["Internal/private_{overview_provider}"] } }, "images_thumbnail": { "lifecycle": { "created": ["Internal/private_{overview_provider}"], "in-review": ["Internal/reviewer", "Internal/private_{overview_provider}"], "published": ["Internal/everyone", "Internal/private_{overview_provider}", "Internal/reviewer", "anon"], "unpublished": ["Internal/private_{overview_provider}"] } } }