@AccessLevel(value=EXTERNAL)
@Implementable
public interface RESTFileValidationHook
This class contains a hook point, which is used by the Doc Service REST APIs when uploading a file. Out of the box, only a dummy implementation is provided, therefore this interface MUST be implemented if using the Doc Service Upload API, unless this functionality is handled elsewhere (for example in a Content Management System or a Gateway).
The validateFile() method is the only method defined in this interface, so the implementation of this method must provide ALL file checking and virus scanning. The type of file checking to be done should include validating the size of the file, validating the file name does not contain paths, validating the file extension, virus scanning etc.
Modifier and Type | Method and Description |
---|---|
void |
validateFile(curam.util.type.Blob fileContents,
java.lang.String fileName)
The validateFile() method is the only method defined in this interface, so
the implementation of this method must provide ALL file checking and virus
scanning.
|
void validateFile(curam.util.type.Blob fileContents, java.lang.String fileName) throws curam.util.exception.AppException, curam.util.exception.InformationalException
The validateFile() method is the only method defined in this interface, so the implementation of this method must provide ALL file checking and virus scanning. The type of file checking to be done should include validating the size of the file, validating the file name does not contain paths, validating the file extension, virus scanning etc.
If an issue with the file is found, an AppException with an appropriate error message should be thrown. The REST infrastructure will handle the App Exception, and will return the error message in the JSON of the response body, along with the correct http error code.
The default implementation of this method may be overwritten using Guice. To do this, a Module class in a custom component (which extends the com.google.inject.AbstractModule class) may be used. In the configure() method, a new custom implementation should be bound to the interface. For example, the configure() method may contain an entry similar to: bind(RESTFileValidation.class).to(RESTFileValidationCustomImpl.class);
Further information about using Guice may be found in the Knowledge Center.
fileContents
- the Blob contents of the file.fileName
- the name of the file, including the file extension.curam.util.exception.AppException
- an exception thrown if the file does not pass all validations,
whose error message will be automatically returned in the error
response of the REST API.curam.util.exception.InformationalException
- generic exception signature.