/** * Returns <code>true</code> if this is an exclusive (or temporary exclusive) lock, * and the given user is the owner and the given project is the project of this lock.<p> * * @param user the user to compare to the owner of this lock * @param project the project to compare to the project of this lock * * @return <code>true</code> if this is an exclusive (or temporary exclusive) lock, * and the given user is the owner and the given project is the project of this lock */ public boolean isExclusiveOwnedInProjectBy(CmsUser user, CmsProject project) { return isExclusive() && isOwnedInProjectBy(user, project); }
/** * Returns <code>true</code> if this is an exclusive (or temporary exclusive) lock, * and the given user is the owner and the given project is the project of this lock.<p> * * @param user the user to compare to the owner of this lock * @param project the project to compare to the project of this lock * * @return <code>true</code> if this is an exclusive (or temporary exclusive) lock, * and the given user is the owner and the given project is the project of this lock */ public boolean isExclusiveOwnedInProjectBy(CmsUser user, CmsProject project) { return isExclusive() && isOwnedInProjectBy(user, project); }
/** * Returns <code>true</code> if this is an exclusive, temporary exclusive, or * directly inherited lock, and the given user is the owner of this lock, * checking also the project of the lock.<p> * * @param user the user to compare to the owner of this lock * @param project the project to compare to the project of this lock * * @return <code>true</code> if this is an exclusive, temporary exclusive, or * directly inherited lock, and the given user is the owner of this lock */ public boolean isDirectlyOwnedInProjectBy(CmsUser user, CmsProject project) { return (isExclusive() || isDirectlyInherited()) && isOwnedInProjectBy(user, project); }
/** * Returns <code>true</code> if this is an exclusive, temporary exclusive, or * directly inherited lock, and the current user is the owner of this lock, * checking also the project of the lock.<p> * * @param cms the CMS context to check * * @return <code>true</code> if this is an exclusive, temporary exclusive, or * directly inherited lock, and the current user is the owner of this lock */ public boolean isDirectlyOwnedInProjectBy(CmsObject cms) { return (isExclusive() || isDirectlyInherited()) && isOwnedInProjectBy( cms.getRequestContext().getCurrentUser(), cms.getRequestContext().getCurrentProject()); }
/** * @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(); return (!resourceUtil[0].getProjectState().isLockedForPublishing() && !lock.isShared() && lock.isOwnedInProjectBy( cms.getRequestContext().currentUser(), cms.getRequestContext().currentProject())); } // resource is not locked by the user in current project, 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(); return (!resourceUtil[0].getProjectState().isLockedForPublishing() && !lock.isShared() && lock.isOwnedInProjectBy( cms.getRequestContext().getCurrentUser(), cms.getRequestContext().getCurrentProject())); } // resource is not locked by the user in current project, rule does not match return false; }
/** * Locks the given resource.<p> * * @param cms the cms context * @param resource the resource to lock * * @throws CmsException in case locking fails */ private static void ensureLock(CmsObject cms, CmsResource resource) throws CmsException { CmsUser user = cms.getRequestContext().getCurrentUser(); CmsLock lock = cms.getLock(resource); if (!lock.isOwnedBy(user)) { cms.lockResourceTemporary(resource); } else if (!lock.isOwnedInProjectBy(user, cms.getRequestContext().getCurrentProject())) { cms.changeLock(resource); } }
/** * @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(); return (!resourceUtil[0].getProjectState().isLockedForPublishing() && !lock.isShared() && lock.isOwnedInProjectBy( cms.getRequestContext().currentUser(), cms.getRequestContext().currentProject())); } // resource is not locked by the user in current project, 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(); return (!resourceUtil[0].getProjectState().isLockedForPublishing() && !lock.isShared() && lock.isOwnedInProjectBy( cms.getRequestContext().getCurrentUser(), cms.getRequestContext().getCurrentProject())); } // resource is not locked by the user in current project, rule does not match return false; }
/** * Locks the given resource temporarily.<p> * * @param resource the resource to lock * * @throws CmsException if locking fails */ private void lockTemporary(CmsResource resource) throws CmsException { CmsObject cms = getCms(); CmsUser user = cms.getRequestContext().getCurrentUser(); CmsLock lock = cms.getLock(resource); if (!lock.isOwnedBy(user)) { cms.lockResourceTemporary(resource); } else if (!lock.isOwnedInProjectBy(user, cms.getRequestContext().getCurrentProject())) { cms.changeLock(resource); } } }
/** * @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().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; }
change = LockChange.locked; lock = cms.getLock(resource); } else if (!lock.isOwnedInProjectBy(user, cms.getRequestContext().getCurrentProject())) { cms.changeLock(resource); change = LockChange.changed;
/** * @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; }
/** * @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() && resourceUtil[0].getResource().getState().isChanged()) { CmsLock lock = resourceUtil[0].getLock(); boolean lockedForPublish = resourceUtil[0].getProjectState().isLockedForPublishing(); if ((!lockedForPublish && !lock.isShared() && lock.isOwnedInProjectBy( cms.getRequestContext().currentUser(), cms.getRequestContext().currentProject())) || (!lockedForPublish && lock.isNullLock() && OpenCms.getWorkplaceManager().autoLockResources())) { try { CmsObject cmsOnline = OpenCms.initCmsObject(cms); cmsOnline.getRequestContext().setCurrentProject(cms.readProject(CmsProject.ONLINE_PROJECT_ID)); try { cmsOnline.readResource(resourceUtil[0].getResource().getStructureId()); return false; } catch (CmsException ex) { // resource state is changed but not in online-project, so it was moved return true; } } catch (CmsException e) { // error reading project return false; } } } // resource is not locked by the user in current project or not locked with enabled autolock, rule does not match return false; }