public GitRepository(String name, String cloneUrl) { this.name = name; this.cloneUrl = cloneUrl; this.htmlUrl = Strings.stripSuffix(cloneUrl, ".git"); }
public GitRepository(String name, String cloneUrl) { this.name = name; this.cloneUrl = cloneUrl; this.htmlUrl = Strings.stripSuffix(cloneUrl, ".git"); }
private SortedMap<String, File> findLogFiles(File logDir, String name) { SortedMap<String, File> answer = new TreeMap<>(); File[] files = logDir.listFiles(); if (files != null) { for (File file : files) { String fileName = file.getName(); if (fileName.endsWith(LogHelpers.LOG_FILE_POSTFIX)) { fileName = Strings.stripSuffix(fileName, LogHelpers.LOG_FILE_POSTFIX); if (fileName.startsWith(name)) { answer.put(fileName, file); } } } } return answer; }
protected static String stripSlashesAndGit(String path) { path = Strings.stripPrefix(path, "/"); path = Strings.stripPrefix(path, "/"); path = Strings.stripSuffix(path, "/"); path = Strings.stripSuffix(path, ".git"); return path; }
/** * Returns the pattern name */ public static String getPatternName(OptionalIdentifiedDefinition camelNode) { // we should grab the annotation instead XmlRootElement root = camelNode.getClass().getAnnotation(XmlRootElement.class); if (root != null) { return root.name(); } String simpleName = Strings.stripSuffix(camelNode.getClass().getSimpleName(), "Definition"); return Introspector.decapitalize(simpleName); }
protected static String stripSlashesAndGit(String path) { path = Strings.stripPrefix(path, "/"); path = Strings.stripPrefix(path, "/"); path = Strings.stripSuffix(path, "/"); path = Strings.stripSuffix(path, ".git"); return path; }
public OpenShiftSPI() { Map<String, String> envs = System.getenv(); for (Map.Entry<String, String> entry : envs.entrySet()) { String key = entry.getKey(); String publicPort = entry.getValue(); if (key.startsWith("OPENSHIFT_") && key.endsWith("_PROXY_PORT")) { String prefix = Strings.stripSuffix(key, "_PROXY_PORT"); String privatePort = envs.get(prefix + "_PORT"); if (privatePort == null) { privatePort = envs.get(prefix); } if (privatePort != null) { try { ports.put(new Integer(privatePort), new Integer(publicPort)); } catch (NumberFormatException ignore) { } } } } }
protected void extractOrganisationAndUserFromUrl() { if (Strings.isNotBlank(url)) { String text = Strings.stripSuffix(url, "./"); text = Strings.stripSuffix(text, ".git"); text = Strings.stripSuffix(text, "/"); String[] split = text.split("/"); if (split != null && split.length > 1) { if (Strings.isNullOrBlank(user)) { user = split[split.length - 2]; } if (Strings.isNullOrBlank(repoName)) { repoName = split[split.length - 1]; } } } }
protected void validatePom(String projectName, File pom) { LOG.debug("Validating " + pom); String prefix = "quickstart " + Strings.stripSuffix(projectName, "-archetype") + " pom.xml"; Element root = null; try { Document doc = archetypeUtils.parseXml(new InputSource(new FileReader(pom))); root = doc.getDocumentElement(); } catch (Exception e) { LOG.error("Failed to parse " + pom + ". " + e, e); return; } if (root == null) { return; } Element propertyElement = getPropertiesElement(root); // lets load all the properties defined in the <properties> element in the bom pom. NodeList dependencyElements = root.getElementsByTagName("dependency"); for (int i = 0, size = dependencyElements.getLength(); i < size; i++) { Element dependency = (Element) dependencyElements.item(i); validateVersion(prefix + " dependency", dependency, propertyElement); } NodeList pluginElements = root.getElementsByTagName("plugin"); for (int i = 0, size = pluginElements.getLength(); i < size; i++) { Element plugin = (Element) pluginElements.item(i); validateVersion(prefix + " plugin", plugin, propertyElement); } }
public static Route createRouteForService(String routeDomainPostfix, String namespace, Service service, Logger log) { Route route = null; String id = KubernetesHelper.getName(service); if (Strings.isNotBlank(id) && shouldCreateRouteForService(log, service, id)) { route = new Route(); String routeId = id; KubernetesHelper.setName(route, namespace, routeId); RouteSpec routeSpec = new RouteSpec(); RouteTargetReference objectRef = new RouteTargetReferenceBuilder().withName(id).build(); //objectRef.setNamespace(namespace); routeSpec.setTo(objectRef); if (Strings.isNotBlank(routeDomainPostfix)) { // Let Openshift determine the route host when the domain is not set String host = Strings.stripSuffix(Strings.stripSuffix(id, "-service"), "."); String namespaceSuffix = "-" + namespace; routeSpec.setHost(host + namespaceSuffix + "." + Strings.stripPrefix(routeDomainPostfix, ".")); } route.setSpec(routeSpec); String json = null; try { json = KubernetesHelper.toJson(route); } catch (JsonProcessingException e) { json = e.getMessage() + ". object: " + route; } } return route; }