1
22
23 package com.liferay.portal.webdav;
24
25 import com.liferay.portal.kernel.util.ContentTypes;
26
27 import java.io.InputStream;
28
29 import java.text.DateFormat;
30 import java.text.SimpleDateFormat;
31
32 import java.util.Date;
33 import java.util.Locale;
34
35
42 public class BaseResourceImpl implements Resource {
43
44 public BaseResourceImpl(String href, String displayName) {
45 this(href, displayName, null, null);
46 }
47
48 public BaseResourceImpl(
49 String href, String displayName, Date createDate, Date modifiedDate) {
50
51 this(href, displayName, createDate, modifiedDate, 0);
52 }
53
54 public BaseResourceImpl(
55 String href, String displayName, Date createDate, Date modifiedDate,
56 int size) {
57
58 _href = href;
59 _displayName = displayName;
60
61 if (createDate == null) {
62 _createDate = new Date();
63 }
64 else {
65 _createDate = createDate;
66 }
67
68 if (modifiedDate == null) {
69 _modifiedDate = new Date();
70 }
71 else {
72 _modifiedDate = _createDate;
73 }
74
75 _size = size;
76 }
77
78 public String getHREF() {
79 return _href;
80 }
81
82 public String getDisplayName() {
83 return _displayName;
84 }
85
86 public boolean isCollection() {
87 return true;
88 }
89
90 public String getCreateDate() {
91 return _createDateFormatter.format(_createDate);
92 }
93
94 public String getModifiedDate() {
95 return _modifiedDateFormatter.format(_modifiedDate);
96 }
97
98 public int getSize() {
99 return _size;
100 }
101
102 public Object getModel() {
103 return _model;
104 }
105
106 public void setModel(Object model) {
107 _model = model;
108 }
109
110 public String getClassName() {
111 return _className;
112 }
113
114 public void setClassName(String className) {
115 _className = className;
116 }
117
118 public long getPrimaryKey() {
119 return _primaryKey;
120 }
121
122 public void setPrimaryKey(long primaryKey) {
123 _primaryKey = primaryKey;
124 }
125
126 public String getContentType() {
127 return ContentTypes.HTTPD_UNIX_DIRECTORY;
128 }
129
130 public InputStream getContentAsStream() throws WebDAVException {
131 return null;
132 }
133
134 private static DateFormat _createDateFormatter =
135 new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
136
137 private static DateFormat _modifiedDateFormatter =
138 new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
139
140 private String _href;
141 private String _displayName;
142 private Date _createDate;
143 private Date _modifiedDate;
144 private int _size;
145 private Object _model;
146 private String _className;
147 private long _primaryKey = -1;
148
149 }