/** * Returns the file type * * @param descriptor File descriptor of file or folder used for operation. * @return Returns the file type of the file * @since v2.0 */ public IFileSystemType GetFileType(FileDescriptor descriptor) { // Start logging elapsed time. long tIn = TimerUtil.CurrentTimeMillis(); ILogging logger = AppRegistryBridge.GetInstance().GetLoggingBridge(); if (logger != null) { logger.Log(ILoggingLogLevel.Debug, this.apiGroup.ToString(), "FileBridge executing getFileType..."); } IFileSystemType result = IFileSystemType.Unknown; if (this._delegate != null) { result = this._delegate.GetFileType(descriptor); if (logger != null) { logger.Log(ILoggingLogLevel.Debug, this.apiGroup.ToString(), "FileBridge executed 'getFileType' in " + (TimerUtil.CurrentTimeMillis() - tIn) + "ms."); } } else { if (logger != null) { logger.Log(ILoggingLogLevel.Error, this.apiGroup.ToString(), "FileBridge no delegate for 'getFileType'."); } } return(result); }
/** * Invokes the given method specified in the API request object. * * @param request APIRequest object containing method name and parameters. * @return APIResponse with status code, message and JSON response or a JSON null string for void functions. Status code 200 is OK, all others are HTTP standard error conditions. */ public new APIResponse Invoke(APIRequest request) { APIResponse response = new APIResponse(); int responseCode = 200; String responseMessage = "OK"; String responseJSON = "null"; switch (request.GetMethodName()) { case "canRead": FileDescriptor descriptor0 = GetJSONProcessor().DeserializeObject <FileDescriptor>(request.GetParameters()[0]); bool response0 = this.CanRead(descriptor0); responseJSON = GetJSONProcessor().SerializeObject(response0); break; case "canWrite": FileDescriptor descriptor1 = GetJSONProcessor().DeserializeObject <FileDescriptor>(request.GetParameters()[0]); bool response1 = this.CanWrite(descriptor1); responseJSON = GetJSONProcessor().SerializeObject(response1); break; case "create": FileDescriptor descriptor2 = GetJSONProcessor().DeserializeObject <FileDescriptor>(request.GetParameters()[0]); IFileResultCallback callback2 = new FileResultCallbackImpl(request.GetAsyncId()); this.Create(descriptor2, callback2); break; case "delete": FileDescriptor descriptor3 = GetJSONProcessor().DeserializeObject <FileDescriptor>(request.GetParameters()[0]); bool cascade3 = GetJSONProcessor().DeserializeObject <bool>(request.GetParameters()[1]); bool response3 = this.Delete(descriptor3, cascade3); responseJSON = GetJSONProcessor().SerializeObject(response3); break; case "exists": FileDescriptor descriptor4 = GetJSONProcessor().DeserializeObject <FileDescriptor>(request.GetParameters()[0]); bool response4 = this.Exists(descriptor4); responseJSON = GetJSONProcessor().SerializeObject(response4); break; case "getContent": FileDescriptor descriptor5 = GetJSONProcessor().DeserializeObject <FileDescriptor>(request.GetParameters()[0]); IFileDataLoadResultCallback callback5 = new FileDataLoadResultCallbackImpl(request.GetAsyncId()); this.GetContent(descriptor5, callback5); break; case "getFileStorageType": FileDescriptor descriptor6 = GetJSONProcessor().DeserializeObject <FileDescriptor>(request.GetParameters()[0]); IFileSystemStorageType response6 = this.GetFileStorageType(descriptor6); responseJSON = GetJSONProcessor().SerializeObject(response6); break; case "getFileType": FileDescriptor descriptor7 = GetJSONProcessor().DeserializeObject <FileDescriptor>(request.GetParameters()[0]); IFileSystemType response7 = this.GetFileType(descriptor7); responseJSON = GetJSONProcessor().SerializeObject(response7); break; case "getSecurityType": FileDescriptor descriptor8 = GetJSONProcessor().DeserializeObject <FileDescriptor>(request.GetParameters()[0]); IFileSystemSecurity response8 = this.GetSecurityType(descriptor8); responseJSON = GetJSONProcessor().SerializeObject(response8); break; case "isDirectory": FileDescriptor descriptor9 = GetJSONProcessor().DeserializeObject <FileDescriptor>(request.GetParameters()[0]); bool response9 = this.IsDirectory(descriptor9); responseJSON = GetJSONProcessor().SerializeObject(response9); break; case "listFiles": FileDescriptor descriptor10 = GetJSONProcessor().DeserializeObject <FileDescriptor>(request.GetParameters()[0]); IFileListResultCallback callback10 = new FileListResultCallbackImpl(request.GetAsyncId()); this.ListFiles(descriptor10, callback10); break; case "listFilesForRegex": FileDescriptor descriptor11 = GetJSONProcessor().DeserializeObject <FileDescriptor>(request.GetParameters()[0]); string regex11 = GetJSONProcessor().DeserializeObject <string>(request.GetParameters()[1]); IFileListResultCallback callback11 = new FileListResultCallbackImpl(request.GetAsyncId()); this.ListFilesForRegex(descriptor11, regex11, callback11); break; case "mkDir": FileDescriptor descriptor12 = GetJSONProcessor().DeserializeObject <FileDescriptor>(request.GetParameters()[0]); bool recursive12 = GetJSONProcessor().DeserializeObject <bool>(request.GetParameters()[1]); bool response12 = this.MkDir(descriptor12, recursive12); responseJSON = GetJSONProcessor().SerializeObject(response12); break; case "move": FileDescriptor source13 = GetJSONProcessor().DeserializeObject <FileDescriptor>(request.GetParameters()[0]); FileDescriptor destination13 = GetJSONProcessor().DeserializeObject <FileDescriptor>(request.GetParameters()[1]); bool createPath13 = GetJSONProcessor().DeserializeObject <bool>(request.GetParameters()[2]); bool overwrite13 = GetJSONProcessor().DeserializeObject <bool>(request.GetParameters()[3]); IFileResultCallback callback13 = new FileResultCallbackImpl(request.GetAsyncId()); this.Move(source13, destination13, createPath13, overwrite13, callback13); break; case "setContent": FileDescriptor descriptor14 = GetJSONProcessor().DeserializeObject <FileDescriptor>(request.GetParameters()[0]); byte[] content14 = GetJSONProcessor().DeserializeObject <byte[]>(request.GetParameters()[1]); IFileDataStoreResultCallback callback14 = new FileDataStoreResultCallbackImpl(request.GetAsyncId()); this.SetContent(descriptor14, content14, callback14); break; default: // 404 - response null. responseCode = 404; responseMessage = "FileBridge does not provide the function '" + request.GetMethodName() + "' Please check your client-side API version; should be API version >= v2.2.15."; break; } response.SetResponse(responseJSON); response.SetStatusCode(responseCode); response.SetStatusMessage(responseMessage); return(response); }