code: public synchronized CmsResource createResource(
          CmsRequestContext context,
          String resourcename,
          int type,
          byte[] content,
          List<CmsProperty> properties)
      throws CmsException {
  
          String checkExistsPath = "/".equals(resourcename) ? "/" : CmsFileUtil.removeTrailingSeparator(resourcename);
          // We use checkExistsPath instead of resourcename because when creating a folder /foo/bar/, we want to fail
          // if a file /foo/bar already exists.
  
          if (existsResource(context, checkExistsPath, CmsResourceFilter.ALL)) {
              // check if the resource already exists by name
              throw new CmsVfsResourceAlreadyExistsException(
                  org.opencms.db.generic.Messages.get().container(
                      org.opencms.db.generic.Messages.ERR_RESOURCE_WITH_NAME_ALREADY_EXISTS_1,
                      resourcename));
          }
          CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
          CmsResource newResource = null;
          try {
              checkOfflineProject(dbc);
              newResource = m_driverManager.createResource(dbc, resourcename, type, content, properties);
          } catch (Exception e) {
              dbc.report(null, Messages.get().container(Messages.ERR_CREATE_RESOURCE_1, resourcename), e);
          } finally {
              dbc.clear();
          }
          return newResource;
      }
docs: Creates a new resource of the given resource type with the provided content and properties.<p>
  
  If the provided content is null and the resource is not a folder, the content will be set to an empty byte array.<p>
  
  @param context the current request context
  @param resourcename the name of the resource to create (full path)
  @param type the type of the resource to create
  @param content the content for the new resource
  @param properties the properties for the new resource
  
  @return the created resource
  
  @throws CmsException if something goes wrong
  
  @see org.opencms.file.types.I_CmsResourceType#createResource(CmsObject, CmsSecurityManager, String, byte[], List)