/** @deprecated since 0.7.0 use {@link #newInputStreamWithContents(String)} */ @Deprecated public static InputStream fromString(String contents) { return newInputStreamWithContents(contents); }
private static String tagForEquivalentPlan(String input) { // plans may be trimmed by yaml parser so do that before checking equivalence // it does mean a format change will be ignored return "equivalent-plan("+Streams.getMd5Checksum(Streams.newInputStreamWithContents(input.trim()))+")"; }
public static ManifestHelper forManifestContents(String contents) throws IOException, BundleException { ManifestHelper result = forManifest(Streams.newInputStreamWithContents(contents)); result.source = contents; return result; }
public static InputStreamSupplier fromString(String input) { return new InputStreamSupplier(Streams.newInputStreamWithContents(input)); }
private static String getChecksum(ZipFile zf) { // checksum should ignore time/date stamps on files - just look at entries and contents. also ignore order. // (tests fail without time/date is one reason, but really if a person rebuilds a ZIP that is the same // files we should treat it as identical) try { Map<String,String> entriesToChecksum = MutableMap.of(); for (ZipEntry ze: Collections.list(zf.entries())) { entriesToChecksum.put(ze.getName(), Streams.getMd5Checksum(zf.getInputStream(ze))); } return Streams.getMd5Checksum(Streams.newInputStreamWithContents(new TreeMap<>(entriesToChecksum).toString())); } catch (Exception e) { throw Exceptions.propagate(e); } }
@Override public ProcessTaskWrapper<Integer> executeScriptAsync(String commands) { String filename = "postgresql-commands-"+Identifiers.makeRandomId(8); installFile(Streams.newInputStreamWithContents(commands), filename); return executeScriptFromInstalledFileAsync(filename); }
@Test(groups = "Integration") public void testCopyStreamTo() throws Exception { String contents = "abc"; File dest = new File(Os.tmp(), "sshMachineLocationTest_dest.tmp"); try { host.copyTo(Streams.newInputStreamWithContents(contents), dest.getAbsolutePath()); assertEquals("abc", Files.readFirstLine(dest, Charsets.UTF_8)); } finally { dest.delete(); } }
@Override public void reconfigureService() { String cfg = getConfigFile(); if (cfg == null) return; if (LOG.isDebugEnabled()) LOG.debug("Reconfiguring {}, targetting {} and {}", new Object[] {this, getServerPoolAddresses(), getUrlMappings()}); if (LOG.isTraceEnabled()) LOG.trace("Reconfiguring {}, config file:\n{}", this, cfg); NginxSshDriver driver = (NginxSshDriver) getDriver(); if (!driver.isCustomizationCompleted()) { if (LOG.isDebugEnabled()) LOG.debug("Reconfiguring {}, but driver's customization not yet complete so aborting", this); return; } driver.getMachine().copyTo(Streams.newInputStreamWithContents(cfg), driver.getRunDir()+"/conf/server.conf"); installSslKeys("global", getSslConfig()); for (UrlMapping mapping : getUrlMappings()) { //cache ensures only the first is installed, which is what is assumed below installSslKeys(mapping.getDomain(), mapping.getConfig(UrlMapping.SSL_CONFIG)); } }
entity.getDriver().copyResource(new KnownSizeInputStream(Streams.newInputStreamWithContents(tempLocalContent), tempLocalContent.length()), tempDest.getAbsolutePath()); assertEquals(Files.readLines(tempDest, Charsets.UTF_8), ImmutableList.of(tempLocalContent)); tempDest.delete();
public Object parseDslExpression(String input) { String s1 = Yamls.getAs( Yamls.parseAll( Streams.reader(Streams.newInputStreamWithContents(input)) ), String.class ); BasicCampPlatform p = new BasicCampPlatform(); p.pdp().addInterpreter(new BrooklynDslInterpreter()); Object out = p.pdp().applyInterpreters(MutableMap.of("key", s1)).get("key"); log.debug("parsed "+input+" as "+out+" ("+(out==null ? "null" : out.getClass())+")"); return out; }
public ParsingResult<Csar> parse(String plan) { ParsingResult<Csar> tp; PlanTypeChecker type = new PlanTypeChecker(plan); if (!type.isTosca) { if (type.csarLink == null) { throw new PlanNotRecognizedException("Does not look like TOSCA"); } tp = uploader.uploadArchive(new ResourceUtils(this).getResourceFromUrl(type.csarLink), "submitted-tosca-archive"); } else { tp = uploader.uploadSingleYaml(Streams.newInputStreamWithContents(plan), "submitted-tosca-plan"); } if (ArchiveUploadService.hasError(tp, ParsingErrorLevel.ERROR)) { throw new UserFacingException("Could not parse TOSCA plan: " + Strings.join(tp.getContext().getParsingErrors(), "\n ")); } return tp; } }
String templateContents = Streams.readFullyString(resource); String processedContents = TemplateProcessor.processTemplateContents(templateContents, (EntityInternal) entity, setup.getAllConfig()); InputStream processedResource = Streams.newInputStreamWithContents(processedContents);
public void testCreateListDestroyContainer() throws IOException { context.getBlobStore().createContainerInLocation(null, testContainerName); context.getBlobStore().list(testContainerName); PageSet<? extends StorageMetadata> ps = context.getBlobStore().list(); assertHasItemNamed(ps, testContainerName); Blob b = context.getBlobStore().blobBuilder("my-blob-1").payload(Streams.newInputStreamWithContents("hello world")).build(); context.getBlobStore().putBlob(testContainerName, b); Blob b2 = context.getBlobStore().getBlob(testContainerName, "my-blob-1"); Assert.assertEquals(Streams.readFullyStringAndClose(b2.getPayload().openStream()), "hello world"); context.getBlobStore().deleteContainer(testContainerName); }
public void testCreateListDestroySimpleDirInContainer() throws IOException { context.getBlobStore().createContainerInLocation(null, testContainerName); context.getBlobStore().createDirectory(testContainerName, "my-dir-1"); PageSet<? extends StorageMetadata> ps = context.getBlobStore().list(testContainerName); assertHasItemNamed(ps, "my-dir-1"); Blob b = context.getBlobStore().blobBuilder("my-blob-1").payload(Streams.newInputStreamWithContents("hello world")).build(); context.getBlobStore().putBlob(testContainerName+"/"+"my-dir-1", b); ps = context.getBlobStore().list(testContainerName, ListContainerOptions.Builder.inDirectory("my-dir-1")); assertHasItemNamed(ps, "my-dir-1/my-blob-1"); // both these syntaxes work: Blob b2 = context.getBlobStore().getBlob(testContainerName+"/"+"my-dir-1", "my-blob-1"); Assert.assertEquals(Streams.readFullyStringAndClose(b2.getPayload().openStream()), "hello world"); Blob b3 = context.getBlobStore().getBlob(testContainerName, "my-dir-1"+"/"+"my-blob-1"); Assert.assertEquals(Streams.readFullyStringAndClose(b3.getPayload().openStream()), "hello world"); context.getBlobStore().deleteContainer(testContainerName); }