Improve logging/exception messages in RecordingPreconditions
This commit is contained in:
parent
2afd0820e5
commit
4e5287c177
|
@ -1,5 +1,12 @@
|
||||||
package ctbrec.recorder;
|
package ctbrec.recorder;
|
||||||
import static ctbrec.recorder.NextGenLocalRecorder.*;
|
|
||||||
|
import ctbrec.Config;
|
||||||
|
import ctbrec.Model;
|
||||||
|
import ctbrec.ModelGroup;
|
||||||
|
import ctbrec.Recording;
|
||||||
|
import ctbrec.recorder.download.Download;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.InvalidKeyException;
|
import java.security.InvalidKeyException;
|
||||||
|
@ -11,14 +18,7 @@ import java.util.Optional;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import static ctbrec.recorder.NextGenLocalRecorder.IGNORE_CACHE;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import ctbrec.Config;
|
|
||||||
import ctbrec.Model;
|
|
||||||
import ctbrec.ModelGroup;
|
|
||||||
import ctbrec.Recording;
|
|
||||||
import ctbrec.recorder.download.Download;
|
|
||||||
|
|
||||||
public class RecordingPreconditions {
|
public class RecordingPreconditions {
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ public class RecordingPreconditions {
|
||||||
LocalTime now = LocalTime.now();
|
LocalTime now = LocalTime.now();
|
||||||
if (start.isBefore(end) && now.isAfter(start) && now.isBefore(end)) {
|
if (start.isBefore(end) && now.isAfter(start) && now.isBefore(end)) {
|
||||||
throw new PreconditionNotMetException("Current time is in recording timeout " + start + " - " + end);
|
throw new PreconditionNotMetException("Current time is in recording timeout " + start + " - " + end);
|
||||||
} else if(start.isAfter(end) && !(now.isAfter(end) && now.isBefore(start))) { // NOSONAR
|
} else if (start.isAfter(end) && !(now.isAfter(end) && now.isBefore(start))) { // NOSONAR
|
||||||
throw new PreconditionNotMetException("Current time is in recording timeout " + start + " - " + end);
|
throw new PreconditionNotMetException("Current time is in recording timeout " + start + " - " + end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,8 +168,14 @@ public class RecordingPreconditions {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
Optional<Model> otherModel = getModelForUrl(modelUrl);
|
Optional<Model> otherModel = getModelForUrl(modelUrl);
|
||||||
if (otherModel.isPresent() && (otherModelIsRecorded(otherModel.get()) || otherModelCanBeRecorded(otherModel.get()))) {
|
if (otherModel.isPresent()) {
|
||||||
|
if (otherModelIsRecorded(otherModel.get())) {
|
||||||
throw new PreconditionNotMetException(otherModel.get() + " from the same group is already recorded");
|
throw new PreconditionNotMetException(otherModel.get() + " from the same group is already recorded");
|
||||||
|
} else if (otherModelCanBeRecorded(otherModel.get())) {
|
||||||
|
throw new PreconditionNotMetException(otherModel.get() + " from the same group can be recorded");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LOG.warn("Couldn't check if model from same group has higer prio for {}", modelUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue