Package com.saperion.ngc.viewer
Class DocumentViewPresenter
- java.lang.Object
-
- com.saperion.ngc.viewer.DocumentViewPresenter
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDocumentViewPresenter()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanDownload(int maskRights, DocumentId documentId)Checks if downloading an item is allowed in this mask.booleancanEditAnnotations(OpenDocumentBean bean)Checks if the user can edit the annotations.booleancanEditDocument(DocumentId id)Checks if the document can be edited.booleancanView(DocumentId documentId)Checks if the document can be opened in viewer.voidcheckConnection()Checks if the connection to the backend is still alive.voiddownloadAsZip(java.util.List<Content> content)Triggers a download of a ZIP containing the specified content.voiddownloadSingle(DocumentId docId, java.lang.String filename, int element)Triggers the download of a single document.DocumentArchiveMetaInfogetArchiveMetaInfo(DocumentId documentId, boolean currentRevision, boolean previewMode)Gets the archive meta info.java.util.List<Content>getContentListForLink(DocumentId id, DocumentArchiveMetaInfo linkMetaInfo)Returns a list ofContentof a linked document.ResultPropertiesgetDocumentInfo(DocumentId id)Returns the database meta-info of the document with the specified ID.longgetElementSize(DocumentId id, int element)Determines the size of the element.java.util.Map<java.lang.Integer,java.lang.Long>getElementSizes(DocumentId id, java.util.List<java.lang.Integer> elementsWithoutSize)Determines the sizes of the list of elements.java.lang.StringgetLinkFilename(DocumentArchiveMetaInfo archiveMetaInfo)Returns the file name for a linked element.longgetLinkFileSize(DocumentArchiveMetaInfo linkInfo)Returns the file size of a linked document.java.lang.StringgetNotes(java.lang.String hDoc)Reads the notes element for the given document id.java.io.InputStreamgetStream(DocumentId id, int element)Gets the document's content as stream.booleanhasAclAnnotationsInEveryDocument(java.util.List<DocumentArchiveMetaInfo.ElementArchiveMetaInfo> elements, DocumentId documentId)Checks for ACL in all sub-structure elements in a documentjava.lang.StringresolveLatestRevision(java.lang.String originalHdoc)Resolves the latest revision of the document with the specified HDOC.com.saperion.externalstorage.library.DocumentuploadDocElementToExternalStorage(DocumentId documentId, java.lang.String selectedFolderID, com.saperion.externalstorage.client.ExternalStorageClient externalStorageClient, com.saperion.externalstorage.ExternalStorageType storageType, int elementNo)voidwriteAuditEvent(java.lang.String hdoc, DocumentService.AuditEvent event, java.lang.String remark)voidwriteNotes(DocumentId documentId, java.lang.String text)Writes the text to the notes element or creates a new one.
-
-
-
Method Detail
-
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
public boolean canEditDocument(DocumentId id) throws AuthenticationException, NgcUiException
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
public java.lang.String getNotes(java.lang.String hDoc) throws AuthenticationException, NgcUiExceptionReads 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, java.lang.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
public void checkConnection() throws AuthenticationException, NgcUiExceptionChecks if the connection to the backend is still alive.- Throws:
AuthenticationException- if re-logon is requiredNgcUiException- if checking the connection failed
-
getElementSizes
public java.util.Map<java.lang.Integer,java.lang.Long> getElementSizes(DocumentId id, java.util.List<java.lang.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(java.lang.String hdoc, DocumentService.AuditEvent event, java.lang.String remark) throws SystemException, AuthenticationException
-
getStream
public java.io.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(java.util.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:
NgcUiExceptionAuthenticationException
-
canView
public boolean canView(DocumentId documentId) throws NgcUiException
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
public boolean canDownload(int maskRights, DocumentId documentId) throws NgcUiExceptionChecks 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
public long getLinkFileSize(DocumentArchiveMetaInfo linkInfo)
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
public java.lang.String getLinkFilename(DocumentArchiveMetaInfo archiveMetaInfo)
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 java.util.List<Content> getContentListForLink(DocumentId id, DocumentArchiveMetaInfo linkMetaInfo) throws NgcUiException, AuthenticationException
Returns a list ofContentof 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
public void downloadAsZip(java.util.List<Content> content) throws AuthenticationException, NgcUiException
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, java.lang.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 java.lang.String resolveLatestRevision(java.lang.String originalHdoc) throws NgcUiException, AuthenticationExceptionResolves 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, java.lang.String selectedFolderID, com.saperion.externalstorage.client.ExternalStorageClient externalStorageClient, com.saperion.externalstorage.ExternalStorageType storageType, int elementNo) throws NgcUiException, com.saperion.externalstorage.exception.ExternalStorageException
- Throws:
NgcUiExceptioncom.saperion.externalstorage.exception.ExternalStorageException
-
-