/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#matches(org.opencms.file.CmsObject, CmsResourceUtil[]) */ public boolean matches(CmsObject cms, CmsResourceUtil[] resourceUtil) { if (resourceUtil[0].isInsideProject()) { if (resourceUtil[0].getLock().isNullLock()) { return !OpenCms.getWorkplaceManager().autoLockResources(); } } // resource is not in current project return false; }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#matches(org.opencms.file.CmsObject, CmsResourceUtil[]) */ public boolean matches(CmsObject cms, CmsResourceUtil[] resourceUtil) { if (resourceUtil[0].isInsideProject()) { if (resourceUtil[0].getLock().isNullLock()) { return !OpenCms.getWorkplaceManager().autoLockResources(); } } // resource is not in current project return false; }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#matches(org.opencms.file.CmsObject, CmsResourceUtil[]) */ public boolean matches(CmsObject cms, CmsResourceUtil[] resourceUtil) { if (resourceUtil[0].isInsideProject()) { boolean matches = (!resourceUtil[0].getProjectState().isLockedForPublishing()) && (CmsStringUtil.isEmptyOrWhitespaceOnly(resourceUtil[0].getLockedByName())); return matches && !OpenCms.getWorkplaceManager().autoLockResources(); } // resource is not in current project return false; }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#matches(org.opencms.file.CmsObject, CmsResourceUtil[]) */ public boolean matches(CmsObject cms, CmsResourceUtil[] resourceUtil) { if (resourceUtil[0].isInsideProject()) { boolean matches = (!resourceUtil[0].getProjectState().isLockedForPublishing()) && (CmsStringUtil.isEmptyOrWhitespaceOnly(resourceUtil[0].getLockedByName())); return matches && !OpenCms.getWorkplaceManager().autoLockResources(); } // resource is not in current project return false; }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#matches(org.opencms.file.CmsObject, CmsResourceUtil[]) */ public boolean matches(CmsObject cms, CmsResourceUtil[] resourceUtil) { if (resourceUtil[0].isInsideProject()) { boolean matches = (!resourceUtil[0].getProjectState().isLockedForPublishing()) && (CmsStringUtil.isEmptyOrWhitespaceOnly(resourceUtil[0].getLockedByName())); return matches && !OpenCms.getWorkplaceManager().autoLockResources(); } // resource is not in current project return false; }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#matches(org.opencms.file.CmsObject, CmsResourceUtil[]) */ public boolean matches(CmsObject cms, CmsResourceUtil[] resourceUtil) { if (resourceUtil[0].isInsideProject()) { boolean matches = (!resourceUtil[0].getProjectState().isLockedForPublishing()) && (CmsStringUtil.isEmptyOrWhitespaceOnly(resourceUtil[0].getLockedByName())); return matches && !OpenCms.getWorkplaceManager().autoLockResources(); } // resource is not in current project return false; }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#matches(org.opencms.file.CmsObject, CmsResourceUtil[]) */ public boolean matches(CmsObject cms, CmsResourceUtil[] resourceUtil) { if (resourceUtil[0].isInsideProject()) { //if (resourceUtil.getLock().isNullLock()) { boolean matches = (!resourceUtil[0].getProjectState().isLockedForPublishing()) && (CmsStringUtil.isEmptyOrWhitespaceOnly(resourceUtil[0].getLockedByName())); return matches && !OpenCms.getWorkplaceManager().autoLockResources(); //} } // resource is not in current project return false; }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#matches(org.opencms.file.CmsObject, CmsResourceUtil[]) */ public boolean matches(CmsObject cms, CmsResourceUtil[] resourceUtil) { if (resourceUtil[0].isInsideProject()) { //if (resourceUtil.getLock().isNullLock()) { boolean matches = (!resourceUtil[0].getProjectState().isLockedForPublishing()) && (CmsStringUtil.isEmptyOrWhitespaceOnly(resourceUtil[0].getLockedByName())); return matches && !OpenCms.getWorkplaceManager().autoLockResources(); //} } // resource is not in current project return false; }
/** * Checks if the current resource has lock state exclusive or inherited.<p> * * This is used to determine whether the dialog shows the option to delete all * siblings of the resource or not. * * @return true if lock state is exclusive or inherited, otherwise false */ 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(); }
/** * Checks if the current resource has lock state exclusive or inherited.<p> * * This is used to determine whether the dialog shows the option to delete all * siblings of the resource or not. * * @return true if lock state is exclusive or inherited, otherwise false */ 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(); }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#matches(org.opencms.file.CmsObject, CmsResourceUtil[]) */ public boolean matches(CmsObject cms, CmsResourceUtil[] resourceUtil) { if (resourceUtil[0].isInsideProject()) { CmsLock lock = resourceUtil[0].getLock(); boolean lockedForPublish = resourceUtil[0].getProjectState().isLockedForPublishing(); return (!lockedForPublish && !lock.isShared() && lock.isOwnedInProjectBy( cms.getRequestContext().getCurrentUser(), cms.getRequestContext().getCurrentProject())) || (!lockedForPublish && lock.isNullLock() && OpenCms.getWorkplaceManager().autoLockResources()); } // resource is not locked by the user in current project or not locked with enabled autolock, rule does not match return false; }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#matches(org.opencms.file.CmsObject, CmsResourceUtil[]) */ public boolean matches(CmsObject cms, CmsResourceUtil[] resourceUtil) { if (resourceUtil[0].isInsideProject()) { CmsLock lock = resourceUtil[0].getLock(); boolean lockedForPublish = resourceUtil[0].getProjectState().isLockedForPublishing(); return (!lockedForPublish && !lock.isShared() && lock.isOwnedInProjectBy( cms.getRequestContext().currentUser(), cms.getRequestContext().currentProject())) || (!lockedForPublish && lock.isNullLock() && OpenCms.getWorkplaceManager().autoLockResources()); } // resource is not locked by the user in current project or not locked with enabled autolock, rule does not match return false; }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#matches(org.opencms.file.CmsObject, CmsResourceUtil[]) */ public boolean matches(CmsObject cms, CmsResourceUtil[] resourceUtil) { if (resourceUtil[0].isInsideProject()) { CmsLock lock = resourceUtil[0].getLock(); boolean lockedForPublish = resourceUtil[0].getProjectState().isLockedForPublishing(); return (!lockedForPublish && !lock.isShared() && lock.isOwnedInProjectBy( cms.getRequestContext().currentUser(), cms.getRequestContext().currentProject())) || (!lockedForPublish && lock.isNullLock() && OpenCms.getWorkplaceManager().autoLockResources()); } // resource is not locked by the user in current project or not locked with enabled autolock, rule does not match return false; }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#matches(org.opencms.file.CmsObject, CmsResourceUtil[]) */ public boolean matches(CmsObject cms, CmsResourceUtil[] resourceUtil) { if (resourceUtil[0].isInsideProject()) { CmsLock lock = resourceUtil[0].getLock(); boolean lockedForPublish = resourceUtil[0].getProjectState().isLockedForPublishing(); return (!lockedForPublish && !lock.isShared() && lock.isOwnedInProjectBy( cms.getRequestContext().currentUser(), cms.getRequestContext().currentProject())) || (!lockedForPublish && lock.isNullLock() && OpenCms.getWorkplaceManager().autoLockResources()); } // resource is not locked by the user in current project or not locked with enabled autolock, rule does not match return false; }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#matches(org.opencms.file.CmsObject, CmsResourceUtil[]) */ public boolean matches(CmsObject cms, CmsResourceUtil[] resourceUtil) { if (resourceUtil[0].isInsideProject()) { CmsLock lock = resourceUtil[0].getLock(); boolean lockedForPublish = resourceUtil[0].getProjectState().isLockedForPublishing(); return (!lockedForPublish && !lock.isShared() && lock.isOwnedInProjectBy( cms.getRequestContext().currentUser(), cms.getRequestContext().currentProject())) || (!lockedForPublish && lock.isNullLock() && OpenCms.getWorkplaceManager().autoLockResources()); } // resource is not locked by the user in current project or not locked with enabled autolock, rule does not match return false; }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#matches(org.opencms.file.CmsObject, CmsResourceUtil[]) */ public boolean matches(CmsObject cms, CmsResourceUtil[] resourceUtil) { if (resourceUtil[0].isInsideProject()) { CmsLock lock = resourceUtil[0].getLock(); boolean lockedForPublish = resourceUtil[0].getProjectState().isLockedForPublishing(); return (!lockedForPublish && !lock.isShared() && lock.isOwnedInProjectBy( cms.getRequestContext().getCurrentUser(), cms.getRequestContext().getCurrentProject())) || (!lockedForPublish && lock.isNullLock() && OpenCms.getWorkplaceManager().autoLockResources()); } // resource is not locked by the user in current project or not locked with enabled autolock, rule does not match return false; }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#matches(org.opencms.file.CmsObject, CmsResourceUtil[]) */ public boolean matches(CmsObject cms, CmsResourceUtil[] resourceUtil) { if (resourceUtil[0].isInsideProject()) { CmsLock lock = resourceUtil[0].getLock(); boolean lockedForPublish = resourceUtil[0].getProjectState().isLockedForPublishing(); return (!lockedForPublish && !lock.isShared() && lock.isOwnedInProjectBy( cms.getRequestContext().getCurrentUser(), cms.getRequestContext().getCurrentProject())) || (!lockedForPublish && lock.isNullLock() && OpenCms.getWorkplaceManager().autoLockResources()); } // resource is not locked by the user in current project or not locked with enabled autolock, rule does not match return false; }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#matches(org.opencms.file.CmsObject, CmsResourceUtil[]) */ public boolean matches(CmsObject cms, CmsResourceUtil[] resourceUtil) { try { if (!cms.hasPermissions( resourceUtil[0].getResource(), CmsPermissionSet.ACCESS_VIEW, false, CmsResourceFilter.ONLY_VISIBLE_NO_DELETED)) { return true; } } catch (@SuppressWarnings("unused") CmsException e) { return true; } if (resourceUtil[0].isInsideProject()) { CmsLock lock = resourceUtil[0].getLock(); boolean lockedForPublish = resourceUtil[0].getProjectState().isLockedForPublishing(); return (!lockedForPublish && !lock.isShared() && lock.isOwnedInProjectBy( cms.getRequestContext().getCurrentUser(), cms.getRequestContext().getCurrentProject())) || (!lockedForPublish && lock.isNullLock() && OpenCms.getWorkplaceManager().autoLockResources()); } // resource is not locked by the user in current project or not locked with enabled autolock, rule does not match return false; }
/** * Checks the lock state of the resource and locks it if the autolock feature is enabled.<p> * * @param resource the resource name which is checked * @param type indicates the mode {@link CmsLockType#EXCLUSIVE} or {@link CmsLockType#TEMPORARY} * * @throws CmsException if reading or locking the resource fails */ public void checkLock(String resource, CmsLockType type) throws CmsException { CmsResource res = getCms().readResource(resource, CmsResourceFilter.ALL); CmsLock lock = getCms().getLock(res); boolean lockable = lock.isLockableBy(getCms().getRequestContext().getCurrentUser()); if (OpenCms.getWorkplaceManager().autoLockResources()) { // autolock is enabled, check the lock state of the resource if (lockable) { // resource is lockable, so lock it automatically if (type == CmsLockType.TEMPORARY) { getCms().lockResourceTemporary(resource); } else { getCms().lockResource(resource); } } else { throw new CmsException(Messages.get().container(Messages.ERR_WORKPLACE_LOCK_RESOURCE_1, resource)); } } else { if (!lockable) { throw new CmsException(Messages.get().container(Messages.ERR_WORKPLACE_LOCK_RESOURCE_1, resource)); } } }
/** * Checks the lock state of the resource and locks it if the autolock feature is enabled.<p> * * @param resource the resource name which is checked * @param type indicates the mode {@link CmsLockType#EXCLUSIVE} or {@link CmsLockType#TEMPORARY} * * @throws CmsException if reading or locking the resource fails */ public void checkLock(String resource, CmsLockType type) throws CmsException { CmsResource res = getCms().readResource(resource, CmsResourceFilter.ALL); CmsLock lock = getCms().getLock(res); boolean lockable = lock.isLockableBy(getCms().getRequestContext().currentUser()); if (OpenCms.getWorkplaceManager().autoLockResources()) { // autolock is enabled, check the lock state of the resource if (lockable) { // resource is lockable, so lock it automatically if (type == CmsLockType.TEMPORARY) { getCms().lockResourceTemporary(resource); } else { getCms().lockResource(resource); } } else { throw new CmsException(Messages.get().container(Messages.ERR_WORKPLACE_LOCK_RESOURCE_1, resource)); } } else { if (!lockable) { throw new CmsException(Messages.get().container(Messages.ERR_WORKPLACE_LOCK_RESOURCE_1, resource)); } } }