Package org.apache.wink.server.utils

Examples of org.apache.wink.server.utils.SingleLinkBuilder


        if (!child) {
            entry.setBase(uriInfo.getAbsolutePath().toString());
        }

        // generate the edit link
        SingleLinkBuilder singleLinkBuilder = linkBuilders.createSingleLinkBuilder();
        if (editable) {
            singleLinkBuilder.subResource(DefectsResource.DEFECT_URL)
                .pathParam(DefectsResource.DEFECT_VAR, id).rel(AtomConstants.ATOM_REL_EDIT)
                .build(entry.getLinks());
        }

        // if this entry is not part of a history response, then generate the
        // history link
        if (!history) {
            singleLinkBuilder.subResource(DefectsResource.DEFECT_HISTORY_URL)
                .pathParam(DefectsResource.DEFECT_VAR, id).rel(AtomConstants.ATOM_REL_HISTORY)
                .type(MediaType.APPLICATION_ATOM_XML_TYPE).build(entry.getLinks());
        }

        // generate system links to self and alternate.
View Full Code Here


        // generate system links
        linkProcessor.createSystemLinksBuilder().resource(DefectsResource.class).subResource(defect
            .getId()).build(entry.getLinks());

        // generate related links - each defect can access its tests
        SingleLinkBuilder singleLinkBuilder = linkProcessor.createSingleLinkBuilder();

        singleLinkBuilder.resource(DefectTestsResource.class).pathParam(DefectsResource.DEFECT_VAR,
                                                                        defect.getId())
            .rel("related").type(MediaType.APPLICATION_ATOM_XML_TYPE).build(entry.getLinks());

        // add attachment link
        if (defect.getPathToAttachment() != null && defect.getPathToAttachment().length() > 0) {
            singleLinkBuilder.resource(DefectsResource.class)
                .subResource(DefectsResource.DEFECT_ATTACHMENT_PATH)
                .pathParam(DefectsResource.DEFECT_VAR, defect.getId()).rel("attachment")
                .type(MediaTypeUtils.IMAGE_JPEG_TYPE).build(entry.getLinks());
        }
View Full Code Here

    public static class SingleLinkAltParamResource {
        @GET
        @Produces("application/atom+xml")
        public String getAtom(@Context LinkBuilders builders) {
            List<SyndLink> links = new ArrayList<SyndLink>();
            SingleLinkBuilder singleLinkBuilder = builders.createSingleLinkBuilder();

            singleLinkBuilder.type(MediaType.APPLICATION_ATOM_XML_TYPE).build(links);
            assertEquals(1, links.size());
            assertLink(links,
                       null,
                       MediaType.APPLICATION_ATOM_XML,
                       "singleLinkAltParam?alt=application%2Fatom%2Bxml");

            links.clear();
            singleLinkBuilder.type(MediaType.APPLICATION_ATOM_XML_TYPE).addAltParam(false)
                .build(links);
            assertEquals(1, links.size());
            assertLink(links, null, MediaType.APPLICATION_ATOM_XML, "singleLinkAltParam");

            links.clear();
            singleLinkBuilder.type(MediaType.APPLICATION_ATOM_XML_TYPE).addAltParam(true)
                .build(links);
            assertEquals(1, links.size());
            assertLink(links,
                       null,
                       MediaType.APPLICATION_ATOM_XML,
                       "singleLinkAltParam?alt=application%2Fatom%2Bxml");

            links.clear();
            singleLinkBuilder.type(MediaType.APPLICATION_ATOM_XML_TYPE).queryParam("alt", "foo")
                .build(links);
            assertEquals(1, links.size());
            assertLink(links, null, MediaType.APPLICATION_ATOM_XML, "singleLinkAltParam?alt=foo");

            return "";
View Full Code Here

    @Path("singleLinkWithRelAndType")
    public static class SingleLinkWithRelAndTypeResource {
        @GET
        @Produces("application/atom+xml")
        public String getAtom(@Context LinkBuilders builders) {
            SingleLinkBuilder builder = builders.createSingleLinkBuilder();

            List<SyndLink> links = new ArrayList<SyndLink>();
            builder.rel("stam").build(links);
            assertEquals(1, links.size());
            assertLink(links, "stam", null, "singleLinkWithRelAndType");

            links.clear();
            builder.rel(null).type(MediaType.APPLICATION_JSON_TYPE).build(links);
            assertEquals(1, links.size());
            assertLink(links,
                       null,
                       "application/json",
                       "singleLinkWithRelAndType?alt=application%2Fjson");

            links.clear();
            builder.rel("stam").type(MediaType.APPLICATION_JSON_TYPE).build(links);
            assertEquals(1, links.size());
            assertLink(links,
                       "stam",
                       "application/json",
                       "singleLinkWithRelAndType?alt=application%2Fjson");

            links.clear();
            builder.resource(SingleLinkResource.class).rel("stam")
                .type(MediaType.APPLICATION_JSON_TYPE).build(links);
            assertEquals(1, links.size());
            assertLink(links, "stam", "application/json", "singleLink?alt=application%2Fjson");

            return "";
View Full Code Here

        @GET
        @Produces("application/atom+xml")
        public String getAtom(@Context LinkBuilders builders) {
            List<SyndLink> links = new ArrayList<SyndLink>();

            SingleLinkBuilder builder =
                builders.createSingleLinkBuilder().resource(SingleLinkWithPathParamResource.class);
            builder.pathParam("id", "1").build(links);
            assertEquals(1, links.size());
            assertLink(links, null, null, "1");

            links.clear();
            builder.subResource("a/{subId}/b").pathParam("subId", "2").build(links);
            assertEquals(1, links.size());
            assertLink(links, null, null, "1/a/2/b");

            return "";
        }
View Full Code Here

        if (!child) {
            entry.setBase(uriInfo.getAbsolutePath().toString());
        }

        // generate the edit link
        SingleLinkBuilder singleLinkBuilder = linkBuilders.createSingleLinkBuilder();
        if (editable) {
            singleLinkBuilder.subResource(DefectsResource.DEFECT_URL)
                .pathParam(DefectsResource.DEFECT_VAR, id).rel(AtomConstants.ATOM_REL_EDIT)
                .build(entry.getLinks());
        }

        // if this entry is not part of a history response, then generate the
        // history link
        if (!history) {
            singleLinkBuilder.subResource(DefectsResource.DEFECT_HISTORY_URL)
                .pathParam(DefectsResource.DEFECT_VAR, id).rel(AtomConstants.ATOM_REL_HISTORY)
                .type(MediaType.APPLICATION_ATOM_XML_TYPE).build(entry.getLinks());
        }

        // generate system links to self and alternate.
View Full Code Here

        // generate system links
        linkProcessor.createSystemLinksBuilder().resource(DefectsResource.class).subResource(defect
            .getId()).build(entry.getLinks());

        // generate related links - each defect can access its tests
        SingleLinkBuilder singleLinkBuilder = linkProcessor.createSingleLinkBuilder();

        singleLinkBuilder.resource(DefectTestsResource.class).pathParam(DefectsResource.DEFECT_VAR,
                                                                        defect.getId())
            .rel("related").type(MediaType.APPLICATION_ATOM_XML_TYPE).build(entry.getLinks());

        // add attachment link
        if (defect.getPathToAttachment() != null && defect.getPathToAttachment().length() > 0) {
            singleLinkBuilder.resource(DefectsResource.class)
                .subResource(DefectsResource.DEFECT_ATTACHMENT_PATH)
                .pathParam(DefectsResource.DEFECT_VAR, defect.getId()).rel("attachment")
                .type(MediaTypeUtils.IMAGE_JPEG_TYPE).build(entry.getLinks());
        }
View Full Code Here

TOP

Related Classes of org.apache.wink.server.utils.SingleLinkBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.