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