private T CreatePathOnlyOperation <T>(PatchOperation operation, ITestApiContext context) where T : PatchOperationBase { var validationResult = this._pathOnlyValidationService.Validate(operation); if (validationResult.HasErrors()) { context.AddError(string.Format("{0} The instruction was ignored.", validationResult)); return(null); } if (operation.Value != null) { context.AddWarning(FormatTooMuchInformationWarningMessage(operation, "value")); } if (!operation.From.IsNullOrEmpty()) { var warning = FormatTooMuchInformationWarningMessage(operation, "from"); context.AddWarning(warning); } return(this.CreateOperation <T>(operation.Path)); }
/// <summary> /// Appends the links to. /// </summary> /// <param name="webLinkable">The <see cref="IWebLinkable" /> object.</param> /// <param name="endPoint"></param> /// <param name="context">Context containing information about the request.</param> //public void AppendFunctionsTo(IWebLinkable webLinkable, ApiResourceEndPoint endPoint, ITestApiContext context) //{ // var webLinkableType = webLinkable.GetType(); // if (webLinkableType != CreatesLinksFor) // { // context.AddWarning( // string.Format( // @"Trying to add functions to invalid type {0} in LightboxDetailFunctionAppender. Operation Cancelled", // webLinkableType)); // return; // } // var securableObjectPermission = // context.AuthenticatedUser.Permissions.FirstOrDefault( // p => p.SecurableObjectType.Equals(SecurableObjectType.OrgUnit)); // webLinkable.Links.Self = "lightbox"; // if (securableObjectPermission == null) // { // AddFunctionsToWebLinkable( // f => f.Value.ResourceEndPoints.Contains(endPoint) && f.Value.Permissions == ulong.MaxValue, // webLinkable.Links); // return; // } // AddFunctionsToWebLinkable( // f => f.Value.ResourceEndPoints.Contains(endPoint) && (f.Value.Permissions & securableObjectPermission.Permissions) > 0 || f.Value.Permissions == ulong.MaxValue, // webLinkable.Links); //} public void AppendFunctionsTo(IWebLinkable webLinkable, ApiResourceEndPoint endPoint, ITestApiContext context) { var webLinkableType = webLinkable.GetType(); if (webLinkableType != CreatesLinksFor) { context.AddWarning( string.Format( @"Trying to add functions to invalid type {0} in LightboxDetailFunctionAppender. Operation Cancelled", webLinkableType)); return; } webLinkable.Links.Self = "tickets"; AddFunctionsToWebLinkable( f => f.Value.ResourceEndPoints.Contains(endPoint) && f.Value.Permissions == ulong.MaxValue, webLinkable.Links); }