public String serialize(final ResourceKey bundleKey, final ResourceKey key)
      throws ResourceException {
    // Validate the parameter
    if (key == null) {
      throw new NullPointerException("The ResourceKey can not be null");
    }
    if (isSupportedKey(key) == false) {
      throw new IllegalArgumentException("Key format is not recognized.");
    }
    if (!(key.getIdentifier() instanceof File)) {
      throw new IllegalArgumentException(
          "ResourceKey is invalid - identifier is not a File object");
    }

    // Log information
    logger.debug("Serializing a File Resource Key...");
    if (key.getParent() != null) {
      throw new ResourceException(
          "Unable to serialize a File-ResourceKey with a parent. This type is not expected to have a parent.");
    }

    // Create a string version of the identifier
    try {
      final File file = (File) key.getIdentifier();
      final String strIdentifier = file.getCanonicalPath();
      final String result =
          ResourceKeyUtils.createStringResourceKey(
              key.getSchema().toString(), strIdentifier, key.getFactoryParameters());
      logger.debug("Serialized File Resource Key: [" + result + "]");
      return result;
    } catch (IOException ioe) {
      throw new IllegalArgumentException(
          "Could not determine cononical path to file specified in ResourceKey: "
              + ioe.getMessage());
    }
  }