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