I was reviewing some code and I found this:

List<Group> groups = getPreferences().getUser().getGroupsAsList();
boolean unifiedMessagingParamsGroup = false;
for (Group group : groups) {
  String host = group.getSettingValue("unified-messaging/host");
  Integer port = null;
  try {
    // hack get the value of the setting returning default value
    // this is due to inheriting ValueStorage instead of BeanWithSettings
    port =
Integer.valueOf(group.inherhitSettingsForEditing(getPreferences().getUser()).getSetting(
                        "unified-messaging/port").getValue());
  } catch (NumberFormatException e) {
  // do nothing ... a senseless thing in order to pass checkstyle
    port = null;
  }
  if (StringUtils.isNotEmpty(host) && port != null) {
    unifiedMessagingParamsGroup = true;
    break;
  }
}


Can someone explain why is this so complicated. I would just write:


String host = getUser().getSettingValue("unified-messaging/host");
Integer port = getUser().getSettingTypeValue("unified-messaging/post");

After all group traversal happens automatically.

What am I missing?
D.

_______________________________________________
sipx-dev mailing list [email protected]
List Archive: http://list.sipfoundry.org/archive/sipx-dev
Unsubscribe: http://list.sipfoundry.org/mailman/listinfo/sipx-dev
sipXecs IP PBX -- http://www.sipfoundry.org/

Reply via email to