List of usage examples for org.springframework.util StringUtils containsWhitespace
public static boolean containsWhitespace(@Nullable String str)
From source file:org.sventon.model.RepositoryName.java
/** * Validates given repository name.//from ww w . j a v a 2s. c o m * * @param name Repository name to validate. * @return True if valid, false if not. */ public static boolean isValid(final String name) { return !(name == null || name.length() == 0) && !StringUtils.containsWhitespace(name); }
From source file:uk.ac.bbsrc.tgac.browser.process.parameter.PathParameter.java
@Override public boolean validateParameterValue(String value) { return !StringUtils.containsWhitespace(value) && !value.contains("~"); }
From source file:com.starit.diamond.server.service.DiskService.java
public void saveToDisk(ConfigInfo configInfo) throws IOException { if (configInfo == null) throw new IllegalArgumentException("configInfo?"); if (!StringUtils.hasLength(configInfo.getDataId()) || StringUtils.containsWhitespace(configInfo.getDataId())) throw new IllegalArgumentException("dataId"); if (!StringUtils.hasLength(configInfo.getGroup()) || StringUtils.containsWhitespace(configInfo.getGroup())) throw new IllegalArgumentException("group"); if (!StringUtils.hasLength(configInfo.getContent())) throw new IllegalArgumentException("content"); final String basePath = WebUtils.getRealPath(servletContext, Constants.BASE_DIR); createDirIfNessary(basePath);//from w w w . j av a2 s . co m final String groupPath = WebUtils.getRealPath(servletContext, Constants.BASE_DIR + "/" + configInfo.getGroup()); createDirIfNessary(groupPath); String group = configInfo.getGroup(); String dataId = configInfo.getDataId(); dataId = SystemConfig.encodeDataIdForFNIfUnderWin(dataId); final String dataPath = WebUtils.getRealPath(servletContext, Constants.BASE_DIR + "/" + group + "/" + dataId); File targetFile = createFileIfNessary(dataPath); File tempFile = File.createTempFile(group + "-" + dataId, ".tmp"); FileOutputStream out = null; PrintWriter writer = null; try { out = new FileOutputStream(tempFile); BufferedOutputStream stream = new BufferedOutputStream(out); writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream, Constants.ENCODE))); configInfo.dump(writer); writer.flush(); } catch (Exception e) { log.error("??, tempFile:" + tempFile + ",targetFile:" + targetFile, e); } finally { if (writer != null) writer.close(); } String cacheKey = generateCacheKey(configInfo.getGroup(), configInfo.getDataId()); // if (this.modifyMarkCache.putIfAbsent(cacheKey, true) == null) { try { // ??? if (!FileUtils.contentEquals(tempFile, targetFile)) { try { // TODO ?, ??? , ?? FileUtils.copyFile(tempFile, targetFile); } catch (Throwable t) { log.error("??, tempFile:" + tempFile + ", targetFile:" + targetFile, t); SystemConfig.system_pause(); throw new RuntimeException(); } } tempFile.delete(); } finally { // this.modifyMarkCache.remove(cacheKey); } } else throw new ConfigServiceException("??"); }
From source file:com.starit.diamond.server.service.ConfigService.java
String generatePath(String dataId, final String group) { if (!StringUtils.hasLength(dataId) || StringUtils.containsWhitespace(dataId)) throw new IllegalArgumentException("dataId"); if (!StringUtils.hasLength(group) || StringUtils.containsWhitespace(group)) throw new IllegalArgumentException("group"); String fnDataId = SystemConfig.encodeDataIdForFNIfUnderWin(dataId); StringBuilder sb = new StringBuilder("/"); sb.append(Constants.BASE_DIR).append("/"); sb.append(group).append("/"); sb.append(fnDataId);// w w w .ja va 2 s . c o m return sb.toString(); }
From source file:it.geosolutions.opensdi2.configurations.model.OSDIConfigurationKVP.java
@Override public boolean validateIDs() { if (StringUtils.isEmpty(scopeID) || StringUtils.containsWhitespace(scopeID) || !org.apache.commons.lang.StringUtils.isAlphanumeric(scopeID)) { return false; }/*from w w w . j a v a 2 s .c o m*/ if (StringUtils.isEmpty(instanceID) || StringUtils.containsWhitespace(instanceID) || !org.apache.commons.lang.StringUtils.isAlphanumeric(instanceID)) { return false; } return true; }
From source file:com.starit.diamond.server.service.ConfigService.java
/** * ?dataIdgroup??//from www. ja v a 2s . c om * * @param dataId * @param group * @return */ public ConfigInfo findConfigInfo(String dataId, String group) { if (!StringUtils.hasLength(dataId) || StringUtils.containsWhitespace(dataId)) throw new IllegalArgumentException("dataId"); if (!StringUtils.hasLength(group) || StringUtils.containsWhitespace(group)) throw new IllegalArgumentException("group"); return persistService.findConfigInfo(dataId, group); }
From source file:com.starit.diamond.server.service.DiskService.java
public void removeConfigInfo(String dataId, String group) throws IOException { if (!StringUtils.hasLength(dataId) || StringUtils.containsWhitespace(dataId)) throw new IllegalArgumentException("dataId"); if (!StringUtils.hasLength(group) || StringUtils.containsWhitespace(group)) throw new IllegalArgumentException("group"); final String basePath = WebUtils.getRealPath(servletContext, Constants.BASE_DIR); createDirIfNessary(basePath);/*w w w . j av a2 s. c om*/ final String groupPath = WebUtils.getRealPath(servletContext, Constants.BASE_DIR + "/" + group); final File groupDir = new File(groupPath); if (!groupDir.exists()) { return; } // group?groupdataId??? String fnDataId = SystemConfig.encodeDataIdForFNIfUnderWin(dataId); final String dataPath = WebUtils.getRealPath(servletContext, Constants.BASE_DIR + "/" + group + "/" + fnDataId); File dataFile = new File(dataPath); if (!dataFile.exists()) { return; } String cacheKey = generateCacheKey(group, dataId); // if (this.modifyMarkCache.putIfAbsent(cacheKey, true) == null) { try { if (!dataFile.delete()) throw new ConfigServiceException("?"); } finally { this.modifyMarkCache.remove(cacheKey); } } else throw new ConfigServiceException("?"); }
From source file:com.taobao.diamond.server.service.ConfigService.java
private void checkParameter(String dataId, String group, String content) { if (!StringUtils.hasLength(dataId) || StringUtils.containsWhitespace(dataId)) throw new ConfigServiceException("dataId"); if (!StringUtils.hasLength(group) || StringUtils.containsWhitespace(group)) throw new ConfigServiceException("group"); if (!StringUtils.hasLength(content)) throw new ConfigServiceException("content"); }
From source file:cn.leancloud.diamond.server.service.ConfigService.java
private void checkParameter(String dataId, String group, String content) { if (!StringUtils.hasLength(dataId) || StringUtils.containsWhitespace(dataId)) throw new ConfigServiceException("dataId"); if (!StringUtils.hasLength(group) || StringUtils.containsWhitespace(group)) throw new ConfigServiceException("group"); if (!StringUtils.hasLength(content)) throw new ConfigServiceException("content"); }
From source file:me.adaptive.core.data.api.UserRegistrationService.java
private boolean isValidUsername(String username) { return !StringUtils.isEmpty(username) && !StringUtils.containsWhitespace(username) && username.length() > 3 && username.length() < 15; }