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.util.ListUtil;
28 import com.liferay.portal.security.permission.ActionKeys;
29 import com.liferay.portal.security.permission.PermissionChecker;
30 import com.liferay.portal.service.ServiceContext;
31 import com.liferay.portlet.tags.model.TagsVocabulary;
32 import com.liferay.portlet.tags.service.base.TagsVocabularyServiceBaseImpl;
33 import com.liferay.portlet.tags.service.permission.TagsPermission;
34 import com.liferay.portlet.tags.service.permission.TagsVocabularyPermission;
35
36 import java.util.Iterator;
37 import java.util.List;
38
39
46 public class TagsVocabularyServiceImpl extends TagsVocabularyServiceBaseImpl {
47
48 public TagsVocabulary addVocabulary(
49 String name, boolean folksonomy, ServiceContext serviceContext)
50 throws PortalException, SystemException {
51
52 TagsPermission.check(
53 getPermissionChecker(), serviceContext.getScopeGroupId(),
54 ActionKeys.ADD_VOCABULARY);
55
56 return tagsVocabularyLocalService.addVocabulary(
57 getUserId(), name, folksonomy, serviceContext);
58 }
59
60 public void deleteVocabulary(long vocabularyId)
61 throws PortalException, SystemException {
62
63 TagsVocabularyPermission.check(
64 getPermissionChecker(), vocabularyId, ActionKeys.DELETE);
65
66 tagsVocabularyLocalService.deleteVocabulary(vocabularyId);
67 }
68
69 public List<TagsVocabulary> getCompanyVocabularies(
70 long companyId, boolean folksonomy)
71 throws PortalException, SystemException {
72
73 return getVocabularies(
74 tagsVocabularyLocalService.getCompanyVocabularies(
75 companyId, folksonomy));
76 }
77
78 public List<TagsVocabulary> getGroupVocabularies(
79 long groupId, boolean folksonomy)
80 throws PortalException, SystemException {
81
82 return getVocabularies(
83 tagsVocabularyLocalService.getGroupVocabularies(
84 groupId, folksonomy));
85 }
86
87 public TagsVocabulary getVocabulary(long vocabularyId)
88 throws PortalException, SystemException {
89
90 TagsVocabularyPermission.check(
91 getPermissionChecker(), vocabularyId, ActionKeys.VIEW);
92
93 return tagsVocabularyLocalService.getVocabulary(vocabularyId);
94 }
95
96 public TagsVocabulary updateVocabulary(
97 long vocabularyId, String name, boolean folksonomy)
98 throws PortalException, SystemException {
99
100 TagsVocabularyPermission.check(
101 getPermissionChecker(), vocabularyId, ActionKeys.UPDATE);
102
103 return tagsVocabularyLocalService.updateVocabulary(
104 vocabularyId, name, folksonomy);
105 }
106
107 protected List<TagsVocabulary> getVocabularies(
108 List<TagsVocabulary> vocabularies)
109 throws PortalException {
110
111 PermissionChecker permissionChecker = getPermissionChecker();
112
113 vocabularies = ListUtil.copy(vocabularies);
114
115 Iterator<TagsVocabulary> itr = vocabularies.iterator();
116
117 while (itr.hasNext()) {
118 TagsVocabulary vocabulary = itr.next();
119
120 if (!TagsVocabularyPermission.contains(
121 permissionChecker, vocabulary, ActionKeys.VIEW)) {
122
123 itr.remove();
124 }
125 }
126
127 return vocabularies;
128 }
129
130 }