/** * Counts the exclusive locked resources in a project.<p> * * @param project the project * * @return the number of exclusive locked resources in the specified project */ public int countExclusiveLocksInProject(CmsProject project) { int count = 0; Iterator<CmsLock> itLocks = OpenCms.getMemoryMonitor().getAllCachedLocks().iterator(); while (itLocks.hasNext()) { CmsLock lock = itLocks.next(); if (lock.getEditionLock().isInProject(project)) { count++; } } return count; }
/** * Counts the exclusive locked resources in a project.<p> * * @param project the project * * @return the number of exclusive locked resources in the specified project */ public int countExclusiveLocksInProject(CmsProject project) { int count = 0; Iterator itLocks = OpenCms.getMemoryMonitor().getAllCachedLocks().iterator(); while (itLocks.hasNext()) { CmsLock lock = (CmsLock)itLocks.next(); if (lock.getEditionLock().isInProject(project)) { count++; } } return count; }
/** * Returns the lock of a possible locked parent folder of a resource, system locks are ignored.<p> * * @param resourceName the name of the resource * * @return the lock of a parent folder, or {@link CmsLock#getNullLock()} if no parent folders are locked by a non system lock */ private CmsLock getParentFolderLock(String resourceName) { Iterator<CmsLock> itLocks = OpenCms.getMemoryMonitor().getAllCachedLocks().iterator(); while (itLocks.hasNext()) { CmsLock lock = itLocks.next(); if (lock.getResourceName().endsWith("/") && resourceName.startsWith(lock.getResourceName()) && !resourceName.equals(lock.getResourceName())) { // system locks does not get inherited lock = lock.getEditionLock(); // check the lock if (!lock.isUnlocked()) { return lock; } } } return CmsLock.getNullLock(); }
/** * Returns the user, who had locked the resource.<p> * * A user can lock a resource, so he is the only one who can write this * resource. This methods checks, if a resource was locked. * * @param dbc the current database context * @param resource the resource * * @return the user, who had locked the resource * * @throws CmsException will be thrown, if the user has not the rights for this resource */ public CmsUser lockedBy(CmsDbContext dbc, CmsResource resource) throws CmsException { return readUser(dbc, m_lockManager.getLock(dbc, resource).getEditionLock().getUserId()); }
/** * Returns the user, who had locked the resource.<p> * * A user can lock a resource, so he is the only one who can write this * resource. This methods checks, if a resource was locked. * * @param dbc the current database context * @param resource the resource * * @return the user, who had locked the resource * * @throws CmsException will be thrown, if the user has not the rights for this resource */ public CmsUser lockedBy(CmsDbContext dbc, CmsResource resource) throws CmsException { return readUser(dbc, m_lockManager.getLock(dbc, resource).getEditionLock().getUserId()); }
/** * Returns the lock of a possible locked parent folder of a resource, system locks are ignored.<p> * * @param absoluteResourceName the name of the resource * * @return the lock of a parent folder, or {@link CmsLock#getNullLock()} * if no parent folders are locked by a non system lock */ private CmsLock getParentFolderLock(final String absoluteResourceName) { Iterator<CmsLock> itLocks = OpenCms.getMemoryMonitor().getAllCachedLocks().iterator(); while (itLocks.hasNext()) { CmsLock lock = itLocks.next(); if (lock.getResourceName().endsWith("/") && absoluteResourceName.startsWith(lock.getResourceName()) && !absoluteResourceName.equals(lock.getResourceName())) { // system locks does not get inherited lock = lock.getEditionLock(); // check the lock if (!lock.isUnlocked()) { return lock; } } } return CmsLock.getNullLock(); }
/** * Returns the lock of a possible locked parent folder of a resource, system locks are ignored.<p> * * @param resourceName the name of the resource * * @return the lock of a parent folder, or {@link CmsLock#getNullLock()} if no parent folders are locked by a non system lock */ private CmsLock getParentFolderLock(String resourceName) { Iterator itLocks = OpenCms.getMemoryMonitor().getAllCachedLocks().iterator(); while (itLocks.hasNext()) { CmsLock lock = (CmsLock)itLocks.next(); if (lock.getResourceName().endsWith("/") && resourceName.startsWith(lock.getResourceName()) && !resourceName.equals(lock.getResourceName())) { // system locks does not get inherited lock = lock.getEditionLock(); // check the lock if (!lock.isUnlocked()) { return lock; } } } return CmsLock.getNullLock(); }
/** * Checks if a resource can be locked by a user.<p> * * The resource is not lockable if it already has a lock of type {@link CmsLockType#PUBLISH}.<p> * * The resource is lockable either * - if it is currently unlocked * - if it has a lock of another type set and the user is the lock owner * * @param user the user to test lockeability for * * @return <code>true</code> if this lock blocks any operation on the locked resource until it is unlocked */ public boolean isLockableBy(CmsUser user) { if (getSystemLock().isPublish()) { return false; } if (getEditionLock().isUnlocked() && getSystemLock().isUnlocked()) { return true; } return getEditionLock().isOwnedBy(user); }
/** * Checks if a resource can be locked by a user.<p> * * The resource is not lockable if it already has a lock of type {@link CmsLockType#PUBLISH}.<p> * * The resource is lockable either * - if it is currently unlocked * - if it has a lock of another type set and the user is the lock owner * * @param user the user to test lockeability for * * @return <code>true</code> if this lock blocks any operation on the locked resource until it is unlocked */ public boolean isLockableBy(CmsUser user) { if (getSystemLock().isPublish()) { return false; } if (getEditionLock().isUnlocked() && getSystemLock().isUnlocked()) { return true; } return getEditionLock().isOwnedBy(user); }
/** * Removes all resources locked in a project.<p> * * @param projectId the ID of the project where the resources have been locked * @param removeSystemLocks if <code>true</code>, also system locks are removed */ public void removeResourcesInProject(CmsUUID projectId, boolean removeSystemLocks) { Iterator<CmsLock> itLocks = OpenCms.getMemoryMonitor().getAllCachedLocks().iterator(); while (itLocks.hasNext()) { CmsLock currentLock = itLocks.next(); if (removeSystemLocks && currentLock.getSystemLock().getProjectId().equals(projectId)) { unlockResource(currentLock.getResourceName(), true); } if (currentLock.getEditionLock().getProjectId().equals(projectId)) { unlockResource(currentLock.getResourceName(), false); } } }
/** * Removes all resources locked in a project.<p> * * @param projectId the ID of the project where the resources have been locked * @param removeSystemLocks if <code>true</code>, also system locks are removed */ public void removeResourcesInProject(CmsUUID projectId, boolean removeSystemLocks) { Iterator itLocks = OpenCms.getMemoryMonitor().getAllCachedLocks().iterator(); while (itLocks.hasNext()) { CmsLock currentLock = (CmsLock)itLocks.next(); if (removeSystemLocks && currentLock.getSystemLock().getProjectId().equals(projectId)) { unlockResource(currentLock.getResourceName(), true); } if (currentLock.getEditionLock().getProjectId().equals(projectId)) { unlockResource(currentLock.getResourceName(), false); } } }
/** * Removes all locks of a user.<p> * * Edition and system locks are removed.<p> * * @param userId the id of the user whose locks should be removed */ public void removeLocks(CmsUUID userId) { Iterator<CmsLock> itLocks = OpenCms.getMemoryMonitor().getAllCachedLocks().iterator(); while (itLocks.hasNext()) { CmsLock currentLock = itLocks.next(); boolean editLock = currentLock.getEditionLock().getUserId().equals(userId); boolean sysLock = currentLock.getSystemLock().getUserId().equals(userId); if (editLock) { unlockResource(currentLock.getResourceName(), false); } if (sysLock) { unlockResource(currentLock.getResourceName(), true); } } }
/** * Removes all locks of a user.<p> * * Edition and system locks are removed.<p> * * @param userId the id of the user whose locks should be removed */ public void removeLocks(CmsUUID userId) { Iterator itLocks = OpenCms.getMemoryMonitor().getAllCachedLocks().iterator(); while (itLocks.hasNext()) { CmsLock currentLock = (CmsLock)itLocks.next(); boolean editLock = currentLock.getEditionLock().getUserId().equals(userId); boolean sysLock = currentLock.getSystemLock().getUserId().equals(userId); if (editLock) { unlockResource(currentLock.getResourceName(), false); } if (sysLock) { unlockResource(currentLock.getResourceName(), true); } } }
/** * Enumeration class for the mode parameter in the * {@link CmsDriverManager#readChangedResourcesInsideProject(CmsDbContext, CmsUUID, CmsReadChangedProjectResourceMode)} * method.<p> */ private static class CmsReadChangedProjectResourceMode { /** * Default constructor.<p> */ protected CmsReadChangedProjectResourceMode() { // noop } }
if (currentLock.getSystemLock().equals(lock) || currentLock.getEditionLock().equals(lock)) { return;
/** * @see org.opencms.gwt.shared.rpc.I_CmsVfsService#forceUnlock(org.opencms.util.CmsUUID) */ public void forceUnlock(CmsUUID structureId) throws CmsRpcException { try { CmsResource resource = getCmsObject().readResource(structureId, CmsResourceFilter.ALL); // get the current lock CmsLock currentLock = getCmsObject().getLock(resource); // check if the resource is locked at all if (currentLock.getEditionLock().isUnlocked() && currentLock.getSystemLock().isUnlocked()) { getCmsObject().lockResourceTemporary(resource); } else { getCmsObject().changeLock(resource); } getCmsObject().unlockResource(resource); } catch (Throwable e) { error(e); } }
lock = lock.getSystemLock(); } else { lock = lock.getEditionLock();
lock = lock.getSystemLock(); } else { lock = lock.getEditionLock();
exclusiveLock.getSystemLock().getType()); if ((lock == null) || !exclusiveLock.getEditionLock().isNullLock()) { CmsLockType type = CmsLockType.SHARED_EXCLUSIVE; if (!getParentLock(siblingName).isNullLock()) {
exclusiveLock.getSystemLock().getType()); if ((lock == null) || !exclusiveLock.getEditionLock().isNullLock()) { CmsLockType type = CmsLockType.SHARED_EXCLUSIVE; if (!getParentLock(siblingName).isNullLock()) {