Example usage for java.net URI toASCIIString

List of usage examples for java.net URI toASCIIString

Introduction

In this page you can find the example usage for java.net URI toASCIIString.

Prototype

public String toASCIIString() 

Source Link

Document

Returns the content of this URI as a US-ASCII string.

Usage

From source file:com.artivisi.belajar.restful.ui.controller.RoleController.java

@RequestMapping(value = "/role", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)// www .j  a va  2  s  .c om
public void create(@RequestBody @Valid Role x, HttpServletRequest request, HttpServletResponse response) {
    belajarRestfulService.save(x);
    String requestUrl = request.getRequestURL().toString();
    URI uri = new UriTemplate("{requestUrl}/{id}").expand(requestUrl, x.getId());
    response.setHeader("Location", uri.toASCIIString());
}

From source file:priv.test.wechat.HttpRequestBase.java

public RequestLine getRequestLine() {
    final String method = getMethod();
    final ProtocolVersion ver = getProtocolVersion();
    final URI uri = getURI();
    String uritext = null;/*  ww  w .ja v a 2 s  . c o  m*/
    if (uri != null) {
        uritext = uri.toASCIIString();
    }
    if (uritext == null || uritext.length() == 0) {
        uritext = "/";
    }
    return new BasicRequestLine(method, uritext, ver);
}

From source file:com.artivisi.belajar.restful.ui.controller.ProdukController.java

@RequestMapping(value = "/produk", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)//  w  w w .j  a  v  a2  s. co m
public void create(@RequestBody @Valid Produk x, HttpServletRequest request, HttpServletResponse response) {
    belajarRestfulService.save(x);
    String requestUrl = request.getRequestURL().toString();
    URI uri = new UriTemplate("{requestUrl}/{id}").expand(requestUrl, x.getId());
    response.setHeader("Location", uri.toASCIIString());
}

From source file:nl.flotsam.calendar.core.CalendarClient.java

public CalendarClient(URI baseURI) {
    this.baseURI = baseURI;
    template = new RestTemplate();
    template.setMessageConverters(//from   w  ww .  ja va2 s .c  om
            Arrays.asList(new HttpMessageConverter<?>[] { new UriListHttpMessageConverter(),
                    new CalendarAsStringHttpMessageConverter(), new StringHttpMessageConverter() }));
    final ClientHttpRequestFactory factory = template.getRequestFactory();
    template.setRequestFactory(new ClientHttpRequestFactory() {

        @Override
        public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException {
            logger.info("Sending " + httpMethod.name() + " to " + uri.toASCIIString());
            return factory.createRequest(uri, httpMethod);
        }
    });
}

From source file:ar.com.zauber.garfio.modules.mantis.model.MantisTrackerSessionProvider.java

/**
 * Creates the MantisTrackerSessionProvider.
 *
 *///from w  ww  .j a  va  2  s  . co  m
public MantisTrackerSessionProvider(final URI garfioURL, final String garfioPassword) {
    Validate.notNull(garfioURL);
    Validate.isTrue(StringUtils.isNotBlank(garfioPassword));

    this.garfioURL = garfioURL.toASCIIString();
    this.garfioPassword = garfioPassword;
}

From source file:com.artivisi.belajar.restful.ui.controller.SaleController.java

@RequestMapping(value = "/sale", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)//from  ww  w  . j  av  a 2  s . c  o  m
public void create(@RequestBody @Valid Sale x, HttpServletRequest request, HttpServletResponse response) {
    belajarRestfulService.save(x);
    String requestUrl = request.getRequestURL().toString();
    URI uri = new UriTemplate("{requestUrl}/{idjual}").expand(requestUrl, x.getIdJual());
    response.setHeader("Location", uri.toASCIIString());
}

From source file:org.callimachusproject.client.HttpUriClient.java

private URI getSystemId(HttpClientContext ctx) {
    HttpUriRequest request = (HttpUriRequest) ctx.getRequest();
    try {/* w  ww . j  a v a  2  s . c om*/
        URI original = request.getURI();
        HttpHost target = ctx.getTargetHost();
        List<URI> list = ctx.getRedirectLocations();
        URI absolute = URIUtils.resolve(original, target, list);
        return new URI(TermFactory.newInstance(absolute.toASCIIString()).getSystemId());
    } catch (URISyntaxException e) {
        return request.getURI();
    }
}

From source file:com.smartitengineering.cms.ws.common.providers.TextURIListProvider.java

@Override
public void writeTo(Collection<URI> t, Class<?> type, Type genericType, Annotation[] annotations,
        MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
        throws IOException, WebApplicationException {
    if (isWriteable(type, genericType, annotations, mediaType)) {
        List<String> lines = new ArrayList<String>(t.size());
        for (URI uri : t) {
            if (uri == null) {
                continue;
            }/*www .  jav  a2s . c  o  m*/
            lines.add(uri.toASCIIString());
        }
        IOUtils.writeLines(lines, null, entityStream);
    }
}

From source file:de.shadowhunt.subversion.internal.CopyOperation.java

@Override
protected HttpUriRequest createRequest() {
    final URI sourceUri = URIUtils.createURI(repository, source);
    final URI targetUri = URIUtils.createURI(repository, target);
    final DavTemplateRequest request = new DavTemplateRequest("COPY", sourceUri);
    request.addHeader("Destination", targetUri.toASCIIString());
    request.addHeader("Depth", Depth.INFINITY.value);
    request.addHeader("Override", "T");

    if (lockToken != null) {
        request.addHeader("If", "<" + targetUri + "> (<" + lockToken + ">)");
    }//from w  w w  . j a  v  a 2  s  .c  o m

    return request;
}

From source file:org.nuxeo.ecm.platform.annotations.proxy.AnnotationServiceProxy.java

private void checkUrl(Annotation annotation) {
    try {/*  ww w. j a  v  a  2  s  .  c o m*/
        URI uri = annotation.getAnnotates();
        if (uri.toASCIIString().startsWith("urn:")) {
            return;
        }
        String url = uri.toURL().toString();
        if (!filter.allow(url)) {
            throw new NuxeoException("Not allowed to annotate: " + url);
        }
    } catch (MalformedURLException e) {
        throw new NuxeoException(e);
    }
}