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