Fix NPE in set-project-parent command if parent is not specified
If for the set-project-parent command the new parent project is not specified by default the root project 'All-Projects' should become the new parent. Currently it fails with a NullPointerException. Change-Id: Ibb46a1e41cd237dfe2abf80de97b20aa2970c89f Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
@@ -180,4 +180,8 @@ public final class Project {
|
|||||||
public void setParentName(String n) {
|
public void setParentName(String n) {
|
||||||
parent = n != null ? new NameKey(n) : null;
|
parent = n != null ? new NameKey(n) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setParentName(NameKey n) {
|
||||||
|
parent = n;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,8 +117,9 @@ final class AdminSetParent extends BaseCommand {
|
|||||||
MetaDataUpdate md = metaDataUpdateFactory.create(key);
|
MetaDataUpdate md = metaDataUpdateFactory.create(key);
|
||||||
try {
|
try {
|
||||||
ProjectConfig config = ProjectConfig.read(md);
|
ProjectConfig config = ProjectConfig.read(md);
|
||||||
config.getProject().setParentName(newParentKey.get());
|
config.getProject().setParentName(newParentKey);
|
||||||
md.setMessage("Inherit access from " + newParentKey.get() + "\n");
|
md.setMessage("Inherit access from "
|
||||||
|
+ (newParentKey != null ? newParentKey.get() : allProjectsName.get()) + "\n");
|
||||||
if (!config.commit(md)) {
|
if (!config.commit(md)) {
|
||||||
err.append("error: Could not update project " + name + "\n");
|
err.append("error: Could not update project " + name + "\n");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user