String aiId;
UID aiId;
  public static String registerConvoy(      Registry toReg,       Asset convoyAsset,      long startTime,      long endTime) {    // get id    String convoyId = convoyAsset.getUID().toString();    // check if convoy is registered    if (toReg.convoys.getConvoy(convoyId) == null) {      // must register this convoy      //      // create a new convoy      org.cougaar.mlm.ui.psp.transit.data.convoys.Convoy toConvoy =        new org.cougaar.mlm.ui.psp.transit.data.convoys.Convoy();      toConvoy.setUID(convoyId);      // set the start and end times      toConvoy.setStartTime(startTime);      toConvoy.setEndTime(endTime);      // set pretty name      String name;      ItemIdentificationPG itemPG;      if (((itemPG = convoyAsset.getItemIdentificationPG()) == null) ||          ((name = itemPG.getItemIdentification()) == null)) {        // typically use itemId, but here use (classname+"-"+UID)        name =          (((convoyAsset instanceof Convoy) ?             "Convoy-" :            (convoyAsset instanceof Train) ?             "Train-" :            "Other-")+           convoyId);      }      if (convoyAsset instanceof AssetGroup) {        toConvoy.setPrettyName(name);        // register the carrier assets in this convoy        List groupL = assetHelper.expandAssetGroup((AssetGroup)convoyAsset);        int n = groupL.size();        for (int i = 0; i < n; i++) {          Asset ai = (Asset)groupL.get(i);          String aiId;          try {            aiId = registerCarrierInstance(toReg, ai, true);          } catch (RuntimeException e) {            throw new IllegalArgumentException(                "Unable to expand (convoy) assetGroup UID:("+                convoyAsset.getUID()+                ") element["+i+"]: "+                ((ai != null) ?                  ("(UID: "+ai.getUID()+")") :                 ("null")));          }          toConvoy.addConveyanceID(aiId);        }      } else {        // should never happen.. Convoys and Trains are AssetGroups        throw new IllegalArgumentException(            "Unexpected Convoy type: "+            ((convoyAsset != null) ?              convoyAsset.getClass().getName() :              "null"));      }      // register the convoy      toReg.convoys.addConvoy(toConvoy);    }    // return the convoy id    return convoyId;  }