Package org.rhq.enterprise.server.rest.domain

Examples of org.rhq.enterprise.server.rest.domain.Link


        List<Link> links = new ArrayList<Link>(reports.length);
        for (String report: reports) {
            UriBuilder uriBuilder = uriInfo.getBaseUriBuilder();
            uriBuilder.path("/reports/{report}");
            URI uri = uriBuilder.build(report);
            Link link = new Link(report,uri.toString());
            links.add(link);
        }

        MediaType mediaType = headers.getAcceptableMediaTypes().get(0);
        Response.ResponseBuilder builder = Response.ok();
        if (mediaType.getType().equals("text") && mediaType.getSubtype().equals("csv")) {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append("Report,URL\n");
            for (Link link: links) {
                stringBuilder.append(link.getRel()).append(",").append(link.getHref());
                stringBuilder.append('\n');
            }
            builder.entity(stringBuilder.toString());
        }
        else if (mediaType.equals(MediaType.TEXT_HTML_TYPE)) {
View Full Code Here


        // add some links
        UriBuilder builder = uriInfo.getBaseUriBuilder();
        builder.path("/alert/{id}/conditions");
        URI uri = builder.build(al.getId());
        Link link = new Link("conditions",uri.toString());
        ret.addLink(link);
        builder = uriInfo.getBaseUriBuilder();
        builder.path("/alert/{id}/notifications");
        uri = builder.build(al.getId());
        link = new Link("notification",uri.toString());
        ret.addLink(link);
        builder = uriInfo.getBaseUriBuilder();
        builder.path("/alert/{id}/definition");
        uri = builder.build(al.getId());
        link = new Link("definition",uri.toString());
        ret.addLink(link);

        int resourceId = alertDefinition.getResource().getId();
        ret.addLink(createUILink(uriInfo,UILinkTemplate.RESOURCE_ALERT,resourceId,al.getId()));
View Full Code Here

            schedule.setDefinitionId(def.getId());
            if (def.getDataType()== DataType.MEASUREMENT) {
                UriBuilder uriBuilder = uriInfo.getBaseUriBuilder();
                uriBuilder.path("/metric/data/group/{groupId}/{definitionId}");
                URI uri = uriBuilder.build(id,def.getId());
                Link link = new Link("metric",uri.toString());
                schedule.addLink(link);
            }

            schedules.add(schedule);
        }
View Full Code Here

            GroupDefinition res = definitionManager.createGroupDefinition(caller,gd);
            UriBuilder uriBuilder = uriInfo.getBaseUriBuilder();
            uriBuilder.path("/group/definition/{id}");
            URI location = uriBuilder.build(res.getId());

            Link link = new Link("edit",location.toString());
            builder= Response.created(location);
            GroupDefinitionRest gdr = buildGDRestFromDefinition(res);
            createLinksForGDRest(uriInfo,gdr);

            builder.entity(gdr);
View Full Code Here

    private void createLinksForGDRest(UriInfo uriInfo, GroupDefinitionRest gdr) {
        UriBuilder uriBuilder = uriInfo.getBaseUriBuilder();
        uriBuilder.path("/group/definition/{id}");
        URI location = uriBuilder.build(gdr.getId());
        Link link = new Link("edit",location.toString());
        gdr.addLink(link);

        uriBuilder = uriInfo.getBaseUriBuilder();
        uriBuilder.path("/group/definition");
        location = uriBuilder.build(new Object[]{});
        link = new Link("create",location.toString());
        gdr.addLink(link);
    }
View Full Code Here

        UriBuilder uriBuilder = uriInfo.getBaseUriBuilder();
        uriBuilder.path("/operation/definitions");
        uriBuilder.queryParam("resourceId", res.getId());
        URI uri = uriBuilder.build();
        Link link = new Link("operationDefinitions", uri.toString());
        rwt.addLink(link);

        link = getLinkToResource(res, uriInfo, "self");
        rwt.addLink(link);
        uriBuilder = uriInfo.getBaseUriBuilder();
        uriBuilder.path("/resource/{id}/schedules");
        uri = uriBuilder.build(res.getId());
        link = new Link("schedules", uri.toString());
        rwt.addLink(link);
        uriBuilder = uriInfo.getBaseUriBuilder();
        uriBuilder.path("/resource/{id}/availability");
        uri = uriBuilder.build(res.getId());
        link = new Link("availability", uri.toString());
        rwt.addLink(link);
        uriBuilder = uriInfo.getBaseUriBuilder();
        uriBuilder.path("/resource/{id}/children");
        uri = uriBuilder.build(res.getId());
        link = new Link("children", uri.toString());
        rwt.addLink(link);
        uriBuilder = uriInfo.getBaseUriBuilder();
        uriBuilder.path("/resource/{id}/alerts");
        uri = uriBuilder.build(res.getId());
        link = new Link("alerts", uri.toString());
        rwt.addLink(link);
        uriBuilder = uriInfo.getBaseUriBuilder();
        uriBuilder.path("/alert/definitions");
        uriBuilder.queryParam("resourceId",res.getId());
        uri = uriBuilder.build(res.getId());
        link = new Link("alertDefinitions", uri.toString());
        rwt.addLink(link);
        if (parent != null) {
            uriBuilder = uriInfo.getBaseUriBuilder();
            uriBuilder.path("/resource/{id}/");
            uri = uriBuilder.build(parent.getId());
            link = new Link("parent", uri.toString());
            rwt.addLink(link);
        }
        rwt.addLink(createUILink(uriInfo,UILinkTemplate.RESOURCE,res.getId()));

        return rwt;
View Full Code Here

        return rwt;
    }

    protected Link getLinkToResource(Resource res, UriInfo uriInfo, String rel) {
        UriBuilder uriBuilder;URI uri;
        Link link;
        uriBuilder = uriInfo.getBaseUriBuilder();
        uriBuilder.path("/resource/{id}");
        uri = uriBuilder.build(res.getId());
        link = new Link(rel, uri.toString());
        return link;
    }
View Full Code Here

        return link;
    }

    protected Link getLinkToResourceType(ResourceType type, UriInfo uriInfo, String rel) {
        UriBuilder uriBuilder;URI uri;
        Link link;
        uriBuilder = uriInfo.getBaseUriBuilder();
        uriBuilder.path("/resource/type/{id}");
        uri = uriBuilder.build(type.getId());
        link = new Link(rel, uri.toString());
        return link;
    }
View Full Code Here

    }

    protected Link getLinkToGroup(ResourceGroup group, UriInfo uriInfo, String rel) {
        UriBuilder uriBuilder;
        URI uri;
        Link link;
        uriBuilder = uriInfo.getBaseUriBuilder();
        uriBuilder.path("/group/{id}");
        uri = uriBuilder.build(group.getId());
        link = new Link(rel, uri.toString());
        return link;
    }
View Full Code Here

        if (resultList.getTotalSize()> (pc.getPageNumber() +1 ) * pc.getPageSize()) {
            int nextPage = page+1;
            uriBuilder = uriInfo.getRequestUriBuilder(); // adds ?q, ?ps and ?category if needed
            uriBuilder.replaceQueryParam("page",nextPage);

            builder.header("Link",new Link("next",uriBuilder.build().toString()).rfc5988String());
        }

        if (page>0) {
            int prevPage = page -1;
            uriBuilder = uriInfo.getRequestUriBuilder(); // adds ?q, ?ps and ?category if needed
            uriBuilder.replaceQueryParam("page",prevPage);
            builder.header("Link", new Link("prev",uriBuilder.build().toString()).rfc5988String());
        }

        // A link to the last page
        if (!pc.isUnlimited()) {
            int lastPage = (resultList.getTotalSize() / pc.getPageSize() ) -1;
            uriBuilder = uriInfo.getRequestUriBuilder(); // adds ?q, ?ps and ?category if needed
            uriBuilder.replaceQueryParam("page",lastPage);
            builder.header("Link", new Link("last",uriBuilder.build().toString()).rfc5988String());
        }

        // A link to the current page
        uriBuilder = uriInfo.getRequestUriBuilder(); // adds ?q, ?ps and ?category if needed
        builder.header("Link", new Link("current",uriBuilder.build().toString()).rfc5988String());


        // Create a total size header
        builder.header("X-collection-size",resultList.getTotalSize());
    }
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.server.rest.domain.Link

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.