public static boolean isNotBlank(String txt) { return !isBlank(txt); }
public static boolean isNotBlank(String txt) { return !isBlank(txt); }
public String authenticate(String username, String password) throws HttpException { if(StringUtils.isBlank(username) ) { throw new IllegalArgumentException("Username missing"); } if(StringUtils.isBlank(password) ) { throw new IllegalArgumentException("Username missing"); } Map<String, String> request = new HashMap<>(); request.put("username", username); request.put("password", password); Map data = jsonHelper.toJsonMap(httpHelper.httpPost(LOGIN_PATH, request)); return data.get("token_type") + " " + data.get("access_token"); }
public API findAPIByExchangeAsset(@NotNull String groupId, @NotNull String assetId, @NotNull String assetVersion, @Nullable String label) throws HttpException, NotFoundException { if (isBlank(groupId)) { throw new IllegalArgumentException("groupId missing (null or blank)"); } if (isBlank(assetId)) { throw new IllegalArgumentException("assetId missing (null or blank)"); } if (isBlank(assetVersion)) { throw new IllegalArgumentException("assetVersion missing (null or blank)"); } for (APIAsset asset : findAllAPIs()) { if (asset.getGroupId().equalsIgnoreCase(groupId) && asset.getAssetId().equalsIgnoreCase(assetId)) { for (API api : asset.getApis()) { if (api.getAssetVersion().equalsIgnoreCase(assetVersion) && (label == null || label.equalsIgnoreCase(api.getInstanceLabel()))) { return api; } } } } throw new NotFoundException("API based on exchange asset not found: groupId=" + groupId + ", assetId=" + assetId + ", assetVersion=" + assetVersion + ", label=" + label); }
public CHDeploymentRequest(String muleVersionName, String regionName, String workerTypeName, int workerCount, Environment environment, String appName, ApplicationSource file, String filename, Map<String, String> properties, APIProvisioningConfig apiProvisioningConfig) throws HttpException, NotFoundException { super(environment, appName, file, filename, properties, apiProvisioningConfig); this.workerCount = workerCount; if (isBlank(muleVersionName)) { muleVersion = environment.findDefaultCHMuleVersion(); } else { muleVersion = environment.findCHMuleVersion(muleVersionName); } if (isBlank(regionName)) { region = environment.findDefaultCHRegion().getId(); } else { region = regionName; } if (isBlank(workerTypeName)) { workerType = environment.findSmallestWorkerType(); } else { workerType = environment.findWorkerTypeByName(workerTypeName); } }
/** * Request for a user to approve an operation using IDVKey * * @param serviceId serviceId * @param userRef User ref * @param redirectUrl URL to redirect browser once the operation has been handled by the user (or if it expired). * @param cancelUrl URL to redirect browser if the user wants to cancel the operation. * @param approvalRequest Approval request details @return Operation results * @throws IOException If an error occurs while performing the operation * @return operation result */ @SuppressWarnings("ConstantConditions") public OperationResult requestApproval(@NotNull String serviceId, @NotNull String userRef, @NotNull URL redirectUrl, @NotNull URL cancelUrl, @NotNull ApprovalRequest approvalRequest) throws IOException { if (approvalRequest == null) { throw new IllegalArgumentException("approval request missing"); } else if (StringUtils.isBlank(approvalRequest.getTitle())) { throw new IllegalArgumentException("approval title missing"); } else if (StringUtils.isBlank(approvalRequest.getText())) { throw new IllegalArgumentException("approval text missing"); } final String json = postJson(new URLBuilder("api/idvkey/approve").add("serviceId", serviceId) .add("redirectUrl", redirectUrl.toString()).add("cancelUrl", cancelUrl.toString()).add("userRef", userRef).toString(), approvalRequest); return jsonMapper.readValue(json, OperationResult.class); }
if (response == null) { throw new TemplateExecutionException("Template processing cancelled by user"); } else if (!blankAllowed && StringUtils.isBlank(response)) { val = null; } else {