--- /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.webdav.methods;\r
+\r
+import com.liferay.portal.kernel.webdav.Resource;\r
+import com.liferay.portal.kernel.webdav.WebDAVException;\r
+import com.liferay.portal.kernel.webdav.WebDAVRequest;\r
+import com.liferay.portal.kernel.webdav.WebDAVStorage;\r
+\r
+import javax.servlet.http.HttpServletResponse;\r
+\r
+import java.text.DateFormat;\r
+import java.text.SimpleDateFormat;\r
+import java.util.Locale;\r
+/**\r
+ * @author Brian Wing Shun Chan\r
+ * @author Alexander Chow\r
+ */\r
+public class HeadMethodImpl implements Method {\r
+ \r
+ private static DateFormat _modifiedDateFormatter =\r
+ new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);\r
+ \r
+ public int process(WebDAVRequest webDavRequest) throws WebDAVException {\r
+ try {\r
+ WebDAVStorage storage = webDavRequest.getWebDAVStorage();\r
+ HttpServletResponse response =\r
+ webDavRequest.getHttpServletResponse();\r
+\r
+ Resource resource = storage.getResource(webDavRequest);\r
+\r
+ if (resource == null) {\r
+ return HttpServletResponse.SC_NOT_FOUND;\r
+ }\r
+\r
+ if (!resource.isCollection()) {\r
+ response.setContentLength((int)resource.getSize());\r
+ response.setContentType(resource.getContentType());\r
+ response.setDateHeader("Last-Modified", _modifiedDateFormatter.parse(resource.getModifiedDate()).getTime());\r
+ }\r
+\r
+ response.addHeader("Translate", "F");\r
+ return HttpServletResponse.SC_OK;\r
+ }\r
+ catch (Exception e) {\r
+ throw new WebDAVException(e);\r
+ }\r
+ }\r
+\r
+}
\ No newline at end of file