I would like to ask if there is any Java API call in liferay which returns the web contents, which were uploaded by a specific user.
For example, I have one user who has upload some content and I want to show in a portlet this content, how can I do this via java?
If you are specifically talking about web-content which is displayed inside
Web-content Display
portlet, then you can use theJournalArticleService
andJournalArticleLocalService
API to fetch the content depending upon the User.Prior to Liferay 6.0 Web-content was known as
JournalArticle
and hence the API name has not changed.So for example:
You can use
DynamicQuery
API, as follows:The above code will retrieve all the
JournalArticle
s so you would get all the versions of a single web-content since all these versions are stored in the sameJournalArticle
table. So for this you can add conditions to thedynamicQuery
for the fields likeversion
,id
,resourcePrimKey
,articleId
,groupId
,companyId
etc.Or if you have more complex needs than you can create a custom-sql-finder in liferay to fetch the desired data from any combination of Liferay DB tables.
If you are talking about contents as in Blogs, Wikis, Files, Webcontents etc then either use their respective
*LocalServiceUtil
or you can useAssetEntryLocalServiceUtil
to fetch the assets for a particular User.So with
AssetEntryLocalServiceUtil
also you can use theDynamicQuery
API as shown above. The code may not be same but will be along the same lines.You can know more about
DynamicQuery
API from this blog.