Plugins You can find out about all the publicly available Grails plugins.

Web Purify Services Integration

  • Authors: Lance Woodson
0 vote
compile "org.grails.plugins:webpurify:0.1"




Provides an integration point for Web Purify profanity filtering services. REST aspects are abstracted away and all calls and result handling can be done with plain old groovy via the WebPurifyService class.


Standard Grails plugin installation. On command line, type:

grails install-plugin webpurify


The plugin must have your web purify api key configured before you can use the service. This should be specified in the webpurify.apiKey property in Groovy config:


Service Injection

The web purify service can be injected into controllers, taglibs, other services and so forth using Grails standard support for dependency injection.

class FooController {
	def webPurifyService

def someAction = { // leverage webPurifyService as needed } }

Service Methods

callCheck: Invokes the method, and invokes a callback closure with true or false if profanity was found or not.

webPurifyService.callCheck(textToCheck, { found ->
	// found == true if profanity found, or false otherwise

callCheckCount: Invokes the method, and invokes a callback closure with a count of the profane words found.

webPurifyService.callCheckCount(textToCheck, { found ->
	// Found will be an integer w/number of profane words found.

callReplace: Invokes the method and invokes a callback closure, passing along a count of profane words and text that has profane words replaced with a series of substitution symbols.

webPurifyService.callReplace(textToCheck, ‘*’, { found, text ->
	// found will be count of profane words
	// text will be text with profane words replaced with * sequences.

callReturn: Invokes the method, and invokes a callback closure, passing along a count of profane words and the list of expletives found.

webPurifyService.callReturn(textToCheck, {found, expletives ->
	// found will be count of profane words
	// expletives will be list of profane words

callAddToBlackList: Invokes the method.


callAddToWhiteList: Invokes the method.


callRemoveFromBlackList: Invokes the method.


callRemoveFromWhiteList: Invokes the method.


Handling Errors

All methods throw a WebPurifyException if an error response is received from the . The exception will contain a code and message property that contains the error code and message from the service. See the Web Purify API docs for more information about the specific error codes for each method.

try {
} catch (e) {
	// handle errors, e.code will have error code if specific error handling needed.

Language Support

All methods accept an optional language property as their last argument to allow you to specify the language you are sending the request in. See the Web Purify docs on foreign language support for more details.

Synchronous Invocation

As of right now, all operations are synchronous in that the invoking thread is used to execute the HTTP request, process the response and invoke any callback closures. If asynchronous execution is needed, you should leverage the quartz plugin and stick the webpurify calls in a job.

String Encoding

The WebPurifyService contains an encodeString closure that is used to encode strings prior to sending them to the web purify services. The default behavior is to substitute XML entities for their corresponding characters in any text or words sent to Web Purify.

characterreplaced with

If custom behavior is needed here, replace the closure in BootStrap.groovy:

class BootStrap {
	def webPurifyService

def init = { servletContext -> webPurifyService.encodeString = { string -> // manpipulate string as needed } } }