1
22
23
41
42 package com.liferay.portal.mirage.service;
43
44 import com.liferay.portal.mirage.aop.ContentTypeInvoker;
45 import com.liferay.portal.mirage.aop.SearchCriteriaInvoker;
46 import com.liferay.portal.mirage.aop.TemplateInvoker;
47 import com.liferay.portal.mirage.model.MirageJournalStructure;
48 import com.liferay.portal.mirage.model.MirageJournalTemplate;
49 import com.liferay.portlet.journal.model.JournalStructure;
50 import com.liferay.portlet.journal.model.JournalTemplate;
51
52 import com.sun.portal.cms.mirage.exception.CMSException;
53 import com.sun.portal.cms.mirage.exception.TemplateNotFoundException;
54 import com.sun.portal.cms.mirage.model.custom.Category;
55 import com.sun.portal.cms.mirage.model.custom.ContentType;
56 import com.sun.portal.cms.mirage.model.custom.OptionalCriteria;
57 import com.sun.portal.cms.mirage.model.custom.Template;
58 import com.sun.portal.cms.mirage.model.custom.UpdateCriteria;
59 import com.sun.portal.cms.mirage.model.search.SearchCriteria;
60 import com.sun.portal.cms.mirage.service.custom.ContentTypeService;
61
62 import java.util.ArrayList;
63 import java.util.List;
64
65
73 public class ContentTypeServiceImpl implements ContentTypeService {
74
75 public void addTemplateToContentType(
76 Template template, ContentType contentType)
77 throws CMSException {
78
79 process(template);
80 }
81
82 public void assignDefaultTemplate(
83 ContentType contentType, Template template) {
84
85 throw new UnsupportedOperationException();
86 }
87
88 public boolean checkContentTypeExists(String contentTypeUUID) {
89 throw new UnsupportedOperationException();
90 }
91
92 public void checkOutTemplate(Template template, ContentType contentType) {
93 throw new UnsupportedOperationException();
94 }
95
96 public int contentTypeSearchCount(
97 Category category, SearchCriteria searchCriteria)
98 throws CMSException {
99
100 SearchCriteriaInvoker searchCriteriaInvoker =
101 (SearchCriteriaInvoker)searchCriteria;
102
103 searchCriteriaInvoker.invoke();
104
105 Integer i = (Integer)searchCriteriaInvoker.getReturnValue();
106
107 return i.intValue();
108 }
109
110 public void createContentType(ContentType contentType) throws CMSException {
111 process(contentType);
112 }
113
114 public void deleteContentType(ContentType contentType) throws CMSException {
115 process(contentType);
116 }
117
118 public void deleteTemplateOfContentType(
119 ContentType contentType, Template template)
120 throws CMSException {
121
122 process(template);
123 }
124
125 public void deleteTemplatesOfContentType(
126 ContentType contentType, Template[] templatesToBeDeleted)
127 throws CMSException {
128
129 process(templatesToBeDeleted[0]);
130 }
131
132 public List<Template> getAllVersionsOfTemplate(
133 Template template, ContentType contentType) {
134
135 throw new UnsupportedOperationException();
136 }
137
138 public List<String> getAvailableContentTypeNames(Category category) {
139 throw new UnsupportedOperationException();
140 }
141
142 public List<ContentType> getAvailableContentTypes(Category category) {
143 throw new UnsupportedOperationException();
144 }
145
146 public ContentType getContentType(ContentType contentType)
147 throws CMSException {
148
149 process(contentType);
150
151 ContentTypeInvoker contentTypeInvoker = (ContentTypeInvoker)contentType;
152
153 JournalStructure structure =
154 (JournalStructure)contentTypeInvoker.getReturnValue();
155
156 return new MirageJournalStructure(structure);
157 }
158
159 public ContentType getContentType(
160 ContentType contentType, OptionalCriteria optionalCriteria) {
161
162 throw new UnsupportedOperationException();
163 }
164
165 public ContentType getContentTypeByNameAndCategory(
166 String contentTypeName, Category category) {
167
168 throw new UnsupportedOperationException();
169 }
170
171 public ContentType getContentTypeByUUID(String contentTypeUUID) {
172 throw new UnsupportedOperationException();
173 }
174
175 public Template getLatestVersionOfTemplate(
176 Template template, ContentType contentType) {
177
178 throw new UnsupportedOperationException();
179 }
180
181 public Template getTemplate(Template template, OptionalCriteria criteria)
182 throws TemplateNotFoundException {
183
184 try {
185 process(template);
186 }
187 catch (CMSException cmse) {
188 throw new TemplateNotFoundException(
189 cmse.getErrorCode(), cmse.getMessage(), cmse.getCause());
190 }
191
192 TemplateInvoker templateInvoker = (TemplateInvoker)template;
193
194 JournalTemplate journalTemplate =
195 (JournalTemplate)templateInvoker.getReturnValue();
196
197 return new MirageJournalTemplate(journalTemplate);
198 }
199
200 public List<Template> getTemplates(
201 ContentType contentType, Template template, OptionalCriteria criteria) {
202
203 throw new UnsupportedOperationException();
204 }
205
206 public int getTemplatesCount(
207 ContentType contentType, Template template, OptionalCriteria criteria) {
208
209 throw new UnsupportedOperationException();
210 }
211
212 public Template getTemplateWithUUID(String templateUUID) {
213 throw new UnsupportedOperationException();
214 }
215
216 public boolean isContentTypeEditable(String contentTypeUUID) {
217 throw new UnsupportedOperationException();
218 }
219
220 public void revertChangesTemplateForTemplate(
221 Template template, ContentType contentType) {
222
223 throw new UnsupportedOperationException();
224 }
225
226 public void saveNewVersionOfTemplate(
227 Template template, ContentType contentType) {
228
229 throw new UnsupportedOperationException();
230 }
231
232 public List<ContentType> searchContentTypes(SearchCriteria searchCriteria)
233 throws CMSException {
234
235 SearchCriteriaInvoker searchCriteriaInvoker =
236 (SearchCriteriaInvoker)searchCriteria;
237
238 searchCriteriaInvoker.invoke();
239
240 List<JournalStructure> structures =
241 (List<JournalStructure>)searchCriteriaInvoker.getReturnValue();
242
243 List<ContentType> contentTypes =
244 new ArrayList<ContentType>(structures.size());
245
246 for (JournalStructure structure : structures) {
247 contentTypes.add(new MirageJournalStructure(structure));
248 }
249
250 return contentTypes;
251 }
252
253 public List<ContentType> searchContentTypesByCategory(
254 Category category, SearchCriteria searchCriteria) {
255
256 throw new UnsupportedOperationException();
257 }
258
259 public List<Template> searchTemplates(SearchCriteria searchCriteria)
260 throws CMSException {
261
262 SearchCriteriaInvoker searchCriteriaInvoker =
263 (SearchCriteriaInvoker)searchCriteria;
264
265 searchCriteriaInvoker.invoke();
266
267 List<JournalTemplate> journalTemplates =
268 (List<JournalTemplate>)searchCriteriaInvoker.getReturnValue();
269
270 List<Template> mirageTemplates =
271 new ArrayList<Template>(journalTemplates.size());
272
273 for (JournalTemplate template : journalTemplates) {
274 mirageTemplates.add(new MirageJournalTemplate(template));
275 }
276
277 return mirageTemplates;
278 }
279
280 public int searchTemplatesCount(SearchCriteria searchCriteria)
281 throws CMSException {
282
283 SearchCriteriaInvoker searchCriteriaInvoker =
284 (SearchCriteriaInvoker)searchCriteria;
285
286 searchCriteriaInvoker.invoke();
287
288 Integer i = (Integer)searchCriteriaInvoker.getReturnValue();
289
290 return i.intValue();
291 }
292
293 public List<Template> searchTemplatesOfContentType(
294 ContentType contentType, SearchCriteria criteria) {
295
296 throw new UnsupportedOperationException();
297 }
298
299 public void unassignDefaultTemplate(ContentType contentType) {
300 throw new UnsupportedOperationException();
301 }
302
303 public void updateCategoryOfContentType(ContentType contentType) {
304 throw new UnsupportedOperationException();
305 }
306
307 public void updateContentType(ContentType contentType) throws CMSException {
308 process(contentType);
309 }
310
311 public void updateContentType(
312 ContentType contentType, UpdateCriteria updateCriteria) {
313
314 throw new UnsupportedOperationException();
315 }
316
317 public void updateTemplateOfContentType(
318 Template template, ContentType contentType)
319 throws CMSException {
320
321 process(template);
322 }
323
324 public void updateTemplateOfContentType(
325 Template template, ContentType contentType, UpdateCriteria criteria) {
326
327 throw new UnsupportedOperationException();
328 }
329
330 public boolean validateTemplate(
331 Template template, ContentType contentType) {
332
333 throw new UnsupportedOperationException();
334 }
335
336 protected void process(ContentType contentType) throws CMSException {
337 ContentTypeInvoker contentTypeInvoker = (ContentTypeInvoker)contentType;
338
339 contentTypeInvoker.invoke();
340 }
341
342 protected void process(Template template) throws CMSException {
343 TemplateInvoker templateInvoker = (TemplateInvoker)template;
344
345 templateInvoker.invoke();
346 }
347
348 }