public void setModel(ResourceTreeModel treemodel) {
   nextstack.removeAllElements();
   prevstack.removeAllElements();
   bnext.setEnabled(false);
   bprev.setEnabled(false);
   tree.setModel(treemodel);
   tree.repaint();
 }
예제 #2
0
    // implemented for ActionListener event handling
    public void actionPerformed(ActionEvent e) {
      String actionCmd = e.getActionCommand();
      Stack locStack = parentBrowserFrame.locationStack;
      Stack fwdStack = parentBrowserFrame.forwardStack;

      if (actionCmd.equals(homeCmd)) // event from home button
      {
        fwdStack.removeAllElements();
        parentBrowserFrame.setBrowserLocation(mainBrowserURL);
      } else if (actionCmd.equals(backCmd)) // event from back button
      {
        if (!locStack.isEmpty()) {
          String myLocale = (String) (locStack.pop());

          // push current location on forward stack
          fwdStack.push(location);
          getForwardButton().setEnabled(true);

          // do *not* cache the last location in the stack
          parentBrowserFrame.setBrowserLocation(myLocale, false);
        }
      } else if (actionCmd.equals(forwardCmd)) // event from forward button
      {
        if (!fwdStack.isEmpty()) {
          // remove location from forward stack
          String newLoc = (String) (fwdStack.pop());

          // DO add the current location to the back stack
          parentBrowserFrame.setBrowserLocation(newLoc);
        }
      } else if (actionCmd.equals(comboCmd)) // event from URL combo box!
      {
        if (e.getSource() instanceof JComboBox) // just to be sure
        {
          JComboBox thisBox = (JComboBox) e.getSource();

          String newLoc = thisBox.getSelectedItem().toString();
          if (newLoc != null && !newLoc.equals("")) // ignore empty selections
          {
            if (thisBox.getSelectedIndex() == -1) {
              thisBox.insertItemAt(newLoc, 0);
            }
            fwdStack.removeAllElements();
            parentBrowserFrame.setBrowserLocation(newLoc);
          }
        }
      }

      // disable the back button if we find the location stack is empty
      if (locStack.isEmpty()) {
        getBackButton().setEnabled(false);
      }

      // disable forward button if forward stack is empty
      if (fwdStack.isEmpty()) {
        getForwardButton().setEnabled(false);
      }
    }
 public void reset() {
   gsStack.removeAllElements();
   gsStack.add(new GraphicsState());
   textMatrix = null;
   textLineMatrix = null;
   resources = null;
 }
예제 #4
0
  // .getResource is called at resourceOwner. This method is available at all Class objects
  public void setPage(String filename, Class<?> resourceOwner) {

    // Check for anchor
    int indexOf = filename.indexOf('#');
    String file;
    String anchorName = null;

    if (indexOf != -1) {
      file = filename.substring(0, indexOf);
      anchorName = filename.substring(indexOf + 1);
    } else {
      file = filename;
    }

    String middle = prefs.get(JabRefPreferences.LANGUAGE) + '/';

    URL old = getPage();

    // First check in specified language
    URL resource = resourceOwner.getResource(GUIGlobals.helpPre + middle + file);

    // If not available fallback to english
    if (resource == null) {
      resource = resourceOwner.getResource(GUIGlobals.helpPre + "en/" + file);
      LOGGER.info("No localization available for file '" + file + "'. Falling back to English.");
    }

    // If still not available print a warning
    if (resource == null) {
      // TODO show warning to user
      LOGGER.error("Could not find html-help for file '" + file + "'.");
      return;
    }

    setPageOnly(resource, anchorName);

    forw.removeAllElements();
    if (old != null) {
      history.push(old);
    }
  }
예제 #5
0
  public Stack<String> NumbMain(String strOpr) {
    Stack<String> stkExpr = new Stack<String>();
    Stack<Integer> stkCondn = new Stack<Integer>();
    Stack<Integer> stkSplitVal = new Stack<Integer>();

    for (int iSplit = 18; iSplit <= 111111111; iSplit = iSplit + 9)
      if (iSplit % 10 != 0 && iSplit % 10 != 9) stkSplitVal.add(iSplit);

    for (int iSplitVal : stkSplitVal) {
      String Exp = "";
      int iValue = 0;
      int iSum = 0;
      int iTemp = iSplitVal;
      boolean sValidate = true;

      while (iTemp > 0) {
        int d = iTemp / 10;
        int k = iTemp - d * 10;
        iTemp = d;
        iSum = iSum + k;
        if (k != 0) stkCondn.add(k);
        else sValidate = false;
      }

      if (sValidate == true && iSum <= 9) {
        int sSize = stkCondn.size();
        for (int stk = 0; stk <= sSize - 1; stk++) {
          int val = stkCondn.pop();
          for (int iIterate = 1; iIterate <= val; iIterate++) {
            Exp += String.valueOf(++iValue);
          }
          if (stk < sSize - 1) Exp += strOpr;
        }
        stkExpr.add(Exp);
      } else stkCondn.removeAllElements();
    }
    return stkExpr;
  }
 @Override
 public void valueChanged(TreeSelectionEvent event) {
   Object node = tree.getLastSelectedPathComponent();
   if (node == null) {
     tree.clearSelection();
     BrowserMenuBar.getInstance().resourceEntrySelected(null);
   } else if (node instanceof ResourceEntry) {
     ResourceEntry entry = (ResourceEntry) node;
     BrowserMenuBar.getInstance().resourceEntrySelected((ResourceEntry) node);
     if (entry != prevnextnode) { // Not result of pressing 'Back' or 'Forward'
       if (prevnextnode != null) {
         prevstack.push(prevnextnode);
         bprev.setEnabled(true);
       }
       nextstack.removeAllElements();
       bnext.setEnabled(false);
       prevnextnode = entry;
     }
     if (showresource) {
       shownresource = entry;
       NearInfinity.getInstance().setViewable(ResourceFactory.getResource(entry));
     }
   } else BrowserMenuBar.getInstance().resourceEntrySelected(null);
 }
예제 #7
0
  /**
   * Returns the value of the expression as an object. The expression tree is specified with its top
   * node. The algorithm uses a stack for evaluation.
   *
   * <p>The symTab parameter can be null, if no variables are expected in the expression. If a
   * variable is found, an error is added to the error list.
   *
   * <p>An exception is thrown, if an error occurs during evaluation.
   *
   * @return The value of the expression as an object.
   * @throws ParseException if there is a problem with the evaluation.
   */
  public Object getValue(Node topNode, SymbolTable symTab_in) throws ParseException {

    // check if arguments are ok
    if (topNode == null) {
      throw new ParseException("topNode parameter is null");
    }

    // set member vars
    // errorList = errorList_in;
    symTab = symTab_in;
    // System.out.println("Evaluating expression " + topNode.toLongString() + " with symTab: " +
    // symTab);
    // errorFlag = false;
    stack.removeAllElements();
    // rjm addition ensure stack is correct before beginning.
    // njf changed from clear() to removeAllElements for 1.1 compatibility

    // evaluate by letting the top node accept the visitor
    topNode.jjtAccept(this, null);
    /*
    } catch (ParseException e) {
    this.addToErrorList("Error: "+e.getMessage());
    return null;
    }
    if(errorFlag) return null;
     */

    // something is wrong if not exactly one item remains on the stack
    // or if the error flag has been set
    if (stack.size() != 1) {
      throw new ParseException("Stack corrupted");
    }

    // return the value of the expression
    return stack.pop();
  }
예제 #8
0
 /* Call this to reinitialize the node stack.  It is called
 automatically by the parser's ReInit() method. */
 void reset() {
   nodes.removeAllElements();
   marks.removeAllElements();
   sp = 0;
   mk = 0;
 }
  /**
   * Handle the response or error (during a failed send) message received for an outgoing request
   *
   * @param messageID Request message ID
   * @param response the Axis2 MessageContext that has been received and has to be handled
   * @param synapseOutMsgCtx the corresponding (outgoing) Synapse MessageContext for the above Axis2
   *     MC, that holds Synapse specific information such as the error handler stack and local
   *     properties etc.
   * @throws AxisFault if the message cannot be processed
   */
  private void handleMessage(
      String messageID,
      MessageContext response,
      org.apache.synapse.MessageContext synapseOutMsgCtx,
      AsyncCallback callback)
      throws AxisFault {
    // apply the tenant information to the out message context
    TenantInfoConfigurator configurator =
        synapseOutMsgCtx.getEnvironment().getTenantInfoConfigurator();
    if (configurator != null) {
      configurator.applyTenantInfo(synapseOutMsgCtx);
    }
    Object o = response.getProperty(SynapseConstants.SENDING_FAULT);
    if (o != null && Boolean.TRUE.equals(o)) {

      StatisticsReporter.reportFaultForAll(
          synapseOutMsgCtx, ErrorLogFactory.createErrorLog(response));
      // there is a sending fault. propagate the fault to fault handlers.

      Stack faultStack = synapseOutMsgCtx.getFaultStack();
      if (faultStack != null && !faultStack.isEmpty()) {

        // if we have access to the full synapseOutMsgCtx.getEnvelope(), then let
        // it flow with the error details. Else, replace its envelope with the
        // fault envelope
        try {
          synapseOutMsgCtx.getEnvelope().build();
        } catch (OMException x) {
          synapseOutMsgCtx.setEnvelope(response.getEnvelope());
        }

        Exception e = (Exception) response.getProperty(SynapseConstants.ERROR_EXCEPTION);

        synapseOutMsgCtx.setProperty(SynapseConstants.SENDING_FAULT, Boolean.TRUE);
        synapseOutMsgCtx.setProperty(
            SynapseConstants.ERROR_CODE, response.getProperty(SynapseConstants.ERROR_CODE));
        synapseOutMsgCtx.setProperty(
            SynapseConstants.ERROR_MESSAGE, response.getProperty(SynapseConstants.ERROR_MESSAGE));
        synapseOutMsgCtx.setProperty(
            SynapseConstants.ERROR_DETAIL, response.getProperty(SynapseConstants.ERROR_DETAIL));
        synapseOutMsgCtx.setProperty(SynapseConstants.ERROR_EXCEPTION, e);

        if (log.isDebugEnabled()) {
          log.debug(
              "[Failed Request Message ID : "
                  + messageID
                  + "]"
                  + " [New to be Retried Request Message ID : "
                  + synapseOutMsgCtx.getMessageID()
                  + "]");
        }

        int errorCode = (Integer) response.getProperty(SynapseConstants.ERROR_CODE);

        // If a timeout has occured and the timeout action of the callback is to discard the message
        if (errorCode == SynapseConstants.NHTTP_CONNECTION_TIMEOUT
            && callback.getTimeOutAction() == SynapseConstants.DISCARD) {
          // Do not execute any fault sequences. Discard message
          if (log.isWarnEnabled()) {
            log.warn(
                "Synapse timed out for the request with Message ID : "
                    + messageID
                    + ". Ignoring fault handlers since the timeout action is DISCARD");
          }
          faultStack.removeAllElements();
        } else {
          ((FaultHandler) faultStack.pop()).handleFault(synapseOutMsgCtx, null);
        }
      }

    } else {

      // there can always be only one instance of an Endpoint in the faultStack of a message
      // if the send was successful, so remove it before we proceed any further
      Stack faultStack = synapseOutMsgCtx.getFaultStack();

      Endpoint successfulEndpoint = null;
      if (faultStack != null && !faultStack.isEmpty() && faultStack.peek() instanceof Endpoint) {
        successfulEndpoint = (Endpoint) faultStack.pop();
      }

      if (log.isDebugEnabled()) {
        log.debug("Synapse received an asynchronous response message");
        log.debug(
            "Received To: " + (response.getTo() != null ? response.getTo().getAddress() : "null"));
        log.debug(
            "SOAPAction: "
                + (response.getSoapAction() != null ? response.getSoapAction() : "null"));
        log.debug(
            "WSA-Action: " + (response.getWSAAction() != null ? response.getWSAAction() : "null"));
        String[] cids = response.getAttachmentMap().getAllContentIDs();
        if (cids != null && cids.length > 0) {
          for (String cid : cids) {
            log.debug("Attachment : " + cid);
          }
        }
        log.debug("Body : \n" + response.getEnvelope());
      }
      MessageContext axisOutMsgCtx =
          ((Axis2MessageContext) synapseOutMsgCtx).getAxis2MessageContext();

      // Processes 'Accept-Encoding'
      ResponseAcceptEncodingProcessor.process(response, axisOutMsgCtx);

      response.setServiceContext(null);
      response.setOperationContext(axisOutMsgCtx.getOperationContext());
      response.setAxisMessage(
          axisOutMsgCtx.getAxisOperation().getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE));

      // set properties on response
      response.setServerSide(true);
      response.setProperty(SynapseConstants.ISRESPONSE_PROPERTY, Boolean.TRUE);
      response.setProperty(
          MessageContext.TRANSPORT_OUT, axisOutMsgCtx.getProperty(MessageContext.TRANSPORT_OUT));
      response.setProperty(
          org.apache.axis2.Constants.OUT_TRANSPORT_INFO,
          axisOutMsgCtx.getProperty(org.apache.axis2.Constants.OUT_TRANSPORT_INFO));
      response.setTransportIn(axisOutMsgCtx.getTransportIn());
      response.setTransportOut(axisOutMsgCtx.getTransportOut());

      // If request is REST assume that the response is REST too
      response.setDoingREST(axisOutMsgCtx.isDoingREST());
      if (axisOutMsgCtx.isDoingMTOM()) {
        response.setDoingMTOM(true);
        response.setProperty(
            org.apache.axis2.Constants.Configuration.ENABLE_MTOM,
            org.apache.axis2.Constants.VALUE_TRUE);
      }
      if (axisOutMsgCtx.isDoingSwA()) {
        response.setDoingSwA(true);
        response.setProperty(
            org.apache.axis2.Constants.Configuration.ENABLE_SWA,
            org.apache.axis2.Constants.VALUE_TRUE);
      }

      // when axis2 receives a soap message without addressing headers it users
      // DISABLE_ADDRESSING_FOR_OUT_MESSAGES property to keep it and hence avoid addressing
      // headers on the response. this causes a problem for synapse if the original message
      // it receivs (from client) has addressing and the synaspse service invocation has not
      // engage addressing. in this case when synapse receives the response from the server
      // addessing In handler dissable addressing since that response does not have addressing
      // headers. synapse sends the response to its orignal client using the same message
      // context. Then this response does not have addressing headers since it already
      // disable. to avoid this we need to set the DISABLE_ADDRESSING_FOR_OUT_MESSAGES
      // property state to original state.
      if (axisOutMsgCtx.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES)
          != null) {

        response.setProperty(
            AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES,
            axisOutMsgCtx.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
      } else {
        response.removeProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES);
      }

      Object messageType =
          axisOutMsgCtx.getProperty(org.apache.axis2.Constants.Configuration.MESSAGE_TYPE);
      if (!HTTPConstants.MEDIA_TYPE_X_WWW_FORM.equals(messageType)) {
        // copy the message type property that's used by the out message to the
        // response message
        response.setProperty(org.apache.axis2.Constants.Configuration.MESSAGE_TYPE, messageType);
      }

      // compare original received message (axisOutMsgCtx) soap version with the response
      // if they are different change to original version
      if (axisOutMsgCtx.isSOAP11() != response.isSOAP11()) {
        if (axisOutMsgCtx.isSOAP11()) {
          SOAPUtils.convertSOAP12toSOAP11(response);
        } else {
          SOAPUtils.convertSOAP11toSOAP12(response);
        }
      }

      if (axisOutMsgCtx.getMessageID() != null) {
        response.setRelationships(new RelatesTo[] {new RelatesTo(axisOutMsgCtx.getMessageID())});
      }

      response.setReplyTo(axisOutMsgCtx.getReplyTo());
      response.setFaultTo(axisOutMsgCtx.getFaultTo());

      if (axisOutMsgCtx.isPropertyTrue(NhttpConstants.IGNORE_SC_ACCEPTED)) {
        response.setProperty(NhttpConstants.FORCE_SC_ACCEPTED, Constants.VALUE_TRUE);
      }

      // create the synapse message context for the response
      Axis2MessageContext synapseInMessageContext =
          new Axis2MessageContext(
              response, synapseOutMsgCtx.getConfiguration(), synapseOutMsgCtx.getEnvironment());
      synapseInMessageContext.setResponse(true);

      Object obj = synapseOutMsgCtx.getProperty(SynapseConstants.FORCE_ERROR_PROPERTY);
      String errorOnSOAPFault = (String) obj;

      if (Constants.VALUE_TRUE.equals(errorOnSOAPFault) && successfulEndpoint != null) {

        if (log.isDebugEnabled()) {
          log.debug("FORCE_ERROR_ON_SOAP_FAULT is true, checking for SOAPFault");
        }

        try {
          RelayUtils.buildMessage(
              ((Axis2MessageContext) synapseInMessageContext).getAxis2MessageContext(), true);
        } catch (Exception e) {
          // handleException("Error while building message", e, synapseInMessageContext);
        }

        if ((synapseInMessageContext.getEnvelope() != null)
            && synapseInMessageContext.getEnvelope().hasFault()) {

          if (log.isDebugEnabled()) {
            log.debug(
                "SOAPFault found in response message, forcing endpoint "
                    + successfulEndpoint.getName()
                    + " to fail");
          }

          // setup new pipe configuration..if failure happens (this will be setup as the source
          // writer and during the TargetContext
          // clean up operation the writer will be reset and pull to the buffer
          MessageContext axis2OUTMC =
              ((Axis2MessageContext) synapseOutMsgCtx).getAxis2MessageContext();
          NHttpServerConnection conn =
              (NHttpServerConnection) axis2OUTMC.getProperty("pass-through.Source-Connection");
          if (conn != null) {
            SourceConfiguration sourceConfiguration =
                (SourceConfiguration) axis2OUTMC.getProperty("PASS_THROUGH_SOURCE_CONFIGURATION");
            Pipe pipe =
                new Pipe(
                    conn,
                    sourceConfiguration.getBufferFactory().getBuffer(),
                    "source",
                    sourceConfiguration);
            axis2OUTMC.setProperty(PassThroughConstants.PASS_THROUGH_PIPE, pipe);
          }

          StatisticsReporter.reportFaultForAll(
              synapseOutMsgCtx, ErrorLogFactory.createErrorLog(response));
          synapseOutMsgCtx.setProperty(SynapseConstants.SENDING_FAULT, Boolean.TRUE);
          synapseOutMsgCtx.setProperty(
              SynapseConstants.ERROR_CODE, SynapseConstants.ENDPOINT_CUSTOM_ERROR);
          ((FaultHandler) successfulEndpoint).handleFault(synapseOutMsgCtx, null);
          return;
        } else {
          successfulEndpoint.onSuccess();
        }

      } else if (successfulEndpoint != null) {
        successfulEndpoint.onSuccess();
      }

      synapseInMessageContext.setTo(
          new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL));
      synapseInMessageContext.setTracingState(synapseOutMsgCtx.getTracingState());

      // set the properties of the original MC to the new MC

      for (Object key : synapseOutMsgCtx.getPropertyKeySet()) {
        synapseInMessageContext.setProperty(
            (String) key, synapseOutMsgCtx.getProperty((String) key));
      }

      // Copy SequenceCallStack from original MC to the new MC
      if (synapseOutMsgCtx.isContinuationEnabled()) {

        // Set the message direction
        if (!synapseOutMsgCtx.isResponse()) {
          synapseInMessageContext.setResponse(false);
        }

        Stack<ContinuationState> seqContinuationStates =
            synapseOutMsgCtx.getContinuationStateStack();
        for (int i = 0; i < seqContinuationStates.size(); i++) {
          synapseInMessageContext.pushContinuationState(seqContinuationStates.get(i));
        }
      }

      // If this response is related to session affinity endpoints -Server initiated session
      Dispatcher dispatcher =
          (Dispatcher)
              synapseOutMsgCtx.getProperty(SynapseConstants.PROP_SAL_ENDPOINT_CURRENT_DISPATCHER);
      if (dispatcher != null && dispatcher.isServerInitiatedSession()) {
        dispatcher.updateSession(synapseInMessageContext);
      }

      StatisticsReporter.reportForAllOnResponseReceived(synapseInMessageContext);

      // send the response message through the synapse mediation flow
      try {
        synapseOutMsgCtx.getEnvironment().injectMessage(synapseInMessageContext);
      } catch (SynapseException syne) {
        Stack stack = synapseInMessageContext.getFaultStack();
        if (stack != null && !stack.isEmpty()) {
          ((FaultHandler) stack.pop()).handleFault(synapseInMessageContext, syne);
        } else {
          log.error(
              "Synapse encountered an exception, "
                  + "No error handlers found - [Message Dropped]\n"
                  + syne.getMessage());
        }
      }
    }
  }
예제 #10
0
 public void reset() {
   forw.removeAllElements();
   history.removeAllElements();
 }