code: public static String addFileExtension(CmsObject cms, String resourcename, String extension) {
  
          if (!extension.startsWith(".")) {
              extension = "." + extension;
          }
  
          if (!resourcename.endsWith(extension)) {
              String name = resourcename + extension;
              int count = 0;
              while (cms.existsResource(name)) {
                  count++;
                  name = resourcename + "." + count + extension;
              }
  
              return name;
          }
  
          return resourcename;
      }
docs: Adds a file extension to the resource name.<p>
  
  If the file with the new extension already exists, an index count will be
  added before the final extension.<p>
  
  For example: <code>index.html.1.jsp</code>.<p>
  
  @see #removeFileExtension(CmsObject, String, String)
  
  @param cms the actual CmsObject
  @param resourcename the name of the resource where to add the file extension
  @param extension the extension to add
  
  @return the resource name with the added file extension