Package org.apache.vinci.transport

Examples of org.apache.vinci.transport.ServiceException


      XTalkTransporter.writeInt(1, os);
      XMLReader xr;
      try {
        xr = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
      } catch (SAXException e) {
        throw new ServiceException("Error creating SAX Parser: " + e);
      } catch (ParserConfigurationException e) {
        throw new ServiceException("Error creating SAX Parser: " + e);
      }
      if (xml_os != null) {
        xml_os.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
      }
      // prevent undeclared namespace warnings.
      try {
        xr.setFeature("http://xml.org/sax/features/namespaces", false);
        handler = new XTalkHandler(os, purgeWhitespace, xml_os);
        xr.setContentHandler(handler);
        xr.setErrorHandler(handler);
        xr.parse(new InputSource(r));
        Debug.p("Final depth: " + handler.depth);
        Debug.p("Final child list size: " + handler.countList.size());
      } catch (SAXException e) {
        Debug.reportException(e);
        throw new ServiceException("XML Parse error: " + e);
      }
    } finally {
      os.close();
      if (xml_os != null) {
        xml_os.close();
View Full Code Here


      UIMAFramework.getLogger().log(Level.FINE, "CAS Annotation Count::" + totalAnnots);

      return responseFrame;
    } catch (Throwable ex) {
      UIMAFramework.getLogger().log(Level.SEVERE, "", ex);
      throw new ServiceException("Unexpected exception in analyze(): " + ex);
    } finally {
      // release CAS back to pool
      if (cas != null) {
        mCasPool.releaseCas(cas);
      }
View Full Code Here

    UIMAFramework.getLogger().log(Level.FINEST, "Command::" + op);
    if (Constants.GETMETA.equals(op)) {
      try {
        return this.getMetaData();
      } catch (Exception ex) {
        throw new ServiceException("getMetaData() threw exception: " + ex);
      }
    } else if (Constants.PROCESS_CAS.equals(op) || Constants.ANNOTATE.equals(op)) {
      return analyze(frame);
    } else if (Constants.BATCH_PROCESS_COMPLETE.equals(op)) {
      try {
        mAE.batchProcessComplete(new ProcessTrace_impl());
        return null; // one way call - do NOT return anything, not
        // even an empty frame
      } catch (IOException e) {
        throw new ServiceException("IOException: " + e);
      } catch (ResourceProcessException e) {
        throw new ServiceException("ResourceProcessException: " + e);
      }
    } else if (Constants.COLLECTION_PROCESS_COMPLETE.equals(op)) {
      try {
        mAE.collectionProcessComplete(new ProcessTrace_impl());
        return new VinciFrame(); // no return value - return empty
        // frame
      } catch (IOException e) {
        throw new ServiceException("IOException: " + e);
      } catch (ResourceProcessException e) {
        throw new ServiceException("ResourceProcessException: " + e);
      }
    } else if (Constants.IS_STATELESS.equals(op)) {
      return new AFrame().fadd("Result", mAE.isStateless());
    } else if (Constants.IS_READONLY.equals(op)) {
      return new AFrame().fadd("Result", mAE.isReadOnly());
View Full Code Here

  public static VinciFrame xmlToVinciFrame(Reader r) throws ServiceException {
    XMLReader xr;
    try {
      xr = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
    } catch (SAXException e) {
      throw new ServiceException("Error creating SAX Parser: " + e);
    } catch (ParserConfigurationException e) {
      throw new ServiceException("Error creating SAX Parser: " + e);
    }
    // prevent undeclared namespace warnings.
    try {
      xr.setFeature("http://xml.org/sax/features/namespaces", false);
      VinciFrameHandler handler = new VinciFrameHandler();
      xr.setContentHandler(handler);
      xr.setErrorHandler(handler);
      xr.parse(new InputSource(r));
      return (VinciFrame) handler.top.component;
    } catch (IOException e) {
      Debug.reportException(e);
      throw new ServiceException("Reader IO error: " + e);
    } catch (SAXException e) {
      Debug.reportException(e);
      throw new ServiceException("XML Parse error: " + e);
    }
  }
View Full Code Here

  public static AFrame xmlToAFrame(Reader r) throws ServiceException {
    XMLReader xr;
    try {
      xr = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
    } catch (SAXException e) {
      throw new ServiceException("Error creating SAX Parser: " + e);
    } catch (ParserConfigurationException e) {
      throw new ServiceException("Error creating SAX Parser: " + e);
    }
    // prevent undeclared namespace warnings.
    try {
      xr.setFeature("http://xml.org/sax/features/namespaces", false);
      AFrameHandler handler = new AFrameHandler();
      xr.setContentHandler(handler);
      xr.setErrorHandler(handler);
      xr.parse(new InputSource(r));
      return (AFrame) handler.top.component;
    } catch (IOException e) {
      Debug.reportException(e);
      throw new ServiceException("Reader IO error: " + e);
    } catch (SAXException e) {
      Debug.reportException(e);
      throw new ServiceException("XML Parse error: " + e);
    }
  }
View Full Code Here

      XTalkTransporter.writeInt(1, os);
      XMLReader xr;
      try {
        xr = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
      } catch (SAXException e) {
        throw new ServiceException("Error creating SAX Parser: " + e);
      } catch (ParserConfigurationException e) {
        throw new ServiceException("Error creating SAX Parser: " + e);
      }
      if (xml_os != null) {
        xml_os.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
      }
      // prevent undeclared namespace warnings.
      try {
        xr.setFeature("http://xml.org/sax/features/namespaces", false);
        handler = new XTalkHandler(os, purgeWhitespace, xml_os);
        xr.setContentHandler(handler);
        xr.setErrorHandler(handler);
        xr.parse(new InputSource(r));
        Debug.p("Final depth: " + handler.depth);
        Debug.p("Final child list size: " + handler.countList.size());
      } catch (SAXException e) {
        Debug.reportException(e);
        throw new ServiceException("XML Parse error: " + e);
      }
    } finally {
      os.close();
      if (xml_os != null) {
        xml_os.close();
View Full Code Here

        rtn.fadd("vinci:EXCEPTION", "Unknown command");
        return rtn;
      }
    } catch (Exception ex) {
      ex.printStackTrace();
      throw new ServiceException(ex.getMessage());
    }
  }
View Full Code Here

                  new Object[] { Thread.currentThread().getName(), serviceHost, servicePort });
          connect(serviceHost, Integer.parseInt(servicePort));
        }
      } catch (ConnectException ce) {
        if (serviceName != null) {
          throw new ServiceException(CpmLocalizedMessage.getLocalizedMessage(
                  CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                  "UIMA_CPM_EXP_unable_to_connect_toservice__WARNING", new Object[] {
                      Thread.currentThread().getName(), serviceName }));
        } else {
          throw new ServiceException(CpmLocalizedMessage.getLocalizedMessage(
                  CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_EXP_unable_to_connect__WARNING",
                  new Object[] { Thread.currentThread().getName(), serviceHost, servicePort }));

        }
View Full Code Here

                  String.valueOf(conn.getPort()) });

      UIMAFramework.getLogger(this.getClass()).log(Level.WARNING, Thread.currentThread().getName(),
              vnse);
      conn.close();
      throw new ServiceException(vnse.getMessage());
    } catch (ServiceDownException sde) {
      UIMAFramework.getLogger(this.getClass()).logrb(
              Level.WARNING,
              this.getClass().getName(),
              "process",
              CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
              "UIMA_CPM_failed_service_request__WARNING",
              new Object[] { Thread.currentThread().getName(), conn.getHost(),
                  String.valueOf(conn.getPort()) });
      UIMAFramework.getLogger(this.getClass()).log(Level.WARNING, Thread.currentThread().getName(),
              sde);
      conn.close();
      throw new ServiceConnectionException(sde.getMessage());
    } catch (ServiceException sde) {
      UIMAFramework.getLogger(this.getClass()).logrb(
              Level.WARNING,
              this.getClass().getName(),
              "process",
              CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
              "UIMA_CPM_failed_service_request__WARNING",
              new Object[] { Thread.currentThread().getName(), conn.getHost(),
                  String.valueOf(conn.getPort()) });
      UIMAFramework.getLogger(this.getClass()).log(Level.WARNING, Thread.currentThread().getName(),
              sde);
      if (sde.getMessage().equals("Unknown command") && aFrame != null) {
        UIMAFramework.getLogger(this.getClass()).log(Level.INFO, aFrame.toXML());
      }
      throw new ServiceConnectionException(sde.getMessage());
    } catch (IOException e) {
      UIMAFramework.getLogger(this.getClass()).logrb(
              Level.WARNING,
              this.getClass().getName(),
              "process",
              CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
              "UIMA_CPM_failed_service_request__WARNING",
              new Object[] { Thread.currentThread().getName(), conn.getHost(),
                  String.valueOf(conn.getPort()) });
      UIMAFramework.getLogger(this.getClass()).log(Level.WARNING, Thread.currentThread().getName(),
              e);
      conn.close();
      if (System.getProperty("TEST_BEFORE_SEND") != null) {
        testAndReconnect();
      }
      if (e instanceof SocketTimeoutException) {
        UIMAFramework.getLogger(this.getClass()).log(Level.WARNING,
                Thread.currentThread().getName() + "  Exception Cause::" + e.getClass().getName());
        throw new ServiceConnectionException(e);
      }
      throw new ServiceConnectionException(CpmLocalizedMessage.getLocalizedMessage(
              CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_EXP_service_timeout__WARNING",
              new Object[] { Thread.currentThread().getName(), conn.getHost(),
                  String.valueOf(conn.getPort()), String.valueOf(currentTimeout) }));
    } catch (Exception e) {
      UIMAFramework.getLogger(this.getClass()).logrb(
              Level.WARNING,
              this.getClass().getName(),
              "process",
              CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
              "UIMA_CPM_failed_service_request__WARNING",
              new Object[] { Thread.currentThread().getName(), conn.getHost(),
                  String.valueOf(conn.getPort()) });
      UIMAFramework.getLogger(this.getClass()).log(Level.WARNING, Thread.currentThread().getName(),
              e);

      conn.close();
      throw new ServiceException(e.getMessage());
    }

  }
View Full Code Here

        UIMAFramework.getLogger(this.getClass()).logrb(Level.FINER, this.getClass().getName(),
                "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_exception__FINER",
                new Object[] { Thread.currentThread().getName(), ex.getMessage() });
        UIMAFramework.getLogger(this.getClass()).log(Level.FINER, "", ex);
      }
      throw new ServiceException(ex.getMessage());
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.vinci.transport.ServiceException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.