Ejemplo n.º 1
0
        /// <summary>
        /// Move folder
        /// </summary>
        /// <param name="request">Request. <see cref="MoveFolderRequest" /></param>
        public void MoveFolder(MoveFolderRequest request)
        {
            // verify the required parameter 'srcPath' is set
            if (request.srcPath == null)
            {
                throw new ApiException(400, "Missing required parameter 'srcPath' when calling MoveFolder");
            }

            // verify the required parameter 'destPath' is set
            if (request.destPath == null)
            {
                throw new ApiException(400, "Missing required parameter 'destPath' when calling MoveFolder");
            }

            // create path and map variables
            var resourcePath = this.configuration.GetServerUrl() + "/editor/storage/folder/move/{srcPath}";

            resourcePath = Regex
                           .Replace(resourcePath, "\\*", string.Empty)
                           .Replace("&amp;", "&")
                           .Replace("/?", "?");
            resourcePath = UrlHelper.AddPathParameter(resourcePath, "srcPath", request.srcPath);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "destPath", request.destPath);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "srcStorageName", request.srcStorageName);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "destStorageName", request.destStorageName);

            this.apiInvoker.InvokeApi(
                resourcePath,
                "PUT",
                null,
                null,
                null);
        }
Ejemplo n.º 2
0
        public HttpResponseMessage MoveFolder(MoveFolderRequest moveFolderRequest)
        {
            var groupId    = this.FindGroupId(this.Request);
            var moduleId   = this.Request.FindModuleId();
            var moduleMode = new SettingsManager(moduleId, groupId).Mode;

            ItemsManager.Instance.MoveFolder(moveFolderRequest.SourceFolderId, moveFolderRequest.DestinationFolderId, moduleMode, groupId);
            return(this.Request.CreateResponse(HttpStatusCode.OK, new { Status = 0 }));
        }
        /// <summary>
        /// Move folder
        /// </summary>
        /// <param name="request">Request. <see cref="MoveFolderRequest" /></param>
        /// <returns><see cref=""/></returns>
        public void MoveFolder(MoveFolderRequest request)
        {
            // verify the required parameter 'srcPath' is set
            if (request.srcPath == null)
            {
                throw new ApiException(400, "Missing required parameter 'srcPath' when calling MoveFolder");
            }

            // verify the required parameter 'destPath' is set
            if (request.destPath == null)
            {
                throw new ApiException(400, "Missing required parameter 'destPath' when calling MoveFolder");
            }

            // create path and map variables
            var resourcePath = this.configuration.GetApiRootUrl() + "/ocr/storage/folder/move/{srcPath}";

            resourcePath = Regex
                           .Replace(resourcePath, "\\*", string.Empty)
                           .Replace("&amp;", "&")
                           .Replace("/?", "?");
            resourcePath = UrlHelper.AddPathParameter(resourcePath, "srcPath", request.srcPath);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "destPath", request.destPath);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "srcStorageName", request.srcStorageName);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "destStorageName", request.destStorageName);

            try
            {
                var response = this.apiInvoker.InvokeApi <string>(
                    resourcePath,
                    "PUT",
                    null,
                    null,
                    null);
                if (response != null)
                {
                    return;
                }

                return;
            }
            catch (ApiException ex)
            {
                if (ex.ErrorCode == 404)
                {
                    return;
                }

                throw;
            }
        }
        public static void Run()
        {
            var apiInstance = new FolderApi(Constants.GetConfig());

            try
            {
                var request = new MoveFolderRequest("Annotationdocs1", "Annotationdocs1", Constants.MyStorage, Constants.MyStorage);

                apiInstance.MoveFolder(request);
                Console.WriteLine("Expected response type is Void: 'Annotationdocs1' folder moved to 'Annotationdocs1'.");
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling FolderApi: " + e.Message);
            }
        }
Ejemplo n.º 5
0
        public void TestMoveFolder()
        {
            this.UploadFileToStorage(
                remoteDataFolder + "/TestMoveFolderSrc/TestMoveFolderSrc.docx",
                null,
                null,
                File.ReadAllBytes(LocalTestDataFolder + localFile)
                );

            var request = new MoveFolderRequest(
                destPath: BaseTestOutPath + "/TestMoveFolderDest_" + CreateRandomGuid,
                srcPath: remoteDataFolder + "/TestMoveFolderSrc"
                );

            this.WordsApi.MoveFolder(request);
        }
Ejemplo n.º 6
0
        public static void Run()
        {
            var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
            var apiInstance   = new FolderApi(configuration);

            try
            {
                var request = new MoveFolderRequest("viewerdocs1", "viewerdocs\viewerdocs1", Common.MyStorage, Common.MyStorage);

                apiInstance.MoveFolder(request);
                Console.WriteLine("Expected response type is Void: 'viewerdocs1' folder moved to 'viewerdocs/viewerdocs1'.");
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling FolderApi: " + e.Message);
            }
        }
Ejemplo n.º 7
0
        public void TestCopyMoveFolder()
        {
            // Create temp folder
            var cRequest = new CreateFolderRequest("temp");

            FolderApi.CreateFolder(cRequest);

            // Copy folder
            var copyRequest = new CopyFolderRequest("temp", "temp1");

            FolderApi.CopyFolder(copyRequest);

            // Check copied folder
            var eRequest  = new ObjectExistsRequest("temp1");
            var eResponse = StorageApi.ObjectExists(eRequest);

            Assert.IsTrue(eResponse.Exists);
            Assert.IsTrue(eResponse.IsFolder);

            // Copy folder
            var moveRequest = new MoveFolderRequest("temp1", "temp2");

            FolderApi.MoveFolder(moveRequest);

            // Check moved folder
            eRequest  = new ObjectExistsRequest("temp1");
            eResponse = StorageApi.ObjectExists(eRequest);
            Assert.IsFalse(eResponse.Exists);
            eRequest  = new ObjectExistsRequest("temp2");
            eResponse = StorageApi.ObjectExists(eRequest);
            Assert.IsTrue(eResponse.Exists);

            // Delete temp and temp2 folders
            var delRequest = new DeleteFolderRequest("temp", null, true);

            FolderApi.DeleteFolder(delRequest);
            delRequest = new DeleteFolderRequest("temp2", null, true);
            FolderApi.DeleteFolder(delRequest);
        }
Ejemplo n.º 8
0
        public object MoveFolder(MoveFolderRequest request)
        {
            // Variables.
            var result   = default(object);
            var rootId   = CoreConstants.System.Root.ToInvariantString();
            var parentId = GuidHelper.GetGuid(request.NewParentId);


            // Catch all errors.
            try
            {
                // Declare list of anonymous type.
                var savedDescendants = new[]
                {
                    new
                    {
                        Id   = string.Empty,
                        Path = new string[] { }
                    }
                }.Take(0).ToList();


                // Variables.
                var folderId   = GuidHelper.GetGuid(request.FolderId);
                var parentPath = Entities.Retrieve(parentId).Path;


                // Get folder and descendants.
                var folder      = Persistence.Retrieve(folderId);
                var descendants = Entities.RetrieveDescendants(folderId);


                // Check if destination folder is under current folder.
                var oldFolderPath = folder.Path;
                if (parentPath.Any(x => x == folderId))
                {
                    result = new
                    {
                        Success = false,
                        Reason  = FolderUnderItself
                    };
                    return(result);
                }


                // Move folder and descendants.
                var oldParentPath = oldFolderPath.Take(oldFolderPath.Length - 1).ToArray();
                var path          = EntityHelper.GetClientPath(Entities.MoveEntity(folder, parentPath));
                foreach (var descendant in descendants)
                {
                    var descendantParentPath = descendant.Path.Take(descendant.Path.Length - 1);
                    var descendantPathEnd    = descendantParentPath.Skip(oldParentPath.Length);
                    var newParentPath        = parentPath.Concat(descendantPathEnd).ToArray();
                    var clientPath           = EntityHelper.GetClientPath(
                        Entities.MoveEntity(descendant, newParentPath));
                    savedDescendants.Add(new
                    {
                        Id   = GuidHelper.GetString(descendant.Id),
                        Path = clientPath
                    });
                }


                // Success.
                result = new
                {
                    Success     = true,
                    Id          = GuidHelper.GetString(folderId),
                    Path        = path,
                    Descendants = savedDescendants.ToArray()
                };
            }
            catch (Exception ex)
            {
                // Error.
                LogHelper.Error <FoldersController>(MoveFolderError, ex);
                result = new
                {
                    Success = false,
                    Reason  = UnhandledError
                };
            }


            // Return result.
            return(result);
        }
Ejemplo n.º 9
0
        public object MoveFolder(MoveFolderRequest request)
        {
            // Variables.
            var result = default(object);
            var rootId = CoreConstants.System.Root.ToInvariantString();
            var parentId = GuidHelper.GetGuid(request.NewParentId);

            // Catch all errors.
            try
            {

                // Declare list of anonymous type.
                var savedDescendants = new[]
                {
                    new
                    {
                        Id = string.Empty,
                        Path = new string[] { }
                    }
                }.Take(0).ToList();

                // Variables.
                var folderId = GuidHelper.GetGuid(request.FolderId);
                var parentPath = Entities.Retrieve(parentId).Path;

                // Get folder and descendants.
                var folder = Persistence.Retrieve(folderId);
                var descendants = Entities.RetrieveDescendants(folderId);

                // Check if destination folder is under current folder.
                var oldFolderPath = folder.Path;
                if (parentPath.Any(x => x == folderId))
                {
                    result = new
                    {
                        Success = false,
                        Reason = FolderUnderItself
                    };
                    return result;
                }

                // Move folder and descendants.
                var oldParentPath = oldFolderPath.Take(oldFolderPath.Length - 1).ToArray();
                var path = EntityHelper.GetClientPath(Entities.MoveEntity(folder, parentPath));
                foreach (var descendant in descendants)
                {
                    var descendantParentPath = descendant.Path.Take(descendant.Path.Length - 1);
                    var descendantPathEnd = descendantParentPath.Skip(oldParentPath.Length);
                    var newParentPath = parentPath.Concat(descendantPathEnd).ToArray();
                    var clientPath = EntityHelper.GetClientPath(
                        Entities.MoveEntity(descendant, newParentPath));
                    savedDescendants.Add(new
                    {
                        Id = GuidHelper.GetString(descendant.Id),
                        Path = clientPath
                    });
                }

                // Success.
                result = new
                {
                    Success = true,
                    Id = GuidHelper.GetString(folderId),
                    Path = path,
                    Descendants = savedDescendants.ToArray()
                };

            }
            catch (Exception ex)
            {

                // Error.
                LogHelper.Error<FoldersController>(MoveFolderError, ex);
                result = new
                {
                    Success = false,
                    Reason = UnhandledError
                };

            }

            // Return result.
            return result;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Moves a Folder under a new resource parent.Returns an Operation which can be used to track the progress of thefolder move workflow.Upon success the Operation.response field will be populated with themoved Folder.Upon failure, a FolderOperationError categorizing the failure cause willbe returned - if the failure occurs synchronously then theFolderOperationError will be returned via the Status.details fieldand if it occurs asynchronously then the FolderOperation will be returnedvia the the Operation.error field.In addition, the Operation.metadata field will be populated with aFolderOperation message as an aid to stateless clients.Folder moves will be rejected if they violate either the naming, heightor fanout constraints described in the [CreateFolder] documentation.The caller must have `resourcemanager.folders.move` permission on thefolder's current and proposed new parent.
        /// Documentation https://developers.google.com/cloudresourcemanager/v2beta1/reference/folders/move
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated Cloudresourcemanager service.</param>
        /// <param name="name">The resource name of the Folder to move.Must be of the form folders/{folder_id}</param>
        /// <param name="body">A valid Cloudresourcemanager v2beta1 body.</param>
        /// <returns>OperationResponse</returns>
        public static Operation Move(CloudresourcemanagerService service, string name, MoveFolderRequest body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (name == null)
                {
                    throw new ArgumentNullException(name);
                }

                // Make the request.
                return(service.Folders.Move(body, name).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Folders.Move failed.", ex);
            }
        }