working commit
This commit is contained in:
@@ -198,3 +198,65 @@ func (hand *Handler) ListFiles(rctx *router.Context) {
|
||||
}
|
||||
rctx.SendJSON(code, res.Files)
|
||||
}
|
||||
|
||||
func (hand *Handler) ListCollections(rctx *router.Context) {
|
||||
|
||||
cpath, _ := rctx.GetSubpath("path")
|
||||
if cpath == "" {
|
||||
cpath = "/"
|
||||
}
|
||||
params := &operator.ListCollectionsParams{
|
||||
Path: cpath,
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadFiles, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
if !opEnable {
|
||||
rctx.SetStatus(http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
// Execution of the operation
|
||||
ctx := rctx.GetContext()
|
||||
code, res, err := hand.oper.ListCollections(ctx, operatorID, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("ListCollections error: %v", err)
|
||||
rctx.SetStatus(code)
|
||||
return
|
||||
}
|
||||
rctx.SendJSON(code, res.Collections)
|
||||
}
|
||||
|
||||
func (hand *Handler) DeleteCollection(rctx *router.Context) {
|
||||
|
||||
cpath, _ := rctx.GetSubpath("path")
|
||||
if cpath == "" {
|
||||
cpath = "/"
|
||||
}
|
||||
params := &operator.DeleteColletionParams{
|
||||
Path: cpath,
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadFiles, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
if !opEnable {
|
||||
rctx.SetStatus(http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
// Execution of the operation
|
||||
ctx := rctx.GetContext()
|
||||
code, res, err := hand.oper.DeleteColletion(ctx, operatorID, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("DeleteColletion error: %v", err)
|
||||
rctx.SetStatus(code)
|
||||
return
|
||||
}
|
||||
rctx.SendJSON(code, res.Files)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user