001
014
015 package com.liferay.portlet.journal.webdav;
016
017 import com.liferay.portal.kernel.io.unsync.UnsyncByteArrayInputStream;
018 import com.liferay.portal.kernel.util.ContentTypes;
019 import com.liferay.portal.kernel.util.StringPool;
020 import com.liferay.portal.kernel.webdav.BaseResourceImpl;
021 import com.liferay.portal.kernel.webdav.WebDAVException;
022 import com.liferay.portlet.journal.model.JournalTemplate;
023
024 import java.io.InputStream;
025
026
029 public class JournalTemplateResourceImpl extends BaseResourceImpl {
030
031 public JournalTemplateResourceImpl(
032 JournalTemplate template, String parentPath, String name) {
033
034 super(
035 parentPath, name, template.getTemplateId(),
036 template.getCreateDate(), template.getModifiedDate(),
037 template.getXsl().length());
038
039 setModel(template);
040 setClassName(JournalTemplate.class.getName());
041 setPrimaryKey(template.getPrimaryKey());
042
043 _template = template;
044 }
045
046 public boolean isCollection() {
047 return false;
048 }
049
050 public String getContentType() {
051 return ContentTypes.TEXT_XML;
052 }
053
054 public InputStream getContentAsStream() throws WebDAVException {
055 try {
056 return new UnsyncByteArrayInputStream(
057 _template.getXsl().getBytes(StringPool.UTF8));
058 }
059 catch (Exception e) {
060 throw new WebDAVException(e);
061 }
062 }
063
064 private JournalTemplate _template;
065
066 }