use of com.liferay.portlet.asset.model.AssetEntry in project liferay-ide by liferay.
the class KBArticleLocalServiceImpl method updateKBArticleAsset.
@Override
public void updateKBArticleAsset(long userId, KBArticle kbArticle, long[] assetCategoryIds, String[] assetTagNames, long[] assetLinkEntryIds) throws PortalException, SystemException {
// TODO
long classTypeId = 0;
AssetEntry assetEntry = assetEntryLocalService.updateEntry(userId, kbArticle.getGroupId(), kbArticle.getCreateDate(), kbArticle.getModifiedDate(), KBArticle.class.getName(), kbArticle.getClassPK(), kbArticle.getUuid(), classTypeId, assetCategoryIds, assetTagNames, false, null, null, null, ContentTypes.TEXT_HTML, kbArticle.getTitle(), kbArticle.getDescription(), null, null, null, 0, 0, null, false);
assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), assetLinkEntryIds, AssetLinkConstants.TYPE_RELATED);
}
use of com.liferay.portlet.asset.model.AssetEntry in project liferay-ide by liferay.
the class AlbumLocalServiceImpl method updateAsset.
public void updateAsset(long userId, Album album, long[] assetCategoryIds, String[] assetTagNames, long[] assetLinkEntryIds) throws PortalException, SystemException {
AssetEntry assetEntry = assetEntryLocalService.updateEntry(userId, album.getGroupId(), album.getCreateDate(), album.getModifiedDate(), Album.class.getName(), album.getAlbumId(), album.getUuid(), 0, assetCategoryIds, assetTagNames, true, null, null, null, ContentTypes.TEXT_HTML, album.getName(), null, null, null, null, 0, 0, null, false);
assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), assetLinkEntryIds, AssetLinkConstants.TYPE_RELATED);
}
use of com.liferay.portlet.asset.model.AssetEntry in project liferay-ide by liferay.
the class KBArticleAssetEntriesUtil method getAssetEntries.
public static List<AssetEntry> getAssetEntries(long[] groupIds, long[] classNameIds, long[] assetTagIds, long resourcePrimKey, int start, int end, String orderByColumn) throws PortalException, SystemException {
AssetEntryQuery assetEntryQuery = new AssetEntryQuery();
assetEntryQuery.setAnyTagIds(assetTagIds);
assetEntryQuery.setClassNameIds(classNameIds);
assetEntryQuery.setEnd(end + 1);
assetEntryQuery.setGroupIds(groupIds);
assetEntryQuery.setOrderByCol1(orderByColumn);
assetEntryQuery.setStart(start);
List<AssetEntry> assetEntries = ListUtil.copy(AssetEntryServiceUtil.getEntries(assetEntryQuery));
AssetEntry assetEntry = null;
for (AssetEntry curAssetEntry : assetEntries) {
if (curAssetEntry.getClassPK() == resourcePrimKey) {
assetEntry = curAssetEntry;
}
}
assetEntries.remove(assetEntry);
return ListUtil.subList(assetEntries, 0, 10);
}
use of com.liferay.portlet.asset.model.AssetEntry in project liferay-ide by liferay.
the class KBArticleLocalServiceImpl method updateStatus.
@Override
public KBArticle updateStatus(long userId, long resourcePrimKey, int status, ServiceContext serviceContext) throws PortalException, SystemException {
// KB article
User user = userPersistence.findByPrimaryKey(userId);
boolean main = false;
Date now = new Date();
if (status == WorkflowConstants.STATUS_APPROVED) {
main = true;
}
KBArticle kbArticle = getLatestKBArticle(resourcePrimKey, WorkflowConstants.STATUS_ANY);
kbArticle.setModifiedDate(serviceContext.getModifiedDate(now));
kbArticle.setMain(main);
kbArticle.setStatus(status);
kbArticle.setStatusByUserId(user.getUserId());
kbArticle.setStatusByUserName(user.getFullName());
kbArticle.setStatusDate(serviceContext.getModifiedDate(now));
kbArticlePersistence.update(kbArticle);
if (status != WorkflowConstants.STATUS_APPROVED) {
return kbArticle;
}
if (!kbArticle.isFirstVersion()) {
KBArticle oldKBArticle = kbArticlePersistence.findByR_V(resourcePrimKey, kbArticle.getVersion() - 1);
oldKBArticle.setMain(false);
kbArticlePersistence.update(oldKBArticle);
}
// Asset
AssetEntry assetEntry = assetEntryLocalService.getEntry(KBArticle.class.getName(), kbArticle.getKbArticleId());
List<AssetLink> assetLinks = assetLinkLocalService.getDirectLinks(assetEntry.getEntryId(), AssetLinkConstants.TYPE_RELATED);
long[] assetLinkEntryIds = StringUtil.split(ListUtil.toString(assetLinks, AssetLink.ENTRY_ID2_ACCESSOR), 0L);
updateKBArticleAsset(userId, kbArticle, assetEntry.getCategoryIds(), assetEntry.getTagNames(), assetLinkEntryIds);
SystemEventHierarchyEntryThreadLocal.push(KBArticle.class);
try {
assetEntryLocalService.deleteEntry(KBArticle.class.getName(), kbArticle.getKbArticleId());
} finally {
SystemEventHierarchyEntryThreadLocal.pop(KBArticle.class);
}
assetEntryLocalService.updateVisible(KBArticle.class.getName(), kbArticle.getResourcePrimKey(), true);
// Social
JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject();
extraDataJSONObject.put("title", kbArticle.getTitle());
if (!kbArticle.isFirstVersion()) {
socialActivityLocalService.addActivity(userId, kbArticle.getGroupId(), KBArticle.class.getName(), resourcePrimKey, AdminActivityKeys.UPDATE_KB_ARTICLE, extraDataJSONObject.toString(), 0);
} else {
socialActivityLocalService.addActivity(userId, kbArticle.getGroupId(), KBArticle.class.getName(), resourcePrimKey, AdminActivityKeys.ADD_KB_ARTICLE, extraDataJSONObject.toString(), 0);
}
// Indexer
Indexer indexer = IndexerRegistryUtil.getIndexer(KBArticle.class);
indexer.reindex(kbArticle);
// Subscriptions
notifySubscribers(kbArticle, serviceContext);
return kbArticle;
}
use of com.liferay.portlet.asset.model.AssetEntry in project liferay-ide by liferay.
the class ArtistLocalServiceImpl method updateAsset.
public void updateAsset(long userId, Artist artist, long[] assetCategoryIds, String[] assetTagNames, long[] assetLinkEntryIds) throws PortalException, SystemException {
AssetEntry assetEntry = assetEntryLocalService.updateEntry(userId, artist.getGroupId(), artist.getCreateDate(), artist.getModifiedDate(), Artist.class.getName(), artist.getArtistId(), artist.getUuid(), 0, assetCategoryIds, assetTagNames, true, null, null, null, ContentTypes.TEXT_HTML, artist.getName(), null, null, null, null, 0, 0, null, false);
assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), assetLinkEntryIds, AssetLinkConstants.TYPE_RELATED);
}
Aggregations