in genie-web/src/main/java/com/netflix/genie/web/apis/rest/v3/hateoas/assemblers/JobModelAssembler.java [52:152]
public EntityModel<Job> toModel(final Job job) {
final String id = job.getId().orElseThrow(IllegalArgumentException::new);
final EntityModel<Job> jobModel = EntityModel.of(job);
try {
jobModel.add(
WebMvcLinkBuilder.linkTo(
WebMvcLinkBuilder
.methodOn(JobRestController.class)
.getJob(id)
).withSelfRel()
);
// TODO: https://github.com/spring-projects/spring-hateoas/issues/186 should be fixed in .20 currently .19
// jobResource.add(
// ControllerLinkBuilder.linkTo(
// JobRestController.class,
// JobRestController.class.getMethod(
// "getJobOutput",
// String.class,
// String.class,
// HttpServletRequest.class,
// HttpServletResponse.class
// ),
// job.getId(),
// null,
// null,
// null
// ).withRel("output")
// );
jobModel.add(
WebMvcLinkBuilder
.linkTo(JobRestController.class)
.slash(id)
.slash(OUTPUT_LINK)
.withRel(OUTPUT_LINK)
);
jobModel.add(
WebMvcLinkBuilder.linkTo(
WebMvcLinkBuilder
.methodOn(JobRestController.class)
.getJobRequest(id)
).withRel(REQUEST_LINK)
);
jobModel.add(
WebMvcLinkBuilder.linkTo(
WebMvcLinkBuilder
.methodOn(JobRestController.class)
.getJobExecution(id)
).withRel(EXECUTION_LINK)
);
jobModel.add(
WebMvcLinkBuilder.linkTo(
WebMvcLinkBuilder
.methodOn(JobRestController.class)
.getJobMetadata(id)
).withRel(METADATA_LINK)
);
jobModel.add(
WebMvcLinkBuilder.linkTo(
WebMvcLinkBuilder
.methodOn(JobRestController.class)
.getJobStatus(id)
).withRel(STATUS_LINK)
);
jobModel.add(
WebMvcLinkBuilder.linkTo(
WebMvcLinkBuilder
.methodOn(JobRestController.class)
.getJobCluster(id)
).withRel(CLUSTER_LINK)
);
jobModel.add(
WebMvcLinkBuilder.linkTo(
WebMvcLinkBuilder
.methodOn(JobRestController.class)
.getJobCommand(id)
).withRel(COMMAND_LINK)
);
jobModel.add(
WebMvcLinkBuilder.linkTo(
WebMvcLinkBuilder
.methodOn(JobRestController.class)
.getJobApplications(id)
).withRel(APPLICATIONS_LINK)
);
} catch (final GenieException | GenieCheckedException ge) {
// If we can't convert it we might as well force a server exception
throw new RuntimeException(ge);
}
return jobModel;
}