public static void appendToOrSetProperty(Properties properties, String key, String value) { Assert.hasText(value); String existingValue = properties.getProperty(key); if (existingValue == null) { existingValue = ""; } String newValue = existingValue + value; properties.setProperty(key, newValue); }
public String psf(String user) { Assert.hasText(user); List<String> args = new ArrayList<String>(); args.add("-u"); args.add(user); args.add("-f"); return cmd(PS, args); }
public String cp(List<String> options, String src, String dst, boolean bypassAnyAliases) { Assert.hasText(src, "src has no text"); Assert.hasText(dst, "dst has no text"); List<String> args = new ArrayList<String>(); args.addAll(CollectionUtils.toEmptyList(options)); args.add(src); args.add(dst); return cmd(CP, args, bypassAnyAliases); }
public String nohup(String command, List<String> nohupArgs) { Assert.hasText(command); List<String> args = new ArrayList<String>(); args.add(command); args.addAll(nohupArgs); return cmd(NOHUP, args); }
@Override public Long getObject() { Assert.hasText(time, "time has no text"); return FormatUtils.getMillis(time); }
@Override public org.kuali.common.util.Project getObject() { Assert.hasText(gav); return org.kuali.common.util.ProjectUtils.loadProject(gav); }
public String ps(String user) { Assert.hasText(user); return cmd(PS, Arrays.asList("-u", user)); }
/** * Converts a GAV into Spring's classpath style notation for the default project properties context. * * <pre> * org.kuali.common:kuali-jdbc -> classpath:org/kuali/common/kuali-jdbc/properties-context.xml * </pre> */ @Deprecated public static String getDefaultPropertyContextLocation(String gav) { Assert.hasText(gav, "gav has no text"); org.kuali.common.util.Project p = org.kuali.common.util.ProjectUtils.getProject(gav); return org.kuali.common.util.ProjectUtils.getClassPathPrefix(p) + "/properties-context.xml"; }
/** * Make sure <code>pattern</code> is bracketed by <code>delimiter</code>. * * <pre> * apidocs -> /apidocs/ * apidocs/ -> /apidocs/ * /apidocs -> /apidocs/ * /apidocs/ -> /apidocs/ * </pre> */ protected String getSuffixPattern(String pattern, String delimiter) { Assert.hasText(pattern, "pattern has no text"); Assert.hasText(delimiter, "delimiter has no text"); StringBuilder sb = new StringBuilder(); if (!StringUtils.startsWith(pattern, delimiter)) { sb.append(delimiter); } sb.append(pattern); if (!StringUtils.endsWith(pattern, delimiter)) { sb.append(delimiter); } return sb.toString(); }
@Override public String getObject() { Assert.notNull(localRepositoryDir); Assert.hasText(getGroupId()); Assert.hasText(getArtifactId()); Assert.hasText(getVersion()); Assert.hasText(getType()); File file = org.kuali.common.util.RepositoryUtils.getFile(localRepositoryDir, this); validate(file); return LocationUtils.getCanonicalPath(file); }
/** * Given groupId:artifactId, convert the groupId to groupId.base, then return a resource friendly prefix * * <pre> * org.kuali.student.db:ks-impex-rice-db = org/kuali/student/ks-impex-rice-db * org.kuali.common:kuali-util = org/kuali/common/kuali-util * </pre> */ public static String getResourcePath(Project project) { Properties properties = project.getProperties(); String groupIdPath = properties.getProperty(Constants.GROUP_ID_PATH_KEY); Assert.hasText(groupIdPath, "groupIdPath has no text"); String artifactId = project.getArtifactId(); return groupIdPath + "/" + artifactId; }
public static String getPropertiesFileLocation(Project project) { Assert.hasText(project.getGroupId(), "groupId has no text"); Assert.hasText(project.getArtifactId(), "artifactId has no text"); Properties properties = new Properties(); properties.setProperty(Constants.GROUP_ID_PATH_KEY, Str.getPath(project.getGroupId())); properties.setProperty(Constants.ARTIFACT_ID_KEY, project.getArtifactId()); return PPH.replacePlaceholders(Constants.PROJECT_PROPERTIES_LOCATION, properties); }
@Override public String toString(RemoteFile source) { Assert.notNull(source); Assert.hasText(source.getAbsolutePath()); Assert.notBlank(encoding); ByteArrayOutputStream out = new ByteArrayOutputStream(); try { copyFile(source, out); return out.toString(encoding); } catch (IOException e) { throw new IllegalStateException("Unexpected IO error", e); } finally { IOUtils.closeQuietly(out); } }
@Override public String toString(RemoteFile source) { Assert.notNull(source); Assert.hasText(source.getAbsolutePath()); Assert.notBlank(encoding); ByteArrayOutputStream out = new ByteArrayOutputStream(); try { copyFile(source, out); return out.toString(encoding); } catch (IOException e) { throw new IllegalStateException("Unexpected IO error", e); } finally { IOUtils.closeQuietly(out); } }
protected void validateConfiguration(org.kuali.common.util.service.ScmService service, ScmRequest request) { // Make sure we are configured correctly Assert.notNull(service, "service is null"); if (!CollectionUtils.isEmpty(request.getCommits())) { Assert.hasText(request.getCommitMessage(), "commitMessage has no text"); } }
@Override public void load(String location, Map<String, Object> contextBeans, PropertySource<?> propertySource) { // Make sure the location isn't empty Assert.hasText(location, "location is null"); // Setup a SpringContext SpringContext context = new SpringContext(); context.setLocations(Arrays.asList(location)); context.setPropertySourceContext(new PropertySourceContext(PropertySourceUtils.asList(propertySource))); // Null safe handling for non-required parameters context.setContextBeans(CollectionUtils.toEmptyMap(contextBeans)); // Load the location using a SpringContext load(context); }
@Override public void load(String location, String beanName, Object bean, PropertySource<?> propertySource) { // Make sure the location isn't empty Assert.hasText(location, "location is null"); // Setup a SpringContext SpringContext context = new SpringContext(); context.setLocations(Arrays.asList(location)); context.setPropertySourceContext(new PropertySourceContext(SpringUtils.asList(propertySource))); // Null safe handling for non-required parameters context.setBeanNames(CollectionUtils.toEmptyList(beanName)); context.setBeans(CollectionUtils.toEmptyList(bean)); // Load the location using a SpringContext load(context); }
/** * <p> * Order is <code>groupId:artifactId:version:classifier:type:scope</code>. * </p> */ public static final Artifact parseArtifact(String gav) { Assert.hasText(gav, "gav has no text"); String[] tokens = StringUtils.splitPreserveAllTokens(gav, GAV_DELIMITER); int len = tokens.length; for (int i = 0; i < len; i++) { tokens[i] = toNull(tokens[i]); } Artifact a = new Artifact(); if (len > 0) { a.setGroupId(tokens[0]); } if (len > 1) { a.setArtifactId(tokens[1]); } if (len > 2) { a.setVersion(tokens[2]); } if (len > 3) { a.setClassifier(tokens[3]); } if (len > 4) { a.setType(tokens[4]); } return a; }
Assert.hasText(gav, "gav has no text");