Skip to main content

Document Management

This page documents the document browser, upload, download, history, attachment, visibility, and PDF tool subsystems in SureDrive. It covers the Angular routes and controllers, the upload service, backend operation constants, and the document entity model.


Overview

Documents in SureDrive are stored within a folder hierarchy defined by the Content Model Editor. The document navigator is the primary user interface — it renders the folder tree on the left and a document list or preview panel on the right. All document operations (upload, download, move, share, sign, annotate, delete, restore) are initiated from this view.

Key owning modules:

  • UI: suredms-web-clientnetwork/study/ folder tree, upload wizard, document detail views
  • Service layer: suredms-web-service — document streaming and processing endpoints
  • Domain model: suredms-commonDocumentEntity, BlobDescriptor

Angular Routes

File: SC/suredms-web-client/src/main/webapp/app/js/state/app-states.js

StateTemplate / ControllerPurpose
app.network.study.browse.filesdrive-file-navigator.htmlMain SureDrive document navigator; folder tree + document list
app.network.study.browse.documentStudyDocumentControllerDocument detail view; metadata, preview, workflow actions
app.network.study.upload-driveDriveUploadFilesControllerMulti-file upload wizard for SureDrive
app.network.study.browse.attachmentStudyAttachmentControllerAttachment detail view for a specific document attachment

Controllers and Services

DriveUploadFilesController

File: SC/suredms-web-client/src/main/webapp/app/js/network/study/drive-upload-files.js

Orchestrates the multi-file upload process. Responsibilities:

  • Collects files from the browser drag/drop or file picker.
  • Allows users to assign content type (folder placement), metadata fields, and PDF conversion options per file.
  • Supports manualVersionChange (Major/Minor version increment selection during upload).
  • Emits upload progress events consumed by the progress indicator component.

StudyDocumentController

File: SC/suredms-web-client/src/main/webapp/app/js/network/study/documents/study-document-details.js

Manages the document detail panel. Responsibilities:

  • Renders document metadata and the PDF preview iframe.
  • Surfaces actions: review, sign, initiate workflow process, associate with tasks.
  • Delegates permission checks to DocumentPermissionsHelper (see Role-Based Access Control).

StudyDocumentHistoryController

File: SC/suredms-web-client/src/main/webapp/app/js/network/study/documents/study-document-history.js

Handles the version history panel for a document:

MethodOperation
fetchDocumentHistoryCalls Mobile.GetDocumentHistory to populate the versions list
revertDocumentCalls OPERATION_DOCUMENT_RESTORE_VERSION to promote an older version to current

UploadFilesHelperService

File: SC/suredms-web-client/src/main/webapp/app/js/network/study/study-upload.js

Shared utility service for all document upload flows:

MethodPurpose
reloadRequiredMetadataFetches mandatory metadata fields based on content type and user role
populateUploadTaskParamsConfigures upload parameters when the upload is part of a workflow task
handleEmailParses .msg / .eml files using JSZip; extracts attachments as individual document objects
copyMetadataParametersSynchronises metadata across multiple files in a batch upload

ContentVisibilityService

File: SC/suredms-web-client/src/main/webapp/app/js/network/study/documents/study-content-visibility-service.js

Manages ACL rules for documents and folders. Implements the backend of the Configuring Document Visibility and Configuring Content Visibility Help flows. Works with ExpandedArchiveAclRule (see Role-Based Access Control).

TrashedArchiveService

File: SC/suredms-web-client/src/main/webapp/app/js/network/study/study-trash.js

Handles soft-delete and permanent-delete flows:

MethodBackend Operation
undeleteArchiveMobile.UndeleteDocuments — restores deleted documents
purgeArchiveMobile.PurgeDocuments — permanently removes documents

StudyNavigatorFileEditorService

File: SC/suredms-web-client/src/main/webapp/app/js/network/study/study-navigator-file-editor.js

Facilitates in-browser PDF manipulation: Split, Merge, and Redact operations surfaced via the PDF Tools panel in the document detail view.


Document Entity Model

File: SC/suredms-common/src/main/java/com/sureclinical/suredms/entity/DocumentEntity.java

MethodDescription
getVersion()Internal numeric version counter
getManualVersionString()User-facing version string (e.g., 1.0, 2.1)
getContentSize()File size in bytes
getDocumentStatus()Lifecycle state: Draft, Effective, Obsolete
isDocumentLocked()true if the document is checked out or otherwise restricted

Backend Operation Constants

Operations are defined in constants-operations.js and executed via ConnectionService. Key document operations:

ConstantOperation StringPurpose
OPERATION_MOBILE_UPLOAD_DOCUMENTMobile.UploadDocumentStreams document binary to the server
Mobile.GetDocumentHistoryReturns version list for a document
OPERATION_DOCUMENT_RESTORE_VERSIONPromotes an older version to current
Mobile.UndeleteDocumentsRestores documents from trash
Mobile.PurgeDocumentsPermanently deletes documents

Document Operations Reference

Help TopicOperationEntry Point
Uploading DocumentsDriveUploadFilesControllerMobile.UploadDocumentDocuments area → Upload button
Downloading DocumentsStudyDocumentController → download actionDocument detail → Download
Moving Documents to ArchiveDocumentPermissionsHelper.canBeMovedToArchive() + acquire queue serviceDocument detail → Move to Archive
Deleting DocumentsSoft delete to trashDocument context menu → Delete
Restoring DocumentsTrashedArchiveService.undeleteArchiveTrash → Restore
Permanently DeletingTrashedArchiveService.purgeArchiveTrash → Permanently Delete
Document HistoryStudyDocumentHistoryController.fetchDocumentHistoryDocument detail → History tab
Revert VersionStudyDocumentHistoryController.revertDocumentHistory tab → Revert
Moving / CopyingStudyNavigatorFileEditorServiceDocument context menu → Move / Copy
Configuring VisibilityContentVisibilityServiceDocument detail → Visibility
Content Visibility (folder)ContentVisibilityServiceFolder context menu → Content Visibility
Using PDF ToolsStudyNavigatorFileEditorService → split / merge / redactDocument detail → PDF Tools
Sharing DocumentsACTION_SHARE_BOOKMARK / sharing serviceDocument detail → Share
Managing AttachmentsStudyAttachmentControllerDocument detail → Attachments tab
Submitting DiscrepanciesQuality review flowDocument detail → Submit Discrepancy
Working with Expired DocumentsExpiry filter in navigatorDocuments → filter by Expired
Importing from SharePointConnector integration (see Connectors)Documents → Import from SharePoint

Bookmarks

File: SC/suredms-web-client/src/main/webapp/app/js/network/study/bookmarks/study-bookmark-navigator.js

StudyBookmarkNavigatorController manages the dedicated Bookmarks view — a filtered version of the document tree showing only user-marked favourites. The ACTION_SHARE_BOOKMARK action allows users to create a direct link to a bookmarked folder or document and share it with other team members.


Keyboard Navigation

File: SC/suredms-web-client/src/main/webapp/app/js/network/study/study-navigator.js

StudyAbstractNavigatorController injects KeyboardNavigationService to handle keyboard shortcuts across the Documents, Bookmarks, Acquire Queue, and Quality Queue views.

KeyMethod / Action
/ arrowselectPreviousEntity / selectNextEntity — move selection in the tree
EnterOpen selected item
BackspaceNavigate to parent directory
EscapeClear selection
DeleteTrigger delete action on selected item (where applicable)

KeyboardNavigationService.bindKeyListener is used in individual controllers to map additional keys to context-specific document actions.


Key Source Files Reference

FilePurpose
SC/suredms-web-client/src/main/webapp/app/js/network/study/drive-upload-files.jsDriveUploadFilesController — multi-file upload wizard
SC/suredms-web-client/src/main/webapp/app/js/network/study/documents/study-document-details.jsStudyDocumentController — document detail view
SC/suredms-web-client/src/main/webapp/app/js/network/study/documents/study-document-history.jsStudyDocumentHistoryController — version history
SC/suredms-web-client/src/main/webapp/app/js/network/study/study-upload.jsUploadFilesHelperService — shared upload helpers
SC/suredms-web-client/src/main/webapp/app/js/network/study/documents/study-document-navigator.jsStudyDocumentNavigatorController — folder tree and document list
SC/suredms-web-client/src/main/webapp/app/js/network/study/documents/study-content-visibility-service.jsContentVisibilityService — ACL/visibility rules
SC/suredms-web-client/src/main/webapp/app/js/network/study/study-trash.jsTrashedArchiveService — soft delete and permanent purge
SC/suredms-web-client/src/main/webapp/app/js/network/study/study-navigator-file-editor.jsStudyNavigatorFileEditorService — in-browser PDF tools
SC/suredms-web-client/src/main/webapp/app/js/network/study/study-navigator.jsStudyAbstractNavigatorController — keyboard navigation
SC/suredms-common/src/main/java/com/sureclinical/suredms/entity/DocumentEntity.javaDocument domain entity
SC/suredms-common/src/main/java/com/sureclinical/suredms/entity/BlobDescriptor.javaLow-level file blob descriptor (filename, hash, mimeType, length)

Annotation Tool

The SureDrive Annotation Tool is embedded in the PDF document viewer. It supports text annotations, sticky-note comments, and search-based redaction.

Entry Point and Controller

File: SC/suredms-web-client/src/main/webapp/app/js/file/file-viewer.js
Controller: DocumentViewerController

MethodDescription
toggleAnnotationBlock()Opens or closes the annotation panel; validates that signing and watermarking are not concurrently active
openAnnotationBlock(isRedaction)Activates either the standard annotation tool or the redaction tool depending on the flag
doAnnotate(confirm)Saves pending annotations to the document
doSearchTextRedaction(redaction)Implements Search & Redact: sends document data to OPERATION_MOBILE_SEARCH_TEXT to locate text occurrences marked for redaction

Permissions

The annotation UI gates access behind two feature flags:

Feature FlagCapability
FEATURE_PDF_ANNOTATIONSStandard PDF annotations (text, sticky notes)
FEATURE_PDF_COMMENTSInline comment tool

In addition, the document must have annotable = true — a flag controlled via Content Model Editor folder or content-type properties. Documents that are not annotable will not show the annotation toolbar.

Relationship to the Content Model Editor

Annotation labels and categories are defined as AnnotationDefinitionEntity records within the CME. AnnotationDefinitionEntity extends PropertyDefinitionEntity, which means annotation terms live alongside metadata term definitions in the content model. This allows structured annotation review: reviewers pick from a predefined vocabulary of annotation types when annotating a document.

Entity: SC/suredms-common/src/main/java/com/sureclinical/suredms/entity/AnnotationDefinitionEntity.java

Backend Processing

File: SC/suredms-web-service/src/main/java/com/sureclinical/suredms/webservice/ItextUtils.java

ItextUtils.redactPdfFile(File inputFile, File outputFile, List<Map<String, Object>> redactions) performs the server-side PDF surgery for redaction using the iText library. It handles complex PDF encodings including JBIG2 and JPX 2000 images.

Help reference: Using-the-SureDrive-Annotation-Tool_73793542.html


Document Tree Settings

The document navigator persists display preferences per user per study, including view mode, column sort, and tree expansion state.

Controller and Services

Controller: StudyAbstractNavigatorController
File: SC/suredms-web-client/src/main/webapp/app/js/network/study/study-navigator.js

SettingDescription
$scope.navigator.viewIdActive view mode: standard directory view, VIEW_BY_CATEGORY, or BY_ANNOTATIONS
$scope.treeOptionsAngular tree component config: node equality checks, CSS class injection
$scope.navigator.pageCurrent pagination state
$scope.navigator.sortActive column sort field and direction
Selection modetoggleSelectionMode() enables bulk-action selection

Persistence

Service: NavigatorPreferencesService
Repository: NavigatorPreferencesRepository
File: SC/suredms-web-client/src/main/webapp/app/js/network/study/study-navigator-filter-preferences-repository.js

Preferences are stored server-side per user/study pair via the NavigatorPreferencesService:

Backend OperationPurpose
Mobile.GetDocumentNavigatorPreferencesFetches saved preferences on navigator load
Mobile.UpdateDocumentNavigatorPreferencesPersists changes when a user modifies view settings

A preferencesHash detects whether settings have changed since last save. study-navigator-context.js restores the user’s previous tree expansion state (expandedNodes), selected node, and filter parameters when they return to the same study.

Help reference: Configuring-SureDrive-Document-Tree-Settings_73891863.html


StudyAbstractNavigatorController is the base class for the document tree and list area in SC/suredms-web-client/src/main/webapp/app/js/network/study/study-navigator.js. It manages the full lifecycle of the folder tree and document list — loading entity hierarchies, applying filters, maintaining selection state, and coordinating document operations.

Key Nuxeo Automation Operations

OperationPurpose
OPERATION_MOBILE_GET_ENTITY_DETAILSFetches detail metadata for a specific entity (folder or document)
OPERATION_MOBILE_GET_ENTITY_HISTORYFetches the version history event list for an entity
OPERATION_MOBILE_GET_DOCUMENT_DETAILSFetches document-specific metadata (content type, milestone, etc.)
OPERATION_MOBILE_GET_DOCUMENT_CHECK_OUTRetrieves check-out state of a document
OPERATION_MOBILE_GET_DOCUMENT_SUFFIXReturns the canonical file suffix for the document
OPERATION_MOBILE_MOVE_DOCUMENTSMoves selected documents to a different folder
OPERATION_MOBILE_COPY_FOLDERSCopies a folder subtree
OPERATION_MOBILE_SET_DOCUMENT_LOCKSets or clears the document lock flag
OPERATION_MOBILE_SET_DOCUMENT_SURVEYAssigns survey metadata to a document
OPERATION_MOBILE_SET_CONTENT_TYPE_LOCKLocks an entity to a specific content type
OPERATION_MOBILE_SET_CONTENT_TYPE_RESERVEReserves a content type slot for a document
OPERATION_MOBILE_GET_MEDICAL_IMAGE_SLIDESFetches medical image slide metadata

The controller maintains a top-level navigator object on $scope:

PropertyTypeMeaning
navigator.viewobjectCurrent view (By Category, By Site, etc.) — loaded from ViewCacheService.getViewForStudy
navigator.currentEntityentityCurrently selected folder or document
navigator.entitiesarrayAll loaded entities for the current view level
navigator.childrenarrayFiltered subset of entities shown in the list
navigator.selectedItemsarrayCurrently selected items (multi-select mode)
navigator.expandedNodesarrayTree nodes currently expanded
navigator.filteringobjectActive filter parameters
navigator.isLoadingInProgressbooleanTrue while an entity load is in flight
navigator.sortobjectCurrent sort column and direction
navigator.pageobjectPagination state for list view

Enrichment and Caching Services

ServiceRole
DocumentEnrichmentServiceenrichEntityTreeNode(entity) — adds UI helper properties to repository objects (display name, icon, action flags)
EntityDetailsCacheServicereloadEntityDetails(entity) — refreshes cached metadata for an entity from the server
ContentVisibilityCacheServiceCaches ACL/blinding rule visibility decisions to avoid repeated server calls
ContentVisibilityServiceApplies blinding rules at render time to filter hidden folders from the tree
StudyNavigatorContextServicerestoreContext() — restores last expanded nodes, selected node, and filter state; isUserStorage()

User tree preferences (expanded nodes, selected node, view, sort direction, filter state) are persisted server-side via:

  • Mobile.GetDocumentNavigatorPreferences — loads saved preferences on navigator init
  • Mobile.UpdateDocumentNavigatorPreferences — saves preferences when the user changes them

A preferencesHash (JSON hash of current preferences) is compared against the last saved hash before sending an update to avoid redundant server writes. study-navigator-context.js restores the previous session state when the user returns to the same study.

Source: SC/suredms-web-client/src/main/webapp/app/js/network/study/study-navigator.js

Key Source Files Reference

FilePurpose
SC/suredms-web-client/src/main/webapp/app/js/state/app-states.jsRoute definitions for document navigator, detail, upload, attachment states
SC/suredms-web-client/src/main/webapp/app/js/network/study/drive-upload-files.jsMulti-file upload wizard controller
SC/suredms-web-client/src/main/webapp/app/js/network/study/study-upload.jsUploadFilesHelperService — shared upload utility
SC/suredms-web-client/src/main/webapp/app/js/network/study/documents/study-document-details.jsDocument detail controller
SC/suredms-web-client/src/main/webapp/app/js/network/study/documents/study-document-history.jsDocument version history controller
SC/suredms-web-client/src/main/webapp/app/js/network/study/documents/study-content-visibility-service.jsDocument and folder ACL / visibility service
SC/suredms-web-client/src/main/webapp/app/js/network/study/study-trash.jsRestore and permanent-delete service
SC/suredms-web-client/src/main/webapp/app/js/network/study/study-navigator-file-editor.jsPDF tools: Split, Merge, Redact
SC/suredms-web-client/src/main/webapp/app/js/network/study/study-navigator.jsDocument tree navigator; keyboard navigation integration
SC/suredms-web-client/src/main/webapp/app/js/network/study/bookmarks/study-bookmark-navigator.jsBookmarks view controller
SC/suredms-common/src/main/java/com/sureclinical/suredms/entity/DocumentEntity.javaDocument domain entity interface