Enabling Assets at the Service Layer

Enabling Assets at the Service Layer
Step 1 of 3

Each row in the AssetEntry table represents an asset and has an entryId primary key, and classNameId and classPK foreign keys. The classNameId specifies the asset’s type. For example, an asset with a classNameId of JournalArticle means that the asset represents a web content article (in Liferay DXP, JournalArticle is the back-end name for a web content article). An asset’s classPK is the primary key of the entity represented by the asset.

Follow these steps to make Liferay DXP’s asset services available to your entities’ service layers:

  1. In the guestbook-service module’s service.xml file, add the following references directly above the closing </entity> tags for Guestbook and Entry:

    <reference package-path="com.liferay.portlet.asset" entity="AssetEntry" />
    <reference package-path="com.liferay.portlet.asset" entity="AssetLink" />
    

    As mentioned above, you must use Liferay DXP’s AssetEntry service for your application to add asset entries that correspond to guestbooks and guestbook entries. You also use Liferay DXP’s AssetLink service for your application to support related assets. Asset links are Liferay DXP’s back-end term for related assets.

  2. You must add finders–two for Guestbooks and two for Entitys–so your assets show in Asset Publisher. Add these below the existing finders for the Guestbook entity:

    <finder name="Status" return-type="Collection">
    	<finder-column name="status" />
    </finder>
    
    <finder name="G_S" return-type="Collection">
    	<finder-column name="groupId" />
    	<finder-column name="status" />
    </finder>
    

    Add these below the existing finders for the Entry entity:

    <finder name="Status" return-type="Collection">
    	<finder-column name="status" />
    </finder>
    <finder name="G_S" return-type="Collection">
    	<finder-column name="groupId" />
    	<finder-column name="status" />
    </finder>
    
  3. Right-click build.gradle and select GradleRefresh Gradle Project.

  4. Run the buildService Gradle task. This task causes the objects referenced above to be injected into your services for use.

Great! Next, you’ll handle assets in your service layer.

« Assets: Integrating with Liferay's FrameworkHandling Assets at the Guestbook Service Layer »
Was this article helpful?
0 out of 0 found this helpful