@Override
 public boolean canHandle(Operation operation) {
   String operationId = operation.getId();
   return ("GetExecutionStatus".equalsIgnoreCase(operationId)
           || "GetExecutionResult".equalsIgnoreCase(operationId))
       && operation.getService().getId().equals("wps");
 }
  /**
   * Ensures that the operation being executed is a GetFeature operation.
   *
   * <p>Subclasses may implement
   */
  public boolean canHandle(Operation operation) {
    // GetFeature operation?
    if ("GetFeature".equalsIgnoreCase(operation.getId())
        || "GetFeatureWithLock".equalsIgnoreCase(operation.getId())) {
      // also check that the resultType is "results"
      GetFeatureRequest req = GetFeatureRequest.adapt(operation.getParameters()[0]);
      if (req.isResultTypeResults()) {
        // call subclass hook
        return canHandleInternal(operation);
      }
    }

    return false;
  }
  public void write(Object value, OutputStream output, Operation operation) throws IOException {
    TransformerBase tx = (TransformerBase) value;

    try {
      tx.transform(operation.getParameters()[0], output);
    } catch (TransformerException e) {
      throw new IOException(e);
    }
  }
 public String getMimeType(Object value, Operation operation) {
   Object request = operation.getParameters()[0];
   if (request instanceof GetExecutionStatusType) {
     return "text/xml";
   } else if (request instanceof GetExecutionResultType) {
     GetExecutionResultType ger = (GetExecutionResultType) request;
     if (ger.getMimeType() != null) {
       return ger.getMimeType();
     } else {
       // generic binary output...
       return "application/octet-stream";
     }
   } else {
     throw new WPSException(
         "Trying to get a mime type for a unknown operation, "
             + "we should not have got here in the first place");
   }
 }
 @Override
 public String getAttachmentFileName(Object value, Operation operation) {
   Object request = operation.getParameters()[0];
   if (request instanceof GetExecutionStatusType) {
     return "text/xml";
   } else if (request instanceof GetExecutionResultType) {
     GetExecutionResultType ger = (GetExecutionResultType) request;
     if (ger.getOutputId() != null) {
       return ger.getOutputId();
     } else {
       // we should really never get here, the request should fail before
       return "result.dat";
     }
   } else {
     throw new WPSException(
         "Trying to get a file name for a unknown operation, "
             + "we should not have got here in the first place");
   }
 }
  public void write(Object value, OutputStream output, Operation operation)
      throws IOException, ServiceException {
    final FeatureDiffReader[] diffReaders = (FeatureDiffReader[]) value;

    // create a new feature collcetion type with just the numbers
    VersioningTransactionConverter converter = new VersioningTransactionConverter();
    final TransactionType transaction = converter.convert(diffReaders, TransactionType.class);

    // declare wfs schema location
    BaseRequestType gft = (BaseRequestType) operation.getParameters()[0];

    Encoder encoder = new Encoder(configuration, configuration.schema());
    encodeWfsSchemaLocation(encoder, gft.getBaseUrl());

    encoder.setIndenting(true);
    encoder.setEncoding(Charset.forName(geoServer.getSettings().getCharset()));

    // set up schema locations
    // round up the info objects for each feature collection
    HashMap /* <String,Set> */ ns2metas = new HashMap();

    for (int i = 0; i < diffReaders.length; i++) {
      final FeatureDiffReader diffReader = diffReaders[i];
      final SimpleFeatureType featureType = diffReader.getSchema();

      // load the metadata for the feature type
      String namespaceURI = featureType.getName().getNamespaceURI();
      FeatureTypeInfo meta =
          geoServer
              .getCatalog()
              .getFeatureTypeByName(namespaceURI, featureType.getName().getLocalPart());

      // add it to the map
      Set metas = (Set) ns2metas.get(namespaceURI);

      if (metas == null) {
        metas = new HashSet();
        ns2metas.put(namespaceURI, metas);
      }

      metas.add(meta);
    }

    // declare application schema namespaces
    for (Iterator i = ns2metas.entrySet().iterator(); i.hasNext(); ) {
      Map.Entry entry = (Map.Entry) i.next();

      String namespaceURI = (String) entry.getKey();
      Set metas = (Set) entry.getValue();

      StringBuffer typeNames = new StringBuffer();

      for (Iterator m = metas.iterator(); m.hasNext(); ) {
        FeatureTypeInfo meta = (FeatureTypeInfo) m.next();
        typeNames.append(meta.getName());

        if (m.hasNext()) {
          typeNames.append(",");
        }
      }

      // set the schema location
      encodeTypeSchemaLocation(encoder, gft.getBaseUrl(), namespaceURI, typeNames);
    }

    try {
      encoder.encode(transaction, element, output);
    } finally {
      for (int i = 0; i < diffReaders.length; i++) {
        diffReaders[i].close();
      }
    }
  }
  /** Checks that the resultType is of type "hits". */
  public boolean canHandle(Operation operation) {
    GetDiffType request =
        (GetDiffType) OwsUtils.parameter(operation.getParameters(), GetDiffType.class);

    return (request != null) && request.getOutputFormat().equals(mime);
  }