refactor(DirectoryController): remove try-catch block
This commit is contained in:
parent
4725614bb3
commit
9fd66d41ca
@ -37,8 +37,6 @@ public class DirectoryController : ControllerBase
|
|||||||
|
|
||||||
[HttpGet("Root/{username}")]
|
[HttpGet("Root/{username}")]
|
||||||
public IActionResult GetRootOf(string username)
|
public IActionResult GetRootOf(string username)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
var root = _dirSearchService.GetSearchRootCache(username);
|
var root = _dirSearchService.GetSearchRootCache(username);
|
||||||
|
|
||||||
@ -53,17 +51,9 @@ public class DirectoryController : ControllerBase
|
|||||||
schemaClassName = root.SchemaClassName
|
schemaClassName = root.SchemaClassName
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "{Message}", ex.Message);
|
|
||||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("CustomSearchFilter")]
|
[HttpGet("CustomSearchFilter")]
|
||||||
public IActionResult GetAllCustomFilters(string? filtername)
|
public IActionResult GetAllCustomFilters(string? filtername)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
if (filtername is null)
|
if (filtername is null)
|
||||||
{
|
{
|
||||||
@ -75,17 +65,9 @@ public class DirectoryController : ControllerBase
|
|||||||
return filter is null ? NotFound() : Ok(filter);
|
return filter is null ? NotFound() : Ok(filter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "{Message}", ex.Message);
|
|
||||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> CreateSearchRoot([FromBody] SearchRootCreateDto searchRootCreateDto)
|
public async Task<IActionResult> CreateSearchRoot([FromBody] SearchRootCreateDto searchRootCreateDto)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
var dirEntryUsername = searchRootCreateDto.Username ?? CurrentUser;
|
var dirEntryUsername = searchRootCreateDto.Username ?? CurrentUser;
|
||||||
if (dirEntryUsername is null)
|
if (dirEntryUsername is null)
|
||||||
@ -103,17 +85,9 @@ public class DirectoryController : ControllerBase
|
|||||||
_dirSearchService.SetSearchRootCache(userResult.Data.Username, searchRootCreateDto.Password);
|
_dirSearchService.SetSearchRootCache(userResult.Data.Username, searchRootCreateDto.Password);
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "{Message}", ex.Message);
|
|
||||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("SearchByFilter/{filter}")]
|
[HttpGet("SearchByFilter/{filter}")]
|
||||||
public IActionResult SearchByFilter([FromRoute] string filter, string? dirEntryUsername, params string[] propName)
|
public IActionResult SearchByFilter([FromRoute] string filter, string? dirEntryUsername, params string[] propName)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
dirEntryUsername ??= CurrentUser;
|
dirEntryUsername ??= CurrentUser;
|
||||||
|
|
||||||
@ -126,17 +100,9 @@ public class DirectoryController : ControllerBase
|
|||||||
return StatusCode(StatusCodes.Status424FailedDependency);
|
return StatusCode(StatusCodes.Status424FailedDependency);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "{Message}", ex.Message);
|
|
||||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("SearchByFilterName/{filterName}")]
|
[HttpGet("SearchByFilterName/{filterName}")]
|
||||||
public IActionResult SearchByFilterName([FromRoute] string filterName, string? dirEntryUsername, params string[] propName)
|
public IActionResult SearchByFilterName([FromRoute] string filterName, string? dirEntryUsername, params string[] propName)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
dirEntryUsername ??= CurrentUser;
|
dirEntryUsername ??= CurrentUser;
|
||||||
|
|
||||||
@ -154,18 +120,10 @@ public class DirectoryController : ControllerBase
|
|||||||
return StatusCode(StatusCodes.Status424FailedDependency);
|
return StatusCode(StatusCodes.Status424FailedDependency);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "{Message}", ex.Message);
|
|
||||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("Group")]
|
[HttpGet("Group")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public IActionResult GetGroups(params string[] propName)
|
public IActionResult GetGroups(params string[] propName)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
string dirEntryUsername = CurrentUser!;
|
string dirEntryUsername = CurrentUser!;
|
||||||
|
|
||||||
@ -183,17 +141,9 @@ public class DirectoryController : ControllerBase
|
|||||||
return StatusCode(StatusCodes.Status424FailedDependency);
|
return StatusCode(StatusCodes.Status424FailedDependency);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "{Message}", ex.Message);
|
|
||||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("User")]
|
[HttpGet("User")]
|
||||||
public IActionResult GetUsersByGroupName([FromQuery] string? groupName = null)
|
public IActionResult GetUsersByGroupName([FromQuery] string? groupName = null)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
string[] propName = { "memberof", "samaccountname", "givenname", "sn", "mail" };
|
string[] propName = { "memberof", "samaccountname", "givenname", "sn", "mail" };
|
||||||
string dirEntryUsername = CurrentUser!;
|
string dirEntryUsername = CurrentUser!;
|
||||||
@ -222,12 +172,6 @@ public class DirectoryController : ControllerBase
|
|||||||
return StatusCode(StatusCodes.Status424FailedDependency);
|
return StatusCode(StatusCodes.Status424FailedDependency);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "{Message}", ex.Message);
|
|
||||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private string? CurrentUser
|
private string? CurrentUser
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user