public static AggregationsManifest fromSource(Map<String, Object> unwrappedAggregationsSource) { ImmutableMap.Builder<String, AggregationManifest> builder = ImmutableMap.builder(); for (Map.Entry<String, Object> entry : unwrappedAggregationsSource.entrySet()) { final String name = entry.getKey(); final Map<String, Object> aggregation = nodeMapValue(entry.getValue(), String.class, Object.class); AggregationsManifest subAggManifest = null; String type = null; for (Map.Entry<String, Object> field : aggregation.entrySet()) { if (field.getKey().equals("aggregations") || field.getKey().equals("aggs")) { subAggManifest = AggregationsManifest.fromSource(nodeMapValue(field.getValue(), String.class, Object.class)); } else { // assume this is the "type" of the agg; we should only see one. checkState(type == null); type = field.getKey(); } } builder.put(name, new AggregationManifest(type, subAggManifest)); } return new AggregationsManifest(builder.build()); }
context.parsedPostFilter(new ParsedFilter(new AndFilter(fliste), ImmutableMap.<String, Filter> builder().build())); } else { fliste.add(origfilter.filter());
fields.put(field.getName(), field); InternalSearchHit internalSearchHit = new InternalSearchHit(docId, id, type, fields.build()); internalSearchHit.score(score); internalSearchHit.sourceRef(source); highlights.put(highlightField.getName(), highlightField); internalSearchHit.highlightFields(highlights.build());
sourceAsMap.putAll(this.source); builder.put("_source", sourceAsMap.build()); for (SearchHit hit : searchHits.hits()) { ImmutableMap.Builder<String, Object> hitProperties = ImmutableMap.builder(); hitProperties.put("_index", hit.index()); hitProperties.put("_type", hit.type()); hitProperties.put("_id", hit.id()); hitProperties.put("_version", hit.version()); hitProperties.put("_source", hit.sourceAsMap()); fieldsMap.put(field.name(), field.value()); hitProperties.put("fields", fieldsMap); hits.add(hitProperties.build()); queryHitsAsMap.put(query, hits); builder.put("_queries", queryHitsAsMap.build());
sourceAsMap.putAll(this.source); builder.put("_source", sourceAsMap.build()); for (SearchHit hit : searchHits.hits()) { ImmutableMap.Builder<String, Object> hitProperties = ImmutableMap.builder(); hitProperties.put("_index", hit.index()); hitProperties.put("_type", hit.type()); hitProperties.put("_id", hit.id()); hitProperties.put("_version", hit.version()); hitProperties.put("_source", hit.sourceAsMap()); fieldsMap.put(field.name(), field.value()); hitProperties.put("fields", fieldsMap); hits.add(hitProperties.build()); queryHitsAsMap.put(query, hits); builder.put("_queries", queryHitsAsMap.build());
Assert.assertEquals("tosca.artifacts.Implementation.Bash", httpRelationshipStartArtifact.getArtifactType()); Assert.assertEquals( ImmutableMap.<String, Object> builder().put(NormativeCredentialConstant.USER_KEY, "good_user") .put(NormativeCredentialConstant.TOKEN_KEY, "real_secured_password").put(NormativeCredentialConstant.TOKEN_TYPE, "password").build(), httpRelationshipStartArtifact.getRepositoryCredential()); Assert.assertEquals("script_repo", httpRelationshipStartArtifact.getRepositoryName());
Assert.assertEquals("tosca.artifacts.Deployment.War", repositoryArtifact.getArtifactType()); Assert.assertEquals( ImmutableMap.<String, Object> builder().put(NormativeCredentialConstant.USER_KEY, "good_user") .put(NormativeCredentialConstant.TOKEN_KEY, "real_secured_password").put(NormativeCredentialConstant.TOKEN_TYPE, "password").build(), repositoryArtifact.getRepositoryCredential()); Assert.assertEquals("maven_repo", repositoryArtifact.getRepositoryName());
@Override public ImmutableMap<String, BlobMetaData> listBlobsByPrefix(@Nullable String blobNamePrefix) throws IOException { ImmutableMap.Builder<String, BlobMetaData> blobsBuilder = ImmutableMap.builder(); ObjectListing prevListing = null; while (true) { ObjectListing list; if (prevListing != null) { list = blobStore.client().listNextBatchOfObjects(prevListing); } else { if (blobNamePrefix != null) { list = blobStore.client().listObjects(blobStore.bucket(), buildKey(blobNamePrefix)); } else { list = blobStore.client().listObjects(blobStore.bucket(), keyPath); } } for (S3ObjectSummary summary : list.getObjectSummaries()) { String name = summary.getKey().substring(keyPath.length()); blobsBuilder.put(name, new PlainBlobMetaData(name, summary.getSize())); } if (list.isTruncated()) { prevListing = list; } else { break; } } return blobsBuilder.build(); }
private void validateHttpArtifact(NodeType httpComponent) { ImplementationArtifact httpComponentCreateArtifact = getImplementationArtifact(httpComponent, "create"); Assert.assertEquals("https://otherCompany/script/short_notation.sh", httpComponentCreateArtifact.getArtifactRef()); Assert.assertEquals("tosca.artifacts.Implementation.Bash", httpComponentCreateArtifact.getArtifactType()); assertNull(httpComponentCreateArtifact.getRepositoryCredential()); assertNull(httpComponentCreateArtifact.getRepositoryName()); assertNull(httpComponentCreateArtifact.getArtifactRepository()); assertNull(httpComponentCreateArtifact.getRepositoryURL()); ImplementationArtifact httpComponentStartArtifact = getImplementationArtifact(httpComponent, "start"); Assert.assertEquals("myScript.abc", httpComponentStartArtifact.getArtifactRef()); Assert.assertEquals("tosca.artifacts.Implementation.Bash", httpComponentStartArtifact.getArtifactType()); Assert.assertEquals( ImmutableMap.<String, Object> builder().put(NormativeCredentialConstant.USER_KEY, "good_user") .put(NormativeCredentialConstant.TOKEN_KEY, "real_secured_password").put(NormativeCredentialConstant.TOKEN_TYPE, "password").build(), httpComponentStartArtifact.getRepositoryCredential()); Assert.assertEquals("script_repo", httpComponentStartArtifact.getRepositoryName()); assertNull(httpComponentStartArtifact.getArtifactRepository()); Assert.assertEquals("https://myCompany/script", httpComponentStartArtifact.getRepositoryURL()); }
public static AggregationsManifest fromSource(Map<String, Object> unwrappedAggregationsSource) { ImmutableMap.Builder<String, AggregationManifest> builder = ImmutableMap.builder(); for (Map.Entry<String, Object> entry : unwrappedAggregationsSource.entrySet()) { final String name = entry.getKey(); final Map<String, Object> aggregation = nodeMapValue(entry.getValue(), String.class, Object.class); AggregationsManifest subAggManifest = null; String type = null; for (Map.Entry<String, Object> field : aggregation.entrySet()) { if (field.getKey().equals("aggregations") || field.getKey().equals("aggs")) { subAggManifest = AggregationsManifest.fromSource(nodeMapValue(field.getValue(), String.class, Object.class)); } else { // assume this is the "type" of the agg; we should only see one. checkState(type == null); type = field.getKey(); } } builder.put(name, new AggregationManifest(type, subAggManifest)); } return new AggregationsManifest(builder.build()); }
@Inject public ViewService(Settings settings, Environment environment, Set<ViewEngineService> viewEngines) { super(settings); this.defaultViewLang = componentSettings.get("default_view_lang", "mvel"); ImmutableMap.Builder<String, ViewEngineService> builder = ImmutableMap.builder(); for (ViewEngineService viewEngine : viewEngines) { for (String type : viewEngine.types()) { builder.put(type, viewEngine); } } this.viewEngines = builder.build(); // compile static scripts File viewsFile = new File(environment.configFile(), "views"); if (viewsFile.exists()) { processViewsDirectory("", viewsFile); } }
@Override public ImmutableMap<String, BlobMetaData> listBlobsByPrefix(final String blobNamePrefix) throws IOException { FileStatus[] files = blobStore.fileSystem().listStatus(path, new PathFilter() { @Override public boolean accept(Path path) { return path.getName().startsWith(blobNamePrefix); } }); if (files == null || files.length == 0) { return ImmutableMap.of(); } ImmutableMap.Builder<String, BlobMetaData> builder = ImmutableMap.builder(); for (FileStatus file : files) { builder.put(file.getPath().getName(), new PlainBlobMetaData(file.getPath().getName(), file.getLen())); } return builder.build(); }
@Inject public ViewService(Settings settings, Environment environment, Set<ViewEngineService> viewEngines) { super(settings); this.defaultViewLang = componentSettings.get("default_view_lang", "mvel"); ImmutableMap.Builder<String, ViewEngineService> builder = ImmutableMap.builder(); for (ViewEngineService viewEngine : viewEngines) { for (String type : viewEngine.types()) { builder.put(type, viewEngine); } } this.viewEngines = builder.build(); // compile static scripts File viewsFile = new File(environment.configFile(), "views"); if (viewsFile.exists()) { processViewsDirectory("", viewsFile); } }
private void validateRemoteWar(DeploymentArtifact repositoryArtifact) { Assert.assertEquals("alien4cloud:alien4cloud-ui:1.3.0-SM3", repositoryArtifact.getArtifactRef()); Assert.assertEquals("tosca.artifacts.Deployment.War", repositoryArtifact.getArtifactType()); Assert.assertEquals( ImmutableMap.<String, Object> builder().put(NormativeCredentialConstant.USER_KEY, "good_user") .put(NormativeCredentialConstant.TOKEN_KEY, "real_secured_password").put(NormativeCredentialConstant.TOKEN_TYPE, "password").build(), repositoryArtifact.getRepositoryCredential()); Assert.assertEquals("maven_repo", repositoryArtifact.getRepositoryName()); Assert.assertEquals("maven", repositoryArtifact.getArtifactRepository()); Assert.assertEquals("https://fastconnect.org/maven/content/repositories/fastconnect", repositoryArtifact.getRepositoryURL()); }
public ImmutableMap<String, BlobMetaData> listBlobs() throws IOException { FileStatus[] files = blobStore.fileSystem().listStatus(path); if (files == null || files.length == 0) { return ImmutableMap.of(); } ImmutableMap.Builder<String, BlobMetaData> builder = ImmutableMap.builder(); for (FileStatus file : files) { builder.put(file.getPath().getName(), new PlainBlobMetaData(file.getPath().getName(), file.getLen())); } return builder.build(); }