[ML] Put back check for inconsistent job id
Lost during the refactor, this checks to make sure an ID in both the URL and the body match. Original commit: elastic/x-pack-elasticsearch@ef96275c99
This commit is contained in:
parent
9da18a14c5
commit
4041545cfa
|
@ -36,6 +36,7 @@ import org.elasticsearch.transport.TransportService;
|
|||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.ml.job.JobManager;
|
||||
import org.elasticsearch.xpack.ml.job.config.Job;
|
||||
import org.elasticsearch.xpack.ml.job.messages.Messages;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
@ -66,6 +67,9 @@ public class PutJobAction extends Action<PutJobAction.Request, PutJobAction.Resp
|
|||
Job.Builder job = Job.PARSER.apply(parser, null);
|
||||
if (job.getId() == null) {
|
||||
job.setId(jobId);
|
||||
} else if (!Strings.isNullOrEmpty(jobId) && !jobId.equals(job.getId())) {
|
||||
// If we have both URI and body job ID, they must be identical
|
||||
throw new IllegalArgumentException(Messages.getMessage(Messages.INCONSISTENT_ID, Job.ID.getPreferredName(), job.getId(), jobId));
|
||||
}
|
||||
if (job.getCreateTime() == null) {
|
||||
job.setCreateTime(new Date());
|
||||
|
|
Loading…
Reference in New Issue