Class FileContentHandler
- java.lang.Object
-
- com.snowbound.contenthandler.example.FileContentHandler
-
- All Implemented Interfaces:
AllAnnotationsInterface
,AnnotationsInterface
,AvailableDocumentsInterface
,BookmarksInterface
,CacheValidator
,CreateDocumentInterface
,DocumentNotesInterface
,EventSubscriberInterface
,HealthCheckInterface
,OCRDataProviderInterface
,SendDocumentInterface
,VirtualViewerContentHandlerInterface
,WatermarksInterface
public class FileContentHandler extends java.lang.Object implements VirtualViewerContentHandlerInterface, AvailableDocumentsInterface, AllAnnotationsInterface, AnnotationsInterface, BookmarksInterface, CreateDocumentInterface, DocumentNotesInterface, EventSubscriberInterface, SendDocumentInterface, WatermarksInterface, OCRDataProviderInterface, CacheValidator, HealthCheckInterface
This is a sample content handler for demonstration and example purposes. It saves documents and sub-components to the local file system. It should not be used for production instances of VirtualViewer.
-
-
Field Summary
-
Fields inherited from interface com.snowbound.contenthandler.interfaces.VirtualViewerContentHandlerInterface
PERM_CREATE, PERM_DELETE, PERM_EDIT, PERM_HIDDEN, PERM_PRINT, PERM_PRINT_WATERMARK, PERM_REDACTION, PERM_VIEW, PERM_VIEW_WATERMARK
-
-
Constructor Summary
Constructors Constructor Description FileContentHandler()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ContentHandlerResult
checkAvailable(ContentHandlerInput input)
Returns null, or an empty ContentHandlerResult for a successful "healthy" result, or throws a VirtualViewerAPIException for an "unhealthy" result.ContentHandlerResult
createDocument(ContentHandlerInput input)
ContentHandlerResult
deleteAnnotation(ContentHandlerInput input)
Called when the client has requested to delete the specified annotation layer.ContentHandlerResult
deleteBookmarkContent(ContentHandlerInput input)
Delete the bookmark XML content for the specified document key, if it exists.ContentHandlerResult
deleteNotesContent(ContentHandlerInput input)
Called when the client has requested to delete all notes for the specified document.ContentHandlerResult
deleteWatermarkContent(ContentHandlerInput input)
Delete the watermark content for the specified document key, if it exists.ContentHandlerResult
eventNotification(ContentHandlerInput input)
This method is called when some events occur in the VirtualViewer client, such as opening a document or viewing a new page on the document.ContentHandlerResult
getAllAnnotationsForDocument(ContentHandlerInput input)
Returns a map of all of the annotations for a specified document key.ContentHandlerResult
getAnnotationContent(ContentHandlerInput input)
Returns the content for the specified annotation layer and document key in the form of a byte array.ContentHandlerResult
getAnnotationContentFromFile(ContentHandlerInput input)
ContentHandlerResult
getAnnotationNames(ContentHandlerInput input)
Returns an array of annotation layer names for the specified document key and client instance key.ContentHandlerResult
getAnnotationProperties(ContentHandlerInput input)
Returns the properties for a specified annotation layer key in the form of a hashtable.ContentHandlerResult
getAvailableDocumentIds(ContentHandlerInput input)
Returns an array containing the set of document keys available for viewing.ContentHandlerResult
getBookmarkContent(ContentHandlerInput input)
Returns the bookmark XML content for the specified document key in the form of a byte array.ContentHandlerResult
getDocumentContent(ContentHandlerInput input)
Returns the content for the specified document key.ContentHandlerResult
getDocumentContentByFile(ContentHandlerInput input)
ContentHandlerResult
getNotesContent(ContentHandlerInput input)
Returns the contents of the document notes XML file for the specified document key in the form of a byte array.ContentHandlerResult
getOCRDataForDocument(ContentHandlerInput input)
Returns a JSON file, passed as a byte array, of OCRed text data for a document.ContentHandlerResult
getOCRDataOnPerformOCR(ContentHandlerInput input)
Returns a JSON file, passed as a byte array, of OCRed text data for a document.ContentHandlerResult
getWatermarkContent(ContentHandlerInput input)
Returns the watermark file for the specified document key in the form of a byte array.void
init(javax.servlet.ServletConfig config)
Used to set up each content handler instance before any methods are called.ContentHandlerResult
saveAnnotationContent(ContentHandlerInput input)
This method gets called when annotation data for the specified annotation file is ready to be saved.ContentHandlerResult
saveAnnotationContent(javax.servlet.http.HttpServletRequest request, java.lang.String clientInstanceId, java.lang.String documentKey, java.lang.String annotationKey, int pageSpecificIndex, byte[] data, java.util.Map annProperties)
ContentHandlerResult
saveDocumentComponents(ContentHandlerInput input)
This method is used to save or update an existing document and sub-components of the document, such as annotations, bookmarks, document notes and watermarks.ContentHandlerResult
saveDocumentComponentsAs(ContentHandlerInput input)
This method is used to save a copy of a document under a new key, along with sub-components of the document, such as annotations, bookmarks, document notes and watermarks.ContentHandlerResult
saveDocumentContent(ContentHandlerInput input)
This method is used to update document data only.ContentHandlerResult
sendDocumentContent(ContentHandlerInput input)
This method gets called to send a document via a mechanism defined by the content handler.static void
setFilePath(java.lang.String pathParam, javax.servlet.ServletContext context)
static void
setSupportsTiffTagAnnotations(boolean pValue)
ContentHandlerResult
validateCache(ContentHandlerInput input)
This method is called before each document is stored in or retrieved from the VirtualViewer document cache and can confirm the operation or prevent it on a document-by-document basis.
-
-
-
Method Detail
-
init
public void init(javax.servlet.ServletConfig config) throws VirtualViewerAPIException
Description copied from interface:VirtualViewerContentHandlerInterface
Used to set up each content handler instance before any methods are called.- Specified by:
init
in interfaceVirtualViewerContentHandlerInterface
- Parameters:
config
- The ServletConfig object for the VirtualViewer server. Can be used to retrieve web.xml parameters.- Throws:
VirtualViewerAPIException
- if content handler throws exception
-
setFilePath
public static void setFilePath(java.lang.String pathParam, javax.servlet.ServletContext context)
-
getAnnotationNames
public ContentHandlerResult getAnnotationNames(ContentHandlerInput input) throws VirtualViewerAPIException
Description copied from interface:AnnotationsInterface
Returns an array of annotation layer names for the specified document key and client instance key.
Example:
public ContentHandlerResult getAnnotationNames(ContentHandlerInput input) throws VirtualViewerAPIException { String clientInstanceId = input.getClientInstanceId(); String documentKey = input.getDocumentId(); String[] arrayNames = new String[2]; arrayNames[0] = "layerOne"; arrayNames[1] = "layerTwo"; ContentHandlerResult result = new ContentHandlerResult(); result.put(ContentHandlerResult.KEY_ANNOTATION_NAMES, arrayNames); return result; }
- Specified by:
getAnnotationNames
in interfaceAnnotationsInterface
- Parameters:
input
- ContentHandlerInput containing the following values:Every row is an expected value in the ContentHandlerInput. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_DOCUMENT_ID java.lang.String The key representing the document. Can be retrieved with String documentId = input.getDocumentId();
.KEY_CLIENT_INSTANCE_ID java.lang.String Custom configurable value used to pass data from client to content handler. If not set then will be the session ID. Can be retrieved with String clientInstanceId = input.getClientInstanceId();
KEY_HTTP_SERVLET_REQUEST javax.servlet.http.HttpServletRequest Request that called this method. Can be retrieved with HttpServletRequest request = input.getHttpServletRequest();
- Returns:
- ContentHandlerResult with the following values:
Every row is an expected value in the ContentHandlerResult. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_ANNOTATION_NAMES java.lang.String[] An array of all the annotation layer keys for the document. - Throws:
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an error- See Also:
AnnotationsInterface.getAnnotationNames(ContentHandlerInput)
-
saveAnnotationContent
public ContentHandlerResult saveAnnotationContent(ContentHandlerInput input) throws VirtualViewerAPIException
Description copied from interface:AnnotationsInterface
This method gets called when annotation data for the specified annotation file is ready to be saved.- Specified by:
saveAnnotationContent
in interfaceAnnotationsInterface
- Parameters:
input
- ContentHandlerInput containing the following values:Every row is an expected value in the ContentHandlerInput. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_ANNOTATION_ID java.lang.String The key for the annotation layer to be saved. Can be retrieved with String annotationId = input.getAnnotationId();
.KEY_ANNOTATION_CONTENT byte[] Annnotation data to be saved. Can be retrieved with byte[] annotationContent = input.getAnnotationContent();
.KEY_ANNOTATION_PROPERTIES java.util.Hashtable Map of annotation properties to be saved. Can be retrieved with Hashtable annotationProperties = input.getAnnotationProperties();
.KEY_DOCUMENT_ID java.lang.String The key representing the document. Can be retrieved with String documentId = input.getDocumentId();
.KEY_CLIENT_INSTANCE_ID java.lang.String Custom configurable value used to pass data from client to content handler. If not set then will be the session ID. Can be retrieved with String clientInstanceId = input.getClientInstanceId();
KEY_HTTP_SERVLET_REQUEST javax.servlet.http.HttpServletRequest Request that called this method. Can be retrieved with HttpServletRequest request = input.getHttpServletRequest();
- Returns:
- ContentHandlerResult with no values currently expected.
- Throws:
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an error- See Also:
AnnotationsInterface.saveAnnotationContent(ContentHandlerInput)
-
saveAnnotationContent
public ContentHandlerResult saveAnnotationContent(javax.servlet.http.HttpServletRequest request, java.lang.String clientInstanceId, java.lang.String documentKey, java.lang.String annotationKey, int pageSpecificIndex, byte[] data, java.util.Map annProperties) throws VirtualViewerAPIException
- Throws:
VirtualViewerAPIException
-
saveDocumentComponents
public ContentHandlerResult saveDocumentComponents(ContentHandlerInput input) throws VirtualViewerAPIException
Description copied from interface:VirtualViewerContentHandlerInterface
This method is used to save or update an existing document and sub-components of the document, such as annotations, bookmarks, document notes and watermarks. In earlier versions, VirtualViewer would pass null to signal that a component should be deleted. Currently, VirtualViewer will pass null to signal that no change should be made to a component.- Specified by:
saveDocumentComponents
in interfaceVirtualViewerContentHandlerInterface
- Parameters:
input
- ContentHandlerInput containing the following values:Every row is an expected value in the ContentHandlerInput. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_DOCUMENT_CONTENT byte[] The document file content. If null no changes need to be saved to the document. Can be retrieved with byte[] documentContent= input.getDocumentContent();
.KEY_ANNOTATION_LAYERS com.snowbound.common.transport.AnnotationLayer[] All of the annotation layers for the document. Each layer should be updated if it layer.isNew() or isModified() is true. If a layer has been saved but is no longer present in the array it may be deleted; if a layer name is present in KEY_DELETED_ANNOTATION_LAYERS but absent from this list of layers, the layer was deleted by the user. If a layer name is absent from both this list of layers and from KEY_DELETED_ANNOTATION_LAYERS, that may indicate that the user never loaded or viewed the layer during their session. Can be retrieved with AnnotationLayer[] annotationLayers= input.getAnnotationLayers();
.KEY_DELETED_ANNOTATION_LAYERS String[] Any annotation layers that were removed during the user's session. This item is present for extra information and validation. If a layer name is present in this array but absent from the list in KEY_ANNOTATION_LAYERS, the layer was deleted by the user. If a layer name is absent from both this array and from KEY_ANNOTATION_LAYERS, that may indicate that the user never loaded or viewed the layer during their session. Can be retrieved with String[] layersDeletedInSession = input.getDeletedAnnotationLayers();
.KEY_BOOKMARK_CONTENT byte[] The bookmark file content. If null no changes need to be saved to the bookmark file. Can be retrieved with byte[] bookmarkContent= input.getBookmarkContent();
.KEY_NOTES_CONTENT byte[] The notes file content. If null no changes need to be saved to the notes file. Can be retrieved with byte[] notesContent = input.getNotesContent();
.KEY_WATERMARK_CONTENT byte[] The watermark file content. If null no changes need to be saved to the watermark file. Can be retrieved with byte[] watermarkContent = input.getWatermarkContent();
.KEY_PAGE_COUNT int The number of pages in the document. Can be retrieved with int pageCount = input.getDocumentPageCount();
.KEY_DOCUMENT_FORMAT int An integer code representing the document format. Can be retrieved along with a format information object with the following code: int formatCode = input.getDocumentFormat(); Format format = VirtualViewerFormatHash.getInstance().getFormat(outputFormat);
KEY_DOCUMENT_ID java.lang.String The key representing the document. Can be retrieved with String documentId = input.getDocumentId();
.KEY_CLIENT_INSTANCE_ID java.lang.String Custom configurable value used to pass data from client to content handler. If not set then will be the session ID. Can be retrieved with String clientInstanceId = input.getClientInstanceId();
KEY_HTTP_SERVLET_REQUEST javax.servlet.http.HttpServletRequest Request that called this method. Can be retrieved with HttpServletRequest request = input.getHttpServletRequest();
- Returns:
- ContentHandlerResult with the following values:
Every row is an expected value in the ContentHandlerResult. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description DOCUMENT_ID_TO_RELOAD String Optional return used to alert the client that the document key has been changed when saving. This could be used if the content handler decided to create a new document under a new key instead of updating the original document. - Throws:
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an error- See Also:
VirtualViewerContentHandlerInterface.saveDocumentComponents(ContentHandlerInput)
-
saveDocumentComponentsAs
public ContentHandlerResult saveDocumentComponentsAs(ContentHandlerInput input) throws VirtualViewerAPIException
Description copied from interface:VirtualViewerContentHandlerInterface
This method is used to save a copy of a document under a new key, along with sub-components of the document, such as annotations, bookmarks, document notes and watermarks.- Specified by:
saveDocumentComponentsAs
in interfaceVirtualViewerContentHandlerInterface
- Parameters:
input
- ContentHandlerInput containing the following values:Every row is an expected value in the ContentHandlerInput. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_DOCUMENT_CONTENT byte[] The document file content. If null no changes need to be saved to the document. Can be retrieved with byte[] documentContent= input.getDocumentContent();
.KEY_ANNOTATION_LAYERS com.snowbound.common.transport.AnnotationLayer[] All of the annotation layers for the document. If not null all layers should be saved for the new document. Can be retrieved with AnnotationLayer[] annotationLayers= input.getAnnotationLayers();
.KEY_BOOKMARK_CONTENT byte[] The bookmark file content. If null no bookmark file need be saved. Can be retrieved with byte[] bookmarkContent= input.getBookmarkContent();
.KEY_NOTES_CONTENT byte[] The notes file content. If null no notes file need be saved. Can be retrieved with byte[] notesContent = input.getNotesContent();
.KEY_WATERMARK_CONTENT byte[] The watermark file content. If null no watermark file need be saved. Can be retrieved with byte[] watermarkContent = input.getWatermarkContent();
.KEY_PAGE_COUNT int The number of pages in the document. Can be retrieved with int pageCount = input.getDocumentPageCount();
.KEY_DOCUMENT_FORMAT int An integer code representing the document format. Can be retrieved along with a format information object with the following code: int formatCode = input.getDocumentFormat(); Format format = VirtualViewerFormatHash.getInstance().getFormat(outputFormat);
KEY_DOCUMENT_ID java.lang.String A temporary key based on the original document's display name. Can be retrieved with String documentId = input.getDocumentId();
.KEY_CLIENT_INSTANCE_ID java.lang.String Custom configurable value used to pass data from client to content handler. If not set then will be the session ID. Can be retrieved with String clientInstanceId = input.getClientInstanceId();
KEY_HTTP_SERVLET_REQUEST javax.servlet.http.HttpServletRequest Request that called this method. Can be retrieved with HttpServletRequest request = input.getHttpServletRequest();
- Returns:
- ContentHandlerResult with the following values:
Every row is an expected value in the ContentHandlerResult. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description DOCUMENT_ID_TO_RELOAD String Optional return used to alert the client that the document key has been changed when saving. VirtualViewer will send a temporary document key in the input based on the original document's display name, but if that is being changed then this return value should be set. - Throws:
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an error- See Also:
VirtualViewerContentHandlerInterface.saveDocumentComponentsAs(ContentHandlerInput)
-
createDocument
public ContentHandlerResult createDocument(ContentHandlerInput input) throws VirtualViewerAPIException
- Specified by:
createDocument
in interfaceCreateDocumentInterface
- Parameters:
input
- ContentHandlerInput containing the following values:Every row is an expected value in the ContentHandlerInput. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_DOCUMENT_CONTENT byte[] The new document's data to be saved. Can be retrieved with byte[] data = input.getDocumentContent();
.KEY_DOCUMENT_ID java.lang.String The key the new document should be saved under. Can be retrieved with String documentId = input.getDocumentId();
.KEY_CLIENT_INSTANCE_ID java.lang.String Custom configurable value used to pass data from client to content handler. If not set then will be the session ID. Can be retrieved with String clientInstanceId = input.getClientInstanceId();
KEY_HTTP_SERVLET_REQUEST javax.servlet.http.HttpServletRequest Request that called this method. Can be retrieved with HttpServletRequest request = input.getHttpServletRequest();
- Returns:
- ContentHandlerResult with no values currently expected.
- Throws:
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an error- See Also:
CreateDocumentInterface.createDocument(com.snowbound.contenthandler.ContentHandlerInput)
-
saveDocumentContent
public ContentHandlerResult saveDocumentContent(ContentHandlerInput input) throws VirtualViewerAPIException
Description copied from interface:VirtualViewerContentHandlerInterface
This method is used to update document data only.- Specified by:
saveDocumentContent
in interfaceVirtualViewerContentHandlerInterface
- Parameters:
input
- ContentHandlerInput containing the following values:Every row is an expected value in the ContentHandlerInput. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_DOCUMENT_CONTENT byte[] The document file content. Can be retrieved with byte[] documentContent= input.getDocumentContent();
.KEY_DOCUMENT_ID java.lang.String The key representing the document. Can be retrieved with String documentId = input.getDocumentId();
.KEY_CLIENT_INSTANCE_ID java.lang.String Custom configurable value used to pass data from client to content handler. If not set then will be the session ID. Can be retrieved with String clientInstanceId = input.getClientInstanceId();
KEY_HTTP_SERVLET_REQUEST javax.servlet.http.HttpServletRequest Request that called this method. Can be retrieved with HttpServletRequest request = input.getHttpServletRequest();
- Returns:
- ContentHandlerResult with the following values:
Every row is an expected value in the ContentHandlerResult. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description DOCUMENT_ID_TO_RELOAD String Optional return used to alert the client that the document key has been changed when saving. This could be used if the content handler decided to create a new document under a new key instead of updating the original document. - Throws:
VirtualViewerAPIException
- if content handler throws exception- See Also:
VirtualViewerContentHandlerInterface.saveDocumentContent(ContentHandlerInput)
-
getAnnotationContent
public ContentHandlerResult getAnnotationContent(ContentHandlerInput input) throws VirtualViewerAPIException
Description copied from interface:AnnotationsInterface
Returns the content for the specified annotation layer and document key in the form of a byte array.
Example:
// This example retrieves the annotation layer data from the local filesystem. The annotation file is assumed to // be in a file named with the form <documentKey>.<annotationLayerKey>.ann. public ContentHandlerResult getAnnotationContent(ContentHandlerInput input) throws VirtualViewerAPIException { String clientInstanceId = input.getClientInstanceId(); String documentKey = input.getDocumentId(); String annotationKey = input.getAnnotationId(); String annotationFilename = documentKey + "." + annotationKey + ".ann"; String fullFilePath = gFilePath + annotationFilename; try { File file = new File(fullFilePath); byte[] bytes = getFileBytes(file); ContentHandlerResult result = new ContentHandlerResult(); result.put(ContentHandlerResult.KEY_ANNOTATION_CONTENT, bytes); return result; } catch (IOException e) { return null; } }
- Specified by:
getAnnotationContent
in interfaceAnnotationsInterface
- Parameters:
input
- ContentHandlerInput containing the following values:Every row is an expected value in the ContentHandlerInput. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_ANNOTATION_ID java.lang.String The key for the requested annotation layer. Can be retrieved with String annotationId = input.getAnnotationId();
.KEY_DOCUMENT_ID java.lang.String The key representing the document. Can be retrieved with String documentId = input.getDocumentId();
.KEY_CLIENT_INSTANCE_ID java.lang.String Custom configurable value used to pass data from client to content handler. If not set then will be the session ID. Can be retrieved with String clientInstanceId = input.getClientInstanceId();
KEY_HTTP_SERVLET_REQUEST javax.servlet.http.HttpServletRequest Request that called this method. Can be retrieved with HttpServletRequest request = input.getHttpServletRequest();
- Returns:
- ContentHandlerResult with the following values:
Every row is an expected value in the ContentHandlerResult. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_ANNOTATION_CONTENT byte[] Contents of the annotation layer file. - Throws:
VirtualViewerAPIException
- if content handler throws exception- See Also:
AnnotationsInterface.getAnnotationContent(ContentHandlerInput)
-
getAnnotationContentFromFile
public ContentHandlerResult getAnnotationContentFromFile(ContentHandlerInput input) throws VirtualViewerAPIException
- Throws:
VirtualViewerAPIException
-
getAnnotationProperties
public ContentHandlerResult getAnnotationProperties(ContentHandlerInput input) throws VirtualViewerAPIException
Description copied from interface:AnnotationsInterface
Returns the properties for a specified annotation layer key in the form of a hashtable. Consult the "Annotation Security FlexSnap: SI Specification" for more details.- Specified by:
getAnnotationProperties
in interfaceAnnotationsInterface
- Parameters:
input
- ContentHandlerInput containing the following values:Every row is an expected value in the ContentHandlerInput. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_ANNOTATION_ID java.lang.String The key for the requested annotation layer. Can be retrieved with String annotationId = input.getAnnotationId();
.KEY_DOCUMENT_ID java.lang.String The key representing the document. Can be retrieved with String documentId = input.getDocumentId();
.KEY_CLIENT_INSTANCE_ID java.lang.String Custom configurable value used to pass data from client to content handler. If not set then will be the session ID. Can be retrieved with String clientInstanceId = input.getClientInstanceId();
KEY_HTTP_SERVLET_REQUEST javax.servlet.http.HttpServletRequest Request that called this method. Can be retrieved with HttpServletRequest request = input.getHttpServletRequest();
- Returns:
- ContentHandlerResult with the following values:
Every row is an expected value in the ContentHandlerResult. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_ANNOTATION_PROPERTIES java.util.Hashtable Map of the specified annotation layer's properties - Throws:
VirtualViewerAPIException
- if content handler throws exception- See Also:
AnnotationsInterface.getAnnotationProperties(ContentHandlerInput)
-
getBookmarkContent
public ContentHandlerResult getBookmarkContent(ContentHandlerInput input) throws VirtualViewerAPIException
Description copied from interface:BookmarksInterface
Returns the bookmark XML content for the specified document key in the form of a byte array.- Specified by:
getBookmarkContent
in interfaceBookmarksInterface
- Parameters:
input
- ContentHandlerInput containing the following values:Every row is an expected value in the ContentHandlerInput. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_DOCUMENT_ID java.lang.String The key representing the document. Can be retrieved with String documentId = input.getDocumentId();
.KEY_CLIENT_INSTANCE_ID java.lang.String Custom configurable value used to pass data from client to content handler. If not set then will be the session ID. Can be retrieved with String clientInstanceId = input.getClientInstanceId();
KEY_HTTP_SERVLET_REQUEST javax.servlet.http.HttpServletRequest Request that called this method. Can be retrieved with HttpServletRequest request = input.getHttpServletRequest();
- Returns:
- ContentHandlerResult with the following values:
Every row is an expected value in the ContentHandlerResult. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_BOOKMARK_CONTENT byte[] Contents of the bookmark XML file, or null if no bookmarks are associated with the given document. - Throws:
VirtualViewerAPIException
- if content handler throws exception- See Also:
BookmarksInterface.getBookmarkContent(ContentHandlerInput)
-
deleteBookmarkContent
public ContentHandlerResult deleteBookmarkContent(ContentHandlerInput input) throws VirtualViewerAPIException
Description copied from interface:BookmarksInterface
Delete the bookmark XML content for the specified document key, if it exists. If it does not exist no action is needed.- Specified by:
deleteBookmarkContent
in interfaceBookmarksInterface
- Parameters:
input
- ContentHandlerInput containing the following values:Every row is an expected value in the ContentHandlerInput. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_DOCUMENT_ID java.lang.String The key representing the document. Can be retrieved with String documentId = input.getDocumentId();
.KEY_CLIENT_INSTANCE_ID java.lang.String Custom configurable value used to pass data from client to content handler. If not set then will be the session ID. Can be retrieved with String clientInstanceId = input.getClientInstanceId();
KEY_HTTP_SERVLET_REQUEST javax.servlet.http.HttpServletRequest Request that called this method. Can be retrieved with HttpServletRequest request = input.getHttpServletRequest();
- Returns:
- ContentHandlerResult with no values currently expected.
- Throws:
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an error- See Also:
BookmarksInterface.deleteBookmarkContent(com.snowbound.contenthandler.ContentHandlerInput)
-
getWatermarkContent
public ContentHandlerResult getWatermarkContent(ContentHandlerInput input) throws VirtualViewerAPIException
Description copied from interface:WatermarksInterface
Returns the watermark file for the specified document key in the form of a byte array.- Specified by:
getWatermarkContent
in interfaceWatermarksInterface
- Parameters:
input
- ContentHandlerInput containing the following values:Every row is an expected value in the ContentHandlerInput. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_DOCUMENT_ID java.lang.String The key representing the document. Can be retrieved with String documentId = input.getDocumentId();
.KEY_CLIENT_INSTANCE_ID java.lang.String Custom configurable value used to pass data from client to content handler. If not set then will be the session ID. Can be retrieved with String clientInstanceId = input.getClientInstanceId();
KEY_HTTP_SERVLET_REQUEST javax.servlet.http.HttpServletRequest Request that called this method. Can be retrieved with HttpServletRequest request = input.getHttpServletRequest();
- Returns:
- ContentHandlerResult with the following values:
Every row is an expected value in the ContentHandlerResult. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_WATERMARK_CONTENT byte[] Contents of the watermark file for this document, or null if no watermarks have been saved. - Throws:
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an error- See Also:
WatermarksInterface.getWatermarkContent(ContentHandlerInput)
-
deleteWatermarkContent
public ContentHandlerResult deleteWatermarkContent(ContentHandlerInput input) throws VirtualViewerAPIException
Description copied from interface:WatermarksInterface
Delete the watermark content for the specified document key, if it exists. If it does not exist no action is needed.- Specified by:
deleteWatermarkContent
in interfaceWatermarksInterface
- Parameters:
input
- ContentHandlerInput containing the following values:Every row is an expected value in the ContentHandlerInput. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_DOCUMENT_ID java.lang.String The key representing the document. Can be retrieved with String documentId = input.getDocumentId();
.KEY_CLIENT_INSTANCE_ID java.lang.String Custom configurable value used to pass data from client to content handler. If not set then will be the session ID. Can be retrieved with String clientInstanceId = input.getClientInstanceId();
KEY_HTTP_SERVLET_REQUEST javax.servlet.http.HttpServletRequest Request that called this method. Can be retrieved with HttpServletRequest request = input.getHttpServletRequest();
- Returns:
- ContentHandlerResult with no values currently expected.
- Throws:
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an error- See Also:
WatermarksInterface.deleteWatermarkContent(ContentHandlerInput)
-
getNotesContent
public ContentHandlerResult getNotesContent(ContentHandlerInput input) throws VirtualViewerAPIException
Description copied from interface:DocumentNotesInterface
Returns the contents of the document notes XML file for the specified document key in the form of a byte array.- Specified by:
getNotesContent
in interfaceDocumentNotesInterface
- Parameters:
input
- ContentHandlerInput containing the following values:Every row is an expected value in the ContentHandlerInput. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_DOCUMENT_ID java.lang.String The key representing the document. Can be retrieved with String documentId = input.getDocumentId();
.KEY_CLIENT_INSTANCE_ID java.lang.String Custom configurable value used to pass data from client to content handler. If not set then will be the session ID. Can be retrieved with String clientInstanceId = input.getClientInstanceId();
KEY_HTTP_SERVLET_REQUEST javax.servlet.http.HttpServletRequest Request that called this method. Can be retrieved with HttpServletRequest request = input.getHttpServletRequest();
- Returns:
- ContentHandlerResult with the following values:
Every row is an expected value in the ContentHandlerResult. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_NOTES_CONTENT byte[] Contents of the document notes XML file, or null if no document notes have been saved. - Throws:
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an error- See Also:
DocumentNotesInterface.getNotesContent(ContentHandlerInput)
-
deleteNotesContent
public ContentHandlerResult deleteNotesContent(ContentHandlerInput input) throws VirtualViewerAPIException
Description copied from interface:DocumentNotesInterface
Called when the client has requested to delete all notes for the specified document.- Specified by:
deleteNotesContent
in interfaceDocumentNotesInterface
- Parameters:
input
- ContentHandlerInput containing the following values:Every row is an expected value in the ContentHandlerInput. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_DOCUMENT_ID java.lang.String The key representing the document. Can be retrieved with String documentId = input.getDocumentId();
.KEY_CLIENT_INSTANCE_ID java.lang.String Custom configurable value used to pass data from client to content handler. If not set then will be the session ID. Can be retrieved with String clientInstanceId = input.getClientInstanceId();
KEY_HTTP_SERVLET_REQUEST javax.servlet.http.HttpServletRequest Request that called this method. Can be retrieved with HttpServletRequest request = input.getHttpServletRequest();
- Returns:
- ContentHandlerResult with no values currently expected.
- Throws:
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an error- See Also:
DocumentNotesInterface.deleteNotesContent(ContentHandlerInput)
-
getDocumentContent
public ContentHandlerResult getDocumentContent(ContentHandlerInput input) throws VirtualViewerAPIException
Description copied from interface:VirtualViewerContentHandlerInterface
Returns the content for the specified document key. The content is usually returned as a byte array, but it can also be a stream or a File object; it can also be a list of byte arrays, streams, or File objects to represent a document made of multiple parts. (VirtualViewer refers to these parts as "content elements").
VirtualViewer is entirely agnostic about the source of document content. It can come from the local file system, a remote system, a database, or any other source as long as your content handler can provide data to VirtualViewer in any of its supported forms.
Another note is that the content handler does not need to be consistent between documents. Any individual document should be returned in the same form each request, but different documents do not need to use the same form. The same content handler can return one document as a byte array, a second as a stream, a third as several components, and yet another in sparse form.
Single-content element returnThis is the most common use case - a single file represents a single document. This file can be returned as a byte array, InputStream, or File object - although the first two forms are recommended.
// This example retrieves the document content from a specific directory in the local filesystem. public ContentHandlerResult getDocumentContent(ContentHandlerInput input) throws VirtualViewerAPIException { String clientInstanceId = input.getClientInstanceId(); String documentKey = input.getDocumentId(); String fullFilePath = gFilePath + URLDecoder.decode(documentKey); File file = new File(fullFilePath); byte[] fileBytes = com.snowbound.common.utils.ClientServerIO.getFileBytes(file); ContentHandlerResult result = new ContentHandlerResult(); result.put(ContentHandlerResult.KEY_DOCUMENT_CONTENT, fileBytes); return result; }
Compound documentsUsing compound documents, you can make a single VirtualViewer document composed of multiple files of different formats. For example, if you provide a PDF and an image file in that order, VirtualViewer will treat it as one document with the image file as the last page.
Document modifications, such as rotating or inserting/deleting pages, cannot be done to a compound document without converting it to a single-file document (either a PDF or a TIF, depending on if the first content element was a text or image file).
To return a compound document, return several content elements in the KEY_DOCUMENT_CONTENT_ELEMENTS parameter. These can be either a byte array, input stream or File and the items in the list do not have to all match. If only one content element is returned it will functionally be the same as a single-content element document described above.
// This example retrieves document content from the local file system and adds the same cover page to every // requested document by returning them as a compound document. public ContentHandlerResult getDocumentContent(ContentHandlerInput input) throws VirtualViewerAPIException { String clientInstanceId = input.getClientInstanceId(); String documentKey = input.getDocumentId(); List<Object> contentElements = new List<Object>(); //Adding the cover page first will make it the first page(s) of the document InputStream coverPage = getCoverPageStream(); contentElements.put(coverPage); //Add the file content from the local system next String fullFilePath = gFilePath + URLDecoder.decode(documentKey); File file = new File(fullFilePath); byte[] fileBytes = com.snowbound.common.utils.ClientServerIO.getFileBytes(file); contentElements.put(fileBytes); ContentHandlerResult result = new ContentHandlerResult(); result.put(ContentHandlerResult.KEY_DOCUMENT_CONTENT_ELEMENTS, contentElements); return result; }
Sparse documentsSparse documents are a special case of compound document. In this case, every content element represents a single page, and each page/content element can be requested and returned in separate chunks as needed. The ideal use case for sparse documents is when a) the document is already split up into single-page files and b) retrieving each page is relatively time-expensive, making retrieving the whole document prohibitive. An example use case could be if a physical document was scanned and converted to a series of large image files, one for each page, and those files were stored on a remote server with a poor connection. Retrieving all of those image files at once may be prohibitive; the document could be represented in sparse form to avoid that cost.
To implement sparse documents you will need to read the KEY_SPARSE_PAGE_INDEX value from input and return at least that page. The index is zero-based. Several additional pages around that page can also be returned - VirtualViewer will cache each page as it retrieves it, so returning additional pages will help limit future requests from VirtualViewer. VirtualViewer suggests an amount of pages to return with KEY_SPARSE_PAGE_COUNT but the suggestion is not required.
Note: if KEY_SPARSE_PAGE_INDEX's value is null then all sparse page elements must be returned. This is for operations that require the entire document, such as emailing or printing. All page elements should be returned in the same way as a partial sparse document: using KEY_DOCUMENT_SPARSE_ELEMENTS.
When returning a sparse document, four values should be returned: the list of sparse content elements, the zero-based page index the returned pages start at, the number of pages being returned, and the total number of pages in the document.
Note: sparse document content elements do not support the File object. Each content element should be a byte array or input stream.
// This example assumes the existence of a function that returns a single page of the document. To fit the best // use case of sparse documents, this function should be relatively expensive, so calling it for each page of // the document is not ideal. public ContentHandlerResult getDocumentContent(ContentHandlerInput input) throws VirtualViewerAPIException { String clientInstanceId = input.getClientInstanceId(); String documentKey = input.getDocumentId(); Integer requestedPageIndex = input.get(ContentHandlerInput.KEY_SPARSE_PAGE_INDEX); List<byte[]> sparseElements = new List<byte[]>(); int documentPageCount = getDocumentPageCount(documentKey); int startPageIndex = 0; int returnPageCount = documentPageCount; //If KEY_SPARSE_PAGE_INDEX is null, all pages should be returned. If it is set then we will return the requested //page and the two next pages. if(requestedPageIndex != null) { startPageIndex = requestedPageIndex; returnPageCount = 3; //Make sure not to request more pages than the document has if(startPageIndex + returnPageCount > documentPageCount) { returnPageCount = documentPageCount - startPageIndex; } } for(int index = startPageIndex; index < startPageIndex + returnPageCount; index++) { byte[] documentPage = getSingleDocumentPage(documentKey, index); sparseElements.put(documentPage); } ContentHandlerResult result = new ContentHandlerResult(); result.put(ContentHandlerResult.KEY_DOCUMENT_SPARSE_ELEMENTs, sparseElements); result.put(ContentHandlerResult.KEY_DOCUMENT_SPARSE_PAGE_INDEX, startPageIndex); result.put(ContentHandlerResult.KEY_DOCUMENT_SPARSE_RETURN_PAGE_COUNT, returnPageCount); // For this example we are assuming each document is exactly 10 pages long. // In actual code the real length should be returned. result.put(ContentHandlerResult.KEY_DOCUMENT_SPARSE_TOTAL_PAGE_COUNT, 10); return result; }
Media documentsVirtualViewer supports video and audio files. Most media files that are supported by modern browsers are supported by VirtualViewer. Not all browsers support the same media types and encodings: see the compatibility chart at https://developer.mozilla.org/en-US/docs/Web/HTML/Supported_media_formats for more details.
If the media format and specific file support streaming, VirtualViewer will stream the media to the browser. In addition, the media file can be streamed from this method to avoid a long initial delay while loading the full media file from the end content store. To stream from this method, return an InputStream that is progressively loading from the end content store. VirtualViewer will read from and cache the stream's data in the background while streaming the file to the client browser as soon as there is enough data to do so.
// This is an example of one way to return a progressively-loading InputStream by using Java's basic URL library // to download a video file over HTTP. InputStream mediaStream = new URL("http://example.com/MyMedia.mp4").openStream(); // VirtualViewer will continously read data from this stream until the file is downloaded, // while also streaming the media to the requesting client browser. result.put(ContentHandlerResult.KEY_DOCUMENT_INPUT_STREAM, mediaStream); result.put(ContentHandlerResult.KEY_DOCUMENT_DISPLAY_NAME, "My Media"); // We should not close the stream in getDocumentContent: VirtualViewer will close the stream once it is completed. return result;
Note: VirtualViewer uses a thread pool to read from the document InputStreams that are returned from this function. This thread pool is configurable via the "asyncStreamBuffer" web.xml init-params. It is strongly recommended that you configure this thread pool to fit your needs and system specifications.
Note: media documents do not support compound documents,multiple content elements or the File content element. Media documents should always be returned as a single byte[] or an InputStream. Media files cannot be included as part of a separate compound document.
CAD/DWG files - including external referencesVirtualViewer supports external references for CAD/DWG files. The external reference files must be returned as a list of
ExternalReference
objects.Note: This feature is currently only supported when running the VirtualViewer server on Windows.
- Specified by:
getDocumentContent
in interfaceVirtualViewerContentHandlerInterface
- Parameters:
input
- ContentHandlerInput containing the following values:Every row is an expected value in the ContentHandlerInput. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_DOCUMENT_ID java.lang.String The key representing the document. Can be retrieved with String documentId = input.getDocumentId();
.KEY_CLIENT_INSTANCE_ID java.lang.String Custom configurable value used to pass data from client to content handler. If not set then will be the session ID. Can be retrieved with String clientInstanceId = input.getClientInstanceId();
KEY_HTTP_SERVLET_REQUEST javax.servlet.http.HttpServletRequest Request that called this method. Can be retrieved with HttpServletRequest request = input.getHttpServletRequest();
KEY_SPARSE_PAGE_INDEX Integer The specific page index being requested. This parameter is used only for sparse documents. If this parameter is null, the entire document should be returned, even for sparse documents. (For sparse documents this should be in the form of a complete KEY_DOCUMENT_SPARSE_ELEMENTS list). Can be retrieved with int pageIndex = input.getSparseRequestedPageNumber();
KEY_SPARSE_PAGE_COUNT int Suggested number of pages to return for a sparse document. This does not have to be respected. Can be retrieved with int pageCount = input.getSparseRequestedPageCount();
- Returns:
- ContentHandlerResult with the following values:
Every row is an expected value in the ContentHandlerResult. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_DOCUMENT_DISPLAY_NAME String The name VirtualViewer should display for this document. If omitted VirtualViewer will display the document key instead. KEY_DOCUMENT_CONTENT byte[] A byte array of the document content. Only one document content return parameter should be set. KEY_DOCUMENT_INPUT_STREAM java.io.InputStream An input stream of the document content. Only one document content return parameter should be set. KEY_DOCUMENT_FILE java.io.File A File object referencing the document content file. Using KEY_DOCUMENT_CONTENT or KEY_DOCUMENT_INPUT_STREAM is recommended for efficiency. Only one document content return parameter should be set. KEY_DOCUMENT_CONTENT_ELEMENTS java.util.List A list of content elements - byte arrays, input streams or File objects. They do not have to be in the same form, nor do the original files need to be the same image or document format (a content element list consisting of a JPEG byte array and a PDF input stream is acceptable). VirtualViewer will treat all of the content elements as if they formed one contiguous document.
If a list containing only one content element is returned, it will behave exactly as the single-content element cases above.
Only one document content return parameter should be set.
KEY_DOCUMENT_SPARSE_ELEMENTS java.util.List A parameter required for sparse documents. A list of single-page content elements - byte arrays or input streams only. File objects are not supported.
If one of the content elements is of a format that supports multiple pages, such as PDF, it must be one page. Any pages beyond the first will be ignored by VirtualViewer.
Only one document content return parameter should be set.
KEY_DOCUMENT_SPARSE_PAGE_INDEX java.util.List A parameter required for sparse documents. The zero-based page index at which the collection of returned pages start. For example, if page index 5 is requested and you are returning pages 5-8, this should equal 5. KEY_DOCUMENT_SPARSE_RETURN_PAGE_COUNT java.util.List A parameter required for sparse documents. The number of pages you are returning with this method. For example, if page index 5 is requested and you are returning pages 5-8, this should return 4. KEY_DOCUMENT_SPARSE_TOTAL_PAGE_COUNT java.util.List A parameter required for sparse documents. The total number of pages in the sparse document. This should be the same in each request for a given document. For example, when a 300-page-long document is requested, this should be 300 - regardless of how many pages are being returned for the request. KEY_EXTERNAL_REFERENCE_CONTENT_ELEMENTS java.util.List< ExternalReference
>A list of external references for CAD/DWG files. - Throws:
VirtualViewerAPIException
- if content handler throws exception- See Also:
VirtualViewerContentHandlerInterface.getDocumentContent(ContentHandlerInput)
-
getDocumentContentByFile
public ContentHandlerResult getDocumentContentByFile(ContentHandlerInput input) throws VirtualViewerAPIException
- Throws:
VirtualViewerAPIException
-
deleteAnnotation
public ContentHandlerResult deleteAnnotation(ContentHandlerInput input) throws VirtualViewerAPIException
Description copied from interface:AnnotationsInterface
Called when the client has requested to delete the specified annotation layer.- Specified by:
deleteAnnotation
in interfaceAnnotationsInterface
- Parameters:
input
- ContentHandlerInput containing the following values:Every row is an expected value in the ContentHandlerInput. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_ANNOTATION_ID java.lang.String The key for the annotation layer to be deleted. Can be retrieved with String annotationId = input.getAnnotationId();
.KEY_DOCUMENT_ID java.lang.String The key representing the document. Can be retrieved with String documentId = input.getDocumentId();
.KEY_CLIENT_INSTANCE_ID java.lang.String Custom configurable value used to pass data from client to content handler. If not set then will be the session ID. Can be retrieved with String clientInstanceId = input.getClientInstanceId();
KEY_HTTP_SERVLET_REQUEST javax.servlet.http.HttpServletRequest Request that called this method. Can be retrieved with HttpServletRequest request = input.getHttpServletRequest();
- Returns:
- ContentHandlerResult with no values currently expected.
- Throws:
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an error- See Also:
AnnotationsInterface.deleteAnnotation(ContentHandlerInput)
-
getAvailableDocumentIds
public ContentHandlerResult getAvailableDocumentIds(ContentHandlerInput input) throws VirtualViewerAPIException
Description copied from interface:AvailableDocumentsInterface
Returns an array containing the set of document keys available for viewing. This is used to populate the list of available documents in the thumbnail display in VirtualViewer. It is not required for retrieving documents - documents can still be retrieved by specifying the document key from the client instead of choosing an available document from this list.
Example:
// This example retrieves all of the filenames in a specific directory as available documents public ContentHandlerResult getAvailableDocumentIds(ContentHandlerInput input) throws VirtualViewerAPIException { String clientInstanceId = input.getClientInstanceId(); File imgDirectory = new File(gFilePath); String[] myArray = imgDirectory.list(this); ContentHandlerResult result = new ContentHandlerResult(); result.put(ContentHandlerResult.KEY_AVAILABLE_DOCUMENT_IDS, myArray); return result; }
- Specified by:
getAvailableDocumentIds
in interfaceAvailableDocumentsInterface
- Parameters:
input
- ContentHandlerInput containing the following values:Every row is an expected value in the ContentHandlerInput. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_CLIENT_INSTANCE_ID java.lang.String Custom configurable value used to pass data from client to content handler. If not set then will be the session ID. Can be retrieved with String clientInstanceId = input.getClientInstanceId();
KEY_HTTP_SERVLET_REQUEST javax.servlet.http.HttpServletRequest Request that called this method. Can be retrieved with HttpServletRequest request = input.getHttpServletRequest();
- Returns:
- ContentHandlerResult with the following values:
Every row is an expected value in the ContentHandlerResult. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_AVAILABLE_DOCUMENT_IDS java.lang.String[] Array of keys for available documents - Throws:
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an error- See Also:
AvailableDocumentsInterface.getAvailableDocumentIds(ContentHandlerInput)
-
sendDocumentContent
public ContentHandlerResult sendDocumentContent(ContentHandlerInput input) throws VirtualViewerAPIException
Description copied from interface:SendDocumentInterface
This method gets called to send a document via a mechanism defined by the content handler. For example, before VirtualViewer supported it by default this method was often used to send documents by email.- Specified by:
sendDocumentContent
in interfaceSendDocumentInterface
- Parameters:
input
- ContentHandlerInput containing the following values:Every row is an expected value in the ContentHandlerInput. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_DOCUMENT_CONTENT byte[] The document file content. Can be retrieved with byte[] documentContent= input.getDocumentContent();
.KEY_DOCUMENT_FORMAT int An integer code representing the document format. Can be retrieved along with a format information object with the following code: int formatCode = input.getDocumentFormat(); Format format = VirtualViewerFormatHash.getInstance().getFormat(outputFormat);
KEY_MERGE_ANNOTATIONS boolean Whether annotations have been merged into the document to be sent. Can be retrieved with boolean annotationsMerged = input.getMergeAnnotations();
.KEY_DOCUMENT_ID java.lang.String The key representing the document. Can be retrieved with String documentId = input.getDocumentId();
.KEY_CLIENT_INSTANCE_ID java.lang.String Custom configurable value used to pass data from client to content handler. If not set then will be the session ID. Can be retrieved with String clientInstanceId = input.getClientInstanceId();
KEY_HTTP_SERVLET_REQUEST javax.servlet.http.HttpServletRequest Request that called this method. Can be retrieved with HttpServletRequest request = input.getHttpServletRequest();
- Returns:
- ContentHandlerResult with no values currently expected.
- Throws:
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an error- See Also:
SendDocumentInterface.sendDocumentContent(ContentHandlerInput)
-
eventNotification
public ContentHandlerResult eventNotification(ContentHandlerInput input) throws VirtualViewerAPIException
Description copied from interface:EventSubscriberInterface
This method is called when some events occur in the VirtualViewer client, such as opening a document or viewing a new page on the document.- Specified by:
eventNotification
in interfaceEventSubscriberInterface
- Parameters:
input
- ContentHandlerInput containing the following values:Every row is an expected value in the ContentHandlerInput. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_EVENT java.lang.Object The type of event, as a constant property of ContentHandlerInput (e.g. ContentHandlerInput.VALUE_EVENT_SAVE_DOCUMENT). KEY_CLIENT_INSTANCE_ID java.lang.String Custom configurable value used to pass data from client to content handler. If not set then will be the session ID. Can be retrieved with String clientInstanceId = input.getClientInstanceId();
KEY_HTTP_SERVLET_REQUEST javax.servlet.http.HttpServletRequest Request that called this method. Can be retrieved with HttpServletRequest request = input.getHttpServletRequest();
- Returns:
- ContentHandlerResult with no values currently expected.
- Throws:
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an error- See Also:
EventSubscriberInterface.eventNotification(com.snowbound.contenthandler.ContentHandlerInput)
-
setSupportsTiffTagAnnotations
public static void setSupportsTiffTagAnnotations(boolean pValue)
-
getAllAnnotationsForDocument
public ContentHandlerResult getAllAnnotationsForDocument(ContentHandlerInput input) throws VirtualViewerAPIException
Description copied from interface:AllAnnotationsInterface
Returns a map of all of the annotations for a specified document key.- Specified by:
getAllAnnotationsForDocument
in interfaceAllAnnotationsInterface
- Parameters:
input
-ContentHandlerInput containing the following values:
Every row is an expected value in the ContentHandlerInput. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_DOCUMENT_ID java.lang.String The key representing the document. Can be retrieved with String documentId = input.getDocumentId();
KEY_CLIENT_INSTANCE_ID java.lang.String Custom configurable value used to pass data from client to content handler. If not set then will be set to the session ID. Can be retrieved with String clientInstanceId = input.getClientInstanceId();
KEY_HTTP_SERVLET_REQUEST javax.servlet.http.HttpServletRequest Request that called this method. Can be retrieved with HttpServletRequest request = input.getHttpServletRequest();
- Returns:
- ContentHandlerResult with the following values:
Every row is an expected value in the ContentHandlerResult. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_ALL_ANNOTATIONS_HASH java.util.Map Map of string annotation layer keys to their AnnotationLayer
objects. - Throws:
VirtualViewerAPIException
- if content handler throws exception- See Also:
AnnotationsInterface.getAnnotationContent(com.snowbound.contenthandler.ContentHandlerInput)
-
getOCRDataForDocument
public ContentHandlerResult getOCRDataForDocument(ContentHandlerInput input) throws VirtualViewerAPIException
Description copied from interface:OCRDataProviderInterface
Returns a JSON file, passed as a byte array, of OCRed text data for a document. This method will be called when the document itself is retrieved. This function should not run any OCR operations, since those are slow and would significantly affect document load on the viewer; it should return existing OCR data only. The JSON schema of the OCR data is available with VirtualViewer documentation.
- Specified by:
getOCRDataForDocument
in interfaceOCRDataProviderInterface
- Parameters:
input
- ContentHandlerInput containing the following values:Every row is an expected value in the ContentHandlerInput. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_DOCUMENT_ID java.lang.String The key representing the document. Can be retrieved with String documentId = input.getDocumentId();
.KEY_CLIENT_INSTANCE_ID java.lang.String Custom configurable value used to pass data from client to content handler. If not set then will be set to the session ID. Can be retrieved with String clientInstanceId = input.getClientInstanceId();
KEY_HTTP_SERVLET_REQUEST javax.servlet.http.HttpServletRequest Request that called this method. Can be retrieved with HttpServletRequest request = input.getHttpServletRequest();
- Returns:
- null, or ContentHandlerResult with the following values:
Every row is an expected value in the ContentHandlerResult. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_OCR_DATA_JSON byte[] A byte array of the OCR JSON data. If both this parameter and KEY_OCR_DATA_JSON_STRING are set, the string representation will be used and this parameter will be ignored. KEY_OCR_DATA_JSON_STRING java.lang.String A JSON string representation of the OCR JSON data. If both this parameter and KEY_OCR_DATA_JSON are set, this parameter will be used and the byte array representation will be ignored. - Throws:
VirtualViewerAPIException
- if content handler throws exception
-
getOCRDataOnPerformOCR
public ContentHandlerResult getOCRDataOnPerformOCR(ContentHandlerInput input) throws VirtualViewerAPIException
Description copied from interface:OCRDataProviderInterface
Returns a JSON file, passed as a byte array, of OCRed text data for a document. This method will be called when the user asks VirtualViewer to perform OCR; it will only be called if OCR is enabled. This function may return existing OCR data, since the OCR cache and the document cache may get out of sync; this will re-insert OCR data into the cache. Additionally, if OCR will be run on demand, it should be run in this function rather than getOCRDataForDocument. The JSON schema of the OCR data is available with VirtualViewer documentation.
- Specified by:
getOCRDataOnPerformOCR
in interfaceOCRDataProviderInterface
- Parameters:
input
- ContentHandlerInput containing the following values:Every row is an expected value in the ContentHandlerInput. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_DOCUMENT_ID java.lang.String The key representing the document. Can be retrieved with String documentId = input.getDocumentId();
.KEY_CLIENT_INSTANCE_ID java.lang.String Custom configurable value used to pass data from client to content handler. If not set then will be set to the session ID. Can be retrieved with String clientInstanceId = input.getClientInstanceId();
KEY_DOCUMENT_OCR_LANGUAGE java.lang.String Optional three-letter language code specified on the client as the language to assume when performing OCR. KEY_HTTP_SERVLET_REQUEST javax.servlet.http.HttpServletRequest Request that called this method. Can be retrieved with HttpServletRequest request = input.getHttpServletRequest();
- Returns:
- null, or ContentHandlerResult with the following values:
Every row is an expected value in the ContentHandlerResult. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_OCR_DATA_JSON byte[] A byte array of the OCR JSON data. If both this parameter and KEY_OCR_DATA_JSON_STRING are set, the string representation will be used and this parameter will be ignored. KEY_OCR_DATA_JSON_STRING java.lang.String A JSON string representation of the OCR JSON data. If both this parameter and KEY_OCR_DATA_JSON are set, this parameter will be used and the byte array representation will be ignored. - Throws:
VirtualViewerAPIException
- if content handler throws exception- See Also:
OCRDataProviderInterface.getOCRDataForDocument(com.snowbound.contenthandler.ContentHandlerInput)
-
validateCache
public ContentHandlerResult validateCache(ContentHandlerInput input)
Description copied from interface:CacheValidator
This method is called before each document is stored in or retrieved from the VirtualViewer document cache and can confirm the operation or prevent it on a document-by-document basis.
The response for each document and operation is cached for a short time in VirtualViewer to prevent asking about the same operation multiple times in quick succession. In other words, if a specific document is prevented from being cached, VirtualViewer will not ask again for a few minutes and the document will remain uncached for that time.
- Specified by:
validateCache
in interfaceCacheValidator
- Parameters:
input
- ContentHandlerInput containing the following values:Every row is an expected value in the ContentHandlerInput. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_CACHE_ACTION ContentHandlerInput.VALUE_CACHE_GET or ContentHandlerInput.VALUE_CACHE_PUT The action to be confirmed for the specified document. GET asks whether the document should be retrieved from the cache, while PUT asks if it should be stored. KEY_DOCUMENT_ID java.lang.String The key representing the document. Can be retrieved with String documentId = input.getDocumentId();
.KEY_CLIENT_INSTANCE_ID java.lang.String Custom configurable value used to pass data from client to content handler. If not set then will be the session ID. Can be retrieved with String clientInstanceId = input.getClientInstanceId();
KEY_HTTP_SERVLET_REQUEST javax.servlet.http.HttpServletRequest Request that called this method. Can be retrieved with HttpServletRequest request = input.getHttpServletRequest();
- Returns:
- ContentHandlerResult with the following values:
Every row is an expected value in the ContentHandlerResult. The first column is the string key for the value. The second column is the type of the value. The third column is the detailed description of the value. Key Type Description KEY_USE_OF_CACHE_ALLOWED boolean true to allow the operation to continue and false to prevent it. This response will be remembered for a few minutes.
-
checkAvailable
public ContentHandlerResult checkAvailable(ContentHandlerInput input) throws VirtualViewerAPIException
Description copied from interface:HealthCheckInterface
Returns null, or an empty ContentHandlerResult for a successful "healthy" result, or throws a VirtualViewerAPIException for an "unhealthy" result. This interface will alow monitoring software to check VirtualViewer's content handler availability. It is up to the content handler implementation to determine what constitutes "healthy and available". For example, the sample FileContentHandler will always return a result--it is pure Java and therefore always available. On the other hand, the RestfulHttpContentHandler will ping the remote content handler and throw the "failure" result if it encounters an problem with the ping.
- Specified by:
checkAvailable
in interfaceHealthCheckInterface
- Parameters:
input
- ContentHandlerInput containing no values.- Returns:
- null, or ContentHandlerResult with no values. This is considered a successful connection check.
- Throws:
VirtualViewerAPIException
- on failure--this is considered a failed connection check.
-
-