/**
   * If a MED with the same NS Prefix is already registered, it will be removed and replaced with
   * the supplied MED
   *
   * @param medFile the file containing the med definition
   * @throws Exception throws exception if the add operation failed
   */
  private static void updateExtensionInRegistry(IFile medFile) throws Exception {
    ModelExtensionRegistry registry = ExtensionPlugin.getInstance().getRegistry();

    // If MED with this prefix is registered, remove it first
    ModelExtensionDefinition med =
        RegistryDeploymentValidator.parseMed(medFile.getContents(), false);
    if (registry.isNamespacePrefixRegistered(med.getNamespacePrefix())) {
      registry.removeDefinition(med.getNamespacePrefix());
    }

    // Add the supplied MED
    addExtensionToRegistry(medFile);
  }
  static void internalRun(IFile medToRegister, boolean isUpdate) {
    boolean wasAdded = true;

    try {
      if (isUpdate) {
        updateExtensionInRegistry(medToRegister);
      } else {
        addExtensionToRegistry(medToRegister);
      }
    } catch (Exception e) {
      wasAdded = false;
      UTIL.log(
          IStatus.ERROR, e, NLS.bind(Messages.medRegistryAddErrorMsg, medToRegister.getName()));
      MessageDialog.openInformation(
          getShell(), Messages.registerMedActionFailedTitle, Messages.registerMedActionFailedMsg);
    }

    if (wasAdded) {
      MessageDialog.openInformation(
          getShell(), Messages.registerMedActionSuccessTitle, Messages.registerMedActionSuccessMsg);
    }
  }