Ejemplo n.º 1
0
  public void reset(
      IOperationContext context,
      String statements,
      String statementsFormat,
      java.util.Collection<org.openanzo.rdf.Statement> checks,
      java.io.Writer output)
      throws AnzoException {
    if (!combusConnection.isConnected()) {
      throw new AnzoException(ExceptionConstants.CLIENT.CLIENT_NOT_CONNECTED);
      // combusConnection.connect();
    }
    long start = 0;
    if (stats.isEnabled()) {
      start = System.currentTimeMillis();
    }
    try {
      TextMessage request = combusConnection.createMessage();
      org.openanzo.combus.JMSMessageWrapper messageWrapper =
          new org.openanzo.combus.JMSMessageWrapper(request);

      messageWrapper.setProperty(SerializationConstants.operation, RESET);
      if (context.getAttribute(SerializationConstants.userDescription) != null) {
        messageWrapper.setProperty(
            SerializationConstants.userDescription,
            context.getAttribute(SerializationConstants.userDescription, String.class));
      }

      messageWrapper.setProperty(PARAM_STATEMENTSFormat, statementsFormat);
      messageWrapper.setBody(statements);
      messageWrapper.setProperty(
          PARAM_CHECKSFormat, org.openrdf.rio.RDFFormat.TRIG.getDefaultMIMEType());
      if (checks != null)
        org.openanzo.services.serialization.transport.StatementsSerializer.serialize(
            checks,
            PARAM_CHECKS,
            org.openrdf.rio.RDFFormat.TRIG.getDefaultMIMEType(),
            messageWrapper);

      TextMessage response =
          combusConnection.requestResponse(
              context, org.openanzo.datasource.IResetService.SERVICE_NAME, request, getTimeout());
      try {
        if (response != null && response.getText() != null) {
          output.write(response.getText());
          output.flush();
        }
      } catch (IOException ioe) {
        throw new AnzoException(ExceptionConstants.IO.WRITE_ERROR, ioe);
      } catch (JMSException jmsex) {
        throw new AnzoException(ExceptionConstants.COMBUS.JMS_MISSING_MESSAGE_PARAMETER, jmsex);
      }
    } finally {
      if (stats.isEnabled()) {
        stats.use("reset", (System.currentTimeMillis() - start));
      }
    }
  }
Ejemplo n.º 2
0
 public void reset(
     IOperationContext context,
     java.util.Collection<org.openanzo.rdf.Statement> statements,
     java.util.Collection<org.openanzo.rdf.Statement> checks)
     throws AnzoException {
   java.io.StringWriter responseWriter = new java.io.StringWriter();
   String _requestBody = null;
   if (statements != null) {
     _requestBody =
         org.openanzo.services.serialization.transport.StatementsSerializer.serialize(
             statements, org.openrdf.rio.RDFFormat.TRIG.getDefaultMIMEType());
   }
   String statementsFormat = org.openrdf.rio.RDFFormat.TRIG.getDefaultMIMEType();
   reset(context, _requestBody, statementsFormat, checks, responseWriter);
 }