List of usage examples for java.net URI toASCIIString
public String toASCIIString()
From source file:com.artivisi.belajar.restful.ui.controller.MenuController.java
@RequestMapping(value = "/menu", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED)/*from w w w . j a v a 2 s.c om*/ public void create(@RequestBody @Valid Menu 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:com.smartitengineering.cms.api.impl.content.ContentIdImpl.java
@Override public String getEncodedUriString() { URI uri = getUri(); return uri == null ? null : uri.toASCIIString(); }
From source file:org.osaf.cosmo.dav.StandardResourceLocator.java
public String getHref(boolean absolute, boolean isCollection) { String path = isCollection && !this.path.equals("/") ? this.path + "/" : this.path; try {/*from ww w .j a v a2s .c om*/ path = context.getPath() + path; String scheme = absolute ? context.getProtocol() : null; String host = absolute ? context.getHost() : null; int port = absolute ? context.getPort() : -1; URI uri = new URI(scheme, null, host, port, path, null, null); return uri.toASCIIString(); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:org.gatherdata.archiver.dao.vfs.internal.VfsArchiverDao.java
public void remove(URI uid) { try {/*ww w. ja v a 2 s . c om*/ FileObject envelopeFile = fsManager.resolveFile(fsBase, uid.toASCIIString()); if (envelopeFile.exists()) { envelopeFile.delete(); } } catch (FileSystemException e) { e.printStackTrace(); } }
From source file:com.msopentech.odatajclient.engine.communication.request.retrieve.ODataLinkCollectionRequest.java
/** * Private constructor.//ww w . ja v a 2s .c o m * * @param odataClient client instance getting this request * @param targetURI target URI. * @param linkName link name. */ ODataLinkCollectionRequest(final ODataClient odataClient, final URI targetURI, final String linkName) { super(odataClient, ODataFormat.class, odataClient.getURIBuilder(targetURI.toASCIIString()).appendLinksSegment(linkName).build()); }
From source file:com.artivisi.belajar.restful.ui.controller.UserController.java
@RequestMapping(value = "/user", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED)/*from ww w.j a v a 2 s . com*/ public void create(@RequestBody @Valid User 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:de.perdoctus.synology.jdadapter.controller.JdAdapter.java
private List<URI> fixURIs(final List<URI> srcURIs) throws URISyntaxException { final List<URI> resultURIs = new ArrayList<URI>(srcURIs.size()); for (final URI srcURI : srcURIs) { String srcURIStr = srcURI.toASCIIString(); for (final String findPattern : URI_REPLACEMENT_LIST.keySet()) { srcURIStr = srcURIStr.replaceAll(findPattern, URI_REPLACEMENT_LIST.get(findPattern)); }/* w w w . ja va2 s .c o m*/ resultURIs.add(new URI(srcURIStr)); } return resultURIs; }
From source file:com.example.notes.NotesController.java
private long extractTagId(URI tagLocation) { try {//from w ww. ja v a2 s.com String idString = TAG_URI_TEMPLATE.match(tagLocation.toASCIIString()).get("id"); return Long.valueOf(idString); } catch (RuntimeException ex) { throw new IllegalArgumentException("The tag '" + tagLocation + "' is invalid"); } }
From source file:org.wikipedia.nirvana.WikiTools.java
private static String fetchQuery(Service service, String query) throws IOException, InterruptedException { URI uri = null; try {/*from w ww . ja v a 2 s. c o m*/ uri = new URI(HTTP, service.DOMAIN, service.PATH, query, null); } catch (URISyntaxException e) { log.error(e.toString()); return null; } if (testMode) { if (savedQueries == null) savedQueries = new ArrayList<>(); savedQueries.add(query); } if (testMode && mockedResponses != null) { if (mockedResponses.isEmpty()) { throw new RuntimeException( "fetchQuery() called in test mode when no mocked responces is available!"); } return mockedResponses.remove(0); } String page = null; try { page = HTTPTools.fetch(uri.toASCIIString(), !fastMode, true, true); } catch (java.net.SocketTimeoutException e) { if (fastMode) { throw e; } else { log.warn(e.toString() + ", retry again ..."); Thread.sleep(TIMEOUT_DELAY); page = HTTPTools.fetch(uri.toASCIIString(), true, true, true); } } return page; }
From source file:de.neofonie.aiko.yaml.RequestDefinition.java
private WebResource getWebResource(final Client client, final String domain) { String path = getUri().replaceAll("/$", ""); URI uri = URI.create(domain + path); System.out.println("\t\t" + method + " " + uri.toASCIIString()); return client.resource(uri); }