code: private static final String getExtension(String filename, String mappingType, String MIMETYPE) throws Exception {
          String extension = "";
          if (mappingType.equals("never")) {
              extension = "";
          } else {
              // if mapping specifies ifmissing and filename contains an extension; extension is "" (filename already contains the extension)
              if (mappingType.equals("ifmissing") && filename.contains(".")) {
                  extension = "";
              } else {
                  // oth
                  if (mappingType.equals("ifmissing") || mappingType.equals("always")) {
                      // look up extension from mapping
                      extension = getExtension(MIMETYPE);
                      // if not found in mappings, use the default
                      if (extension.isEmpty())
                          extension = m_datastreamDefaultExtension;
                  } else {
                      // unknown mapping type
                      logger.warn("Unknown extension mapping type specified in fedora.fcfg");
                      extension = m_datastreamDefaultExtension;
                  }
              }
  
          }
          return extension;
      }
docs: Get a filename extension for a datastream based on mime-type to extension mapping.
  mappingType may be:
  <li>never: never look up extension
  <li>ifmissing: if the given filename already contains an extension return nothing,
  otherwise look up an extension
  <li>always: always look up an extension