Skip to main content

Version: 23.10

Virus Scan

The Virus Scan service is used to scan the provided file, and return true if it's virus free.

This service is configured via the Form Details tab on the Virus Scan tab.

Service Invoke Parameters

Parameters are not nullable except where otherwise indicated.

ParameterDescription
svcDefSvcDef
Required. A service definition value object.
fileNameString
Required. The name of the file to scan for viruses.
fileDatabyte[]
Required. The file data of the file to scan for viruses.

Script Result

The script returns a boolean value. The result is true if the file name and data are virus free; otherwise, the result is false.

A runtime exception may occur if there is a configuration error.

Error Handling

If an error occurs when invoking your Virus Scan Groovy script, the error is logged in the Journey Manager database error log, and the user is redirected to the error page on the form space. The transaction is rolled back, and no transaction record is created.

Templates

Service

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')
}
}

Unit Test

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
}
}