link start!

This commit is contained in:
cherubin
2026-03-17 13:31:18 -07:00
commit 08abe87cfb
5910 changed files with 386288 additions and 0 deletions
@@ -0,0 +1,62 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.sys.license.LicenseUtil
* javax.baja.sys.BObject
* javax.baja.sys.Context
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.ui.BTextField
* javax.baja.ui.BWidget
* javax.baja.workbench.fieldeditor.BWbFieldEditor
*/
package com.tridium.platform.ui.license;
import com.tridium.platform.license.BCertificateSummary;
import com.tridium.sys.license.LicenseUtil;
import javax.baja.sys.BObject;
import javax.baja.sys.Context;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.ui.BTextField;
import javax.baja.ui.BWidget;
import javax.baja.workbench.fieldeditor.BWbFieldEditor;
public class BCertificateSummaryFE
extends BWbFieldEditor {
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$platform$ui$license$BCertificateSummaryFE == null ? (class$com$tridium$platform$ui$license$BCertificateSummaryFE = BCertificateSummaryFE.class$("com.tridium.platform.ui.license.BCertificateSummaryFE")) : class$com$tridium$platform$ui$license$BCertificateSummaryFE));
protected BTextField text = new BTextField("", 41, false);
static /* synthetic */ Class class$com$tridium$platform$ui$license$BCertificateSummaryFE;
public Type getType() {
return TYPE;
}
public BCertificateSummaryFE() {
this.setContent((BWidget)this.text);
}
protected void doLoadValue(BObject bObject, Context context) throws Exception {
BCertificateSummary bCertificateSummary = (BCertificateSummary)bObject;
if (bCertificateSummary.getCertificateGenerated() == Long.MIN_VALUE) {
this.text.setText(this.getLexicon().getText("CertificateSummaryFE.text.null"));
} else {
this.text.setText(this.getLexicon().getText("CertificateSummaryFE.text", new Object[]{LicenseUtil.formatDate((long)bCertificateSummary.getCertificateGenerated()), LicenseUtil.formatDate((long)bCertificateSummary.getCertificateExpires())}));
}
}
protected BObject doSaveValue(BObject bObject, Context context) throws Exception {
return bObject;
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
}
@@ -0,0 +1,170 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.file.BIFile
* javax.baja.file.IFileFilter
* javax.baja.log.Log
* javax.baja.space.Mark
* javax.baja.sys.BObject
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.ui.BDialog
* javax.baja.ui.BWidget
* javax.baja.ui.Command
* javax.baja.ui.CommandArtifact
* javax.baja.ui.list.BList
* javax.baja.ui.list.ListModel
* javax.baja.ui.pane.BTextEditorPane
* javax.baja.ui.transfer.TransferContext
* javax.baja.ui.transfer.TransferFormat
*/
package com.tridium.platform.ui.license;
import com.tridium.platform.ui.license.FileInfoListModel;
import javax.baja.file.BIFile;
import javax.baja.file.IFileFilter;
import javax.baja.log.Log;
import javax.baja.space.Mark;
import javax.baja.sys.BObject;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.ui.BDialog;
import javax.baja.ui.BWidget;
import javax.baja.ui.Command;
import javax.baja.ui.CommandArtifact;
import javax.baja.ui.list.BList;
import javax.baja.ui.list.ListModel;
import javax.baja.ui.pane.BTextEditorPane;
import javax.baja.ui.transfer.TransferContext;
import javax.baja.ui.transfer.TransferFormat;
public class BFileInfoList
extends BList {
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$platform$ui$license$BFileInfoList == null ? (class$com$tridium$platform$ui$license$BFileInfoList = BFileInfoList.class$("com.tridium.platform.ui.license.BFileInfoList")) : class$com$tridium$platform$ui$license$BFileInfoList));
private IFileFilter dragOverFilter;
private IFileFilter dropFilter;
private Command deleteCommand;
private Command viewCommand;
private ListTransfer listTransfer;
private static Log log = Log.getLog((String)"platform");
static /* synthetic */ Class class$com$tridium$platform$ui$license$BFileInfoList;
public BFileInfoList() {
throw new UnsupportedOperationException();
}
public BFileInfoList(FileInfoListModel fileInfoListModel, IFileFilter iFileFilter, ListTransfer listTransfer) {
this(fileInfoListModel, iFileFilter, iFileFilter, listTransfer);
}
public BFileInfoList(FileInfoListModel fileInfoListModel, IFileFilter iFileFilter, IFileFilter iFileFilter2, ListTransfer listTransfer) {
super((ListModel)fileInfoListModel);
this.dragOverFilter = iFileFilter;
this.dropFilter = iFileFilter2;
this.listTransfer = listTransfer;
this.setPasteEnabled(true);
this.deleteCommand = new DeleteFileCommand();
this.viewCommand = new ViewFileCommand();
}
public FileInfoListModel getFileInfoListModel() {
return (FileInfoListModel)this.getModel();
}
public CommandArtifact doDelete() throws Exception {
this.deleteCommand.invoke();
return null;
}
public CommandArtifact insertTransferData(TransferContext transferContext) throws Exception {
BObject[] bObjectArray;
Mark mark = Mark.getCurrent();
if (mark != null && (bObjectArray = mark.getValues())[0] instanceof BIFile && this.dragOverFilter.accept((BIFile)bObjectArray[0]) && this.dropFilter.accept((BIFile)bObjectArray[0])) {
this.listTransfer.processFile((BIFile)bObjectArray[0]);
}
return null;
}
public int dragOver(TransferContext transferContext) {
Mark mark;
if (transferContext.getEnvelope().supports(TransferFormat.mark) && (mark = (Mark)transferContext.getEnvelope().getData(TransferFormat.mark)).getValues()[0] instanceof BIFile && this.dragOverFilter.accept((BIFile)mark.getValues()[0])) {
return 16;
}
return 0;
}
public CommandArtifact drop(TransferContext transferContext) throws Exception {
Mark mark = (Mark)transferContext.getEnvelope().getData(TransferFormat.mark);
if (mark.getValues()[0] instanceof BIFile && this.dragOverFilter.accept((BIFile)mark.getValues()[0]) && this.dropFilter.accept((BIFile)mark.getValues()[0])) {
this.listTransfer.processFile((BIFile)mark.getValues()[0]);
}
return null;
}
public Command getDeleteCommand() {
return this.deleteCommand;
}
public Command getViewCommand() {
return this.viewCommand;
}
public Type getType() {
return TYPE;
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
public static interface ListTransfer {
public void processFile(BIFile var1) throws Exception;
}
private class ViewFileCommand
extends Command {
public ViewFileCommand() {
super((BWidget)BFileInfoList.this, TYPE.getModule(), "FileList.view");
this.setEnabled(false);
}
public CommandArtifact doInvoke() {
try {
FileInfoListModel fileInfoListModel = (FileInfoListModel)BFileInfoList.this.getModel();
int n = BFileInfoList.this.getSelectedIndex();
BDialog.message((BWidget)BFileInfoList.this, (String)fileInfoListModel.getFileName(n), (Object)new BTextEditorPane(fileInfoListModel.getFileContents(n), 20, 80, false));
}
catch (Exception exception) {
log.error("error reading contents of file", (Throwable)exception);
}
return null;
}
}
private class DeleteFileCommand
extends Command {
public DeleteFileCommand() {
super((BWidget)BFileInfoList.this, TYPE.getModule(), "FileList.delete");
this.setEnabled(false);
}
public CommandArtifact doInvoke() {
FileInfoListModel fileInfoListModel = (FileInfoListModel)BFileInfoList.this.getModel();
int[] nArray = BFileInfoList.this.getSelectedIndices();
if (4 == BDialog.confirm((BWidget)BFileInfoList.this, (String)BFileInfoList.this.getLexicon().getText("FileList.delete.confirmTitle"), (Object)BFileInfoList.this.getLexicon().getText("FileList.delete.confirmMessage"))) {
for (int i = 0; i < nArray.length; ++i) {
fileInfoListModel.deleteFiles(nArray);
}
}
BFileInfoList.this.getSelection().deselectAll();
return null;
}
}
}
@@ -0,0 +1,40 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.sys.BIcon
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.workbench.tool.BWbNavNodeTool
*/
package com.tridium.platform.ui.license;
import javax.baja.sys.BIcon;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.workbench.tool.BWbNavNodeTool;
public class BLicenseDatabaseTool
extends BWbNavNodeTool {
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$platform$ui$license$BLicenseDatabaseTool == null ? (class$com$tridium$platform$ui$license$BLicenseDatabaseTool = BLicenseDatabaseTool.class$("com.tridium.platform.ui.license.BLicenseDatabaseTool")) : class$com$tridium$platform$ui$license$BLicenseDatabaseTool));
private static final BIcon icon = BIcon.std((String)"doc.png");
static /* synthetic */ Class class$com$tridium$platform$ui$license$BLicenseDatabaseTool;
public Type getType() {
return TYPE;
}
public BIcon getIcon() {
return icon;
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
}
@@ -0,0 +1,676 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.file.types.text.BLicenseFile
* com.tridium.sys.Nre
* com.tridium.sys.license.dom.LicenseDatabase
* com.tridium.sys.license.dom.VendorLicense
* com.tridium.workbench.tools.BRequestLicenseTool
* javax.baja.file.BDirectory
* javax.baja.file.BFileSpace
* javax.baja.file.BFileSystem
* javax.baja.file.BIFile
* javax.baja.file.FilePath
* javax.baja.file.IFileFilter
* javax.baja.gx.BImage
* javax.baja.gx.BInsets
* javax.baja.naming.BOrd
* javax.baja.nre.util.Array
* javax.baja.nre.util.IFilter
* javax.baja.sys.BAbsTime
* javax.baja.sys.BObject
* javax.baja.sys.BValue
* javax.baja.sys.Context
* javax.baja.sys.LocalizableRuntimeException
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.ui.BBorder
* javax.baja.ui.BDialog
* javax.baja.ui.BLabel
* javax.baja.ui.BRadioButton
* javax.baja.ui.BWidget
* javax.baja.ui.ToggleCommandGroup
* javax.baja.ui.enums.BHalign
* javax.baja.ui.enums.BValign
* javax.baja.ui.event.BFocusEvent
* javax.baja.ui.file.ExtFileFilter
* javax.baja.ui.list.BList
* javax.baja.ui.pane.BBorderPane
* javax.baja.ui.pane.BEdgePane
* javax.baja.ui.pane.BGridPane
* javax.baja.ui.transfer.BTransferWidget
* javax.baja.ui.util.UiLexicon
* javax.baja.util.Lexicon
* javax.baja.util.LexiconText
* javax.baja.workbench.view.BWbComponentView
*/
package com.tridium.platform.ui.license;
import com.tridium.file.types.text.BLicenseFile;
import com.tridium.platform.BSystemPlatformService;
import com.tridium.platform.license.BLicenseArchiveFile;
import com.tridium.platform.license.BLicensePlatformService;
import com.tridium.platform.license.BrandProps;
import com.tridium.platform.license.CertificateInfo;
import com.tridium.platform.license.IFileInfo;
import com.tridium.platform.license.LicenseInfo;
import com.tridium.platform.license.LicenseSync;
import com.tridium.platform.license.PortalLicenseUtil;
import com.tridium.platform.ui.license.BFileInfoList;
import com.tridium.platform.ui.license.FileInfoListModel;
import com.tridium.platform.ui.license.UiUtil;
import com.tridium.platform.ui.util.AsyncCommand;
import com.tridium.platform.ui.util.BBox;
import com.tridium.platform.ui.util.BButtonPane;
import com.tridium.platform.ui.util.BCommandEnablePolicy;
import com.tridium.platform.ui.util.BFileChooserDialog;
import com.tridium.platform.ui.util.BFileChooserListView;
import com.tridium.platform.ui.util.BIBeamPane;
import com.tridium.platform.ui.util.CommandBindings;
import com.tridium.platform.ui.util.CommandUtil;
import com.tridium.platform.ui.util.ExtPathFilter;
import com.tridium.platform.ui.util.IFilePathFilter;
import com.tridium.platform.ui.util.LabelUtil;
import com.tridium.sys.Nre;
import com.tridium.sys.license.dom.LicenseDatabase;
import com.tridium.sys.license.dom.VendorLicense;
import com.tridium.workbench.tools.BRequestLicenseTool;
import java.io.OutputStream;
import java.util.HashSet;
import javax.baja.file.BDirectory;
import javax.baja.file.BFileSpace;
import javax.baja.file.BFileSystem;
import javax.baja.file.BIFile;
import javax.baja.file.FilePath;
import javax.baja.file.IFileFilter;
import javax.baja.gx.BImage;
import javax.baja.gx.BInsets;
import javax.baja.naming.BOrd;
import javax.baja.nre.util.Array;
import javax.baja.nre.util.IFilter;
import javax.baja.sys.BAbsTime;
import javax.baja.sys.BObject;
import javax.baja.sys.BValue;
import javax.baja.sys.Context;
import javax.baja.sys.LocalizableRuntimeException;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.ui.BBorder;
import javax.baja.ui.BDialog;
import javax.baja.ui.BLabel;
import javax.baja.ui.BRadioButton;
import javax.baja.ui.BWidget;
import javax.baja.ui.ToggleCommandGroup;
import javax.baja.ui.enums.BHalign;
import javax.baja.ui.enums.BValign;
import javax.baja.ui.event.BFocusEvent;
import javax.baja.ui.file.ExtFileFilter;
import javax.baja.ui.list.BList;
import javax.baja.ui.pane.BBorderPane;
import javax.baja.ui.pane.BEdgePane;
import javax.baja.ui.pane.BGridPane;
import javax.baja.ui.transfer.BTransferWidget;
import javax.baja.ui.util.UiLexicon;
import javax.baja.util.Lexicon;
import javax.baja.util.LexiconText;
import javax.baja.workbench.view.BWbComponentView;
public class BLicensePlatformServicePlugin
extends BWbComponentView {
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$platform$ui$license$BLicensePlatformServicePlugin == null ? (class$com$tridium$platform$ui$license$BLicensePlatformServicePlugin = BLicensePlatformServicePlugin.class$("com.tridium.platform.ui.license.BLicensePlatformServicePlugin")) : class$com$tridium$platform$ui$license$BLicensePlatformServicePlugin));
private static IFileFilter licenseFilter = new ExtFileFilter("TODO", "license,lar");
private static IFileFilter larFilter = new ExtFileFilter("TODO", "lar");
private static IFilePathFilter larPathFilter = new ExtPathFilter("lar");
private static IFileFilter certFilter = new ExtFileFilter("TODO", "certificate");
private BFileInfoList certs;
private FileInfoListModel certModel;
private BFileInfoList licenses;
private FileInfoListModel licenseModel;
private BLabel hostNameLabel;
private BLabel hostIdLabel;
private BLabel brandIdLabel;
private BFileSpace fileSpace;
private String brandId;
private String hostId;
private static final Lexicon lex = Lexicon.make((String)"platform");
static /* synthetic */ Class class$com$tridium$platform$ui$license$BLicensePlatformServicePlugin;
static /* synthetic */ Class class$com$tridium$platform$license$LicenseInfo;
static /* synthetic */ Class class$com$tridium$platform$license$CertificateInfo;
static /* synthetic */ Class class$com$tridium$platform$license$IFileInfo;
public Type getType() {
return TYPE;
}
public BLicensePlatformServicePlugin() {
BIBeamPane bIBeamPane = new BIBeamPane();
BGridPane bGridPane = new BGridPane(2);
bGridPane.setHalign(BHalign.left);
bGridPane.setValign(BValign.top);
bGridPane.setColumnGap(10.0);
bGridPane.setRowGap(6.0);
BLabel bLabel = LabelUtil.makeLabel(LexiconText.make((Type)TYPE, (String)"LicensePlatformServicePlugin.hostNameLabel"), true);
bGridPane.add(null, (BValue)bLabel);
this.hostNameLabel = new BLabel();
bGridPane.add(null, (BValue)this.hostNameLabel);
bLabel = LabelUtil.makeLabel(LexiconText.make((Type)TYPE, (String)"LicensePlatformServicePlugin.hostIdLabel"), true);
bGridPane.add(null, (BValue)bLabel);
this.hostIdLabel = new BLabel();
bGridPane.add(null, (BValue)this.hostIdLabel);
bLabel = LabelUtil.makeLabel(LexiconText.make((Type)TYPE, (String)"LicensePlatformServicePlugin.brandIdLabel"), true);
bGridPane.add(null, (BValue)bLabel);
this.brandIdLabel = new BLabel();
bGridPane.add(null, (BValue)this.brandIdLabel);
bIBeamPane.setTop((BWidget)new BBorderPane((BWidget)bGridPane, 0.0, 0.0, 6.0, 0.0));
this.licenseModel = new FileInfoListModel(LicenseInfo.LICENSES_PATH, "license", class$com$tridium$platform$license$LicenseInfo == null ? (class$com$tridium$platform$license$LicenseInfo = BLicensePlatformServicePlugin.class$("com.tridium.platform.license.LicenseInfo")) : class$com$tridium$platform$license$LicenseInfo);
this.licenses = new BFileInfoList(this.licenseModel, licenseFilter, new LicenseValidator(), new LicenseTransfer());
CommandBindings commandBindings = new CommandBindings();
ImportCommand importCommand = new ImportCommand(this.licenses);
ExportCommand exportCommand = new ExportCommand(this.licenses);
commandBindings.addCommand(importCommand, BCommandEnablePolicy.always);
commandBindings.addCommand(exportCommand, BCommandEnablePolicy.anySelection);
commandBindings.addCommand(this.licenses.getViewCommand(), BCommandEnablePolicy.singleSelection);
commandBindings.addCommand(this.licenses.getDeleteCommand(), BCommandEnablePolicy.anySelection);
commandBindings.setDoubleClickCommand(this.licenses.getViewCommand());
this.licenses.setController(new FileListController(commandBindings));
this.licenses.setSelection(new CommandBindings.ListSelection(commandBindings));
this.licenses.setMultipleSelection(true);
BButtonPane bButtonPane = new BButtonPane();
bButtonPane.setUniformColumnWidth(false);
bButtonPane.add(importCommand);
bButtonPane.add(exportCommand);
bButtonPane.add(this.licenses.getViewCommand());
bButtonPane.add(this.licenses.getDeleteCommand());
bLabel = new BLabel(lex.getText("LicensePlatformServicePlugin.licenseList.header"));
bIBeamPane.setLeft((BWidget)new BEdgePane((BWidget)bLabel, (BWidget)bButtonPane, null, null, (BWidget)new BBorderPane((BWidget)new BBorderPane((BWidget)this.licenses, BBorder.inset, BInsets.DEFAULT), 5.0, 0.0, 5.0, 0.0)));
bLabel.setHalign(BHalign.left);
this.certModel = new FileInfoListModel(CertificateInfo.CERTS_PATH, "certificate", class$com$tridium$platform$license$CertificateInfo == null ? (class$com$tridium$platform$license$CertificateInfo = BLicensePlatformServicePlugin.class$("com.tridium.platform.license.CertificateInfo")) : class$com$tridium$platform$license$CertificateInfo);
this.certs = new BFileInfoList(this.certModel, certFilter, new CertificateTransfer());
AddCertCommand addCertCommand = new AddCertCommand(this.certs);
commandBindings = new CommandBindings();
commandBindings.addCommand(addCertCommand, BCommandEnablePolicy.always);
commandBindings.addCommand(this.certs.getViewCommand(), BCommandEnablePolicy.singleSelection);
commandBindings.addCommand(this.certs.getDeleteCommand(), BCommandEnablePolicy.anySelection);
commandBindings.setDoubleClickCommand(this.certs.getViewCommand());
this.certs.setController(new FileListController(commandBindings));
this.certs.setSelection(new CommandBindings.ListSelection(commandBindings));
this.certs.setMultipleSelection(true);
bButtonPane = new BButtonPane();
bButtonPane.setUniformColumnWidth(false);
bButtonPane.add(addCertCommand);
bButtonPane.add(this.certs.getViewCommand());
bButtonPane.add(this.certs.getDeleteCommand());
bLabel = new BLabel(lex.getText("LicensePlatformServicePlugin.certList.header"));
bIBeamPane.setRight((BWidget)new BEdgePane((BWidget)bLabel, (BWidget)bButtonPane, null, null, (BWidget)new BBorderPane((BWidget)new BBorderPane((BWidget)this.certs, BBorder.inset, BInsets.DEFAULT), 5.0, 0.0, 5.0, 0.0)));
bLabel.setHalign(BHalign.left);
bIBeamPane.setCenter(new BBox(20.0, 0.0));
this.setContent((BWidget)bIBeamPane);
this.autoRegisterForComponentEvents = false;
}
protected void doLoadValue(BObject bObject, Context context) throws Exception {
BLicensePlatformService bLicensePlatformService = (BLicensePlatformService)bObject;
this.registerForComponentEvents(bLicensePlatformService, 4);
bLicensePlatformService.poll();
this.hostNameLabel.setText(bLicensePlatformService.getHost().getNavDisplayName(null));
BSystemPlatformService bSystemPlatformService = (BSystemPlatformService)BOrd.make((String)"service:platform:SystemPlatformService").get((BObject)bLicensePlatformService);
bSystemPlatformService.lease(2);
this.hostId = bSystemPlatformService.getHostId();
this.hostIdLabel.setText(this.hostId);
this.fileSpace = (BFileSpace)BOrd.make((String)"file:").get((BObject)bLicensePlatformService);
this.certModel.loadValue(this.fileSpace);
this.licenseModel.loadValue(this.fileSpace);
this.findBrandId();
}
protected void findBrandId() throws Exception {
this.brandId = null;
for (int i = 0; this.brandId == null && i < this.licenseModel.getItemCount(); ++i) {
VendorLicense vendorLicense = ((LicenseInfo)this.licenseModel.getInfo((int)i)).vendorLicense;
this.brandId = vendorLicense.getBrandId();
}
if (this.brandId == null) {
this.brandId = new BrandProps(this.fileSpace).get("brand.id", null);
}
this.brandIdLabel.setText(this.brandId == null ? "" : this.brandId);
}
protected LicenseInfo[] getDatabaseLicenses() throws Exception {
Array array = new Array(class$com$tridium$platform$license$LicenseInfo == null ? (class$com$tridium$platform$license$LicenseInfo = BLicensePlatformServicePlugin.class$("com.tridium.platform.license.LicenseInfo")) : class$com$tridium$platform$license$LicenseInfo);
VendorLicense[] vendorLicenseArray = LicenseDatabase.LOCAL_INSTANCE.getLicenses(this.hostId);
String string = this.brandId;
for (int i = 0; i < vendorLicenseArray.length; ++i) {
if (vendorLicenseArray[i].getBrandId() != null && string != null && !string.equals(vendorLicenseArray[i].getBrandId())) continue;
array.add((Object)new LicenseInfo(vendorLicenseArray[i], null));
string = vendorLicenseArray[i].getBrandId();
}
return (LicenseInfo[])array.trim();
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
protected void saveToStation(IFileInfo iFileInfo) throws Exception {
BIFile bIFile = this.fileSpace.makeFile(iFileInfo.getInstalledFilePath());
OutputStream outputStream = bIFile.getOutputStream();
try {
iFileInfo.write(outputStream);
}
finally {
try {
outputStream.close();
}
catch (Exception exception) {}
}
}
protected void sync(LicenseSync licenseSync, LicenseSync licenseSync2) throws Exception {
IFileInfo iFileInfo;
int n;
int n2;
Array array = new Array(class$com$tridium$platform$license$IFileInfo == null ? (class$com$tridium$platform$license$IFileInfo = BLicensePlatformServicePlugin.class$("com.tridium.platform.license.IFileInfo")) : class$com$tridium$platform$license$IFileInfo);
Array array2 = new Array(class$com$tridium$platform$license$IFileInfo == null ? (class$com$tridium$platform$license$IFileInfo = BLicensePlatformServicePlugin.class$("com.tridium.platform.license.IFileInfo")) : class$com$tridium$platform$license$IFileInfo);
Array array3 = new Array(class$com$tridium$platform$license$IFileInfo == null ? (class$com$tridium$platform$license$IFileInfo = BLicensePlatformServicePlugin.class$("com.tridium.platform.license.IFileInfo")) : class$com$tridium$platform$license$IFileInfo);
boolean bl = false;
boolean bl2 = false;
if (licenseSync != null) {
n2 = licenseSync.toRemove.size();
array3.addAll(licenseSync.toRemove);
for (n = 0; n < n2; ++n) {
iFileInfo = (LicenseInfo)licenseSync.toRemove.get(n);
iFileInfo.file.delete();
bl = true;
}
n2 = licenseSync.toAdd.size();
array.addAll(licenseSync.toAdd);
for (n = 0; n < n2; ++n) {
iFileInfo = (LicenseInfo)licenseSync.toAdd.get(n);
this.saveToStation(iFileInfo);
bl2 = true;
bl = true;
}
n2 = licenseSync.toUpdate.size();
array2.addAll(licenseSync.toUpdate);
for (n = 0; n < n2; ++n) {
iFileInfo = (LicenseInfo)licenseSync.toUpdate.get(n);
this.saveToStation(iFileInfo);
bl2 = true;
bl = true;
}
}
if (licenseSync2 != null) {
n2 = licenseSync2.toAdd.size();
array.addAll(licenseSync2.toAdd);
for (n = 0; n < n2; ++n) {
iFileInfo = (CertificateInfo)licenseSync2.toAdd.get(n);
this.saveToStation(iFileInfo);
bl = true;
}
n2 = licenseSync2.toUpdate.size();
array2.addAll(licenseSync2.toUpdate);
for (n = 0; n < n2; ++n) {
iFileInfo = (CertificateInfo)licenseSync2.toUpdate.get(n);
this.saveToStation(iFileInfo);
bl = true;
}
}
if (bl) {
if (bl2) {
BWidget bWidget = UiUtil.buildUpdateDescription(lex.getText("LicensePlatformServicePlugin.sync.successMessage"), lex.getText("LicensePlatformServicePlugin.sync.restartMessage"), (IFileInfo[])array.trim(), (IFileInfo[])array2.trim(), (IFileInfo[])array3.trim());
if (4 == BDialog.confirm((BWidget)this, (String)lex.getText("LicensePlatformServicePlugin.sync.successTitle"), (Object)bWidget, (int)12)) {
BSystemPlatformService bSystemPlatformService = (BSystemPlatformService)BOrd.make((String)"service:platform:SystemPlatformService").get(this.getCurrentValue());
bSystemPlatformService.lease(Integer.MAX_VALUE);
bSystemPlatformService.restartStation();
return;
}
} else {
BWidget bWidget = UiUtil.buildUpdateDescription(lex.getText("LicensePlatformServicePlugin.sync.successMessage"), null, (IFileInfo[])array.trim(), (IFileInfo[])array2.trim(), (IFileInfo[])array3.trim());
BDialog.message((BWidget)this, (String)lex.getText("LicensePlatformServicePlugin.sync.successTitle"), (Object)bWidget);
}
this.loadValue(this.getCurrentValue());
} else {
BDialog.message((BWidget)this, (String)lex.getText("LicensePlatformServicePlugin.sync.currentTitle"), (Object)lex.getText("LicensePlatformServicePlugin.sync.currentMessage"));
}
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
private class CertificateTransfer
implements BFileInfoList.ListTransfer {
private CertificateTransfer() {
}
public void processFile(BIFile bIFile) throws Exception {
CertificateInfo[] certificateInfoArray = new CertificateInfo[]{new CertificateInfo(bIFile)};
CertificateInfo[] certificateInfoArray2 = (CertificateInfo[])BLicensePlatformServicePlugin.this.certModel.getInfo();
LicenseSync licenseSync = PortalLicenseUtil.syncCertificates(certificateInfoArray2, certificateInfoArray);
BLicensePlatformServicePlugin.this.sync(null, licenseSync);
}
}
private class LicenseTransfer
implements BFileInfoList.ListTransfer {
private LicenseTransfer() {
}
public void processFile(BIFile bIFile) throws Exception {
LicenseInfo[] licenseInfoArray = PortalLicenseUtil.getLicenseInfo(bIFile, BLicensePlatformServicePlugin.this.hostId, BLicensePlatformServicePlugin.this.brandId);
LicenseInfo[] licenseInfoArray2 = (LicenseInfo[])BLicensePlatformServicePlugin.this.licenseModel.getInfo();
LicenseSync licenseSync = PortalLicenseUtil.syncLicenses(BLicensePlatformServicePlugin.this.hostId, licenseInfoArray2, licenseInfoArray);
BLicensePlatformServicePlugin.this.sync(licenseSync, null);
}
}
private class AddCertCommand
extends AsyncCommand {
public AddCertCommand(BList bList) {
super((BWidget)bList, TYPE.getModule(), "LicensePlatformServicePlugin.addCert");
}
public void doInvokeAsync() {
block5: {
try {
BIFile[] bIFileArray;
BIFile bIFile = BFileSystem.INSTANCE.findFile(CertificateInfo.CERTS_PATH);
if (bIFile == null) {
bIFile = BFileSystem.INSTANCE.getSysHome();
}
if ((bIFileArray = BFileChooserDialog.chooseFiles(this.getOwner(), BImage.make((String)lex.getText("LicensePlatformServicePlugin.addCertDialog.icon")), lex.getText("LicensePlatformServicePlugin.addCertDialog.title"), lex.getText("LicensePlatformServicePlugin.addCertDialog.message", new Object[]{BLicensePlatformServicePlugin.this.hostNameLabel.getText()}), bIFile, certFilter, certFilter)).length <= 0) break block5;
try {
CertificateInfo[] certificateInfoArray = CertificateInfo.make(bIFileArray);
CertificateInfo[] certificateInfoArray2 = (CertificateInfo[])BLicensePlatformServicePlugin.this.certModel.getInfo();
LicenseSync licenseSync = PortalLicenseUtil.syncCertificates(certificateInfoArray2, certificateInfoArray);
BLicensePlatformServicePlugin.this.sync(null, licenseSync);
}
catch (Exception exception) {
throw new LocalizableRuntimeException("platform", "LicensePlatformServicePlugin.addCertException", (Throwable)exception);
}
BLicensePlatformServicePlugin.this.loadValue(BLicensePlatformServicePlugin.this.getCurrentValue());
}
catch (Throwable throwable) {
CommandUtil.error(this, throwable);
}
}
}
}
private class ImportCommand
extends AsyncCommand {
public ImportCommand(BList bList) {
super((BWidget)bList, TYPE.getModule(), "LicensePlatformServicePlugin.importLicense");
}
private void importFile() throws Exception {
BIFile bIFile = BFileSystem.INSTANCE.findFile(LicenseInfo.LICENSES_PATH);
if (bIFile == null) {
bIFile = BFileSystem.INSTANCE.getSysHome();
}
Object[] objectArray = BFileChooserDialog.chooseFiles(this.getOwner(), BImage.make((String)lex.getText("LicensePlatformServicePlugin.importFileDialog.icon")), lex.getText("LicensePlatformServicePlugin.importFileDialog.title"), lex.getText("LicensePlatformServicePlugin.importFileDialog.message", new Object[]{BLicensePlatformServicePlugin.this.hostNameLabel.getText()}), bIFile, licenseFilter, licenseFilter, new LicenseListModel());
Array array = new Array(objectArray);
if ((array = array.filter((IFilter)new LicenseValidator())).size() == 0) {
return;
}
LicenseInfo[] licenseInfoArray = PortalLicenseUtil.getLicenseInfo((BIFile[])array.trim(), BLicensePlatformServicePlugin.this.hostId, BLicensePlatformServicePlugin.this.brandId);
LicenseInfo[] licenseInfoArray2 = (LicenseInfo[])BLicensePlatformServicePlugin.this.licenseModel.getInfo();
LicenseSync licenseSync = PortalLicenseUtil.syncLicenses(BLicensePlatformServicePlugin.this.hostId, licenseInfoArray2, licenseInfoArray);
BLicensePlatformServicePlugin.this.sync(licenseSync, null);
}
public void requestLicense() {
UiUtil.requestLicense(this.getOwner().getShell(), BLicensePlatformServicePlugin.this.hostId);
}
public void getOnline() throws Exception {
int n;
LicenseInfo[] licenseInfoArray = (LicenseInfo[])BLicensePlatformServicePlugin.this.licenseModel.getInfo();
CertificateInfo[] certificateInfoArray = (CertificateInfo[])BLicensePlatformServicePlugin.this.certModel.getInfo();
LicenseInfo[] licenseInfoArray2 = null;
CertificateInfo[] certificateInfoArray2 = null;
HashSet<String> hashSet = new HashSet<String>();
for (n = 0; n < licenseInfoArray.length; ++n) {
hashSet.add(licenseInfoArray[n].vendorLicense.getVendor());
}
for (n = 0; n < certificateInfoArray.length; ++n) {
hashSet.add(certificateInfoArray[n].vendorCertificate.getVendor());
}
n = 1;
LicenseSync licenseSync = null;
LicenseSync licenseSync2 = null;
try {
licenseInfoArray2 = LicenseInfo.make(PortalLicenseUtil.getExistingLicenses(BLicensePlatformServicePlugin.this.hostId, BLicensePlatformServicePlugin.this.brandId));
licenseSync = PortalLicenseUtil.syncLicenses(BLicensePlatformServicePlugin.this.hostId, licenseInfoArray, licenseInfoArray2);
for (int i = 0; i < licenseInfoArray2.length; ++i) {
hashSet.add(licenseInfoArray2[i].vendorLicense.getVendor());
}
n = licenseSync.unchanged() && LicenseInfo.countActiveLicenses(licenseInfoArray, BAbsTime.now()) == 0 ? 1 : 0;
}
catch (Exception exception) {
// empty catch block
}
try {
String[] stringArray = new String[hashSet.size()];
hashSet.toArray(stringArray);
certificateInfoArray2 = CertificateInfo.make(PortalLicenseUtil.getCertificates(stringArray));
licenseSync2 = PortalLicenseUtil.syncCertificates(certificateInfoArray, certificateInfoArray2);
}
catch (Exception exception) {
// empty catch block
}
try {
BLicensePlatformServicePlugin.this.sync(licenseSync, licenseSync2);
}
catch (Exception exception) {
// empty catch block
}
if (n != 0) {
BRequestLicenseTool.requestLicense((BWidget)BLicensePlatformServicePlugin.this.getWbShell(), (String)BLicensePlatformServicePlugin.this.hostId);
}
}
public void doInvokeAsync() {
try {
if (Nre.bootEnv.isRemote()) {
this.importFile();
return;
}
BGridPane bGridPane = new BGridPane(1);
ToggleCommandGroup toggleCommandGroup = new ToggleCommandGroup();
BRadioButton bRadioButton = new BRadioButton(toggleCommandGroup, lex.getText("LicensePlatformServicePlugin.importType.file"), true);
bGridPane.add(null, (BValue)bRadioButton);
BRadioButton bRadioButton2 = new BRadioButton(toggleCommandGroup, lex.getText("LicensePlatformServicePlugin.importType.localDb"), false);
bGridPane.add(null, (BValue)bRadioButton2);
LicenseInfo[] licenseInfoArray = (LicenseInfo[])BLicensePlatformServicePlugin.this.licenseModel.getInfo();
LicenseInfo[] licenseInfoArray2 = BLicensePlatformServicePlugin.this.getDatabaseLicenses();
LicenseSync licenseSync = PortalLicenseUtil.syncLicenses(BLicensePlatformServicePlugin.this.hostId, licenseInfoArray, licenseInfoArray2);
if (licenseSync.unchanged()) {
bRadioButton2.setEnabled(false);
}
BRadioButton bRadioButton3 = new BRadioButton(toggleCommandGroup, lex.getText("LicensePlatformServicePlugin.importType.getOnline"), false);
BRadioButton bRadioButton4 = new BRadioButton(toggleCommandGroup, lex.getText("LicensePlatformServicePlugin.importType.requestLicense"), false);
if (PortalLicenseUtil.isApiAvailable()) {
if (PortalLicenseUtil.requestLicensesOnline()) {
bGridPane.add(null, (BValue)bRadioButton3);
} else {
bGridPane.add(null, (BValue)bRadioButton4);
}
}
if (1 == BDialog.open((BWidget)this.getOwner(), (String)lex.getText("LicensePlatformServicePlugin.importType.dlgTitle"), (Object)new BBorderPane((BWidget)bGridPane, 10.0, 10.0, 10.0, 10.0), (int)3)) {
if (bRadioButton.isSelected()) {
this.importFile();
} else if (bRadioButton2.isSelected()) {
BLicensePlatformServicePlugin.this.sync(licenseSync, null);
} else if (bRadioButton3.isSelected()) {
this.getOnline();
} else if (bRadioButton4.isSelected()) {
this.requestLicense();
}
}
}
catch (Throwable throwable) {
CommandUtil.error(this, throwable);
}
}
}
private class ExportCommand
extends AsyncCommand {
public ExportCommand(BList bList) {
super((BWidget)bList, TYPE.getModule(), "LicensePlatformServicePlugin.exportLicense");
}
public void doInvokeAsync() {
try {
BDirectory bDirectory = BFileSystem.INSTANCE.getSysHome();
FilePath filePath = BFileChooserDialog.chooseFilePath(this.getOwner(), BImage.make((String)lex.getText("LicensePlatformServicePlugin.exportDialog.icon")), lex.getText("LicensePlatformServicePlugin.exportDialog.title"), lex.getText("LicensePlatformServicePlugin.exportDialog.message"), (BIFile)bDirectory, larFilter, larPathFilter, new LicenseListModel(), "licenses.lar");
if (filePath != null) {
BLicenseArchiveFile bLicenseArchiveFile = (BLicenseArchiveFile)BFileSystem.INSTANCE.findFile(filePath);
if (bLicenseArchiveFile == null) {
bLicenseArchiveFile = (BLicenseArchiveFile)BFileSystem.INSTANCE.makeFile(filePath);
} else if (8 == BDialog.confirm((BWidget)this.getOwner(), (String)lex.getText("LicensePlatformServicePlugin.replaceFileDialog.title"), (Object)lex.getText("LicensePlatformServicePlugin.replaceFileDialog.message", new Object[]{filePath.getName()}))) {
return;
}
if (filePath.getParent().getBody().equals(LicenseInfo.LICENSES_PATH.getBody())) {
BLicensePlatformServicePlugin.this.licenseModel.reload();
}
int[] nArray = BLicensePlatformServicePlugin.this.licenseModel.getSelection().getItems();
VendorLicense[] vendorLicenseArray = new VendorLicense[nArray.length];
for (int i = 0; i < nArray.length; ++i) {
vendorLicenseArray[i] = ((LicenseInfo)((BLicensePlatformServicePlugin)BLicensePlatformServicePlugin.this).licenseModel.getInfo((int)nArray[i])).vendorLicense;
}
bLicenseArchiveFile.writeLicenses(vendorLicenseArray);
BDialog.message((BWidget)this.getOwner(), (String)lex.getText("LicensePlatformServicePlugin.fileWrittenDialog.title"), (Object)lex.getText("LicensePlatformServicePlugin.fileWrittenDialog.message", new Object[]{filePath.getName()}));
}
}
catch (Throwable throwable) {
CommandUtil.error(this, throwable);
}
}
}
public static class LicenseListModel
extends BFileChooserListView.ListModel {
public int getColumnCount() {
return 2;
}
public String getColumnName(int n) {
switch (n) {
case 0: {
return UiLexicon.bajaui.getText("fileChooser.name");
}
case 1: {
return lex.getText("LicensePlatformServicePlugin.hostIdLabel");
}
}
return "";
}
public Object getValueAt(int n, int n2) {
BIFile bIFile = (BIFile)this.kids[n];
switch (n2) {
case 0: {
return super.getValueAt(n, n2);
}
case 1: {
try {
if (bIFile.getExtension() == null || !(bIFile instanceof BLicenseFile)) {
return "";
}
LicenseInfo licenseInfo = new LicenseInfo(bIFile);
return licenseInfo.vendorLicense.getHostId();
}
catch (Exception exception) {
return "";
}
}
}
return null;
}
}
private class LicenseValidator
implements IFileFilter,
IFilter {
private LicenseValidator() {
}
public boolean accept(Object object) {
if (object instanceof BIFile) {
return this.accept((BIFile)object);
}
return false;
}
public boolean accept(BIFile bIFile) {
try {
if (bIFile instanceof BLicenseFile) {
LicenseInfo licenseInfo = new LicenseInfo(bIFile);
if (BLicensePlatformServicePlugin.this.hostId.equals(licenseInfo.vendorLicense.getHostId())) {
if (BLicensePlatformServicePlugin.this.brandId != null && licenseInfo.vendorLicense.getBrandId() != null && !BLicensePlatformServicePlugin.this.brandId.equals(licenseInfo.vendorLicense.getBrandId())) {
BDialog.error((BWidget)BLicensePlatformServicePlugin.this, (String)lex.getText("LicensePlatformServicePlugin.cantChangeBrand.title"), (Object)lex.getText("LicensePlatformServicePlugin.cantChangeBrand.message", new Object[]{licenseInfo}));
return false;
}
if (licenseInfo.allowsLocalWbAccess()) {
return true;
}
BDialog.error((BWidget)BLicensePlatformServicePlugin.this, (String)lex.getText("LicensePlatformServicePlugin.noAccess.title"), (Object)lex.getText("LicensePlatformServicePlugin.noAccess.message", new Object[]{licenseInfo}));
return false;
}
BDialog.error((BWidget)BLicensePlatformServicePlugin.this, (String)lex.getText("LicensePlatformServicePlugin.badHostId.title"), (Object)lex.getText("LicensePlatformServicePlugin.badHostId.message", new Object[]{licenseInfo}));
return false;
}
if (bIFile instanceof BLicenseArchiveFile) {
VendorLicense[] vendorLicenseArray = ((BLicenseArchiveFile)bIFile).getLicenses(BLicensePlatformServicePlugin.this.hostId);
int n = 0;
for (int i = 0; i < vendorLicenseArray.length; ++i) {
if (BLicensePlatformServicePlugin.this.brandId != null && vendorLicenseArray[i].getBrandId() != null && !BLicensePlatformServicePlugin.this.brandId.equals(vendorLicenseArray[i].getBrandId())) continue;
LicenseInfo licenseInfo = new LicenseInfo(vendorLicenseArray[i], bIFile);
if (!licenseInfo.allowsLocalWbAccess()) {
BDialog.error((BWidget)BLicensePlatformServicePlugin.this, (String)lex.getText("LicensePlatformServicePlugin.noAccess.title"), (Object)lex.getText("LicensePlatformServicePlugin.noAccess.message", new Object[]{licenseInfo}));
return false;
}
++n;
}
if (n == 0) {
BDialog.error((BWidget)BLicensePlatformServicePlugin.this, (String)lex.getText("LicensePlatformServicePlugin.noHostLicenses.title"), (Object)lex.getText("LicensePlatformServicePlugin.noHostLicenses.message"));
return false;
}
return true;
}
return false;
}
catch (Exception exception) {
throw new LocalizableRuntimeException("platform", "LicensePlatformServicePlugin.addLicenseException", (Throwable)exception);
}
}
public String getDescription(Context context) {
return "TODO";
}
}
private class FileListController
extends CommandBindings.ListController {
public FileListController(CommandBindings commandBindings) {
super(commandBindings);
}
public void focusGained(BFocusEvent bFocusEvent) {
BLicensePlatformServicePlugin.this.setTransferWidget((BTransferWidget)this.getList());
if (this.getList() == BLicensePlatformServicePlugin.this.certs) {
BLicensePlatformServicePlugin.this.licenses.getSelection().deselectAll();
} else {
BLicensePlatformServicePlugin.this.certs.getSelection().deselectAll();
}
}
}
}
@@ -0,0 +1,58 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.sys.license.LicenseUtil
* javax.baja.sys.BObject
* javax.baja.sys.Context
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.ui.BTextField
* javax.baja.ui.BWidget
* javax.baja.workbench.fieldeditor.BWbFieldEditor
*/
package com.tridium.platform.ui.license;
import com.tridium.platform.license.BVendorLicenseSummary;
import com.tridium.sys.license.LicenseUtil;
import javax.baja.sys.BObject;
import javax.baja.sys.Context;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.ui.BTextField;
import javax.baja.ui.BWidget;
import javax.baja.workbench.fieldeditor.BWbFieldEditor;
public class BVendorLicenseSummaryFE
extends BWbFieldEditor {
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$platform$ui$license$BVendorLicenseSummaryFE == null ? (class$com$tridium$platform$ui$license$BVendorLicenseSummaryFE = BVendorLicenseSummaryFE.class$("com.tridium.platform.ui.license.BVendorLicenseSummaryFE")) : class$com$tridium$platform$ui$license$BVendorLicenseSummaryFE));
protected BTextField text = new BTextField("", 41, false);
static /* synthetic */ Class class$com$tridium$platform$ui$license$BVendorLicenseSummaryFE;
public Type getType() {
return TYPE;
}
public BVendorLicenseSummaryFE() {
this.setContent((BWidget)this.text);
}
protected void doLoadValue(BObject bObject, Context context) throws Exception {
BVendorLicenseSummary bVendorLicenseSummary = (BVendorLicenseSummary)bObject;
this.text.setText(this.getLexicon().getText("VendorLicenseSummaryFE.text", new Object[]{LicenseUtil.formatDate((long)bVendorLicenseSummary.getLicenseGenerated()), LicenseUtil.formatDate((long)bVendorLicenseSummary.getLicenseExpires())}));
}
protected BObject doSaveValue(BObject bObject, Context context) throws Exception {
return bObject;
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
}
@@ -0,0 +1,93 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.gx.BInsets
* javax.baja.sys.Action
* javax.baja.sys.BComponent
* javax.baja.sys.BObject
* javax.baja.sys.Context
* javax.baja.sys.Slot
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.ui.BBorder
* javax.baja.ui.BWidget
* javax.baja.ui.pane.BBorderPane
* javax.baja.ui.pane.BEdgePane
* javax.baja.ui.pane.BScrollPane
* javax.baja.ui.pane.BSplitPane
* javax.baja.ui.text.BTextEditor
* javax.baja.ui.transfer.BTransferWidget
* javax.baja.workbench.view.BWbView
*/
package com.tridium.platform.ui.license;
import com.tridium.platform.license.BLicenseArchiveFile;
import com.tridium.platform.ui.license.BWorkbenchLicenseTree;
import com.tridium.platform.ui.util.BButtonPane;
import javax.baja.gx.BInsets;
import javax.baja.sys.Action;
import javax.baja.sys.BComponent;
import javax.baja.sys.BObject;
import javax.baja.sys.Context;
import javax.baja.sys.Slot;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.ui.BBorder;
import javax.baja.ui.BWidget;
import javax.baja.ui.pane.BBorderPane;
import javax.baja.ui.pane.BEdgePane;
import javax.baja.ui.pane.BScrollPane;
import javax.baja.ui.pane.BSplitPane;
import javax.baja.ui.text.BTextEditor;
import javax.baja.ui.transfer.BTransferWidget;
import javax.baja.workbench.view.BWbView;
public class BWorkbenchLicenseManager
extends BWbView {
public static final Action handleTreeValueUpdated = BWorkbenchLicenseManager.newAction((int)0, null);
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$platform$ui$license$BWorkbenchLicenseManager == null ? (class$com$tridium$platform$ui$license$BWorkbenchLicenseManager = BWorkbenchLicenseManager.class$("com.tridium.platform.ui.license.BWorkbenchLicenseManager")) : class$com$tridium$platform$ui$license$BWorkbenchLicenseManager));
private BTextEditor details;
private BWorkbenchLicenseTree tree = new BWorkbenchLicenseTree();
static /* synthetic */ Class class$com$tridium$platform$ui$license$BWorkbenchLicenseManager;
public void handleTreeValueUpdated() {
this.invoke(handleTreeValueUpdated, null, null);
}
public Type getType() {
return TYPE;
}
public BWorkbenchLicenseManager() {
this.linkTo(null, (BComponent)this.tree, (Slot)BWorkbenchLicenseTree.valueUpdated, (Slot)handleTreeValueUpdated);
this.details = new BTextEditor("", false);
BScrollPane bScrollPane = new BScrollPane((BWidget)this.details);
BSplitPane bSplitPane = new BSplitPane((BWidget)new BBorderPane((BWidget)new BScrollPane((BWidget)this.tree), BBorder.inset, BInsets.DEFAULT), (BWidget)new BBorderPane((BWidget)bScrollPane, BBorder.inset, BInsets.DEFAULT));
bSplitPane.setDividerPosition(33.0);
this.setContent((BWidget)new BEdgePane(null, (BWidget)new BButtonPane(this.tree.getCommands(), true, false), null, null, (BWidget)new BBorderPane((BWidget)new BBorderPane((BWidget)bSplitPane, 10.0, 0.0, 4.0, 0.0), 4.0, 10.0, 4.0, 10.0)));
this.setTransferWidget((BTransferWidget)this.tree);
}
protected void doLoadValue(BObject bObject, Context context) throws Exception {
if (bObject instanceof BLicenseArchiveFile) {
this.tree.importLicenseArchive((BLicenseArchiveFile)bObject, context);
} else {
this.tree.load(context);
}
}
public void doHandleTreeValueUpdated(Context context) throws Exception {
this.details.setText(this.tree.getDetailsText());
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
}
@@ -0,0 +1,639 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.file.types.text.BLicenseFile
* com.tridium.sys.license.dom.CertificateDatabase
* com.tridium.sys.license.dom.LicenseDatabase
* com.tridium.sys.license.dom.VendorCertificate
* com.tridium.sys.license.dom.VendorLicense
* javax.baja.file.BDirectory
* javax.baja.file.BFileSystem
* javax.baja.file.BIFile
* javax.baja.file.FilePath
* javax.baja.file.IFileFilter
* javax.baja.gx.BImage
* javax.baja.nre.util.Array
* javax.baja.space.Mark
* javax.baja.sys.Action
* javax.baja.sys.BComponent
* javax.baja.sys.BIcon
* javax.baja.sys.BObject
* javax.baja.sys.BValue
* javax.baja.sys.BajaRuntimeException
* javax.baja.sys.Context
* javax.baja.sys.Slot
* javax.baja.sys.Sys
* javax.baja.sys.Topic
* javax.baja.sys.Type
* javax.baja.ui.BDialog
* javax.baja.ui.BLabel
* javax.baja.ui.BWidget
* javax.baja.ui.Command
* javax.baja.ui.CommandArtifact
* javax.baja.ui.enums.BHalign
* javax.baja.ui.file.ExtFileFilter
* javax.baja.ui.pane.BBorderPane
* javax.baja.ui.pane.BEdgePane
* javax.baja.ui.transfer.TransferContext
* javax.baja.ui.transfer.TransferFormat
* javax.baja.ui.tree.BTree
* javax.baja.ui.tree.TreeModel
* javax.baja.ui.tree.TreeNode
* javax.baja.ui.util.UiLexicon
* javax.baja.util.Lexicon
*/
package com.tridium.platform.ui.license;
import com.tridium.file.types.text.BLicenseFile;
import com.tridium.platform.license.BEnvLicenseSummary;
import com.tridium.platform.license.BLicenseArchiveFile;
import com.tridium.platform.license.LicenseInfo;
import com.tridium.platform.license.PortalLicenseUtil;
import com.tridium.platform.ui.util.AsyncCommand;
import com.tridium.platform.ui.util.BBox;
import com.tridium.platform.ui.util.BButtonPane;
import com.tridium.platform.ui.util.BFileChooserDialog;
import com.tridium.platform.ui.util.CommandUtil;
import com.tridium.platform.ui.util.ExtPathFilter;
import com.tridium.platform.ui.util.FavoriteDirectory;
import com.tridium.platform.ui.util.IFilePathFilter;
import com.tridium.sys.license.dom.CertificateDatabase;
import com.tridium.sys.license.dom.LicenseDatabase;
import com.tridium.sys.license.dom.VendorCertificate;
import com.tridium.sys.license.dom.VendorLicense;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.util.HashSet;
import java.util.Iterator;
import java.util.TreeMap;
import java.util.TreeSet;
import javax.baja.file.BDirectory;
import javax.baja.file.BFileSystem;
import javax.baja.file.BIFile;
import javax.baja.file.FilePath;
import javax.baja.file.IFileFilter;
import javax.baja.gx.BImage;
import javax.baja.nre.util.Array;
import javax.baja.space.Mark;
import javax.baja.sys.Action;
import javax.baja.sys.BComponent;
import javax.baja.sys.BIcon;
import javax.baja.sys.BObject;
import javax.baja.sys.BValue;
import javax.baja.sys.BajaRuntimeException;
import javax.baja.sys.Context;
import javax.baja.sys.Slot;
import javax.baja.sys.Sys;
import javax.baja.sys.Topic;
import javax.baja.sys.Type;
import javax.baja.ui.BDialog;
import javax.baja.ui.BLabel;
import javax.baja.ui.BWidget;
import javax.baja.ui.Command;
import javax.baja.ui.CommandArtifact;
import javax.baja.ui.enums.BHalign;
import javax.baja.ui.file.ExtFileFilter;
import javax.baja.ui.pane.BBorderPane;
import javax.baja.ui.pane.BEdgePane;
import javax.baja.ui.transfer.TransferContext;
import javax.baja.ui.transfer.TransferFormat;
import javax.baja.ui.tree.BTree;
import javax.baja.ui.tree.TreeModel;
import javax.baja.ui.tree.TreeNode;
import javax.baja.ui.util.UiLexicon;
import javax.baja.util.Lexicon;
public class BWorkbenchLicenseTree
extends BTree {
public static final Action handleSelectionModified = BWorkbenchLicenseTree.newAction((int)0, null);
public static final Topic valueUpdated = BWorkbenchLicenseTree.newTopic((int)0, null);
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$platform$ui$license$BWorkbenchLicenseTree == null ? (class$com$tridium$platform$ui$license$BWorkbenchLicenseTree = BWorkbenchLicenseTree.class$("com.tridium.platform.ui.license.BWorkbenchLicenseTree")) : class$com$tridium$platform$ui$license$BWorkbenchLicenseTree));
private static final BIcon HOST_ICON = BIcon.std((String)"host.png");
private static final BIcon LICENSE_ICON = BIcon.std((String)"file.png");
private static final IFileFilter LAR_FILTER = new ExtFileFilter("TODO", "lar");
private static final IFilePathFilter LAR_PATH_FILTER = new ExtPathFilter("lar");
private static final IFileFilter LICENSE_FILTER = new ExtFileFilter("TODO", "license,lar");
private static final Lexicon LEX = Lexicon.make((String)"platform");
private Command importFile = new ImportFile();
private Command exportFile = new ExportFile();
private Command delete = new Delete();
private SyncOnline syncOnline = new SyncOnline();
static /* synthetic */ Class class$com$tridium$platform$ui$license$BWorkbenchLicenseTree;
static /* synthetic */ Class class$com$tridium$sys$license$dom$VendorLicense;
static /* synthetic */ Class class$com$tridium$platform$license$BEnvLicenseSummary;
public void handleSelectionModified() {
this.invoke(handleSelectionModified, null, null);
}
public void fireValueUpdated(BValue bValue) {
this.fire(valueUpdated, bValue, null);
}
public Type getType() {
return TYPE;
}
public BWorkbenchLicenseTree() {
this.setModel(new Model());
this.setMultipleSelection(true);
this.linkTo(null, (BComponent)this, (Slot)BTree.selectionModified, (Slot)handleSelectionModified);
}
public String getDetailsText() throws Exception {
TreeNode[] treeNodeArray = this.getSelection().getNodes();
if (treeNodeArray.length == 1 && treeNodeArray[0] instanceof LicenseNode) {
return ((LicenseNode)treeNodeArray[0]).getContents();
}
return "";
}
public void importLicenseArchive(BLicenseArchiveFile bLicenseArchiveFile, Context context) throws Exception {
LicenseDatabase.LOCAL_INSTANCE.importFile((BIFile)bLicenseArchiveFile);
this.load(context);
BDialog.message((BWidget)this, (Object)LEX.getText("WorkbenchLicenseTree.importFile.success"));
}
public void load(Context context) throws Exception {
((Model)this.getModel()).load(context);
}
public void reload() throws Exception {
((Model)this.getModel()).reload();
}
public Command[] getCommands() {
if (PortalLicenseUtil.requestLicensesOnline()) {
return new Command[]{this.importFile, this.exportFile, this.delete, this.syncOnline};
}
return new Command[]{this.importFile, this.exportFile, this.delete};
}
public int dragOver(TransferContext transferContext) {
if (transferContext.isCopy() && transferContext.getEnvelope().supports(TransferFormat.mark)) {
Mark mark = (Mark)transferContext.getEnvelope().getData(TransferFormat.mark);
BObject[] bObjectArray = mark.getValues();
for (int i = 0; i < bObjectArray.length; ++i) {
if (!(bObjectArray[i] instanceof BLicenseFile) && !(bObjectArray[i] instanceof BLicenseArchiveFile)) continue;
return 16;
}
}
return 0;
}
public CommandArtifact drop(TransferContext transferContext) throws Exception {
if (transferContext.isCopy() && transferContext.getEnvelope().supports(TransferFormat.mark)) {
Mark mark = (Mark)transferContext.getEnvelope().getData(TransferFormat.mark);
BObject[] bObjectArray = mark.getValues();
boolean bl = false;
for (int i = 0; i < bObjectArray.length; ++i) {
if (!(bObjectArray[i] instanceof BLicenseFile) && !(bObjectArray[i] instanceof BLicenseArchiveFile)) continue;
LicenseDatabase.LOCAL_INSTANCE.importFile((BIFile)bObjectArray[i]);
bl = true;
}
if (bl) {
this.load((Context)transferContext);
BDialog.message((BWidget)this, (Object)LEX.getText("WorkbenchLicenseTree.importFile.success"));
}
}
return null;
}
public void doHandleSelectionModified() {
TreeNode[] treeNodeArray = this.getSelection().getNodes();
this.delete.setEnabled(treeNodeArray.length > 0);
this.fireValueUpdated(null);
}
private String[] getSelectedHostIds() {
TreeNode[] treeNodeArray = this.getSelection().getNodes();
HashSet<String> hashSet = new HashSet<String>();
for (int i = 0; i < treeNodeArray.length; ++i) {
if (treeNodeArray[i] instanceof HostNode) {
hashSet.add(((HostNode)treeNodeArray[i]).getHostId());
continue;
}
hashSet.add(((LicenseNode)treeNodeArray[i]).getHostId());
}
String[] stringArray = new String[hashSet.size()];
hashSet.toArray(stringArray);
return stringArray;
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
private class SyncOnline
extends AsyncCommand {
public boolean canceled = false;
public SyncOnline() {
super((BWidget)BWorkbenchLicenseTree.this, LEX.getText("WorkbenchLicenseTree.syncOnline.label"), null, null, LEX.getText("WorkbenchLicenseTree.syncOnline.description"));
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public void doInvokeAsync() {
block21: {
try {
TreeNode[] treeNodeArray = BWorkbenchLicenseTree.this.getSelection().getNodes();
int n = 0;
int n2 = 0;
if (treeNodeArray.length == 0) {
if (4 != BDialog.confirm((BWidget)BWorkbenchLicenseTree.this, (String)LEX.getText("WorkbenchLicenseTree.syncAll.confirmTitle"), (Object)LEX.getText("WorkbenchLicenseTree.syncAll.confirmMessage"))) {
return;
}
this.canceled = false;
BLabel bLabel = new BLabel(LEX.getText("WorkbenchLicenseTree.syncAll.working", new Object[]{"0"}));
bLabel.setHalign(BHalign.left);
BDialog bDialog = new BDialog(this.getOwner(), LEX.getText("WorkbenchLicenseTree.syncAll.workingTitle"), false, (BWidget)new BEdgePane((BWidget)new BBox(300.0, 0.0), (BWidget)new BBorderPane((BWidget)new BButtonPane(new Command[]{new CancelSync()}), 0.0, 10.0, 10.0, 10.0), null, null, (BWidget)new BBorderPane((BWidget)bLabel, 10.0, 10.0, 10.0, 10.0)));
bDialog.setBoundsCenteredOnOwner();
bDialog.open();
try {
Array array = new Array(class$com$tridium$sys$license$dom$VendorLicense == null ? (class$com$tridium$sys$license$dom$VendorLicense = BWorkbenchLicenseTree.class$("com.tridium.sys.license.dom.VendorLicense")) : class$com$tridium$sys$license$dom$VendorLicense);
VendorCertificate[] vendorCertificateArray = LicenseDatabase.LOCAL_INSTANCE.iterator();
while (vendorCertificateArray.hasNext()) {
if (this.canceled) {
array.clear();
break;
}
array.add(vendorCertificateArray.next());
if (array.size() < 100) continue;
VendorLicense[] vendorLicenseArray = PortalLicenseUtil.getPortalUpdates((VendorLicense[])array.trim());
for (int i = 0; i < vendorLicenseArray.length; ++i) {
if (!LicenseDatabase.LOCAL_INSTANCE.add(vendorLicenseArray[i])) continue;
bLabel.setText(LEX.getText("WorkbenchLicenseTree.syncAll.working", new Object[]{String.valueOf(++n)}));
}
array.clear();
}
if (array.size() > 0) {
vendorCertificateArray = PortalLicenseUtil.getPortalUpdates((VendorLicense[])array.trim());
for (int i = 0; i < vendorCertificateArray.length; ++i) {
if (!LicenseDatabase.LOCAL_INSTANCE.add((VendorLicense)vendorCertificateArray[i])) continue;
bLabel.setText(LEX.getText("WorkbenchLicenseTree.syncAll.working", new Object[]{String.valueOf(++n)}));
}
}
vendorCertificateArray = PortalLicenseUtil.getPortalUpdates(CertificateDatabase.LOCAL_INSTANCE.getCertificates());
for (int i = 0; i < vendorCertificateArray.length; ++i) {
if (!CertificateDatabase.LOCAL_INSTANCE.add(vendorCertificateArray[i])) continue;
bLabel.setText(LEX.getText("WorkbenchLicenseTree.syncAll.cert.working", new Object[]{String.valueOf(++n2)}));
}
}
finally {
bDialog.close();
}
if (n > 0 || n2 > 0) {
BWorkbenchLicenseTree.this.reload();
}
BDialog.message((BWidget)this.getOwner(), (String)LEX.getText("WorkbenchLicenseTree.syncOnline.completeTitle"), (Object)new BEdgePane((BWidget)new BBox(300.0, 1.0), null, null, null, (BWidget)new BLabel(LEX.getText("WorkbenchLicenseTree.syncOnline.completeMessage", new Object[]{String.valueOf(n), String.valueOf(n2)}), BHalign.left)));
break block21;
}
Array array = new Array(class$com$tridium$platform$license$BEnvLicenseSummary == null ? (class$com$tridium$platform$license$BEnvLicenseSummary = BWorkbenchLicenseTree.class$("com.tridium.platform.license.BEnvLicenseSummary")) : class$com$tridium$platform$license$BEnvLicenseSummary);
for (int i = 0; i < treeNodeArray.length; ++i) {
TreeNode treeNode;
if (treeNodeArray[i] instanceof HostNode) {
treeNode = (HostNode)treeNodeArray[i];
LicenseNode[] licenseNodeArray = treeNode.getChildren();
for (int j = 0; j < licenseNodeArray.length; ++j) {
array.add((Object)BEnvLicenseSummary.make(licenseNodeArray[j].getVendorLicense()));
}
continue;
}
treeNode = (LicenseNode)treeNodeArray[i];
array.add((Object)BEnvLicenseSummary.make(treeNode.getVendorLicense()));
}
VendorLicense[] vendorLicenseArray = PortalLicenseUtil.getPortalUpdates((BEnvLicenseSummary[])array.trim());
for (int i = 0; i < vendorLicenseArray.length; ++i) {
if (!LicenseDatabase.LOCAL_INSTANCE.add(vendorLicenseArray[i])) continue;
++n;
}
VendorCertificate[] vendorCertificateArray = PortalLicenseUtil.getPortalUpdates(CertificateDatabase.LOCAL_INSTANCE.getCertificates());
for (int i = 0; i < vendorCertificateArray.length; ++i) {
if (!CertificateDatabase.LOCAL_INSTANCE.add(vendorCertificateArray[i])) continue;
++n2;
}
if (n > 0 || n2 > 0) {
BWorkbenchLicenseTree.this.reload();
}
BDialog.message((BWidget)this.getOwner(), (String)LEX.getText("WorkbenchLicenseTree.syncOnline.completeTitle"), (Object)LEX.getText("WorkbenchLicenseTree.syncOnline.completeMessage", new Object[]{String.valueOf(n), String.valueOf(n2)}));
}
catch (Exception exception) {
CommandUtil.error(this, exception);
}
}
}
}
private class CancelSync
extends Command {
public CancelSync() {
super((BWidget)BWorkbenchLicenseTree.this, UiLexicon.bajaui().getText("cancel"), null, null, null);
}
public CommandArtifact doInvoke() {
((BWorkbenchLicenseTree)BWorkbenchLicenseTree.this).syncOnline.canceled = true;
return null;
}
}
private class Delete
extends Command {
public Delete() {
super((BWidget)BWorkbenchLicenseTree.this, LEX.getText("WorkbenchLicenseTree.delete.label"), null, null, LEX.getText("WorkbenchLicenseTree.delete.description"));
this.setEnabled(false);
}
public CommandArtifact doInvoke() throws Exception {
TreeNode[] treeNodeArray = BWorkbenchLicenseTree.this.getSelection().getNodes();
if (treeNodeArray.length > 0 && 4 == BDialog.confirm((BWidget)BWorkbenchLicenseTree.this, (String)LEX.getText("WorkbenchLicenseTree.delete.confirmTitle"), (Object)LEX.getText("WorkbenchLicenseTree.delete.confirmMessage"))) {
for (int i = 0; i < treeNodeArray.length; ++i) {
if (treeNodeArray[i] instanceof HostNode) {
for (int j = 0; j < treeNodeArray[i].getChildCount(); ++j) {
LicenseDatabase.LOCAL_INSTANCE.remove(((LicenseNode)treeNodeArray[i].getChild(j)).getVendorLicense());
}
continue;
}
LicenseDatabase.LOCAL_INSTANCE.remove(((LicenseNode)treeNodeArray[i]).getVendorLicense());
}
BWorkbenchLicenseTree.this.getSelection().deselectAll();
BWorkbenchLicenseTree.this.reload();
}
return null;
}
}
private class ExportFile
extends Command {
public ExportFile() {
super((BWidget)BWorkbenchLicenseTree.this, LEX.getText("WorkbenchLicenseTree.exportFile.label"), null, null, LEX.getText("WorkbenchLicenseTree.exportFile.description"));
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public CommandArtifact doInvoke() throws Exception {
TreeNode[] treeNodeArray = BWorkbenchLicenseTree.this.getSelection().getNodes();
if (treeNodeArray.length == 0 && 8 == BDialog.confirm((BWidget)BWorkbenchLicenseTree.this, (String)LEX.getText("WorkbenchLicenseTree.exportFile.confirmTitle"), (Object)LEX.getText("WorkbenchLicenseTree.exportFile.confirmMessage"))) {
return null;
}
BDirectory bDirectory = FavoriteDirectory.loadByPath(TYPE.toString(), "larDir", null);
FilePath filePath = BFileChooserDialog.chooseFilePath((BWidget)BWorkbenchLicenseTree.this, null, LEX.getText("WorkbenchLicenseTree.exportFile.title"), LEX.getText("WorkbenchLicenseTree.exportFile.message"), (BIFile)bDirectory, LAR_FILTER, LAR_PATH_FILTER, null, "licenses.lar");
if (filePath == null) {
return null;
}
BIFile bIFile = BFileSystem.INSTANCE.findFile(filePath);
if (bIFile == null) {
bIFile = BFileSystem.INSTANCE.makeFile(filePath);
} else if (8 == BDialog.confirm((BWidget)BWorkbenchLicenseTree.this, (String)LEX.getText("WorkbenchLicenseTree.exportFile.replaceTitle"), (Object)LEX.getText("WorkbenchLicenseTree.exportFile.replaceMessage", new Object[]{filePath.getName()}))) {
return null;
}
FavoriteDirectory.savePath(TYPE.toString(), "larDir", (BDirectory)bIFile.getNavParent());
OutputStream outputStream = bIFile.getOutputStream();
try {
if (treeNodeArray.length == 0) {
LicenseDatabase.LOCAL_INSTANCE.exportLicenses(outputStream);
} else {
LicenseDatabase.LOCAL_INSTANCE.exportLicenses(BWorkbenchLicenseTree.this.getSelectedHostIds(), outputStream);
}
BDialog.message((BWidget)BWorkbenchLicenseTree.this, (Object)LEX.getText("WorkbenchLicenseTree.exportFile.success"));
}
finally {
try {
outputStream.close();
}
catch (Exception exception) {}
}
return null;
}
}
private class ImportFile
extends Command {
public ImportFile() {
super((BWidget)BWorkbenchLicenseTree.this, LEX.getText("WorkbenchLicenseTree.importFile.label"), null, null, LEX.getText("WorkbenchLicenseTree.importFile.description"));
}
public CommandArtifact doInvoke() throws Exception {
BIFile bIFile = BFileChooserDialog.chooseFile((BWidget)BWorkbenchLicenseTree.this, null, LEX.getText("WorkbenchLicenseTree.importFile.title"), LEX.getText("WorkbenchLicenseTree.importFile.message"), (BIFile)FavoriteDirectory.loadByPath(TYPE.toString(), "larDir", null), LICENSE_FILTER, LICENSE_FILTER);
if (bIFile == null) {
return null;
}
LicenseDatabase.LOCAL_INSTANCE.importFile(bIFile);
BWorkbenchLicenseTree.this.reload();
BDialog.message((BWidget)BWorkbenchLicenseTree.this, (Object)LEX.getText("WorkbenchLicenseTree.importFile.success"));
return null;
}
}
private class LicenseNode
extends TreeNode {
private VendorLicense vendorLicense;
private Context cx;
public LicenseNode(HostNode hostNode, VendorLicense vendorLicense, Context context) {
super((TreeNode)hostNode);
this.update(vendorLicense);
this.cx = context;
}
public String getText() {
return LicenseInfo.getSummaryText(this.vendorLicense, this.cx);
}
public boolean update(VendorLicense vendorLicense) {
if (this.vendorLicense == null || !vendorLicense.getSignature().equals(this.vendorLicense.getSignature())) {
this.vendorLicense = vendorLicense;
return true;
}
return false;
}
public BImage getIcon() {
return BImage.make((BIcon)LICENSE_ICON);
}
public int getChildCount() {
return 0;
}
public TreeNode getChild(int n) {
throw new ArrayIndexOutOfBoundsException();
}
public VendorLicense getVendorLicense() {
return this.vendorLicense;
}
public String getHostId() {
return this.getVendorLicense().getHostId();
}
public String getContents() throws Exception {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
this.vendorLicense.save((OutputStream)byteArrayOutputStream);
return byteArrayOutputStream.toString();
}
}
private class HostNode
extends TreeNode {
private String hostId;
private LicenseNode[] children = null;
private Context cx;
public HostNode(TreeModel treeModel, String string, Context context) {
super(treeModel);
this.hostId = string;
this.cx = context;
}
public String getHostId() {
return this.hostId;
}
public String getText() {
return this.getHostId();
}
public BImage getIcon() {
return BImage.make((BIcon)HOST_ICON);
}
public int getChildCount() {
return this.getChildren().length;
}
public TreeNode getChild(int n) {
return this.getChildren()[n];
}
public synchronized boolean update() throws Exception {
if (this.children == null) {
return false;
}
TreeMap<String, LicenseNode> treeMap = new TreeMap<String, LicenseNode>();
TreeSet<String> treeSet = new TreeSet<String>();
boolean bl = false;
boolean bl2 = false;
for (int i = 0; i < this.children.length; ++i) {
treeSet.add(this.children[i].getText());
treeMap.put(this.children[i].getText(), this.children[i]);
}
VendorLicense[] vendorLicenseArray = LicenseDatabase.LOCAL_INSTANCE.getLicenses(this.hostId);
for (int i = 0; i < vendorLicenseArray.length; ++i) {
String string = LicenseInfo.getSummaryText(vendorLicenseArray[i], this.cx);
LicenseNode licenseNode = (LicenseNode)((Object)treeMap.get(string));
if (licenseNode == null) {
treeMap.put(string, new LicenseNode(this, vendorLicenseArray[i], this.cx));
bl = true;
bl2 = true;
continue;
}
bl = licenseNode.update(vendorLicenseArray[i]) || bl;
treeSet.remove(licenseNode.getText());
}
Iterator iterator = treeSet.iterator();
while (iterator.hasNext()) {
treeMap.remove(iterator.next());
bl2 = true;
bl = true;
}
if (bl2) {
this.children = new LicenseNode[treeMap.size()];
treeMap.values().toArray(this.children);
}
return bl;
}
public LicenseNode[] getChildren() {
try {
if (this.children == null) {
VendorLicense[] vendorLicenseArray = LicenseDatabase.LOCAL_INSTANCE.getLicenses(this.hostId);
this.children = new LicenseNode[vendorLicenseArray.length];
for (int i = 0; i < vendorLicenseArray.length; ++i) {
this.children[i] = new LicenseNode(this, vendorLicenseArray[i], this.cx);
}
}
return this.children;
}
catch (RuntimeException runtimeException) {
throw runtimeException;
}
catch (Exception exception) {
throw new BajaRuntimeException((Throwable)exception);
}
}
}
private class Model
extends TreeModel {
private HostNode[] hostNodes = new HostNode[0];
private Context cx;
private Model() {
}
public synchronized void load(Context context) throws Exception {
int n;
this.cx = context;
String[] stringArray = LicenseDatabase.LOCAL_INSTANCE.getHostIds();
TreeMap<String, HostNode> treeMap = new TreeMap<String, HostNode>();
boolean bl = false;
boolean bl2 = false;
TreeSet<String> treeSet = new TreeSet<String>();
for (n = 0; n < this.hostNodes.length; ++n) {
treeMap.put(this.hostNodes[n].getHostId(), this.hostNodes[n]);
treeSet.add(this.hostNodes[n].getHostId());
}
for (n = 0; n < stringArray.length; ++n) {
HostNode hostNode = (HostNode)((Object)treeMap.get(stringArray[n]));
if (hostNode == null) {
treeMap.put(stringArray[n], new HostNode(this, stringArray[n], context));
bl2 = true;
continue;
}
treeSet.remove(stringArray[n]);
bl = hostNode.update() || bl;
}
Iterator iterator = treeSet.iterator();
while (iterator.hasNext()) {
treeMap.remove(iterator.next());
bl2 = true;
}
if (bl2) {
bl = true;
this.hostNodes = new HostNode[treeMap.size()];
treeMap.values().toArray(this.hostNodes);
}
if (bl) {
this.updateTree();
BWorkbenchLicenseTree.this.fireValueUpdated(null);
}
}
public synchronized void reload() throws Exception {
this.load(this.cx);
}
public int getRootCount() {
return this.hostNodes.length;
}
public TreeNode getRoot(int n) {
return this.hostNodes[n];
}
public Context getContext() {
return this.cx;
}
}
}
@@ -0,0 +1,248 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.fox.sys.file.BFoxFileSpace
* com.tridium.fox.sys.file.BFoxFileStore
* com.tridium.sys.license.dom.LicenseDatabase
* com.tridium.sys.license.dom.VendorLicense
* javax.baja.file.BDirectory
* javax.baja.file.BFileSpace
* javax.baja.file.BIFile
* javax.baja.file.FilePath
* javax.baja.nre.util.Array
* javax.baja.nre.util.ByteBuffer
* javax.baja.sys.BajaRuntimeException
* javax.baja.ui.list.ListModel
* javax.baja.util.Version
*/
package com.tridium.platform.ui.license;
import com.tridium.fox.sys.file.BFoxFileSpace;
import com.tridium.fox.sys.file.BFoxFileStore;
import com.tridium.platform.fox.BLicenseChannel;
import com.tridium.platform.license.CertificateInfo;
import com.tridium.platform.license.IFileInfo;
import com.tridium.platform.license.LicenseInfo;
import com.tridium.platform.license.PortalLicenseUtil;
import com.tridium.sys.license.dom.LicenseDatabase;
import com.tridium.sys.license.dom.VendorLicense;
import java.io.InputStream;
import javax.baja.file.BDirectory;
import javax.baja.file.BFileSpace;
import javax.baja.file.BIFile;
import javax.baja.file.FilePath;
import javax.baja.nre.util.Array;
import javax.baja.nre.util.ByteBuffer;
import javax.baja.sys.BajaRuntimeException;
import javax.baja.ui.list.ListModel;
import javax.baja.util.Version;
public class FileInfoListModel
extends ListModel {
private Array kids = new Array(class$com$tridium$platform$license$IFileInfo == null ? (class$com$tridium$platform$license$IFileInfo = FileInfoListModel.class$("com.tridium.platform.license.IFileInfo")) : class$com$tridium$platform$license$IFileInfo);
private FilePath directoryPath;
private String ext;
private BFileSpace space;
private Class elementClass;
static /* synthetic */ Class class$com$tridium$platform$license$IFileInfo;
public FileInfoListModel(FilePath filePath, String string, Class clazz) {
this.directoryPath = filePath;
this.ext = string;
this.elementClass = clazz;
}
public int getItemCount() {
return this.kids.size();
}
public Object getItem(int n) {
return this.getFileName(n);
}
public IFileInfo getInfo(int n) {
return (IFileInfo)this.kids.get(n);
}
public BIFile getFile(int n) {
return this.getInfo(n).getFile();
}
public String getFileName(int n) {
return this.getFile(n).getFileName();
}
public int getFileSize(int n) {
return (int)this.getFile(n).getSize();
}
public synchronized IFileInfo[] getInfo() {
IFileInfo[] iFileInfoArray = (IFileInfo[])java.lang.reflect.Array.newInstance(this.elementClass, this.getItemCount());
for (int i = 0; i < this.getItemCount(); ++i) {
iFileInfoArray[i] = this.getInfo(i);
}
return iFileInfoArray;
}
public FilePath getFilePath(int n) {
return this.directoryPath.merge(this.getFileName(n));
}
public InputStream getFileContentStream(int n) {
BLicenseChannel bLicenseChannel = this.getChannel();
if (bLicenseChannel != null) {
try {
return bLicenseChannel.read((BFoxFileStore)this.getFile(n).getStore());
}
catch (Exception exception) {
// empty catch block
}
}
try {
return this.getFile(n).getInputStream();
}
catch (RuntimeException runtimeException) {
throw runtimeException;
}
catch (Exception exception) {
throw new BajaRuntimeException((Throwable)exception);
}
}
public void deleteFiles(int[] nArray) {
try {
BIFile[] bIFileArray = new BIFile[nArray.length];
for (int i = 0; i < bIFileArray.length; ++i) {
this.getFile(nArray[i]).delete();
}
this.reload();
}
catch (RuntimeException runtimeException) {
throw runtimeException;
}
catch (Exception exception) {
throw new BajaRuntimeException((Throwable)exception);
}
}
public void deleteFile(int n) {
try {
this.getFile(n).delete();
this.kids.remove(n);
this.updateList();
}
catch (RuntimeException runtimeException) {
throw runtimeException;
}
catch (Exception exception) {
throw new BajaRuntimeException((Throwable)exception);
}
}
public String getFileContents(int n) {
BLicenseChannel bLicenseChannel = this.getChannel();
if (bLicenseChannel != null) {
try {
ByteBuffer byteBuffer = new ByteBuffer();
byteBuffer.readToEnd(bLicenseChannel.read((BFoxFileStore)this.getFile(n).getStore()));
return new String(byteBuffer.toByteArray());
}
catch (Exception exception) {
// empty catch block
}
}
try {
return new String(this.getFile(n).read());
}
catch (RuntimeException runtimeException) {
throw runtimeException;
}
catch (Exception exception) {
throw new BajaRuntimeException((Throwable)exception);
}
}
public void reload() {
this.loadValue(this.space);
}
public synchronized void loadValue(BFileSpace bFileSpace) {
BDirectory bDirectory;
this.kids.clear();
this.space = bFileSpace;
BIFile[] bIFileArray = null;
BLicenseChannel bLicenseChannel = this.getChannel();
if (bLicenseChannel != null) {
try {
if (this.directoryPath.equals((Object)CertificateInfo.CERTS_PATH)) {
bIFileArray = bLicenseChannel.listcertificates((BFoxFileSpace)this.space);
} else if (this.directoryPath.equals((Object)LicenseInfo.LICENSES_PATH)) {
bIFileArray = bLicenseChannel.listlicenses((BFoxFileSpace)this.space);
}
}
catch (Exception exception) {
// empty catch block
}
}
if (bIFileArray == null && (bDirectory = (BDirectory)this.space.findFile(this.directoryPath)) != null) {
bIFileArray = bDirectory.listFiles();
}
for (int i = 0; i < bIFileArray.length; ++i) {
if (bIFileArray[i].getExtension() == null || !bIFileArray[i].getExtension().equals(this.ext)) continue;
try {
InputStream inputStream;
IFileInfo iFileInfo = PortalLicenseUtil.makeFileInfo(bIFileArray[i]);
this.kids.add((Object)iFileInfo);
if (!(iFileInfo instanceof LicenseInfo)) continue;
VendorLicense vendorLicense = null;
try {
if (bLicenseChannel != null) {
inputStream = bLicenseChannel.read((BFoxFileStore)bIFileArray[i].getStore());
vendorLicense = VendorLicense.make((String)bIFileArray[i].getFileName(), (InputStream)inputStream);
}
}
catch (Exception exception) {
// empty catch block
}
if (vendorLicense == null) {
vendorLicense = VendorLicense.make((BIFile)bIFileArray[i]);
}
if ((inputStream = LicenseDatabase.LOCAL_INSTANCE.getLicense(vendorLicense.getHostId(), vendorLicense.getVendor(), vendorLicense.getBrandId())) != null && inputStream.getGenerated() >= vendorLicense.getGenerated()) continue;
LicenseDatabase.LOCAL_INSTANCE.add(vendorLicense);
continue;
}
catch (Exception exception) {
exception.printStackTrace();
}
}
this.updateList();
}
public BLicenseChannel getChannel() {
BLicenseChannel bLicenseChannel = null;
if (this.space instanceof BFoxFileSpace) {
BFoxFileSpace bFoxFileSpace = (BFoxFileSpace)this.space;
try {
Version version = (Version)bFoxFileSpace.getFoxSession().fw(404, (Object)"platform", null, null, null);
if (version != null && version.compareTo((Object)new Version("3.7.201")) != -1) {
bLicenseChannel = (BLicenseChannel)bFoxFileSpace.getFoxSession().getConnection().getChannels().get("license", BLicenseChannel.TYPE);
}
}
catch (Exception exception) {
// empty catch block
}
}
return bLicenseChannel;
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
}
@@ -0,0 +1,117 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.ui.theme.Theme
* javax.baja.sys.BModule
* javax.baja.sys.BValue
* javax.baja.sys.Sys
* javax.baja.ui.BDialog
* javax.baja.ui.BLabel
* javax.baja.ui.BWidget
* javax.baja.ui.BWidgetShell
* javax.baja.ui.enums.BHalign
* javax.baja.ui.pane.BBorderPane
* javax.baja.ui.pane.BEdgePane
* javax.baja.ui.pane.BGridPane
* javax.baja.util.Lexicon
*/
package com.tridium.platform.ui.license;
import com.tridium.platform.license.IFileInfo;
import com.tridium.platform.license.PortalLicenseUtil;
import com.tridium.ui.theme.Theme;
import java.lang.reflect.Method;
import javax.baja.sys.BModule;
import javax.baja.sys.BValue;
import javax.baja.sys.Sys;
import javax.baja.ui.BDialog;
import javax.baja.ui.BLabel;
import javax.baja.ui.BWidget;
import javax.baja.ui.BWidgetShell;
import javax.baja.ui.enums.BHalign;
import javax.baja.ui.pane.BBorderPane;
import javax.baja.ui.pane.BEdgePane;
import javax.baja.ui.pane.BGridPane;
import javax.baja.util.Lexicon;
public class UiUtil {
public static final Lexicon lex = Lexicon.make((String)"platform");
static /* synthetic */ Class class$javax$baja$ui$BWidgetShell;
static /* synthetic */ Class class$java$lang$String;
public static void requestLicense(BWidgetShell bWidgetShell, String string) {
if (!PortalLicenseUtil.isApiAvailable()) {
throw new UnsupportedOperationException();
}
try {
BModule bModule = Sys.loadModule((String)"portalApi");
Class clazz = bModule.loadClass("com.tridium.portal.wb.LicenseProcedure");
Method method = clazz.getMethod("requestLicense", class$javax$baja$ui$BWidgetShell == null ? (class$javax$baja$ui$BWidgetShell = UiUtil.class$("javax.baja.ui.BWidgetShell")) : class$javax$baja$ui$BWidgetShell, class$java$lang$String == null ? (class$java$lang$String = UiUtil.class$("java.lang.String")) : class$java$lang$String);
method.invoke(null, bWidgetShell, string);
}
catch (Exception exception) {
BDialog.error((BWidget)bWidgetShell, (String)"Error", (Object)"License request failed.", (Throwable)exception);
}
}
public static BWidget buildUpdateDescription(String string, IFileInfo[] iFileInfoArray, IFileInfo[] iFileInfoArray2, IFileInfo[] iFileInfoArray3) {
return UiUtil.buildUpdateDescription(string, null, iFileInfoArray, iFileInfoArray2, iFileInfoArray3);
}
public static BWidget buildUpdateDescription(String string, String string2, IFileInfo[] iFileInfoArray, IFileInfo[] iFileInfoArray2, IFileInfo[] iFileInfoArray3) {
int n;
int n2;
BLabel bLabel;
BEdgePane bEdgePane = new BEdgePane();
BLabel bLabel2 = new BLabel(string);
bLabel2.setHalign(BHalign.left);
bEdgePane.setTop((BWidget)bLabel2);
BGridPane bGridPane = new BGridPane(1);
bGridPane.setHalign(BHalign.left);
bEdgePane.setCenter((BWidget)new BBorderPane((BWidget)bGridPane, 4.0, 4.0, 4.0, 0.0));
if (iFileInfoArray != null && iFileInfoArray.length != 0) {
bLabel = new BLabel(lex.getText("UiUtil.added"));
bLabel.setFont(Theme.label().getBoldText());
bGridPane.add(null, (BValue)bLabel);
n2 = iFileInfoArray.length;
for (n = 0; n < n2; ++n) {
bGridPane.add(null, (BValue)new BBorderPane((BWidget)new BLabel(iFileInfoArray[n].toString()), 0.0, 0.0, 0.0, 10.0));
}
}
if (iFileInfoArray2 != null && iFileInfoArray2.length != 0) {
bLabel = new BLabel(lex.getText("UiUtil.updated"));
bLabel.setFont(Theme.label().getBoldText());
bGridPane.add(null, (BValue)bLabel);
n2 = iFileInfoArray2.length;
for (n = 0; n < n2; ++n) {
bGridPane.add(null, (BValue)new BBorderPane((BWidget)new BLabel(iFileInfoArray2[n].toString()), 0.0, 0.0, 0.0, 10.0));
}
}
if (iFileInfoArray3 != null && iFileInfoArray3.length != 0) {
bLabel = new BLabel(lex.getText("UiUtil.removed"));
bLabel.setFont(Theme.label().getBoldText());
bGridPane.add(null, (BValue)bLabel);
n2 = iFileInfoArray3.length;
for (n = 0; n < n2; ++n) {
bGridPane.add(null, (BValue)new BBorderPane((BWidget)new BLabel(iFileInfoArray3[n].toString()), 0.0, 0.0, 0.0, 10.0));
}
}
if (string2 != null) {
bLabel2 = new BLabel(string2);
bLabel2.setHalign(BHalign.left);
bEdgePane.setBottom((BWidget)bLabel2);
}
return bEdgePane;
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
}