Performs the lock/unlock/steal lock operation.<p>

@return true, if the operation was performed, otherwise false
@throws CmsException if operation is not successful
199768
@Override
    protected boolean performDialogOperation() throws CmsException {

        //on multi resource operation display "please wait" screen
        if (isMultiOperation() && !DIALOG_WAIT.equals(getParamAction())) {
            return false;
        }
        // determine action to perform (lock, unlock, change lock)
        int dialogAction = getDialogAction(getCms());

        // now perform the operation on the resource(s)
        Iterator<String> i = getResourceList().iterator();
        while (i.hasNext()) {
            String resName = i.next();
            try {
                performSingleResourceOperation(resName, dialogAction);
            } catch (CmsException e) {
                // collect exceptions to create a detailed output
                addMultiOperationException(e);
            }
        }
        // generate the error message for exception
        String message;
        if (dialogAction == TYPE_LOCK) {
            message = Messages.ERR_LOCK_MULTI_0;
        } else {
            message = Messages.ERR_UNLOCK_MULTI_0;
        }
        checkMultiOperationException(Messages.get(), message);

        return true;
    }
1358071
public void readLocks() throws CmsException {

        CmsDbContext dbc = m_dbContextFactory.getDbContext();
        try {
            m_driverManager.readLocks(dbc);
        } finally {
            dbc.clear();
        }
    }
89772
private CmsClientLock generateClientLock(CmsResource resource) throws CmsException {

        CmsObject cms = getCmsObject();
        CmsLock lock = cms.getLock(resource);
        CmsClientLock clientLock = new CmsClientLock();
        clientLock.setLockType(CmsClientLock.LockType.valueOf(lock.getType().getMode()));
        CmsUUID ownerId = lock.getUserId();
        if (!lock.isUnlocked() && (ownerId != null)) {
            clientLock.setLockOwner(cms.readUser(ownerId).getDisplayName(cms, cms.getRequestContext().getLocale()));
            clientLock.setOwnedByUser(cms.getRequestContext().getCurrentUser().getId().equals(ownerId));
        }
        return clientLock;
    }
111498
protected boolean performDialogOperation() throws CmsException, ParseException {

        // get the request parameters for resource and publish scheduled date
        String resource = getParamResource();
        String publishScheduledDate = getParamPublishscheduleddate();
        String userName = getCms().getRequestContext().getCurrentUser().getName();

        // get the java date format
        //        DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, getLocale());
        //        dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        //        Date date = dateFormat.parse(publishScheduledDate);
        long lDate = org.opencms.widgets.CmsCalendarWidget.getCalendarDate(getMessages(), publishScheduledDate, true);
        Date date = new Date(lDate);

        // check if the selected date is in the future
        if (date.getTime() < new Date().getTime()) {
            // the selected date in in the past, this is not possible
            throw new CmsException(Messages.get().container(Messages.ERR_PUBLISH_SCHEDULED_DATE_IN_PAST_1, date));
        }

        // make copies from the admin cmsobject and the user cmsobject
        // get the admin cms object
        CmsWorkplaceAction action = CmsWorkplaceAction.getInstance();
        CmsObject cmsAdmin = action.getCmsAdminObject();
        // get the user cms object
        CmsObject cms = OpenCms.initCmsObject(getCms());

        // set the current user site to the admin cms object
        cmsAdmin.getRequestContext().setSiteRoot(cms.getRequestContext().getSiteRoot());

        String rootPath = getCms().getRequestContext().addSiteRoot(resource);
        String projectName = computeProjectName(rootPath, date);
        CmsProject tmpProject = null;
        try {
            // create the project
            tmpProject = cmsAdmin.createProject(
                projectName,
                "",
                CmsRole.WORKPLACE_USER.getGroupName(),
                CmsRole.PROJECT_MANAGER.getGroupName(),
                CmsProject.PROJECT_TYPE_TEMPORARY);
        } catch (CmsException e) {
            String resName = CmsResource.getName(rootPath);
            if (resName.length() > 64) {
                resName = resName.substring(0, 64) + "...";
            }
            // use UUID to make sure the project name is still unique
            projectName = computeProjectName(resName, date) + " [" + new CmsUUID() + "]";
            // create the project
            tmpProject = cmsAdmin.createProject(
                projectName,
                "",
                CmsRole.WORKPLACE_USER.getGroupName(),
                CmsRole.PROJECT_MANAGER.getGroupName(),
                CmsProject.PROJECT_TYPE_TEMPORARY);
        }
        // make the project invisible for all users
        tmpProject.setHidden(true);
        // write the project to the database
        cmsAdmin.writeProject(tmpProject);
        // set project as current project
        cmsAdmin.getRequestContext().setCurrentProject(tmpProject);
        cms.getRequestContext().setCurrentProject(tmpProject);

        // copy the resource to the project
        cmsAdmin.copyResourceToProject(resource);

        // lock the resource in the current project
        CmsLock lock = cms.getLock(resource);
        // prove is current lock from current but not in current project
        if ((lock != null)
            && lock.isOwnedBy(cms.getRequestContext().getCurrentUser())
            && !lock.isOwnedInProjectBy(
                cms.getRequestContext().getCurrentUser(),
                cms.getRequestContext().getCurrentProject())) {
            // file is locked by current user but not in current project
            // change the lock from this file
            cms.changeLock(resource);
        }
        // lock resource from current user in current project
        cms.lockResource(resource);
        // get current lock
        lock = cms.getLock(resource);

        // create a new scheduled job
        CmsScheduledJobInfo job = new CmsScheduledJobInfo();
        // the job name
        String jobName = projectName;
        // set the job parameters
        job.setJobName(jobName);
        job.setClassName("org.opencms.scheduler.jobs.CmsPublishScheduledJob");
        // create the cron expression
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        String cronExpr = ""
            + calendar.get(Calendar.SECOND)
            + " "
            + calendar.get(Calendar.MINUTE)
            + " "
            + calendar.get(Calendar.HOUR_OF_DAY)
            + " "
            + calendar.get(Calendar.DAY_OF_MONTH)
            + " "
            + (calendar.get(Calendar.MONTH) + 1)
            + " "
            + "?"
            + " "
            + calendar.get(Calendar.YEAR);
        // set the cron expression
        job.setCronExpression(cronExpr);
        // set the job active
        job.setActive(true);
        // create the context info
        CmsContextInfo contextInfo = new CmsContextInfo();
        contextInfo.setProjectName(projectName);
        contextInfo.setUserName(cmsAdmin.getRequestContext().getCurrentUser().getName());
        // create the job schedule parameter
        SortedMap<String, String> params = new TreeMap<String, String>();
        // the user to send mail to
        params.put(CmsPublishScheduledJob.PARAM_USER, userName);
        // the job name
        params.put(CmsPublishScheduledJob.PARAM_JOBNAME, jobName);
        // the link check
        params.put(CmsPublishScheduledJob.PARAM_LINKCHECK, "true");
        // add the job schedule parameter
        job.setParameters(params);
        // add the context info to the scheduled job
        job.setContextInfo(contextInfo);
        // add the job to the scheduled job list
        OpenCms.getScheduleManager().scheduleJob(cmsAdmin, job);
        // update the XML configuration
        OpenCms.writeConfiguration(CmsSchedulerConfiguration.class);
        return true;
    }
919345
public function remove()
    {
        if ($this->locked) {
            throw new \RuntimeException('can not remove a locked semaphore resource');
        }
        if (!is_resource($this->lock_id)) {
            throw new \RuntimeException('can not remove a empty semaphore resource');
        }

        if (!sem_release($this->lock_id)) {
            return false;
        }

        return true;
    }
649412
private boolean isAllowedUser(CmsUser user) throws CmsException {

        if (user.getOuFqn().startsWith(m_cms.getRequestContext().getOuFqn())) {
            return true;
        }
        return OpenCms.getRoleManager().getRolesOfUser(m_cms, user.getName(), m_ou, true, true, false).size() > 0;
    }
467816
private void lock(CmsObject cms, CmsResource resource) throws CmsException {

        CmsLock lock = cms.getLock(resource);
        if (lock.isUnlocked()) {
            cms.lockResourceTemporary(resource);
        } else {
            cms.changeLock(resource);
        }
    }
1068317
public void lockResource(CmsResource resource) throws CmsException {

        getResourceType(resource).lockResource(this, m_securityManager, resource, CmsLockType.EXCLUSIVE);
    }
168368
public function podiumLock()
    {
        $this->locked = !$this->locked;
        if ($this->save()) {
            Log::info($this->locked ? 'Thread locked' : 'Thread unlocked', $this->id, __METHOD__);
            return true;
        }
        return false;
    }
333164
public void cancel() {

        if (m_lockActionRecord.getChange() == LockChange.locked) {
            CmsObject cms = A_CmsUI.getCmsObject();
            try {
                CmsResource res = cms.readResource(m_editId);
                cms.unlockResource(res);
            } catch (CmsException e) {
                LOG.warn("Failed to unlock resource " + m_editId.toString(), e);
            }
        }
        CmsAppWorkplaceUi.get().enableGlobalShortcuts();
    }
273654
public boolean isSyncEnabled() {

        CmsSynchronizeSettings syncSettings = getSettings().getUserSettings().getSynchronizeSettings();
        return (syncSettings != null) && syncSettings.isSyncEnabled();
    }
1000322
private void unlockInherited(final String absoluteResourcename) throws CmsException {

        CmsObject cms = getCms();
        CmsLock parentLock = getParentLock(absoluteResourcename);
        if (!parentLock.isNullLock()) {
            if (parentLock.isInherited()) {
                unlockInherited(parentLock.getResourceName());
            } else {
                if (!parentLock.isLockableBy(cms.getRequestContext().getCurrentUser())) {
                    cms.changeLock(cms.getRequestContext().removeSiteRoot(parentLock.getResourceName()));
                }
                cms.unlockResource(cms.getRequestContext().removeSiteRoot(parentLock.getResourceName()));
            }
        }

    }
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;
    }
176300
@Override
    protected boolean performDialogOperation() throws CmsException {

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

        // determine the correct delete option
        CmsResourceDeleteMode deleteOption = Boolean.valueOf(getParamDeleteSiblings()).booleanValue()
        ? CmsResource.DELETE_REMOVE_SIBLINGS
        : CmsResource.DELETE_PRESERVE_SIBLINGS;

        Iterator<String> i = getResourceList().iterator();
        // iterate the resources to delete
        while (i.hasNext()) {
            String resName = i.next();
            try {
                performSingleDeleteOperation(resName, deleteOption);
            } 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_DELETE_MULTI_0);

        return true;
    }
757216
private void clearLock() throws CmsException {

        if ((m_lockActionRecord != null) && (m_lockActionRecord.getChange() == LockChange.locked)) {
            CmsResource updatedRes = m_cms.readResource(m_resource.getStructureId(), CmsResourceFilter.ALL);
            try {
                m_cms.unlockResource(updatedRes);
            } catch (CmsLockException e) {
                LOG.warn(e.getLocalizedMessage(), e);
            }
            m_lockActionRecord = null;
        }
    }
1092517
private void tryUnlock(CmsResource resource) {

        try {
            m_cms.unlockResource(resource);
        } catch (Exception unlockError) {
            LOG.debug(unlockError.getLocalizedMessage(), unlockError);
        }
    }
1091267
protected CmsLock getRelatedLock() {

        if (m_relatedLock == null) {
            CmsLockType type;
            if (isSystemLock()) {
                type = CmsLockType.UNLOCKED;
            } else {
                type = CmsLockType.SYSTEM_UNLOCKED;
            }
            CmsLock lock = new CmsLock(getResourceName(), getUserId(), getProject(), type);
            lock.setRelatedLock(this);
            if (isUnlocked()) {
                // prevent the null lock gets modified
                return lock;
            }
            m_relatedLock = lock;
        }
        return m_relatedLock;
    }