backend-api OUTV разрешил для /launchers/specific

This commit is contained in:
AKurakin 2023-08-17 11:13:10 +03:00
parent 19579ec0b0
commit fd22d89ecb

View file

@ -4,6 +4,8 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
@ -29,6 +31,7 @@ import ru.spcex.platform.enumeration.Task;
import ru.spcex.platform.imdg.api.Imdg;
import ru.spcex.platform.imdg.api.ImdgProvider;
import ru.spcex.platform.utils.enumeration.EnumMessage;
import ru.spcex.platform.utils.enumeration.IEnumKey;
import ru.spcex.platform.utils.enumeration.IMessageResolver;
import java.util.Collection;
@ -38,6 +41,7 @@ import java.util.concurrent.ExecutionException;
@Controller
@RequestMapping("/launchers")
public class LauncherController extends AbstractQueueController {
protected final Logger log = LoggerFactory.getLogger(getClass());
private final IStateLoader stateLoader;
private final Imdg<User> userImdg;
private final Imdg<AbstractDictionary> taskDictionary;
@ -100,9 +104,9 @@ public class LauncherController extends AbstractQueueController {
if (taskEnum == null) {
throw new NotFound404Exception("task dictionary element with code '" + launcherNew.getTask() + "'");
}
if (!Task.startOfClearing.getKey().equals(taskEnum.getCode())) {
throw new IllegalStateException(String.format("Task %s not support request with body", taskEnum.getCode()));
}
if (!IEnumKey.contains(taskEnum.getCode(), Task.startOfClearing, Task.dbfExport_OUTV)) {
log.warn(String.format("Task %s not support request with body", taskEnum.getCode()));
} // else В мете эти модели с дополнительными параметрами (OUTV).
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String username = KeycloakUtils.getUserNameFromAuthentication(authentication);
User user = userImdg.getFirstObjectByFieldValues(Map.of("identifier", username));