Class AbstractDocumentManager<T_REST_DOCUMENT extends RestDocument>
- java.lang.Object
-
- net.webpdf.wsclient.session.rest.documents.AbstractDocumentManager<T_REST_DOCUMENT>
-
- Type Parameters:
T_REST_DOCUMENT- TheRestDocumenttype managed by theAbstractDocumentManager.
- All Implemented Interfaces:
DocumentManager<T_REST_DOCUMENT>
- Direct Known Subclasses:
RestWebServiceDocumentManager
public abstract class AbstractDocumentManager<T_REST_DOCUMENT extends RestDocument> extends Object implements DocumentManager<T_REST_DOCUMENT>
An instance ofAbstractDocumentManagerallows to monitor and interact with theRestDocuments uploaded to aRestSessionof the webPDF server.
-
-
Constructor Summary
Constructors Constructor Description AbstractDocumentManager(@NotNull RestSession<T_REST_DOCUMENT> session)Initializes aDocumentManagerfor the givenRestSession.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract @NotNull RestDocumentState<T_REST_DOCUMENT>accessInternalState(T_REST_DOCUMENT document)Requests access to the internalRestDocumentState.booleancontainsDocument(@NotNull String documentId)protected abstract T_REST_DOCUMENTcreateDocument(@NotNull String documentId)Creates a newRestDocumentfor the given document ID.voiddeleteDocument(@NotNull String documentId)Deletes theRestDocumentwith the given document ID from the webPDF server.voiddownloadDocument(@NotNull String documentId, @NotNull OutputStream outputStream)Downloads theRestDocumentwith the given document ID and writes it to the givenOutputStream.voiddownloadDocument(@Nullable RestDocument document, @NotNull OutputStream outputStream)Downloads theRestDocumentand writes it to the givenOutputStream.T_REST_DOCUMENTgetDocument(@NotNull String documentId)Returns theRestDocumentthat is known to theDocumentManagerfor the given document ID.@NotNull List<HistoryEntry>getDocumentHistory(@NotNull String documentId)Returns theHistoryEntrys known for theRestDocumentwith the given document ID.@NotNull HistoryEntrygetDocumentHistoryEntry(@NotNull String documentId, int historyId)Returns theHistoryEntrywith the given history ID for theRestDocumentwith the given document ID.@NotNull StringgetDocumentID(@NotNull DocumentFile document)Returns the document ID the givenDocumentFileis known by to thisDocumentManager.@NotNull List<T_REST_DOCUMENT>getDocuments()Returns a list of allRestDocuments known to thisDocumentManager.@NotNull RestSession<T_REST_DOCUMENT>getSession()booleanisDocumentHistoryActive()Checks whether a document history is collected for managedRestDocuments.T_REST_DOCUMENTrenameDocument(@NotNull String documentId, @NotNull String fileName)Rename theRestDocumentwith the given document ID.voidsetDocumentHistoryActive(boolean documentHistoryActive)Sets whether a document history shall be collected for managedRestDocuments.@NotNull List<T_REST_DOCUMENT>synchronize()Synchronizes theRestDocuments of thisDocumentManagerwith the actually uploaded documents of the webPDF server.T_REST_DOCUMENTsynchronize(@NotNull DocumentFile documentFile)@Nullable HistoryEntryupdateDocumentHistory(@NotNull String documentId, @NotNull HistoryEntry historyEntry)Updates the history of theRestDocumentwith the given document ID using the givenHistoryEntry.T_REST_DOCUMENTuploadDocument(@NotNull File file)Uploads the givenFileto the webPDF server, adds it to thisDocumentManagerand returns the resultingRestDocumenthandle.T_REST_DOCUMENTuploadDocument(@NotNull InputStream data, @NotNull String fileName)Uploads the givenInputStreamto the webPDF server as a document resource with the given file name, adds it to thisDocumentManagerand returns the resultingRestDocumenthandle.
-
-
-
Constructor Detail
-
AbstractDocumentManager
public AbstractDocumentManager(@NotNull @NotNull RestSession<T_REST_DOCUMENT> session)Initializes aDocumentManagerfor the givenRestSession.- Parameters:
session- TheRestSessionaDocumentManagershall be created for.
-
-
Method Detail
-
getSession
@NotNull public @NotNull RestSession<T_REST_DOCUMENT> getSession()
- Specified by:
getSessionin interfaceDocumentManager<T_REST_DOCUMENT extends RestDocument>- Returns:
- The
RestSessiontheDocumentManageris managingRestDocuments for.
-
synchronize
@NotNull public T_REST_DOCUMENT synchronize(@NotNull @NotNull DocumentFile documentFile) throws ResultException
- Specified by:
synchronizein interfaceDocumentManager<T_REST_DOCUMENT extends RestDocument>- Returns:
- The synchronized
RestDocument. - Throws:
ResultException- Shall be thrown upon a synchronization failure.
-
synchronize
@NotNull public @NotNull List<T_REST_DOCUMENT> synchronize() throws ResultException
Synchronizes theRestDocuments of thisDocumentManagerwith the actually uploaded documents of the webPDF server.- Specified by:
synchronizein interfaceDocumentManager<T_REST_DOCUMENT extends RestDocument>- Returns:
- A list of the synchronized
RestDocuments. - Throws:
ResultException- Shall be thrown upon a synchronization failure.
-
getDocumentID
@NotNull public @NotNull String getDocumentID(@NotNull @NotNull DocumentFile document) throws ResultException
Returns the document ID the givenDocumentFileis known by to thisDocumentManager.- Specified by:
getDocumentIDin interfaceDocumentManager<T_REST_DOCUMENT extends RestDocument>- Parameters:
document- TheDocumentFilea document ID shall be found for.- Returns:
- The document ID mapped to the given
DocumentFile. - Throws:
ResultException- Shall be thrown, if requesting the document ID failed.
-
getDocument
@NotNull public T_REST_DOCUMENT getDocument(@NotNull @NotNull String documentId) throws ResultException
Returns theRestDocumentthat is known to theDocumentManagerfor the given document ID.- Specified by:
getDocumentin interfaceDocumentManager<T_REST_DOCUMENT extends RestDocument>- Parameters:
documentId- The document ID aRestDocumentshall be found for.- Returns:
- The
RestDocumentmapped to the given document ID. - Throws:
ResultException- Shall be thrown, if requesting the document failed.
-
getDocuments
@NotNull public @NotNull List<T_REST_DOCUMENT> getDocuments()
Returns a list of allRestDocuments known to thisDocumentManager.- Specified by:
getDocumentsin interfaceDocumentManager<T_REST_DOCUMENT extends RestDocument>- Returns:
- A list of all
RestDocuments known to thisDocumentManager.
-
containsDocument
public boolean containsDocument(@NotNull @NotNull String documentId)- Specified by:
containsDocumentin interfaceDocumentManager<T_REST_DOCUMENT extends RestDocument>- Parameters:
documentId- The document ID, that shall be checked for existence.- Returns:
true, if thisDocumentManagercontains aRestDocumentwith the given ID.
-
downloadDocument
public void downloadDocument(@NotNull @NotNull String documentId, @NotNull @NotNull OutputStream outputStream) throws ResultExceptionDownloads theRestDocumentwith the given document ID and writes it to the givenOutputStream.- Specified by:
downloadDocumentin interfaceDocumentManager<T_REST_DOCUMENT extends RestDocument>- Parameters:
documentId- The document ID of theRestDocumentto download.outputStream- TheOutputStreamto write the downloadedRestDocumentto.- Throws:
ResultException- Shall be thrown, should the download have failed.
-
downloadDocument
public void downloadDocument(@Nullable @Nullable RestDocument document, @NotNull @NotNull OutputStream outputStream) throws ResultExceptionDownloads theRestDocumentand writes it to the givenOutputStream.- Specified by:
downloadDocumentin interfaceDocumentManager<T_REST_DOCUMENT extends RestDocument>- Parameters:
document- TheRestDocumentto download.outputStream- TheOutputStreamto write the downloadedRestDocumentto.- Throws:
ResultException- Shall be thrown, should the download have failed.
-
uploadDocument
@NotNull public T_REST_DOCUMENT uploadDocument(@NotNull @NotNull File file) throws ResultException
Uploads the givenFileto the webPDF server, adds it to thisDocumentManagerand returns the resultingRestDocumenthandle.- Specified by:
uploadDocumentin interfaceDocumentManager<T_REST_DOCUMENT extends RestDocument>- Parameters:
file- TheFileto upload.- Returns:
- The resulting
RestDocumenthandle. - Throws:
ResultException- Shall be thrown, should the upload have failed.
-
uploadDocument
@NotNull public T_REST_DOCUMENT uploadDocument(@NotNull @NotNull InputStream data, @NotNull @NotNull String fileName) throws ResultException
Uploads the givenInputStreamto the webPDF server as a document resource with the given file name, adds it to thisDocumentManagerand returns the resultingRestDocumenthandle.- Specified by:
uploadDocumentin interfaceDocumentManager<T_REST_DOCUMENT extends RestDocument>- Parameters:
data- The documentInputStreamto upload.fileName- The name of the uploaded document.- Returns:
- The resulting
RestDocumenthandle. - Throws:
ResultException- Shall be thrown, should the upload have failed.
-
deleteDocument
public void deleteDocument(@NotNull @NotNull String documentId) throws ResultExceptionDeletes theRestDocumentwith the given document ID from the webPDF server.- Specified by:
deleteDocumentin interfaceDocumentManager<T_REST_DOCUMENT extends RestDocument>- Parameters:
documentId- The document ID of theRestDocumentto delete.- Throws:
ResultException- Shall be thrown, should deleting the document have failed.
-
renameDocument
@NotNull public T_REST_DOCUMENT renameDocument(@NotNull @NotNull String documentId, @NotNull @NotNull String fileName) throws ResultException
Rename theRestDocumentwith the given document ID.- Specified by:
renameDocumentin interfaceDocumentManager<T_REST_DOCUMENT extends RestDocument>- Parameters:
documentId- The document ID of theRestDocumentto rename.fileName- The new name for theRestDocument.- Returns:
- The resulting
RestDocumenthandle. - Throws:
ResultException- Shall be thrown, should renaming the document have failed.
-
isDocumentHistoryActive
public boolean isDocumentHistoryActive()
Checks whether a document history is collected for managedRestDocuments.- Specified by:
isDocumentHistoryActivein interfaceDocumentManager<T_REST_DOCUMENT extends RestDocument>- Returns:
trueshould collecting the document history be active.
-
setDocumentHistoryActive
public void setDocumentHistoryActive(boolean documentHistoryActive) throws ResultExceptionSets whether a document history shall be collected for managedRestDocuments.- Specified by:
setDocumentHistoryActivein interfaceDocumentManager<T_REST_DOCUMENT extends RestDocument>- Parameters:
documentHistoryActive-trueshould collecting the document history be activated.- Throws:
ResultException
-
getDocumentHistory
@NotNull public @NotNull List<HistoryEntry> getDocumentHistory(@NotNull @NotNull String documentId) throws ResultException
Returns theHistoryEntrys known for theRestDocumentwith the given document ID.- Specified by:
getDocumentHistoryin interfaceDocumentManager<T_REST_DOCUMENT extends RestDocument>- Parameters:
documentId- The document ID of theRestDocumentthe history shall be requested for.- Returns:
- The
HistoryEntrys known for the selectedRestDocument. - Throws:
ResultException- Shall be thrown, should requesting the document history have failed.
-
getDocumentHistoryEntry
@NotNull public @NotNull HistoryEntry getDocumentHistoryEntry(@NotNull @NotNull String documentId, int historyId) throws ResultException
Returns theHistoryEntrywith the given history ID for theRestDocumentwith the given document ID.- Specified by:
getDocumentHistoryEntryin interfaceDocumentManager<T_REST_DOCUMENT extends RestDocument>- Parameters:
documentId- The document ID of theRestDocumenttheHistoryEntryshall be requested for.historyId- The history ID of theHistoryEntry, that shall be requested.- Returns:
- The selected
HistoryEntry. - Throws:
ResultException- Shall be thrown, should requesting the document history have failed.
-
updateDocumentHistory
@Nullable public @Nullable HistoryEntry updateDocumentHistory(@NotNull @NotNull String documentId, @NotNull @NotNull HistoryEntry historyEntry) throws ResultException
Updates the history of theRestDocumentwith the given document ID using the givenHistoryEntry.- Specified by:
updateDocumentHistoryin interfaceDocumentManager<T_REST_DOCUMENT extends RestDocument>- Parameters:
documentId- The document ID of theRestDocumentto update.historyEntry- TheHistoryEntryto update the contained values for.- Returns:
- The updated
HistoryEntry. - Throws:
ResultException- Shall be thrown, should updating the document history have failed.
-
createDocument
@NotNull protected abstract T_REST_DOCUMENT createDocument(@NotNull @NotNull String documentId) throws ResultException
Creates a newRestDocumentfor the given document ID.- Parameters:
documentId- The document ID a matchingRestDocumentshall be created for.- Returns:
- The created
RestDocument. - Throws:
ResultException- Shall be thrown, should creating the document fail.
-
accessInternalState
@NotNull protected abstract @NotNull RestDocumentState<T_REST_DOCUMENT> accessInternalState(@NotNull T_REST_DOCUMENT document)
Requests access to the internalRestDocumentState.- Parameters:
document- TheRestDocumentto request access for.- Returns:
- The internal
RestDocumentState.
-
-