Skip to content

Instantly share code, notes, and snippets.

@johndemic
Created November 28, 2011 20:52
Show Gist options
  • Save johndemic/1401993 to your computer and use it in GitHub Desktop.
Save johndemic/1401993 to your computer and use it in GitHub Desktop.
@Module(name = "validator", schemaVersion = "1.0-SNAPSHOT")
public class ValidatorModule {
/**
* Processor to filter our invalid products from a List payload.
* <p/>
* {@sample.xml ../../../doc/Validator-connector.xml.sample validator:my-processor}
*
* @param products The products to validate
* @return The products which are valid
*/
@Processor(name = "product")
public Object validateProducts(@Payload List<Map> products) throws Exception {
List<Map> validProducts = new ArrayList<Map>();
for (Map product : products) {
if (product.containsKey("sku") || product.containsKey("product_id")) {
validProducts.add(product);
}
}
return validProducts;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment