Examples of UriBuilder


Examples of javax.ws.rs.core.UriBuilder

    @POST
    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response create(Person person) {
        dao.create(person);
        UriBuilder builder = UriBuilder.fromUri(uriInfo.getRequestUri()).path("{id}");
        return Response.created(builder.build(person.getId()))
            .entity(person)
            .build();
    }
View Full Code Here

Examples of javax.ws.rs.core.UriBuilder

        this.serverUrl = serverUrl;
        this.serverStatus = serverStatus;
    }

    public List<InputSummaryResponse> getPersistedInputs() throws IOException {
        final UriBuilder uriBuilder = UriBuilder.fromUri(serverUrl);
        uriBuilder.path("/system/radios/" + serverStatus.getNodeId().toString() + "/inputs");

        final Request request = httpclient.prepareGet(uriBuilder.build().toString()).build();
        LOG.debug("API Request {} {}", request.getMethod(), request.getUrl());
        final Future<Response> f = httpclient.executeRequest(request);

        final Response r;
        try {
View Full Code Here

Examples of javax.ws.rs.core.UriBuilder

        return null;
    }

    // TODO make this use a generic ApiClient class that knows the graylog2-server node address(es) or something.
    public RegisterInputResponse registerInCluster(MessageInput input) throws ExecutionException, InterruptedException, IOException {
        final UriBuilder uriBuilder = UriBuilder.fromUri(serverUrl);
        uriBuilder.path("/system/radios/" + serverStatus.getNodeId().toString() + "/inputs");

        RegisterInputRequest rir = new RegisterInputRequest(input, serverStatus.getNodeId().toString());

        String json;
        try {
            json = mapper.writeValueAsString(rir);
        } catch (IOException e) {
            throw new RuntimeException("Could not create JSON for register input request.", e);
        }

        Future<Response> f = httpclient.preparePost(uriBuilder.build().toString())
                .setBody(json)
                .execute();

        Response r = f.get();
View Full Code Here

Examples of javax.ws.rs.core.UriBuilder

        return response;
    }

    public void unregisterInCluster(MessageInput input) throws ExecutionException, InterruptedException, IOException {
        final UriBuilder uriBuilder = UriBuilder.fromUri(serverUrl);
        uriBuilder.path("/system/radios/" + serverStatus.getNodeId().toString() + "/inputs/" + input.getPersistId());

        Future<Response> f = httpclient.prepareDelete(uriBuilder.build().toString()).execute();
        Response r = f.get();
        if (r.getStatusCode() != 204) {
            throw new RuntimeException("Expected HTTP response [204] for input unregistration but got [" + r.getStatusCode() + "].");
        }
    }
View Full Code Here

Examples of javax.ws.rs.core.UriBuilder

        ObjectMapper mapper = new ObjectMapper();

        ObjectNode rootNode = mapper.createObjectNode();
        rootNode.put("rest_transport_address", ourUri.toString());

        final UriBuilder uriBuilder = UriBuilder.fromUri(server);
        uriBuilder.path("/system/radios/" + radioId + "/ping");

        Future<Response> f = client.preparePut(uriBuilder.build().toString())
                .setBody(rootNode.toString())
                .execute();

        Response r = f.get();
View Full Code Here

Examples of javax.ws.rs.core.UriBuilder

            Preconditions.checkNotNull(pathTemplate, "path() needs to be set to a non-null value.");

            URI builtUrl;
            try {
                String path = MessageFormat.format(pathTemplate, pathParams.toArray());
                final UriBuilder uriBuilder = UriBuilder.fromUri(target.getTransportAddress());
                uriBuilder.path(path);
                for (F.Tuple<String, String> queryParam : queryParams) {
                    uriBuilder.queryParam(queryParam._1, queryParam._2);
                }

                if (unauthenticated && sessionId != null) {
                    LOG.error("Both session() and unauthenticated() are set for this request, this is a bug, using session id.", new Throwable());
                }
                if (sessionId != null) {
                    // pass the current session id via basic auth and special "password"
                    uriBuilder.userInfo(sessionId + ":session");
                }
                builtUrl = uriBuilder.build();
                return builtUrl.toURL();
            } catch (MalformedURLException e) {
                // TODO handle this properly
                LOG.error("Could not build target URL", e);
                throw new RuntimeException(e);
View Full Code Here

Examples of javax.ws.rs.core.UriBuilder

      logger.finer(" get USERs is here !");
      mf = (ModelFacade)getServletContext().getAttribute(WebConstants.MF_KEY);
      List<Person> allUsers = mf.getAllPersons();
       JSONArray uriArray = new JSONArray();
        for (Person userEntity : allUsers) {
            UriBuilder ub = uriInfo.getAbsolutePathBuilder();
            URI userUri = ub.
                    path(userEntity.getUserName()).
                    build();
            uriArray.put(userUri.toASCIIString());
        }
        return uriArray;
View Full Code Here

Examples of javax.ws.rs.core.UriBuilder

          model.getBatch());
      scanners.put(id, instance);
      if (LOG.isDebugEnabled()) {
        LOG.debug("new scanner: " + id);
      }
      UriBuilder builder = uriInfo.getAbsolutePathBuilder();
      URI uri = builder.path(id).build();
      return Response.created(uri).build();
    } catch (IOException e) {
      throw new WebApplicationException(e,
              Response.Status.SERVICE_UNAVAILABLE);
    } catch (Exception e) {
View Full Code Here

Examples of javax.ws.rs.core.UriBuilder

        }
       
        @Override
        protected void setDefaultEntryProperties(Entry entry, List<LogRecord> rs, int entryIndex) {
            super.setDefaultEntryProperties(entry, rs, entryIndex);
            UriBuilder builder = context.getUriInfo().getAbsolutePathBuilder().path("entry");
            Integer realIndex = page == 1 ? entryIndex : page * pageSize + entryIndex;

            entry.addLink(builder.clone().path(realIndex.toString()).build().toString(), "self");
            entry.addLink(builder.path("alternate").path(realIndex.toString()).build().toString(),
                          "alternate");
        }
View Full Code Here

Examples of javax.ws.rs.core.UriBuilder

        ServletContext context = request.getSession().getServletContext();
               
        // substitute $$sgs.server with the sgs server URL
        String serverURL = ServletPropertyUtil.getProperty("jnlp.wonderland.server.url", context);
        if (serverURL == null) {
            UriBuilder builder = UriBuilder.fromUri(request.getRequestURL().toString());
            serverURL = builder.replacePath("/").build().toString();
           
            /*try {
                serverName = InetAddress.getLocalHost().getCanonicalHostName();
            } catch (UnknownHostException uhe) {
                logger.log(Level.WARNING, "Error getting local host", uhe);
                serverName = "localhost";
            }*/
        }
        jnlpTemplate = substitute(jnlpTemplate, "$$wonderland.server.url", serverURL);

        // substitute in the config directory
        String configDirURL = ServletPropertyUtil.getProperty("jnlp.wonderland.client.config.dir", context);
        if (configDirURL == null) {
            UriBuilder builder = UriBuilder.fromUri(request.getRequestURL().toString());
            configDirURL = builder.replacePath("/wonderland-web-front/config/").build().toString();
        }
        jnlpTemplate = substitute(jnlpTemplate, "$$wonderland.client.config.dir", configDirURL);

        // add in additional properties
        StringBuilder props = new StringBuilder();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.