--- /dev/null
+/**\r
+ * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.\r
+ *\r
+ * This library is free software; you can redistribute it and/or modify it under\r
+ * the terms of the GNU Lesser General Public License as published by the Free\r
+ * Software Foundation; either version 2.1 of the License, or (at your option)\r
+ * any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful, but WITHOUT\r
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more\r
+ * details.\r
+ */\r
+\r
+package com.liferay.portal.kernel.webdav;\r
+\r
+import com.liferay.portal.kernel.util.ContentTypes;\r
+import com.liferay.portal.kernel.util.FastDateFormatFactoryUtil;\r
+import com.liferay.portal.kernel.util.HttpUtil;\r
+import com.liferay.portal.kernel.util.StringPool;\r
+import com.liferay.portal.kernel.util.Validator;\r
+import com.liferay.portal.model.Lock;\r
+\r
+import java.io.InputStream;\r
+\r
+import java.text.Format;\r
+\r
+import java.util.Date;\r
+import java.util.Locale;\r
+\r
+/**\r
+ * @author Brian Wing Shun Chan\r
+ * @author Alexander Chow\r
+ */\r
+public class BaseResourceImpl implements Resource {\r
+\r
+ public BaseResourceImpl(String parentPath, long name, long displayName) {\r
+ this(parentPath, String.valueOf(name), String.valueOf(displayName));\r
+ }\r
+\r
+ public BaseResourceImpl(String parentPath, long name, String displayName) {\r
+ this(parentPath, String.valueOf(name), displayName);\r
+ }\r
+\r
+ public BaseResourceImpl(\r
+ String parentPath, String name, String displayName) {\r
+\r
+ this(parentPath, name, displayName, null, null);\r
+ }\r
+\r
+ public BaseResourceImpl(\r
+ String parentPath, String name, String displayName, Date createDate,\r
+ Date modifiedDate) {\r
+\r
+ this(parentPath, name, displayName, createDate, modifiedDate, 0);\r
+ }\r
+\r
+ public BaseResourceImpl(\r
+ String parentPath, String name, String displayName, Date createDate,\r
+ Date modifiedDate, long size) {\r
+\r
+ _href = HttpUtil.decodeURL(parentPath);\r
+\r
+ if (Validator.isNotNull(name)) {\r
+ _href += StringPool.SLASH + name;\r
+ }\r
+\r
+ _href = HttpUtil.encodePath(_href);\r
+\r
+ _displayName = displayName;\r
+\r
+ if (createDate == null) {\r
+ _createDate = new Date();\r
+ }\r
+ else {\r
+ _createDate = createDate;\r
+ }\r
+\r
+ if (modifiedDate == null) {\r
+ _modifiedDate = new Date();\r
+ }\r
+ else {\r
+ _modifiedDate = _createDate;\r
+ }\r
+\r
+ _size = size;\r
+ }\r
+\r
+ public String getClassName() {\r
+ return _className;\r
+ }\r
+\r
+ @SuppressWarnings("unused")\r
+ public InputStream getContentAsStream() throws WebDAVException {\r
+ return null;\r
+ }\r
+\r
+ public String getContentType() {\r
+ return ContentTypes.HTTPD_UNIX_DIRECTORY;\r
+ }\r
+\r
+ public String getCreateDate() {\r
+ return _createDateFormatter.format(_createDate);\r
+ }\r
+\r
+ public String getDisplayName() {\r
+ return _displayName;\r
+ }\r
+\r
+ public String getHREF() {\r
+ return _href;\r
+ }\r
+\r
+ public Object getModel() {\r
+ return _model;\r
+ }\r
+\r
+ public String getModifiedDate() {\r
+ return _modifiedDateFormatter.format(_modifiedDate);\r
+ }\r
+\r
+ public long getPrimaryKey() {\r
+ return _primaryKey;\r
+ }\r
+\r
+ public long getSize() {\r
+ return _size;\r
+ }\r
+\r
+ public boolean isCollection() {\r
+ return true;\r
+ }\r
+\r
+ public boolean isLocked() {\r
+ return _lock != null;\r
+ }\r
+\r
+ public void setClassName(String className) {\r
+ _className = className;\r
+ }\r
+\r
+ public void setModel(Object model) {\r
+ _model = model;\r
+ }\r
+\r
+ public void setPrimaryKey(long primaryKey) {\r
+ _primaryKey = primaryKey;\r
+ }\r
+ \r
+ public Lock getLock() {\r
+ return _lock;\r
+ }\r
+\r
+ public void setLock(Lock lock) {\r
+ _lock = lock;\r
+ }\r
+\r
+ private static Format _createDateFormatter =\r
+ FastDateFormatFactoryUtil.getSimpleDateFormat(\r
+ "yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);\r
+\r
+ private static Format _modifiedDateFormatter =\r
+ FastDateFormatFactoryUtil.getSimpleDateFormat(\r
+ "EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);\r
+\r
+ private String _className;\r
+ private Date _createDate;\r
+ private String _displayName;\r
+ private String _href;\r
+ private Object _model;\r
+ private Date _modifiedDate;\r
+ private long _primaryKey = -1;\r
+ private long _size;\r
+ private Lock _lock;\r
+\r
+}
\ No newline at end of file