Performs the undo changes operation on a resource.<p>

@return true, if the changes on a resource were undone, otherwise false
@throws CmsException if undo changes is not successful
332400
@Override
    protected boolean performDialogOperation() throws CmsException {

        // check if the current resource is a folder for single operation
        boolean isFolder = isOperationOnFolder();
        // on folder undo changes or multi operation display "please wait" screen, not for simple file undo changes
        if ((isMultiOperation() || isFolder) && !DIALOG_WAIT.equals(getParamAction())) {
            // return false, this will trigger the "please wait" screen
            return false;
        }

        // get the flag if the undo changes is recursive from request parameter
        boolean undoRecursive = Boolean.valueOf(getParamRecursive()).booleanValue();
        boolean undoMove = Boolean.valueOf(getParamMove()).booleanValue();

        CmsResourceUndoMode mode = CmsResource.UNDO_CONTENT;
        if (undoRecursive) {
            mode = CmsResource.UNDO_CONTENT_RECURSIVE;
        }
        if (undoMove) {
            mode = mode.includeMove();
        }

        Iterator<String> i = getResourceList().iterator();
        // iterate the resources to delete
        while (i.hasNext()) {
            String resName = i.next();
            try {
                // lock resource if autolock is enabled
                checkLock(resName);
                // undo changes on the resource
                getCms().undoChanges(resName, mode);
            } catch (CmsException e) {
                if (isMultiOperation()) {
                    // collect exceptions to create a detailed output
                    addMultiOperationException(e);
                } else {
                    // for single operation, throw the exception immediately
                    throw e;
                }
            }
        }
        // check if exceptions occurred
        checkMultiOperationException(Messages.get(), Messages.ERR_UNDO_CHANGES_MULTI_0);

        return true;
    }
1077349
public boolean undo() {
    LOGGER.trace("undo, before, size: " + changes.size() + " pos: " + position.get()
        + " validPos: " + validPosition.get());
    Change lastChange = prev();
    if (lastChange != null) {
      doWithoutListeners(lastChange.getSetting(), lastChange::undo);
      LOGGER.trace("undo, after, size: " + changes.size() + " pos: " + position.get()
          + " validPos: " + validPosition.get());
      return true;
    }
    return false;
  }
56919
@Override
    protected boolean performDialogOperation() throws CmsException {

        // check if the current resource is a folder for single operation
        boolean isFolder = isOperationOnFolder();

        // on folder copy display "please wait" screen, not for simple file copy
        if ((isMultiOperation() || isFolder) && !DIALOG_WAIT.equals(getParamAction())) {
            // return false, this will trigger the "please wait" screen
            return false;
        }

        // get the copy mode from request parameter value
        CmsResourceCopyMode copyMode = CmsResource.COPY_PRESERVE_SIBLING;
        try {
            copyMode = CmsResourceCopyMode.valueOf(Integer.parseInt(getParamCopymode()));
        } catch (Exception e) {
            // can usually be ignored
            if (LOG.isInfoEnabled()) {
                LOG.info(e.getLocalizedMessage());
            }
        }

        // check the overwrite options
        boolean overwrite = Boolean.valueOf(getParamOverwrite()).booleanValue();
        overwrite = ((isMultiOperation() && overwrite) || DIALOG_CONFIRMED.equals(getParamAction()));

        // calculate the target name
        String target = getParamTarget();
        if (target == null) {
            target = "";
        }

        String storedSiteRoot = null;
        try {
            // check if a site root was added to the target name
            String sitePrefix = "";
            if (OpenCms.getSiteManager().getSiteRoot(target) != null) {
                String siteRootFolder = getCms().getRequestContext().getSiteRoot();
                if (siteRootFolder.endsWith("/")) {
                    siteRootFolder = siteRootFolder.substring(0, siteRootFolder.length() - 1);
                }
                sitePrefix = siteRootFolder;
                storedSiteRoot = getCms().getRequestContext().getSiteRoot();
                getCms().getRequestContext().setSiteRoot("/");
            }

            Iterator<String> i = getResourceList().iterator();
            // iterate the resources to copy
            while (i.hasNext()) {
                String resName = i.next();
                try {
                    performSingleCopyOperation(resName, target, sitePrefix, copyMode, overwrite);
                } catch (CmsException e) {
                    if (isMultiOperation()) {
                        // collect exceptions to create a detailed output
                        addMultiOperationException(e);
                    } else {
                        // for single operation, throw the exception immediately
                        throw e;
                    }
                }
            }
            // check if exceptions occurred
            checkMultiOperationException(Messages.get(), Messages.ERR_COPY_MULTI_0);
        } finally {
            // restore the site root
            if (storedSiteRoot != null) {
                getCms().getRequestContext().setSiteRoot(storedSiteRoot);
            }
        }
        return true;
    }
1122791
protected boolean performEditOperation(HttpServletRequest request) throws CmsException {

        boolean useTempfileProject = Boolean.valueOf(getParamUsetempfileproject()).booleanValue();
        try {
            if (useTempfileProject) {
                switchToTempProject();
            }
            // write the common properties defined in the explorer type settings
            Iterator<String> i = getExplorerTypeSettings().getProperties().iterator();
            // iterate over the properties
            while (i.hasNext()) {
                String curProperty = i.next();
                String paramValue = request.getParameter(PREFIX_VALUE + curProperty);
                String oldValue = request.getParameter(PREFIX_HIDDEN + curProperty);
                writeProperty(curProperty, paramValue, oldValue);
            }

            // write the navigation properties if enabled
            if (showNavigation()) {
                // get the navigation enabled parameter
                String paramValue = request.getParameter("enablenav");
                String oldValue = null;
                if (Boolean.valueOf(paramValue).booleanValue()) {
                    // navigation enabled, update params
                    paramValue = request.getParameter("navpos");
                    if (!"-1".equals(paramValue) && !String.valueOf(Float.MAX_VALUE).equals(paramValue)) {
                        // update the property only when it is different from "-1" (meaning no change)
                        oldValue = request.getParameter(PREFIX_HIDDEN + CmsPropertyDefinition.PROPERTY_NAVPOS);
                        writeProperty(CmsPropertyDefinition.PROPERTY_NAVPOS, paramValue, oldValue);
                    }
                    paramValue = request.getParameter(PREFIX_VALUE + CmsPropertyDefinition.PROPERTY_NAVTEXT);
                    oldValue = request.getParameter(PREFIX_HIDDEN + CmsPropertyDefinition.PROPERTY_NAVTEXT);
                    writeProperty(CmsPropertyDefinition.PROPERTY_NAVTEXT, paramValue, oldValue);
                } else {
                    // navigation disabled, delete property values
                    writeProperty(CmsPropertyDefinition.PROPERTY_NAVPOS, null, null);
                    writeProperty(CmsPropertyDefinition.PROPERTY_NAVTEXT, null, null);
                }
            }
        } finally {
            if (useTempfileProject) {
                switchToCurrentProject();
            }
        }
        return true;
    }
749857
boolean undoChanges() {
        final State state = stateUpdater.getAndSet(this, State.ROLLBACK_ONLY);
        if (state == State.COMPLETED || state == State.ROLLBACK_ONLY) {
            // Was actually completed already
            return false;
        }
        PatchingTaskContext.Mode currentMode = this.mode;
        mode = PatchingTaskContext.Mode.UNDO;
        final PatchContentLoader loader = PatchContentLoader.create(miscBackup, null, null);
        // Undo changes for the identity
        undoChanges(identityEntry, loader);
        // TODO maybe check if we need to do something for the layers too !?
        if (state == State.INVALIDATE || currentMode == PatchingTaskContext.Mode.ROLLBACK) {
            // For apply the state needs to be invalidate
            // For rollback the files are invalidated as part of the tasks
            final PatchingTaskContext.Mode mode = currentMode == PatchingTaskContext.Mode.APPLY ? PatchingTaskContext.Mode.ROLLBACK : PatchingTaskContext.Mode.APPLY;
            for (final File file : moduleInvalidations) {
                try {
                    PatchModuleInvalidationUtils.processFile(this, file, mode);
                } catch (Exception e) {
                    PatchLogger.ROOT_LOGGER.debugf(e, "failed to restore state for %s", file);
                }
            }
            if(!modulesToReenable.isEmpty()) {
                for (final File file : modulesToReenable) {
                    try {
                        PatchModuleInvalidationUtils.processFile(this, file, PatchingTaskContext.Mode.APPLY);
                    } catch (Exception e) {
                        PatchLogger.ROOT_LOGGER.debugf(e, "failed to restore state for %s", file);
                    }
                }
            }
            if(!modulesToDisable.isEmpty()) {
                for (final File file : modulesToDisable) {
                    try {
                        PatchModuleInvalidationUtils.processFile(this, file, PatchingTaskContext.Mode.ROLLBACK);
                    } catch (Exception e) {
                        PatchLogger.ROOT_LOGGER.debugf(e, "failed to restore state for %s", file);
                    }
                }
            }
        }
        return true;
    }
58436
public boolean hasCorrectLockstate() {

        org.opencms.lock.CmsLock lock = null;
        try {
            // get the lock state for the current resource
            lock = getCms().getLock(getParamResource());
        } catch (CmsException e) {
            // error getting lock state, log the error and return false
            LOG.error(e.getLocalizedMessage(getLocale()), e);
            return false;
        }
        // check if auto lock feature is enabled
        boolean autoLockFeature = lock.isNullLock() && OpenCms.getWorkplaceManager().autoLockResources();
        return autoLockFeature || lock.isExclusive() || lock.isInherited();
    }
590283
protected void init() throws CmsException {

        m_cms = OpenCms.initCmsObject(m_cms);
        // we want to use autocorrection when writing XML contents back
        //m_cms.getRequestContext().setAttribute(CmsXmlContent.AUTO_CORRECTION_ATTRIBUTE, Boolean.TRUE);
        m_cms.getRequestContext().setSiteRoot("");
        List<CmsPair<CmsResource, CmsResource>> allMatchingResources = Lists.newArrayList();
        for (CmsPair<String, String> pair : m_sourceTargetPairs) {
            List<CmsPair<CmsResource, CmsResource>> matchingResources = getMatchingResources(
                pair.getFirst(),
                pair.getSecond());
            allMatchingResources.addAll(matchingResources);
        }
        for (CmsPair<CmsResource, CmsResource> resPair : allMatchingResources) {
            CmsResource source = resPair.getFirst();
            CmsResource target = resPair.getSecond();
            m_translationsById.put(source.getStructureId(), target);
            m_translationsByPath.put(source.getRootPath(), target);
        }
    }
349389
boolean isEditable(CmsObject cms, CmsResource resource) {

        try {
            return cms.hasPermissions(resource, CmsPermissionSet.ACCESS_WRITE, false, CmsResourceFilter.ALL);
        } catch (CmsException e) {
            return false;
        }
    }
213479
private CmsClientSitemapEntry delete(CmsSitemapChange change) throws CmsException {

        CmsObject cms = getCmsObject();
        CmsResource resource = cms.readResource(change.getEntryId(), CmsResourceFilter.ONLY_VISIBLE_NO_DELETED);
        ensureLock(resource);
        cms.deleteResource(cms.getSitePath(resource), CmsResource.DELETE_PRESERVE_SIBLINGS);
        tryUnlock(resource);
        return null;
    }
1144941
private void deleteResourceFromProject(CmsObject cms, CmsResource res) throws CmsException {

        CmsLock lock = cms.getLock(res);
        if (lock.isUnlocked() || lock.isLockableBy(cms.getRequestContext().getCurrentUser())) {
            cms.lockResourceTemporary(res);
        } else {
            cms.changeLock(res);
        }
        cms.deleteResource(cms.getSitePath(res), CmsResource.DELETE_PRESERVE_SIBLINGS);
    }
668049
protected boolean remove(CmsResource resource) {

        // it is essential that this method is only visible within the db package!
        boolean ret = m_fileList.remove(resource);
        ret |= m_folderList.remove(resource);
        ret |= m_deletedFolderList.remove(resource);
        return ret;
    }
789863
public boolean isEditable() {

        if (m_request == null) {
            return false;
        }
        CmsExplorerTypeSettings settings = OpenCms.getWorkplaceManager().getExplorerTypeSetting(getResourceTypeName());
        if (settings != null) {
            String rightSite = OpenCms.getSiteManager().getSiteRoot(getResource().getRootPath());
            if (rightSite == null) {
                rightSite = "";
            }
            String currentSite = getCms().getRequestContext().getSiteRoot();
            try {
                getCms().getRequestContext().setSiteRoot(rightSite);
                return settings.isEditable(getCms(), getResource());
            } finally {
                getCms().getRequestContext().setSiteRoot(currentSite);
            }
        }
        return false;
    }
955359
private boolean performDialogOperation(HttpServletRequest request) throws CmsException {

        List<CmsPropertyDefinition> propertyDef = getCms().readAllPropertyDefinitions();
        boolean useTempfileProject = Boolean.valueOf(getParamUsetempfileproject()).booleanValue();
        try {
            if (useTempfileProject) {
                switchToTempProject();
            }
            Map<String, CmsProperty> activeProperties = getActiveProperties();
            String activeTab = getActiveTabName();
            List<CmsProperty> propertiesToWrite = new ArrayList<CmsProperty>();

            // check all property definitions of the resource for new values
            Iterator<CmsPropertyDefinition> i = propertyDef.iterator();
            while (i.hasNext()) {
                CmsPropertyDefinition curPropDef = i.next();
                String propName = CmsEncoder.escapeXml(curPropDef.getName());
                String valueStructure = null;
                String valueResource = null;

                if (key(Messages.GUI_PROPERTIES_INDIVIDUAL_0).equals(activeTab)) {
                    // get parameters from the structure tab
                    valueStructure = request.getParameter(PREFIX_VALUE + propName);
                    valueResource = request.getParameter(PREFIX_RESOURCE + propName);
                    if ((valueStructure != null)
                        && !"".equals(valueStructure.trim())
                        && valueStructure.equals(valueResource)) {
                        // the resource value was shown/entered in input field, set structure value to empty String
                        valueStructure = "";
                    }
                } else {
                    // get parameters from the resource tab
                    valueStructure = request.getParameter(PREFIX_STRUCTURE + propName);
                    valueResource = request.getParameter(PREFIX_VALUE + propName);
                }

                // check values for blanks and null
                if (valueStructure != null) {
                    valueStructure = valueStructure.trim();
                }

                if (valueResource != null) {
                    valueResource = valueResource.trim();
                }

                // create new CmsProperty object to store
                CmsProperty newProperty = new CmsProperty();
                newProperty.setName(curPropDef.getName());
                newProperty.setStructureValue(valueStructure);
                newProperty.setResourceValue(valueResource);

                // get the old property values
                CmsProperty oldProperty = activeProperties.get(curPropDef.getName());
                if (oldProperty == null) {
                    // property was not set, create new empty property object
                    oldProperty = new CmsProperty();
                    oldProperty.setName(curPropDef.getName());
                }

                boolean writeStructureValue = false;
                boolean writeResourceValue = false;
                String oldValue = oldProperty.getStructureValue();
                String newValue = newProperty.getStructureValue();

                // write the structure value if the existing structure value is not null and we want to delete the structure value
                writeStructureValue = ((oldValue != null) && newProperty.isDeleteStructureValue());
                // or if we want to write a value which is neither the delete value or an empty value
                writeStructureValue |= !newValue.equals(oldValue)
                    && !"".equalsIgnoreCase(newValue)
                    && !CmsProperty.DELETE_VALUE.equalsIgnoreCase(newValue);
                // set the structure value explicitly to null to leave it as is in the database
                if (!writeStructureValue) {
                    newProperty.setStructureValue(null);
                }

                oldValue = oldProperty.getResourceValue();
                newValue = newProperty.getResourceValue();

                // write the resource value if the existing resource value is not null and we want to delete the resource value
                writeResourceValue = ((oldValue != null) && newProperty.isDeleteResourceValue());
                // or if we want to write a value which is neither the delete value or an empty value
                writeResourceValue |= !newValue.equals(oldValue)
                    && !"".equalsIgnoreCase(newValue)
                    && !CmsProperty.DELETE_VALUE.equalsIgnoreCase(newValue);
                // set the resource value explicitly to null to leave it as is in the database
                if (!writeResourceValue) {
                    newProperty.setResourceValue(null);
                }

                if (writeStructureValue || writeResourceValue) {
                    // add property to list only if property values have changed
                    propertiesToWrite.add(newProperty);
                }
            }
            if (propertiesToWrite.size() > 0) {
                // lock resource if autolock is enabled
                checkLock(getParamResource());
                //write the new property values
                getCms().writePropertyObjects(getParamResource(), propertiesToWrite);
            }
        } finally {
            if (useTempfileProject) {
                switchToCurrentProject();
            }
        }
        return true;
    }
161373
protected List<CmsUUID> undelete() throws CmsException {

        List<CmsUUID> modifiedResources = new ArrayList<CmsUUID>();
        CmsObject cms = m_context.getCms();
        for (CmsResource resource : m_context.getResources()) {
            CmsLockActionRecord actionRecord = null;
            try {
                actionRecord = CmsLockUtil.ensureLock(m_context.getCms(), resource);
                cms.undeleteResource(cms.getSitePath(resource), true);
                modifiedResources.add(resource.getStructureId());
            } finally {
                if ((actionRecord != null) && (actionRecord.getChange() == LockChange.locked)) {

                    try {
                        cms.unlockResource(resource);
                    } catch (CmsLockException e) {
                        LOG.warn(e.getLocalizedMessage(), e);
                    }
                }
            }
        }
        return modifiedResources;
    }
256957
protected void performRestoreOperation() throws CmsException {

        CmsUUID structureId = new CmsUUID(getSelectedItem().get(LIST_COLUMN_STRUCTURE_ID).toString());
        int version = Integer.parseInt(getSelectedItems().get(0).getId());
        if (version == CmsHistoryResourceHandler.PROJECT_OFFLINE_VERSION) {
            // it is not possible to restore the offline version
            return;
        }
        CmsResource res = getCms().readResource(structureId, CmsResourceFilter.IGNORE_EXPIRATION);
        checkLock(getCms().getSitePath(res));
        getCms().restoreResourceVersion(res.getStructureId(), version);
    }
721238
void unlockCurrent() {

        if (m_currentResource != null) {
            if ((m_lockAction != null) && m_lockAction.getChange().equals(LockChange.locked)) {
                CmsLockUtil.tryUnlock(A_CmsUI.getCmsObject(), m_currentResource);
            }
        }
        m_lockAction = null;
    }
70587
public boolean shouldIncrementVersionBasedOnResources(CmsObject cms) throws CmsException {

        if (m_checkpointTime == 0) {
            return true;
        }

        // adjust the site root, if necessary
        CmsObject cmsClone = adjustSiteRootIfNecessary(cms, this);

        // calculate the module resources
        List<CmsResource> moduleResources = calculateModuleResources(cmsClone, this);

        for (CmsResource resource : moduleResources) {
            try {
                List<CmsResource> resourcesToCheck = Lists.newArrayList();
                resourcesToCheck.add(resource);
                if (resource.isFolder()) {
                    resourcesToCheck.addAll(cms.readResources(resource, CmsResourceFilter.IGNORE_EXPIRATION, true));
                }
                for (CmsResource resourceToCheck : resourcesToCheck) {
                    if (resourceToCheck.getDateLastModified() > m_checkpointTime) {
                        return true;
                    }
                }
            } catch (CmsException e) {
                LOG.warn(e.getLocalizedMessage(), e);
                continue;
            }
        }
        return false;
    }