Package org.apache.wink.server.utils

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


        // (feed entries have no content, they have just metadata so there is no
        // need to set content
        // here)
        Map<String, String> bookmarks = BookmarkStore.getInstance().getBookmarks();

        SystemLinksBuilder entryLinksBuilder = linkBuilders.createSystemLinksBuilder();
        for (String key : bookmarks.keySet()) {
            // set the sub-resource state of the builder for this entry
            entryLinksBuilder.subResource(key);
            SyndEntry entry = createEntry(key, bookmarks.get(key), entryLinksBuilder, null);
            feed.addEntry(entry);
        }
        // generate collection links in the response
        linkBuilders.createSystemLinksBuilder().build(feed.getLinks());
View Full Code Here


        }

        String bookmarkId = BookmarkStore.getNewId();
        BookmarkStore.getInstance().putBookmark(bookmarkId, bookmark);

        SystemLinksBuilder entryLinksBuilder =
            linkBuilders.createSystemLinksBuilder().subResource(bookmarkId);
        SyndEntry entry = createEntry(bookmarkId, bookmark, entryLinksBuilder, uriInfo);

        URI location = uriInfo.getAbsolutePathBuilder().segment(bookmarkId).build();
        return Response.created(location).entity(entry).build();
View Full Code Here

        feed.setBase(uriInfo.getAbsolutePath().toString());

        boolean editable = true;

        SystemLinksBuilder systemLinksBuilder = linkBuilders.createSystemLinksBuilder();

        // generate history links
        if (history) {
            // all defects in the collection are the history of the same defect
            // and they all have the
            // same defect id, so we can use the id of the first one
            systemLinksBuilder.subResource(DefectsResource.DEFECT_HISTORY_URL)
                .pathParam(DefectsResource.DEFECT_VAR, defects.get(0).getId()).build(feed
                    .getLinks());
            if (!defects.isEmpty()) {
                // if this is a history of a defect, then the last defect in the
                // list is the latest state of the defect
                editable = !(defects.get(defects.size() - 1).isDeleted());
            }
        } else {
            // generate system links
            systemLinksBuilder.build(feed.getLinks());
        }

        // set the entries
        for (DefectBean defect : defects) {
            DefectAsset defectAsset = new DefectAsset(defect, true, history);
View Full Code Here

        @Produces("application/atom+xml")
        public String getAtom(@Context LinkBuilders builders, @Context UriInfo uriInfo) {
            List<SyndLink> links = null;

            URI base = uriInfo.getBaseUri();
            SystemLinksBuilder builder = builders.createSystemLinksBuilder().relativeTo(base);

            links = new ArrayList<SyndLink>();
            builder.allResources(true).build(links);
            assertEquals(6, links.size());
            assertLink(links, "self", null, "systemLinks/ContinuedSearch");
            assertLink(links, "edit", null, "systemLinks/ContinuedSearch");
            assertLink(links,
                       "alternate",
                       "application/xml",
                       "systemLinks/ContinuedSearch?alt=application%2Fxml");
            assertLink(links,
                       "alternate",
                       "application/json",
                       "systemLinks/ContinuedSearch?alt=application%2Fjson");
            assertLink(links,
                       "alternate",
                       "text/html",
                       "systemLinks/ContinuedSearch?alt=text%2Fhtml");
            assertLink(links,
                       "alternate",
                       "application/atom+xml",
                       "systemLinks/ContinuedSearch?alt=application%2Fatom%2Bxml");

            links = new ArrayList<SyndLink>();
            builder.allResources(false).build(links);
            assertEquals(2, links.size());
            assertLink(links, "self", null, "systemLinks/ContinuedSearch");
            assertLink(links,
                       "alternate",
                       "application/atom+xml",
                       "systemLinks/ContinuedSearch?alt=application%2Fatom%2Bxml");

            links = new ArrayList<SyndLink>();
            builder.resource(SystemLinksContinuedSearch3Resource.class)
                .pathParam("v1", "Continued").pathParam("v2", "Search").allResources(true)
                .build(links);
            assertEquals(6, links.size());
            assertLink(links, "self", null, "systemLinks/ContinuedSearch");
            assertLink(links, "edit", null, "systemLinks/ContinuedSearch");
            assertLink(links,
                       "alternate",
                       "application/xml",
                       "systemLinks/ContinuedSearch?alt=application%2Fxml");
            assertLink(links,
                       "alternate",
                       "application/json",
                       "systemLinks/ContinuedSearch?alt=application%2Fjson");
            assertLink(links,
                       "alternate",
                       "text/html",
                       "systemLinks/ContinuedSearch?alt=text%2Fhtml");
            assertLink(links,
                       "alternate",
                       "application/atom+xml",
                       "systemLinks/ContinuedSearch?alt=application%2Fatom%2Bxml");

            links = new ArrayList<SyndLink>();
            builder.allResources(false).build(links);
            assertEquals(3, links.size());
            assertLink(links, "self", null, "systemLinks/ContinuedSearch");
            assertLink(links, "edit", null, "systemLinks/ContinuedSearch");
            assertLink(links,
                       "alternate",
View Full Code Here

        @Produces("application/atom+xml")
        public String getAtom(@Context LinkBuilders builders, @Context UriInfo uriInfo) {
            List<SyndLink> links = null;

            URI base = uriInfo.getBaseUri();
            SystemLinksBuilder builder = builders.createSystemLinksBuilder().relativeTo(base);

            links = new ArrayList<SyndLink>();
            builder.allResources(true).build(links);
            assertEquals(6, links.size());
            assertLink(links, "self", null, "systemLinks/ContinuedSearch/SubResources/1");
            assertLink(links, "edit", null, "systemLinks/ContinuedSearch/SubResources/1");
            assertLink(links,
                       "alternate",
                       "application/xml",
                       "systemLinks/ContinuedSearch/SubResources/1?alt=application%2Fxml");
            assertLink(links,
                       "alternate",
                       "application/json",
                       "systemLinks/ContinuedSearch/SubResources/1?alt=application%2Fjson");
            assertLink(links,
                       "alternate",
                       "text/html",
                       "systemLinks/ContinuedSearch/SubResources/1?alt=text%2Fhtml");
            assertLink(links,
                       "alternate",
                       "application/atom+xml",
                       "systemLinks/ContinuedSearch/SubResources/1?alt=application%2Fatom%2Bxml");

            links = new ArrayList<SyndLink>();
            builder.allResources(false).build(links);
            assertEquals(2, links.size());
            assertLink(links, "self", null, "systemLinks/ContinuedSearch/SubResources/1");
            assertLink(links,
                       "alternate",
                       "application/atom+xml",
                       "systemLinks/ContinuedSearch/SubResources/1?alt=application%2Fatom%2Bxml");

            links = new ArrayList<SyndLink>();
            builder.resource(SystemLinksContinuedSearchSubResources3Resource.class)
                .subResource("{id}").pathParam("v1", "Continued").pathParam("v2", "Search")
                .pathParam("id", "1").allResources(true).build(links);
            assertEquals(6, links.size());
            assertLink(links, "self", null, "systemLinks/ContinuedSearch/SubResources/1");
            assertLink(links, "edit", null, "systemLinks/ContinuedSearch/SubResources/1");
            assertLink(links,
                       "alternate",
                       "application/xml",
                       "systemLinks/ContinuedSearch/SubResources/1?alt=application%2Fxml");
            assertLink(links,
                       "alternate",
                       "application/json",
                       "systemLinks/ContinuedSearch/SubResources/1?alt=application%2Fjson");
            assertLink(links,
                       "alternate",
                       "text/html",
                       "systemLinks/ContinuedSearch/SubResources/1?alt=text%2Fhtml");
            assertLink(links,
                       "alternate",
                       "application/atom+xml",
                       "systemLinks/ContinuedSearch/SubResources/1?alt=application%2Fatom%2Bxml");

            links = new ArrayList<SyndLink>();
            builder.allResources(false).build(links);
            assertEquals(3, links.size());
            assertLink(links, "self", null, "systemLinks/ContinuedSearch/SubResources/1");
            assertLink(links, "edit", null, "systemLinks/ContinuedSearch/SubResources/1");
            assertLink(links,
                       "alternate",
View Full Code Here

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

            systemLinksBuilder.build(links);
            assertEquals(2, links.size());
            assertLink(links, "self", null, "systemLinksAltParam");
            assertLink(links,
                       "alternate",
                       "application/atom+xml",
                       "systemLinksAltParam?alt=application%2Fatom%2Bxml");

            links.clear();
            systemLinksBuilder.addAltParam(false).build(links);
            assertEquals(2, links.size());
            assertLink(links, "self", null, "systemLinksAltParam");
            assertLink(links, "alternate", "application/atom+xml", "systemLinksAltParam");

            links.clear();
            systemLinksBuilder.addAltParam(true).build(links);
            assertEquals(2, links.size());
            assertLink(links, "self", null, "systemLinksAltParam");
            assertLink(links,
                       "alternate",
                       "application/atom+xml",
                       "systemLinksAltParam?alt=application%2Fatom%2Bxml");

            links.clear();
            systemLinksBuilder.addAltParam(false).queryParam("alt", "foo").build(links);
            assertEquals(2, links.size());
            assertLink(links, "self", null, "systemLinksAltParam?alt=foo");
            assertLink(links, "alternate", "application/atom+xml", "systemLinksAltParam?alt=foo");

            links.clear();
            systemLinksBuilder.addAltParam(true).build(links);
            assertEquals(2, links.size());
            assertLink(links, "self", null, "systemLinksAltParam?alt=foo");
            assertLink(links, "alternate", "application/atom+xml", "systemLinksAltParam?alt=foo");
            return "";
        }
View Full Code Here

        }

        @GET
        @Produces("application/atom+xml")
        public String getAtom(@Context LinkBuilders builders) {
            SystemLinksBuilder builder = builders.createSystemLinksBuilder();

            List<SyndLink> links = new ArrayList<SyndLink>();
            builder.types(LinkType.ALTERNATE).build(links);
            assertEquals(3, links.size());
            assertLink(links,
                       "alternate",
                       "application/xml",
                       "systemLinksSelective?alt=application%2Fxml");
            assertLink(links,
                       "alternate",
                       "application/json",
                       "systemLinksSelective?alt=application%2Fjson");
            assertLink(links,
                       "alternate",
                       "application/atom+xml",
                       "systemLinksSelective?alt=application%2Fatom%2Bxml");

            links.clear();
            builder.types(LinkType.SELF).build(links);
            assertEquals(1, links.size());
            assertLink(links, "self", null, "systemLinksSelective");

            links.clear();
            builder.types(LinkType.EDIT).build(links);
            assertEquals(1, links.size());
            assertLink(links, "edit", null, "systemLinksSelective");

            links.clear();
            builder.types(LinkType.OPENSEARCH).build(links);
            assertEquals(1, links.size());
            assertLink(links,
                       "search",
                       "application/opensearchdescription+xml",
                       "systemLinksSelective?alt=application%2Fopensearchdescription%2Bxml");

            links.clear();
            builder.types(LinkType.SELF, LinkType.EDIT).build(links);
            assertEquals(2, links.size());
            assertLink(links, "self", null, "systemLinksSelective");
            assertLink(links, "edit", null, "systemLinksSelective");

            links.clear();
            builder.types(LinkType.EDIT, LinkType.OPENSEARCH).build(links);
            assertEquals(2, links.size());
            assertLink(links, "edit", null, "systemLinksSelective");
            assertLink(links,
                       "search",
                       "application/opensearchdescription+xml",
                       "systemLinksSelective?alt=application%2Fopensearchdescription%2Bxml");

            links.clear();
            builder.types(LinkType.SELF, LinkType.EDIT, LinkType.OPENSEARCH, LinkType.ALTERNATE)
                .build(links);
            assertEquals(6, links.size());
            assertLink(links, "self", null, "systemLinksSelective");
            assertLink(links, "edit", null, "systemLinksSelective");
            assertLink(links,
                       "search",
                       "application/opensearchdescription+xml",
                       "systemLinksSelective?alt=application%2Fopensearchdescription%2Bxml");
            assertLink(links,
                       "alternate",
                       "application/xml",
                       "systemLinksSelective?alt=application%2Fxml");
            assertLink(links,
                       "alternate",
                       "application/json",
                       "systemLinksSelective?alt=application%2Fjson");
            assertLink(links,
                       "alternate",
                       "application/atom+xml",
                       "systemLinksSelective?alt=application%2Fatom%2Bxml");

            links.clear();
            builder.types().build(links);
            assertEquals(6, links.size());
            assertLink(links, "self", null, "systemLinksSelective");
            assertLink(links, "edit", null, "systemLinksSelective");
            assertLink(links,
                       "alternate",
View Full Code Here

        @GET
        @Produces("application/atom+xml")
        public String getAtom(@Context LinkBuilders builders) {

            List<SyndLink> links = new ArrayList<SyndLink>();
            SystemLinksBuilder builder = builders.createSystemLinksBuilder();
            builder.relativeTo(URI.create("http://localhost:80/foo/bar")).build(links);
            assertEquals(3, links.size());
            assertLink(links, "self", null, "../systemLinksRelativeToAnotherUri");
            assertLink(links,
                       "alternate",
                       "application/xml",
                       "../systemLinksRelativeToAnotherUri?alt=application%2Fxml");
            assertLink(links,
                       "alternate",
                       "application/atom+xml",
                       "../systemLinksRelativeToAnotherUri?alt=application%2Fatom%2Bxml");

            links.clear();
            builder.baseUri(URI.create("http://koko:81")).relativeTo(URI
                .create("http://koko:81/foo/bar")).build(links);
            assertEquals(3, links.size());
            assertLink(links, "self", null, "../systemLinksRelativeToAnotherUri");
            assertLink(links,
                       "alternate",
                       "application/xml",
                       "../systemLinksRelativeToAnotherUri?alt=application%2Fxml");
            assertLink(links,
                       "alternate",
                       "application/atom+xml",
                       "../systemLinksRelativeToAnotherUri?alt=application%2Fatom%2Bxml");

            links.clear();
            builder.baseUri(URI.create("http://koko:82/")).relativeTo(URI
                .create("http://koko:82/foo/bar/zoo/")).build(links);
            assertEquals(3, links.size());
            assertLink(links, "self", null, "../../../systemLinksRelativeToAnotherUri");
            assertLink(links,
                       "alternate",
                       "application/xml",
                       "../../../systemLinksRelativeToAnotherUri?alt=application%2Fxml");
            assertLink(links,
                       "alternate",
                       "application/atom+xml",
                       "../../../systemLinksRelativeToAnotherUri?alt=application%2Fatom%2Bxml");

            links.clear();
            builder.baseUri(URI.create("http://koko:82/")).relativeTo(URI
                .create("http://koko:82/foo/bar/zoo/")).build(links);
            assertEquals(3, links.size());
            assertLink(links, "self", null, "../../../systemLinksRelativeToAnotherUri");
            assertLink(links,
                       "alternate",
View Full Code Here

        // (feed entries have no content, they have just metadata so there is no
        // need to set content
        // here)
        Map<String, String> bookmarks = BookmarkStore.getInstance().getBookmarks();

        SystemLinksBuilder entryLinksBuilder = linkBuilders.createSystemLinksBuilder();
        for (String key : bookmarks.keySet()) {
            // set the sub-resource state of the builder for this entry
            entryLinksBuilder.subResource(key);
            SyndEntry entry = createEntry(key, bookmarks.get(key), entryLinksBuilder, null);
            feed.addEntry(entry);
        }
        // generate collection links in the response
        linkBuilders.createSystemLinksBuilder().build(feed.getLinks());
View Full Code Here

        }

        String bookmarkId = BookmarkStore.getNewId();
        BookmarkStore.getInstance().putBookmark(bookmarkId, bookmark);

        SystemLinksBuilder entryLinksBuilder =
            linkBuilders.createSystemLinksBuilder().subResource(bookmarkId);
        SyndEntry entry = createEntry(bookmarkId, bookmark, entryLinksBuilder, uriInfo);

        URI location = uriInfo.getAbsolutePathBuilder().segment(bookmarkId).build();
        return Response.created(location).entity(entry).build();
View Full Code Here

TOP

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

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.