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