本文整理汇总了Java中org.apache.brooklyn.util.stream.Streams类的典型用法代码示例。如果您正苦于以下问题:Java Streams类的具体用法?Java Streams怎么用?Java Streams使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Streams类属于org.apache.brooklyn.util.stream包,在下文中一共展示了Streams类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import org.apache.brooklyn.util.stream.Streams; //导入依赖的package包/类
public ParsingResult<Csar> parse(String plan) {
ParsingResult<Csar> tp;
PlanTypeChecker type = new PlanTypeChecker(plan);
if (!type.isTosca) {
if (type.csarLink == null) {
throw new UnsupportedTypePlanException("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;
}
示例2: makeOutputPath
import org.apache.brooklyn.util.stream.Streams; //导入依赖的package包/类
private Path makeOutputPath(String yamlFile, String scriptsFolder, String... scripts) throws IOException {
File tempDir = Files.createTempDir();
tempDir.deleteOnExit();
File subfolder = new File(tempDir.getAbsolutePath() + "/scripts");
subfolder.mkdir();
Streams.copy(new ResourceUtils(this).getResourceFromUrl("classpath://templates/" + yamlFile),
new FileOutputStream(tempDir.toString() + "/" + yamlFile));
for (String script : scripts) {
Streams.copy(new ResourceUtils(this).getResourceFromUrl("classpath://scripts/" + scriptsFolder + "/" + script),
new FileOutputStream(subfolder.toString() + "/" + script));
}
Path outputPath = java.nio.file.Files.createTempFile("temp", ".zip");
FileUtil.zip(tempDir.toPath(), outputPath);
return outputPath;
}
示例3: execute
import org.apache.brooklyn.util.stream.Streams; //导入依赖的package包/类
@Override
public Response execute(Request request) throws IOException {
Map<String, String> headersMap = MutableMap.of();
for (Header header: request.getHeaders()) {
headersMap.put(header.getName(), header.getValue());
}
String mimeType = "text/plain"; // Default Content-Type used in Brooklyn Ambari
byte[] content = null;
TypedOutput body = request.getBody();
if (body != null) {
mimeType = request.getBody().mimeType();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
body.writeTo(baos);
content = baos.toByteArray();
} finally {
Streams.closeQuietly(baos);
}
}
final HttpResponse response = httpExecutor.execute(new HttpRequest.Builder()
.headers(headersMap)
.uri(URI.create(request.getUrl()))
.method(request.getMethod())
.body(content)
.build());
List<Header> responseHeaders = Lists.newArrayList();
for (Map.Entry<String, String> entry: response.headers().entries()) {
responseHeaders.add(new Header(entry.getKey(), entry.getValue()));
}
TypedInput responseBody = new TypedByteArray(mimeType, ByteStreams.toByteArray(response.getContent()));
return new Response(request.getUrl(),
response.code(),
(response.reasonPhrase() != null) ? response.reasonPhrase() : "",
responseHeaders,
responseBody);
}
示例4: uploadArchive
import org.apache.brooklyn.util.stream.Streams; //导入依赖的package包/类
public ParsingResult<Csar> uploadArchive(InputStream resourceFromUrl, String callerReferenceName) {
try {
File f = new File(tmpRoot, callerReferenceName + "_" + Identifiers.makeRandomId(8));
Streams.copy(resourceFromUrl, new FileOutputStream(f));
return uploadArchive(f, callerReferenceName);
} catch (Exception e) {
throw Exceptions.propagate(e);
}
}
示例5: create
import org.apache.brooklyn.util.stream.Streams; //导入依赖的package包/类
@RequestMapping(value = "/create", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED)
public void create(InputStream uploadedInputStream){
admin.postBlueprint(Streams.readFullyString(uploadedInputStream));
// TODO create a response
}
开发者ID:cloudfoundry-incubator,项目名称:apache-brooklyn-service-broker,代码行数:6,代码来源:BrooklynController.java