
com.qiniu.process.filtration.SeniorChecker Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of qsuits Show documentation
Show all versions of qsuits Show documentation
qiniu-suits is a efficient tools for qiniu api implemented by java8.
package com.qiniu.process.filtration;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import com.qiniu.config.JsonFile;
import com.qiniu.util.JsonConvertUtils;
import java.io.IOException;
import java.util.*;
public class SeniorChecker {
final private String checkName;
private Set extMimeList;
private Set extMimeTypeList;
public SeniorChecker(String checkName, String configPath, boolean rewrite) throws IOException {
this.checkName = checkName;
this.extMimeList = new HashSet<>();
this.extMimeTypeList = new HashSet<>();
if (configPath != null && !"".equals(configPath)) {
JsonFile customJson = new JsonFile(configPath);
JsonElement jsonElement = customJson.getElement("ext-mime");
this.extMimeTypeList = new HashSet<>(JsonConvertUtils.fromJsonArray(jsonElement.getAsJsonArray(),
new TypeToken>(){}));
}
if (!rewrite) {
JsonFile jsonFile = new JsonFile("resources" + System.getProperty("file.separator") + "check.json");
JsonObject extMime = jsonFile.getElement("ext-mime").getAsJsonObject();
List defaultList = JsonConvertUtils.fromJsonArray(extMime.get("image").getAsJsonArray(),
new TypeToken>(){});
defaultList.addAll(JsonConvertUtils.fromJsonArray(extMime.get("audio").getAsJsonArray(),
new TypeToken>(){}));
defaultList.addAll(JsonConvertUtils.fromJsonArray(extMime.get("video").getAsJsonArray(),
new TypeToken>(){}));
this.extMimeList.addAll(defaultList);
this.extMimeTypeList.addAll(JsonConvertUtils.fromJsonArray(extMime.get("other").getAsJsonArray(),
new TypeToken>(){}));
}
}
public String getCheckName() {
return checkName;
}
public boolean isValid() {
return checkName != null && !"".equals(checkName);
}
public List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy