CommunicationChannel.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. package com.crystaldecisions.proxy.remoteagent;
  2. /**
  3. * @author sunyj
  4. * @since 2017/12/26 16:12
  5. */
  6. import com.businessobjects.sdk.erom.remoteagent.Agent;
  7. import com.businessobjects.sdk.erom.remoteagent.commands.CommandObject;
  8. import com.crystaldecisions.client.helper.ISecurityContext;
  9. import com.crystaldecisions.sdk.occa.report.lib.ReportSDKException;
  10. import com.crystaldecisions.xml.serialization.IXMLSerializable;
  11. import java.io.IOException;
  12. import java.util.Locale;
  13. import java.util.Vector;
  14. public class CommunicationChannel {
  15. private Agent agent = null;
  16. private boolean ifV = false;
  17. private ITextWriter forV = null;
  18. private Vector communicationChannelEventListeners = new Vector();
  19. public CommunicationChannel(Agent agent) {
  20. this.agent = agent;
  21. }
  22. public void addListener(ICommunicationChannelEventListener communicationChannelEventListener) {
  23. this.communicationChannelEventListeners.add(communicationChannelEventListener);
  24. }
  25. protected void a(CommunicationChannelEvent communicationChannelEvent) {
  26. for(int i = 0; i < this.communicationChannelEventListeners.size(); ++i) {
  27. ICommunicationChannelEventListener communicationChannelEventListener = (ICommunicationChannelEventListener)this.communicationChannelEventListeners.elementAt(i);
  28. communicationChannelEventListener.a(communicationChannelEvent);
  29. }
  30. }
  31. public void forM() {
  32. this.agent = null;
  33. this.forV = null;
  34. }
  35. public boolean doM() {
  36. return this.ifV;
  37. }
  38. public Locale getLocale() {
  39. return this.agent != null ? this.agent.getLocale() : Locale.getDefault();
  40. }
  41. public ITextWriter a() {
  42. return this.forV;
  43. }
  44. public void a(String var1, String var2, ISecurityContext var3) throws ReportSDKException {
  45. if (var1 == null) {
  46. throw new NullPointerException();
  47. } else {
  48. RecordingUtil.ifM();
  49. RecordingUtil.a(this, var1, var2, var3);
  50. RecordingUtil.doM();
  51. }
  52. }
  53. public void ifM(ICommunicationChannelEventListener var1) {
  54. this.communicationChannelEventListeners.remove(var1);
  55. }
  56. public ResultInfo a(ISecurityContext iSecurityContext, String docId, int requestId, int options, IXMLSerializable ixmlSerializable, RequestPriority requestPriority) throws ReportSDKException {
  57. if (requestPriority.getRequestPriority() > 10) {
  58. throw new IndexOutOfBoundsException();
  59. } else {
  60. try {
  61. if (this.ifV && this.forV != null) {
  62. RequestEntry var7 = new RequestEntry(iSecurityContext, docId, requestId, options, ixmlSerializable, requestPriority);
  63. RecordingUtil.a(this.forV, var7);
  64. }
  65. CommandObject commandObject = new CommandObject(requestId, ixmlSerializable);
  66. this.agent.execute(commandObject);
  67. ResultInfo resultInfo = (ResultInfo)commandObject.getOutput();
  68. if (resultInfo == null) {
  69. resultInfo = new ResultInfo();
  70. resultInfo.setResultCode(-2147217405);
  71. resultInfo.setErrorMsg(ExceptionHelper.loadResultCodeMsg(-2147217405, this.getLocale()));
  72. resultInfo.setResultObj((IXMLSerializable)null);
  73. }
  74. if (this.ifV && this.forV != null) {
  75. boolean var9 = ClientSDKOptions.m_RequestRecordingOptions.m_RecordSucceededResultDetails;
  76. boolean var10 = var9 || resultInfo.getResultCode() != 0 || requestId == 3;
  77. RecordingUtil.a(this.forV, resultInfo, var10);
  78. }
  79. int resultCode = resultInfo.getResultCode();
  80. if (ResultCode.FAILED(resultCode)) {
  81. String errorMsg = resultInfo.getErrorMsg(true);
  82. if (errorMsg.length() == 0) {
  83. resultInfo.setErrorMsg(ExceptionHelper.loadResultCodeMsg(resultCode, this.getLocale()));
  84. }
  85. }
  86. this.a(new CommunicationChannelEvent(this, resultInfo));
  87. return resultInfo;
  88. } catch (IOException var11) {
  89. ;
  90. } catch (NullPointerException var12) {
  91. ;
  92. }
  93. return null;
  94. }
  95. }
  96. public void a(boolean var1) {
  97. if ((!this.ifV || !var1) && (this.ifV || var1)) {
  98. this.ifV = var1;
  99. if (this.ifV) {
  100. RecordingUtil.ifM();
  101. } else {
  102. RecordingUtil.doM();
  103. }
  104. }
  105. }
  106. public void a(ITextWriter var1) {
  107. this.forV = var1;
  108. }
  109. public Object a(Class var1) {
  110. return this.agent.getInternal(var1);
  111. }
  112. public Object a(String var1, Class var2) {
  113. return this.agent.getInternal(var1, var2);
  114. }
  115. }