@Override
    public CmsResource createResource(
        CmsObject cms,
        CmsSecurityManager securityManager,
        String resourcename,
        byte[] content,
        List<CmsProperty> properties)
    throws CmsException {

        boolean hasModelUri = false;
        CmsXmlContainerPage newContent = null;
        if ((getSchema() != null) && ((content == null) || (content.length == 0))) {
            // unmarshal the content definition for the new resource
            CmsXmlContentDefinition contentDefinition = CmsXmlContentDefinition.unmarshal(cms, getSchema());

            // read the default locale for the new resource
            Locale locale = OpenCms.getLocaleManager().getDefaultLocales(
                cms,
                CmsResource.getParentFolder(resourcename)).get(0);

            String modelUri = (String)cms.getRequestContext().getAttribute(CmsRequestContext.ATTRIBUTE_MODEL);

            // must set URI of OpenCms user context to parent folder of created resource,
            // in order to allow reading of properties for default values
            CmsObject newCms = OpenCms.initCmsObject(cms);
            newCms.getRequestContext().setUri(CmsResource.getParentFolder(resourcename));
            if (modelUri != null) {
                // create the new content from the model file
                newContent = CmsXmlContainerPageFactory.createDocument(newCms, locale, modelUri);
                hasModelUri = true;
            } else {
                // create the new content from the content definition
                newContent = CmsXmlContainerPageFactory.createDocument(
                    newCms,
                    locale,
                    OpenCms.getSystemInfo().getDefaultEncoding(),
                    contentDefinition);
            }
            // get the bytes from the created content
            content = newContent.marshal();
        }

        // now create the resource using the super class
        CmsResource resource = super.createResource(cms, securityManager, resourcename, content, properties);

        // a model file was used, call the content handler for post-processing
        if (hasModelUri) {
            newContent = CmsXmlContainerPageFactory.unmarshal(cms, resource);
            resource = newContent.getHandler().prepareForWrite(cms, newContent, newContent.getFile());
        }

        return resource;
    }
@ Override public CmsResource createResource ( CmsObject cms , CmsSecurityManager securityManager , String resourcename , byte [ ] content , List < CmsProperty > properties ) throws CmsException { boolean hasModelUri = false ; CmsXmlContainerPage newContent = null ; if ( ( getSchema ( ) != null ) && ( ( content == null ) || ( content . length == 0 ) ) ) { CmsXmlContentDefinition contentDefinition = CmsXmlContentDefinition . unmarshal ( cms , getSchema ( ) ) ; Locale locale = OpenCms . getLocaleManager ( ) . getDefaultLocales ( cms , CmsResource . getParentFolder ( resourcename ) ) . get ( 0 ) ; String modelUri = ( String ) cms . getRequestContext ( ) . getAttribute ( CmsRequestContext . ATTRIBUTE_MODEL ) ; CmsObject newCms = OpenCms . initCmsObject ( cms ) ; newCms . getRequestContext ( ) . setUri ( CmsResource . getParentFolder ( resourcename ) ) ; if ( modelUri != null ) { newContent = CmsXmlContainerPageFactory . createDocument ( newCms , locale , modelUri ) ; hasModelUri = true ; } else { newContent = CmsXmlContainerPageFactory . createDocument ( newCms , locale , OpenCms . getSystemInfo ( ) . getDefaultEncoding ( ) , contentDefinition ) ; } content = newContent . marshal ( ) ; } CmsResource resource = super . createResource ( cms , securityManager , resourcename , content , properties ) ; if ( hasModelUri ) { newContent = CmsXmlContainerPageFactory . unmarshal ( cms , resource ) ; resource = newContent . getHandler ( ) . prepareForWrite ( cms , newContent , newContent . getFile ( ) ) ; } return resource ; }
@see org.opencms.file.types.CmsResourceTypeXmlContent#createResource(org.opencms.file.CmsObject, org.opencms.db.CmsSecurityManager, java.lang.String, byte[], java.util.List)