List of usage examples for java.net URI toASCIIString
public String toASCIIString()
From source file:com.serena.rlc.jenkins.plugins.rlcnotifier.RLCSite.java
public String encodePath(String path) { String result;// w w w . ja va 2 s.co m URI uri; try { uri = new URI(null, null, path, null); result = uri.toASCIIString(); } catch (Exception e) { result = path; } return result; }
From source file:org.dataconservancy.dcs.ingest.client.impl.DualManagerDeposit.java
public DcsFile referenceMetadata(String path, String... targets) { DcsFile file = newFile();/*from w w w.j ava 2s .c o m*/ URI pathUri = getUri(path); file.setSource(pathUri.toASCIIString()); file.setName(getFileName(pathUri)); for (String target : targets) { linkFileMetadata(file.getId(), target); } return file; }
From source file:at.uni_salzburg.cs.ckgroup.cpcc.engmap.EngMapServlet.java
@Override public void reloadConfigFile() throws IOException { if (configFile == null || !configFile.exists()) { LOG.error("No configuration file available."); return;//from ww w . j a v a 2 s. c om } FileInputStream inStream = new FileInputStream(configFile); configuration.loadConfig(inStream); inStream.close(); LOG.info("Loading configuration from " + configFile); URI pilotUrl = configuration.getPilotUrl(); sensorProxy.setPilotUrl(pilotUrl != null ? pilotUrl.toASCIIString() : null); LOG.info("Loading configuration from " + configFile); List<IMappingAlgorithm> algorithms = new ArrayList<IMappingAlgorithm>(); List<Class<IMappingAlgorithm>> mapperAlgorithmClassList = configuration.getMapperAlgorithmClassList(); if (mapperAlgorithmClassList != null) { for (Class<IMappingAlgorithm> cls : mapperAlgorithmClassList) { try { algorithms.add(cls.newInstance()); } catch (Exception e) { LOG.error("Can not instantiate mapper algorithm", e); throw new IOException("Can not instantiate mapper algorithm", e); } } } mapper.setMappingAlgorithms(algorithms); for (File vehicleDir : vehicleStorage.listVehicleFolder()) { IVirtualVehicle vehicle = vehicleMap.get(vehicleDir.getName()); if (vehicle == null) { try { vehicle = vehicleBuilder.build(vehicleDir); if (!vehicle.isActive() && configuration.isPilotAvailable()) { vehicle.resume(); } vehicleMap.put(vehicleDir.getName(), vehicle); } catch (IOException e) { vehicleMap.remove(vehicleDir.getName()); vehicleStorage.removeVehicleWorkDir(vehicleDir); LOG.error("Virtual vehicle in " + vehicleDir.getName() + " is corrupt and has been removed."); } } } if (configuration.isPilotAvailable() && !sensorProxy.isRunning()) { sensorProxy.start(); } Runnable r = new Runnable() { @Override public void run() { try { registerMySelfWithMe(); } catch (IOException e) { LOG.error("Self registration failed", e); } } }; Thread t = new Thread(r); t.start(); }
From source file:net.xy.jcms.shared.adapter.HttpRequestDataAccessContext.java
@Override public String buildUriWithParams(final String requestString, final Map<Object, Object> parameters) { // 1. should not alter external links // 2. should convert absolute uris to relatives if possible try {/*ww w .j a va 2 s .c o m*/ URI build; // the initial request try { // first asume its already an proper url build = new URI(requestString); } catch (final URISyntaxException ex) { // second encode to an proper url final String requestUri = URLEncoder.encode(requestString, "UTF-8"); build = new URI(requestUri); } if (!build.isAbsolute()) { build = rootUrl.resolve(build); // make it absolute } final String path = StringUtils.isNotBlank(build.getPath()) ? build.getPath() : "/"; build = new URI(build.getScheme(), build.getUserInfo(), build.getHost(), build.getPort(), path, buildQuery(parameters), build.getFragment()); final URI relBuild = rootUrl.relativize(build); final String ret; if (!relBuild.isAbsolute()) { // because we relativate it always to docroot, which is the // servlet container in JEE ret = contextPath + relBuild.toASCIIString().replace("+", "%20"); } else { ret = relBuild.toASCIIString(); } return ret; } catch (final URISyntaxException e) { throw new IllegalArgumentException("URL couldn't be build from given parameters. " + DebugUtils.printFields(requestString, parameters), e); } catch (final UnsupportedEncodingException e) { throw new IllegalArgumentException( " Encoding is not supported " + DebugUtils.printFields(requestString, parameters), e); } }
From source file:com.almende.eve.transport.ws.WsServerTransport.java
@Override public void send(final URI receiverUri, final String message, final String tag) throws IOException { if (remotes.containsKey(receiverUri)) { final Async remote = remotes.get(receiverUri); remote.sendText(message);//from ww w .ja v a 2 s .c om remote.flushBatch(); } else { throw new IOException("Remote: " + receiverUri.toASCIIString() + " is currently not connected. (" + getAddress() + " / " + remotes.keySet() + ")"); } }
From source file:org.apache.ode.bpel.compiler.BpelC.java
/** * Register a "global" WSDL import for compilation. This is used to specify WSDL * imports for BPEL 1.1 processes that do not support the <code><import></code> * BPEL construct.// w w w. j a v a 2s. c om * @param wsdl the WSDL URI (resolvable against the resource repository) */ public void setProcessWSDL(URI wsdl) { if (__log.isDebugEnabled()) { __log.debug("Adding WSDL import: \"" + wsdl.toASCIIString() + "\"."); } _bpel11wsdl = wsdl; }
From source file:org.dataconservancy.dcs.ingest.client.impl.DualManagerDeposit.java
public DcsFile referenceFile(String path, String... manifestations) { if (manifestations.length == 0 && dcp.getManifestations().size() == 1) { return referenceFile(path, dcp.getManifestations().iterator().next().getId()); } else if (manifestations.length == 0) { throw new IllegalStateException("Cannot add a file if there are no manifestations"); }/*from w w w . j a va2 s . c o m*/ DcsFile file = newFile(); URI pathUri = getUri(path); file.setSource(pathUri.toASCIIString()); file.setName(getFileName(pathUri)); for (String m : manifestations) { DcsManifestation manifestation = getManifestation(m); DcsManifestationFile dmf = new DcsManifestationFile(); dmf.setRef(new DcsFileRef(file.getId())); manifestation.addManifestationFile(dmf); saveManifestation(manifestation); } return file; }
From source file:org.apache.olingo.ext.proxy.commons.AbstractCollectionInvocationHandler.java
public <ET extends EntityType<?>> boolean addRef(final ET element) { if (element instanceof Proxy && Proxy.getInvocationHandler(element) instanceof EntityInvocationHandler) { final EntityInvocationHandler handler = EntityInvocationHandler.class .cast(Proxy.getInvocationHandler(element)); final URI id = handler.getEntity().getId(); if (id == null) { return false; }//from ww w .ja v a 2s . c o m return referenceItems.add(id.toASCIIString()); } return false; }
From source file:stargate.client.hdfs.StargateFileSystem.java
public void initialize(URI stargateUIServiceURL) throws IOException { if (stargateUIServiceURL == null) { throw new IllegalArgumentException("stargateUIServiceURL is null"); }//from ww w. j a v a 2 s . c om LOG.info("connecting to Stargate : " + stargateUIServiceURL.toASCIIString()); this.userInterfaceClient = new HTTPUserInterfaceClient(stargateUIServiceURL); if (!this.userInterfaceClient.isLive()) { throw new IOException("cannot connect to Stargate : " + stargateUIServiceURL.toASCIIString()); } this.localCluster = this.userInterfaceClient.getCluster(); LOG.info("connected : " + stargateUIServiceURL.toASCIIString()); }
From source file:com.bluros.updater.service.UpdateCheckService.java
private void getAvailableUpdates() { // Get the type of update we should check for int updateType = Utils.getUpdateType(); // Get the actual ROM Update Server URL URI updateServerUri = getServerURI(); UpdatesJsonObjectRequest request;//from www .j a v a 2 s .c o m try { request = new UpdatesJsonObjectRequest(updateServerUri.toASCIIString(), Utils.getUserAgentString(this), buildUpdateRequest(updateType), this, this); // Improve request error tolerance request.setRetryPolicy(new DefaultRetryPolicy(UPDATE_REQUEST_TIMEOUT, UPDATE_REQUEST_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); // Set the tag for the request, reuse logging tag request.setTag(TAG); } catch (JSONException e) { Log.e(TAG, "Could not build request", e); return; } ((UpdateApplication) getApplicationContext()).getQueue().add(request); }