code: private boolean existsResource(String path, boolean rootPath) {
  
          CmsObject cms = getCmsObject();
          if (rootPath) {
              String origSiteRoot = cms.getRequestContext().getSiteRoot();
              try {
                  cms.getRequestContext().setSiteRoot("");
                  if (cms.existsResource(path, CmsResourceFilter.ALL)) {
                      return true;
                  }
              } finally {
                  cms.getRequestContext().setSiteRoot(origSiteRoot);
              }
          } else {
              if (cms.existsResource(path, CmsResourceFilter.ALL)) {
                  return true;
              }
          }
          return false;
      }
docs: Checks if a resource already exists for the given path.<p>
  
  @param path the path
  @param rootPath in case the path is a root path
  
  @return true if a resource already exists