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:
Edwin Kempin
2011-09-27 10:43:59 +02:00
parent 813123b520
commit eacafc6900
2 changed files with 7 additions and 2 deletions

View File

@@ -117,8 +117,9 @@ final class AdminSetParent extends BaseCommand {
MetaDataUpdate md = metaDataUpdateFactory.create(key);
try {
ProjectConfig config = ProjectConfig.read(md);
config.getProject().setParentName(newParentKey.get());
md.setMessage("Inherit access from " + newParentKey.get() + "\n");
config.getProject().setParentName(newParentKey);
md.setMessage("Inherit access from "
+ (newParentKey != null ? newParentKey.get() : allProjectsName.get()) + "\n");
if (!config.commit(md)) {
err.append("error: Could not update project " + name + "\n");
}