MenuResult<ManagedObject<?>> result;
try {
result = getManagedObject(app, context, path, names);
} catch (AuthorizationException e) {
Message msg = ERR_DSCFG_ERROR_CREATE_AUTHZ.get(ufn);
throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS, msg);
} catch (DefinitionDecodingException e) {
Message pufn = path.getManagedObjectDefinition().getUserFriendlyName();
Message msg = ERR_DSCFG_ERROR_GET_PARENT_DDE.get(pufn, pufn, pufn);
throw new ClientException(LDAPResultCode.OTHER, msg);
} catch (ManagedObjectDecodingException e) {
Message pufn = path.getManagedObjectDefinition().getUserFriendlyName();
Message msg = ERR_DSCFG_ERROR_GET_PARENT_MODE.get(pufn);
throw new ClientException(LDAPResultCode.OTHER, msg, e);
} catch (CommunicationException e) {
Message msg = ERR_DSCFG_ERROR_CREATE_CE.get(ufn, e
.getMessage());
throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msg);
} catch (ConcurrentModificationException e) {
Message msg = ERR_DSCFG_ERROR_CREATE_CME.get(ufn);
throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg);
} catch (ManagedObjectNotFoundException e) {
Message pufn = path.getManagedObjectDefinition().getUserFriendlyName();
Message msg = ERR_DSCFG_ERROR_GET_PARENT_MONFE.get(pufn);
if (app.isInteractive()) {
app.println();
app.printVerboseMessage(msg);
return MenuResult.cancel();
} else {
throw new ClientException(LDAPResultCode.NO_SUCH_OBJECT, msg);
}
}
if (result.isQuit()) {
if (!app.isMenuDrivenMode()) {
// User chose to cancel creation.
Message msg = INFO_DSCFG_CONFIRM_CREATE_FAIL.get(ufn);
app.printVerboseMessage(msg);
}
return MenuResult.quit();
} else if (result.isCancel()) {
// Must be menu driven, so no need for error message.
return MenuResult.cancel();
}
ManagedObject<?> parent = result.getValue();
// Determine the type of managed object to be created. If we are creating
// a managed object beneath a set relation then prevent creation of
// duplicates.
Set<String> prohibitedTypes;
if (relation instanceof SetRelationDefinition) {
SetRelationDefinition<C, S> sr = (SetRelationDefinition<C, S>) relation;
prohibitedTypes = new HashSet<String>();
try
{
for (String child : parent.listChildren(sr)) {
prohibitedTypes.add(child);
}
}
catch (AuthorizationException e)
{
Message msg = ERR_DSCFG_ERROR_CREATE_AUTHZ.get(ufn);
throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS,
msg);
}
catch (ConcurrentModificationException e)
{
Message msg = ERR_DSCFG_ERROR_CREATE_CME.get(ufn);
throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg);
}
catch (CommunicationException e)
{
Message msg = ERR_DSCFG_ERROR_CREATE_CE.get(ufn, e
.getMessage());
throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msg);
}
} else {
// No prohibited types.
prohibitedTypes = Collections.emptySet();
}