Showing posts with label Repository. Show all posts
Showing posts with label Repository. Show all posts

Super Type and Sub Type in Repository

ATG Repository supports the inheritance of Objects through concepts of super-type and sub-type. Sub-type inherits all the properties of Super-type. Super-type can have multiple sub-types.

Following example shows "Library content" can be either "Book" or "Video CD". "Library content" is Super-type and "Book" and "Video CD" are sub-types.



Object Model

<!-- Library content-->
<item-descriptor name="libraryContent" sub-type-property="type">

  <table name="libraryContent" type="primary" id-column-names="id">
    <property name="type" data-type="enumerated">
      <option value="book"/>
      <option value="videoCD"/>
    </property>
    <property name="name"/>
    <property name="size"/>
    <property name="weight"/>
  </table>
</item-descriptor>

<!-- Book-->
<item-descriptor name="book" super-type="libraryContent" sub-type-value="book">
  <table name="book" type="auxiliary" id-column-names="id">
    <property name="pages"/>
  </table>
</item-descriptor>

<!-- Video CD-->
<item-descriptor name="videoCD" super-type="libraryContent" sub-type-value="videoCD">
  <table name="videoCD" type="auxiliary" id-column-names="id">
    <property name="duration"/>
  </table>
</item-descriptor>


Advantages
1. Most of properties from super-type can be reused in sub types.
2. This saves a lot of space in DB.




Secured Repository

Secured Repositories


The Oracle ATG Web Commerce secured repository system works in conjunction with the Oracle ATG Web Commerce Security System to provide fine-grained access control to repository item descriptors, individual repository items, and individual properties through Access Control List (ACL) settings.

Features:
•    Control access to repository item descriptors: Control who can create, add, remove, and query items defined by an item descriptor; similar to controlling access to a whole database table.
•    Control access to individual repository items: Control who can read, write, destroy, and query a repository item.; similar to controlling access to a single database row.
•    Control access to properties of all repository items in a repository item descriptor: Control who can read or write a property in any repository item defined by an item descriptor; similar to controlling access to a database table column.
•    Control access to properties of an individual repository item: Control who can read or write a particular property in a repository item; similar to controlling the field of a database table row.
•    Limit query results: Control who can receive repository items that are returned by a repository query.
•    Set ownership of a repository item: At creation time, the current user is assigned as the owner of the new repository item. The owner can query a repository item and modify its ACL; otherwise this is simply an association of an identity to an Item.
•    Automatically generate ACLs for new repository items: When a repository item is created, it is assigned an ACL that is constructed out of an ACL fragment and a template for the creator/owner (creator) and each group the owner belongs to.

Creating a Secured Repository
1.    Modify the Underlying Repository:
Add properties to the repository definition as follows

<item-descriptor name=”my”……………. >
….
<property name="item_owner" column-names="item_owner" data-type="string"/>
<property name="item_acl" column-names="item_acl" data-type="string"/>
<property name="secured_property_acl" column-names="secured_property_acl" data-type="string"/>
</item- descriptor>

2.    Configure the Secured Repository Adapter Component:

File name: SecuredMyRepository.properties
# SecuredMyRepository.properties
$class=atg.adapter.secure.GenericSecuredMutableRepository
$scope=global
name=My repository for the secured repository implementation
repositoryName=SecuredMyRepository
# the repository that we're wrapping
repository=MyRepository
# The template file that configures the repository
configurationFile=secured-My-repository.xml
# The security configuration component used by the repository
securityConfiguration=/atg/dynamo/security/SecuredRepositorySecurityConfiguration
# Various Dynamo services we need
XMLToolsFactory=/atg/dynamo/service/xml/XMLToolsFactory
transactionManager=/atg/dynamo/transaction/TransactionManager


3.    Register the Secured Repository Adapter Component:
/atg/registry/ContentRepositories

initialRepositories+=/MyRepository,/SecuredMyRepository

4.    Create the Secured Repository Definition File:
<!-- secured-my-repository.xml -->
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE secured-repository-template
 PUBLIC "-//Art Technology Group, Inc.//DTD Dynamo Security//EN"
 "http://www.atg.com/dtds/security/secured_repository_template_1.1.dtd">
<secured-repository-template>
 <item-descriptor name="my">

   <!-- The ACL that applies to the item view/descriptor -->
   <descriptor-acl value="Admin$role$administrators-group:
     read,write,create,delete;Admin$role$everyone-group:read"/>

   <!-- The property where the ownership is stored -->
   <owner-property name="item_owner"/>

   <!-- The property where ACL is stored in -->
   <acl-property name="item_acl"/>

   <!-- An ACL fragment that is assigned to all new items -->
   <creation-base-acl value="Admin$role$administrators-group:
      read,write,list,destroy,read_owner,write_owner,read_acl,write_acl;
      Admin$role$everyone-group:read,list"/>

   <!-- Access rights assigned to the owner when an item is created -->
   <creation-owner-acl-template value="$:read,write,list,destroy"/>

   <!-- Access rights assigned to all owner groups when an item is created. 
        WARNING: This feature can be dangerous. -->
   <creation-group-acl-template value="$:read,list"/>

   <property name="secured_property">
     <!-- The ACL that applies to this property across all repository items -->
     <descriptor-acl value="Admin$role$administrators-group:
        read,write;Admin$role$everyone-group:read"/>

     <!-- The name of the item property where this property's ACL is stored. -->
     <acl-property name="secured_property_acl"/>

     <!-- An ACL fragment assigned to this property when an item is created. -->
     <creation-base-acl value="Admin$role$administrators-group:read,write"/>

     <!-- Access rights assigned to the owner when an item is created -->
     <creation-owner-acl-template value="$:read,write"/>

     <!-- Access rights assigned to all owner groups when an item is created. 
          WARNING: This feature can be dangerous. -->
     <creation-group-acl-template value="$:read,write"/>

   </property>
 </item-descriptor>
</secured-repository-template>

5.    Modify the SQL for the Repository Data Store:
Add following columns to table.
item_owner varchar,
item_acl varchar,
secured_property_acl varchar

6.    Rebuild your EAR.

7.    Modify the Repository Mapping in Admin/Console to map SecuredMyRepository to both MyRepository_staging and MyRepository_production.

Versioning your Repository - Expert III

This part explains the versioning the DDL(SQL Scripts) used for creating the Tables.

Follow the following steps to change DDL(SQL Scripts).

Step 1: Remove the Foreign key references if any.

Step 2: Add following 7 columns to Primary table of RDF.

    asset_version         INTEGER NOT NULL,
    workspace_id         varchar2(40) NOT NULL,
    branch_id         varchar2(40) NOT NULL,
    is_head         number(1) NOT NULL,
    version_deleted     number(1) NOT NULL,
    version_editable     number(1) NOT NULL,
    pred_version         INTEGER NULL,
    checkin_date         TIMESTAMP NULL,
    CHECK (version_deleted IN (0, 1)),
    CHECK (version_editable IN (0, 1)),
    CHECK (is_head IN (0, 1))


Add  following single column to Auxiliary and Multi Table of RDF.

asset_version         INTEGER    NOT NULL

Step 3: Add asset_version to Primary, so you will have primary key as combination of existing primary key and asset_version.

Step 4: Remove the attribute "unique" from RDF. (ATG Suggests to do so. But I didn't find any harm in keeping the same).


Thus, you have versioned DDL for your RDF.

Versioning your Repository - Expert II

Step 6: Override the AssetResolver component.
Path: /atg/dynamo/service/AssetResolver

additionalAssetSources+=\
/my/
Library_production,\
/my/Address_production,\
/my/Library_staging,\
/my/Address_staging


Above added components appear in the Destination Repositories list in the Admin Console deployment.

Step 7: Override the VersionManagerService component.
Path: /atg/epub/version/VersionManagerService

versionedRepositories+=\
    Address=/my/Address,\
    Library=/my/Library

Above component manages and controls the versioning of assets.

Step 8: Override the ProductionRepositoryMapper component.
Path: /atg/repository/ProductionRepositoryMapper

repositoryMappings+=\
 
/my/Address=/my/Address_production,\
  /my/Library=/my/Library_production


This completes the versioning the repository through components. In next post, we will learn how to change the DDL's for Publishing Schema.

Versioning your Repository - Expert I

Versioning the Repository includes when you wants to manage the your repository items through BCC (Merchandising).

Follow the series of steps to register your repository in BCC.

Step 1: Place the RDF(Repository Defination File) in BCC Module.

Step 2: Place the Component file in BCC Module with following Contents in it.

Path: /my/Library.properties

$class=atg.adapter.gsa.GSARepositoryatg.adapter.version.VersionRepository
$scope=global
repositoryName=Library

# database access- for Publishing Schema, use JTDataSource
dataSource=/atg/dynamo/service/jdbc/SwitchingDataSourceJTDataSource
transactionManager=/atg/dynamo/transaction/TransactionManager

# our XML definitionFile
definitionFiles=/my/library.xml

# XML parsing
XMLToolsFactory=/atg/dynamo/service/xml/XMLToolsFactory

# id generation
idGenerator=/atg/dynamo/service/IdGenerator

#Add Following two.
versionManager=/atg/epub/version/VersionManagerService
versionItemsByDefault=true


Step 3: Create the Production and Staging Components (Staging not needed, if you have only Production Workflow)

Path: /my/Library_production.properties

$class=atg.adapter.gsa.GSARepository
$scope=global
repositoryName=Library_production

# database access- use SwitchingDataSource
dataSource=/atg/dynamo/service/jdbc/SwitchingDataSource
transactionManager=/atg/dynamo/transaction/TransactionManager

# our XML definitionFile
definitionFiles=/my/library.xml

# XML parsing
XMLToolsFactory=/atg/dynamo/service/xml/XMLToolsFactory

# id generation
idGenerator=/atg/dynamo/service/IdGenerator

lockManager=/atg/dynamo/service/ClientLockManager_production
foreignRepositoryMapper=/atg/repository/ProductionRepositoryMapper


Path: /my/Library_staging.properties

$class=atg.adapter.gsa.GSARepository
$scope=global
repositoryName=Library_staging

# database access- use JTDataSource_staging
dataSource=/atg/dynamo/service/jdbc/JTDataSource_staging
transactionManager=/atg/dynamo/transaction/TransactionManager

# our XML definitionFile
definitionFiles=/my/library.xml

# XML parsing
XMLToolsFactory=/atg/dynamo/service/xml/XMLToolsFactory

# id generation
idGenerator=/atg/dynamo/service/IdGenerator

lockManager=/atg/dynamo/service/ClientLockManager_staging



Step 4: Override the ContentRepositories component.

/atg/registry/ContentRepositories

Step 5: Add your custom repositories to ContentRepositories component.



initialRepositories+=/my/Address,\
                              /my/Library
 

DisplayNames, sorting and Grouping- InterMediate II

Display Names using the Resource Bundle (Localising the Labels).

Define resource bundle using following attribute.
    <attribute name="resourceBundle" value="resourceBundleName"/>

ex: <attribute name="resourceBundle" value="my.Resource"/>

Localising the values can be applied at
  • Item-descriptor
  • Property
Labels that can be localised using resource bundle are
  • display-name ( to display-name-resource)
  • description ( to description-resource)
  • category ( to category-resource)
Item-descriptor <item-descriptor name="author" display-name-resource="author" >
<attribute name="resourceBundle" value="my.Resource"/>
.
.
.
</item-descriptor> 


Property
<property name="firstName" column-name="first_name" display-name-resource="firstName" data-type="string"/>
 <attribute name="resourceBundle" value="my.Resource"/>
</property> 

And Resource file would contain following content.
author=Author
firstName=First Name


Grouping Properties and Sorting them in groups.

Properties under each Item-descriptor can be grouped together using "category" attribute at property level.Category attribute can be localised using resource bundle.

<table name="BOOK_MASTER" type="primary" id-column-name="book_id">
        <property name="id" column-name="book_id"/>
        <property name="name" column-name="name" display-name="name" data-type="string" category="basics"/>
        <property name="description" column-name="description" display-name="description" data-type="big string"
category="basics"/>
        <property name="price" column-name="price" display-name="price" data-type="double"
category="additionalInfo"/>
        <property name="pages" column-name="pages" display-name="pages" data-type="int" category="additionalInfo"/>
       <property name="available" column-name="available" display-name="available" data-type="boolean" category="additionalInfo"/>
    </table>


In the above example, properties "name" and "description" are grouped under "Basics" category, and properties "price" , "pages" and "available" are under "AdditionalInfo" category.


Adding resource Bundle to category.
<property name="name" column-name="name" display-name="name" data-type="string" category-resource="basics">
 <attribute name="resourceBundle" value="my.Resource"/>
</property> 


And Resource file contains the value for basics.

To sort the properties under category, use the attribute "propertySortPriority" with value. Depending on the value(-ve to +ve), properties will be sorted. If not provided, will be sorted alphabetically. 

<property name="name" column-name="name" display-name="name" data-type="string" category-resource="basics">




<attribute name="resourceBundle" value="my.Resource"/>
 <attribute name="propertySortPriority" value="0"/>
</property>
 <property name="description" column-name="description" display-name="description" data-type="big string" category-resource="basics">
 <attribute name="resourceBundle" value="my.Resource"/>
  <attribute name="propertySortPriority" value="1"/>
</property>

In above example, property "name" would appear above property "description".

Where are display-names, grouping and sorting comes to help?

Ans: When viewing Items in BCC, ACC. 

Initialising your Repository to ATG Module - InterMediate I

To initialise your repository to ATG Module(Assuming that your ATG Module requires DAS DPS DSS DCS,

Step 1: Override the ContentRepositories component.

/atg/registry/ContentRepositories

Step 2: Add your custom repositories to ContentRepositories component.

initialRepositories+=/my/Address,\
                              /my/Library

If your repository uses Switching Data Soruce, Repository component would be up after SDS(Switching Data Source) component is up.


Using the StartSQLRepository - Beginners IV

StartSQLRepository can be used for following activites,
  1. Verifing the Data Defination XML is correctly formed and complies with the DTD.
  2. Generating the SQL Statements to create tables.
  3. Import the data into DB (Supports both versioned and non-versioned) and exporting the data.
Points 1 and 2 are covered as part of scope. Point 3 will be covered in coming up topics.

Steps for generating DDL using the  StartSQLRepository.


1.    Shut down all the nucleus instances running in machine.(JBOSS, JUNIT)
2.    Create the following folder structure(if not present).
                       <DYNAMO_HOME>\home\localconfig\atg\dynamo\service\jdbc
3.    Create JTDataSource.properties under jdbc folder and place the following content into file.
                        dataSource=/atg/dynamo/service/jdbc/FakeXADataSource
4.    Create FakeXADataSource.properties under jdbc folder and place the following content into file.
$class=atg.service.jdbc.FakeXADataSource
#Below contents vary according the DB
driver=oracle.jdbc.OracleDriver
URL=jdbc:oracle:thin:@<host>:<port>:<SID>
user=my_core
password=my_core

    Above contents can vary according to which DB, you want to refer.

5.    In the Component of your defination file, change the "datasource" to new path(applicable only if your repository was going to be versioned repository).
             dataSource=/atg/dynamo/service/jdbc/JTDataSource

6.   If your repository refers to any OOTB repository, override the OOTB component in <DYNAMO_HOME>\home\localconfig. And provide the "datasoruce"


            dataSource=/atg/dynamo/service/jdbc/JTDataSource

7.   User in FakeXADataSource.properties will be core database if its non-versioned database, else it would be one of switch DB.

8.    Run the startSQLRepository command from <DYNAMO_HOME>\home\bin
   startSQLRepository -m Module_name –repository RepositoryComponentPath -outputSQLFile Path of SQL FILE.

Ex: startSQLRepository -m MyStore -repository /my/Library -outputSQLFile c:\test.sql

P.S : startSQLRepository can be executed using the –server attribute and passing server instance of <DYNAMO_HOME>\home\bin. But servers should contain the above files.


 

Creating your own ATG Repository - Beginners- III

We will be covering the Multi Table, referencing other repositories and One to Many relation in between same repository.

Must read Points:
1. Multi table is used to maintain one to Many relations between Items.
2. Multi table can hold Map, List or Set of items.
3. One item-descriptor can hold N number of Multi tables.

Simple Table below explains concepts of Map, List and Set.


Type\Conditions
Data-type=
multi-column-name=
Set
“set”
Not Required
List
“list”
Seq_number of type “int”(acts as sequence)
Map
“map”
String which acts as key

4. component-item-type if multi valued property needs to be referenced, else component-data-type.
5. id-column-name should be same of primary table.

Step 1: Analyse the Table and data-type.



We will be using "set" to store the Books.

Step 2: Add the Multi column to "author" item.

<item-descriptor name="author" display-name="author" >
   
    <table name="AUTHOR_MASTER" type="primary" id-column-name="author_id">
    ........
    </table>
   
    <table name="AUTHOR_BOOKS" type="multi" id-column-names="author_id">
        <property name="books" column-names="book" display-name="books" data-type="set" component-item-type="book"/>
    </table>
</item-descriptor>

Step 3: Author has primary address, which references to Address Repository.




We will add one more column to primary table of "author" item and reference to Address Repository.

Step 4: Add column to Primary table of "author" item and reference.

<table name="AUTHOR_MASTER" type="primary" id-column-name="author_id">
    ........
    <property name="address" column-names="address" display-name="address" item-type="address" repository="/my/Address"/>
    </table>


repository will hold the referenced repository's Component Path.