本文整理汇总了Java中io.fabric8.utils.Strings类的典型用法代码示例。如果您正苦于以下问题:Java Strings类的具体用法?Java Strings怎么用?Java Strings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Strings类属于io.fabric8.utils包,在下文中一共展示了Strings类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: validate
import io.fabric8.utils.Strings; //导入依赖的package包/类
@Override
public void validate(UIValidationContext context) {
// lets ignore the mission validation as its not suitable for fabric8
// super.validate(context);
if (github == null || !github.isDetailsValid()) {
// invoked too early before the github account is setup - lets return silently
return;
}
String orgName = getOrganisationName(gitOrganisation.getValue());
String repoName = getGithubRepositoryNameValue();
if (Strings.isNotBlank(orgName)) {
if (Strings.isNotBlank(repoName)) {
github.validateRepositoryName(getNamed(), context, orgName, repoName);
}
}
}
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:19,代码来源:Fabric8ProjectInfoStep.java
示例2: GitRepositoryDTO
import io.fabric8.utils.Strings; //导入依赖的package包/类
public GitRepositoryDTO(String key, GHRepository repository) {
this.id = key;
this.name = repository.getName();
if (Strings.isNullOrBlank(name)) {
name = repository.getFullName();
}
if (Strings.isNullOrBlank(name)) {
name = key;
}
description = repository.getDescription();
if (Strings.isNullOrBlank(description) || key.equals(description)) {
try {
description = createdAtText(repository.getCreatedAt());
} catch (IOException e) {
// ignore
}
}
if (Strings.isNullOrBlank(description)) {
description = repository.getHomepage();
}
}
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:22,代码来源:GitRepositoryDTO.java
示例3: initializeUI
import io.fabric8.utils.Strings; //导入依赖的package包/类
public void initializeUI(final UIBuilder builder) throws Exception {
super.initializeUI(builder);
this.github = gitHubFacadeFactory.createGitHubFacade(builder.getUIContext());
// TODO cache this per user every say 30 seconds!
Collection<GitOrganisationDTO> organisations = new ArrayList<>();
if (github != null && github.isDetailsValid()) {
String orgKey = github.getDetails().getUserCacheKey();
organisations = organisationsCache.computeIfAbsent(orgKey, k -> github.loadGitHubOrganisations());
}
gitOrganisation.setValueChoices(organisations);
gitOrganisation.setItemLabelConverter(GitOrganisationDTO::getId);
String userName = github.getDetails().getUsername();
if (Strings.isNotBlank(userName)) {
for (GitOrganisationDTO organisation : organisations) {
if (userName.equals(organisation.getName())) {
gitOrganisation.setDefaultValue(organisation);
break;
}
}
}
if (organisations.size() > 1) {
builder.add(gitOrganisation);
}
}
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:27,代码来源:GitHubImportPickOrganisationStep.java
示例4: getEmail
import io.fabric8.utils.Strings; //导入依赖的package包/类
public String getEmail() {
String email = details.getEmail();
if (Strings.isNullOrBlank(email)) {
GHMyself gitMyself = getMyself();
if (gitMyself != null) {
try {
email = gitMyself.getEmail();
if (Strings.isNullOrBlank(email)) {
LOG.warn("No email found on the user settings or GitHub myself, default to invalid address");
// github user might have chosen to keep email address private
// populate it with invalid address as null is invalid for org.eclipse.jgit.lib.PersonIdent
email = "[email protected]";
}
} catch (IOException e) {
LOG.warn("Could not get github.getMyself().getEmail(): " + e, e);
}
}
}
return email;
}
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:22,代码来源:GitHubFacade.java
示例5: createRepository
import io.fabric8.utils.Strings; //导入依赖的package包/类
public GHRepository createRepository(String orgName, String repoName, String description) throws IOException {
GHCreateRepositoryBuilder builder;
if (Strings.isNullOrBlank(orgName) || orgName.equals(details.getUsername())) {
builder = github.createRepository(repoName);
} else {
builder = github.getOrganization(orgName).createRepository(repoName);
}
// TODO link to the space URL?
builder.private_(false)
.homepage("")
.issues(false)
.downloads(false)
.wiki(false);
if (Strings.isNotBlank(description)) {
builder.description(description);
}
return builder.create();
}
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:20,代码来源:GitHubFacade.java
示例6: getUserName
import io.fabric8.utils.Strings; //导入依赖的package包/类
/**
* Returns the current users kubernetes/openshift user name
*/
public String getUserName() {
OpenShiftClient oc = getOpenShiftClientOrNull();
if (oc != null) {
User user = oc.users().withName("~").get();
if (user == null) {
LOG.warn("Failed to find current logged in user!");
} else {
String answer = KubernetesHelper.getName(user);
if (Strings.isNullOrBlank(answer)) {
LOG.warn("No name for User " + user);
} else {
return answer;
}
}
}
// TODO needs to use the current token to find the current user name
return Configs.currentUserName();
}
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:23,代码来源:KubernetesClientHelper.java
示例7: ensureSpaceLabelAddedToPom
import io.fabric8.utils.Strings; //导入依赖的package包/类
private static boolean ensureSpaceLabelAddedToPom(Document document, String spaceId) {
if (document != null && Strings.isNotBlank(spaceId)) {
NodeList plugins = document.getElementsByTagName("plugin");
if (plugins != null) {
for (int i = 0, size = plugins.getLength(); i < size; i++) {
Node item = plugins.item(i);
if (item instanceof Element) {
Element element = (Element) item;
if ("fabric8-maven-plugin".equals(DomHelper.firstChildTextContent(element, "artifactId"))) {
String indent = "\n ";
Element configuration = getOrCreateChild(element, "configuration", indent);
Element resources = getOrCreateChild(configuration, "resources", indent + " ");
Element labels = getOrCreateChild(resources, "labels", indent + " ");
Element all = getOrCreateChild(labels, "all", indent + " ");
Element space = getOrCreateChild(all, "space", indent + " ");
if (!spaceId.equals(space.getTextContent())) {
space.setTextContent(spaceId);
return true;
}
}
}
}
}
}
return false;
}
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:27,代码来源:ChoosePipelineStep.java
示例8: testSingleUpdate
import io.fabric8.utils.Strings; //导入依赖的package包/类
@Test
public void testSingleUpdate() throws Exception {
String dependency = "cheese";
String version = "1.2.3";
PushVersionChanges command = new PushVersionChanges(NPM, dependency, version);
parentContext.updateVersion(NPM, dependency, version);
assertContextCommandComment(command,
COMMAND_COMMENT_INDENT + Strings.join(" ", PUSH_VERSION, "--kind", NPM, dependency, version));
String comment = command.createPullRequestComment();
CompositeCommand parsedCommands = parseCommandComment(comment, 1);
PushVersionChanges parsedUpdateVersion = CommandAssertions.assertChildIsPushVersionChanges(parsedCommands, 0);
CommandAssertions.assertPushVersionContext(parsedUpdateVersion, NPM, dependency, version);
}
开发者ID:fabric8-updatebot,项目名称:updatebot,代码行数:17,代码来源:PullRequestCommentReadWriteTest.java
示例9: testTwoUpdates
import io.fabric8.utils.Strings; //导入依赖的package包/类
@Test
public void testTwoUpdates() throws Exception {
String dependency1 = "beer";
String version1 = "2.3.4";
String dependency2 = "wine";
String version2 = "4.5.6";
PushVersionChanges command = new PushVersionChanges(NPM, dependency1, version1, dependency2, version2);
assertContextCommandComment(command,
COMMAND_COMMENT_INDENT + Strings.join(" ", PUSH_VERSION, "--kind", NPM, dependency1, version1, dependency2, version2));
String comment = command.createPullRequestComment();
CompositeCommand parsedCommands = parseCommandComment(comment, 1);
PushVersionChanges parsedUpdateVersion1 = CommandAssertions.assertChildIsPushVersionChanges(parsedCommands, 0);
CommandAssertions.assertPushVersionContext(parsedUpdateVersion1, NPM, dependency1, version1, dependency2, version2);
}
开发者ID:fabric8-updatebot,项目名称:updatebot,代码行数:19,代码来源:PullRequestCommentReadWriteTest.java
示例10: assertPluginVersionChanged
import io.fabric8.utils.Strings; //导入依赖的package包/类
protected static void assertPluginVersionChanged(File file, Document doc, DependencyVersionChange change) {
boolean found = false;
List<Element> elements = findElementsWithName(doc.getRootElement(), "plugin");
for (Element element : elements) {
String groupId = firstChildTextContent(element, "groupId");
String artifactId = firstChildTextContent(element, "artifactId");
String version = firstChildTextContent(element, "version");
if (Strings.notEmpty(groupId) && Strings.notEmpty(artifactId) && Strings.notEmpty(version)) {
if (change.matches(groupId, artifactId)) {
found = true;
if (!version.startsWith("$")) {
LOG.info("File " + file + " has plugin " + change.getDependency() + " version: " + version);
assertThat(version).describedAs("File " + file + " plugin version for " + change.getDependency()).isEqualTo(change.getVersion());
}
}
}
}
assertThat(found).describedAs("File " + file + " does not have plugin " +
change.getDependency() + " version: " + change.getVersion()).isTrue();
}
开发者ID:fabric8-updatebot,项目名称:updatebot,代码行数:21,代码来源:PomHelperTest.java
示例11: assertDependencyVersionChanged
import io.fabric8.utils.Strings; //导入依赖的package包/类
protected static void assertDependencyVersionChanged(File file, Document doc, DependencyVersionChange change) {
boolean found = false;
List<Element> elements = findElementsWithName(doc.getRootElement(), "dependency");
for (Element element : elements) {
String groupId = firstChildTextContent(element, "groupId");
String artifactId = firstChildTextContent(element, "artifactId");
String version = firstChildTextContent(element, "version");
if (Strings.notEmpty(groupId) && Strings.notEmpty(artifactId) && Strings.notEmpty(version)) {
if (change.matches(groupId, artifactId)) {
found = true;
if (!version.startsWith("$")) {
LOG.info("File " + file + " has dependency " + change.getDependency() + " version: " + version);
assertThat(version).describedAs("File " + file + " dependency version for " + change.getDependency()).isEqualTo(change.getVersion());
}
}
}
}
/*
assertThat(found).describedAs("File " + file + " does not have dependency " +
change.getDependency() + " version: " + change.getVersion()).isTrue();
*/
}
开发者ID:fabric8-updatebot,项目名称:updatebot,代码行数:23,代码来源:PomHelperTest.java
示例12: getArchetypesFromJar
import io.fabric8.utils.Strings; //导入依赖的package包/类
protected List<String> getArchetypesFromJar(File archetypeJar) throws IOException {
assertThat(archetypeJar).exists();
JarFile jar = new JarFile(archetypeJar);
String entryName = "archetype-catalog.xml";
ZipEntry entry = jar.getEntry(entryName);
assertThat(entry).describedAs("Missing entry " + entryName + " in jar " + archetypeJar).isNotNull();
SortedSet<String> artifactIds = new TreeSet<>();
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
InputSource is = new InputSource(jar.getInputStream(entry));
Document doc = builder.parse(is);
NodeList artifactTags = doc.getElementsByTagName("artifactId");
for (int i = 0, size = artifactTags.getLength(); i < size; i++) {
Node element = artifactTags.item(i);
String artifactId = element.getTextContent();
if (Strings.isNotBlank(artifactId)) {
artifactIds.add(artifactId);
}
}
} catch (Exception e) {
fail("Failed to parse " + entryName + " in jar " + archetypeJar + ". Exception " + e, e);
}
return new ArrayList<>(artifactIds);
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:27,代码来源:PopulateMavenRepositoryTest.java
示例13: getArchetypesFromJar
import io.fabric8.utils.Strings; //导入依赖的package包/类
protected List<String> getArchetypesFromJar() throws IOException {
String entryName = "archetype-catalog.xml";
URL url = getClass().getClassLoader().getResource(entryName);
assertThat(url).describedAs("Could not find resource " + entryName + " on the classpath!").isNotNull();
SortedSet<String> artifactIds = new TreeSet<>();
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
InputSource is = new InputSource(url.openStream());
Document doc = builder.parse(is);
NodeList artifactTags = doc.getElementsByTagName("artifactId");
for (int i = 0, size = artifactTags.getLength(); i < size; i++) {
Node element = artifactTags.item(i);
String artifactId = element.getTextContent();
if (Strings.isNotBlank(artifactId)) {
artifactIds.add(artifactId);
}
}
} catch (Exception e) {
fail("Failed to parse " + entryName + " in catalog " + url + ". Exception " + e, e);
}
return new ArrayList<>(artifactIds);
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:25,代码来源:CreateQuickstartProjectKT.java
示例14: unshellifyName
import io.fabric8.utils.Strings; //导入依赖的package包/类
/**
* A name of the form "foo-bar-whatnot" is turned into "Foo: Bar Whatnot"
*/
public static String unshellifyName(String name) {
if (Strings.isNotBlank(name)) {
if (name.indexOf('-') >= 0 && name.toLowerCase().equals(name)) {
String[] split = name.split("-");
StringBuffer buffer = new StringBuffer();
int idx = 0;
for (String part : split) {
if (idx == 1) {
buffer.append(": ");
} else if (idx > 1) {
buffer.append(" ");
}
buffer.append(capitalize(part));
idx++;
}
return buffer.toString();
}
}
return name;
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:24,代码来源:UICommands.java
示例15: getResultMessage
import io.fabric8.utils.Strings; //导入依赖的package包/类
protected static String getResultMessage(Result result) {
if (result instanceof CompositeResult) {
CompositeResult compositeResult = (CompositeResult) result;
List<Result> results = compositeResult.getResults();
StringBuilder buffer = new StringBuilder();
for (Result childResult : results) {
String childResultMessage = getResultMessage(childResult);
if (Strings.isNotBlank(childResultMessage)) {
if (buffer.length() > 0) {
buffer.append("\n");
}
buffer.append(childResultMessage);
}
}
return buffer.toString();
} else if (result != null) {
return result.getMessage();
} else {
return null;
}
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:22,代码来源:UICommands.java
示例16: createCommitInfo
import io.fabric8.utils.Strings; //导入依赖的package包/类
public CommitInfo createCommitInfo(RevCommit entry) {
final Date date = GitUtils.getCommitDate(entry);
PersonIdent authorIdent = entry.getAuthorIdent();
String author = null;
String name = null;
String email = null;
String avatarUrl = null;
if (authorIdent != null) {
author = authorIdent.getName();
name = authorIdent.getName();
email = authorIdent.getEmailAddress();
// lets try default the avatar
if (Strings.isNotBlank(email)) {
avatarUrl = getAvatarUrl(email);
}
}
boolean merge = entry.getParentCount() > 1;
String shortMessage = entry.getShortMessage();
String sha = entry.getName();
return new CommitInfo(sha, author, name, email, avatarUrl, date, merge, shortMessage);
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:23,代码来源:RepositoryResource.java
示例17: configureBranch
import io.fabric8.utils.Strings; //导入依赖的package包/类
protected void configureBranch(Git git, String branch) {
// lets update the merge config
if (Strings.isNotBlank(branch)) {
StoredConfig config = git.getRepository().getConfig();
if (Strings.isNullOrBlank(config.getString("branch", branch, "remote")) || Strings.isNullOrBlank(config.getString("branch", branch, "merge"))) {
config.setString("branch", branch, "remote", getRemote());
config.setString("branch", branch, "merge", "refs/heads/" + branch);
try {
config.save();
} catch (IOException e) {
LOG.error("Failed to save the git configuration to " + basedir
+ " with branch " + branch + " on remote repo: " + remoteRepository + " due: " + e.getMessage() + ". This exception is ignored.", e);
}
}
}
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:17,代码来源:RepositoryResource.java
示例18: asyncCloneOrPullJenkinsWorkflows
import io.fabric8.utils.Strings; //导入依赖的package包/类
public void asyncCloneOrPullJenkinsWorkflows(final UserDetails userDetails) {
final File folder = getJenkinsfilesLibraryFolder();
if (Strings.isNotBlank(jenkinsfileLibraryGitUrl)) {
executorService.execute(new Runnable() {
@Override
public void run() {
StopWatch watch = new StopWatch();
try {
LOG.debug("Cloning or pulling jenkins workflow repo from " + jenkinsfileLibraryGitUrl + " to " + folder);
UserDetails anonymous = userDetails.createAnonymousDetails();
cloneOrPullRepo(anonymous, folder, jenkinsfileLibraryGitUrl, null, null);
} catch (Exception e) {
LOG.error("Failed to clone jenkins workflow repo from : " + jenkinsfileLibraryGitUrl + ". " + e, e);
} finally {
LOG.info("asyncCloneOrPullJenkinsWorkflows took " + watch.taken());
}
}
});
} else {
LOG.warn("Cannot clone jenkins workflow repository as the environment variable JENKINSFILE_LIBRARY_GIT_REPOSITORY is not defined");
}
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:23,代码来源:ProjectFileSystem.java
示例19: createBuildConfig
import io.fabric8.utils.Strings; //导入依赖的package包/类
public static BuildConfig createBuildConfig(String buildConfigName, Map<String, String> labels, String gitUrlText, String outputImageStreamName, String imageText, String webhookSecret) {
BuildConfigBuilder buildConfigBuilder = buildConfigBuilder(buildConfigName, labels);
BuildConfigSpecBuilder specBuilder = new BuildConfigSpecBuilder();
addBuildParameterGitSource(specBuilder, gitUrlText);
if (Strings.isNotBlank(outputImageStreamName)) {
addBuildParameterOutput(specBuilder, outputImageStreamName);
}
if (Strings.isNotBlank(imageText)) {
addBuildConfigSpectiStrategy(specBuilder, imageText);
}
if (Strings.isNotBlank(webhookSecret)) {
addWebHookTriggers(specBuilder, webhookSecret);
}
return buildConfigBuilder.withSpec(specBuilder.build()).build();
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:17,代码来源:BuildConfigs.java
示例20: printServices
import io.fabric8.utils.Strings; //导入依赖的package包/类
private void printServices(ServiceList services, PrintStream out) {
TablePrinter table = new TablePrinter();
table.columns("id", "labels", "selector", "port");
List<Service> items = services.getItems();
if (items == null) {
items = Collections.EMPTY_LIST;
}
Filter<Service> filter = KubernetesHelper.createServiceFilter(filterText.getValue());
for (Service service : items) {
if (filter.matches(service)) {
String labels = KubernetesHelper.toLabelsString(service.getMetadata().getLabels());
String selector = KubernetesHelper.toLabelsString(getSelector(service));
Set<Integer> ports = getPorts(service);
List<Integer> portList = new ArrayList<>(ports);
String portText;
if (portList.size() == 1) {
portText = portList.get(0).toString();
} else {
portText = Strings.join(portList, ", ");
}
table.row(KubernetesHelper.getName(service), labels, selector, portText);
}
}
table.print();
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:27,代码来源:ServicesList.java
注:本文中的io.fabric8.utils.Strings类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论