public boolean testAuthorizedPlatform()

in bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/LLMConfigServiceImpl.java [159:194]


    public boolean testAuthorizedPlatform(AuthPlatformDTO authPlatformDTO) {
        if (authPlatformDTO.getId() != null) {
            authPlatformDTO =
                    AuthPlatformConverter.INSTANCE.fromPO2DTO(authPlatformDao.findById(authPlatformDTO.getId()));
        }

        PlatformPO platformPO = validateAndGetPlatform(authPlatformDTO.getPlatformId());

        List<String> supportModels = List.of(platformPO.getSupportModels().split(","));
        if (supportModels.isEmpty() || !supportModels.contains(authPlatformDTO.getModel())) {
            throw new ApiException(ApiExceptionEnum.MODEL_NOT_SUPPORTED);
        }

        if (authPlatformDTO.getId() != null) {
            AuthPlatformPO authPlatformPO = validateAndGetAuthPlatform(authPlatformDTO.getId());

            AuthPlatformDTO existAuthPlatformDTO = AuthPlatformConverter.INSTANCE.fromPO2DTO(authPlatformPO);
            authPlatformDTO.setAuthCredentials(existAuthPlatformDTO.getAuthCredentials());
            authPlatformDTO.setModel(existAuthPlatformDTO.getModel());
        }

        Map<String, String> credentialSet =
                getStringMap(authPlatformDTO, PlatformConverter.INSTANCE.fromPO2DTO(platformPO));

        if (!testAuthorization(platformPO.getName(), authPlatformDTO.getModel(), credentialSet)) {
            throw new ApiException(ApiExceptionEnum.CREDIT_INCORRECT);
        }

        if (authPlatformDTO.getId() != null) {
            AuthPlatformPO authPlatformPO = AuthPlatformConverter.INSTANCE.fromDTO2PO(authPlatformDTO);
            authPlatformPO.setStatus(AuthPlatformStatus.AVAILABLE.getCode());
            authPlatformDao.partialUpdateById(authPlatformPO);
        }

        return true;
    }