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.JournalStructure;
023
024 import java.io.InputStream;
025
026
029 public class JournalStructureResourceImpl extends BaseResourceImpl {
030
031 public JournalStructureResourceImpl(
032 JournalStructure structure, String parentPath, String name) {
033
034 super(
035 parentPath, name, structure.getStructureId(),
036 structure.getCreateDate(), structure.getModifiedDate(),
037 structure.getXsd().length());
038
039 setModel(structure);
040 setClassName(JournalStructure.class.getName());
041 setPrimaryKey(structure.getPrimaryKey());
042
043 _structure = structure;
044 }
045
046 @Override
047 public boolean isCollection() {
048 return false;
049 }
050
051 @Override
052 public String getContentType() {
053 return ContentTypes.TEXT_XML;
054 }
055
056 @Override
057 public InputStream getContentAsStream() throws WebDAVException {
058 try {
059 return new UnsyncByteArrayInputStream(
060 _structure.getXsd().getBytes(StringPool.UTF8));
061 }
062 catch (Exception e) {
063 throw new WebDAVException(e);
064 }
065 }
066
067 private JournalStructure _structure;
068
069 }