List of usage examples for org.apache.commons.lang CharEncoding UTF_8
String UTF_8
To view the source code for org.apache.commons.lang CharEncoding UTF_8.
Click Source Link
Eight-bit Unicode Transformation Format.
From source file:org.cloudifysource.esc.driver.provisioning.privateEc2.PrivateEC2CloudifyDriver.java
private S3Object uploadCloudDir(final ProvisioningContextImpl ctx, final String script, final boolean isManagement) throws CloudProvisioningException { try {/*from w w w. j a va2 s.com*/ final ComputeTemplate template = this.getManagerComputeTemplate(); final String cloudDirectory = isManagement ? ((File) this.cloud.getCustom().get("###CLOUD_DIRECTORY###")).getAbsolutePath() : template.getAbsoluteUploadDir(); final String s3BucketName = (String) template.getCustom().get("s3BucketName"); // Generate env script final StringBuilder sb = new StringBuilder(); sb.append("#!/bin/bash\n"); sb.append(script); if (isManagement) { // TODO retrieve port dynamically for LUS_IP_ADDRESS sb.append("export LUS_IP_ADDRESS=`curl http://instance-data/latest/meta-data/local-ipv4`:4174"); } // Create tmp dir final File createTempFile = File.createTempFile("cloudify_env", ""); createTempFile.delete(); // Create tmp file final File tmpEnvFile = new File(createTempFile, CLOUDIFY_ENV_SCRIPT); tmpEnvFile.deleteOnExit(); // Write the script into the temp filedir FileUtils.writeStringToFile(tmpEnvFile, sb.toString(), CharEncoding.UTF_8); // Compress file logger.fine("Archive folders to upload: " + cloudDirectory + " and " + tmpEnvFile.getAbsolutePath()); String[] sourcePaths = new String[] { cloudDirectory, tmpEnvFile.getAbsolutePath() }; final File tarGzFile = TarGzUtils.createTarGz(sourcePaths, false); // Upload to S3 final S3Object s3Object = amazonS3Uploader.uploadFile(s3BucketName, tarGzFile); return s3Object; } catch (IOException e) { throw new CloudProvisioningException(e); } }
From source file:org.codice.ddf.catalog.download.action.ResourceDownloadActionProvider.java
@Override protected URL getMetacardActionUrl(String metacardSource, Metacard metacard) throws MalformedURLException, URISyntaxException, UnsupportedEncodingException { String encodedMetacardId = URLEncoder.encode(metacard.getId(), CharEncoding.UTF_8); String encodedMetacardSource = URLEncoder.encode(metacardSource, CharEncoding.UTF_8); return getActionUrl(encodedMetacardSource, encodedMetacardId); }
From source file:org.codice.ddf.catalog.download.action.ResourceDownloadActionProviderTest.java
private URL getUrl(String metacardId) throws MalformedURLException, UnsupportedEncodingException { String encodedMetacardId = URLEncoder.encode(metacardId, CharEncoding.UTF_8); String urlString = String.format("%s?source=%s&metacard=%s", CONTEXT_PATH, REMOTE_SITE_NAME, encodedMetacardId);/* w w w .ja v a 2 s .co m*/ return new URL(SystemBaseUrl.EXTERNAL.constructUrl(urlString, true)); }
From source file:org.codice.ddf.endpoints.rest.action.AbstractMetacardActionProvider.java
@Override public <T> List<Action> getActions(T input) { if (input instanceof Metacard) { Metacard metacard = (Metacard) input; if (StringUtils.isBlank(metacard.getId())) { LOGGER.info("No id given. No action to provide."); return Collections.emptyList(); }//ww w . j a v a2 s . c om if (isHostUnset(SystemBaseUrl.getHost())) { LOGGER.info("Host name/ip not set. Cannot create link for metacard."); return Collections.emptyList(); } String metacardId = null; String metacardSource = null; try { metacardId = URLEncoder.encode(metacard.getId(), CharEncoding.UTF_8); metacardSource = URLEncoder.encode(getSource(metacard), CharEncoding.UTF_8); } catch (UnsupportedEncodingException e) { LOGGER.info("Unsupported Encoding exception", e); return Collections.emptyList(); } Action action = getAction(metacardId, metacardSource); if (action == null) { return Collections.emptyList(); } return Arrays.asList(action); } return Collections.emptyList(); }
From source file:org.codice.ddf.endpoints.rest.action.MetacardTransformerActionProviderTest.java
private URL getUrl(String metacardId) throws MalformedURLException, UnsupportedEncodingException { String encodedMetacardId = URLEncoder.encode(metacardId, CharEncoding.UTF_8); String urlString = String.format("%s%s/%s/%s?transform=%s", CONTEXT_ROOT, SOURCES_PATH, REMOTE_SOURCE_ID, encodedMetacardId, SAMPLE_TRANSFORMER_ID); return new URL(SystemBaseUrl.EXTERNAL.constructUrl(urlString, true)); }
From source file:org.codice.ddf.endpoints.rest.action.TestMetacardTransformerActionProvider.java
private URL getUrl(String metacardId) throws MalformedURLException, UnsupportedEncodingException { String encodedMetacardId = URLEncoder.encode(metacardId, CharEncoding.UTF_8); String urlString = String.format("%s%s/%s/%s?transform=%s", CONTEXT_ROOT, SOURCES_PATH, REMOTE_SOURCE_ID, encodedMetacardId, SAMPLE_TRANSFORMER_ID); return new URL(SystemBaseUrl.constructUrl(urlString, true)); }
From source file:org.codice.ddf.endpoints.rest.action.TestViewMetacardActionProvider.java
private URL getUrl(String metacardId) throws MalformedURLException, UnsupportedEncodingException { String encodedMetacardId = URLEncoder.encode(metacardId, CharEncoding.UTF_8); String urlString = String.format("%s%s/%s/%s", CONTEXT_ROOT, SOURCES_PATH, REMOTE_SOURCE_ID, encodedMetacardId);//from w w w .ja v a 2s. c om return new URL(SystemBaseUrl.constructUrl(urlString, true)); }
From source file:org.codice.ddf.endpoints.rest.action.ViewMetacardActionProviderTest.java
private URL getUrl(String metacardId) throws MalformedURLException, UnsupportedEncodingException { String encodedMetacardId = URLEncoder.encode(metacardId, CharEncoding.UTF_8); String urlString = String.format("%s%s/%s/%s", CONTEXT_ROOT, SOURCES_PATH, REMOTE_SOURCE_ID, encodedMetacardId);/* w w w .ja v a2 s.c o m*/ return new URL(SystemBaseUrl.EXTERNAL.constructUrl(urlString, true)); }
From source file:org.codice.ddf.rest.impl.action.AbstractMetacardActionProvider.java
@Override public <T> Action getAction(T input) { if (!canHandle(input)) { return null; }//www .j ava 2s . co m Metacard metacard = (Metacard) input; if (StringUtils.isBlank(metacard.getId())) { LOGGER.info("No id given. No action to provide."); return null; } if (isHostUnset(SystemBaseUrl.EXTERNAL.getHost())) { LOGGER.info("Host name/ip not set. Cannot create link for metacard."); return null; } String metacardId = null; String metacardSource = null; try { metacardId = URLEncoder.encode(metacard.getId(), CharEncoding.UTF_8); metacardSource = URLEncoder.encode(getSource(metacard), CharEncoding.UTF_8); } catch (UnsupportedEncodingException e) { LOGGER.info("Unsupported Encoding exception", e); return null; } return getAction(metacardId, metacardSource); }
From source file:org.codice.ddf.transformer.preview.actions.PreviewActionProviderTest.java
private URL getUrl(String metacardId, String metacardSource) throws MalformedURLException, UnsupportedEncodingException { String encodedMetacardId = URLEncoder.encode(metacardId, CharEncoding.UTF_8); String urlString = String.format("%s%s/%s/%s?transform=preview", CONTEXT_ROOT, SOURCES_PATH, metacardSource, encodedMetacardId);/*w ww. j a va2 s . com*/ return new URL(SystemBaseUrl.EXTERNAL.constructUrl(urlString, true)); }