protected void performSingleOperation(
        CmsResource source,
        CmsResource target,
        String name,
        Action action,
        boolean overwrite,
        Map<String, String> macroMap)
    throws CmsException {

        // add new parent and source to the update resources
        m_updateResources.add(target.getStructureId());
        m_updateResources.add(source.getStructureId());

        String finalTarget = target.getRootPath();
        if (finalTarget.equals(source.getRootPath()) || finalTarget.startsWith(source.getRootPath())) {
            throw new CmsVfsException(
                org.opencms.workplace.commons.Messages.get().container(
                    org.opencms.workplace.commons.Messages.ERR_COPY_ONTO_ITSELF_1,
                    finalTarget));
        }
        finalTarget = CmsStringUtil.joinPaths(finalTarget, name);
        // delete existing target resource if selected or confirmed by the user
        if (overwrite && getRootCms().existsResource(finalTarget, CmsResourceFilter.ONLY_VISIBLE)) {
            CmsLockUtil.ensureLock(
                getRootCms(),
                getRootCms().readResource(finalTarget, CmsResourceFilter.ONLY_VISIBLE));
            if (getRootCms().existsResource(finalTarget, CmsResourceFilter.ONLY_VISIBLE_NO_DELETED)) {
                if ((action != Action.container_page_automatic)
                    && (action != Action.container_page_copy)
                    && (action != Action.container_page_reuse)) {
                    // container page copy modes don't just call copyResource(), they need special handling for the overwrite case
                    getRootCms().deleteResource(finalTarget, CmsResource.DELETE_PRESERVE_SIBLINGS);
                }
            }
        }
        // copy the resource
        if (action == Action.move) {
            // add former parent to the update resources
            CmsResource parent = getRootCms().readParentFolder(source.getStructureId());
            m_updateResources.add(parent.getStructureId());
            CmsLockActionRecord lockRecord = CmsLockUtil.ensureLock(getRootCms(), source);
            getRootCms().moveResource(source.getRootPath(), finalTarget);
            if (lockRecord.getChange() == CmsLockActionRecord.LockChange.locked) {
                getRootCms().unlockResource(finalTarget);
            }
        } else if ((action == Action.container_page_automatic)
            || (action == Action.container_page_copy)
            || (action == Action.container_page_reuse)) {
            CmsContainerPageCopier copier = new CmsContainerPageCopier(m_context.getCms());
            try {

                CmsContainerPageCopier.CopyMode mode = action == Action.container_page_automatic
                ? CmsContainerPageCopier.CopyMode.automatic
                : (action == Action.container_page_copy
                ? CmsContainerPageCopier.CopyMode.smartCopyAndChangeLocale
                : CmsContainerPageCopier.CopyMode.reuse);
                copier.setCopyMode(mode);
                copier.run(m_context.getResources().get(0), target, name);
                m_context.finish(
                    Arrays.asList(
                        copier.getTargetFolder().getStructureId(),
                        copier.getCopiedFolderOrPage().getStructureId()));
            } catch (CmsException e) {
                m_context.error(e);
            } catch (NoCustomReplacementException e) {
                String errorMessage = CmsVaadinUtils.getMessageText(
                    org.opencms.ui.Messages.GUI_COPYPAGE_NO_REPLACEMENT_FOUND_1,
                    e.getResource().getRootPath());
                CmsErrorDialog.showErrorDialog(errorMessage, e);
            }
        } else {

            CmsResourceCopyMode copyMode = null;
            switch ((Action)m_actionCombo.getValue()) {
                case copy_all:
                    copyMode = CmsResource.COPY_AS_NEW;
                    break;
                case copy_sibling_all:
                    copyMode = CmsResource.COPY_AS_SIBLING;
                    break;
                case copy_sibling_mixed:
                case sub_sitemap:
                default:
                    copyMode = CmsResource.COPY_PRESERVE_SIBLING;
            }

            //Copies resources. Adjust links if action==Action.sub_sitemap, resolves macro if marcoMap if not null or empty
            CmsMacroResolver.copyAndResolveMacro(
                getRootCms(),
                source.getRootPath(),
                finalTarget,
                macroMap,
                action == Action.sub_sitemap,
                copyMode);

            getRootCms().unlockResource(finalTarget);

            CmsResource copyResource = getRootCms().readResource(finalTarget);
            m_updateResources.add(copyResource.getStructureId());
        }
    }
protected void performSingleOperation ( CmsResource source , CmsResource target , String name , Action action , boolean overwrite , Map < String , String > macroMap ) throws CmsException { m_updateResources . add ( target . getStructureId ( ) ) ; m_updateResources . add ( source . getStructureId ( ) ) ; String finalTarget = target . getRootPath ( ) ; if ( finalTarget . equals ( source . getRootPath ( ) ) || finalTarget . startsWith ( source . getRootPath ( ) ) ) { throw new CmsVfsException ( org . opencms . workplace . commons . Messages . get ( ) . container ( org . opencms . workplace . commons . Messages . ERR_COPY_ONTO_ITSELF_1 , finalTarget ) ) ; } finalTarget = CmsStringUtil . joinPaths ( finalTarget , name ) ; if ( overwrite && getRootCms ( ) . existsResource ( finalTarget , CmsResourceFilter . ONLY_VISIBLE ) ) { CmsLockUtil . ensureLock ( getRootCms ( ) , getRootCms ( ) . readResource ( finalTarget , CmsResourceFilter . ONLY_VISIBLE ) ) ; if ( getRootCms ( ) . existsResource ( finalTarget , CmsResourceFilter . ONLY_VISIBLE_NO_DELETED ) ) { if ( ( action != Action . container_page_automatic ) && ( action != Action . container_page_copy ) && ( action != Action . container_page_reuse ) ) { getRootCms ( ) . deleteResource ( finalTarget , CmsResource . DELETE_PRESERVE_SIBLINGS ) ; } } } if ( action == Action . move ) { CmsResource parent = getRootCms ( ) . readParentFolder ( source . getStructureId ( ) ) ; m_updateResources . add ( parent . getStructureId ( ) ) ; CmsLockActionRecord lockRecord = CmsLockUtil . ensureLock ( getRootCms ( ) , source ) ; getRootCms ( ) . moveResource ( source . getRootPath ( ) , finalTarget ) ; if ( lockRecord . getChange ( ) == CmsLockActionRecord . LockChange . locked ) { getRootCms ( ) . unlockResource ( finalTarget ) ; } } else if ( ( action == Action . container_page_automatic ) || ( action == Action . container_page_copy ) || ( action == Action . container_page_reuse ) ) { CmsContainerPageCopier copier = new CmsContainerPageCopier ( m_context . getCms ( ) ) ; try { CmsContainerPageCopier . CopyMode mode = action == Action . container_page_automatic ? CmsContainerPageCopier . CopyMode . automatic : ( action == Action . container_page_copy ? CmsContainerPageCopier . CopyMode . smartCopyAndChangeLocale : CmsContainerPageCopier . CopyMode . reuse ) ; copier . setCopyMode ( mode ) ; copier . run ( m_context . getResources ( ) . get ( 0 ) , target , name ) ; m_context . finish ( Arrays . asList ( copier . getTargetFolder ( ) . getStructureId ( ) , copier . getCopiedFolderOrPage ( ) . getStructureId ( ) ) ) ; } catch ( CmsException e ) { m_context . error ( e ) ; } catch ( NoCustomReplacementException e ) { String errorMessage = CmsVaadinUtils . getMessageText ( org . opencms . ui . Messages . GUI_COPYPAGE_NO_REPLACEMENT_FOUND_1 , e . getResource ( ) . getRootPath ( ) ) ; CmsErrorDialog . showErrorDialog ( errorMessage , e ) ; } } else { CmsResourceCopyMode copyMode = null ; switch ( ( Action ) m_actionCombo . getValue ( ) ) { case copy_all : copyMode = CmsResource . COPY_AS_NEW ; break ; case copy_sibling_all : copyMode = CmsResource . COPY_AS_SIBLING ; break ; case copy_sibling_mixed : case sub_sitemap : default : copyMode = CmsResource . COPY_PRESERVE_SIBLING ; } CmsMacroResolver . copyAndResolveMacro ( getRootCms ( ) , source . getRootPath ( ) , finalTarget , macroMap , action == Action . sub_sitemap , copyMode ) ; getRootCms ( ) . unlockResource ( finalTarget ) ; CmsResource copyResource = getRootCms ( ) . readResource ( finalTarget ) ; m_updateResources . add ( copyResource . getStructureId ( ) ) ; } }
Performs the single resource operation.<p>

@param source the source
@param target the target folder
@param name the target resource name
@param action the action
@param overwrite if existing resources should be overwritten
@param macroMap map of key-value pairs to be resolved as macro. if null or empty, then ignored

@throws CmsException in case the operation fails