package divconq.filestore.bucket;
import divconq.hub.DomainInfo;
import divconq.xml.XElement;
public class BucketUtil {
static public Bucket buildBucket(String name, DomainInfo domain) {
XElement settings = domain.getSettings();
if (settings == null)
return null;
for (XElement bucket : settings.selectAll("Buckets/Bucket")) {
if (name.equals(bucket.getAttribute("Name"))) {
// TODO allow for override classes
Bucket b = new Bucket();
b.init(domain, bucket, null);
return b;
}
}
return null;
}
static public boolean isSufficentEvidence(String lookingfor, String got) {
if ("Size".equals(lookingfor))
return ("Size".equals(got) || "MD5".equals(got) || "SHA128".equals(got) || "SHA256".equals(got) || "SHA512".equals(got));
if ("MD5".equals(lookingfor))
return ("MD5".equals(got) || "SHA128".equals(got) || "SHA256".equals(got) || "SHA512".equals(got));
if ("SHA128".equals(lookingfor))
return ("SHA128".equals(got) || "SHA256".equals(got) || "SHA512".equals(got));
if ("SHA256".equals(lookingfor))
return ("SHA256".equals(got) || "SHA512".equals(got));
if ("SHA512".equals(lookingfor))
return ("SHA512".equals(got));
return false;
}
static public String maxEvidence(String lhs, String rhs) {
if ("Size".equals(lhs) && ("MD5".equals(rhs) || "SHA128".equals(rhs) || "SHA256".equals(rhs) || "SHA512".equals(rhs)))
return rhs;
if ("MD5".equals(lhs) && ("SHA128".equals(rhs) || "SHA256".equals(rhs) || "SHA512".equals(rhs)))
return rhs;
if ("SHA128".equals(lhs) && ("SHA256".equals(rhs) || "SHA512".equals(rhs)))
return rhs;
if ("SHA256".equals(lhs) && "SHA512".equals(rhs))
return rhs;
return lhs;
}
}