private QueryResponse CreateJob(DirectoryScanJob model) { Uri uriResult; bool validUri = Uri.TryCreate(model.CallbackUrl, UriKind.Absolute, out uriResult) && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps); if (!validUri) { var response = new QueryResponse { Valid = false }; response.Errors = new List <Error> { new Error { Code = "ErrorCreatingJob", Type = "Client", Message = string.Format("Invalid CallbackUrl format: {0}", model.CallbackUrl) } }; return(response); } var dataMap = new Dictionary <string, object> { { "DIRECTORY_NAME", model.DirectoryName }, { "CALLBACK_URL", model.CallbackUrl }, { "MINIMUM_UPDATE_AGE", model.MinimumUpdateAge.ToString(CultureInfo.InvariantCulture) }, { "LAST_MODIFIED_TIME", model.LastModifiedTime.ToString("o") } }; return(base.CreateJob(model, typeof(RDirectoryScanJob), dataMap, model.Description)); }
public QueryResponse Put([FromBody] DirectoryScanJob model) { Logger.InfoFormat("Entered DirectoryScanJobsController.Put(). Job Name = {0}", model.JobName); var authorizedJobGroups = _permissionsHelper.GetAuthorizedJobGroups().ToList(); if ((authorizedJobGroups.Contains(model.JobGroup) || authorizedJobGroups.Contains("*")) && model.JobGroup != "*") { return(CreateJob(model)); } throw new HttpResponseException(HttpStatusCode.Unauthorized); }
private QueryResponse CreateJob(DirectoryScanJob model) { Uri uriResult; bool validUri = Uri.TryCreate(model.CallbackUrl, UriKind.Absolute, out uriResult) && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps); if (!validUri) { var response = new QueryResponse {Valid = false}; response.Errors = new List<Error> { new Error { Code = "ErrorCreatingJob", Type = "Client", Message = string.Format("Invalid CallbackUrl format: {0}", model.CallbackUrl) } }; return response; } var dataMap = new Dictionary<string, object> { {"DIRECTORY_NAME", model.DirectoryName}, {"CALLBACK_URL", model.CallbackUrl}, {"MINIMUM_UPDATE_AGE", model.MinimumUpdateAge.ToString(CultureInfo.InvariantCulture)}, {"LAST_MODIFIED_TIME", model.LastModifiedTime.ToString("o")} }; return base.CreateJob(model, typeof (RDirectoryScanJob), dataMap, model.Description); }