List of usage examples for com.google.common.collect ImmutableMap get
V get(Object key);
From source file:org.openo.sdno.testframework.moco.requestmacher.QueryParamRequestMatcher.java
@Override public boolean match(Request request) { DefaultHttpRequest inHttpRequest = (DefaultHttpRequest) request; Map<String, String> matchedQueryMap = matchedRequest.getQueries(); if (null == matchedQueryMap || matchedQueryMap.isEmpty()) { return true; }/* ww w .j a v a2 s .c om*/ ImmutableMap<String, String[]> inQueryMap = inHttpRequest.getQueries(); for (Map.Entry<String, String> curQueryEntity : matchedQueryMap.entrySet()) { String[] curInParamList = inQueryMap.get(curQueryEntity.getKey()); // impossible matches if (null == curInParamList || 0 == curInParamList.length) { return false; } if (!Pattern.compile(curQueryEntity.getValue()).matcher(curInParamList[0]).matches()) { return false; } } return true; }
From source file:fr.xebia.cloud.amazon.aws.tools.AmazonAwsUtils.java
public static void deleteCnameIfExist(Iterable<String> cnames, HostedZone hostedZone, AmazonRoute53 route53) { // List all// ww w . j a v a 2s . c om ListResourceRecordSetsRequest listResourceRecordSetsRequest = new ListResourceRecordSetsRequest() // .withStartRecordType(RRType.CNAME) .withHostedZoneId(hostedZone.getId()); ListResourceRecordSetsResult listResourceRecordSetsResult = route53 .listResourceRecordSets(listResourceRecordSetsRequest); if (listResourceRecordSetsResult.isTruncated()) { logger.warn("truncated result"); } Function<ResourceRecordSet, String> cnameExtractor = new Function<ResourceRecordSet, String>() { @Override public String apply(@Nullable ResourceRecordSet resourceRecordSet) { if (resourceRecordSet == null) { return null; } if (!RRType.CNAME.equals(RRType.fromValue(resourceRecordSet.getType()))) { return null; } return resourceRecordSet.getName(); } }; Iterable<ResourceRecordSet> existingCnamesAsResourceRecordSet = Iterables .filter(listResourceRecordSetsResult.getResourceRecordSets(), new Predicate<ResourceRecordSet>() { @Override public boolean apply(@Nullable ResourceRecordSet resourceRecordSet) { return RRType.CNAME.equals(RRType.fromValue(resourceRecordSet.getType())); } }); final ImmutableMap<String, ResourceRecordSet> existingCnames = Maps .uniqueIndex(existingCnamesAsResourceRecordSet, cnameExtractor); Sets.SetView<String> cnamesToDelete = Sets.intersection(Sets.newHashSet(cnames), existingCnames.keySet()); Function<String, Change> cnameToDeleteCnameChange = new Function<String, Change>() { @Override public Change apply(@Nullable String cname) { ResourceRecordSet existingResourceRecordSet = existingCnames.get(cname); return new Change().withAction(ChangeAction.DELETE) .withResourceRecordSet(new ResourceRecordSet().withType(RRType.CNAME).withName(cname) .withTTL(existingResourceRecordSet.getTTL()) .withResourceRecords(existingResourceRecordSet.getResourceRecords())); } }; List<Change> changes = Lists.newArrayList(Iterables.transform(cnamesToDelete, cnameToDeleteCnameChange)); if (changes.isEmpty()) { logger.debug("No CNAME to delete"); return; } logger.info("Delete CNAME changes {}", changes); ChangeResourceRecordSetsRequest changeResourceRecordSetsRequest = new ChangeResourceRecordSetsRequest() .withHostedZoneId(hostedZone.getId()).withChangeBatch(new ChangeBatch().withChanges(changes)); route53.changeResourceRecordSets(changeResourceRecordSetsRequest); }
From source file:org.incode.module.country.dom.impl.CountryRepository.java
@Programmatic public List<Country> countriesFor(final Iterable<String> countryCodes) { List<Country> available = Lists.newArrayList(); final ImmutableMap<String, Country> countryByCode = Maps.uniqueIndex(allCountries(), input -> input.getName()); for (String countryCodeForUser : countryCodes) { available.add(countryByCode.get(countryCodeForUser)); }/*from w w w . j a v a2 s . co m*/ return available; }
From source file:com.baasbox.service.push.providers.GCMServer.java
@Override public void setConfiguration(ImmutableMap<Factory.ConfigurationKeys, String> configuration) { apikey = configuration.get(ConfigurationKeys.ANDROID_API_KEY); if (StringUtils.isNotEmpty(apikey)) { isInit = true;// w w w . j ava 2s .co m } }
From source file:com.google.gerrit.metrics.dropwizard.MetricJson.java
MetricJson(Metric metric, ImmutableMap<String, String> atts, boolean dataOnly) { if (!dataOnly) { description = atts.get(Description.DESCRIPTION); unit = atts.get(Description.UNIT); constant = toBool(atts, Description.CONSTANT); rate = toBool(atts, Description.RATE); gauge = toBool(atts, Description.GAUGE); cumulative = toBool(atts, Description.CUMULATIVE); }/* w w w. j a v a 2 s .c o m*/ init(metric, atts); }
From source file:org.apache.cloudstack.outofbandmanagement.driver.ipmitool.IpmitoolOutOfBandManagementDriver.java
private String getIpmiUserId(ImmutableMap<OutOfBandManagement.Option, String> options, final Duration timeOut) { final String username = options.get(OutOfBandManagement.Option.USERNAME); if (Strings.isNullOrEmpty(username)) { throw new CloudRuntimeException("Empty IPMI user configured, cannot proceed to find user's ID"); }//ww w .ja v a 2 s . c o m final List<String> ipmiToolCommands = IPMITOOL.getIpmiToolCommandArgs(IpmiToolPath.value(), IpmiToolInterface.value(), IpmiToolRetries.value(), options, "user", "list"); final OutOfBandManagementDriverResponse output = IPMITOOL.executeCommands(ipmiToolCommands, timeOut); if (!output.isSuccess()) { throw new CloudRuntimeException( "Failed to find IPMI user to change password, error: " + output.getError()); } final String userId = IPMITOOL.findIpmiUser(output.getResult(), username); if (Strings.isNullOrEmpty(userId)) { throw new CloudRuntimeException("No IPMI user ID found for the username: " + username); } return userId; }
From source file:com.baasbox.controllers.actions.filters.InjectSession.java
@Override public F.Promise<SimpleResult> call(Context ctx) throws Throwable { if (BaasBoxLogger.isTraceEnabled()) BaasBoxLogger.trace("Method Start"); Http.Context.current.set(ctx); ctx.response().setHeader("Access-Control-Allow-Origin", "*"); //injects the user data & credential into the context String token = ctx.request().getHeader(SessionKeys.TOKEN.toString()); if (token != null) { ImmutableMap<SessionKeys, ? extends Object> sessionData = SessionTokenProvider.getSessionTokenProvider() .getSession(token);//www . j a v a 2 s. c om if (sessionData != null) { ctx.args.put("username", sessionData.get(SessionKeys.USERNAME)); ctx.args.put("password", sessionData.get(SessionKeys.PASSWORD)); ctx.args.put("appcode", sessionData.get(SessionKeys.APP_CODE)); ctx.args.put("token", token); } } //executes the request F.Promise<SimpleResult> result = delegate.call(ctx); if (BaasBoxLogger.isTraceEnabled()) BaasBoxLogger.trace("Method End"); return result; }
From source file:org.icgc.dcc.portal.model.Mutation.java
@SuppressWarnings("unchecked") @JsonCreator/*from w ww .ja v a 2s .co m*/ public Mutation(Map<String, Object> fieldMap) { ImmutableMap<String, String> fields = FIELDS_MAPPING.get(Kind.MUTATION); id = getString(fieldMap.get(fields.get("id"))); type = getString(fieldMap.get(fields.get("type"))); chromosome = getString(fieldMap.get(fields.get("chromosome"))); start = getLong(fieldMap.get(fields.get("start"))); end = getLong(fieldMap.get(fields.get("end"))); mutation = getString(fieldMap.get(fields.get("mutation"))); assemblyVersion = getString(fieldMap.get(fields.get("assemblyVersion"))); referenceGenomeAllele = getString(fieldMap.get(fields.get("referenceGenomeAllele"))); testedDonorCount = getLong(fieldMap.get(fields.get("testedDonorCount"))); affectedDonorCountTotal = getLong(fieldMap.get(fields.get("affectedDonorCountTotal"))); affectedDonorCountFiltered = getLong(fieldMap.get(fields.get("affectedDonorCountFiltered"))); affectedProjectCount = getLong(fieldMap.get(fields.get("affectedProjectCount"))); affectedProjectIds = (List<String>) fieldMap.get(fields.get("affectedProjectIds")); platform = (List<String>) fieldMap.get(fields.get("platform")); consequenceType = (List<String>) fieldMap.get(fields.get("consequenceType")); verificationStatus = (List<String>) fieldMap.get(fields.get("verificationStatus")); occurrences = buildOccurrences((List<Map<String, Object>>) fieldMap.get("ssm_occurrence")); transcripts = buildTranscripts((List<Map<String, Object>>) fieldMap.get("transcript")); consequences = buildConsequences((List<Map<String, Object>>) fieldMap.get("consequences")); functionalImpact = (List<String>) fieldMap.get(fields.get("functionalImpact")); }
From source file:cd.go.contrib.elasticagents.dockerswarm.elasticagent.DockerServices.java
@Override public void refreshAll(PluginRequest pluginRequest) throws Exception { if (!refreshed) { DockerClient docker = docker(pluginRequest.getPluginSettings()); List<Service> services = docker.listServices(); for (Service service : services) { ImmutableMap<String, String> labels = service.spec().labels(); if (labels != null && Constants.PLUGIN_ID.equals(labels.get(Constants.CREATED_BY_LABEL_KEY))) { register(DockerService.fromService(service)); }/*from w w w.ja va 2s . c o m*/ } refreshed = true; } }
From source file:com.google.jimfs.DosAttributeProvider.java
@Override public DosFileAttributeView view(FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews) { return new View(lookup, (BasicFileAttributeView) inheritedViews.get("basic")); }