MCPcopy Create free account
hub / github.com/ddf-project/DDF / validateName

Method validateName

core/src/main/java/io/ddf/DDF.java:279–297  ·  view source on GitHub ↗
(String name)

Source from the content-addressed store, hash-verified

277 // TODO: What's current namespace? Should we allow same name among
278 // different engines?
279 private void validateName(String name) throws DDFException {
280 Boolean isNameExisted;
281 try {
282 this.getManager().getDDFByName(name);
283 isNameExisted = true;
284 } catch (DDFException e) {
285 isNameExisted = false;
286 }
287 if(isNameExisted) {
288 throw new DDFException(String.format("DDF with name %s already exists", name));
289 }
290
291 Pattern p = Pattern.compile("^[a-zA-Z0-9_-]*$");
292 Matcher m = p.matcher(name);
293 if(!m.find()) {
294 throw new DDFException(String.format("Invalid name %s, only allow alphanumeric (uppercase and lowercase a-z, numbers 0-9) " +
295 "and dash (\"-\") and underscore (\"_\")", name));
296 }
297 }
298
299 @Override
300 public String getGlobalObjectType() {

Callers 1

setNameMethod · 0.95

Calls 2

getManagerMethod · 0.95
getDDFByNameMethod · 0.45

Tested by

no test coverage detected