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