All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sippnex.fileblade.controller.DirectoryController Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
package com.sippnex.fileblade.controller;

import com.sippnex.fileblade.domain.FbDirectory;
import com.sippnex.fileblade.domain.FbElement;
import com.sippnex.fileblade.service.DirectoryService;
import com.sippnex.fileblade.util.PathUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Set;

@RestController
@RequestMapping("/fileblade/directories")
public class DirectoryController {

    private final DirectoryService directoryService;

    public DirectoryController(DirectoryService directoryService) {
        this.directoryService = directoryService;
    }

    @GetMapping("**")
    public Set readDirectory(HttpServletRequest request) throws IOException {
        String pathString = PathUtils.getPathFromRequest(request);
        return directoryService.readDirectory(new FbDirectory(pathString));
    }

    @PostMapping("**")
    public void createDirectory(HttpServletRequest request) throws IOException {
        String pathString = PathUtils.getPathFromRequest(request);
        directoryService.createDirectory(new FbDirectory(pathString));
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy