docs(bruno): overhaul bruno to match new API
This commit is contained in:
@@ -30,11 +30,9 @@ public class SecurityConfig {
|
||||
.addFilterBefore(jwtFilter, UsernamePasswordAuthenticationFilter.class)
|
||||
.authorizeHttpRequests(auth -> auth
|
||||
.requestMatchers(HttpMethod.OPTIONS, "/api/v1/**").permitAll()
|
||||
.requestMatchers("/api/v1/download/clip/**","/api/v1/clips/", "/api/v1/clips/**").authenticated()
|
||||
.requestMatchers("/api/v1/auth/login", "/api/v1/auth/user").permitAll()
|
||||
.requestMatchers("/api/v1/upload", "/api/v1/download/**").permitAll()
|
||||
.requestMatchers("/api/v1/edit/**", "/api/v1/process/**", "/api/v1/progress/**", "/api/v1/convert/**").permitAll()
|
||||
.requestMatchers("/api/v1/metadata/**").permitAll()
|
||||
.requestMatchers("/api/v1/media/**").authenticated()
|
||||
.requestMatchers("/api/v1/jobs/**").authenticated()
|
||||
.requestMatchers("/api/v1/users/me", "/api/v1/users/logout").authenticated()
|
||||
.requestMatchers("/api/v1/stream/start", "/api/v1/stream/stop", "/api/v1/stream/heartbeat").permitAll()
|
||||
.anyRequest().authenticated()
|
||||
)
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.ddf.vodsystem.controllers;
|
||||
import com.ddf.vodsystem.controllers.dto.JobResponse;
|
||||
import com.ddf.vodsystem.dto.APIResponse;
|
||||
import com.ddf.vodsystem.dto.Job;
|
||||
import com.ddf.vodsystem.exceptions.ClipNotFound;
|
||||
import com.ddf.vodsystem.exceptions.NotReadyException;
|
||||
import com.ddf.vodsystem.services.JobRegistryService;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
@@ -17,7 +18,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("api/v1/job")
|
||||
@RequestMapping("api/v1/jobs")
|
||||
public class JobController {
|
||||
private final JobRegistryService jobRegistryService;
|
||||
private static final String SUCCESS = "success";
|
||||
@@ -57,7 +58,7 @@ public class JobController {
|
||||
Resource resource = new FileSystemResource(job.getDownload());
|
||||
|
||||
if (!resource.exists()) {
|
||||
return ResponseEntity.notFound().build();
|
||||
throw new ClipNotFound("Job download file " + job.getDownload() + " does not exist.");
|
||||
}
|
||||
|
||||
return ResponseEntity.ok()
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
package com.ddf.vodsystem.controllers;
|
||||
|
||||
import com.ddf.vodsystem.controllers.dto.ClipSectionRequest;
|
||||
import com.ddf.vodsystem.controllers.dto.SaveSectionRequest;
|
||||
import com.ddf.vodsystem.controllers.dto.UUIDResponse;
|
||||
import com.ddf.vodsystem.dto.Job;
|
||||
import com.ddf.vodsystem.dto.ClipOptions;
|
||||
import com.ddf.vodsystem.dto.APIResponse;
|
||||
import com.ddf.vodsystem.services.MediaService;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Instant;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/media")
|
||||
@@ -22,10 +25,10 @@ public class MediaController {
|
||||
this.mediaService = mediaService;
|
||||
}
|
||||
|
||||
@PostMapping("/compress")
|
||||
@PostMapping(value = "/compress", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public ResponseEntity<APIResponse<UUIDResponse>> compress(
|
||||
@RequestParam("file")MultipartFile file,
|
||||
@RequestParam("options") ClipOptions options
|
||||
@Valid @ModelAttribute ClipOptions options
|
||||
) throws IOException, InterruptedException {
|
||||
Job job = mediaService.compress(file, options);
|
||||
return ResponseEntity.ok(new APIResponse<>(
|
||||
@@ -38,9 +41,8 @@ public class MediaController {
|
||||
|
||||
@PostMapping("/save")
|
||||
public ResponseEntity<APIResponse<UUIDResponse>> save(
|
||||
@RequestParam("start") Instant startTime,
|
||||
@RequestParam("end") Instant endTime) throws IOException {
|
||||
Job job = mediaService.saveSection(startTime, endTime);
|
||||
@RequestBody SaveSectionRequest saveSectionRequest) throws IOException {
|
||||
Job job = mediaService.saveSection(saveSectionRequest.startTime(), saveSectionRequest.endTime());
|
||||
return ResponseEntity.ok(new APIResponse<>(
|
||||
SUCCESS,
|
||||
"Section saving successfully started",
|
||||
@@ -50,8 +52,8 @@ public class MediaController {
|
||||
|
||||
@PostMapping("/clip")
|
||||
public ResponseEntity<APIResponse<UUIDResponse>> clip(
|
||||
@RequestParam("duration") float duration) throws IOException {
|
||||
Job job = mediaService.clip(duration);
|
||||
@RequestBody ClipSectionRequest clipSectionRequest) throws IOException {
|
||||
Job job = mediaService.clip(clipSectionRequest.duration());
|
||||
return ResponseEntity.ok(new APIResponse<>(
|
||||
SUCCESS,
|
||||
"Clipping successfully started",
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/user/")
|
||||
@RequestMapping("/api/v1/users")
|
||||
public class UserController {
|
||||
private final UserService userService;
|
||||
|
||||
|
||||
@@ -1,15 +1,31 @@
|
||||
package com.ddf.vodsystem.dto;
|
||||
|
||||
import jakarta.validation.constraints.*;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ClipOptions {
|
||||
@NotBlank
|
||||
private String title;
|
||||
|
||||
private String description;
|
||||
|
||||
@NotNull
|
||||
@Positive
|
||||
private Float startPoint;
|
||||
|
||||
@NotNull @Positive
|
||||
private Float duration;
|
||||
|
||||
@DecimalMin("1.0") @DecimalMax("120.0")
|
||||
private Float fps;
|
||||
|
||||
@Positive
|
||||
private Integer width;
|
||||
|
||||
@Positive
|
||||
private Integer height;
|
||||
|
||||
@Positive
|
||||
private Float fileSize;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.context.SecurityContext;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
@@ -60,9 +61,12 @@ public class JwtFilter extends OncePerRequestFilter {
|
||||
}
|
||||
|
||||
Optional<Authentication> authentication = getAuthentication(jwt);
|
||||
authentication.ifPresent(value ->
|
||||
SecurityContextHolder.getContext().setAuthentication(value)
|
||||
);
|
||||
authentication.ifPresent(auth -> {
|
||||
SecurityContext context = SecurityContextHolder.createEmptyContext();
|
||||
context.setAuthentication(auth);
|
||||
SecurityContextHolder.setContext(context);
|
||||
});
|
||||
|
||||
filterChain.doFilter(request, response);
|
||||
}
|
||||
|
||||
|
||||
@@ -229,7 +229,7 @@ public class ClipService {
|
||||
try {
|
||||
newClipFile = directoryService.getUserClipsFile(user.getId(), fileName);
|
||||
thumbnailFile = directoryService.getUserThumbnailsFile(user.getId(), fileName + ".png");
|
||||
directoryService.cutFile(clipFile, newClipFile);
|
||||
directoryService.copyFile(clipFile, newClipFile);
|
||||
} catch (IOException e) {
|
||||
throw new StorageException("Failed to move clip from temporary directory to output directory", e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user