Code review for SecurityCamera
This commit is contained in:
parent
2b93ffa07b
commit
cddf718767
5 changed files with 3 additions and 14 deletions
|
@ -71,6 +71,7 @@ public class SpringFoxConfig {
|
|||
.or(PathSelectors.regex("/dimmableLight.*")::apply)
|
||||
.or(PathSelectors.regex("/knobDimmer.*")::apply)
|
||||
.or(PathSelectors.regex("/regularLight.*")::apply)
|
||||
.or(PathSelectors.regex("/securityCamera.*")::apply)
|
||||
.or(PathSelectors.regex("/sensor.*")::apply)
|
||||
.or(PathSelectors.regex("/smartPlug.*")::apply)
|
||||
.or(PathSelectors.regex("/switch.*")::apply)
|
||||
|
|
|
@ -51,6 +51,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|||
// dont authenticate this particular request
|
||||
.authorizeRequests()
|
||||
.antMatchers(
|
||||
"/security_camera_videos/**",
|
||||
"/sensor-socket",
|
||||
"/auth/login",
|
||||
"/swagger-ui.html",
|
||||
|
|
|
@ -11,7 +11,6 @@ import java.util.List;
|
|||
import javax.validation.Valid;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
@ -38,12 +37,6 @@ public class SecurityCameraController {
|
|||
return securityCameraService.findById(id).orElseThrow(NotFoundException::new);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}/video")
|
||||
public FileSystemResource getVideo(@PathVariable("id") long id) throws NotFoundException {
|
||||
SecurityCamera s = findById(id);
|
||||
return s.getSurveillanceVideo();
|
||||
}
|
||||
|
||||
private SecurityCamera save(SecurityCamera newSC, SecurityCameraSaveRequest sc) {
|
||||
newSC.setName(sc.getName());
|
||||
newSC.setRoomId(sc.getRoomId());
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
||||
|
||||
import java.io.File;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
|
||||
@Entity
|
||||
public class SecurityCamera extends Switchable {
|
||||
|
@ -20,16 +18,12 @@ public class SecurityCamera extends Switchable {
|
|||
|
||||
@Column(name = "video", nullable = false)
|
||||
@NotNull
|
||||
private String path = "backend/media/security_camera_videos/security_camera_1.mp4";
|
||||
private String path = "/security_camera_videos/security_camera_1.mp4";
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public FileSystemResource getSurveillanceVideo() {
|
||||
return new FileSystemResource(new File(path));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOn() {
|
||||
return on;
|
||||
|
|
Loading…
Reference in a new issue