List of usage examples for org.apache.commons.lang3.tuple ImmutablePair getRight
@Override
public R getRight()
From source file:io.dockstore.client.cli.CWLClientTest.java
@Test public void parseCWL() throws Exception { final URL resource = Resources.getResource("cwl.json"); final CWL cwl = new CWL(); final ImmutablePair<String, String> output = cwl.parseCWL(resource.getFile(), true); assertTrue(!output.getLeft().isEmpty() && output.getLeft().contains("cwlVersion")); assertTrue(!output.getRight().isEmpty() && output.getRight().contains("cwltool")); }
From source file:com.github.rwhogg.git_vcr.VelocityReport.java
/** * extract the changes between two reviews * @return A map of (old) files to changes in results *///from w ww . j a v a 2s. co m @SuppressWarnings("rawtypes") private Map<String, Changes> extractChanges() { Map<String, Changes> changeMap = new HashMap<>(); List<ImmutablePair<String, String>> changedFiles = Util.getFilesChanged(patch); // FIXME: for now, we'll just assume no files were added or deleted for (ImmutablePair<String, String> filePair : changedFiles) { String oldFileName = filePair.getLeft(); String newFileName = filePair.getRight(); Changes changesForThisFile = new Changes(); Map<Class, List<String>> resultsForOldFile = oldResults.getResultsFor(oldFileName); Map<Class, List<String>> resultsForNewFile = newResults.getResultsFor(newFileName); Set<Class> toolsUsed = resultsForOldFile.keySet(); assert toolsUsed.equals(resultsForNewFile.keySet()); // for each tool, go through and detect changes for (Class toolUsed : toolsUsed) { List<String> oldResultListFromThisTool = resultsForOldFile.get(toolUsed); List<String> newResultListFromThisTool = resultsForNewFile.get(toolUsed); Set<String> oldResultsFromThisTool = new HashSet<>(oldResultListFromThisTool); Set<String> newResultsFromThisTool = new HashSet<>(newResultListFromThisTool); Set<String> additions = Sets.difference(newResultsFromThisTool, oldResultsFromThisTool); Set<String> subtractions = Sets.difference(oldResultsFromThisTool, newResultsFromThisTool); // construct the change List<String> additionList = Arrays.asList(additions.toArray(new String[additions.size()])); List<String> subtractionList = Arrays.asList(subtractions.toArray(new String[subtractions.size()])); ImmutablePair<List<String>, List<String>> changeListPair = ImmutablePair.of(additionList, subtractionList); changesForThisFile.put(toolUsed, changeListPair); } changeMap.put(oldFileName, changesForThisFile); } return changeMap; }
From source file:io.cloudslang.content.amazon.actions.tags.DescribeTagsAction.java
/** * Describes one or more of the tags for your EC2 resources. * * @param endpoint Optional - Endpoint to which request will be sent. * Default: "https://ec2.amazonaws.com" * @param identity ID of the secret access key associated with your Amazon AWS or * IAM account. * Example: "AKIAIOSFODNN7EXAMPLE" * @param credential Secret access key associated with your Amazon AWS or IAM account. * Example: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" * @param proxyHost Optional - proxy server used to connect to Amazon API. If empty no * proxy will be used. * @param proxyPort Optional - proxy server port. You must either specify values for both * proxyHost and proxyPort inputs or leave them both empty. * @param proxyUsername Optional - proxy server user name. * Default: "" * @param proxyPassword Optional - proxy server password associated with the proxyUsername * input value. * @param version Optional - Version of the web service to made the call against it. * Example: "2016-11-15" * Default: "2016-11-15" * @param headers Optional - string containing the headers to use for the request * separated by new line (CRLF). The header name-value pair will be * separated by ":" * Format: Conforming with HTTP standard for headers (RFC 2616) * Examples: "Accept:text/plain" * Default: "" * @param queryParams Optional - string containing query parameters that will be appended * to the URL. The names and the values must not be URL encoded because * if they are encoded then a double encoded will occur. The separator * between name-value pairs is "&" symbol. The query name will be * separated from query value by "=" * Examples: "parameterName1=parameterValue1¶meterName2=parameterValue2" * Default: "" * @param delimiter Optional - Delimiter that will be used between filter values. * Default: "," * @param filterKey Optional - The tag key. * Default: "" * @param filterResourceId Optional - The resource ID. * Default: "" * @param filterResourceType Optional - The resource type. * Valid values: customer-gateway, dhcp-options, image, instance, * internet-gateway, network-acl, network-interface, reserved-instances, * route-table, security-group, snapshot, spot-instances-request, * subnet, volume, vpc, vpn-connection, vpn-gateway. * Default: "" * @param filterValue Optional - The tag value. * Default: "" * @param maxResults Optional - The maximum number of results to return in a single call. * This value can be between 5 and 1000. To retrieve the remaining * results, make another call with the returned NextToken value. * Default: "" * @param nextToken Optional - The token to retrieve the next page of results. * Default: "" * @return A map with strings as keys and strings as values that contains: outcome of the action (or failure message * and the exception if there is one), returnCode of the operation and the ID of the request *///from w ww . j a va 2 s .com @Action(name = "Describe Tags", outputs = { @Output(RETURN_CODE), @Output(RETURN_RESULT), @Output(EXCEPTION) }, responses = { @Response(text = SUCCESS, field = RETURN_CODE, value = ReturnCodes.SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = FAILURE, field = RETURN_CODE, value = ReturnCodes.FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true) }) public Map<String, String> execute(@Param(value = ENDPOINT) String endpoint, @Param(value = IDENTITY, required = true) String identity, @Param(value = CREDENTIAL, required = true, encrypted = true) String credential, @Param(value = PROXY_HOST) String proxyHost, @Param(value = PROXY_PORT) String proxyPort, @Param(value = PROXY_USERNAME) String proxyUsername, @Param(value = PROXY_PASSWORD, encrypted = true) String proxyPassword, @Param(value = HEADERS) String headers, @Param(value = QUERY_PARAMS) String queryParams, @Param(value = VERSION) String version, @Param(value = DELIMITER) String delimiter, @Param(value = FILTER_KEY) String filterKey, @Param(value = FILTER_RESOURCE_ID) String filterResourceId, @Param(value = FILTER_RESOURCE_TYPE) String filterResourceType, @Param(value = FILTER_VALUE) String filterValue, @Param(value = MAX_RESULTS) String maxResults, @Param(value = NEXT_TOKEN) String nextToken) { try { version = getDefaultStringInput(version, TAGS_DEFAULT_API_VERSION); final CommonInputs commonInputs = new CommonInputs.Builder().withEndpoint(endpoint, EC2_API, EMPTY) .withIdentity(identity).withCredential(credential).withProxyHost(proxyHost) .withProxyPort(proxyPort).withProxyUsername(proxyUsername).withProxyPassword(proxyPassword) .withHeaders(headers).withQueryParams(queryParams).withVersion(version).withDelimiter(delimiter) .withAction(DESCRIBE_TAGS).withApiService(EC2_API).withRequestUri(EMPTY) .withRequestPayload(EMPTY).withHttpClientMethod(HTTP_CLIENT_METHOD_GET).build(); final List<ImmutablePair<String, String>> filterPairs = Arrays.asList(of(KEY, filterKey), of(RESOURCE_ID, filterResourceId), of(RESOURCE_TYPE, filterResourceType), of(VALUE, filterValue)); final FilterInputs.Builder filterInputsBuilder = new FilterInputs.Builder() .withDelimiter(commonInputs.getDelimiter()).withMaxResults(maxResults).withNextToken(nextToken); for (ImmutablePair<String, String> filterPair : filterPairs) { if (isNotEmpty(filterPair.getRight())) { filterInputsBuilder.withNewFilter(filterPair.getLeft(), filterPair.getRight()); } } final FilterInputs filterInputs = filterInputsBuilder.build(); return new QueryApiExecutor().execute(commonInputs, filterInputs); } catch (Exception exception) { return ExceptionProcessor.getExceptionResult(exception); } }
From source file:CWLClientTest.java
/** * This test demonstrates how to parse a CWL document using CWL tool. * @throws Exception/*from www .j a va 2s.com*/ */ @Test public void parseCWL() throws Exception { final URL resource = Resources.getResource("cwl.json"); final CWL cwl = new CWL(); final ImmutablePair<String, String> output = cwl.parseCWL(resource.getFile()); assertTrue(!output.getLeft().isEmpty() && output.getLeft().contains("cwlVersion")); assertTrue(!output.getRight().isEmpty() && output.getRight().contains("cwltool")); }
From source file:eu.bittrade.libs.steemj.configuration.PrivateKeyStorage.java
/** * Internal method to convert a WIF private key into an ECKey object. * // w ww. jav a 2 s . c om * @param wifPrivateKey * The key pair to convert. * @return The converted key pair. */ private ImmutablePair<PrivateKeyType, ECKey> convertWifToECKeyPair( ImmutablePair<PrivateKeyType, String> wifPrivateKey) { return new ImmutablePair<>(wifPrivateKey.getLeft(), DumpedPrivateKey.fromBase58(null, wifPrivateKey.getRight(), new Sha256ChecksumProvider()).getKey()); }
From source file:com.capitati.omtc.core.negotiation.Negotiator.java
private boolean isClientAPISupported(ISemanticVersion version) { final ImmutablePair<Integer, SemanticVersionComponent> versionComp = SemanticVersionComparator .compare(apiVersion, version); boolean isApiSupported = false; switch (versionComp.getRight()) { case PRE_RELEASE_AND_BUILD_VERSION: case PATCH_VERSION: case MINOR_VERSION: isApiSupported = true;// w ww . ja va 2 s . co m break; case MAJOR_VERSION: case INVALID: isApiSupported = (versionComp.getLeft() == 0) ? true : false; break; } return isApiSupported; }
From source file:eu.bittrade.libs.steemj.configuration.PrivateKeyStorage.java
/** * Get a private key of the given private key type for the given account * name./*w w w .ja va 2s . com*/ * * @param privateKeyType * The type of the key to request. * @param accountName * The account to request the key for. * @throws InvalidParameterException * If no key could be find for the given account name. * @return The requested private key. */ public ECKey getKeyForAccount(PrivateKeyType privateKeyType, AccountName accountName) { List<ImmutablePair<PrivateKeyType, ECKey>> privateKeysForAccount = this.getPrivateKeysPerAccounts() .get(accountName); if (privateKeysForAccount == null) { throw new InvalidParameterException(privateKeyType.name() + " for the account '" + accountName + "' has not been added to the PrivateKeyStore."); } for (ImmutablePair<PrivateKeyType, ECKey> privateKey : privateKeysForAccount) { if (privateKey != null && privateKey.getLeft().equals(privateKeyType)) { return privateKey.getRight(); } } throw new InvalidParameterException(privateKeyType.name() + " for the account '" + accountName + "' has not been added to the PrivateKeyStore."); }
From source file:io.github.collaboratory.LauncherCWL.java
/** * * @param workingDir where to save stderr and stdout * @param execute a pair holding the unformatted stderr and stderr * @param stdout formatted stdout for outpuit * @param stderr formatted stderr for output * @param cwltool help text explaining name of integration *///from ww w. j a va 2 s . c om public static void outputIntegrationOutput(String workingDir, ImmutablePair<String, String> execute, String stdout, String stderr, String cwltool) { System.out.println(cwltool + " stdout:\n" + stdout); System.out.println(cwltool + " stderr:\n" + stderr); try { final Path path = Paths.get(workingDir + File.separator + cwltool + ".stdout.txt"); FileUtils.writeStringToFile(path.toFile(), execute.getLeft(), StandardCharsets.UTF_8, false); System.out.println("Saving copy of " + cwltool + " stdout to: " + path.toAbsolutePath().toString()); final Path txt2 = Paths.get(workingDir + File.separator + cwltool + ".stderr.txt"); FileUtils.writeStringToFile(txt2.toFile(), execute.getRight(), StandardCharsets.UTF_8, false); System.out.println("Saving copy of " + cwltool + " stderr to: " + txt2.toAbsolutePath().toString()); } catch (IOException e) { throw new RuntimeException("unable to save " + cwltool + " output", e); } }
From source file:io.cloudslang.content.amazon.actions.volumes.DescribeVolumesAction.java
/** * Describes one or more volumes./*ww w . j av a 2s .co m*/ * Note: If you are describing a long list of volumes, you can paginate the output to make the list more manageable. * The maxResults parameter sets the maximum number of results returned in a single page. * If the list of results exceeds your maxResults value, then that number of results is returned along with a * nextToken value that can be passed to a subsequent DescribeVolumes operation to retrieve the remaining results. * * @param endpoint Endpoint to which request will be sent. * Default: "https://ec2.amazonaws.com" * @param identity ID of the secret access key associated with your Amazon AWS or IAM account. * Example: "AKIAIOSFODNN7EXAMPLE" * @param credential Secret access key associated with your Amazon AWS or IAM account. * Example: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" * @param proxyHost Optional - proxy server used to connect to Amazon API. If empty no proxy * will be used. * Default: "" * @param proxyPort Optional - proxy server port. You must either specify values for both * <proxyHost> and <proxyPort> inputs or leave them both empty. * Default: "" * @param proxyUsername Optional - proxy server user name. * Default: "" * @param proxyPassword Optional - proxy server password associated with the <proxyUsername> * input value. * Default: "" * @param headers Optional - string containing the headers to use for the request separated * by new line (CRLF). The header name-value pair will be separated by ":". * Format: Conforming with HTTP standard for headers (RFC 2616) * Examples: "Accept:text/plain" * Default: "" * @param queryParams Optional - string containing query parameters that will be appended to * the URL. The names and the values must not be URL encoded because if * they are encoded then a double encoded will occur. The separator between * name-value pairs is "&" symbol. The query name will be separated from * query value by "=". * Examples: "parameterName1=parameterValue1¶meterName2=parameterValue2" * Default: "" * @param version Version of the web service to made the call against it. * Example: "2016-11-15" * Default: "2016-11-15" * @param delimiter Optional - Delimiter that will be used. * Default: "," * @param filterAttachmentAttachTime Optional - The time stamp when the attachment initiated. * Example: "2016-12-02T10:28:20.000Z" * Default: "" * @param filterAttachmentDeleteOnTermination Optional - Whether the volume is deleted on instance termination. * Valid values: true | false * Default: "" * @param filterAttachmentDevice Optional - The device name that is exposed to the instance. * Example: "/dev/sda1" * Default: "" * @param filterAttachmentInstanceId Optional - The ID of the instance the volume is attached to. * Example: "i-468cisID" * Default: "" * @param filterAttachmentStatus Optional - The attachment state. * Valid values: attaching | attached | detaching | detached * Default: "" * @param filterAvailabilityZone Optional - The Availability Zone in which the volume was created. * Example: "us-east-xx" * Default: "" * @param filterCreateTime Optional - The time stamp when the volume was created. * Default: "" * @param filterEncrypted Optional - The encryption status of the volume. * Valid values: true | false * Default: "" * @param filterSize Optional - The size of the volume, in GiB. * Example: "50" * Default: "" * @param filterSnapshotId Optional - The snapshot from which the volume was created. * Example: "snap-1234567890abcdef0" * Default: "" * @param filterStatus Optional - The status of the volume. * Valid values: creating | available | in-use | deleting | deleted | error * Default: "" * @param filterTag Optional - The key/value combination of a tag assigned to the resource. * Example: "tagKey=tagValue" * Default: "" * @param filterTagKey Optional - The key of a tag assigned to the resource. This filter is * independent of the filterTagValue filter. For example, if you use both * the filter filterTagKey="Purpose" and the filter filterTagValue="X", * you get any resources assigned both the tag key Purpose (regardless of what the tag's value is), * and the tag value X (regardless of what the tag's key is). * Note: If you want to list only resources where Purpose is X, * see the filterTag filter. * Example: "tagKey" * Default: "" * @param filterTagValue Optional - The value of a tag assigned to the resource. * This filter is independent of the filterTagKey filter. * Example: "tagValue" * @param filterVolumeId Optional - The volume ID. * Example: "vol-049df61146c4d7901" * Default: "" * @param filterVolumeType Optional - The Amazon EBS volume type. * Valid values: gp2 | io1 | st1 | sc1 | standard * Default: "" * @param maxResults Optional - The maximum number of results to return in a single call. To retrieve the * remaining results, make another call with the returned NextToken value. This value can * be between 5 and 1000. You cannot specify this parameter and the tag filters in the same call. * Default: "" * @param nextToken Optional - The token to use to retrieve the next page of results. This value is null when * there are no more results to return. * Default: "" * @return A map with strings as keys and strings as values that contains: outcome of the action, returnCode of the * operation, or failure message and the exception if there is one */ @Action(name = "Describe Volumes", outputs = { @Output(RETURN_CODE), @Output(RETURN_RESULT), @Output(EXCEPTION) }, responses = { @Response(text = SUCCESS, field = RETURN_CODE, value = ReturnCodes.SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = FAILURE, field = RETURN_CODE, value = ReturnCodes.FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR) }) public Map<String, String> execute(@Param(value = ENDPOINT) String endpoint, @Param(value = IDENTITY, required = true) String identity, @Param(value = CREDENTIAL, required = true, encrypted = true) String credential, @Param(value = PROXY_HOST) String proxyHost, @Param(value = PROXY_PORT) String proxyPort, @Param(value = PROXY_USERNAME) String proxyUsername, @Param(value = PROXY_PASSWORD, encrypted = true) String proxyPassword, @Param(value = HEADERS) String headers, @Param(value = QUERY_PARAMS) String queryParams, @Param(value = VERSION) String version, @Param(value = DELIMITER) String delimiter, @Param(value = VOLUME_IDS_STRING) String volumeIdsString, @Param(value = FILTER_ATTACHMENT_ATTACH_TIME) String filterAttachmentAttachTime, @Param(value = FILTER_ATTACHMENT_DELETE_ON_TERMINATION) String filterAttachmentDeleteOnTermination, @Param(value = FILTER_ATTACHMENT_DEVICE) String filterAttachmentDevice, @Param(value = FILTER_ATTACHMENT_INSTANCE_ID) String filterAttachmentInstanceId, @Param(value = FILTER_ATTACHMENT_STATUS) String filterAttachmentStatus, @Param(value = FILTER_AVAILABILITY_ZONE) String filterAvailabilityZone, @Param(value = FILTER_CREATE_TIME) String filterCreateTime, @Param(value = FILTER_ENCRYPTED) String filterEncrypted, @Param(value = FILTER_SIZE) String filterSize, @Param(value = FILTER_SNAPSHOT_ID) String filterSnapshotId, @Param(value = FILTER_STATUS) String filterStatus, @Param(value = FILTER_TAG) String filterTag, @Param(value = FILTER_TAG_KEY) String filterTagKey, @Param(value = FILTER_TAG_VALUE) String filterTagValue, @Param(value = FILTER_VOLUME_ID) String filterVolumeId, @Param(value = FILTER_VOLUME_TYPE) String filterVolumeType, @Param(value = MAX_RESULTS) String maxResults, @Param(value = NEXT_TOKEN) String nextToken) { try { version = getDefaultStringInput(version, VOLUMES_DEFAULT_API_VERSION); delimiter = getDefaultStringInput(delimiter, COMMA_DELIMITER); final CommonInputs commonInputs = new CommonInputs.Builder().withEndpoint(endpoint, EC2_API, EMPTY) .withIdentity(identity).withCredential(credential).withProxyHost(proxyHost) .withProxyPort(proxyPort).withProxyUsername(proxyUsername).withProxyPassword(proxyPassword) .withHeaders(headers).withQueryParams(queryParams).withVersion(version).withDelimiter(delimiter) .withAction(DESCRIBE_VOLUMES).withApiService(EC2_API).withRequestUri(EMPTY) .withRequestPayload(EMPTY).withHttpClientMethod(HTTP_CLIENT_METHOD_GET).build(); final VolumeInputs volumeInputs = new VolumeInputs.Builder().withVolumeIdsString(volumeIdsString) .withMaxResults(maxResults).withNextToken(nextToken).build(); final List<ImmutablePair<String, String>> filterPairs = Arrays.asList( of(VolumeFilter.ATTACHMENT_ATTACH_TIME, filterAttachmentAttachTime), of(VolumeFilter.ATTACHMENT_DELETE_ON_TERMINATION, filterAttachmentDeleteOnTermination), of(VolumeFilter.ATTACHMENT_DEVICE, filterAttachmentDevice), of(VolumeFilter.ATTACHMENT_INSTANCE_ID, filterAttachmentInstanceId), of(VolumeFilter.ATTACHMENT_STATUS, filterAttachmentStatus), of(VolumeFilter.AVAILABILITY_ZONE, filterAvailabilityZone), of(VolumeFilter.CREATE_TIME, filterCreateTime), of(VolumeFilter.ENCRYPTED, filterEncrypted), of(VolumeFilter.SIZE, filterSize), of(VolumeFilter.SNAPSHOT_ID, filterSnapshotId), of(VolumeFilter.STATUS, filterStatus), of(VolumeFilter.TAG_KEY, filterTagKey), of(VolumeFilter.TAG_VALUE, filterTagValue), of(VolumeFilter.VOLUME_ID, filterVolumeId), of(VolumeFilter.VOLUME_TYPE, filterVolumeType)); final FilterInputs.Builder filterInputsBuilder = new FilterInputs.Builder().withDelimiter(delimiter); for (ImmutablePair<String, String> filterPair : filterPairs) { if (isNotEmpty(filterPair.getRight())) { filterInputsBuilder.withNewFilter(filterPair.getLeft(), filterPair.getRight()); } } if (isNotEmpty(filterTag)) { processTagFilter(filterTag, delimiter, filterInputsBuilder); } final FilterInputs filterInputs = filterInputsBuilder.build(); return new QueryApiExecutor().execute(commonInputs, volumeInputs, filterInputs); } catch (Exception e) { return ExceptionProcessor.getExceptionResult(e); } }
From source file:io.lavagna.service.importexport.FileUpload.java
@Override void process(EventFull e, Event event, Date time, User user, ImportContext context, Path tempFile) { try {/* www . j av a2 s . c o m*/ Path p = Objects.requireNonNull(Read.readFile("files/" + e.getContent(), tempFile)); CardDataUploadContentInfo fileData = Read.readObject("files/" + e.getContent() + ".json", tempFile, new TypeToken<CardDataUploadContentInfo>() { }); ImmutablePair<Boolean, CardData> res = cardDataService.createFile(event.getValueString(), e.getContent(), fileData.getSize(), cardId(e), Files.newInputStream(p), fileData.getContentType(), user, time); if (res.getLeft()) { context.getFileId().put(event.getDataId(), res.getRight().getId()); } Files.delete(p); } catch (IOException ioe) { throw new IllegalStateException("error while handling event FILE_UPLOAD for event: " + e, ioe); } }