controllers docs checkpoint
This commit is contained in:
@ -35,6 +35,10 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
|
||||
/**
|
||||
* Rest controller to Config related endpoints. More detailed api docs is
|
||||
* available via swagger
|
||||
*/
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping("/api/" + App.API_VERSION + "/configurator")
|
||||
@ -47,14 +51,22 @@ public class ConfigController {
|
||||
|
||||
@Value("${plannaplan.dev}")
|
||||
private boolean isDev;
|
||||
|
||||
|
||||
@Autowired
|
||||
private ConfiguratorService contrl;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
private UserService userService;
|
||||
|
||||
/**
|
||||
* @param file file .xlsx that contains courses and groups with
|
||||
* apoinnted rules
|
||||
* @param firstTourBegin formated string dd.MM.yyyy
|
||||
* @param firstTourEnd formated string dd.MM.yyyy
|
||||
* @param secondTourBegin formated string dd.MM.yyyy
|
||||
* @param secondTourEnd formated string dd.MM.yyyy
|
||||
* @return was config success
|
||||
*/
|
||||
@PostMapping(path = "/config", consumes = { "multipart/form-data" })
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@ApiOperation("Imports data to system. To call you need to provide ADMIN token")
|
||||
@ -82,7 +94,13 @@ public class ConfigController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param firstTourBegin formated string dd.MM.yyyy
|
||||
* @param firstTourEnd formated string dd.MM.yyyy
|
||||
* @param secondTourBegin formated string dd.MM.yyyy
|
||||
* @param secondTourEnd formated string dd.MM.yyyy
|
||||
* @return was operation successful
|
||||
*/
|
||||
@PostMapping(path = "/config/tours")
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@ApiOperation("Set tours dates. To call you need to provide ADMIN token")
|
||||
@ -104,12 +122,15 @@ public class ConfigController {
|
||||
return new ResponseEntity<>("Sucess", HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param file file .xlsx that contains courses and groups with
|
||||
* @return was operation successfull
|
||||
*/
|
||||
@PostMapping(path = "/config/courses", consumes = { "multipart/form-data" })
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@ApiOperation("Imports data to system. To call you need to provide ADMIN token")
|
||||
public ResponseEntity<String> configAppChangeCources(
|
||||
@RequestParam("file") @ApiParam(value = "file .xlsx that contains courses and groups with apoinnted rules") MultipartFile file)
|
||||
{
|
||||
@RequestParam("file") @ApiParam(value = "file .xlsx that contains courses and groups with apoinnted rules") MultipartFile file) {
|
||||
try {
|
||||
this.contrl.importCoursesStream(file.getInputStream());
|
||||
return new ResponseEntity<>("Sucess", HttpStatus.OK);
|
||||
@ -118,15 +139,20 @@ public class ConfigController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ticket CAS ticket to get user wuthority
|
||||
* @return was admin created
|
||||
*/
|
||||
@PostMapping(path = "/admin/init")
|
||||
@ApiOperation("It can be run only in the initialization of the application. It will create admin user to manage the application.")
|
||||
public ResponseEntity<String> initAdmin(@RequestParam("ticket") @ApiParam(value = "Ticket for validation.") String ticket){
|
||||
if (this.userService.adminExists()){
|
||||
public ResponseEntity<String> initAdmin(
|
||||
@RequestParam("ticket") @ApiParam(value = "Ticket for validation.") String ticket) {
|
||||
if (this.userService.adminExists()) {
|
||||
return new ResponseEntity<>("Admin had been already created.", HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
|
||||
final CasValidator validator = isDev ? new DefaultUAMCasValidator(serviceUrl, ticket)
|
||||
: new CustomUAMCasValidator(serviceUrl, ticket);
|
||||
: new CustomUAMCasValidator(serviceUrl, ticket);
|
||||
|
||||
try {
|
||||
final CasUserIdentity casUserIdentity = validator.validate();
|
||||
@ -140,5 +166,5 @@ public class ConfigController {
|
||||
} catch (Exception e) {
|
||||
return new ResponseEntity<>("Internal Server Error", HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user