Created
November 28, 2011 20:52
-
-
Save johndemic/1401993 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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