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:
-
In the
guestbook-service
module’sservice.xml
file, add the following references directly above the closing</entity>
tags forGuestbook
andEntry
:<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’sAssetLink
service for your application to support related assets. Asset links are Liferay DXP’s back-end term for related assets. -
You must add finders–two for
Guestbook
s and two forEntity
s–so your assets show in Asset Publisher. Add these below the existing finders for theGuestbook
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>
-
Right-click
build.gradle
and select Gradle → Refresh Gradle Project. -
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.