minor fix in DocumentPath, DCS

Change-Id: I13f332bc3897e7fc047744c36be4f208cf820d4f
This commit is contained in:
Yuta HIGUCHI 2017-09-01 16:59:52 -07:00 committed by Yuta HIGUCHI
parent e9761740db
commit 153d3589a5
2 changed files with 4 additions and 5 deletions

View File

@ -125,19 +125,18 @@ public class DistributedDynamicConfigStore
@Override
public CompletableFuture<Boolean>
addNode(ResourceId complete, DataNode node) {
CompletableFuture<Boolean> eventFuture = CompletableFuture.completedFuture(true);
String spath = ResourceIdParser.parseResId(complete);
if (spath == null) {
throw new FailedException("Invalid RsourceId, cannot create Node");
}
if (spath.compareTo(ResourceIdParser.ROOT) != 0) {
if (!spath.equals(ResourceIdParser.ROOT)) {
if (completeVersioned(keystore.get(DocumentPath.from(spath))) == null) {
throw new FailedException("Node or parent does not exist for " + spath);
}
}
spath = ResourceIdParser.appendNodeKey(spath, node.key());
parseNode(spath, node);
return eventFuture;
return CompletableFuture.completedFuture(true);
}
private void parseNode(String path, DataNode node) {

View File

@ -74,8 +74,8 @@ public class DocumentPath implements Comparable<DocumentPath> {
public DocumentPath(String nodeName, DocumentPath parentPath) {
checkNotNull(nodeName, "Node name cannot be null");
if (nodeName.contains(pathSeparator)) {
throw new IllegalDocumentNameException(
"Periods are not allowed in names.");
throw new IllegalDocumentNameException("'" + pathSeparator + "'" +
" are not allowed in names.");
}
if (parentPath != null) {
pathElements.addAll(parentPath.pathElements());