use of org.apache.commons.lang3.StringUtils.isEmpty in project azure-gradle-plugins by lenala.
the class AnnotationHandlerImpl method patchStorageBinding.
private void patchStorageBinding(final Method method, final List<BaseBinding> bindings) {
final Optional<Annotation> storageAccount = Arrays.stream(method.getAnnotations()).filter(a -> a instanceof StorageAccount).findFirst();
if (storageAccount.isPresent()) {
logger.quiet("StorageAccount annotation found.");
final String connectionString = ((StorageAccount) storageAccount.get()).value();
bindings.stream().forEach(b -> {
if (b instanceof StorageBaseBinding) {
final StorageBaseBinding sb = (StorageBaseBinding) b;
// Override storage bindings with empty connection
if (StringUtils.isEmpty(sb.getConnection())) {
sb.setConnection(connectionString);
}
}
});
} else {
logger.quiet("No StorageAccount annotation found.");
}
}
use of org.apache.commons.lang3.StringUtils.isEmpty in project mule by mulesoft.
the class DefaultArtifactClassLoaderFilter method exportsClass.
@Override
public boolean exportsClass(String className) {
checkArgument(!StringUtils.isEmpty(className), "Class name cannot be empty");
final String packageName = getPackageName(className);
return exportedClassPackages.contains(packageName);
}
use of org.apache.commons.lang3.StringUtils.isEmpty in project cloudbreak by hortonworks.
the class AmbariStackDetailsJsonToStackRepoDetailsConverter method convert.
@Override
public StackRepoDetails convert(AmbariStackDetailsJson source) {
StackRepoDetails repo = new StackRepoDetails();
Map<String, String> stack = new HashMap<>();
Map<String, String> util = new HashMap<>();
boolean baseRepoRequiredFieldsExists = Stream.of(source.getStackRepoId(), source.getStackBaseURL(), source.getUtilsRepoId(), source.getUtilsBaseURL()).noneMatch(StringUtils::isEmpty);
if (!isVdfRequiredFieldsExists(source) && !baseRepoRequiredFieldsExists) {
String msg = "The 'repositoryVersion', 'versionDefinitionFileUrl' or " + "'stackBaseURL', 'stackRepoId', 'utilsBaseUrl', 'utilsRepoId' fields must be specified!";
throw new BadRequestException(msg);
}
stack.put("repoid", source.getStackRepoId());
util.put("repoid", source.getUtilsRepoId());
if (baseRepoRequiredFieldsExists) {
String stackBaseURL = source.getStackBaseURL();
String utilsBaseURL = source.getUtilsBaseURL();
if (source.getOs() == null) {
stack.put(REDHAT_6, stackBaseURL);
stack.put(REDHAT_7, stackBaseURL);
stack.put(DEBIAN_9, stackBaseURL);
stack.put(UBUNTU_16, stackBaseURL);
util.put(REDHAT_6, utilsBaseURL);
util.put(REDHAT_7, utilsBaseURL);
util.put(DEBIAN_9, utilsBaseURL);
util.put(UBUNTU_16, utilsBaseURL);
} else {
stack.put(source.getOs(), stackBaseURL);
util.put(source.getOs(), utilsBaseURL);
}
}
if (!StringUtils.isEmpty(source.getRepositoryVersion())) {
stack.put(StackRepoDetails.REPOSITORY_VERSION, source.getRepositoryVersion());
stack.put("repoid", source.getStack());
}
if (!StringUtils.isEmpty(source.getVersionDefinitionFileUrl())) {
stack.put(StackRepoDetails.CUSTOM_VDF_REPO_KEY, source.getVersionDefinitionFileUrl());
}
if (!StringUtils.isEmpty(source.getMpackUrl())) {
stack.put(StackRepoDetails.MPACK_TAG, source.getMpackUrl());
}
repo.setStack(stack);
repo.setUtil(util);
repo.setEnableGplRepo(source.isEnableGplRepo());
repo.setVerify(source.getVerify());
repo.setHdpVersion(source.getVersion());
return repo;
}
use of org.apache.commons.lang3.StringUtils.isEmpty in project azure-tools-for-java by Microsoft.
the class CreateDeploymentForm method doOKAction.
@Override
protected void doOKAction() {
deploymentName = deploymentNameTextField.getText();
final AzureString title = AzureOperationBundle.title("arm|deployment.deploy", deploymentName);
AzureTaskManager.getInstance().runInBackground(new AzureTask(project, title, false, () -> {
EventUtil.executeWithLog(TelemetryConstants.ARM, TelemetryConstants.CREATE_DEPLOYMENT, (operation -> {
Subscription subs = (Subscription) subscriptionCb.getSelectedItem();
com.microsoft.azure.management.Azure azure = AuthMethodManager.getInstance().getAzureClient(subs.getId());
WithTemplate template;
if (createNewRgButton.isSelected()) {
rgName = rgNameTextFiled.getText();
final Region region = (Region) regionCb.getSelectedItem();
template = azure.deployments().define(deploymentName).withNewResourceGroup(rgNameTextFiled.getText(), com.microsoft.azure.management.resources.fluentcore.arm.Region.fromName(region.getName()));
} else {
ResourceGroup rg = (ResourceGroup) rgNameCb.getSelectedItem();
List<ResourceEx<Deployment>> deployments = AzureMvpModel.getInstance().getDeploymentByRgName(subs.getId(), rg.getName());
boolean isExist = deployments.parallelStream().anyMatch(deployment -> deployment.getResource().name().equals(deploymentName));
if (isExist) {
throw new RuntimeException(DUPLICATED_DEPLOYMENT_NAME);
}
rgName = rg.getName();
template = azure.deployments().define(deploymentName).withExistingResourceGroup(rg.getName());
}
String fileText = templateTextField.getText();
String content = IOUtils.toString(new FileReader(fileText));
String parametersPath = parametersTextField.getText();
String parameters = StringUtils.isEmpty(parametersPath) ? "{}" : IOUtils.toString(new FileReader(parametersPath));
parameters = DeploymentUtils.parseParameters(parameters);
template.withTemplate(content).withParameters(parameters).withMode(DeploymentMode.INCREMENTAL).create();
UIUtils.showNotification(statusBar, NOTIFY_CREATE_DEPLOYMENT_SUCCESS, MessageType.INFO);
updateUI();
}), (ex) -> {
UIUtils.showNotification(statusBar, NOTIFY_CREATE_DEPLOYMENT_FAIL + ", " + ex.getMessage(), MessageType.ERROR);
updateUI();
});
}));
close(DialogWrapper.OK_EXIT_CODE, true);
}
use of org.apache.commons.lang3.StringUtils.isEmpty in project storm by apache.
the class LogviewerLogSearchHandler method deepSearchLogsForTopology.
/**
* Advanced search across worker log files in a topology.
*
* @param topologyId topology ID
* @param user username
* @param search search string
* @param numMatchesStr the count of maximum matches. Note that this number is with respect to each port, not to each log or each search
* request
* @param portStr worker port, null or '*' if the request wants to search from all worker logs
* @param fileOffsetStr index (offset) of the log files
* @param offsetStr start offset for log file
* @param searchArchived true if the request wants to search also archived files, false if not
* @param callback callbackParameterName for JSONP
* @param origin origin
* @return Response containing JSON content representing search result
*/
public Response deepSearchLogsForTopology(String topologyId, String user, String search, String numMatchesStr, String portStr, String fileOffsetStr, String offsetStr, Boolean searchArchived, String callback, String origin) throws IOException {
int numMatchedFiles = 0;
int numScannedFiles = 0;
Path rootDir = logRoot;
Path absTopoDir = rootDir.resolve(topologyId).toAbsolutePath().normalize();
Object returnValue;
if (StringUtils.isEmpty(search) || !absTopoDir.toFile().exists() || !absTopoDir.startsWith(rootDir)) {
returnValue = new ArrayList<>();
} else {
int fileOffset = ObjectReader.getInt(fileOffsetStr, 0);
int offset = ObjectReader.getInt(offsetStr, 0);
int numMatches = ObjectReader.getInt(numMatchesStr, 1);
if (StringUtils.isEmpty(portStr) || portStr.equals("*")) {
try (Stream<Path> topoDir = Files.list(absTopoDir)) {
// check for all ports
Stream<List<Path>> portsOfLogs = topoDir.map(portDir -> logsForPort(user, portDir)).filter(logs -> logs != null && !logs.isEmpty());
if (BooleanUtils.isNotTrue(searchArchived)) {
portsOfLogs = portsOfLogs.map(fl -> Collections.singletonList(first(fl)));
}
final List<Matched> matchedList = portsOfLogs.map(logs -> findNMatches(logs, numMatches, 0, 0, search)).collect(toList());
numMatchedFiles = matchedList.stream().mapToInt(match -> match.getMatches().size()).sum();
numScannedFiles = matchedList.stream().mapToInt(match -> match.openedFiles).sum();
returnValue = matchedList;
}
} else {
int port = Integer.parseInt(portStr);
// check just the one port
@SuppressWarnings("unchecked") List<Integer> slotsPorts = SupervisorUtils.getSlotsPorts(stormConf);
boolean containsPort = slotsPorts.stream().anyMatch(slotPort -> slotPort != null && (slotPort == port));
if (!containsPort) {
returnValue = new ArrayList<>();
} else {
Path absPortDir = absTopoDir.resolve(Integer.toString(port)).toAbsolutePath().normalize();
if (!absPortDir.toFile().exists() || !absPortDir.startsWith(absTopoDir)) {
returnValue = new ArrayList<>();
} else {
List<Path> filteredLogs = logsForPort(user, absPortDir);
if (BooleanUtils.isNotTrue(searchArchived)) {
filteredLogs = Collections.singletonList(first(filteredLogs));
fileOffset = 0;
}
returnValue = findNMatches(filteredLogs, numMatches, fileOffset, offset, search);
numMatchedFiles = ((Matched) returnValue).getMatches().size();
numScannedFiles = ((Matched) returnValue).openedFiles;
}
}
}
}
if (numMatchedFiles == 0) {
numDeepSearchNoResult.mark();
}
numFileScanned.update(numScannedFiles);
return LogviewerResponseBuilder.buildSuccessJsonResponse(returnValue, callback, origin);
}
Aggregations