private boolean writeContent(CmsObject cmsObject, I_CmsReport report, CmsFile file, byte[] content) {

        boolean success = true;

        // get current lock from file
        try {
            // try to lock the resource
            if (!lockResource(cmsObject, file, report)) {
                report.println(
                    Messages.get().container(Messages.RPT_SOURCESEARCH_LOCKED_FILE_0, cmsObject.getSitePath(file)),
                    I_CmsReport.FORMAT_ERROR);
                success = false;
            }
        } catch (CmsException e) {
            report.println(
                Messages.get().container(Messages.RPT_SOURCESEARCH_LOCKED_FILE_0, cmsObject.getSitePath(file)),
                I_CmsReport.FORMAT_ERROR);
            if (LOG.isErrorEnabled()) {
                LOG.error(e.getMessageContainer(), e);
            }
            success = false;
        }

        // write the file content
        try {
            file.setContents(content);
            cmsObject.writeFile(file);
        } catch (Exception e) {
            m_errorUpdate += 1;
            report.println(
                org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_FAILED_0),
                I_CmsReport.FORMAT_ERROR);
            if (LOG.isErrorEnabled()) {
                LOG.error(e.toString());
            }
            success = false;
        }

        // unlock the resource
        try {
            cmsObject.unlockResource(cmsObject.getSitePath(file));
        } catch (CmsException e) {
            m_errorUpdate += 1;
            report.println(
                Messages.get().container(Messages.RPT_SOURCESEARCH_UNLOCK_FILE_0),
                I_CmsReport.FORMAT_WARNING);
            if (LOG.isErrorEnabled()) {
                LOG.error(e.getMessageContainer(), e);
            }
            success = false;
        }

        if (success) {
            // successfully updated
            report.println(
                org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_OK_0),
                I_CmsReport.FORMAT_OK);
        }

        return success;
    }
private boolean writeContent ( CmsObject cmsObject , I_CmsReport report , CmsFile file , byte [ ] content ) { boolean success = true ; try { if ( ! lockResource ( cmsObject , file , report ) ) { report . println ( Messages . get ( ) . container ( Messages . RPT_SOURCESEARCH_LOCKED_FILE_0 , cmsObject . getSitePath ( file ) ) , I_CmsReport . FORMAT_ERROR ) ; success = false ; } } catch ( CmsException e ) { report . println ( Messages . get ( ) . container ( Messages . RPT_SOURCESEARCH_LOCKED_FILE_0 , cmsObject . getSitePath ( file ) ) , I_CmsReport . FORMAT_ERROR ) ; if ( LOG . isErrorEnabled ( ) ) { LOG . error ( e . getMessageContainer ( ) , e ) ; } success = false ; } try { file . setContents ( content ) ; cmsObject . writeFile ( file ) ; } catch ( Exception e ) { m_errorUpdate += 1 ; report . println ( org . opencms . report . Messages . get ( ) . container ( org . opencms . report . Messages . RPT_FAILED_0 ) , I_CmsReport . FORMAT_ERROR ) ; if ( LOG . isErrorEnabled ( ) ) { LOG . error ( e . toString ( ) ) ; } success = false ; } try { cmsObject . unlockResource ( cmsObject . getSitePath ( file ) ) ; } catch ( CmsException e ) { m_errorUpdate += 1 ; report . println ( Messages . get ( ) . container ( Messages . RPT_SOURCESEARCH_UNLOCK_FILE_0 ) , I_CmsReport . FORMAT_WARNING ) ; if ( LOG . isErrorEnabled ( ) ) { LOG . error ( e . getMessageContainer ( ) , e ) ; } success = false ; } if ( success ) { report . println ( org . opencms . report . Messages . get ( ) . container ( org . opencms . report . Messages . RPT_OK_0 ) , I_CmsReport . FORMAT_OK ) ; } return success ; }
Writes the file contents.<p>

@param cmsObject the cms context
@param report the report
@param file the file to write
@param content the file content

@return success flag