# Document Management System (DMS)

Version: 1.0 | Release Date: 30/6/2018

# Search DMS File

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("http://127.0.0.1:8080/jsf/rfws/dms/searchFile?query=hk&target=attr;tag;content&limit=10&offset=0&sortField=title&sortOrder=desc")
  .get()
  .addHeader("authorization", "Bearer OGFiZmU2ZTktMzYzMS00NjIwLWJhNGYtYWU2OGQyNTZhMmNi")
  .addHeader("client_id", "C-SGF2aWQncyBhcHBsaWNhdGlvbjIwMTctMDItMTAxNjc=")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

# HTTP Request

GET http://127.0.0.1:8080/jsf/rfws/dms/searchFile?query=[Query String]&target=[search target]&limit=[limit size]&offset=[]&sortField=[The ordering field]&sortOrder=[sort order]

# Parameters

Name Description Default Example
query Query String (i.e. the string you want to seach) N/A (cannot be empty) Hk
target The parts you want to search, seaparted by colon ;. Available Options:
  • attr: File attributes include file title, author, tags.
  • tag: Header Tags and the file tags
  • content: The file content (the loading time might increase in such case)
N/A (cannot be empty) “attr;tag”
limit The number of records to be retrieved 1000 10
offset The offset (note that this will not be effective if limit is not defined.) 0 20
sortField The ordering field. Available options: title, lastModifyDate, createDate lastModifyDate title
sortOrder The ordering order (note that this will not be effective if sortField is not defined.) Available Options: asc, desc desc asc
authorization Required. Access Token obtained via Oauth2 string(Header)
client_id Required. When registered in [OAuth Applications], generated by the M18 string(Header)

# Result

If API runs success, status of the response will be 200. If API runs failed, status of the response will be 400, then it will return the CheckMsg. You can get a CheckMsg JSON array from the response header with key word 'error_info'.

Type Location Description
success Body A JSON array
fail Header(error_info) A CheckMsg

Success Example:

[
    {"lastModifyUser" : "admin",
     "extension" : "png",
     "needPassword" : "true",
     "lastModifyUid" : "5",
     "fileSize" : 125312.0,
     "createUser" : "admin",
     "id" : "35",
     "title" : "untitled23452889",
     "lastModifyDate" : "2016-12-02 17:57:26",
     "tags":""},
   {"lastModifyUser" : "test123",
     "extension" : "doc",
     "needPassword" : "true",
     "lastModifyUid" : "1",
     "fileSize" : 1755136.0,
     "createUser" : "admin",
     "id" : "33",
     "title" : "task121179_hkas_interfacex",
     "lastModifyDate" : "2017-03-10 17:57:26",
     "tags":""},
        
    }
]

Output Parameter:

Parameter Name Meaning
id ID of the file
title Title of the file
extension Extension of the file
fileSize File size of the file
tags Tags of the file
createUser Create User’s username of the file
createUid Create User’s ID of the file
createDate Date of create of the file
lastModifyUser Last Modify User’s username of the file
lastModifyUid Last Modify User’s ID of the file
lastModifyDate Date of last modify of the file
needPassword Whether the file is encrypted with password or not. *

# Download DMS File

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("http://127.0.0.1:8080/jsf/rfws/dms/getFile?id=10")
  .get()
  .addHeader("authorization", "Bearer OGFiZmU2ZTktMzYzMS00NjIwLWJhNGYtYWU2OGQyNTZhMmNi")
  .addHeader("client_id", "C-SGF2aWQncyBhcHBsaWNhdGlvbjIwMTctMDItMTAxNjc=")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

# HTTP Request

GET http://127.0.0.1:8080/jsf/rfws/dms/getFile?id=[Attachment ID]

# Parameters

Name Type Description
authorization string(Header) Required. Access Token obtained via Oauth2
client_id string(Header) Required. When registered in [OAuth Applications], generated by the M18
id long(Query) **Required.**AttachmentID
password string(Query) Requiredwhen the file is encrypted with password, Passwordof the attachment

# Result

If API runs success, status of the response will be 200. If API runs failed , status of the response will be 400, then it will return the CheckMsg. You can get a CheckMsg JSON array from the response header with key word 'error_info'.

Type Location Description
success Body a file
fail Header(error_info) A CheckMsg

# Method to Transfer File Password

Note that the attachment module supports password encryption to the file. If a user would like to pass the password to encrypt or decrypt the file, the user needs to first encrypt the password for security purpose. Our system uses AES mode to encrypt the password for web service transmission.

Here are the example codes:

	private static Key aesKey = new SecretKeySpec("Mac02017Dms02017".getBytes(), "AES");

	public static String encryptDmsTransferPassword(String password) {
		try {
			Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
			// encrypt the text
			cipher.init(Cipher.ENCRYPT_MODE, aesKey);
			byte[] encrypted = cipher.doFinal(password.getBytes());
			return DatatypeConverter.printHexBinary(encrypted);
		} catch (Exception e) {
			e.printStackTrace();
			return "";
		}
	}