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