Enabling Assets at the Service Layer
Step 1 of 3
Each row in the
AssetEntry table represents an asset. It has an
primary key along with
classPK foreign keys. The
classNameId specifies the asset’s type. For example, an asset with
JournalArticle means that the asset represents a web
content article (
JournalArticle is the back-end name for a web content
article). An asset’s
classPK is the primary key of the entity represented by
Follow these steps to make asset services available to your entities’ service layers:
service.xmlfile, add the following references directly above the closing
<reference package-path="com.liferay.portlet.asset" entity="AssetEntry" /> <reference package-path="com.liferay.portlet.asset" entity="AssetLink" />
As mentioned above, you must use the
AssetEntryservice so your application can add asset entries corresponding to guestbooks and guestbook entries. You also use the
AssetLinkservice to support related assets. Asset links are Liferay DXP’s back-end term for related assets.
You must add finders—two for
Guestbooks and two for
Entitys—so your assets show in Asset Publisher, because it searches for entities by
status(i.e., is it Workflow-approved?) and by
groupId(i.e., is it in this Site?). Add these below the existing finders for the
<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>
buildServiceGradle task. This task injects the objects referenced above into your services for use.
build.gradleand select Gradle → Refresh Gradle Project.
Great! Next, you’ll handle assets in your service layer.