/**
  * @see
  *     org.openmrs.messagesource.MutableMessageSource#addPresentation(org.openmrs.messagesource.PresentationMessage)
  */
 public void addPresentation(PresentationMessage message) {
   File propertyFile = findPropertiesFileFor(message.getCode());
   if (propertyFile != null) {
     Properties props = new Properties();
     try {
       OpenmrsUtil.loadProperties(props, propertyFile);
       props.setProperty(message.getCode(), message.getMessage());
       OpenmrsUtil.storeProperties(props, propertyFile, "OpenMRS Application Messages");
     } catch (Exception e) {
       log.error("Error generated", e);
     }
   }
 }
 /**
  * @see
  *     org.openmrs.messagesource.MutableMessageSource#removePresentation(org.openmrs.messagesource.PresentationMessage)
  */
 public void removePresentation(PresentationMessage message) {
   File propertyFile = findPropertiesFileFor(message.getCode());
   if (propertyFile != null) {
     Properties props = new Properties();
     try {
       OpenmrsUtil.loadProperties(props, propertyFile);
       props.remove(message.getCode());
       OpenmrsUtil.storeProperties(props, propertyFile, PROPERTIES_FILE_COMMENT);
     } catch (Exception e) {
       log.error("Error generated", e);
     }
   }
 }
  /**
   * Presumes to append the messages to a message.properties file which is already being monitored
   * by the super ReloadableResourceBundleMessageSource. This is a blind, trusting hack.
   *
   * @see org.openmrs.messagesource.MutableMessageSource#publishProperties(java.util.Properties,
   *     java.lang.String, java.lang.String, java.lang.String, java.lang.String)
   * @deprecated use {@linkplain #merge(MutableMessageSource, boolean)}
   */
  @Deprecated
  public void publishProperties(
      Properties props, String locale, String namespace, String name, String version) {

    String filePrefix = (namespace.length() > 0) ? (namespace + "_") : "";
    String propertiesPath = "/WEB-INF/" + filePrefix + "messages" + locale + ".properties";

    Resource propertiesResource = applicationContext.getResource(propertiesPath);
    try {
      File propertiesFile = propertiesResource.getFile();

      if (!propertiesFile.exists()) {
        propertiesFile.createNewFile();
      }
      // append the properties to the appropriate messages file
      OpenmrsUtil.storeProperties(props, propertiesFile, namespace + ": " + name + " v" + version);

    } catch (Exception ex) {
      log.error("Error creating new properties file");
    }
  }