130 lines
5.0 KiB
Java
130 lines
5.0 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* com.tridium.file.types.text.BLicenseFile
|
|
* javax.baja.file.BDirectory
|
|
* javax.baja.file.BIFile
|
|
* javax.baja.file.FilePath
|
|
* javax.baja.nre.util.Array
|
|
* javax.baja.nre.util.IFilter
|
|
*/
|
|
package com.tridium.platform.daemon;
|
|
|
|
import com.tridium.file.types.text.BLicenseFile;
|
|
import com.tridium.platform.daemon.BDaemonSession;
|
|
import com.tridium.platform.daemon.DaemonFileUtil;
|
|
import com.tridium.platform.daemon.PlatformOperationListener;
|
|
import com.tridium.platform.daemon.message.FileTransferMessage;
|
|
import com.tridium.platform.license.LicenseInfo;
|
|
import com.tridium.platform.license.PortalLicenseUtil;
|
|
import javax.baja.file.BDirectory;
|
|
import javax.baja.file.BIFile;
|
|
import javax.baja.file.FilePath;
|
|
import javax.baja.nre.util.Array;
|
|
import javax.baja.nre.util.IFilter;
|
|
import javax.baja.platform.IPlatformOperationListener;
|
|
import javax.baja.platform.PlatformLicenseManager;
|
|
|
|
/*
|
|
* Illegal identifiers - consider using --renameillegalidents true
|
|
*/
|
|
public class NiagaraLicenseManager
|
|
implements PlatformLicenseManager {
|
|
private BDaemonSession session;
|
|
static /* synthetic */ Class class$com$tridium$platform$license$LicenseInfo;
|
|
|
|
public static NiagaraLicenseManager make(BDaemonSession bDaemonSession) {
|
|
return new NiagaraLicenseManager(bDaemonSession);
|
|
}
|
|
|
|
public String getHostId() throws Exception {
|
|
return this.session.getHostProperties().getHostId();
|
|
}
|
|
|
|
public BIFile[] getLicenses() throws Exception {
|
|
BDirectory bDirectory = (BDirectory)this.session.getFileSpace().findFile(new FilePath("!licenses"));
|
|
if (bDirectory == null) {
|
|
return new BIFile[0];
|
|
}
|
|
Array array = new Array((Object[])bDirectory.listFiles());
|
|
array = array.filter(new IFilter(){
|
|
|
|
public final boolean accept(Object object) {
|
|
return object instanceof BLicenseFile;
|
|
}
|
|
});
|
|
return (BIFile[])array.trim();
|
|
}
|
|
|
|
public void installLicenses(BIFile[] bIFileArray, IPlatformOperationListener iPlatformOperationListener) throws Exception {
|
|
Object object;
|
|
LicenseInfo[] licenseInfoArray;
|
|
FileTransferMessage fileTransferMessage = new FileTransferMessage(this.session.getFileSpace());
|
|
LicenseInfo[] licenseInfoArray2 = LicenseInfo.make(bIFileArray);
|
|
BDirectory bDirectory = (BDirectory)this.session.getFileSpace().findFile(new FilePath("!licenses"));
|
|
if (bDirectory == null) {
|
|
licenseInfoArray = new LicenseInfo[]{};
|
|
} else {
|
|
object = bDirectory.listFiles();
|
|
Class clazz = class$com$tridium$platform$license$LicenseInfo;
|
|
if (clazz == null) {
|
|
clazz = class$com$tridium$platform$license$LicenseInfo = NiagaraLicenseManager.class("[Lcom.tridium.platform.license.LicenseInfo;", false);
|
|
}
|
|
Array array = new Array(clazz);
|
|
int n = 0;
|
|
while (n < ((BIFile[])object).length) {
|
|
if (object[n] instanceof BLicenseFile) {
|
|
try {
|
|
array.add((Object)new LicenseInfo(object[n]));
|
|
}
|
|
catch (Exception exception) {
|
|
fileTransferMessage.addDelete(object[n].getFilePath());
|
|
}
|
|
}
|
|
++n;
|
|
}
|
|
licenseInfoArray = (LicenseInfo[])array.trim();
|
|
}
|
|
object = PortalLicenseUtil.syncLicenses(this.getHostId(), null, licenseInfoArray, licenseInfoArray2);
|
|
int n = 0;
|
|
while (n < object.toAdd.size()) {
|
|
LicenseInfo licenseInfo = (LicenseInfo)object.toAdd.get(n);
|
|
fileTransferMessage.addFile(licenseInfo.file, licenseInfo.getInstalledFilePath());
|
|
++n;
|
|
}
|
|
n = 0;
|
|
while (n < object.toUpdate.size()) {
|
|
LicenseInfo licenseInfo = (LicenseInfo)object.toUpdate.get(n);
|
|
fileTransferMessage.addFile(licenseInfo.file, licenseInfo.getInstalledFilePath());
|
|
++n;
|
|
}
|
|
n = 0;
|
|
while (n < object.toRemove.size()) {
|
|
LicenseInfo licenseInfo = (LicenseInfo)object.toRemove.get(n);
|
|
fileTransferMessage.addDelete(licenseInfo.file.getFilePath());
|
|
++n;
|
|
}
|
|
PlatformOperationListener platformOperationListener = new PlatformOperationListener(iPlatformOperationListener);
|
|
DaemonFileUtil.transfer(this.session, fileTransferMessage, platformOperationListener, platformOperationListener);
|
|
}
|
|
|
|
static /* synthetic */ Class class(String string, boolean bl) {
|
|
try {
|
|
Class<?> clazz = Class.forName(string);
|
|
if (!bl) {
|
|
clazz = clazz.getComponentType();
|
|
}
|
|
return clazz;
|
|
}
|
|
catch (ClassNotFoundException classNotFoundException) {
|
|
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
|
}
|
|
}
|
|
|
|
private NiagaraLicenseManager(BDaemonSession bDaemonSession) {
|
|
this.session = bDaemonSession;
|
|
}
|
|
}
|
|
|