258 lines
8.4 KiB
Java
258 lines
8.4 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* javax.baja.file.BIFile
|
|
* javax.baja.sys.Sys
|
|
* javax.baja.sys.Type
|
|
* javax.baja.xml.XContent
|
|
* javax.baja.xml.XElem
|
|
* javax.baja.xml.XParser
|
|
* javax.baja.xml.XWriter
|
|
*/
|
|
package com.tridium.install;
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.InputStream;
|
|
import java.io.OutputStream;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import javax.baja.file.BIFile;
|
|
import javax.baja.platform.install.BFileReconciler;
|
|
import javax.baja.sys.Sys;
|
|
import javax.baja.sys.Type;
|
|
import javax.baja.xml.XContent;
|
|
import javax.baja.xml.XElem;
|
|
import javax.baja.xml.XParser;
|
|
import javax.baja.xml.XWriter;
|
|
|
|
/*
|
|
* Illegal identifiers - consider using --renameillegalidents true
|
|
*/
|
|
public class BUnitDatabaseMerge
|
|
extends BFileReconciler {
|
|
public static final BUnitDatabaseMerge INSTANCE = new BUnitDatabaseMerge();
|
|
public static final Type TYPE;
|
|
static /* synthetic */ Class class$com$tridium$install$BUnitDatabaseMerge;
|
|
|
|
public Type getType() {
|
|
return TYPE;
|
|
}
|
|
|
|
public BFileReconciler.ReconciliationResults reconcile(BIFile bIFile, BIFile bIFile2) throws Exception {
|
|
Object object;
|
|
String string;
|
|
boolean bl = false;
|
|
HashMap<String, XElem> hashMap = new HashMap<String, XElem>();
|
|
HashMap<String, XElem> hashMap2 = new HashMap<String, XElem>();
|
|
HashMap<String, Object> hashMap3 = new HashMap<String, Object>();
|
|
XElem xElem = this.parseFile(bIFile2);
|
|
XElem[] xElemArray = xElem.elems("quantity");
|
|
int n = 0;
|
|
while (n < xElemArray.length) {
|
|
XElem xElem2 = xElemArray[n];
|
|
string = xElem2.get("n");
|
|
hashMap2.put(string, xElem2);
|
|
object = xElem2.elems("unit");
|
|
int n2 = 0;
|
|
while (n2 < ((XElem[])object).length) {
|
|
String string2 = object[n2].get("n");
|
|
hashMap.put(string2, object[n2]);
|
|
hashMap3.put(string2, string);
|
|
++n2;
|
|
}
|
|
++n;
|
|
}
|
|
XElem xElem3 = this.parseFile(bIFile);
|
|
xElemArray = xElem3.elems("quantity");
|
|
int n3 = 0;
|
|
while (n3 < xElemArray.length) {
|
|
string = xElemArray[n3];
|
|
object = string.get("n");
|
|
XElem[] xElemArray2 = string.elems("unit");
|
|
int n4 = 0;
|
|
while (n4 < xElemArray2.length) {
|
|
String string3;
|
|
XElem xElem4 = xElemArray2[n4];
|
|
String string4 = xElem4.get("n");
|
|
XElem xElem5 = (XElem)hashMap.get(string4);
|
|
if (xElem5 == null) {
|
|
string3 = this.getOldQuantityElem((XElem)string, xElem, hashMap2);
|
|
xElem5 = xElem4.copy();
|
|
string3.addContent((XContent)xElem5);
|
|
hashMap.put(string4, xElem5);
|
|
bl = true;
|
|
} else {
|
|
XElem xElem6;
|
|
string3 = (String)hashMap3.get(string4);
|
|
if (!((String)object).equals(string3)) {
|
|
xElem6 = (XElem)hashMap2.get(string3);
|
|
xElem6.removeContent((XContent)xElem5);
|
|
xElem6 = this.getOldQuantityElem((XElem)string, xElem, hashMap2);
|
|
xElem5 = xElem4.copy();
|
|
xElem6.addContent((XContent)xElem5);
|
|
hashMap3.put(string4, object);
|
|
hashMap.put(string4, xElem5);
|
|
bl = true;
|
|
} else if (!this.equivalent(xElem4, xElem5)) {
|
|
xElem6 = this.getOldQuantityElem((XElem)string, xElem, hashMap2);
|
|
xElem6.removeContent((XContent)xElem5);
|
|
xElem5 = xElem4.copy();
|
|
xElem6.addContent((XContent)xElem5);
|
|
hashMap.put(string4, xElem5);
|
|
bl = true;
|
|
}
|
|
}
|
|
++n4;
|
|
}
|
|
++n3;
|
|
}
|
|
if (bl) {
|
|
return new XmlReconciliationResults(xElem);
|
|
}
|
|
return NO_RECONCILIATION;
|
|
}
|
|
|
|
protected XElem getOldQuantityElem(XElem xElem, XElem xElem2, Map map) {
|
|
String string = xElem.get("n");
|
|
XElem xElem3 = (XElem)map.get(string);
|
|
if (xElem3 == null) {
|
|
xElem3 = this.shallowCopy(xElem);
|
|
xElem2.addContent((XContent)xElem3);
|
|
map.put(string, xElem3);
|
|
}
|
|
return xElem3;
|
|
}
|
|
|
|
protected boolean equivalent(XElem xElem, XElem xElem2) {
|
|
if (xElem == xElem2) {
|
|
return true;
|
|
}
|
|
if (xElem == null) {
|
|
boolean bl = false;
|
|
if (xElem2 == null) {
|
|
bl = true;
|
|
}
|
|
return bl;
|
|
}
|
|
if (xElem2 == null) {
|
|
return false;
|
|
}
|
|
if (this.equals(xElem.ns(), xElem2.ns()) && this.equals(xElem.name(), xElem2.name()) && xElem.attrSize() == xElem2.attrSize()) {
|
|
int n = 0;
|
|
while (n < xElem.attrSize()) {
|
|
int n2 = xElem2.attrIndex(xElem.attrNs(n), xElem.attrName(n));
|
|
if (n2 < 0) {
|
|
return false;
|
|
}
|
|
if (!this.equals(xElem.attrValue(n), xElem2.attrValue(n2))) {
|
|
return false;
|
|
}
|
|
++n;
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
protected boolean equals(Object object, Object object2) {
|
|
if (object == object2) {
|
|
return true;
|
|
}
|
|
if (object == null) {
|
|
boolean bl = false;
|
|
if (object2 == null) {
|
|
bl = true;
|
|
}
|
|
return bl;
|
|
}
|
|
return object.equals(object2);
|
|
}
|
|
|
|
/*
|
|
* WARNING - Removed try catching itself - possible behaviour change.
|
|
*/
|
|
protected XElem parseFile(BIFile bIFile) throws Exception {
|
|
XElem xElem;
|
|
InputStream inputStream = bIFile.getInputStream();
|
|
try {
|
|
xElem = XParser.make((InputStream)inputStream).parse();
|
|
Object var4_4 = null;
|
|
}
|
|
catch (Throwable throwable) {
|
|
Object var4_5 = null;
|
|
try {
|
|
inputStream.close();
|
|
}
|
|
catch (Exception exception) {}
|
|
throw throwable;
|
|
}
|
|
try {
|
|
inputStream.close();
|
|
}
|
|
catch (Exception exception) {}
|
|
return xElem;
|
|
}
|
|
|
|
protected XElem shallowCopy(XElem xElem) {
|
|
XElem xElem2 = new XElem(xElem.ns(), xElem.name());
|
|
int n = 0;
|
|
while (n < xElem.attrSize()) {
|
|
xElem2.addAttr(xElem.attrNs(n), xElem.attrName(n), xElem.attrValue(n));
|
|
++n;
|
|
}
|
|
return xElem2;
|
|
}
|
|
|
|
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());
|
|
}
|
|
}
|
|
|
|
protected BUnitDatabaseMerge() {
|
|
}
|
|
|
|
static {
|
|
Class clazz = class$com$tridium$install$BUnitDatabaseMerge;
|
|
if (clazz == null) {
|
|
clazz = class$com$tridium$install$BUnitDatabaseMerge = BUnitDatabaseMerge.class("[Lcom.tridium.install.BUnitDatabaseMerge;", false);
|
|
}
|
|
TYPE = Sys.loadType((Class)clazz);
|
|
}
|
|
|
|
public static class XmlReconciliationResults
|
|
implements BFileReconciler.ReconciliationResults {
|
|
public byte[] contents;
|
|
|
|
public InputStream getInputStream() {
|
|
return new ByteArrayInputStream(this.contents);
|
|
}
|
|
|
|
public long getSize() {
|
|
return this.contents.length;
|
|
}
|
|
|
|
public boolean shouldReplaceContents() {
|
|
return true;
|
|
}
|
|
|
|
public XmlReconciliationResults(XElem xElem) throws Exception {
|
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
XWriter xWriter = new XWriter((OutputStream)byteArrayOutputStream);
|
|
xElem.write(xWriter);
|
|
xWriter.flush();
|
|
this.contents = byteArrayOutputStream.toByteArray();
|
|
}
|
|
}
|
|
}
|
|
|