Merge branch 'sonar-fix' into 'dev'
more Sonarqube fixes See merge request sa4-2020/the-sanmarinoes/backend!121
This commit is contained in:
commit
f7927887b8
6 changed files with 13 additions and 12 deletions
|
@ -14,7 +14,7 @@ import org.springframework.stereotype.Component;
|
||||||
@Component
|
@Component
|
||||||
public class JWTTokenUtils {
|
public class JWTTokenUtils {
|
||||||
/** The duration in seconds of the validity of a single token */
|
/** The duration in seconds of the validity of a single token */
|
||||||
private static final long JWT_TOKEN_VALIDITY = 5 * 60 * 60;
|
private static final long JWT_TOKEN_VALIDITY = (long) 5 * 60 * 60;
|
||||||
|
|
||||||
/** The secret key used to encrypt all JWTs */
|
/** The secret key used to encrypt all JWTs */
|
||||||
@Value("${jwt.secret}")
|
@Value("${jwt.secret}")
|
||||||
|
|
|
@ -6,7 +6,6 @@ import ch.usi.inf.sa4.sanmarinoes.smarthut.models.MotionSensor;
|
||||||
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.MotionSensorRepository;
|
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.MotionSensorRepository;
|
||||||
import ch.usi.inf.sa4.sanmarinoes.smarthut.service.DeviceService;
|
import ch.usi.inf.sa4.sanmarinoes.smarthut.service.DeviceService;
|
||||||
import ch.usi.inf.sa4.sanmarinoes.smarthut.service.MotionSensorService;
|
import ch.usi.inf.sa4.sanmarinoes.smarthut.service.MotionSensorService;
|
||||||
import ch.usi.inf.sa4.sanmarinoes.smarthut.socket.SensorSocketEndpoint;
|
|
||||||
import java.security.Principal;
|
import java.security.Principal;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -21,7 +20,6 @@ public class MotionSensorController {
|
||||||
@Autowired private DeviceService deviceService;
|
@Autowired private DeviceService deviceService;
|
||||||
@Autowired private MotionSensorService motionSensorService;
|
@Autowired private MotionSensorService motionSensorService;
|
||||||
@Autowired private MotionSensorRepository motionSensorRepository;
|
@Autowired private MotionSensorRepository motionSensorRepository;
|
||||||
@Autowired private SensorSocketEndpoint sensorSocketEndpoint;
|
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public MotionSensor create(
|
public MotionSensor create(
|
||||||
|
|
|
@ -76,8 +76,8 @@ public class SecurityCameraController {
|
||||||
.findByIdAndUsername(deviceId, principal.getName())
|
.findByIdAndUsername(deviceId, principal.getName())
|
||||||
.orElseThrow(NotFoundException::new);
|
.orElseThrow(NotFoundException::new);
|
||||||
State<? extends Switchable> s = d.cloneState();
|
State<? extends Switchable> s = d.cloneState();
|
||||||
sceneRepository.findById(sceneId).orElseThrow(NotFoundException::new);
|
final Scene sc = sceneRepository.findById(sceneId).orElseThrow(NotFoundException::new);
|
||||||
s.setSceneId(sceneId);
|
s.setSceneId(sc.getId());
|
||||||
if (stateRepository.countByDeviceIdAndSceneId(deviceId, sceneId) > 0)
|
if (stateRepository.countByDeviceIdAndSceneId(deviceId, sceneId) > 0)
|
||||||
throw new DuplicateStateException();
|
throw new DuplicateStateException();
|
||||||
return stateRepository.save(s);
|
return stateRepository.save(s);
|
||||||
|
|
|
@ -4,7 +4,6 @@ import ch.usi.inf.sa4.sanmarinoes.smarthut.config.GsonExclude;
|
||||||
import ch.usi.inf.sa4.sanmarinoes.smarthut.config.SocketGsonExclude;
|
import ch.usi.inf.sa4.sanmarinoes.smarthut.config.SocketGsonExclude;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
|
||||||
|
@ -13,6 +12,14 @@ import javax.persistence.*;
|
||||||
@Inheritance(strategy = InheritanceType.JOINED)
|
@Inheritance(strategy = InheritanceType.JOINED)
|
||||||
public abstract class Device {
|
public abstract class Device {
|
||||||
|
|
||||||
|
public Set<Trigger<? extends Device>> getTriggers() {
|
||||||
|
return triggers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<State<?>> getStates() {
|
||||||
|
return states;
|
||||||
|
}
|
||||||
|
|
||||||
/** Ways a device can behave in the automation flow. For now only input/output */
|
/** Ways a device can behave in the automation flow. For now only input/output */
|
||||||
public enum FlowType {
|
public enum FlowType {
|
||||||
@SerializedName("INPUT")
|
@SerializedName("INPUT")
|
||||||
|
@ -38,7 +45,7 @@ public abstract class Device {
|
||||||
@OneToMany(mappedBy = "device", orphanRemoval = true)
|
@OneToMany(mappedBy = "device", orphanRemoval = true)
|
||||||
@GsonExclude
|
@GsonExclude
|
||||||
@SocketGsonExclude
|
@SocketGsonExclude
|
||||||
private Set<Trigger<? extends Device>> triggers = new HashSet<>();
|
private Set<Trigger<? extends Device>> triggers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The room this device belongs in, as a foreign key id. To use when updating and inserting from
|
* The room this device belongs in, as a foreign key id. To use when updating and inserting from
|
||||||
|
@ -66,7 +73,7 @@ public abstract class Device {
|
||||||
@OneToMany(mappedBy = "device", orphanRemoval = true)
|
@OneToMany(mappedBy = "device", orphanRemoval = true)
|
||||||
@GsonExclude
|
@GsonExclude
|
||||||
@SocketGsonExclude
|
@SocketGsonExclude
|
||||||
private Set<State<?>> states = new HashSet<>();
|
private Set<State<?>> states;
|
||||||
|
|
||||||
@Transient @GsonExclude private Long fromHostId = null;
|
@Transient @GsonExclude private Long fromHostId = null;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class RangeTrigger<D extends Device & RangeTriggerable> extends Trigger<D> {
|
public class RangeTrigger<D extends Device & RangeTriggerable> extends Trigger<D> {
|
||||||
|
@ -46,7 +45,6 @@ public class RangeTrigger<D extends Device & RangeTriggerable> extends Trigger<D
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private Operator operator;
|
private Operator operator;
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private double range;
|
private double range;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
||||||
import ch.usi.inf.sa4.sanmarinoes.smarthut.config.GsonExclude;
|
import ch.usi.inf.sa4.sanmarinoes.smarthut.config.GsonExclude;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
|
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
|
||||||
|
@ -45,7 +44,6 @@ public abstract class Trigger<D extends Device> {
|
||||||
private Automation automation;
|
private Automation automation;
|
||||||
|
|
||||||
@Column(name = "automation_id", nullable = false)
|
@Column(name = "automation_id", nullable = false)
|
||||||
@NotNull
|
|
||||||
private Long automationId;
|
private Long automationId;
|
||||||
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
|
|
Loading…
Reference in a new issue