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.JournalStructure;
23
24 import java.io.InputStream;
25
26
32 public class JournalStructureResourceImpl extends BaseResourceImpl {
33
34 public JournalStructureResourceImpl(
35 JournalStructure structure, String parentPath, String name) {
36
37 super(
38 parentPath, name, structure.getStructureId(),
39 structure.getCreateDate(), structure.getModifiedDate(),
40 structure.getXsd().length());
41
42 setModel(structure);
43 setClassName(JournalStructure.class.getName());
44 setPrimaryKey(structure.getPrimaryKey());
45
46 _structure = structure;
47 }
48
49 public boolean isCollection() {
50 return false;
51 }
52
53 public String getContentType() {
54 return ContentTypes.TEXT_XML;
55 }
56
57 public InputStream getContentAsStream() throws WebDAVException {
58 try {
59 return new UnsyncByteArrayInputStream(
60 _structure.getXsd().getBytes(StringPool.UTF8));
61 }
62 catch (Exception e) {
63 throw new WebDAVException(e);
64 }
65 }
66
67 private JournalStructure _structure;
68
69 }