MenuResult<ManagedObject<?>> result;
try {
result = getManagedObject(app, context, path, names);
} catch (AuthorizationException e) {
Message msg = ERR_DSCFG_ERROR_LIST_AUTHZ.get(ufn);
throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS,
msg);
} catch (DefinitionDecodingException e) {
ufn = path.getManagedObjectDefinition().getUserFriendlyName();
Message msg = ERR_DSCFG_ERROR_GET_PARENT_DDE.get(ufn, ufn, ufn);
throw new ClientException(LDAPResultCode.OTHER, msg);
} catch (ManagedObjectDecodingException e) {
ufn = path.getManagedObjectDefinition().getUserFriendlyName();
Message msg = ERR_DSCFG_ERROR_GET_PARENT_MODE.get(ufn);
throw new ClientException(LDAPResultCode.OTHER, msg, e);
} catch (CommunicationException e) {
Message msg = ERR_DSCFG_ERROR_LIST_CE.get(ufn, e.getMessage());
throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msg);
} catch (ConcurrentModificationException e) {
Message msg = ERR_DSCFG_ERROR_LIST_CME.get(ufn);
throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg);
} catch (ManagedObjectNotFoundException e) {
ufn = path.getManagedObjectDefinition().getUserFriendlyName();
Message msg = ERR_DSCFG_ERROR_GET_PARENT_MONFE.get(ufn);
if (app.isInteractive()) {
app.println();
app.printVerboseMessage(msg);
return MenuResult.cancel();
} else {
throw new ClientException(LDAPResultCode.NO_SUCH_OBJECT, msg);
}
}
if (result.isQuit()) {
return MenuResult.quit();
} else if (result.isCancel()) {
return MenuResult.cancel();
}
ManagedObject<?> parent = result.getValue();
SortedMap<String, ManagedObject<?>> children =
new TreeMap<String, ManagedObject<?>>();
if (relation instanceof InstantiableRelationDefinition) {
InstantiableRelationDefinition<?, ?> irelation =
(InstantiableRelationDefinition<?, ?>) relation;
try {
for (String s : parent.listChildren(irelation)) {
try {
children.put(s, parent.getChild(irelation, s));
} catch (ManagedObjectNotFoundException e) {
// Ignore - as it's been removed since we did the list.
}
}
} catch (DefinitionDecodingException e) {
// FIXME: just output this as a warnings (incl. the name) but
// continue.
Message msg = ERR_DSCFG_ERROR_LIST_DDE.get(ufn, ufn, ufn);
throw new ClientException(LDAPResultCode.OTHER, msg);
} catch (ManagedObjectDecodingException e) {
// FIXME: just output this as a warnings (incl. the name) but
// continue.
Message msg = ERR_DSCFG_ERROR_LIST_MODE.get(ufn);
throw new ClientException(LDAPResultCode.OTHER, msg, e);
} catch (AuthorizationException e) {
Message msg = ERR_DSCFG_ERROR_LIST_AUTHZ.get(ufn);
throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS,
msg);
} catch (ConcurrentModificationException e) {
Message msg = ERR_DSCFG_ERROR_LIST_CME.get(ufn);
throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg);
} catch (CommunicationException e) {
Message msg = ERR_DSCFG_ERROR_LIST_CE.get(ufn, e.getMessage());
throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN,
msg);
}
} else if (relation instanceof SetRelationDefinition) {
SetRelationDefinition<?, ?> srelation =
(SetRelationDefinition<?, ?>) relation;
try {
for (String s : parent.listChildren(srelation)) {
try {
children.put(s, parent.getChild(srelation, s));
} catch (ManagedObjectNotFoundException e) {
// Ignore - as it's been removed since we did the list.
}
}
} catch (DefinitionDecodingException e) {
// FIXME: just output this as a warnings (incl. the name) but
// continue.
Message msg = ERR_DSCFG_ERROR_LIST_DDE.get(ufn, ufn, ufn);
throw new ClientException(LDAPResultCode.OTHER, msg);
} catch (ManagedObjectDecodingException e) {
// FIXME: just output this as a warnings (incl. the name) but
// continue.
Message msg = ERR_DSCFG_ERROR_LIST_MODE.get(ufn);
throw new ClientException(LDAPResultCode.OTHER, msg, e);
} catch (AuthorizationException e) {
Message msg = ERR_DSCFG_ERROR_LIST_AUTHZ.get(ufn);
throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS,
msg);
} catch (ConcurrentModificationException e) {
Message msg = ERR_DSCFG_ERROR_LIST_CME.get(ufn);
throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg);
} catch (CommunicationException e) {
Message msg = ERR_DSCFG_ERROR_LIST_CE.get(ufn, e.getMessage());
throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN,
msg);
}
} else if (relation instanceof OptionalRelationDefinition) {
OptionalRelationDefinition<?, ?> orelation =
(OptionalRelationDefinition<?, ?>) relation;
try {
if (parent.hasChild(orelation)) {
ManagedObject<?> child = parent.getChild(orelation);
children.put(child.getManagedObjectDefinition().getName(), child);
} else {
// Indicate that the managed object does not exist.
Message msg = ERR_DSCFG_ERROR_FINDER_NO_CHILDREN.get(ufn);
if (app.isInteractive()) {
app.println();
app.printVerboseMessage(msg);
return MenuResult.cancel();
} else {
throw new ClientException(LDAPResultCode.NO_SUCH_OBJECT, msg);
}
}
} catch (AuthorizationException e) {
Message msg = ERR_DSCFG_ERROR_LIST_AUTHZ.get(ufn);
throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS,
msg);
} catch (DefinitionDecodingException e) {
Message msg = ERR_DSCFG_ERROR_LIST_DDE.get(ufn, ufn, ufn);
throw new ClientException(LDAPResultCode.OTHER, msg);
} catch (ManagedObjectDecodingException e) {
Message msg = ERR_DSCFG_ERROR_LIST_MODE.get(ufn);
throw new ClientException(LDAPResultCode.OTHER, msg, e);
} catch (ConcurrentModificationException e) {
Message msg = ERR_DSCFG_ERROR_LIST_CME.get(ufn);
throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg);
} catch (CommunicationException e) {
Message msg = ERR_DSCFG_ERROR_LIST_CE.get(ufn, e.getMessage());
throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN,
msg);
} catch (ManagedObjectNotFoundException e) {
Message msg = ERR_DSCFG_ERROR_LIST_MONFE.get(ufn);
throw new ClientException(LDAPResultCode.NO_SUCH_OBJECT, msg);
}
}
// Output the results.
if (app.isScriptFriendly()) {