1 17 package org.alfresco.repo.webdav; 18 19 import javax.servlet.http.HttpServletResponse ; 20 21 import org.alfresco.model.ContentModel; 22 import org.alfresco.service.cmr.model.FileFolderService; 23 import org.alfresco.service.cmr.model.FileInfo; 24 import org.alfresco.service.cmr.model.FileNotFoundException; 25 import org.alfresco.service.cmr.repository.NodeRef; 26 import org.w3c.dom.Document ; 27 28 33 public class MkcolMethod extends WebDAVMethod 34 { 35 38 public MkcolMethod() 39 { 40 } 41 42 47 protected void parseRequestHeaders() throws WebDAVServerException 48 { 49 } 51 52 57 protected void parseRequestBody() throws WebDAVServerException 58 { 59 61 Document body = getRequestBodyAsDocument(); 62 63 if (body != null) 64 { 65 throw new WebDAVServerException(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE); 66 } 67 } 68 69 74 protected void executeImpl() throws WebDAVServerException, Exception 75 { 76 FileFolderService fileFolderService = getFileFolderService(); 77 78 try 80 { 81 getDAVHelper().getNodeForPath(getRootNodeRef(), getPath(), getServletPath()); 82 throw new WebDAVServerException(HttpServletResponse.SC_METHOD_NOT_ALLOWED); 84 } 85 catch (FileNotFoundException e) 86 { 87 } 89 90 String parentPath = getPath(); 92 int lastPos = parentPath.lastIndexOf(WebDAVHelper.PathSeperator); 93 94 NodeRef parentNodeRef = null; 95 96 if ( lastPos == 0) 97 { 98 100 parentPath = WebDAVHelper.PathSeperator; 101 parentNodeRef = getRootNodeRef(); 102 } 103 else if (lastPos != -1) 104 { 105 parentPath = parentPath.substring(0, lastPos + 1); 107 try 108 { 109 FileInfo parentFileInfo = getDAVHelper().getNodeForPath(getRootNodeRef(), parentPath, m_request.getServletPath()); 110 parentNodeRef = parentFileInfo.getNodeRef(); 111 } 112 catch (FileNotFoundException e) 113 { 114 throw new WebDAVServerException(HttpServletResponse.SC_NOT_FOUND); 116 } 117 } 118 else 119 { 120 throw new WebDAVServerException(HttpServletResponse.SC_METHOD_NOT_ALLOWED); 122 } 123 124 String folderName = getPath().substring(lastPos + 1); 126 127 fileFolderService.create(parentNodeRef, folderName, ContentModel.TYPE_FOLDER); 129 130 m_response.setStatus(HttpServletResponse.SC_CREATED); 132 } 133 } 134 | Popular Tags |