public CmsResource createNewElement(CmsObject userCms, CmsResource modelResource, String pageFolderRootPath)
    throws CmsException {

        checkOffline(userCms);
        checkInitialized();
        CmsObject rootCms = rootCms(userCms);
        String folderPath = getFolderPath(userCms, pageFolderRootPath);
        CmsVfsUtil.createFolder(userCms, folderPath);
        String destination = CmsStringUtil.joinPaths(folderPath, getNamePattern(true));
        String creationPath = OpenCms.getResourceManager().getNameGenerator().getNewFileName(rootCms, destination, 5);
        // set the content locale
        rootCms.getRequestContext().setAttribute(
            CmsRequestContext.ATTRIBUTE_NEW_RESOURCE_LOCALE,
            userCms.getRequestContext().getLocale());
        if (modelResource != null) {
            // set the model resource
            rootCms.getRequestContext().setAttribute(CmsRequestContext.ATTRIBUTE_MODEL, modelResource.getRootPath());
        }
        CmsResource createdResource = rootCms.createResource(
            creationPath,
            getType(),
            null,
            new ArrayList<CmsProperty>(0));
        if (modelResource != null) {
            // set the model resource
            CmsCategoryService.getInstance().copyCategories(rootCms, modelResource, creationPath);
        }
        try {
            rootCms.unlockResource(creationPath);
        } catch (CmsLockException e) {
            // probably the parent folder is locked
            LOG.info(e.getLocalizedMessage(), e);
        }
        return createdResource;
    }
public CmsResource createNewElement ( CmsObject userCms , CmsResource modelResource , String pageFolderRootPath ) throws CmsException { checkOffline ( userCms ) ; checkInitialized ( ) ; CmsObject rootCms = rootCms ( userCms ) ; String folderPath = getFolderPath ( userCms , pageFolderRootPath ) ; CmsVfsUtil . createFolder ( userCms , folderPath ) ; String destination = CmsStringUtil . joinPaths ( folderPath , getNamePattern ( true ) ) ; String creationPath = OpenCms . getResourceManager ( ) . getNameGenerator ( ) . getNewFileName ( rootCms , destination , 5 ) ; rootCms . getRequestContext ( ) . setAttribute ( CmsRequestContext . ATTRIBUTE_NEW_RESOURCE_LOCALE , userCms . getRequestContext ( ) . getLocale ( ) ) ; if ( modelResource != null ) { rootCms . getRequestContext ( ) . setAttribute ( CmsRequestContext . ATTRIBUTE_MODEL , modelResource . getRootPath ( ) ) ; } CmsResource createdResource = rootCms . createResource ( creationPath , getType ( ) , null , new ArrayList < CmsProperty > ( 0 ) ) ; if ( modelResource != null ) { CmsCategoryService . getInstance ( ) . copyCategories ( rootCms , modelResource , creationPath ) ; } try { rootCms . unlockResource ( creationPath ) ; } catch ( CmsLockException e ) { LOG . info ( e . getLocalizedMessage ( ) , e ) ; } return createdResource ; }
Creates a new element.<p>

@param userCms the CMS context to use
@param modelResource the model resource to use
@param pageFolderRootPath the root path of the folder containing the current container page

@return the created resource

@throws CmsException if something goes wrong