old changes I don't remember
This commit is contained in:
parent
fc1e3d8daa
commit
e20fc79c65
|
@ -11,6 +11,7 @@ public abstract class CommonConfigFileLoader<P extends Enum<P>> {
|
|||
private static final String CONFIG_FOLDER = "/config";
|
||||
|
||||
public enum CommonProjectConfiguration {
|
||||
FILEBOT_PATHS_STARTER,
|
||||
SONARR_API_HOST,
|
||||
SONARR_API_KEY,
|
||||
SONARR_PATHS_STARTER,
|
||||
|
|
|
@ -5,11 +5,11 @@ import org.apache.commons.lang.StringUtils;
|
|||
|
||||
public class LocalEnvironmentManager {
|
||||
|
||||
public enum LocalMode {NAS, PC, CONTABO}
|
||||
public enum LocalMode {NAS, PC}
|
||||
|
||||
static LocalMode mode;
|
||||
static {
|
||||
mode = LocalMode.CONTABO;
|
||||
mode = LocalMode.NAS;
|
||||
}
|
||||
|
||||
public static final String PROJECT_ROOT = System.getProperty("user.dir");
|
||||
|
@ -35,7 +35,7 @@ public class LocalEnvironmentManager {
|
|||
}
|
||||
|
||||
public static boolean isWorkingWithProdFiles () {
|
||||
return mode.equals(LocalMode.CONTABO) || !isLocal();
|
||||
return mode.equals(LocalMode.NAS) || !isLocal();
|
||||
}
|
||||
|
||||
public static LocalMode getLocalMode() {
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
package tv.mangrana.jobs;
|
||||
|
||||
import tv.mangrana.config.LocalEnvironmentManager;
|
||||
import tv.mangrana.exception.JobFileNotMovedException;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static tv.mangrana.jobs.JobFile.JobLocation.*;
|
||||
import static tv.mangrana.utils.PathUtils.shiftFileFolder;
|
||||
|
||||
public abstract class JobFile<E> {
|
||||
|
||||
public enum JobLocation {
|
||||
PATH_TODO("to_do"),
|
||||
PATH_DOING("doing"),
|
||||
PATH_DONE("done");
|
||||
private final String folderName;
|
||||
private static final String LOCAL_WORKING_PATH = "local_test";
|
||||
JobLocation(String folderName) {
|
||||
this.folderName=folderName;
|
||||
}
|
||||
public String getFolderName(){
|
||||
return getLocalNameIfNecessary(this);
|
||||
}
|
||||
private String getLocalNameIfNecessary(JobLocation location) {
|
||||
if (LocalEnvironmentManager.isLocal() && !LocalEnvironmentManager.isWorkingWithProdFiles()
|
||||
&& (location.equals(JobLocation.PATH_TODO) || location.equals(JobLocation.PATH_DOING))) {
|
||||
return LOCAL_WORKING_PATH;
|
||||
}
|
||||
return location.folderName;
|
||||
}
|
||||
}
|
||||
|
||||
protected JobFile(File jobFile) {
|
||||
this.jobFile = jobFile;
|
||||
}
|
||||
|
||||
public abstract String getInfo(E key);
|
||||
|
||||
public abstract boolean hasNoInfo();
|
||||
|
||||
protected File jobFile;
|
||||
|
||||
public File getFile () {
|
||||
return jobFile;
|
||||
}
|
||||
|
||||
|
||||
public void markDoing() throws JobFileNotMovedException {
|
||||
if (jobFile.getAbsolutePath().contains(PATH_TODO.getFolderName())) {
|
||||
jobFile = shiftFileFolder(jobFile, PATH_TODO, PATH_DOING);
|
||||
}
|
||||
}
|
||||
|
||||
public void markDone() throws JobFileNotMovedException {
|
||||
jobFile = shiftFileFolder(jobFile, PATH_DOING, PATH_DONE);
|
||||
}
|
||||
|
||||
public void forceMarkDone() throws JobFileNotMovedException {
|
||||
if (jobFile.getAbsolutePath().contains(PATH_DOING.getFolderName())) {
|
||||
jobFile = shiftFileFolder(jobFile, PATH_DOING, PATH_DONE);
|
||||
} else if (jobFile.getAbsolutePath().contains(PATH_TODO.getFolderName())) {
|
||||
jobFile = shiftFileFolder(jobFile, PATH_TODO, PATH_DONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void driveBack() throws JobFileNotMovedException {
|
||||
if (jobFile.getAbsolutePath().contains(PATH_DOING.getFolderName())) {
|
||||
jobFile = shiftFileFolder(jobFile, PATH_DOING, PATH_TODO);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
package tv.mangrana.jobs;
|
||||
|
||||
import tv.mangrana.config.LocalEnvironmentManager;
|
||||
import tv.mangrana.exception.JobFileNotMovedException;
|
||||
import tv.mangrana.utils.PathUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static tv.mangrana.config.LocalEnvironmentManager.LocalMode.CONTABO;
|
||||
import static tv.mangrana.config.LocalEnvironmentManager.getLocalMode;
|
||||
import static tv.mangrana.jobs.JobFile.JobLocation;
|
||||
import static tv.mangrana.jobs.JobFile.JobLocation.PATH_DOING;
|
||||
import static tv.mangrana.jobs.JobFile.JobLocation.PATH_TODO;
|
||||
import static tv.mangrana.utils.PathUtils.addSubElement;
|
||||
import static tv.mangrana.utils.PathUtils.rootFolder;
|
||||
|
||||
public class JobFileManager {
|
||||
|
||||
private JobFileManager(){}
|
||||
|
||||
static final String JOBS_FOLDER = "jobs";
|
||||
static final String CONTABO_JOBS_FOLDER = "contabo_jobs";
|
||||
|
||||
static final String RESUME_FILE = "jobs.txt";
|
||||
|
||||
public enum JobFileType {
|
||||
SONARR_JOBS("sonarr"),
|
||||
RADARR_JOBS("radarr"),
|
||||
TRANSMISSION_JOBS("transm");
|
||||
|
||||
private final String folderName;
|
||||
JobFileType(String folderName) {
|
||||
this.folderName=folderName;
|
||||
}
|
||||
public String getFolderName(){
|
||||
return folderName;
|
||||
}
|
||||
}
|
||||
public static void moveUncompletedJobsToRetry(JobFileType appType) {
|
||||
File jobsDir = new File(getAbsolutePath(PATH_DOING, appType));
|
||||
File[] files = jobsDir.listFiles();
|
||||
List<File> uncompleted = files!=null
|
||||
? Arrays.asList(files)
|
||||
: Collections.emptyList();
|
||||
uncompleted.forEach(file -> {
|
||||
try {
|
||||
PathUtils.shiftFileFolder(file, PATH_DOING, PATH_TODO);
|
||||
} catch (JobFileNotMovedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static List<File> retrieveJobFiles(String fileIdentifierRegex, JobFileType appType) {
|
||||
File jobsDir = new File(getAbsolutePath(PATH_TODO, appType));
|
||||
File[] files = jobsDir.listFiles();
|
||||
return files==null
|
||||
? Collections.emptyList()
|
||||
: Arrays.stream(files)
|
||||
.filter(file -> file.getName().matches(fileIdentifierRegex))
|
||||
.sorted(PathUtils::compareFileCreationDate)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static String getAbsolutePath(JobLocation location, JobFileType appType) {
|
||||
String jobsFolder = getJobsFolder();
|
||||
String appFolderPath = addSubElement(jobsFolder, appType.getFolderName());
|
||||
return addSubElement(appFolderPath, location.getFolderName());
|
||||
}
|
||||
|
||||
public static String getResumeFile() {
|
||||
String jobsFolder = getJobsFolder();
|
||||
return addSubElement(jobsFolder, RESUME_FILE);
|
||||
}
|
||||
|
||||
public static String getJobsFolder() {
|
||||
return LocalEnvironmentManager.isLocal()
|
||||
? addSubElement(rootFolder(LocalEnvironmentManager.getLocalRootPath()), getLocalJobsFolderName())
|
||||
: rootFolder(JOBS_FOLDER);
|
||||
}
|
||||
|
||||
static String getLocalJobsFolderName() {
|
||||
return CONTABO.equals(getLocalMode())
|
||||
? CONTABO_JOBS_FOLDER
|
||||
: JOBS_FOLDER;
|
||||
}
|
||||
}
|
|
@ -1,113 +0,0 @@
|
|||
package tv.mangrana.jobs;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import tv.mangrana.exception.IncorrectWorkingReferencesException;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.MessageFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static tv.mangrana.utils.Output.DATE_TIME_FORMAT;
|
||||
|
||||
public class JobsFileStorage {
|
||||
|
||||
static final String COMPLETED_DATE = "done";
|
||||
static final String JOB_TYPE = "type";
|
||||
static final String HASH = "hash";
|
||||
static final String ARR_ID = "arrId";
|
||||
static final String INTERNET_DB_ID = "iId";
|
||||
static final String ELEMENT_NAME = "element";
|
||||
|
||||
public final String JOB_LINE_FORMAT;
|
||||
private static final String RESUME_FILE = JobFileManager.getResumeFile();
|
||||
|
||||
private final List<Map<String, String>> linesInfo;
|
||||
|
||||
public JobsFileStorage() throws IncorrectWorkingReferencesException {
|
||||
String preFormat = "{COMPLETED_DATE}: {5} | {JOB_TYPE}: {0} | {HASH}: {1} | {ARR_ID}: {2} | {INTERNET_DB_ID}: {3} | {ELEMENT_NAME}: {4}";
|
||||
JOB_LINE_FORMAT = preFormat
|
||||
.replace("{COMPLETED_DATE}", COMPLETED_DATE)
|
||||
.replace("{JOB_TYPE}", JOB_TYPE)
|
||||
.replace("{HASH}", HASH)
|
||||
.replace("{ARR_ID}", ARR_ID)
|
||||
.replace("{INTERNET_DB_ID}", INTERNET_DB_ID)
|
||||
.replace("{ELEMENT_NAME}", ELEMENT_NAME);
|
||||
|
||||
linesInfo = getInfoFromFile();
|
||||
}
|
||||
|
||||
private List<Map<String, String>> getInfoFromFile() throws IncorrectWorkingReferencesException {
|
||||
List<Map<String, String>> newLinesInfo = new ArrayList<>();
|
||||
try (Stream<String> linesStream = Files.lines(Paths.get(RESUME_FILE))) {
|
||||
linesStream
|
||||
.filter(probableLine -> StringUtils.isNotEmpty(probableLine) && probableLine.contains("|"))
|
||||
.forEach(line -> newLinesInfo.add(line2Map(line)));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new IncorrectWorkingReferencesException("A problem occurred when trying to get jobs file info");
|
||||
}
|
||||
return newLinesInfo;
|
||||
}
|
||||
|
||||
private Map<String, String> line2Map(String line) {
|
||||
Map<String, String> mappedLine = new HashMap<>();
|
||||
String[] infoList = line.split("\\|");
|
||||
for (String elementInfo : infoList) {
|
||||
if (!elementInfo.trim().startsWith(COMPLETED_DATE)) {
|
||||
String[] fieldValue = elementInfo.split(":");
|
||||
String field = fieldValue[0].trim();
|
||||
String value = fieldValue[1].trim();
|
||||
mappedLine.put(field, value);
|
||||
}
|
||||
}
|
||||
return mappedLine;
|
||||
}
|
||||
|
||||
public void persistCompleted(String type, String downloadId, int arrId, int iId, String element, LocalDateTime time){
|
||||
String jobLine = MessageFormat.format(JOB_LINE_FORMAT,
|
||||
type,
|
||||
downloadId,
|
||||
fixLength(String.valueOf(arrId)),
|
||||
fixLength(String.valueOf(iId)),
|
||||
element,
|
||||
formatTime(time));
|
||||
addLine(jobLine);
|
||||
}
|
||||
|
||||
String fixLength(String text) {
|
||||
return StringUtils.rightPad(text, 7);
|
||||
}
|
||||
|
||||
void addLine(String jobLine) {
|
||||
try (FileWriter fw = new FileWriter(RESUME_FILE, true);
|
||||
PrintWriter pw = new PrintWriter(fw)) {
|
||||
|
||||
pw.println(jobLine);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String getIIDByElement(String element) {
|
||||
return linesInfo.stream()
|
||||
.filter(mappedLine -> element.equals(mappedLine.get(ELEMENT_NAME)))
|
||||
.findAny()
|
||||
.map(found -> found.get(INTERNET_DB_ID))
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
String formatTime(LocalDateTime time) {
|
||||
return time.format(DateTimeFormatter.ofPattern(DATE_TIME_FORMAT));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package tv.mangrana.radarr.api.schema.movie;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
|
||||
import javax.annotation.Generated;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"ignoreEpisodesWithFiles",
|
||||
"ignoreEpisodesWithoutFiles",
|
||||
"monitor",
|
||||
"searchForMovie",
|
||||
"addMethod"
|
||||
})
|
||||
@Generated("jsonschema2pojo")
|
||||
public class AddOptions {
|
||||
|
||||
@JsonProperty("ignoreEpisodesWithFiles")
|
||||
private Boolean ignoreEpisodesWithFiles;
|
||||
@JsonProperty("ignoreEpisodesWithoutFiles")
|
||||
private Boolean ignoreEpisodesWithoutFiles;
|
||||
@JsonProperty("monitor")
|
||||
private String monitor;
|
||||
@JsonProperty("searchForMovie")
|
||||
private Boolean searchForMovie;
|
||||
@JsonProperty("addMethod")
|
||||
private String addMethod;
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new LinkedHashMap<String, Object>();
|
||||
|
||||
@JsonProperty("ignoreEpisodesWithFiles")
|
||||
public Boolean getIgnoreEpisodesWithFiles() {
|
||||
return ignoreEpisodesWithFiles;
|
||||
}
|
||||
|
||||
@JsonProperty("ignoreEpisodesWithFiles")
|
||||
public void setIgnoreEpisodesWithFiles(Boolean ignoreEpisodesWithFiles) {
|
||||
this.ignoreEpisodesWithFiles = ignoreEpisodesWithFiles;
|
||||
}
|
||||
|
||||
@JsonProperty("ignoreEpisodesWithoutFiles")
|
||||
public Boolean getIgnoreEpisodesWithoutFiles() {
|
||||
return ignoreEpisodesWithoutFiles;
|
||||
}
|
||||
|
||||
@JsonProperty("ignoreEpisodesWithoutFiles")
|
||||
public void setIgnoreEpisodesWithoutFiles(Boolean ignoreEpisodesWithoutFiles) {
|
||||
this.ignoreEpisodesWithoutFiles = ignoreEpisodesWithoutFiles;
|
||||
}
|
||||
|
||||
@JsonProperty("monitor")
|
||||
public String getMonitor() {
|
||||
return monitor;
|
||||
}
|
||||
|
||||
@JsonProperty("monitor")
|
||||
public void setMonitor(String monitor) {
|
||||
this.monitor = monitor;
|
||||
}
|
||||
|
||||
@JsonProperty("searchForMovie")
|
||||
public Boolean getSearchForMovie() {
|
||||
return searchForMovie;
|
||||
}
|
||||
|
||||
@JsonProperty("searchForMovie")
|
||||
public void setSearchForMovie(Boolean searchForMovie) {
|
||||
this.searchForMovie = searchForMovie;
|
||||
}
|
||||
|
||||
@JsonProperty("addMethod")
|
||||
public String getAddMethod() {
|
||||
return addMethod;
|
||||
}
|
||||
|
||||
@JsonProperty("addMethod")
|
||||
public void setAddMethod(String addMethod) {
|
||||
this.addMethod = addMethod;
|
||||
}
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,239 @@
|
|||
|
||||
package tv.mangrana.radarr.api.schema.movie;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Generated;
|
||||
import com.fasterxml.jackson.annotation.JsonAnyGetter;
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import tv.mangrana.radarr.api.schema.queue.Quality__1;
|
||||
import tv.mangrana.sonarr.api.schema.history.Revision;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"movieId",
|
||||
"relativePath",
|
||||
"path",
|
||||
"size",
|
||||
"dateAdded",
|
||||
"indexerFlags",
|
||||
"quality",
|
||||
"customFormats",
|
||||
"qualityCutoffNotMet",
|
||||
"languages",
|
||||
"edition",
|
||||
"id"
|
||||
})
|
||||
@Generated("jsonschema2pojo")
|
||||
public class MovieFile {
|
||||
|
||||
@JsonProperty("movieId")
|
||||
private Integer movieId;
|
||||
@JsonProperty("relativePath")
|
||||
private String relativePath;
|
||||
@JsonProperty("path")
|
||||
private String path;
|
||||
@JsonProperty("size")
|
||||
private Long size;
|
||||
@JsonProperty("dateAdded")
|
||||
private String dateAdded;
|
||||
@JsonProperty("indexerFlags")
|
||||
private Integer indexerFlags;
|
||||
@JsonProperty("quality")
|
||||
private Quality quality;
|
||||
@JsonProperty("customFormats")
|
||||
private List<Object> customFormats;
|
||||
@JsonProperty("qualityCutoffNotMet")
|
||||
private Boolean qualityCutoffNotMet;
|
||||
@JsonProperty("languages")
|
||||
private List<Language> languages;
|
||||
@JsonProperty("edition")
|
||||
private String edition;
|
||||
@JsonProperty("id")
|
||||
private Integer id;
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new LinkedHashMap<String, Object>();
|
||||
|
||||
@JsonProperty("movieId")
|
||||
public Integer getMovieId() {
|
||||
return movieId;
|
||||
}
|
||||
|
||||
@JsonProperty("movieId")
|
||||
public void setMovieId(Integer movieId) {
|
||||
this.movieId = movieId;
|
||||
}
|
||||
|
||||
@JsonProperty("relativePath")
|
||||
public String getRelativePath() {
|
||||
return relativePath;
|
||||
}
|
||||
|
||||
@JsonProperty("relativePath")
|
||||
public void setRelativePath(String relativePath) {
|
||||
this.relativePath = relativePath;
|
||||
}
|
||||
|
||||
@JsonProperty("path")
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
@JsonProperty("path")
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@JsonProperty("size")
|
||||
public Long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@JsonProperty("size")
|
||||
public void setSize(Long size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
@JsonProperty("dateAdded")
|
||||
public String getDateAdded() {
|
||||
return dateAdded;
|
||||
}
|
||||
|
||||
@JsonProperty("dateAdded")
|
||||
public void setDateAdded(String dateAdded) {
|
||||
this.dateAdded = dateAdded;
|
||||
}
|
||||
|
||||
@JsonProperty("indexerFlags")
|
||||
public Integer getIndexerFlags() {
|
||||
return indexerFlags;
|
||||
}
|
||||
|
||||
@JsonProperty("indexerFlags")
|
||||
public void setIndexerFlags(Integer indexerFlags) {
|
||||
this.indexerFlags = indexerFlags;
|
||||
}
|
||||
|
||||
@JsonProperty("quality")
|
||||
public Quality getQuality() {
|
||||
return quality;
|
||||
}
|
||||
|
||||
@JsonProperty("quality")
|
||||
public void setQuality(Quality quality) {
|
||||
this.quality = quality;
|
||||
}
|
||||
|
||||
@JsonProperty("customFormats")
|
||||
public List<Object> getCustomFormats() {
|
||||
return customFormats;
|
||||
}
|
||||
|
||||
@JsonProperty("customFormats")
|
||||
public void setCustomFormats(List<Object> customFormats) {
|
||||
this.customFormats = customFormats;
|
||||
}
|
||||
|
||||
@JsonProperty("qualityCutoffNotMet")
|
||||
public Boolean getQualityCutoffNotMet() {
|
||||
return qualityCutoffNotMet;
|
||||
}
|
||||
|
||||
@JsonProperty("qualityCutoffNotMet")
|
||||
public void setQualityCutoffNotMet(Boolean qualityCutoffNotMet) {
|
||||
this.qualityCutoffNotMet = qualityCutoffNotMet;
|
||||
}
|
||||
|
||||
@JsonProperty("languages")
|
||||
public List<Language> getLanguages() {
|
||||
return languages;
|
||||
}
|
||||
|
||||
@JsonProperty("languages")
|
||||
public void setLanguages(List<Language> languages) {
|
||||
this.languages = languages;
|
||||
}
|
||||
|
||||
@JsonProperty("edition")
|
||||
public String getEdition() {
|
||||
return edition;
|
||||
}
|
||||
|
||||
@JsonProperty("edition")
|
||||
public void setEdition(String edition) {
|
||||
this.edition = edition;
|
||||
}
|
||||
|
||||
@JsonProperty("id")
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@JsonProperty("id")
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"quality",
|
||||
"revision"
|
||||
})
|
||||
@Generated("jsonschema2pojo")
|
||||
class Quality {
|
||||
|
||||
@JsonProperty("quality")
|
||||
private Quality__1 quality;
|
||||
@JsonProperty("revision")
|
||||
private Revision revision;
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new LinkedHashMap<String, Object>();
|
||||
|
||||
@JsonProperty("quality")
|
||||
public Quality__1 getQuality() {
|
||||
return quality;
|
||||
}
|
||||
|
||||
@JsonProperty("quality")
|
||||
public void setQuality(Quality__1 quality) {
|
||||
this.quality = quality;
|
||||
}
|
||||
|
||||
@JsonProperty("revision")
|
||||
public Revision getRevision() {
|
||||
return revision;
|
||||
}
|
||||
|
||||
@JsonProperty("revision")
|
||||
public void setRevision(Revision revision) {
|
||||
this.revision = revision;
|
||||
}
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,17 +1,12 @@
|
|||
package tv.mangrana.utils;
|
||||
|
||||
|
||||
|
||||
import tv.mangrana.exception.JobFileNotMovedException;
|
||||
import tv.mangrana.jobs.JobFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileAlreadyExistsException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.attribute.FileTime;
|
||||
import java.util.Optional;
|
||||
|
||||
public class PathUtils {
|
||||
|
||||
|
@ -38,27 +33,6 @@ public class PathUtils {
|
|||
return absolutePath.substring(absolutePath.lastIndexOf(SEPARATOR)+1);
|
||||
}
|
||||
|
||||
public static File shiftFileFolder(File jobFile, JobFile.JobLocation folderOrigin, JobFile.JobLocation folderDestination) throws JobFileNotMovedException {
|
||||
try {
|
||||
Path newPath = Files.move(
|
||||
jobFile.toPath()
|
||||
, Paths.get(jobFile.getAbsolutePath()
|
||||
.replaceFirst(folderOrigin.getFolderName(), folderDestination.getFolderName())));
|
||||
log(Output.msg("moved job file <{2}> from -{0}- to -{1}-", folderOrigin, folderDestination, jobFile.getAbsolutePath()));
|
||||
return newPath.toFile();
|
||||
} catch (FileAlreadyExistsException e) {
|
||||
log("File already exists on destination and will be deleted from source");
|
||||
boolean deleted = jobFile.delete();
|
||||
if (!deleted) throw new JobFileNotMovedException("Could not move the file because exists on destination and either delete it from source");
|
||||
} catch (IOException e) {
|
||||
log(Output.msg("COULD NOT MOVE file {2} from -{0}- to -{1}-", folderOrigin, folderDestination, jobFile.getAbsolutePath()));
|
||||
e.printStackTrace();
|
||||
boolean renamed = jobFile.renameTo(new File(jobFile.getName() + "_handled"));
|
||||
if (!renamed) throw new JobFileNotMovedException("Could not move the file and either rename it");
|
||||
}
|
||||
return jobFile;
|
||||
}
|
||||
|
||||
public static int compareFileCreationDate (File o1, File o2) {
|
||||
final String creationTimeAttr = "creationTime";
|
||||
int res = 0;
|
||||
|
|
Loading…
Reference in New Issue