0
0

Document Store Reference Manual

Docs
Docs EInnovator Posted 10 Jun 20

Java / Spring Boot Client Library for Document Store

Overview

Getting Started

External Configuration

Table below provides a quick summary for the configuration options:

DocumentsClientConfiguration:

PropertyTypeDefault ValueRequiredDescription
serverStringhttp://localhost:2020Yes*Server URL
filesFilesConfiguration Files Configuration
localBoolean FalseEnable App Local File System Access
localRootBoolean/dataFalseVirtual Root Folder for Local System

FilesConfiguration:

PropertyTypeDefault ValueRequiredDescription
rootString/.upload/Yes*Root folder for uploaded files
tmpString/.tmp/ Folder for uploaded temporary files
locationsMap<String, String> NoMap for App defined keys to default file locations
foldersMap<String, String> NoMap for App defined folders to default file locations
extsMap<String, List<String>> No@Deprecated
useTmpForMap<String, Boolean> No@Deprecated

Example: Configuring File Storage in Remote Document (application.yaml)

documents:
  server: http://documents.mydomain.com
  root: "/.upload/myapp"

Programmatic Configuration

Documents API

Example: Writing a File

@Autowired
private DocumentsClient client;

private URI writeDocument(String path, String content) {
	Document document = new Document()
			.withPath(path)
			.withInfo("My File...")
			.withInputStream(new ByteArrayInputStream(content.getBytes()))
			.withContentLength((long)content.length());
	URI uri = client.write(document, null, null);
	assertNotNull(uri);
	return uri;

Example: Read User JSON File

public Map<String, Object> readFavoritesFileForPrincipal(String path) {
	final String FAVORITES_PATH = "/.myapp/favorites.json";
	Document document = client.read(FAVORITES_PATH, DocumentOptions.CONTENT_AND_META, null);
	return MappingUtils.fromJson(document2.getOrReadContent(), Map.class);
}

Example: Discard files

final String TMP_PATH = "/tmp/.myapp";

public Map<String, Object> deleteTmpFiles() {
	client.delete(TMP_PATH, DocumentOptions.FORCE, null);		
}

Rest Endpoints

This section describes the REST endpoints automatically setup the the einnovator-documents-starter.

Table below provides a quick summary:

DocumentRestController:

MethodPathQuery ParametersRequest BodyResponse BodyStatusLogSecurityDescription
GET/api/__/**DocumentFilter
PageOptions
Document[] (JSON) OKlist List files in Folder
GET/api/_/**DocumentOptions OK NOT_FOUNDdownload Download Document Content
GET/api/_meta/**DocumentOptionsDocument (JSON) OK NOT_FOUNDmeta Get Document Meta data
POST/api/__/**DocumentOptions CREATEDmkdir Make new Folder
DELETE/api/__/**DocumentOptions NO_CONTENTdelete Delete Document (file or folder)

FileUploadController:

MethodPathQuery ParametersRequest BodyResponse BodyStatusLogSecurityDescription
POSTDocumentOptions/upload
/_upload
/api/upload
/api/_upload
Multipart{Document Meta, Content} CREATEDupload Upload Document with Content and Meta-Data
Comments and Discussion

Content