The Repository is a central interface that provides access to censhare assets. Assets are presented as logical model instances, the mapping to the “legacy” data model of the persistence layer is handled transparently.

Simple read access for single assets is handled transparently by the AssetRef.get() differencing call. Internally this uses the Repository to access the asset and build a logical model instance.

In some cases the direct use of the Repository is recommended, for instance to load a set of assets efficiently:

Repository repo = Platform.getCCService(Repository.class);
Iterable<Asset> assets = repo.buildAssetsByRefs(Arrays.asList(ref1, ref2, ref3));

Read access to resource assets referenced by resource key is available through the Repository.getResourceAsset(AssetRef key)and the Repository.getResourceAssetByResourceKey(String key). Note that the access to these resources is governed by a different set of permissions than the normal assets.

The Repository also encapsulates the write access to assets which are handled through a surrounding Atomic instance. In this case an UpdatingRepository instance is required:

UpdatingRepository repo = Platform.getCCService(UpdatingRepository.class);
AtomicRef atomicRef = repo.createNew("Name of new asset", AssetType.TEXT);
Asset newAsset = atomicRef.get();
atomicRef.checkInNew(newAsset);

A simple update on an asset is triggered through the AssetRef.set().
Some other write access methods are:

  • checkOut()
  • checkOutInside()

Additionally, data objects (instances of DataObject) from the master data tables can be retrieved and updated through getDataObject(DataObjectKey<T> key) and setDataObject (DataObject dto).