Package com.saperion.ngc.viewer
Class DocumentViewPresenter
java.lang.Object
com.saperion.ngc.viewer.DocumentViewPresenter
- All Implemented Interfaces:
Presenter
Presenter for document viewing.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
canDownload
(int maskRights, DocumentId documentId) Checks if downloading an item is allowed in this mask.boolean
Checks if the user can edit the annotations.boolean
Checks if the document can be edited.boolean
canView
(DocumentId documentId) Checks if the document can be opened in viewer.void
Checks if the connection to the backend is still alive.void
downloadAsZip
(List<Content> content) Triggers a download of a ZIP containing the specified content.void
downloadSingle
(DocumentId docId, String filename, int element) Triggers the download of a single document.getArchiveMetaInfo
(DocumentId documentId, boolean currentRevision, boolean previewMode) Gets the archive meta info.getContentListForLink
(DocumentId id, DocumentArchiveMetaInfo linkMetaInfo) Returns a list ofContent
of a linked document.Returns the database meta-info of the document with the specified ID.long
getElementSize
(DocumentId id, int element) Determines the size of the element.getElementSizes
(DocumentId id, List<Integer> elementsWithoutSize) Determines the sizes of the list of elements.getLinkFilename
(DocumentArchiveMetaInfo archiveMetaInfo) Returns the file name for a linked element.long
getLinkFileSize
(DocumentArchiveMetaInfo linkInfo) Returns the file size of a linked document.Reads the notes element for the given document id.getStream
(DocumentId id, int element) Gets the document's content as stream.boolean
hasAclAnnotationsInEveryDocument
(List<DocumentArchiveMetaInfo.ElementArchiveMetaInfo> elements, DocumentId documentId) Checks for ACL in all sub-structure elements in a documentresolveLatestRevision
(String originalHdoc) Resolves the latest revision of the document with the specified HDOC.com.saperion.externalstorage.library.Document
uploadDocElementToExternalStorage
(DocumentId documentId, String selectedFolderID, com.saperion.externalstorage.client.ExternalStorageClient externalStorageClient, com.saperion.externalstorage.ExternalStorageType storageType, int elementNo) void
writeAuditEvent
(String hdoc, DocumentService.AuditEvent event, String remark) void
writeNotes
(DocumentId documentId, String text) Writes the text to the notes element or creates a new one.
-
Constructor Details
-
DocumentViewPresenter
protected DocumentViewPresenter()Constructor.
-
-
Method Details
-
getArchiveMetaInfo
public DocumentArchiveMetaInfo getArchiveMetaInfo(DocumentId documentId, boolean currentRevision, boolean previewMode) throws NgcUiException, AuthenticationException Gets the archive meta info.- Parameters:
documentId
- the document idcurrentRevision
- if true, the latest revision of the document will be retrievedpreviewMode
- used to decide if the document will be opened in the preview viewer or not- Returns:
- meta information about the document
- Throws:
NgcUiException
- exception to be handled by viewAuthenticationException
- re-logon required
-
canEditDocument
Checks if the document can be edited.- Parameters:
id
- document id- Returns:
- true if edit is possible
- Throws:
AuthenticationException
- authentication exceptionNgcUiException
- exception that causes an error window
-
getNotes
Reads the notes element for the given document id. It returns the text or an empty string, if the notes element don't exists.- Parameters:
hDoc
- Document id- Returns:
- Notes string
- Throws:
AuthenticationException
- authentication exceptionNgcUiException
- exception that causes an error window
-
writeNotes
public void writeNotes(DocumentId documentId, String text) throws AuthenticationException, NgcUiException Writes the text to the notes element or creates a new one.- Parameters:
documentId
- Document IDtext
- Text- Throws:
AuthenticationException
- authentication exceptionNgcUiException
- exception that causes an error window
-
checkConnection
Checks if the connection to the backend is still alive.- Throws:
AuthenticationException
- if re-logon is requiredNgcUiException
- if checking the connection failed
-
getElementSizes
public Map<Integer,Long> getElementSizes(DocumentId id, List<Integer> elementsWithoutSize) throws NgcUiException, AuthenticationException Determines the sizes of the list of elements.- Parameters:
id
- document idelementsWithoutSize
- List of elements that have no file size.- Returns:
- Map with element numbers and its sizes (in bytes)
- Throws:
NgcUiException
- exception to be handled by viewAuthenticationException
- Authentication exception
-
getElementSize
public long getElementSize(DocumentId id, int element) throws NgcUiException, AuthenticationException Determines the size of the element.- Parameters:
id
- document idelement
- element number- Returns:
- size (in bytes)
- Throws:
NgcUiException
- exception to be handled by viewAuthenticationException
- Authentication exception
-
writeAuditEvent
public void writeAuditEvent(String hdoc, DocumentService.AuditEvent event, String remark) throws SystemException, AuthenticationException -
getStream
public InputStream getStream(DocumentId id, int element) throws NgcUiException, AuthenticationException Gets the document's content as stream.- Parameters:
id
- the id of the documentelement
- the element to retrieve- Returns:
- the content as stream
- Throws:
NgcUiException
- exception to be handled by viewAuthenticationException
- authentication exception
-
canEditAnnotations
public boolean canEditAnnotations(OpenDocumentBean bean) throws NgcUiException, AuthenticationException Checks if the user can edit the annotations. If an annotation contains an ACL that forbids editing, the viewer must be switched to read-only mode. The annotations are retrieved from the backend and are stored in the bean for re-use.- Parameters:
bean
- the open-document-bean- Returns:
- true, if user can edit the annotations
- Throws:
NgcUiException
- exception to be handled by viewAuthenticationException
- re-logon required
-
hasAclAnnotationsInEveryDocument
public boolean hasAclAnnotationsInEveryDocument(List<DocumentArchiveMetaInfo.ElementArchiveMetaInfo> elements, DocumentId documentId) throws NgcUiException, AuthenticationException Checks for ACL in all sub-structure elements in a document- Parameters:
elements
- sub-structure elements in a documentdocumentId
- document id- Returns:
- true if any acl is found on any sub-structure element else false
- Throws:
NgcUiException
AuthenticationException
-
canView
Checks if the document can be opened in viewer.- Parameters:
documentId
- id of the document- Returns:
- true if viewing is allowed
- Throws:
NgcUiException
- exception to be handled by view
-
canDownload
Checks if downloading an item is allowed in this mask.- Parameters:
maskRights
- rights on this maskdocumentId
- id of the current document- Returns:
- true if allowed
- Throws:
NgcUiException
- exception to be handled by view
-
getLinkFileSize
Returns the file size of a linked document. If the document has a single element, the size of the element is returned. If not, "unknown size" is returned.- Parameters:
linkInfo
- archive info of the linked element- Returns:
- file size string
-
getLinkFilename
Returns the file name for a linked element. If the linked document contains a single element, the name of the element is returned. If not, a generic title ("Documents") is returned.- Parameters:
archiveMetaInfo
- archive info of the linked element- Returns:
- file name string
-
getContentListForLink
public List<Content> getContentListForLink(DocumentId id, DocumentArchiveMetaInfo linkMetaInfo) throws NgcUiException, AuthenticationException Returns a list ofContent
of a linked document.- Parameters:
id
- id of the linked documentlinkMetaInfo
- archive info of the link- Returns:
- list of
Content
- Throws:
NgcUiException
- exception to be handled by viewAuthenticationException
- re-logon required
-
downloadAsZip
Triggers a download of a ZIP containing the specified content.- Parameters:
content
- content to download- Throws:
AuthenticationException
- re-logon requiredNgcUiException
- exception to be handled by view
-
downloadSingle
public void downloadSingle(DocumentId docId, String filename, int element) throws AuthenticationException, NgcUiException Triggers the download of a single document.- Parameters:
docId
- id of the document to downloadfilename
- name of the fileelement
- element to download- Throws:
AuthenticationException
- re-logon requiredNgcUiException
- exception to be handled by view
-
resolveLatestRevision
public String resolveLatestRevision(String originalHdoc) throws NgcUiException, AuthenticationException Resolves the latest revision of the document with the specified HDOC.- Parameters:
originalHdoc
- HDOC to resolve- Returns:
- HDOC of the latest revision of the document
- Throws:
NgcUiException
- system error when resolving revisionAuthenticationException
- re-logon required
-
getDocumentInfo
public ResultProperties getDocumentInfo(DocumentId id) throws NgcUiException, AuthenticationException Returns the database meta-info of the document with the specified ID.- Parameters:
id
- document's ID- Returns:
- database meta-info
- Throws:
NgcUiException
- exception to be handled by viewAuthenticationException
- re-logon required
-
uploadDocElementToExternalStorage
public com.saperion.externalstorage.library.Document uploadDocElementToExternalStorage(DocumentId documentId, String selectedFolderID, com.saperion.externalstorage.client.ExternalStorageClient externalStorageClient, com.saperion.externalstorage.ExternalStorageType storageType, int elementNo) throws NgcUiException, com.saperion.externalstorage.exception.ExternalStorageException - Throws:
NgcUiException
com.saperion.externalstorage.exception.ExternalStorageException
-