|
|
@ -1,6 +1,7 @@ |
|
|
package rest |
|
|
package rest |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
|
|
|
"encoding/xml" |
|
|
"fmt" |
|
|
"fmt" |
|
|
"net/http" |
|
|
"net/http" |
|
|
"net/url" |
|
|
"net/url" |
|
|
@ -50,9 +51,18 @@ func (this *DavService) makePropstatResponse(href string, pstats []dav.Propstat) |
|
|
return &resp |
|
|
return &resp |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//从一个matter中获取其propnames,每个propname都是一个xml标签。
|
|
|
|
|
|
func (this *DavService) PropNames(matter *Matter) []xml.Name { |
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//处理 方法
|
|
|
//处理 方法
|
|
|
func (this *DavService) HandlePropfind(writer http.ResponseWriter, request *http.Request, subPath string) { |
|
|
func (this *DavService) HandlePropfind(writer http.ResponseWriter, request *http.Request, subPath string) { |
|
|
|
|
|
|
|
|
|
|
|
fmt.Printf("列出文件/文件夹 %s\n", subPath) |
|
|
|
|
|
|
|
|
//获取请求者
|
|
|
//获取请求者
|
|
|
user := this.checkUser(writer, request) |
|
|
user := this.checkUser(writer, request) |
|
|
|
|
|
|
|
|
@ -63,10 +73,26 @@ func (this *DavService) HandlePropfind(writer http.ResponseWriter, request *http |
|
|
propfind, _, err := dav.ReadPropfind(request.Body) |
|
|
propfind, _, err := dav.ReadPropfind(request.Body) |
|
|
this.PanicError(err) |
|
|
this.PanicError(err) |
|
|
|
|
|
|
|
|
|
|
|
//寻找符合条件的matter.
|
|
|
|
|
|
matters := this.matterDao.ListByUserUuidAndPath(user.Uuid, subPath) |
|
|
|
|
|
if len(matters) == 0 { |
|
|
|
|
|
this.PanicNotFound("%s不存在", subPath) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//准备一个输出结果的Writer
|
|
|
//准备一个输出结果的Writer
|
|
|
multiStatusWriter := dav.MultiStatusWriter{Writer: writer} |
|
|
multiStatusWriter := dav.MultiStatusWriter{Writer: writer} |
|
|
|
|
|
|
|
|
|
|
|
for _, matter := range matters { |
|
|
|
|
|
|
|
|
|
|
|
fmt.Printf("开始分析 %s\n", matter.Name) |
|
|
|
|
|
|
|
|
var propstats []dav.Propstat |
|
|
var propstats []dav.Propstat |
|
|
|
|
|
var props = make([]dav.Property, 0) |
|
|
|
|
|
props = append(props, dav.Property{ |
|
|
|
|
|
XMLName: xml.Name{Space: "DAV:"}, |
|
|
|
|
|
}) |
|
|
propstats = append(propstats, dav.Propstat{ |
|
|
propstats = append(propstats, dav.Propstat{ |
|
|
|
|
|
Props: props, |
|
|
ResponseDescription: "有点问题", |
|
|
ResponseDescription: "有点问题", |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
@ -74,6 +100,11 @@ func (this *DavService) HandlePropfind(writer http.ResponseWriter, request *http |
|
|
|
|
|
|
|
|
err = multiStatusWriter.Write(response) |
|
|
err = multiStatusWriter.Write(response) |
|
|
this.PanicError(err) |
|
|
this.PanicError(err) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//闭合
|
|
|
|
|
|
err = multiStatusWriter.Close() |
|
|
|
|
|
this.PanicError(err) |
|
|
|
|
|
|
|
|
fmt.Printf("%v %v \n", matter.Name, propfind.Prop) |
|
|
fmt.Printf("%v %v \n", matter.Name, propfind.Prop) |
|
|
|
|
|
|
|
|
|