Search in sources :

Example 1 with LdapConfigurationDuplicatedException

use of org.gluu.oxtrust.api.server.util.LdapConfigurationDuplicatedException in project oxTrust by GluuFederation.

the class LDAPAuthenticationWebResource method createLdapConfiguration.

@POST
@Operation(summary = "Create a new configuration", description = "Create a new configuration")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = LdapConfigurationDTO.class)), description = "Success") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response createLdapConfiguration(@Valid LdapConfigurationDTO ldapConfiguration) {
    log(logger, "Create a new configuration");
    try {
        if (existingLdapConfigurationValidator.isInvalid(ldapConfiguration)) {
            throw new LdapConfigurationDuplicatedException(ldapConfiguration.getConfigId());
        }
        GluuLdapConfiguration gluuLdapConfiguration = ldapConfigurationDtoAssembly.fromDto(ldapConfiguration);
        ldapConfigurationService.save(gluuLdapConfiguration);
        return Response.ok(read(ldapConfiguration.getConfigId())).build();
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : LdapConfigurationDuplicatedException(org.gluu.oxtrust.api.server.util.LdapConfigurationDuplicatedException) GluuLdapConfiguration(org.gluu.model.ldap.GluuLdapConfiguration) LdapConfigurationDuplicatedException(org.gluu.oxtrust.api.server.util.LdapConfigurationDuplicatedException) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Aggregations

Operation (io.swagger.v3.oas.annotations.Operation)1 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)1 GluuLdapConfiguration (org.gluu.model.ldap.GluuLdapConfiguration)1 LdapConfigurationDuplicatedException (org.gluu.oxtrust.api.server.util.LdapConfigurationDuplicatedException)1 ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)1