Virus Scan
The Virus Scan service is used to scan the provided file and return true if virus free.
The result is true if the file name and data are virus free, otherwise the result is false.
This service is configured via the Form Details tab under Virus Scan tab.
Service Invoke Parameters
Parameter | Description | Nullable |
---|---|---|
svcDef | the service definition value object, see SvcDef | no |
fileName | the file name as String | no |
fileData | the file data as byte[] | no |
Script Result
The script should return boolean value - if true then the file is virus free, otherwise return false.
Runtime exception may occur if there is configuration error.
Error Handling
If an error occurs invoking your Virus Scan Groovy script the error will be logged in the Journey Manager database error log, the user will be redirected to the error page on the form space. The transaction will be rolled back, and no transaction record will be created.
Service Template
This secion shows service template Groovy script.
import com.avoka.core.groovy.GroovyLogger as logger
import com.avoka.tm.vo.*
class FluentVirusScanService {
/*
* Perform a file virus scan
*
* return: true if the file is virus free
*/
boolean invoke(SvcDef svcDef, String fileName, byte[] fileData) {
return !fileName.endsWith('.exe')
}
} ```
<h3>Unit Test Template</h3>
<p>This section shows unit test template Groovy script.</p>
import com.avoka.core.groovy.GroovyLogger as logger import com.avoka.tm.svc.* import com.avoka.tm.vo.* import org.junit.Test
class UnitTest extends AbstractJUnitTest {
/*
* Perform service unit test
*
* throws exception if unit test fails
*/
@Test
void testVirusScan() throws Exception {
Map params = [
"svcDef": svcDef,
"fileName": "filename.txt",
"fileData": "some content".getBytes()
]
boolean result = (boolean) new ServiceInvoker(svcDef).invoke(params)
logger.info "Virus free: " + result
assert result == true
}
}