use of org.ovirt.engine.api.v3.types.V3API in project ovirt-engine by oVirt.
the class V3SystemServer method replaceLinkHeader.
private Response replaceLinkHeader(Response response) {
Object entity = response.getEntity();
if (entity != null && entity instanceof V3API) {
V3API api = (V3API) entity;
List<V3Link> links = api.getLinks();
if (links != null) {
String root = CurrentManager.get().getRoot();
String header = links.stream().map(link -> String.format("<%s%s>; rel=%s", root, link.getHref(), link.getRel())).collect(joining(","));
response = Response.fromResponse(response).header("Link", null).header("Link", header).build();
}
}
return response;
}
use of org.ovirt.engine.api.v3.types.V3API in project ovirt-engine by oVirt.
the class V3ApiOutAdapter method adapt.
@Override
public V3API adapt(Api from) {
V3API to = new V3API();
if (from.isSetActions()) {
to.setActions(adaptOut(from.getActions()));
}
// Remove the links for "rels" that are new in version 4 of the API:
if (from.isSetLinks()) {
List<Link> links = from.getLinks().stream().filter(link -> !RELS_TO_REMOVE.contains(link.getRel())).collect(toList());
to.getLinks().addAll(adaptOut(links));
}
// In version 4 of the API the "capabilities" resource was removed, but it still exists in version 3, so we
// need to explicitly add a the link:
to.getLinks().add(0, makeCapabilitiesLink());
if (from.isSetSpecialObjects()) {
to.setSpecialObjects(adaptOut(from.getSpecialObjects()));
}
if (from.isSetProductInfo()) {
to.setProductInfo(adaptOut(from.getProductInfo()));
}
if (from.isSetSummary()) {
to.setSummary(adaptOut(from.getSummary()));
}
if (from.isSetTime()) {
to.setTime(from.getTime());
}
return to;
}
Aggregations