101 lines
3.2 KiB
Java
101 lines
3.2 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* javax.baja.nre.util.TextUtil
|
|
*/
|
|
package com.tridium.sys.license.dom;
|
|
|
|
import com.tridium.sys.license.dom.HostLicenseSet;
|
|
import com.tridium.sys.license.dom.VendorLicense;
|
|
import java.io.PrintWriter;
|
|
import java.util.ArrayList;
|
|
import java.util.Iterator;
|
|
import javax.baja.file.BDirectory;
|
|
import javax.baja.file.BIFile;
|
|
import javax.baja.nre.util.TextUtil;
|
|
|
|
/*
|
|
* Illegal identifiers - consider using --renameillegalidents true
|
|
*/
|
|
public class LicenseSet {
|
|
private ArrayList list;
|
|
|
|
public Iterator iterator() throws Exception {
|
|
return this.list.iterator();
|
|
}
|
|
|
|
public boolean add(VendorLicense vendorLicense) throws Exception {
|
|
this.list.add(vendorLicense);
|
|
return false;
|
|
}
|
|
|
|
public boolean remove(VendorLicense vendorLicense) throws Exception {
|
|
return this.list.remove(vendorLicense);
|
|
}
|
|
|
|
public void clear() throws Exception {
|
|
this.list.clear();
|
|
}
|
|
|
|
public HostLicenseSet toHostLicenseSet(String string) throws Exception {
|
|
return this.toHostLicenseSet(string, null);
|
|
}
|
|
|
|
public HostLicenseSet toHostLicenseSet(String string, String string2) throws Exception {
|
|
HostLicenseSet hostLicenseSet = null;
|
|
Iterator iterator = this.iterator();
|
|
while (iterator.hasNext()) {
|
|
VendorLicense vendorLicense = (VendorLicense)iterator.next();
|
|
if (!string.equals(vendorLicense.getHostId()) || string2 != null && vendorLicense.getBrandId() != null && !vendorLicense.getBrandId().equals(string2)) continue;
|
|
if (hostLicenseSet == null) {
|
|
hostLicenseSet = new HostLicenseSet();
|
|
}
|
|
if (hostLicenseSet.getVendorLicense(vendorLicense.getVendor()) != null) {
|
|
throw new RuntimeException("Duplicate licenses for same hostId and vendor: " + vendorLicense.getVendor());
|
|
}
|
|
hostLicenseSet.add(vendorLicense);
|
|
}
|
|
return hostLicenseSet;
|
|
}
|
|
|
|
public void load(BDirectory bDirectory) {
|
|
BIFile[] bIFileArray = bDirectory.listFiles();
|
|
int n = 0;
|
|
while (bIFileArray != null && n < bIFileArray.length) {
|
|
BIFile bIFile = bIFileArray[n];
|
|
if (!bIFile.isDirectory() && "license".equals(bIFile.getExtension())) {
|
|
try {
|
|
this.add(VendorLicense.make(bIFile));
|
|
}
|
|
catch (Exception exception) {
|
|
System.out.println("ERROR: Cannot read \"" + bIFile + '\"');
|
|
exception.printStackTrace();
|
|
}
|
|
}
|
|
++n;
|
|
}
|
|
}
|
|
|
|
public void dump() throws Exception {
|
|
this.dump(new PrintWriter(System.out));
|
|
}
|
|
|
|
public void dump(PrintWriter printWriter) throws Exception {
|
|
printWriter.println(TextUtil.getClassName(this.getClass()));
|
|
Iterator iterator = this.iterator();
|
|
while (iterator.hasNext()) {
|
|
((VendorLicense)iterator.next()).dump(printWriter);
|
|
}
|
|
}
|
|
|
|
private final /* synthetic */ void this() {
|
|
this.list = new ArrayList();
|
|
}
|
|
|
|
public LicenseSet() {
|
|
this.this();
|
|
}
|
|
}
|
|
|