/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.tridium.data.BToDataTable * com.tridium.data.DataTableDecoder * com.tridium.data.DataTableEncoder * javax.baja.collection.BICollection * javax.baja.collection.BITable * javax.baja.data.BIDataTable * javax.baja.data.BIDataValue * javax.baja.naming.BOrd * javax.baja.naming.UnresolvedException * javax.baja.sys.BObject * javax.baja.sys.Context * javax.baja.sys.Sys * javax.baja.sys.Type * javax.baja.util.BTypeSpec */ package com.tridium.fox.sys.data; import com.tridium.data.BToDataTable; import com.tridium.data.DataTableDecoder; import com.tridium.data.DataTableEncoder; import com.tridium.fox.message.FoxMessage; import com.tridium.fox.session.Fox; import com.tridium.fox.session.FoxCircuit; import com.tridium.fox.session.FoxRequest; import com.tridium.fox.session.FoxResponse; import com.tridium.fox.session.InvalidCommandException; import com.tridium.fox.sys.BFoxChannel; import java.io.DataInput; import java.io.DataInputStream; import java.io.DataOutput; import java.io.DataOutputStream; import java.io.FilterOutputStream; import javax.baja.collection.BICollection; import javax.baja.collection.BITable; import javax.baja.data.BIDataTable; import javax.baja.data.BIDataValue; import javax.baja.naming.BOrd; import javax.baja.naming.UnresolvedException; import javax.baja.sys.BObject; import javax.baja.sys.Context; import javax.baja.sys.Sys; import javax.baja.sys.Type; import javax.baja.util.BTypeSpec; public class BDataChannel extends BFoxChannel { public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$fox$sys$data$BDataChannel == null ? (class$com$tridium$fox$sys$data$BDataChannel = BDataChannel.class$("com.tridium.fox.sys.data.BDataChannel")) : class$com$tridium$fox$sys$data$BDataChannel)); static /* synthetic */ Class class$com$tridium$fox$sys$data$BDataChannel; public Type getType() { return TYPE; } public BDataChannel() { super("data"); } public FoxResponse process(FoxRequest foxRequest) throws Exception { String string = foxRequest.command; throw new InvalidCommandException(string); } public void circuitOpened(FoxCircuit foxCircuit) throws Exception { String string = foxCircuit.command; if (string == "resolve") { this.resolve(foxCircuit); return; } throw new InvalidCommandException(string); } public BObject resolve(BOrd bOrd) throws Exception { FoxMessage foxMessage = new FoxMessage(); foxMessage.add("ord", bOrd.toString()); FoxCircuit foxCircuit = this.openCircuit("resolve"); foxCircuit.writeMessage(foxMessage); foxCircuit.flush(); FoxMessage foxMessage2 = foxCircuit.readMessage(); if (foxMessage2.getString("exception", null) != null) { throw Fox.exceptionTranslator.messageToException(foxMessage2); } boolean bl = foxMessage2.getBoolean("resolved", false); if (!bl) { throw new UnresolvedException(bOrd.toString()); } String string = foxMessage2.getString("targetType"); if (string.equals("table")) { BIDataTable bIDataTable = DataTableDecoder.decode((DataInput)new DataInputStream(foxCircuit.getInputStream())); foxCircuit.close(); return (BObject)bIDataTable; } if (string.equals("value")) { String string2 = foxMessage2.getString("valueType"); Type type = BTypeSpec.make((String)string2).getResolvedType(); BObject bObject = type.getInstance(); BObject bObject2 = ((BIDataValue)bObject).decode((DataInput)new DataInputStream(foxCircuit.getInputStream())); foxCircuit.close(); return bObject2; } throw new UnresolvedException("Unsupported result type (" + string + ") for " + bOrd.toString()); } public void resolve(FoxCircuit foxCircuit) throws Exception { Object object; Object object2; FoxMessage foxMessage = foxCircuit.readMessage(); String string = foxMessage.getString("ord", null); if (string == null) { foxCircuit.writeMessage(BDataChannel.unresolved()); foxCircuit.flush(); return; } BObject bObject = null; try { object2 = BOrd.make((String)("local:|" + string)); bObject = object2.resolve(null, this.getSessionContext()).get(); } catch (UnresolvedException unresolvedException) { unresolvedException.printStackTrace(); foxCircuit.writeMessage(BDataChannel.unresolved()); foxCircuit.flush(); return; } catch (Exception exception) { exception.printStackTrace(); foxCircuit.writeMessage(Fox.exceptionTranslator.exceptionToMessage(exception)); foxCircuit.flush(); return; } object2 = new FoxMessage(); ((FoxMessage)object2).add("resolved", true); BObject bObject2 = null; if (bObject instanceof BICollection) { ((FoxMessage)object2).add("targetType", "table"); if (bObject instanceof BIDataTable) { bObject2 = bObject; } else { object = ((BICollection)bObject).toTable(); bObject2 = (BObject)BToDataTable.toDataTable((BITable)object); } } else { ((FoxMessage)object2).add("targetType", "value"); bObject2 = (BObject)bObject.toDataValue(); ((FoxMessage)object2).add("valueType", bObject2.getType().getTypeSpec().toString()); } foxCircuit.writeMessage((FoxMessage)object2); foxCircuit.flush(); object = new DataOutputStream(foxCircuit.getOutputStream()); if (bObject2 instanceof BIDataTable) { DataTableEncoder.encode((BIDataTable)((BIDataTable)bObject2), (DataOutput)object, (Context)this.getSessionContext()); } else { ((BIDataValue)bObject2).encode((DataOutput)object); } ((DataOutputStream)object).flush(); ((FilterOutputStream)object).close(); } private static FoxMessage unresolved() { return BDataChannel.unresolved(null, null); } private static FoxMessage unresolved(String string, String string2) { FoxMessage foxMessage = new FoxMessage(); foxMessage.add("resolved", false); if (string2 != null) { foxMessage.add("msg", string2); } return foxMessage; } static /* synthetic */ Class class$(String string) { try { return Class.forName(string); } catch (ClassNotFoundException classNotFoundException) { throw new NoClassDefFoundError(classNotFoundException.getMessage()); } } }