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.
*/
package com.tridium.sys.transfer;
import com.tridium.sys.transfer.CompToComp;
import com.tridium.sys.transfer.FileToFile;
import com.tridium.sys.transfer.TransferResult;
import java.io.OutputStream;
import javax.baja.file.BDirectory;
import javax.baja.file.BFileSpace;
import javax.baja.file.BIFile;
import javax.baja.io.ValueDocEncoder;
import javax.baja.space.BComponentSpace;
import javax.baja.util.BUnrestrictedFolder;
public class CompToBog
extends CompToComp {
String filename;
protected void name() throws Exception {
if (CompToBog.isDebugOn()) {
CompToBog.debug("CompToBog.name");
}
this.insertNames = (String[])this.suggestedNames.clone();
}
protected BComponentSpace getTargetSpace() {
return new BComponentSpace(null, null, null);
}
protected void insert() throws Exception {
if (CompToBog.isDebugOn()) {
CompToBog.debug("CompToBog.insert");
}
BDirectory bDirectory = (BDirectory)this.target;
BFileSpace bFileSpace = bDirectory.getFileSpace();
this.filename = FileToFile.getUniqueFilename(bDirectory, this.insertNames[0] + ".bog");
BIFile bIFile = bFileSpace.makeFile(bDirectory.getFilePath().merge(this.filename), this.getContext());
BUnrestrictedFolder bUnrestrictedFolder = new BUnrestrictedFolder();
int n = 0;
while (n < this.insertValues.length) {
bUnrestrictedFolder.add(this.insertNames[n], this.insertValues[n]);
++n;
}
OutputStream outputStream = bIFile.getOutputStream();
ValueDocEncoder valueDocEncoder = new ValueDocEncoder(outputStream);
valueDocEncoder.setZipped(true);
valueDocEncoder.encodeDocument(bUnrestrictedFolder);
valueDocEncoder.close();
}
public TransferResult makeResult() {
return new TransferResult(new String[]{this.filename}){
public final void undo() {
throw new UnsupportedOperationException();
}
};
}
}
@@ -0,0 +1,480 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.transfer;
import com.tridium.sys.schema.ComponentSlotMap;
import com.tridium.sys.transfer.CompTransferResult;
import com.tridium.sys.transfer.TransferListener;
import com.tridium.sys.transfer.TransferResult;
import com.tridium.sys.transfer.TransferStrategy;
import com.tridium.util.ObjectUtil;
import java.util.ArrayList;
import java.util.HashMap;
import javax.baja.naming.BOrd;
import javax.baja.space.BComponentSpace;
import javax.baja.sync.SyncBuffer;
import javax.baja.sync.Transaction;
import javax.baja.sys.BComplex;
import javax.baja.sys.BComponent;
import javax.baja.sys.BLink;
import javax.baja.sys.BObject;
import javax.baja.sys.BValue;
import javax.baja.sys.BasicContext;
import javax.baja.sys.Context;
import javax.baja.sys.CopyHints;
import javax.baja.sys.Property;
import javax.baja.sys.Slot;
import javax.baja.sys.SlotCursor;
import javax.baja.util.BFormat;
import javax.baja.util.BNameMap;
import javax.baja.util.BWsAnnotation;
public class CompToComp
extends TransferStrategy {
protected boolean sameSpace;
protected boolean sameParent;
protected boolean exact;
protected boolean copySource;
protected boolean keepAllLinks;
protected BComponent sourceParent;
protected BObject[] sourceValues;
protected String[] suggestedNames;
protected int sourceCount;
protected BWsAnnotation origin;
protected BFormat[] insertDisplayNames;
protected String[] insertNames;
protected BValue[] insertValues;
protected HashMap handleMap;
public TransferResult transfer() throws Exception {
this.init();
this.load();
this.name();
this.annotate();
this.remapHandles();
this.relink();
this.insert();
this.remove();
return this.makeResult();
}
public void init() {
this.sourceValues = this.mark.getValues();
this.suggestedNames = this.mark.getNames();
this.sourceCount = this.sourceValues.length;
this.origin = (BWsAnnotation)this.getParameter("origin", (BObject)null);
this.sourceParent = this.getSourceParent();
this.sameParent = this.isSameParent();
this.sameSpace = this.isSameSpace();
this.exact = this.getParameter("exact", this.isMove());
this.copySource = this.getParameter("copySource", true);
this.keepAllLinks = this.getParameter("keepAllLinks", false);
if (this.context == null) {
this.context = new BasicContext();
}
if (CompToComp.isDebugOn()) {
this.dump();
}
}
private final BComponent getSourceParent() {
int n = 0;
while (n < this.sourceValues.length) {
BObject bObject = this.sourceValues[n];
if (bObject.isComponent()) {
return (BComponent)bObject.asComponent().getParent();
}
++n;
}
return null;
}
private final boolean isSameParent() {
int n = 0;
while (n < this.sourceValues.length) {
BObject bObject = this.sourceValues[n];
if (bObject.isComponent() && bObject.asComponent().getParent() == this.target) {
return true;
}
++n;
}
return false;
}
private final boolean isSameSpace() {
if (this.sourceParent != null && this.target.isComponent()) {
boolean bl = false;
if (this.sourceParent.getSpace() == this.target.asComponent().getSpace()) {
bl = true;
}
return bl;
}
return false;
}
protected void load() throws Exception {
if (CompToComp.isDebugOn()) {
CompToComp.debug("load");
}
this.insertValues = new BValue[this.sourceCount];
System.arraycopy(this.sourceValues, 0, this.insertValues, 0, this.sourceCount);
if (this.copySource) {
TransferListenerCopyHints transferListenerCopyHints = new TransferListenerCopyHints();
transferListenerCopyHints.defaultOnClone = this.exact ^ true;
transferListenerCopyHints.swizzleHandles = true;
if (CompToComp.isDebugOn()) {
CompToComp.debug(" newCopy: " + transferListenerCopyHints);
}
this.insertValues = BValue.newCopy(this.insertValues, transferListenerCopyHints);
}
}
protected void name() throws Exception {
if (CompToComp.isDebugOn()) {
CompToComp.debug("name");
}
this.insertNames = (String[])this.suggestedNames.clone();
this.insertDisplayNames = new BFormat[this.sourceCount];
HashMap<String, String> hashMap = new HashMap<String, String>();
BComponent bComponent = this.target.asComponent();
BComponentSpace bComponentSpace = bComponent.getComponentSpace();
TargetNameContainer targetNameContainer = new TargetNameContainer(bComponent, hashMap);
int n = 0;
while (n < this.insertNames.length) {
BNameMap bNameMap;
BComplex bComplex;
BComplex bComplex2;
String string = this.insertNames[n];
string = (String)bComponentSpace.fw(111, string, targetNameContainer, null, null);
hashMap.put(string, string);
this.insertNames[n] = string;
if (this.sourceValues[n].isComplex() && (bComplex2 = (bComplex = (BComplex)this.sourceValues[n]).getParent()) != null && (bNameMap = (BNameMap)bComplex2.get("displayNames")) != null) {
this.insertDisplayNames[n] = bNameMap.get(bComplex.getName());
}
++n;
}
}
public static String getUniqueName(BComponent bComponent, String string) {
return ObjectUtil.generateUniqueSlotName(string, new TargetNameContainer(bComponent, new HashMap()));
}
protected void annotate() throws Exception {
if (CompToComp.isDebugOn()) {
CompToComp.debug("annotate");
}
if (this.origin != null) {
this.moveToOrigin();
} else if (this.sameParent) {
int n = 0;
while (n < this.sourceCount) {
this.stagger(this.insertValues[n], 1);
++n;
}
}
}
protected void moveToOrigin() {
BWsAnnotation bWsAnnotation = CompToComp.computeOrigin(this.sourceValues, this.sourceCount);
int n = this.origin.p - bWsAnnotation.p;
int n2 = this.origin.q - bWsAnnotation.q;
int n3 = 0;
int n4 = 0;
while (n4 < this.insertValues.length) {
BWsAnnotation bWsAnnotation2;
BComponent bComponent = (BComponent)this.insertValues[n4];
Property property = bComponent.getProperty("wsAnnotation");
if (property != null) {
bWsAnnotation2 = (BWsAnnotation)bComponent.get(property);
bComponent.set(property, (BValue)bWsAnnotation2.translate(n, n2));
} else {
bWsAnnotation2 = BWsAnnotation.make(this.origin.p + n3, this.origin.q + n3, 8);
n3 += 4;
bComponent.add("wsAnnotation", bWsAnnotation2);
}
++n4;
}
}
public static BWsAnnotation computeOrigin(BObject[] bObjectArray, int n) {
int n2 = Integer.MAX_VALUE;
int n3 = Integer.MAX_VALUE;
int n4 = 0;
while (n4 < n) {
BWsAnnotation bWsAnnotation = (BWsAnnotation)bObjectArray[n4].asComplex().get("wsAnnotation");
if (bWsAnnotation != null) {
n2 = Math.min(n2, bWsAnnotation.p);
n3 = Math.min(n3, bWsAnnotation.q);
}
++n4;
}
if (n2 == Integer.MAX_VALUE) {
n2 = 0;
}
if (n3 == Integer.MAX_VALUE) {
n3 = 0;
}
return BWsAnnotation.make(n2, n3);
}
protected void stagger(BObject bObject, int n) {
BComplex bComplex = (BComplex)bObject;
Property property = bComplex.getProperty("wsAnnotation");
if (property != null) {
BWsAnnotation bWsAnnotation = (BWsAnnotation)bComplex.get(property);
bComplex.set(property, (BValue)bWsAnnotation.translate(n, n));
}
}
protected void remapHandles() {
if (CompToComp.isDebugOn()) {
CompToComp.debug("remapHandles");
}
ArrayList arrayList = new ArrayList();
int n = 0;
while (n < this.insertValues.length) {
if (this.insertValues[n].isComponent()) {
this.listComponents(arrayList, this.insertValues[n].asComponent());
}
++n;
}
n = arrayList.size();
BComponentSpace bComponentSpace = this.getTargetSpace();
Object[] objectArray = (Object[])bComponentSpace.fw(103, new Integer(n), null, null, null);
this.handleMap = new HashMap();
int n2 = 0;
while (n2 < n) {
BComponent bComponent = (BComponent)arrayList.get(n2);
Object object = bComponent.getHandle();
Object object2 = objectArray[n2];
((ComponentSlotMap)bComponent.fw(1)).setHandle(object2);
if (object != null) {
if (CompToComp.isDebugOn()) {
CompToComp.debug(" " + object + " -> " + object2);
}
this.handleMap.put(object, object2);
}
++n2;
}
}
protected void listComponents(ArrayList arrayList, BComponent bComponent) {
arrayList.add(bComponent);
SlotCursor slotCursor = bComponent.getProperties();
while (slotCursor.nextComponent()) {
this.listComponents(arrayList, slotCursor.get().asComponent());
}
}
protected BComponentSpace getTargetSpace() {
return this.target.asComponent().getComponentSpace();
}
protected void relink() throws Exception {
if (CompToComp.isDebugOn()) {
CompToComp.debug("relink");
}
int n = 0;
while (n < this.sourceCount) {
if (this.insertValues[n] instanceof BComplex) {
this.relink((BComplex)this.insertValues[n]);
if (this.listener != null) {
this.updateStatus("Updating links \"" + CompToComp.toString(this.sourceValues[n]) + "\"...");
}
}
++n;
}
}
private final void relink(BComplex bComplex) {
BComplex bComplex2 = bComplex;
Property[] propertyArray = bComplex2.getPropertiesArray();
int n = 0;
while (n < propertyArray.length) {
Property property = propertyArray[n];
if (property.getTypeAccess() == 7) {
BValue bValue = bComplex2.get(property);
if (bValue instanceof BLink) {
this.relink((BLink)bValue);
} else if (bValue instanceof BOrd) {
BOrd bOrd = this.relink((BOrd)bValue);
if (bOrd != null) {
bComplex2.set(property, (BValue)bOrd);
}
} else if (bValue instanceof BComplex) {
this.relink((BComplex)bValue);
}
}
++n;
}
}
private final BOrd relink(BOrd bOrd) {
BOrd bOrd2;
String string = bOrd.toString();
if (!string.startsWith("h:")) {
if (CompToComp.isDebugOn()) {
CompToComp.debug(" ord not handle: " + bOrd);
}
return null;
}
String string2 = string.substring(2).trim();
Object v = this.handleMap.get(string2);
if (v == null) {
bOrd2 = BOrd.make("h:" + ComponentSlotMap.unswizzle(string2));
if (CompToComp.isDebugOn()) {
CompToComp.debug(" ord unswizzle: " + bOrd + " -> " + bOrd2);
}
} else {
bOrd2 = BOrd.make("h:" + v);
if (CompToComp.isDebugOn()) {
CompToComp.debug(" ord remap: " + bOrd + " -> " + bOrd2);
}
}
return bOrd2;
}
private final void relink(BLink bLink) {
String string = bLink.getSourceOrd().toString();
if (!string.startsWith("h:")) {
if (CompToComp.isDebugOn()) {
CompToComp.debug(" link not handle: " + string);
}
return;
}
String string2 = string.substring(2).trim();
Object v = this.handleMap.get(string2);
if (v == null) {
if (this.sameSpace && (this.exact || this.keepAllLinks)) {
BOrd bOrd = BOrd.make("h:" + ComponentSlotMap.unswizzle(string2));
if (CompToComp.isDebugOn()) {
CompToComp.debug(" link unsizzle: " + string + " -> " + bOrd);
}
bLink.setSourceOrd(bOrd);
} else {
if (CompToComp.isDebugOn()) {
CompToComp.debug(" link remove: " + string);
}
BComponent bComponent = (BComponent)bLink.getParent();
bComponent.remove(bLink.getPropertyInParent());
String string3 = bLink.getTargetSlotName();
Slot slot = bComponent.getSlot(string3);
if (slot instanceof Property) {
Property property = (Property)slot;
bComponent.set(property, property.getDefaultValue().newCopy());
}
}
} else {
BOrd bOrd = BOrd.make("h:" + v);
if (CompToComp.isDebugOn()) {
CompToComp.debug(" link remap: " + string + " -> " + bOrd);
}
bLink.setSourceOrd(bOrd);
}
}
protected void insert() throws Exception {
BComponent bComponent;
Context context;
if (CompToComp.isDebugOn()) {
CompToComp.debug("insert");
}
if ((context = Transaction.start(bComponent = this.target.asComponent(), this.context)) instanceof SyncBuffer) {
((SyncBuffer)((Object)context)).fw(this.listener);
}
if (CompToComp.isDebugOn()) {
CompToComp.debug(" tx: " + context.getClass().getName());
}
int n = 0;
while (n < this.insertValues.length) {
if (this.insertDisplayNames[n] != null) {
BNameMap bNameMap = (BNameMap)bComponent.get("displayNames");
if (bNameMap == null) {
bNameMap = BNameMap.make(BNameMap.NULL, this.insertNames[n], this.insertDisplayNames[n]);
bComponent.add("displayNames", bNameMap);
} else {
bNameMap = BNameMap.make(bNameMap, this.insertNames[n], this.insertDisplayNames[n]);
bComponent.set("displayNames", (BValue)bNameMap);
}
}
bComponent.add(this.insertNames[n], this.insertValues[n], context);
if (this.listener != null) {
this.updateStatus("Inserting \"" + CompToComp.toString(this.sourceValues[n]) + "\"...");
}
++n;
}
Transaction.end(bComponent, context);
}
protected void remove() throws Exception {
if (!this.isMove()) {
return;
}
if (CompToComp.isDebugOn()) {
CompToComp.debug("remove");
}
int n = 0;
while (n < this.sourceValues.length) {
BComplex bComplex = (BComplex)this.sourceValues[n];
BComplex bComplex2 = bComplex.getParent();
if (bComplex2 != null) {
bComplex2.asComponent().remove(bComplex.getPropertyInParent(), this.context);
}
++n;
}
}
protected TransferResult makeResult() throws Exception {
return new CompTransferResult(this.action, this.sourceParent, this.suggestedNames, (BComponent)this.target, this.insertNames);
}
public void dumpExtra() {
CompToComp.debug(" o source[" + this.sourceCount + "]:");
int n = 0;
while (n < this.sourceCount) {
CompToComp.debug(" " + this.suggestedNames[n] + ": " + this.sourceValues[n].toDebugString());
++n;
}
CompToComp.debug(" o sourceParent: " + this.sourceParent);
CompToComp.debug(" o sameParent: " + this.sameParent);
CompToComp.debug(" o exact: " + this.exact);
CompToComp.debug(" o copySource: " + this.copySource);
CompToComp.debug(" o origin: " + this.origin);
CompToComp.debug(" o exact: " + this.exact);
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
class TransferListenerCopyHints
extends CopyHints
implements TransferListener {
public void updateStatus(String string) {
CompToComp.this.updateStatus(string);
}
TransferListenerCopyHints() {
}
}
public static class TargetNameContainer
implements ObjectUtil.NameContainer {
BComponent target;
HashMap dups;
public boolean contains(String string) {
boolean bl = false;
if (this.target.asComponent().getSlot(string) != null || this.dups.get(string) != null) {
bl = true;
}
return bl;
}
public TargetNameContainer(BComponent bComponent, HashMap hashMap) {
this.target = bComponent;
this.dups = hashMap;
}
}
}
@@ -0,0 +1,74 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.transfer;
import com.tridium.sys.transfer.TransferResult;
import com.tridium.sys.transfer.TransferStrategy;
import javax.baja.space.Mark;
import javax.baja.sync.Transaction;
import javax.baja.sys.BComponent;
import javax.baja.sys.BObject;
import javax.baja.sys.BVector;
import javax.baja.sys.Context;
import javax.baja.sys.Property;
public class CompTransferResult
extends TransferResult {
public final int action;
public final BComponent origParent;
public final String[] origNames;
public final BComponent target;
public final String[] insertNames;
public void undo() throws Exception {
if (this.action == 16) {
this.undoCopy();
} else {
this.undoMove();
}
}
protected BComponent makeParams() {
return new BVector();
}
private final void undoCopy() throws Exception {
String[] stringArray = this.getInsertNames();
Context context = Transaction.start(this.target, null);
int n = 0;
while (n < stringArray.length) {
Property property = this.target.getProperty(stringArray[n]);
this.target.remove(property, context);
++n;
}
Transaction.end(this.target, context);
}
public void undoMove() throws Exception {
Mark mark = CompTransferResult.rebuildMark(this.target, this.insertNames, this.origNames);
TransferStrategy transferStrategy = TransferStrategy.make(32, mark, this.origParent, this.makeParams(), null);
transferStrategy.transfer();
}
static Mark rebuildMark(BComponent bComponent, String[] stringArray, String[] stringArray2) throws Exception {
bComponent.loadSlots();
BObject[] bObjectArray = new BObject[stringArray.length];
int n = 0;
while (n < bObjectArray.length) {
bObjectArray[n] = bComponent.get(stringArray[n]);
++n;
}
return new Mark(bObjectArray, stringArray2);
}
public CompTransferResult(int n, BComponent bComponent, String[] stringArray, BComponent bComponent2, String[] stringArray2) {
super(stringArray2);
this.action = n;
this.origParent = bComponent;
this.origNames = stringArray;
this.target = bComponent2;
this.insertNames = stringArray2;
}
}
@@ -0,0 +1,597 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.Array
* javax.baja.nre.util.TextUtil
*/
package com.tridium.sys.transfer;
import com.tridium.sys.transfer.TransferStrategy;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Iterator;
import javax.baja.io.ValueDocDecoder;
import javax.baja.io.ValueDocEncoder;
import javax.baja.naming.BOrd;
import javax.baja.nre.util.Array;
import javax.baja.nre.util.TextUtil;
import javax.baja.space.BComponentSpace;
import javax.baja.space.Mark;
import javax.baja.sync.Transaction;
import javax.baja.sys.BBoolean;
import javax.baja.sys.BComplex;
import javax.baja.sys.BComponent;
import javax.baja.sys.BFacets;
import javax.baja.sys.BLink;
import javax.baja.sys.BValue;
import javax.baja.sys.BajaRuntimeException;
import javax.baja.sys.BasicContext;
import javax.baja.sys.Context;
import javax.baja.sys.Knob;
import javax.baja.sys.Property;
import javax.baja.sys.Slot;
import javax.baja.sys.SlotCursor;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class DeleteOp {
static final int MAGIC_1 = 7649;
static final int MAGIC_2 = 11745;
static final char MAGIC_3 = '\u2de2';
static final BFacets noRemoveLinks = BFacets.make("niagaraRemoveLinks", BBoolean.FALSE);
protected BComponentSpace space;
protected Context context;
protected int size;
protected BOrd[] parentOrds;
protected String[] propNames;
protected BValue[] values;
protected int[] flags;
protected BFacets[] facets;
protected ExternalLink[] extLinks;
protected ExternalComposite[] extComposites;
static /* synthetic */ Class class$com$tridium$sys$transfer$DeleteOp$ExternalComposite;
static /* synthetic */ Class class$com$tridium$sys$transfer$DeleteOp$ExternalLink;
public static DeleteOp make(Mark mark, Context context) {
return new DeleteOp(mark, context);
}
public static DeleteOp make(BComponentSpace bComponentSpace, Context context, InputStream inputStream) throws Exception {
DeleteOp deleteOp = new DeleteOp();
deleteOp.space = bComponentSpace;
deleteOp.context = context;
deleteOp.read(inputStream);
return deleteOp;
}
public DeleteOp delete() {
return (DeleteOp)this.space.fw(106, this, null, null, null);
}
public DeleteOp undelete() {
return (DeleteOp)this.space.fw(107, this, null, null, null);
}
public DeleteOp doDelete() {
Process process = new Process();
process.resolveParents();
process.resolveProps();
process.save();
process.explode();
process.saveAndRemoveExternalLinks();
process.remove();
return this;
}
public DeleteOp doUndelete() {
Process process = new Process();
process.resolveParents();
process.add();
process.restoreExternalComposites();
process.restoreExternalLinks();
return this;
}
private final void read(InputStream inputStream) throws Exception {
Object object;
int n;
DataInputStream dataInputStream = new DataInputStream(inputStream);
if (dataInputStream.readInt() != 7649) {
throw new IOException("Invalid magic 1");
}
if (dataInputStream.readInt() != 1) {
throw new IOException("Invalid version");
}
this.size = dataInputStream.readInt();
this.parentOrds = new BOrd[this.size];
this.propNames = new String[this.size];
int n2 = 0;
while (n2 < this.size) {
this.parentOrds[n2] = BOrd.make(dataInputStream.readUTF());
this.propNames[n2] = dataInputStream.readUTF();
++n2;
}
if (dataInputStream.readBoolean()) {
n2 = dataInputStream.readInt();
this.extLinks = new ExternalLink[n2];
n = 0;
while (n < n2) {
String[] stringArray = TextUtil.split((String)dataInputStream.readUTF(), (char)'\n');
object = BOrd.make(stringArray[0]);
int n3 = 0;
if (stringArray.length >= 2) {
n3 = Integer.parseInt(stringArray[1], 16);
}
int n4 = n3;
BLink bLink = (BLink)ValueDocDecoder.unmarshal(dataInputStream.readUTF());
this.extLinks[n] = new ExternalLink((BOrd)object, bLink, n4);
++n;
}
}
dataInputStream.readUTF();
Class clazz = class$com$tridium$sys$transfer$DeleteOp$ExternalComposite;
if (clazz == null) {
clazz = class$com$tridium$sys$transfer$DeleteOp$ExternalComposite = DeleteOp.class("[Lcom.tridium.sys.transfer.DeleteOp$ExternalComposite;", false);
}
Array array = new Array(clazz);
n = dataInputStream.readInt();
int n5 = 0;
while (n5 < n) {
object = dataInputStream.readUTF();
if (((String)object).startsWith("c")) {
array.add((Object)new ExternalComposite().decode((String)object));
}
++n5;
}
this.extComposites = (ExternalComposite[])array.trim();
if (dataInputStream.readInt() != 11745) {
throw new IOException("Invalid magic 2");
}
if (dataInputStream.readBoolean()) {
this.flags = new int[this.size];
this.facets = new BFacets[this.size];
this.values = new BValue[this.size];
n5 = 0;
while (n5 < this.size) {
this.flags[n5] = dataInputStream.readInt();
this.facets[n5] = BFacets.make(dataInputStream.readUTF());
dataInputStream.readUTF();
++n5;
}
if (dataInputStream.readInt() != 11746) {
throw new IOException("Invalid magic 3");
}
ValueDocDecoder valueDocDecoder = new ValueDocDecoder(dataInputStream);
int n6 = 0;
while (n6 < this.size) {
valueDocDecoder.next();
this.values[n6] = valueDocDecoder.decode();
++n6;
}
}
}
public void write(OutputStream outputStream) throws Exception {
DataOutputStream dataOutputStream = new DataOutputStream(outputStream);
dataOutputStream.writeInt(7649);
dataOutputStream.writeInt(1);
dataOutputStream.writeInt(this.size);
int n = 0;
while (n < this.size) {
dataOutputStream.writeUTF(this.parentOrds[n].toString());
dataOutputStream.writeUTF(this.propNames[n]);
++n;
}
if (this.extLinks == null) {
dataOutputStream.writeBoolean(false);
} else {
dataOutputStream.writeBoolean(true);
dataOutputStream.writeInt(this.extLinks.length);
n = 0;
while (n < this.extLinks.length) {
dataOutputStream.writeUTF(this.extLinks[n].target.toString() + '\n' + Integer.toHexString(this.extLinks[n].flags));
dataOutputStream.writeUTF(ValueDocEncoder.marshal(this.extLinks[n].link));
++n;
}
}
dataOutputStream.writeUTF("");
if (this.extComposites == null) {
dataOutputStream.writeInt(0);
} else {
dataOutputStream.writeInt(this.extComposites.length);
n = 0;
while (n < this.extComposites.length) {
dataOutputStream.writeUTF(this.extComposites[n].encode());
++n;
}
}
dataOutputStream.writeInt(11745);
if (this.values == null) {
dataOutputStream.writeBoolean(false);
dataOutputStream.flush();
} else {
dataOutputStream.writeBoolean(true);
n = 0;
while (n < this.size) {
dataOutputStream.writeInt(this.flags[n]);
dataOutputStream.writeUTF(this.facets[n].encodeToString());
dataOutputStream.writeUTF("");
++n;
}
dataOutputStream.writeInt(11746);
dataOutputStream.flush();
ValueDocEncoder valueDocEncoder = new ValueDocEncoder(dataOutputStream);
valueDocEncoder.setEncodeTransients(true);
valueDocEncoder.setEncodeComments(false);
int n2 = 0;
while (n2 < this.size) {
valueDocEncoder.encode(this.values[n2]);
++n2;
}
valueDocEncoder.flush();
}
}
public void dump() {
PrintWriter printWriter = new PrintWriter(System.out);
this.dump(printWriter);
printWriter.flush();
}
public void dump(PrintWriter printWriter) {
printWriter.println("DeleteOp");
printWriter.println(" size=" + this.size);
printWriter.println(" items=");
int n = 0;
while (n < this.size) {
printWriter.println(" [" + n + "] " + this.parentOrds[n] + '/' + this.propNames[n]);
++n;
}
if (this.values != null) {
printWriter.println(" values=");
n = 0;
while (n < this.size) {
printWriter.println(" [" + n + "] " + this.values[n].toDebugString());
BComponent[] bComponentArray = ((BComponent)this.values[n]).getChildComponents();
int n2 = 0;
while (n2 < bComponentArray.length) {
if (bComponentArray[n2].getPropertyInParent().isDynamic()) {
printWriter.println(" " + bComponentArray[n2].getName() + ' ' + bComponentArray[n2].toDebugString());
}
++n2;
}
BLink[] bLinkArray = this.values[n].asComponent().getLinks();
int n3 = 0;
while (n3 < bLinkArray.length) {
printWriter.println(" " + bLinkArray[n3].getName() + ' ' + bLinkArray[n3]);
++n3;
}
++n;
}
}
if (this.extLinks != null) {
printWriter.println(" extLinks=");
n = 0;
while (n < this.extLinks.length) {
printWriter.println(" [" + n + "] " + this.extLinks[n]);
++n;
}
}
if (this.extComposites != null) {
printWriter.println(" extComposites=");
n = 0;
while (n < this.extComposites.length) {
printWriter.println(" [" + n + "] " + this.extComposites[n]);
++n;
}
}
}
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 DeleteOp() {
}
protected DeleteOp(Mark mark, Context context) {
this.space = (BComponentSpace)TransferStrategy.toSpace(mark);
this.context = context;
this.size = mark.size();
this.parentOrds = new BOrd[this.size];
this.propNames = new String[this.size];
int n = 0;
while (n < this.size) {
BComplex bComplex = (BComplex)mark.getValue(n);
BComponent bComponent = (BComponent)bComplex.getParent();
String string = bComplex.getPropertyInParent().getName();
this.parentOrds[n] = bComponent.getHandleOrd();
this.propNames[n] = string;
++n;
}
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class Process {
protected BComponent[] parents;
protected Property[] props;
protected HashMap byHandle;
public void resolveParents() {
this.parents = new BComponent[DeleteOp.this.size];
int n = 0;
while (n < DeleteOp.this.size) {
this.parents[n] = (BComponent)DeleteOp.this.parentOrds[n].get(DeleteOp.this.space);
++n;
}
}
public void resolveProps() {
this.props = new Property[DeleteOp.this.size];
int n = 0;
while (n < DeleteOp.this.size) {
this.props[n] = this.parents[n].getProperty(DeleteOp.this.propNames[n]);
if (this.props[n] == null) {
throw new IllegalStateException("Missing prop to delete: " + DeleteOp.this.parentOrds[n] + "::" + DeleteOp.this.propNames[n]);
}
++n;
}
}
public void save() {
DeleteOp.this.values = new BValue[DeleteOp.this.size];
DeleteOp.this.flags = new int[DeleteOp.this.size];
DeleteOp.this.facets = new BFacets[DeleteOp.this.size];
int n = 0;
while (n < DeleteOp.this.size) {
BComponent bComponent = this.parents[n];
Property property = this.props[n];
DeleteOp.this.values[n] = bComponent.get(property);
DeleteOp.this.flags[n] = property.getDefaultFlags();
DeleteOp.this.facets[n] = property.getFacets();
++n;
}
}
public void explode() {
this.byHandle = new HashMap();
int n = 0;
while (n < DeleteOp.this.size) {
if (DeleteOp.this.values[n] instanceof BComponent) {
this.explode((BComponent)DeleteOp.this.values[n]);
}
++n;
}
}
private final void explode(BComponent bComponent) {
this.byHandle.put(bComponent.getHandle(), bComponent);
SlotCursor slotCursor = bComponent.getProperties();
while (slotCursor.nextComponent()) {
this.explode((BComponent)slotCursor.get());
}
}
public void saveAndRemoveExternalLinks() {
Class clazz = class$com$tridium$sys$transfer$DeleteOp$ExternalLink;
if (clazz == null) {
clazz = class$com$tridium$sys$transfer$DeleteOp$ExternalLink = DeleteOp.class("[Lcom.tridium.sys.transfer.DeleteOp$ExternalLink;", false);
}
Array array = new Array(clazz);
Class clazz2 = class$com$tridium$sys$transfer$DeleteOp$ExternalComposite;
if (clazz2 == null) {
clazz2 = class$com$tridium$sys$transfer$DeleteOp$ExternalComposite = DeleteOp.class("[Lcom.tridium.sys.transfer.DeleteOp$ExternalComposite;", false);
}
Array array2 = new Array(clazz2);
Iterator iterator = this.byHandle.values().iterator();
while (iterator.hasNext()) {
this.saveAndRemoveExternalLinks((BComponent)iterator.next(), null, array, array2);
}
DeleteOp.this.extLinks = (ExternalLink[])array.trim();
DeleteOp.this.extComposites = (ExternalComposite[])array2.trim();
}
private final void saveAndRemoveExternalLinks(BComponent bComponent, Slot slot, Array array, Array array2) {
Slot slot2;
BComplex bComplex;
Object object;
BComplex bComplex2;
Knob[] knobArray = slot == null ? bComponent.getKnobs() : bComponent.getKnobs(slot);
int n = 0;
while (n < knobArray.length) {
Knob knob = knobArray[n];
bComplex2 = knob.getTargetComponent();
object = knob.getTargetSlot();
bComplex = knob.getLink();
if (bComplex == null) {
System.out.println("WARNING: Cannot save knob for undo: " + knob);
} else {
slot2 = bComplex.getPropertyInParent();
if (slot != null || this.byHandle.get(((BComponent)bComplex2).getHandle()) == null) {
boolean bl = false;
if (object.isDynamic() && (slot2.getDefaultFlags() & 0x1000) != 0 && (object.getDefaultFlags() & 0x1000) != 0) {
bl = true;
}
boolean bl2 = bl;
array.add((Object)new ExternalLink(((BComponent)bComplex2).getHandleOrd(), (BLink)bComplex.newCopy(), slot2.getDefaultFlags()));
((BComponent)bComplex2).remove((Property)slot2, DeleteOp.this.context);
if (bl2) {
this.removeCompositeSlot((BComponent)bComplex2, (Property)object, array, array2);
}
}
}
++n;
}
BLink[] bLinkArray = slot == null ? bComponent.getLinks() : bComponent.getLinks(slot);
int n2 = 0;
while (n2 < bLinkArray.length) {
bComplex2 = bLinkArray[n2];
object = null;
try {
object = ((BLink)bComplex2).getSourceComponent();
}
catch (Exception exception) {}
if (object == null) {
System.out.println("WARNING: Cannot save link for undo: " + bComplex2);
} else {
boolean bl;
bComplex = ((BLink)bComplex2).getTargetComponent();
slot2 = ((BLink)bComplex2).getSourceSlot();
Property property = bComplex2.getPropertyInParent();
boolean bl3 = false;
if (slot2.isDynamic() && (slot2.getDefaultFlags() & 0x1000) != 0 && (property.getDefaultFlags() & 0x1000) != 0) {
bl3 = true;
}
if ((bl = bl3) || slot != null) {
array.add((Object)new ExternalLink(((BComponent)bComplex).getHandleOrd(), (BLink)bComplex2.newCopy(), property.getDefaultFlags()));
((BComponent)bComplex).remove(property, DeleteOp.this.context);
}
if (bl) {
this.removeCompositeSlot((BComponent)object, (Property)slot2, array, array2);
}
}
++n2;
}
}
public void removeCompositeSlot(BComponent bComponent, Property property, Array array, Array array2) {
ExternalComposite externalComposite = new ExternalComposite();
externalComposite.composite = bComponent.getHandleOrd();
externalComposite.name = property.getName();
externalComposite.flags = property.getDefaultFlags();
externalComposite.facets = property.getFacets();
externalComposite.type = property.getType();
array2.add((Object)externalComposite);
this.saveAndRemoveExternalLinks(bComponent, property, array, array2);
bComponent.remove(property, DeleteOp.this.context);
}
public void remove() {
BasicContext basicContext = new BasicContext(DeleteOp.this.context, noRemoveLinks);
int n = 0;
while (n < DeleteOp.this.size) {
this.parents[n].remove(this.props[n], (Context)basicContext);
++n;
}
}
public void add() {
try {
Transaction transaction = DeleteOp.this.space.newTransaction(DeleteOp.this.context);
int n = 0;
while (n < DeleteOp.this.size) {
BComponent bComponent = this.parents[n];
String string = DeleteOp.this.propNames[n];
BValue bValue = DeleteOp.this.values[n];
int n2 = DeleteOp.this.flags[n];
BFacets bFacets = DeleteOp.this.facets[n];
bComponent.add(string, bValue, n2, bFacets, transaction);
++n;
}
transaction.commit(DeleteOp.this.context);
}
catch (Exception exception) {
throw new BajaRuntimeException(exception);
}
}
public void restoreExternalComposites() {
int n = 0;
while (n < DeleteOp.this.extComposites.length) {
try {
ExternalComposite externalComposite = DeleteOp.this.extComposites[n];
BComponent bComponent = (BComponent)externalComposite.composite.get(DeleteOp.this.space);
BValue bValue = (BValue)externalComposite.type.getInstance();
bComponent.add(externalComposite.name, bValue, externalComposite.flags, externalComposite.facets);
}
catch (Exception exception) {
exception.printStackTrace();
}
++n;
}
}
public void restoreExternalLinks() {
int n = 0;
while (n < DeleteOp.this.extLinks.length) {
BOrd bOrd = DeleteOp.this.extLinks[n].target;
BLink bLink = DeleteOp.this.extLinks[n].link;
int n2 = DeleteOp.this.extLinks[n].flags;
try {
BComponent bComponent = (BComponent)bOrd.get(DeleteOp.this.space);
bComponent.add(null, (BValue)bLink, n2);
}
catch (Exception exception) {
exception.printStackTrace();
}
++n;
}
}
}
static class ExternalLink {
BOrd target;
BLink link;
int flags;
public String toString() {
return "" + this.target + ' ' + this.link;
}
ExternalLink(BOrd bOrd, BLink bLink, int n) {
this.target = bOrd;
this.link = bLink;
this.flags = n;
}
}
static class ExternalComposite {
BOrd composite;
String name;
int flags;
BFacets facets;
Type type;
public String toString() {
return this.composite + ' ' + this.name + ' ' + Integer.toHexString(this.flags) + ' ' + this.facets + ' ' + this.type;
}
String encode() throws IOException {
return "c\n" + this.composite.encodeToString() + '\n' + this.name + '\n' + Integer.toHexString(this.flags) + '\n' + this.facets.encodeToString() + '\n' + this.type.toString();
}
ExternalComposite decode(String string) throws IOException {
String[] stringArray = TextUtil.split((String)string, (char)'\n');
this.composite = BOrd.make(stringArray[1]);
this.name = stringArray[2];
this.flags = Integer.parseInt(stringArray[3], 16);
this.facets = BFacets.make(stringArray[4]);
this.type = Sys.getType(stringArray[5]);
return this;
}
ExternalComposite() {
}
}
}
@@ -0,0 +1,53 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.transfer;
import com.tridium.sys.transfer.CompToComp;
import com.tridium.sys.transfer.TransferResult;
import java.util.ArrayList;
import java.util.HashMap;
import javax.baja.file.BIComponentFile;
import javax.baja.space.Mark;
import javax.baja.sys.BObject;
public class FileToComp
extends CompToComp {
public TransferResult transfer() throws Exception {
this.mark = this.filesToCompMark();
return super.transfer();
}
private final Mark filesToCompMark() throws Exception {
BObject[] bObjectArray = this.mark.getValues();
ArrayList<String> arrayList = new ArrayList<String>();
ArrayList<BObject> arrayList2 = new ArrayList<BObject>();
HashMap<Object, Object> hashMap = new HashMap<Object, Object>(bObjectArray.length * 2);
int n = 0;
while (n < bObjectArray.length) {
if (bObjectArray[n] instanceof BIComponentFile) {
Mark mark = ((BIComponentFile)((Object)bObjectArray[n])).readComponents();
BObject[] bObjectArray2 = mark.getValues();
String[] stringArray = mark.getNames();
int n2 = 0;
while (n2 < bObjectArray2.length) {
Object object;
arrayList.add(stringArray[n2]);
arrayList2.add(bObjectArray2[n2]);
if (bObjectArray2[n2].isComponent() && (object = bObjectArray2[n2].asComponent().getHandle()) != null) {
if (hashMap.containsKey(object)) {
throw new Exception("Duplicate handles found in files, must transfer to component individually");
}
hashMap.put(object, object);
}
++n2;
}
} else {
throw new Exception("Only IComponentFiles files may be transfered to a component");
}
++n;
}
return new Mark(arrayList2.toArray(new BObject[arrayList2.size()]), arrayList.toArray(new String[arrayList.size()]));
}
}
@@ -0,0 +1,266 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.transfer;
import com.tridium.sys.transfer.TransferResult;
import com.tridium.sys.transfer.TransferStrategy;
import com.tridium.util.ObjectUtil;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import javax.baja.file.BAbstractFile;
import javax.baja.file.BDirectory;
import javax.baja.file.BFileSpace;
import javax.baja.file.BIFile;
import javax.baja.file.FilePath;
import javax.baja.file.FileUtil;
import javax.baja.sys.BObject;
import javax.baja.util.Lexicon;
public class FileToFile
extends TransferStrategy {
BIFile[] sourceFiles;
BDirectory targetDir;
String[] insertNames;
Lexicon lex;
String lexCopying;
String lexMoving;
String lexDeleting;
public TransferResult transfer() throws Exception {
this.init();
this.name();
this.copy();
this.remove();
return this.makeResult();
}
protected void init() throws Exception {
if (FileToFile.isDebugOn()) {
FileToFile.debug("init");
}
this.targetDir = (BDirectory)this.target;
BObject[] bObjectArray = this.mark.getValues();
this.sourceFiles = new BIFile[bObjectArray.length];
int n = 0;
while (n < bObjectArray.length) {
BIFile bIFile;
this.sourceFiles[n] = bIFile = (BIFile)((Object)bObjectArray[n]);
if (bIFile == this.targetDir) {
throw new IllegalStateException("Source == destination: " + this.targetDir.getFilePath());
}
++n;
}
this.lex = Lexicon.make("baja", this.context);
this.lexCopying = this.lex.getText("file.copying");
this.lexMoving = this.lex.getText("file.moving");
this.lexDeleting = this.lex.getText("file.deleting");
}
protected void name() throws Exception {
if (FileToFile.isDebugOn()) {
FileToFile.debug("name");
}
HashMap hashMap = FileToFile.namesToHashMap(this.targetDir);
String[] stringArray = this.mark.getNames();
this.insertNames = new String[stringArray.length];
int n = 0;
while (n < this.insertNames.length) {
this.insertNames[n] = FileToFile.getUniqueFilename(hashMap, stringArray[n]);
if (FileToFile.isDebugOn()) {
FileToFile.debug(" " + stringArray[n] + " -> " + this.insertNames[n]);
}
hashMap.put(this.insertNames[n], "x");
++n;
}
}
public static HashMap namesToHashMap(BDirectory bDirectory) {
HashMap<String, String> hashMap = new HashMap<String, String>();
BIFile[] bIFileArray = bDirectory.listFiles();
int n = 0;
while (n < bIFileArray.length) {
hashMap.put(bIFileArray[n].getFileName(), "x");
++n;
}
return hashMap;
}
public static String getUniqueFilename(BDirectory bDirectory, String string) {
return FileToFile.getUniqueFilename(FileToFile.namesToHashMap(bDirectory), string);
}
public static boolean isUniqueFilename(BDirectory bDirectory, String string) {
boolean bl = false;
if (FileToFile.namesToHashMap(bDirectory).get(string) == null) {
bl = true;
}
return bl;
}
public static String getUniqueFilename(HashMap hashMap, String string) {
if (!hashMap.containsKey(string)) {
return string;
}
String string2 = "";
int n = string.lastIndexOf(46);
if (n > 0) {
string2 = string.substring(n);
string = string.substring(0, n);
}
String string3 = ObjectUtil.generateUniqueName(string, new MapNameContainer(hashMap, string2));
return string3 + string2;
}
protected void copy() throws Exception {
if (FileToFile.isDebugOn()) {
FileToFile.debug("copy");
}
int n = 0;
while (n < this.sourceFiles.length) {
this.copy(this.sourceFiles[n], this.targetDir, this.insertNames[n]);
++n;
}
}
private final void copy(BIFile bIFile, BDirectory bDirectory, String string) throws Exception {
if (bIFile instanceof BDirectory) {
this.copyDir((BDirectory)bIFile, bDirectory, string);
} else {
this.copyFile(bIFile, bDirectory, string);
}
}
private final void copyDir(BDirectory bDirectory, BDirectory bDirectory2, String string) throws Exception {
if (FileToFile.isDebugOn()) {
FileToFile.debug(" copyDir: " + bDirectory.getFilePath());
}
BFileSpace bFileSpace = bDirectory2.getFileSpace();
BDirectory bDirectory3 = bFileSpace.makeDir(bDirectory2.getFilePath().merge(string), this.getContext());
BIFile[] bIFileArray = bDirectory.listFiles();
int n = 0;
while (n < bIFileArray.length) {
this.copy(bIFileArray[n], bDirectory3, bIFileArray[n].getFileName());
++n;
}
bDirectory3.setLastModified(bDirectory.getLastModified());
}
/*
* WARNING - Removed back jump from a try to a catch block - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
private final void copyFile(BIFile bIFile, BDirectory bDirectory, String string) throws Exception {
BIFile bIFile2;
block18: {
block19: {
if (FileToFile.isDebugOn()) {
FileToFile.debug(" copyFile: " + bIFile.getFilePath());
FileToFile.debug(" isMove: " + this.isMove());
FileToFile.debug(" dest: " + bDirectory);
}
if (bDirectory.toString(null).equals("file:!trash") || bDirectory.toString(null).startsWith("file:!trash/")) {
this.updateStatus(this.lexDeleting + " \"" + string + "\"...");
} else if (this.isMove()) {
this.updateStatus(this.lexMoving + " \"" + string + "\"...");
} else {
this.updateStatus(this.lexCopying + " \"" + string + "\"...");
}
BFileSpace bFileSpace = bDirectory.getFileSpace();
bIFile2 = bFileSpace.makeFile(bDirectory.getFilePath().merge(string), this.getContext());
if (!bIFile.getExtension().equalsIgnoreCase("bog")) break block19;
InputStream inputStream = null;
OutputStream outputStream = null;
try {
inputStream = bIFile.getInputStream();
outputStream = bIFile2.getOutputStream();
FileUtil.pipe(inputStream, outputStream);
}
catch (Throwable throwable) {
Object var9_9 = null;
try {
if (inputStream != null) {
inputStream.close();
}
}
catch (Exception exception) {}
try {
if (outputStream == null) throw throwable;
outputStream.close();
throw throwable;
}
catch (Exception exception) {}
throw throwable;
}
{
Object var9_10 = null;
try {}
catch (Exception exception) {}
if (inputStream != null) {
inputStream.close();
}
try {}
catch (Exception exception) {}
if (outputStream != null) {
outputStream.close();
}
break block18;
}
break block18;
}
FileUtil.pipe(bIFile, bIFile2);
}
if (!(bIFile2 instanceof BAbstractFile)) return;
((BAbstractFile)bIFile2).setLastModified(bIFile.getLastModified());
}
protected void remove() throws Exception {
if (!this.isMove()) {
return;
}
if (FileToFile.isDebugOn()) {
FileToFile.debug("remove");
}
int n = 0;
while (n < this.sourceFiles.length) {
BIFile bIFile = this.sourceFiles[n];
BFileSpace bFileSpace = bIFile.getFileSpace();
FilePath filePath = bIFile.getFilePath();
if (this.targetDir.toString(null).startsWith("file:!trash")) {
this.updateStatus(this.lexDeleting + " \"" + filePath.getName() + "\"...");
} else {
this.updateStatus(this.lexMoving + " \"" + filePath.getName() + "\"...");
}
bFileSpace.delete(filePath, this.getContext());
++n;
}
}
protected TransferResult makeResult() throws Exception {
return null;
}
static class MapNameContainer
implements ObjectUtil.NameContainer {
Map map;
String ext;
public boolean contains(String string) {
boolean bl = false;
if (this.map.get(string + this.ext) != null) {
bl = true;
}
return bl;
}
MapNameContainer(Map map, String string) {
this.map = map;
this.ext = string;
}
}
}
@@ -0,0 +1,95 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.transfer;
import com.tridium.sys.engine.EngineUtil;
import com.tridium.sys.schema.ComponentSlotMap;
import com.tridium.sys.transfer.CompToComp;
import com.tridium.sys.transfer.TransferResult;
import javax.baja.sync.Transaction;
import javax.baja.sys.BBoolean;
import javax.baja.sys.BComplex;
import javax.baja.sys.BComponent;
import javax.baja.sys.BFacets;
import javax.baja.sys.BObject;
import javax.baja.sys.BValue;
import javax.baja.sys.BasicContext;
import javax.baja.sys.Context;
import javax.baja.sys.LocalizableException;
import javax.baja.sys.Property;
import javax.baja.sys.Slot;
public class IntraCompSpaceMove
extends CompToComp {
public TransferResult transfer() throws Exception {
this.init();
this.copySource = false;
this.load();
this.name();
this.annotate();
this.move();
this.reactiveLinks();
return this.makeResult();
}
protected void move() throws Exception {
Object object;
BComponent bComponent = this.sourceParent;
BComponent bComponent2 = this.target.asComponent();
BObject[] bObjectArray = this.sourceValues;
int n = this.sourceValues.length;
int[] nArray = new int[n];
Property[] propertyArray = new Property[n];
int n2 = 0;
while (n2 < n) {
if (!bObjectArray[n2].isComplex()) {
throw new LocalizableException("baja", "CannotMoveSimples");
}
BComplex bComplex = (BComplex)bObjectArray[n2];
object = bComplex.getPropertyInParent();
if (object.isFrozen()) {
throw new LocalizableException("baja", "CannotMoveFrozen", new Object[]{bComplex.getDisplayName((Slot)object, this.context)});
}
propertyArray[n2] = object;
nArray[n2] = bComponent.getFlags((Slot)object);
++n2;
}
String string = bComponent2.getSlotPath().toString();
int n3 = 0;
while (n3 < n) {
if (bObjectArray[n3].isComponent() && (string.equals(object = bObjectArray[n3].asComponent().getSlotPath().toString()) || string.startsWith((String)object + '/'))) {
throw new LocalizableException("baja", "CannotMoveUnderSelf");
}
++n3;
}
ComponentSlotMap componentSlotMap = (ComponentSlotMap)bComponent2.fw(1);
int n4 = 0;
while (n4 < n) {
componentSlotMap.checkAdd(this.insertNames[n4], nArray[n4], (BValue)bObjectArray[n4], BFacets.NULL, this.context);
++n4;
}
BasicContext basicContext = new BasicContext(this.context, BFacets.make("niagaraRemoveLinks", BBoolean.FALSE));
Context context = Transaction.start(bComponent, basicContext);
int n5 = 0;
while (n5 < n) {
bComponent.remove(propertyArray[n5], context);
++n5;
}
Transaction.end(bComponent, context);
context = Transaction.start(bComponent2, this.context);
n5 = 0;
while (n5 < n) {
bComponent2.add(this.insertNames[n5], (BComplex)bObjectArray[n5], nArray[n5], context);
++n5;
}
Transaction.end(bComponent2, context);
}
protected void reactiveLinks() {
BComponent bComponent = this.target.asComponent();
BComponent bComponent2 = bComponent.getComponentSpace().getRootComponent();
EngineUtil.activateLinks(bComponent2);
}
}
@@ -0,0 +1,45 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.transfer;
import com.tridium.sys.transfer.FileToFile;
import com.tridium.sys.transfer.TransferResult;
import javax.baja.file.BFileSpace;
import javax.baja.file.BIFile;
import javax.baja.file.FilePath;
public class IntraFileSpaceMove
extends FileToFile {
public TransferResult transfer() throws Exception {
this.init();
this.name();
this.move();
return null;
}
public void move() throws Exception {
if (IntraFileSpaceMove.isDebugOn()) {
IntraFileSpaceMove.debug("IntraFileSpaceMove.move");
}
BFileSpace bFileSpace = this.targetDir.getFileSpace();
FilePath filePath = this.targetDir.getFilePath();
int n = 0;
while (n < this.sourceFiles.length) {
BIFile bIFile = this.sourceFiles[n];
FilePath filePath2 = bIFile.getFilePath();
FilePath filePath3 = filePath.merge(this.insertNames[n]);
if (IntraFileSpaceMove.isDebugOn()) {
IntraFileSpaceMove.debug(" " + filePath2 + " -> " + filePath3);
}
if (this.targetDir.toString(null).equals("file:!trash ") || this.targetDir.toString(null).startsWith("file:!trash/")) {
this.updateStatus(this.lexDeleting + " \"" + filePath2.getName() + "\"...");
} else {
this.updateStatus(this.lexMoving + " \"" + filePath2.getName() + "\"...");
}
bFileSpace.move(filePath2, filePath3, this.getContext());
++n;
}
}
}
@@ -0,0 +1,19 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.transfer;
import com.tridium.sys.transfer.RemoteTransferSpace;
import com.tridium.sys.transfer.TransferResult;
import com.tridium.sys.transfer.TransferStrategy;
import javax.baja.space.BISpaceNode;
import javax.baja.space.BSpace;
public class RemoteIntraSpace
extends TransferStrategy {
public TransferResult transfer() throws Exception {
BSpace bSpace = ((BISpaceNode)((Object)this.target)).getSpace();
return ((RemoteTransferSpace)((Object)bSpace)).transfer(this);
}
}
@@ -0,0 +1,12 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.transfer;
import com.tridium.sys.transfer.TransferResult;
import com.tridium.sys.transfer.TransferStrategy;
public interface RemoteTransferSpace {
public TransferResult transfer(TransferStrategy var1) throws Exception;
}
@@ -0,0 +1,9 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.transfer;
public interface TransferListener {
public void updateStatus(String var1);
}
@@ -0,0 +1,19 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.transfer;
public abstract class TransferResult {
private String[] insertNames;
public String[] getInsertNames() {
return this.insertNames;
}
public abstract void undo() throws Exception;
public TransferResult(String[] stringArray) {
this.insertNames = stringArray;
}
}
@@ -0,0 +1,342 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.transfer;
import com.tridium.space.BGateway;
import com.tridium.sys.transfer.CompToBog;
import com.tridium.sys.transfer.CompToComp;
import com.tridium.sys.transfer.FileToComp;
import com.tridium.sys.transfer.FileToFile;
import com.tridium.sys.transfer.IntraFileSpaceMove;
import com.tridium.sys.transfer.RemoteIntraSpace;
import com.tridium.sys.transfer.RemoteTransferSpace;
import com.tridium.sys.transfer.TransferListener;
import com.tridium.sys.transfer.TransferResult;
import javax.baja.file.BDirectory;
import javax.baja.file.BFileSpace;
import javax.baja.file.BIFile;
import javax.baja.file.FilePath;
import javax.baja.log.Log;
import javax.baja.naming.BOrd;
import javax.baja.space.BComponentSpace;
import javax.baja.space.BISpaceNode;
import javax.baja.space.BSpace;
import javax.baja.space.Mark;
import javax.baja.sys.BBoolean;
import javax.baja.sys.BComponent;
import javax.baja.sys.BInteger;
import javax.baja.sys.BObject;
import javax.baja.sys.BString;
import javax.baja.sys.BValue;
import javax.baja.sys.Context;
import javax.baja.sys.Property;
import javax.baja.virtual.BVirtualGateway;
public abstract class TransferStrategy {
public static final int ACTION_COPY = 16;
public static final int ACTION_MOVE = 32;
public static final String PARAM_EXACT = "exact";
public static final String PARAM_ORIGIN = "origin";
public static final String PARAM_COPY_SOURCE = "copySource";
public static final String PARAM_KEEP_ALL_LINKS = "keepAllLinks";
public static final Log log = Log.getLog("sys.transfer");
int action;
BObject target;
Mark mark;
Context context;
BComponent params;
TransferListener listener;
public static TransferStrategy make(int n, Mark mark, BObject bObject, BComponent bComponent, Context context) {
Object object;
if (TransferStrategy.isDebugOn()) {
TransferStrategy.debug("====== TransferStrategy.make ======");
TransferStrategy.debug(" action = " + n);
TransferStrategy.debug(" mark = " + mark);
TransferStrategy.debug(" target = " + bObject);
TransferStrategy.debug(" params = " + bComponent);
TransferStrategy.debug(" context = " + context);
}
bObject = TransferStrategy.toActualTarget(bObject);
if (mark.getValues().length == 1) {
object = mark.getNames()[0];
BObject bObject2 = mark.getValues()[0];
if (bObject2 instanceof BComponentSpace) {
BComponent bComponent2 = ((BComponentSpace)bObject2).getRootComponent();
mark = new Mark(bComponent2, (String)object);
}
}
if ((object = TransferStrategy.makeImpl(n, mark, bObject, context)) == null) {
return null;
}
if (TransferStrategy.isDebugOn()) {
TransferStrategy.debug(" class = " + object.getClass().getName());
}
((TransferStrategy)object).action = n;
((TransferStrategy)object).mark = mark;
((TransferStrategy)object).target = bObject;
((TransferStrategy)object).params = bComponent;
((TransferStrategy)object).context = context;
return object;
}
public static BObject toActualTarget(BObject bObject) {
BComponent bComponent;
BComponentSpace bComponentSpace;
if (bObject instanceof BGateway) {
bObject = ((BGateway)bObject).getGatewaySpace();
}
if (bObject instanceof BComponentSpace) {
return ((BComponentSpace)bObject).getRootComponent();
}
if (bObject.getType().getTypeName().equals("FoxFileSpace")) {
return (BObject)((Object)((BFileSpace)bObject).resolveFile(new FilePath("^")));
}
if (bObject.getType().getTypeName().equals("BogFile")) {
return BOrd.make("bog:|slot:/").get(bObject);
}
if (bObject.getType().getTypeName().equals("SaxFile")) {
return BOrd.make("sax:|slot:/").get(bObject);
}
if (bObject instanceof BVirtualGateway && (bComponentSpace = ((BVirtualGateway)bObject).getVirtualSpace()) != null && (bComponent = bComponentSpace.getRootComponent()) != null) {
bComponent.loadSlots();
return bComponent;
}
return bObject;
}
static TransferStrategy makeImpl(int n, Mark mark, BObject bObject, Context context) {
if (bObject instanceof BComponent) {
return TransferStrategy.toComp(n, mark, (BComponent)bObject, context);
}
if (bObject instanceof BIFile) {
return TransferStrategy.toFile(n, mark, (BIFile)((Object)bObject), context);
}
return null;
}
static TransferStrategy toComp(int n, Mark mark, BComponent bComponent, Context context) {
BComponentSpace bComponentSpace;
BSpace bSpace = TransferStrategy.toSpace(mark);
if (bSpace == (bComponentSpace = bComponent.getComponentSpace())) {
if (bComponentSpace instanceof RemoteTransferSpace) {
return new RemoteIntraSpace();
}
if (n == 32) {
return (TransferStrategy)bSpace.fw(113);
}
}
TransferStrategy transferStrategy = null;
if (bSpace == null) {
transferStrategy = new CompToComp();
} else if (bSpace instanceof BComponentSpace) {
transferStrategy = (TransferStrategy)bSpace.fw(114);
if (transferStrategy == null) {
transferStrategy = new CompToComp();
}
} else if (bSpace instanceof BFileSpace && (transferStrategy = (TransferStrategy)bSpace.fw(115)) == null) {
transferStrategy = new FileToComp();
}
return transferStrategy;
}
static TransferStrategy toFile(int n, Mark mark, BIFile bIFile, Context context) {
BSpace bSpace = TransferStrategy.toSpace(mark);
if (bSpace instanceof BFileSpace) {
return TransferStrategy.fileToFile(n, mark, bIFile, context);
}
if (bSpace instanceof BComponentSpace) {
return TransferStrategy.componentToFile(n, mark, bIFile, context);
}
return null;
}
static TransferStrategy fileToFile(int n, Mark mark, BIFile bIFile, Context context) {
BFileSpace bFileSpace;
BFileSpace bFileSpace2 = (BFileSpace)TransferStrategy.toSpace(mark);
if (bFileSpace2 == (bFileSpace = bIFile.getFileSpace())) {
if (bFileSpace instanceof RemoteTransferSpace) {
return new RemoteIntraSpace();
}
BObject[] bObjectArray = mark.getValues();
boolean bl = false;
int n2 = 0;
while (n2 < bObjectArray.length && !bl) {
if (bObjectArray[n2] instanceof BIFile && ((BIFile)((Object)bObjectArray[n2])).isDirectory()) {
bl = true;
}
++n2;
}
if (n == 32 && !bl) {
return new IntraFileSpaceMove();
}
}
return new FileToFile();
}
static TransferStrategy componentToFile(int n, Mark mark, BIFile bIFile, Context context) {
if (bIFile instanceof BDirectory) {
return new CompToBog();
}
return null;
}
public int getAction() {
return this.action;
}
public boolean isCopy() {
boolean bl = false;
if (this.action == 16) {
bl = true;
}
return bl;
}
public boolean isMove() {
boolean bl = false;
if (this.action == 32) {
bl = true;
}
return bl;
}
public Mark getMark() {
return this.mark;
}
public BObject getTarget() {
return this.target;
}
public Context getContext() {
return this.context;
}
public abstract TransferResult transfer() throws Exception;
public BComponent getParameters() {
return this.params;
}
public BObject getParameter(String string, BObject bObject) {
if (this.params == null) {
return bObject;
}
BValue bValue = this.params.get(string);
if (bValue != null) {
return bValue;
}
return bObject;
}
public boolean getParameter(String string, boolean bl) {
if (this.params == null) {
return bl;
}
BBoolean bBoolean = (BBoolean)this.params.get(string);
if (bBoolean != null) {
return bBoolean.getBoolean();
}
return bl;
}
public int getParameter(String string, int n) {
if (this.params == null) {
return n;
}
BInteger bInteger = (BInteger)this.params.get(string);
if (bInteger != null) {
return bInteger.getInt();
}
return n;
}
public String getParameter(String string, String string2) {
if (this.params == null) {
return string2;
}
BString bString = (BString)this.params.get(string);
if (bString != null) {
return bString.getString();
}
return string2;
}
public TransferListener getListener() {
return this.listener;
}
public void setListener(TransferListener transferListener) {
this.listener = transferListener;
}
public void updateStatus(String string) {
try {
if (this.listener != null) {
this.listener.updateStatus(string);
}
}
catch (Exception exception) {
exception.printStackTrace();
}
}
public static String toString(BObject bObject) {
try {
BComponent bComponent;
if (bObject instanceof BComponent && (bComponent = (BComponent)bObject).isMounted()) {
return bComponent.toPathString();
}
return bObject.getType().toString();
}
catch (Exception exception) {
return "error";
}
}
public static BSpace toSpace(Mark mark) {
return TransferStrategy.toSpace(mark.getValues()[0]);
}
public static BSpace toSpace(BObject bObject) {
if (bObject instanceof BISpaceNode) {
return ((BISpaceNode)((Object)bObject)).getSpace();
}
return null;
}
public static boolean isDebugOn() {
return log.isTraceOn();
}
public static void debug(String string) {
System.out.print("> ");
System.out.println(string);
}
public void dump() {
TransferStrategy.debug("Transfer: " + this.getClass().getName());
TransferStrategy.debug(" o action: " + (this.isMove() ? "move" : "copy"));
TransferStrategy.debug(" o target: " + this.target);
TransferStrategy.debug(" o mark: " + this.mark);
TransferStrategy.debug(" o context: " + this.context);
this.dumpExtra();
if (this.params == null) {
TransferStrategy.debug(" o params: null");
} else {
TransferStrategy.debug(" o params:");
Property[] propertyArray = this.params.getPropertiesArray();
int n = 0;
while (n < propertyArray.length) {
TransferStrategy.debug(" " + propertyArray[n].getName() + " = " + this.params.get(propertyArray[n]));
++n;
}
}
}
protected void dumpExtra() {
}
}