use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Service in project kramerius by ceskaexpedice.
the class IiifAPI method manifest.
@GET
@Path("{pid}/manifest")
@Produces({ MediaType.APPLICATION_JSON + ";charset=utf-8" })
public Response manifest(@PathParam("pid") String pid) {
checkPid(pid);
try {
DocumentDto document = getIiifDocument(pid);
PropertyValue titleLabel = new PropertyValueSimpleImpl(document.getTitle());
Manifest manifest = new ManifestImpl(UriBuilder.fromUri(iiifUri).path(getClass(), "manifest").build(pid), titleLabel);
List<String> fieldList = new ArrayList<String>();
List<Canvas> canvases = new ArrayList<Canvas>();
List<String> children = ItemResourceUtils.solrChildrenPids(pid, fieldList, solrAccess, solrMemoization);
Map<String, Pair<Integer, Integer>> resolutions = getResolutions(children);
for (String p : children) {
String repPid = p.replace("/", "");
if (repPid.equals(pid)) {
continue;
}
DocumentDto page = getIiifDocument(repPid);
if (!"page".equals(page.getModel()))
continue;
String id = ApplicationURL.applicationURL(this.requestProvider.get()) + "/canvas/" + repPid;
Pair<Integer, Integer> resolution = resolutions.get(p);
if (resolution != null) {
Canvas canvas = new CanvasImpl(id, new PropertyValueSimpleImpl(page.getTitle()), resolution.getLeft(), resolution.getRight());
ImageResource resource = new ImageResourceImpl();
String resourceId = ApplicationURL.applicationURL(this.requestProvider.get()).toString() + "/iiif/" + repPid + "/full/full/0/default.jpg";
resource.setType("dctypes:Image");
resource.setId(resourceId);
resource.setHeight(resolution.getLeft());
resource.setWidth(resolution.getRight());
resource.setFormat("image/jpeg");
Service service = new ServiceImpl();
service.setContext("http://iiif.io/api/image/2/context.json");
service.setId(ApplicationURL.applicationURL(this.requestProvider.get()).toString() + "/iiif/" + repPid);
service.setProfile("http://iiif.io/api/image/2/level1.json");
resource.setService(service);
Image image = new ImageImpl();
image.setOn(new URI(id));
image.setResource(resource);
canvas.setImages(Collections.singletonList(image));
canvases.add(canvas);
}
}
// no pages - 500 ?
if (canvases.isEmpty()) {
throw new GenericApplicationException("cannot create manifest for pid '" + pid + "'");
}
Sequence sequence = new SequenceImpl();
sequence.setCanvases(canvases);
manifest.setSequences(Collections.singletonList(sequence));
return Response.ok().entity(toJSON(manifest)).build();
} catch (IOException e) {
throw new GenericApplicationException(e.getMessage());
} catch (URISyntaxException e) {
throw new GenericApplicationException(e.getMessage());
} catch (InterruptedException e) {
throw new GenericApplicationException(e.getMessage());
}
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Service in project dekorate by dekorateio.
the class KnativeExampleTest method shouldContainServiceWithPortNamedHttp1.
@Test
public void shouldContainServiceWithPortNamedHttp1() {
KubernetesList list = Serialization.unmarshalAsList(KnativeExampleTest.class.getClassLoader().getResourceAsStream("META-INF/dekorate/knative.yml"));
assertNotNull(list);
assertEquals(1, list.getItems().size());
Service s = findFirst(list, Service.class).orElseThrow(() -> new IllegalStateException("No knative service found!"));
assertNotNull(s);
Container c = s.getSpec().getTemplate().getSpec().getContainers().get(0);
assertEquals("http1", c.getPorts().get(0).getName());
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Service in project dekorate by dekorateio.
the class Issue409Test method shouldHaveCustomImageInKnativeYaml.
@Test
public void shouldHaveCustomImageInKnativeYaml() {
Service s = Serialization.unmarshal(Service.class.getClassLoader().getResourceAsStream("META-INF/dekorate/knative.yml"));
assertNotNull(s);
Container c = s.getSpec().getTemplate().getSpec().getContainers().get(0);
assertNotNull(c);
String image = c.getImage();
assertEquals("my-group/my-name:my-version", image);
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Service in project dekorate by dekorateio.
the class Issue572Test method shouldHaveMatchingPath.
@Test
public void shouldHaveMatchingPath() {
KubernetesList list = Serialization.unmarshalAsList(getClass().getClassLoader().getResourceAsStream("META-INF/dekorate/knative.yml"));
assertNotNull(list);
Service s = findFirst(list, Service.class).orElseThrow(() -> new IllegalStateException());
assertNotNull(s);
assertEquals("cluster-local", s.getMetadata().getLabels().get("serving.knative.dev/visibility"));
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Service in project dekorate by dekorateio.
the class Issue442MultiPlatformTest method shouldHaveCustomGroupAndVersionInKnativeYml.
@Test
public void shouldHaveCustomGroupAndVersionInKnativeYml() {
KubernetesList list = Serialization.unmarshalAsList(Issue442MultiPlatformTest.class.getClassLoader().getResourceAsStream("META-INF/dekorate/knative.yml"));
assertNotNull(list);
Service s = findFirst(list, Service.class).orElseThrow(() -> new IllegalStateException());
assertNotNull(s);
Map<String, String> labels = s.getMetadata().getLabels();
assertNotNull(labels);
assertEquals("kn-group", labels.get(Labels.PART_OF));
assertEquals("1.0-knative", labels.get(Labels.VERSION));
}
Aggregations