Performs the resource deletion.<p>

@return true, if the resource(s) was/were deleted, otherwise false
@throws CmsException if deletion is not successful
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;
    }
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;
    }
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;
    }
20165
public function deleteAction()
	{
		$page = $this->getPageLocalization()
				->getMaster();

		$entityManager = $this->getEntityManager();

		$count = (int) $entityManager->createQuery(sprintf('SELECT COUNT(p.id) FROM %s p WHERE p.template = ?0', PageLocalization::CN()))
				->setParameters(array($page->getId()))
				->getSingleScalarResult();

		if ($count > 0) {
			throw new CmsException(null, "Cannot remove template, {$count} page(s) still uses it.");
		}

		$entityManager->remove($page);
		$entityManager->flush();

		return new SupraJsonResponse();
	}
845478
protected void ensureLock() throws CmsException {

        CmsLock lock = m_cms.getLock(m_resource);
        if (lock.isUnlocked() || !lock.isLockableBy(m_cms.getRequestContext().getCurrentUser())) {
            m_cms.lockResourceTemporary(m_cms.getSitePath(m_resource));
            m_needToUnlock = true;
        }
    }
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;
    }
1190710
@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;
        }

        // get the new release date for the resource(s) from request parameter
        long releaseDate = CmsResource.DATE_RELEASED_DEFAULT;
        boolean resetReleaseDate = Boolean.valueOf(getParamResetrelease()).booleanValue();
        boolean leaveReleaseDate = false;
        if (!resetReleaseDate) {
            try {
                if ((CmsStringUtil.isNotEmptyOrWhitespaceOnly(getParamReleasedate()))
                    && (!getParamReleasedate().startsWith(CmsTouch.DEFAULT_DATE_STRING))) {
                    releaseDate = CmsCalendarWidget.getCalendarDate(getMessages(), getParamReleasedate(), true);
                } else {
                    leaveReleaseDate = true;
                }
            } catch (ParseException e) {
                throw new CmsException(
                    Messages.get().container(Messages.ERR_PARSE_RELEASEDATE_1, getParamReleasedate()),
                    e);
            }
        }

        // get the new expire date for the resource(s) from request parameter
        long expireDate = CmsResource.DATE_EXPIRED_DEFAULT;
        boolean resetExpireDate = Boolean.valueOf(getParamResetexpire()).booleanValue();
        boolean leaveExpireDate = false;
        if (!resetExpireDate) {
            try {
                if ((CmsStringUtil.isNotEmptyOrWhitespaceOnly(getParamExpiredate()))
                    && (!getParamExpiredate().startsWith(CmsTouch.DEFAULT_DATE_STRING))) {
                    expireDate = CmsCalendarWidget.getCalendarDate(getMessages(), getParamExpiredate(), true);
                } else {
                    leaveExpireDate = true;
                }
            } catch (ParseException e) {
                throw new CmsException(
                    Messages.get().container(Messages.ERR_PARSE_EXPIREDATE_1, getParamExpiredate()),
                    e);
            }
        }

        // get the flag if the operation is recursive from request parameter
        boolean modifyRecursive = Boolean.valueOf(getParamRecursive()).booleanValue();

        // now iterate the resource(s)
        Iterator<String> i = getResourceList().iterator();
        while (i.hasNext()) {
            String resName = i.next();
            try {
                performSingleResourceAvailability(
                    resName,
                    releaseDate,
                    expireDate,
                    leaveReleaseDate,
                    leaveExpireDate,
                    modifyRecursive);
            } catch (CmsException e) {
                // collect exceptions to create a detailed output
                addMultiOperationException(e);
            }
        }

        boolean notificationEnabled = Boolean.valueOf(getParamEnablenotification()).booleanValue();
        int notificationInterval = 0;
        try {
            notificationInterval = Integer.parseInt(getParamNotificationinterval());
        } catch (Throwable e) {
            // ignore
        }

        // get the flag if the operation should be executed on resource siblings, too
        boolean modifySiblings = Boolean.valueOf(getParamModifysiblings()).booleanValue();

        // now iterate the resource(s)
        i = getResourceList().iterator();
        while (i.hasNext()) {
            String resName = i.next();
            try {
                performSingleResourceNotification(
                    getCms(),
                    resName,
                    notificationEnabled,
                    notificationInterval,
                    modifySiblings);
            } catch (CmsException e) {
                // collect exceptions to create a detailed output
                addMultiOperationException(e);
            }
        }
        checkMultiOperationException(Messages.get(), Messages.ERR_AVAILABILITY_MULTI_0);

        return true;
    }
1199467
public boolean hasMoreAdminOUs() throws CmsException {

        List<CmsOrganizationalUnit> orgUnits = getOrgUnits();

        if (orgUnits == null) {
            return false;
        }
        if (orgUnits.size() <= 1) {
            return false;
        }
        return true;
    }
349389
boolean isEditable(CmsObject cms, CmsResource resource) {

        try {
            return cms.hasPermissions(resource, CmsPermissionSet.ACCESS_WRITE, false, CmsResourceFilter.ALL);
        } catch (CmsException e) {
            return false;
        }
    }
119379
private boolean resourceExists(CmsObject cms, String resource) {

        try {
            cms.readResource(resource, CmsResourceFilter.ALL);
            return true;
        } catch (CmsException e) {
            return false;
        }
    }
844228
@Override
    protected boolean performDialogOperation() throws CmsException {

        // on folder touch or multi resource operation display "please wait" screen, not for simple file copy
        if (!DIALOG_WAIT.equals(getParamAction())) {
            // check if the "please wait" screen has to be shown
            if (isMultiOperation()) {
                // show please wait for every multi resource operation
                return false;
            } else {
                // check if the single resource is a folder
                CmsResource sourceRes = getCms().readResource(getParamResource(), CmsResourceFilter.ALL);
                if (sourceRes.isFolder()) {
                    return false;
                }
            }
        }

        // get the new timestamp for the resource(s) from request parameter
        long timeStamp = 0;
        boolean correctDate = false;
        try {
            if (CmsStringUtil.isNotEmpty(getParamNewtimestamp())) {
                timeStamp = CmsCalendarWidget.getCalendarDate(getMessages(), getParamNewtimestamp(), true);
                correctDate = true;
            }
        } catch (ParseException e) {
            throw new CmsException(Messages.get().container(Messages.ERR_PARSE_TIMESTAMP_1, getParamNewtimestamp()), e);
        }

        // get the flag if the touch is recursive from request parameter
        boolean touchRecursive = Boolean.valueOf(getParamRecursive()).booleanValue();
        // get the flag to the touch the content from request parameter
        boolean touchContent = Boolean.valueOf(getParamContent()).booleanValue();

        // now touch the resource(s)
        Iterator<String> i = getResourceList().iterator();
        while (i.hasNext()) {
            String resName = i.next();
            try {
                // lock resource if autolock is enabled
                checkLock(resName);
                touchSingleResource(getCms(), resName, timeStamp, touchRecursive, correctDate, touchContent);
            } catch (CmsException e) {
                // collect exceptions to create a detailed output
                addMultiOperationException(e);
            }
        }
        checkMultiOperationException(Messages.get(), Messages.ERR_TOUCH_MULTI_0);

        return true;
    }
43604
protected boolean isOperationOnMovedResource() {

        Iterator<String> i = getResourceList().iterator();
        while (i.hasNext()) {
            String resName = i.next();
            String target = resourceOriginalPath(getCms(), resName);
            if ((target != null) && !target.equals(resName)) {
                // found a moved resource
                return true;
            }
        }
        return false;
    }
995224
public void actionDeleteCascade() throws JspException {

        // save initialized instance of this class in request attribute for included sub-elements
        getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this);
        try {
            // list of all resources containing this propertydefinition
            List resourcesWithProperty = getCms().readResourcesWithProperty(getParamPropertyName());
            // list of all resources locked by another user, containing this propertydefinition
            List resourcesLockedByOtherUser = getResourcesLockedByOtherUser(resourcesWithProperty);
            // do the following operations only if all of the resources are not locked by another user
            if (resourcesLockedByOtherUser.isEmpty()) {
                // save the site root
                String storedSiteRoot = getCms().getRequestContext().getSiteRoot();
                try {
                    // change to the root site
                    getCms().getRequestContext().setSiteRoot("/");

                    Iterator i = resourcesWithProperty.iterator();
                    while (i.hasNext()) {
                        CmsResource resource = (CmsResource)i.next();
                        // read the property object
                        CmsProperty property = getCms().readPropertyObject(
                            resource.getRootPath(),
                            getParamPropertyName(),
                            false);
                        // try to delete the property if it is not the NULL PROPERTY
                        // if the property is the NULL PROPERTY, it only had a shared
                        // value which was deleted at a sibling which was already processed
                        if (!property.isNullProperty()) {
                            CmsLock lock = getCms().getLock(resource);
                            if (lock.isUnlocked()) {
                                // lock the resource for the current (Admin) user
                                getCms().lockResource(resource.getRootPath());
                            }
                            property.setStructureValue(CmsProperty.DELETE_VALUE);
                            property.setResourceValue(CmsProperty.DELETE_VALUE);
                            // write the property with the null value to the resource and cascade it from the definition
                            getCms().writePropertyObject(resource.getRootPath(), property);
                            // unlock the resource
                            getCms().unlockResource(resource.getRootPath());
                        }
                    }
                    // delete the property definition at last
                    getCms().deletePropertyDefinition(getParamPropertyName());
                } finally {
                    // restore the siteroot
                    getCms().getRequestContext().setSiteRoot(storedSiteRoot);
                    // close the dialog
                    actionCloseDialog();
                }
            } else {

                StringBuffer reason = new StringBuffer();
                reason.append(dialogWhiteBoxStart());
                reason.append(buildResourceList(resourcesLockedByOtherUser, true));
                reason.append(dialogWhiteBoxEnd());
                throw new CmsVfsException(
                    Messages.get().container(Messages.ERR_DEL_PROP_RESOURCES_LOCKED_1, reason.toString()));
            }
        } catch (Throwable e) {
            // error while deleting property definition, show error dialog
            includeErrorpage(this, e);
        }
    }
561931
private void deleteResource(final String sitePath) {

        CmsRpcAction<Void> action = new CmsRpcAction<Void>() {

            /**
             * @see org.opencms.gwt.client.rpc.CmsRpcAction#execute()
             */
            @Override
            public void execute() {

                CmsCoreProvider.getVfsService().deleteResource(sitePath, this);

            }

            /**
             * @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object)
             */
            @Override
            protected void onResponse(Void result) {

                onAfterDeletion();
            }
        };
        action.execute();
    }
1270923
@InterfaceAudience.Public
    public boolean isDeletion() {
        Object deleted = getProperty("_deleted");
        if (deleted == null) {
            return false;
        }
        Boolean deletedBool = (Boolean) deleted;
        return deletedBool.booleanValue();
    }
680486
public void actionDeleteResource() throws JspException {

        if ((getParamDialogmode() != null) && getParamDialogmode().startsWith(MODE_WIZARD)) {
            // only delete resource if dialog mode is a wizard mode
            try {
                getCms().deleteResource(getParamResource(), CmsResource.DELETE_PRESERVE_SIBLINGS);
            } catch (Throwable e) {
                // error deleting the resource, show error dialog
                includeErrorpage(this, e);
            }
        }
    }
1196719
private CmsSitemapChange undelete(CmsSitemapChange change) throws CmsException {

        CmsObject cms = getCmsObject();
        CmsResource deleted = cms.readResource(change.getEntryId(), CmsResourceFilter.ALL);
        if (deleted.getState().isDeleted()) {
            ensureLock(deleted);
            cms.undeleteResource(getCmsObject().getSitePath(deleted), true);
            tryUnlock(deleted);
        }
        String parentPath = CmsResource.getParentFolder(cms.getSitePath(deleted));
        CmsJspNavElement navElement = getNavBuilder().getNavigationForResource(
            parentPath,
            CmsResourceFilter.ONLY_VISIBLE_NO_DELETED);
        CmsClientSitemapEntry entry = toClientEntry(navElement, navElement.isInNavigation());
        entry.setSubEntries(getChildren(parentPath, 2, null), null);
        change.setUpdatedEntry(entry);
        change.setParentId(cms.readParentFolder(deleted.getStructureId()).getStructureId());
        return change;
    }