1
22
23 package com.liferay.portlet.tags.service.impl;
24
25 import com.liferay.portal.PortalException;
26 import com.liferay.portal.SystemException;
27 import com.liferay.portal.kernel.dao.orm.QueryUtil;
28 import com.liferay.portal.kernel.log.Log;
29 import com.liferay.portal.kernel.log.LogFactoryUtil;
30 import com.liferay.portal.kernel.search.BooleanClauseOccur;
31 import com.liferay.portal.kernel.search.BooleanQuery;
32 import com.liferay.portal.kernel.search.BooleanQueryFactoryUtil;
33 import com.liferay.portal.kernel.search.Document;
34 import com.liferay.portal.kernel.search.Field;
35 import com.liferay.portal.kernel.search.Hits;
36 import com.liferay.portal.kernel.search.SearchEngineUtil;
37 import com.liferay.portal.kernel.search.TermQuery;
38 import com.liferay.portal.kernel.search.TermQueryFactoryUtil;
39 import com.liferay.portal.kernel.util.GetterUtil;
40 import com.liferay.portal.kernel.util.InstancePool;
41 import com.liferay.portal.kernel.util.ListUtil;
42 import com.liferay.portal.kernel.util.StringPool;
43 import com.liferay.portal.kernel.util.StringUtil;
44 import com.liferay.portal.kernel.util.Validator;
45 import com.liferay.portal.model.User;
46 import com.liferay.portal.util.PortalInstances;
47 import com.liferay.portal.util.PortalUtil;
48 import com.liferay.portal.util.PortletKeys;
49 import com.liferay.portal.util.PropsValues;
50 import com.liferay.portlet.blogs.model.BlogsEntry;
51 import com.liferay.portlet.bookmarks.model.BookmarksEntry;
52 import com.liferay.portlet.documentlibrary.model.DLFileEntry;
53 import com.liferay.portlet.imagegallery.model.IGImage;
54 import com.liferay.portlet.journal.model.JournalArticle;
55 import com.liferay.portlet.messageboards.model.MBMessage;
56 import com.liferay.portlet.tags.model.TagsAsset;
57 import com.liferay.portlet.tags.model.TagsAssetDisplay;
58 import com.liferay.portlet.tags.model.TagsAssetType;
59 import com.liferay.portlet.tags.model.TagsEntry;
60 import com.liferay.portlet.tags.service.base.TagsAssetLocalServiceBaseImpl;
61 import com.liferay.portlet.tags.util.TagsAssetValidator;
62 import com.liferay.portlet.tags.util.TagsUtil;
63 import com.liferay.portlet.wiki.model.WikiPage;
64
65 import java.util.ArrayList;
66 import java.util.Date;
67 import java.util.List;
68
69
74 public class TagsAssetLocalServiceImpl extends TagsAssetLocalServiceBaseImpl {
75
76 public void deleteAsset(long assetId)
77 throws PortalException, SystemException {
78
79 TagsAsset asset = tagsAssetPersistence.findByPrimaryKey(assetId);
80
81 deleteAsset(asset);
82 }
83
84 public void deleteAsset(String className, long classPK)
85 throws SystemException {
86
87 long classNameId = PortalUtil.getClassNameId(className);
88
89 TagsAsset asset = tagsAssetPersistence.fetchByC_C(classNameId, classPK);
90
91 if (asset != null) {
92 deleteAsset(asset);
93 }
94 }
95
96 public void deleteAsset(TagsAsset asset) throws SystemException {
97 tagsAssetPersistence.remove(asset);
98 }
99
100 public TagsAsset getAsset(long assetId)
101 throws PortalException, SystemException {
102
103 return tagsAssetPersistence.findByPrimaryKey(assetId);
104 }
105
106 public TagsAsset getAsset(String className, long classPK)
107 throws PortalException, SystemException {
108
109 long classNameId = PortalUtil.getClassNameId(className);
110
111 return tagsAssetPersistence.findByC_C(classNameId, classPK);
112 }
113
114 public TagsAssetType[] getAssetTypes(String languageId) {
115 TagsAssetType[] assetTypes =
116 new TagsAssetType[TagsUtil.ASSET_TYPE_CLASS_NAMES.length];
117
118 for (int i = 0; i < TagsUtil.ASSET_TYPE_CLASS_NAMES.length; i++) {
119 assetTypes[i] = getAssetType(
120 TagsUtil.ASSET_TYPE_CLASS_NAMES[i], languageId);
121 }
122
123 return assetTypes;
124 }
125
126 public List<TagsAsset> getAssets(
127 long[] entryIds, long[] notEntryIds, boolean andOperator,
128 boolean excludeZeroViewCount, int start, int end)
129 throws SystemException {
130
131 return getAssets(
132 0, new long[0], entryIds, notEntryIds, andOperator,
133 excludeZeroViewCount, null, null, start, end);
134 }
135
136 public List<TagsAsset> getAssets(
137 long groupId, long[] classNameIds, long[] entryIds,
138 long[] notEntryIds, boolean andOperator,
139 boolean excludeZeroViewCount, int start, int end)
140 throws SystemException {
141
142 return getAssets(
143 groupId, classNameIds, entryIds, notEntryIds, andOperator,
144 excludeZeroViewCount, null, null, start, end);
145 }
146
147 public List<TagsAsset> getAssets(
148 long[] entryIds, long[] notEntryIds, boolean andOperator,
149 boolean excludeZeroViewCount, Date publishDate, Date expirationDate,
150 int start, int end)
151 throws SystemException {
152
153 return getAssets(
154 0, new long[0], entryIds, notEntryIds, andOperator,
155 excludeZeroViewCount, publishDate, expirationDate, start, end);
156 }
157
158 public List<TagsAsset> getAssets(
159 long groupId, long[] classNameIds, long[] entryIds,
160 long[] notEntryIds, boolean andOperator,
161 boolean excludeZeroViewCount, Date publishDate, Date expirationDate,
162 int start, int end)
163 throws SystemException {
164
165 if ((entryIds.length == 0) && (notEntryIds.length == 0)) {
166 return tagsAssetFinder.findAssets(
167 groupId, classNameIds, null, null, null, null,
168 excludeZeroViewCount, publishDate, expirationDate, start, end);
169 }
170 else if (andOperator) {
171 return tagsAssetFinder.findByAndEntryIds(
172 groupId, classNameIds, entryIds, notEntryIds, null, null, null,
173 null, excludeZeroViewCount, publishDate, expirationDate, start,
174 end);
175 }
176 else {
177 return tagsAssetFinder.findByOrEntryIds(
178 groupId, classNameIds, entryIds, notEntryIds, null, null, null,
179 null, excludeZeroViewCount, publishDate, expirationDate, start,
180 end);
181 }
182 }
183
184 public List<TagsAsset> getAssets(
185 long[] entryIds, long[] notEntryIds, boolean andOperator,
186 String orderByCol1, String orderByCol2, String orderByType1,
187 String orderByType2, boolean excludeZeroViewCount, Date publishDate,
188 Date expirationDate, int start, int end)
189 throws SystemException {
190
191 return getAssets(
192 0, new long[0], entryIds, notEntryIds, andOperator,
193 excludeZeroViewCount, publishDate, expirationDate, start, end);
194 }
195
196 public List<TagsAsset> getAssets(
197 long groupId, long[] classNameIds, long[] entryIds,
198 long[] notEntryIds, boolean andOperator, String orderByCol1,
199 String orderByCol2, String orderByType1, String orderByType2,
200 boolean excludeZeroViewCount, Date publishDate, Date expirationDate,
201 int start, int end)
202 throws SystemException {
203
204 if ((entryIds.length == 0) && (notEntryIds.length == 0)) {
205 return tagsAssetFinder.findAssets(
206 groupId, classNameIds, orderByCol1, orderByCol2, orderByType1,
207 orderByType2, excludeZeroViewCount, publishDate, expirationDate,
208 start, end);
209 }
210 else if (andOperator) {
211 return tagsAssetFinder.findByAndEntryIds(
212 groupId, classNameIds, entryIds, notEntryIds, orderByCol1,
213 orderByCol2, orderByType1, orderByType2, excludeZeroViewCount,
214 publishDate, expirationDate, start, end);
215 }
216 else {
217 return tagsAssetFinder.findByOrEntryIds(
218 groupId, classNameIds, entryIds, notEntryIds, orderByCol1,
219 orderByCol2, orderByType1, orderByType2, excludeZeroViewCount,
220 publishDate, expirationDate, start, end);
221 }
222 }
223
224 public int getAssetsCount(
225 long[] entryIds, long[] notEntryIds, boolean andOperator,
226 boolean excludeZeroViewCount)
227 throws SystemException {
228
229 return getAssetsCount(
230 0, new long[0], entryIds, notEntryIds, andOperator,
231 excludeZeroViewCount, null, null);
232 }
233
234 public int getAssetsCount(
235 long groupId, long[] entryIds, long[] notEntryIds,
236 boolean andOperator, boolean excludeZeroViewCount)
237 throws SystemException {
238
239 return getAssetsCount(
240 groupId, new long[0], entryIds, notEntryIds, andOperator,
241 excludeZeroViewCount, null, null);
242 }
243
244 public int getAssetsCount(
245 long[] entryIds, long[] notEntryIds, boolean andOperator,
246 boolean excludeZeroViewCount, Date publishDate, Date expirationDate)
247 throws SystemException {
248
249 return getAssetsCount(
250 0, new long[0], entryIds, notEntryIds, andOperator,
251 excludeZeroViewCount, publishDate, expirationDate);
252 }
253
254 public int getAssetsCount(
255 long groupId, long[] classNameIds, long[] entryIds,
256 long[] notEntryIds, boolean andOperator,
257 boolean excludeZeroViewCount, Date publishDate, Date expirationDate)
258 throws SystemException {
259
260 if ((entryIds.length == 0) && (notEntryIds.length == 0)) {
261 return tagsAssetFinder.countAssets(
262 groupId, classNameIds, excludeZeroViewCount, publishDate,
263 expirationDate);
264 }
265 else if (andOperator) {
266 return tagsAssetFinder.countByAndEntryIds(
267 groupId, classNameIds, entryIds, notEntryIds,
268 excludeZeroViewCount, publishDate, expirationDate);
269 }
270 else {
271 return tagsAssetFinder.countByOrEntryIds(
272 groupId, classNameIds, entryIds, notEntryIds,
273 excludeZeroViewCount, publishDate, expirationDate);
274 }
275 }
276
277 public TagsAssetDisplay[] getCompanyAssetDisplays(
278 long companyId, int start, int end, String languageId)
279 throws SystemException {
280
281 return getAssetDisplays(
282 getCompanyAssets(companyId, start, end), languageId);
283 }
284
285 public List<TagsAsset> getCompanyAssets(long companyId, int start, int end)
286 throws SystemException {
287
288 return tagsAssetPersistence.findByCompanyId(companyId, start, end);
289 }
290
291 public int getCompanyAssetsCount(long companyId) throws SystemException {
292 return tagsAssetPersistence.countByCompanyId(companyId);
293 }
294
295 public List<TagsAsset> getTopViewedAssets(
296 String className, boolean asc, int start, int end)
297 throws SystemException {
298
299 return getTopViewedAssets(new String[] {className}, asc, start, end);
300 }
301
302 public List<TagsAsset> getTopViewedAssets(
303 String[] className, boolean asc, int start, int end)
304 throws SystemException {
305
306 long[] classNameIds = new long[className.length];
307
308 for (int i = 0; i < className.length; i++) {
309 classNameIds[i] = PortalUtil.getClassNameId(className[i]);
310 }
311
312 return tagsAssetFinder.findByViewCount(classNameIds, asc, start, end);
313 }
314
315 public TagsAsset incrementViewCounter(String className, long classPK)
316 throws SystemException {
317
318 if (classPK <= 0) {
319 return null;
320 }
321
322 long classNameId = PortalUtil.getClassNameId(className);
323
324 TagsAsset asset = tagsAssetPersistence.fetchByC_C(classNameId, classPK);
325
326 if (asset != null) {
327 asset.setViewCount(asset.getViewCount() + 1);
328
329 tagsAssetPersistence.update(asset, false);
330 }
331
332 return asset;
333 }
334
335 public Hits search(
336 long companyId, String portletId, String keywords, int start,
337 int end)
338 throws SystemException {
339
340 try {
341 BooleanQuery contextQuery = BooleanQueryFactoryUtil.create();
342
343 if (Validator.isNotNull(portletId)) {
344 contextQuery.addRequiredTerm(Field.PORTLET_ID, portletId);
345 }
346 else {
347 BooleanQuery portletIdsQuery = BooleanQueryFactoryUtil.create();
348
349 for (String assetTypePortletId :
350 TagsUtil.ASSET_TYPE_PORTLET_IDS) {
351
352 TermQuery termQuery = TermQueryFactoryUtil.create(
353 Field.PORTLET_ID, assetTypePortletId);
354
355 portletIdsQuery.add(termQuery, BooleanClauseOccur.SHOULD);
356 }
357
358 contextQuery.add(portletIdsQuery, BooleanClauseOccur.MUST);
359 }
360
361 BooleanQuery searchQuery = BooleanQueryFactoryUtil.create();
362
363 if (Validator.isNotNull(keywords)) {
364 searchQuery.addTerm(Field.TITLE, keywords);
365 searchQuery.addTerm(Field.CONTENT, keywords);
366 searchQuery.addTerm(Field.DESCRIPTION, keywords);
367 searchQuery.addTerm(Field.PROPERTIES, keywords);
368 searchQuery.addTerm(Field.TAGS_ENTRIES, keywords, true);
369 }
370
371 BooleanQuery fullQuery = BooleanQueryFactoryUtil.create();
372
373 fullQuery.add(contextQuery, BooleanClauseOccur.MUST);
374
375 if (searchQuery.clauses().size() > 0) {
376 fullQuery.add(searchQuery, BooleanClauseOccur.MUST);
377 }
378
379 return SearchEngineUtil.search(companyId, fullQuery, start, end);
380 }
381 catch (Exception e) {
382 throw new SystemException(e);
383 }
384 }
385
386 public TagsAssetDisplay[] searchAssetDisplays(
387 long companyId, String portletId, String keywords,
388 String languageId, int start, int end)
389 throws SystemException {
390
391 List<TagsAsset> assets = new ArrayList<TagsAsset>();
392
393 Hits hits = search(companyId, portletId, keywords, start, end);
394
395 List<Document> hitsList = hits.toList();
396
397 for (Document doc : hitsList) {
398 try {
399 TagsAsset asset = getAsset(doc);
400
401 if (asset != null) {
402 assets.add(asset);
403 }
404 }
405 catch (Exception e) {
406 if (_log.isWarnEnabled()) {
407 _log.warn(e);
408 }
409 }
410 }
411
412 return getAssetDisplays(assets, languageId);
413 }
414
415 public int searchAssetDisplaysCount(
416 long companyId, String portletId, String keywords,
417 String languageId)
418 throws SystemException {
419
420 Hits hits = search(
421 companyId, portletId, keywords, QueryUtil.ALL_POS,
422 QueryUtil.ALL_POS);
423
424 return hits.getLength();
425 }
426
427 public TagsAsset updateAsset(
428 long userId, long groupId, String className, long classPK,
429 String[] entryNames)
430 throws PortalException, SystemException {
431
432 return updateAsset(
433 userId, groupId, className, classPK, entryNames, null, null, null,
434 null, null, null, null, null, null, 0, 0, null);
435 }
436
437 public TagsAsset updateAsset(
438 long userId, long groupId, String className, long classPK,
439 String[] entryNames, Date startDate, Date endDate, Date publishDate,
440 Date expirationDate, String mimeType, String title,
441 String description, String summary, String url, int height,
442 int width, Integer priority)
443 throws PortalException, SystemException {
444
445 return updateAsset(
446 userId, groupId, className, classPK, entryNames, startDate,
447 endDate, publishDate, expirationDate, mimeType, title, description,
448 summary, url, height, width, priority, true);
449 }
450
451 public TagsAsset updateAsset(
452 long userId, long groupId, String className, long classPK,
453 String[] entryNames, Date startDate, Date endDate, Date publishDate,
454 Date expirationDate, String mimeType, String title,
455 String description, String summary, String url, int height,
456 int width, Integer priority, boolean sync)
457 throws PortalException, SystemException {
458
459
461 User user = userPersistence.findByPrimaryKey(userId);
462 long classNameId = PortalUtil.getClassNameId(className);
463
464 if (entryNames == null) {
465 entryNames = new String[0];
466 }
467
468 title = StringUtil.shorten(title, 300, StringPool.BLANK);
469 Date now = new Date();
470
471 validate(className, entryNames);
472
473 TagsAsset asset = tagsAssetPersistence.fetchByC_C(classNameId, classPK);
474
475 if (asset == null) {
476 long assetId = counterLocalService.increment();
477
478 asset = tagsAssetPersistence.create(assetId);
479
480 asset.setCompanyId(user.getCompanyId());
481 asset.setUserId(user.getUserId());
482 asset.setUserName(user.getFullName());
483 asset.setCreateDate(now);
484 asset.setClassNameId(classNameId);
485 asset.setClassPK(classPK);
486 asset.setPublishDate(publishDate);
487 asset.setExpirationDate(expirationDate);
488
489 if (priority == null) {
490 asset.setPriority(0);
491 }
492
493 asset.setViewCount(0);
494 }
495
496 asset.setGroupId(groupId);
497 asset.setModifiedDate(now);
498 asset.setStartDate(startDate);
499 asset.setEndDate(endDate);
500 asset.setPublishDate(publishDate);
501 asset.setExpirationDate(expirationDate);
502 asset.setMimeType(mimeType);
503 asset.setTitle(title);
504 asset.setDescription(description);
505 asset.setSummary(summary);
506 asset.setUrl(url);
507 asset.setHeight(height);
508 asset.setWidth(width);
509
510 if (priority != null) {
511 asset.setPriority(priority.intValue());
512 }
513
514
516 List<TagsEntry> entries = new ArrayList<TagsEntry>(entryNames.length);
517
518 for (int i = 0; i < entryNames.length; i++) {
519 String name = entryNames[i].trim().toLowerCase();
520
521 TagsEntry entry = tagsEntryPersistence.fetchByC_N(
522 user.getCompanyId(), name);
523
524 if (entry == null) {
525 entry = tagsEntryLocalService.addEntry(
526 user.getUserId(), entryNames[i],
527 TagsEntryLocalServiceImpl.DEFAULT_PROPERTIES);
528 }
529
530 entries.add(entry);
531 }
532
533 tagsAssetPersistence.setTagsEntries(asset.getAssetId(), entries);
534
535
538 tagsAssetPersistence.update(asset, false);
539
540
542 if (!sync) {
543 return asset;
544 }
545
546 if (className.equals(BlogsEntry.class.getName())) {
547 BlogsEntry entry = blogsEntryPersistence.findByPrimaryKey(classPK);
548
549 entry.setTitle(title);
550
551 blogsEntryPersistence.update(entry, false);
552 }
553 else if (className.equals(BookmarksEntry.class.getName())) {
554 BookmarksEntry entry = bookmarksEntryPersistence.findByPrimaryKey(
555 classPK);
556
557 entry.setName(title);
558 entry.setComments(description);
559 entry.setUrl(url);
560
561 bookmarksEntryPersistence.update(entry, false);
562 }
563 else if (className.equals(DLFileEntry.class.getName())) {
564 DLFileEntry fileEntry = dlFileEntryPersistence.findByPrimaryKey(
565 classPK);
566
567 fileEntry.setTitle(title);
568 fileEntry.setDescription(description);
569
570 dlFileEntryPersistence.update(fileEntry, false);
571 }
572 else if (className.equals(JournalArticle.class.getName())) {
573 JournalArticle article = journalArticlePersistence.findByPrimaryKey(
574 classPK);
575
576 article.setTitle(title);
577 article.setDescription(description);
578
579 journalArticlePersistence.update(article, false);
580 }
581 else if (className.equals(MBMessage.class.getName())) {
582 MBMessage message = mbMessagePersistence.findByPrimaryKey(classPK);
583
584 message.setSubject(title);
585
586 mbMessagePersistence.update(message, false);
587 }
588 else if (className.equals(WikiPage.class.getName())) {
589 WikiPage page = wikiPagePersistence.findByPrimaryKey(classPK);
590
591 page.setTitle(title);
592
593 wikiPagePersistence.update(page, false);
594 }
595
596 return asset;
597 }
598
599 public void validate(String className, String[] entryNames)
600 throws PortalException {
601
602 TagsAssetValidator validator = (TagsAssetValidator)InstancePool.get(
603 PropsValues.TAGS_ASSET_VALIDATOR);
604
605 validator.validate(className, entryNames);
606 }
607
608 protected TagsAsset getAsset(Document doc)
609 throws PortalException, SystemException {
610
611 String portletId = GetterUtil.getString(doc.get(Field.PORTLET_ID));
612
613 if (portletId.equals(PortletKeys.BLOGS)) {
614 long entryId = GetterUtil.getLong(doc.get(Field.ENTRY_CLASS_PK));
615
616 long classNameId = PortalUtil.getClassNameId(
617 BlogsEntry.class.getName());
618 long classPK = entryId;
619
620 return tagsAssetPersistence.findByC_C(classNameId, classPK);
621 }
622 else if (portletId.equals(PortletKeys.BOOKMARKS)) {
623 long entryId = GetterUtil.getLong(doc.get(Field.ENTRY_CLASS_PK));
624
625 long classNameId = PortalUtil.getClassNameId(
626 BookmarksEntry.class.getName());
627 long classPK = entryId;
628
629 return tagsAssetPersistence.findByC_C(classNameId, classPK);
630 }
631 else if (portletId.equals(PortletKeys.DOCUMENT_LIBRARY)) {
632 long folderId = GetterUtil.getLong(doc.get("repositoryId"));
633 String name = doc.get("path");
634
635 DLFileEntry fileEntry = dlFileEntryLocalService.getFileEntry(
636 folderId, name);
637
638 long classNameId = PortalUtil.getClassNameId(
639 DLFileEntry.class.getName());
640 long classPK = fileEntry.getFileEntryId();
641
642 return tagsAssetPersistence.findByC_C(classNameId, classPK);
643 }
644 else if (portletId.equals(PortletKeys.IMAGE_GALLERY)) {
645 long imageId = GetterUtil.getLong(doc.get(Field.ENTRY_CLASS_PK));
646
647 long classNameId = PortalUtil.getClassNameId(
648 IGImage.class.getName());
649 long classPK = imageId;
650
651 return tagsAssetPersistence.findByC_C(classNameId, classPK);
652 }
653 else if (portletId.equals(PortletKeys.JOURNAL)) {
654 long groupId = GetterUtil.getLong(doc.get(Field.GROUP_ID));
655 String articleId = doc.get(Field.ENTRY_CLASS_PK);
656
658 long articleResourcePrimKey =
659 journalArticleResourceLocalService.getArticleResourcePrimKey(
660 groupId, articleId);
661
662 long classNameId = PortalUtil.getClassNameId(
663 JournalArticle.class.getName());
664 long classPK = articleResourcePrimKey;
665
666 return tagsAssetPersistence.findByC_C(classNameId, classPK);
667 }
668 else if (portletId.equals(PortletKeys.MESSAGE_BOARDS)) {
669 long messageId = GetterUtil.getLong(doc.get(Field.ENTRY_CLASS_PK));
670
671 long classNameId = PortalUtil.getClassNameId(
672 MBMessage.class.getName());
673 long classPK = messageId;
674
675 return tagsAssetPersistence.findByC_C(classNameId, classPK);
676 }
677 else if (portletId.equals(PortletKeys.WIKI)) {
678 long nodeId = GetterUtil.getLong(doc.get(Field.ENTRY_CLASS_PK));
679 String title = doc.get(Field.TITLE);
680
681 long pageResourcePrimKey =
682 wikiPageResourceLocalService.getPageResourcePrimKey(
683 nodeId, title);
684
685 long classNameId = PortalUtil.getClassNameId(
686 WikiPage.class.getName());
687 long classPK = pageResourcePrimKey;
688
689 return tagsAssetPersistence.findByC_C(classNameId, classPK);
690 }
691
692 return null;
693 }
694
695 protected TagsAssetDisplay[] getAssetDisplays(
696 List<TagsAsset> assets, String languageId)
697 throws SystemException {
698
699 TagsAssetDisplay[] assetDisplays = new TagsAssetDisplay[assets.size()];
700
701 for (int i = 0; i < assets.size(); i++) {
702 TagsAsset asset = assets.get(i);
703
704 String className = PortalUtil.getClassName(asset.getClassNameId());
705 String portletId = PortalUtil.getClassNamePortletId(className);
706 String portletTitle = PortalUtil.getPortletTitle(
707 portletId, asset.getCompanyId(), languageId);
708
709 List<TagsEntry> tagsEntriesList =
710 tagsAssetPersistence.getTagsEntries(asset.getAssetId());
711
712 String tagsEntries = ListUtil.toString(
713 tagsEntriesList, "name", ", ");
714
715 TagsAssetDisplay assetDisplay = new TagsAssetDisplay();
716
717 assetDisplay.setAssetId(asset.getAssetId());
718 assetDisplay.setCompanyId(asset.getCompanyId());
719 assetDisplay.setUserId(asset.getUserId());
720 assetDisplay.setUserName(asset.getUserName());
721 assetDisplay.setCreateDate(asset.getCreateDate());
722 assetDisplay.setModifiedDate(asset.getModifiedDate());
723 assetDisplay.setClassNameId(asset.getClassNameId());
724 assetDisplay.setClassName(className);
725 assetDisplay.setClassPK(asset.getClassPK());
726 assetDisplay.setPortletId(portletId);
727 assetDisplay.setPortletTitle(portletTitle);
728 assetDisplay.setStartDate(asset.getStartDate());
729 assetDisplay.setEndDate(asset.getEndDate());
730 assetDisplay.setPublishDate(asset.getPublishDate());
731 assetDisplay.setExpirationDate(asset.getExpirationDate());
732 assetDisplay.setMimeType(asset.getMimeType());
733 assetDisplay.setTitle(asset.getTitle());
734 assetDisplay.setDescription(asset.getDescription());
735 assetDisplay.setSummary(asset.getSummary());
736 assetDisplay.setUrl(asset.getUrl());
737 assetDisplay.setHeight(asset.getHeight());
738 assetDisplay.setWidth(asset.getWidth());
739 assetDisplay.setPriority(asset.getPriority());
740 assetDisplay.setViewCount(asset.getViewCount());
741 assetDisplay.setTagsEntries(tagsEntries);
742
743 assetDisplays[i] = assetDisplay;
744 }
745
746 return assetDisplays;
747 }
748
749 protected TagsAssetType getAssetType(String className, String languageId) {
750 long companyId = PortalInstances.getDefaultCompanyId();
751
752 long classNameId = PortalUtil.getClassNameId(className);
753
754 String portletId = PortalUtil.getClassNamePortletId(className);
755 String portletTitle = PortalUtil.getPortletTitle(
756 portletId, companyId, languageId);
757
758 TagsAssetType assetType = new TagsAssetType();
759
760 assetType.setClassNameId(classNameId);
761 assetType.setClassName(className);
762 assetType.setPortletId(portletId);
763 assetType.setPortletTitle(portletTitle);
764
765 return assetType;
766 }
767
768 private static Log _log =
769 LogFactoryUtil.getLog(TagsAssetLocalServiceImpl.class);
770
771 }