protected void processImportResource(CmsObject cms, CmsResourceImportData resData, int index) {

        boolean changed = false;
        m_report.print(
            org.opencms.report.Messages.get().container(
                org.opencms.report.Messages.RPT_ARGUMENT_1,
                "( " + index + " / " + m_moduleData.getResourceData().size() + " ) "),
            I_CmsReport.FORMAT_NOTE);
        m_report.print(Messages.get().container(Messages.RPT_IMPORTING_0), I_CmsReport.FORMAT_NOTE);
        m_report.print(
            org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_ARGUMENT_1, resData.getPath()));
        m_report.print(org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_DOTS_0));
        try {
            CmsResource oldRes = null;
            try {
                if (resData.hasStructureId()) {
                    oldRes = cms.readResource(
                        resData.getResource().getStructureId(),
                        CmsResourceFilter.IGNORE_EXPIRATION);
                } else {
                    oldRes = cms.readResource(resData.getPath(), CmsResourceFilter.IGNORE_EXPIRATION);
                }
            } catch (CmsVfsResourceNotFoundException e) {
                LOG.debug(e.getLocalizedMessage(), e);
            }
            CmsResource currentRes = oldRes;
            if (oldRes != null) {
                String oldPath = cms.getSitePath(oldRes);
                String newPath = resData.getPath();
                if (!CmsStringUtil.comparePaths(oldPath, resData.getPath())) {
                    cms.moveResource(oldPath, newPath);
                    changed = true;
                    currentRes = cms.readResource(oldRes.getStructureId(), CmsResourceFilter.IGNORE_EXPIRATION);
                }
            }
            boolean needsImport = true;
            boolean reducedExport = !resData.hasDateLastModified();
            byte[] content = resData.getContent();
            if (oldRes != null) {
                if (!resData.hasStructureId()) {
                    needsImport = false;
                } else if (oldRes.getState().isUnchanged()
                    && !needToUpdateResourceFields(oldRes, resData.getResource(), reducedExport)) {

                    // if resource is changed or new, we don't want to go into this code block
                    // because even if the content / metaadata are the same, we still want the file to be published at the end,
                    // so we import it to add it to the current working project

                    if (oldRes.isFile() && (content != null)) {
                        CmsFile file = cms.readFile(oldRes);
                        if (Arrays.equals(file.getContents(), content)) {
                            needsImport = false;
                        } else {
                            LOG.debug("Content mismatch for " + file.getRootPath());
                        }
                    } else {
                        needsImport = false;
                    }
                }
            }
            if (needsImport || (oldRes == null)) { // oldRes null check is redundant, we just do it to remove the warning in Eclipse
                currentRes = cms.importResource(
                    resData.getPath(),
                    resData.getResource(),
                    content,
                    new ArrayList<CmsProperty>());
                changed = true;
                m_importIds.add(currentRes.getStructureId());
            } else {
                currentRes = cms.readResource(oldRes.getStructureId(), CmsResourceFilter.ALL);
                CmsLock lock = cms.getLock(currentRes);
                if (lock.isUnlocked()) {
                    lock(cms, currentRes);
                }
            }
            resData.setImportResource(currentRes);
            List<CmsProperty> propsToWrite = compareProperties(cms, resData, currentRes);
            if (!propsToWrite.isEmpty()) {
                cms.writePropertyObjects(currentRes, propsToWrite);
                changed = true;
            }
            changed |= updateAcls(cms, resData, currentRes);
            if (changed) {
                m_report.println(
                    org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_OK_0),
                    I_CmsReport.FORMAT_OK);
            } else {
                m_report.println(
                    org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_SKIPPED_0),
                    I_CmsReport.FORMAT_NOTE);
            }

        } catch (Exception e) {
            m_report.println(e);
            LOG.error(e.getLocalizedMessage(), e);

        }
    }
protected void processImportResource ( CmsObject cms , CmsResourceImportData resData , int index ) { boolean changed = false ; m_report . print ( org . opencms . report . Messages . get ( ) . container ( org . opencms . report . Messages . RPT_ARGUMENT_1 , "( " + index + " / " + m_moduleData . getResourceData ( ) . size ( ) + " ) " ) , I_CmsReport . FORMAT_NOTE ) ; m_report . print ( Messages . get ( ) . container ( Messages . RPT_IMPORTING_0 ) , I_CmsReport . FORMAT_NOTE ) ; m_report . print ( org . opencms . report . Messages . get ( ) . container ( org . opencms . report . Messages . RPT_ARGUMENT_1 , resData . getPath ( ) ) ) ; m_report . print ( org . opencms . report . Messages . get ( ) . container ( org . opencms . report . Messages . RPT_DOTS_0 ) ) ; try { CmsResource oldRes = null ; try { if ( resData . hasStructureId ( ) ) { oldRes = cms . readResource ( resData . getResource ( ) . getStructureId ( ) , CmsResourceFilter . IGNORE_EXPIRATION ) ; } else { oldRes = cms . readResource ( resData . getPath ( ) , CmsResourceFilter . IGNORE_EXPIRATION ) ; } } catch ( CmsVfsResourceNotFoundException e ) { LOG . debug ( e . getLocalizedMessage ( ) , e ) ; } CmsResource currentRes = oldRes ; if ( oldRes != null ) { String oldPath = cms . getSitePath ( oldRes ) ; String newPath = resData . getPath ( ) ; if ( ! CmsStringUtil . comparePaths ( oldPath , resData . getPath ( ) ) ) { cms . moveResource ( oldPath , newPath ) ; changed = true ; currentRes = cms . readResource ( oldRes . getStructureId ( ) , CmsResourceFilter . IGNORE_EXPIRATION ) ; } } boolean needsImport = true ; boolean reducedExport = ! resData . hasDateLastModified ( ) ; byte [ ] content = resData . getContent ( ) ; if ( oldRes != null ) { if ( ! resData . hasStructureId ( ) ) { needsImport = false ; } else if ( oldRes . getState ( ) . isUnchanged ( ) && ! needToUpdateResourceFields ( oldRes , resData . getResource ( ) , reducedExport ) ) { if ( oldRes . isFile ( ) && ( content != null ) ) { CmsFile file = cms . readFile ( oldRes ) ; if ( Arrays . equals ( file . getContents ( ) , content ) ) { needsImport = false ; } else { LOG . debug ( "Content mismatch for " + file . getRootPath ( ) ) ; } } else { needsImport = false ; } } } if ( needsImport || ( oldRes == null ) ) { currentRes = cms . importResource ( resData . getPath ( ) , resData . getResource ( ) , content , new ArrayList < CmsProperty > ( ) ) ; changed = true ; m_importIds . add ( currentRes . getStructureId ( ) ) ; } else { currentRes = cms . readResource ( oldRes . getStructureId ( ) , CmsResourceFilter . ALL ) ; CmsLock lock = cms . getLock ( currentRes ) ; if ( lock . isUnlocked ( ) ) { lock ( cms , currentRes ) ; } } resData . setImportResource ( currentRes ) ; List < CmsProperty > propsToWrite = compareProperties ( cms , resData , currentRes ) ; if ( ! propsToWrite . isEmpty ( ) ) { cms . writePropertyObjects ( currentRes , propsToWrite ) ; changed = true ; } changed |= updateAcls ( cms , resData , currentRes ) ; if ( changed ) { m_report . println ( org . opencms . report . Messages . get ( ) . container ( org . opencms . report . Messages . RPT_OK_0 ) , I_CmsReport . FORMAT_OK ) ; } else { m_report . println ( org . opencms . report . Messages . get ( ) . container ( org . opencms . report . Messages . RPT_SKIPPED_0 ) , I_CmsReport . FORMAT_NOTE ) ; } } catch ( Exception e ) { m_report . println ( e ) ; LOG . error ( e . getLocalizedMessage ( ) , e ) ; } }
Processes single resource from module import data.

@param cms the CMS context to use
@param resData the resource data from the module import
@param index index of the current import resource