code: protected boolean checkResourcePermissions(
          CmsPermissionSet required,
          boolean neededForFolder,
          CmsMessageContainer errorMessage) {
  
          boolean hasPermissions = false;
          try {
              CmsResource res;
              if (neededForFolder) {
                  // check permissions for the folder the resource is in
                  res = getCms().readResource(CmsResource.getParentFolder(getParamResource()), CmsResourceFilter.ALL);
              } else {
                  res = getCms().readResource(getParamResource(), CmsResourceFilter.ALL);
              }
              hasPermissions = getCms().hasPermissions(res, required, false, CmsResourceFilter.ALL);
          } catch (CmsException e) {
              // should usually never happen
              if (LOG.isInfoEnabled()) {
                  LOG.info(e);
              }
          }
  
          if (!hasPermissions) {
              // store the error message in the users session
              getSettings().setErrorMessage(errorMessage);
          }
  
          return hasPermissions;
      }
docs: Checks if the permissions of the current user on the resource to use in the dialog are sufficient.<p>
  
  Automatically generates a CmsMessageContainer object with an error message and stores it in the users session.<p>
  
  @param required the required permissions for the dialog
  @param neededForFolder if true, the permissions are required for the parent folder of the resource (e.g. for editors)
  @param errorMessage the message container that is stored in the session in case the permissions are not sufficient
  
  @return true if the permissions are sufficient, otherwise false