package com.crystaldecisions.proxy.remoteagent; /** * @author sunyj * @since 2017/12/26 16:12 */ import com.businessobjects.sdk.erom.remoteagent.Agent; import com.businessobjects.sdk.erom.remoteagent.commands.CommandObject; import com.crystaldecisions.client.helper.ISecurityContext; import com.crystaldecisions.sdk.occa.report.lib.ReportSDKException; import com.crystaldecisions.xml.serialization.IXMLSerializable; import java.io.IOException; import java.util.Locale; import java.util.Vector; public class CommunicationChannel { private Agent agent = null; private boolean ifV = false; private ITextWriter forV = null; private Vector communicationChannelEventListeners = new Vector(); public CommunicationChannel(Agent agent) { this.agent = agent; } public void addListener(ICommunicationChannelEventListener communicationChannelEventListener) { this.communicationChannelEventListeners.add(communicationChannelEventListener); } protected void a(CommunicationChannelEvent communicationChannelEvent) { for(int i = 0; i < this.communicationChannelEventListeners.size(); ++i) { ICommunicationChannelEventListener communicationChannelEventListener = (ICommunicationChannelEventListener)this.communicationChannelEventListeners.elementAt(i); communicationChannelEventListener.a(communicationChannelEvent); } } public void forM() { this.agent = null; this.forV = null; } public boolean doM() { return this.ifV; } public Locale getLocale() { return this.agent != null ? this.agent.getLocale() : Locale.getDefault(); } public ITextWriter a() { return this.forV; } public void a(String var1, String var2, ISecurityContext var3) throws ReportSDKException { if (var1 == null) { throw new NullPointerException(); } else { RecordingUtil.ifM(); RecordingUtil.a(this, var1, var2, var3); RecordingUtil.doM(); } } public void ifM(ICommunicationChannelEventListener var1) { this.communicationChannelEventListeners.remove(var1); } public ResultInfo a(ISecurityContext iSecurityContext, String docId, int requestId, int options, IXMLSerializable ixmlSerializable, RequestPriority requestPriority) throws ReportSDKException { if (requestPriority.getRequestPriority() > 10) { throw new IndexOutOfBoundsException(); } else { try { if (this.ifV && this.forV != null) { RequestEntry var7 = new RequestEntry(iSecurityContext, docId, requestId, options, ixmlSerializable, requestPriority); RecordingUtil.a(this.forV, var7); } CommandObject commandObject = new CommandObject(requestId, ixmlSerializable); this.agent.execute(commandObject); ResultInfo resultInfo = (ResultInfo)commandObject.getOutput(); if (resultInfo == null) { resultInfo = new ResultInfo(); resultInfo.setResultCode(-2147217405); resultInfo.setErrorMsg(ExceptionHelper.loadResultCodeMsg(-2147217405, this.getLocale())); resultInfo.setResultObj((IXMLSerializable)null); } if (this.ifV && this.forV != null) { boolean var9 = ClientSDKOptions.m_RequestRecordingOptions.m_RecordSucceededResultDetails; boolean var10 = var9 || resultInfo.getResultCode() != 0 || requestId == 3; RecordingUtil.a(this.forV, resultInfo, var10); } int resultCode = resultInfo.getResultCode(); if (ResultCode.FAILED(resultCode)) { String errorMsg = resultInfo.getErrorMsg(true); if (errorMsg.length() == 0) { resultInfo.setErrorMsg(ExceptionHelper.loadResultCodeMsg(resultCode, this.getLocale())); } } this.a(new CommunicationChannelEvent(this, resultInfo)); return resultInfo; } catch (IOException var11) { ; } catch (NullPointerException var12) { ; } return null; } } public void a(boolean var1) { if ((!this.ifV || !var1) && (this.ifV || var1)) { this.ifV = var1; if (this.ifV) { RecordingUtil.ifM(); } else { RecordingUtil.doM(); } } } public void a(ITextWriter var1) { this.forV = var1; } public Object a(Class var1) { return this.agent.getInternal(var1); } public Object a(String var1, Class var2) { return this.agent.getInternal(var1, var2); } }