1
19
20 package com.liferay.portlet.journal.webdav;
21
22 import com.liferay.portal.kernel.util.ContentTypes;
23 import com.liferay.portal.kernel.util.StringPool;
24 import com.liferay.portal.webdav.BaseResourceImpl;
25 import com.liferay.portal.webdav.WebDAVException;
26 import com.liferay.portlet.journal.model.JournalTemplate;
27
28 import java.io.ByteArrayInputStream;
29 import java.io.InputStream;
30
31
37 public class JournalTemplateResourceImpl extends BaseResourceImpl {
38
39 public JournalTemplateResourceImpl(
40 JournalTemplate template, String parentPath, String name) {
41
42 super(
43 parentPath, name, template.getTemplateId(),
44 template.getCreateDate(), template.getModifiedDate(),
45 template.getXsl().length());
46
47 setModel(template);
48 setClassName(JournalTemplate.class.getName());
49 setPrimaryKey(template.getPrimaryKey());
50
51 _template = template;
52 }
53
54 public boolean isCollection() {
55 return false;
56 }
57
58 public String getContentType() {
59 return ContentTypes.TEXT_XML;
60 }
61
62 public InputStream getContentAsStream() throws WebDAVException {
63 try {
64 return new ByteArrayInputStream(
65 _template.getXsl().getBytes(StringPool.UTF8));
66 }
67 catch (Exception e) {
68 throw new WebDAVException(e);
69 }
70 }
71
72 private JournalTemplate _template;
73
74 }