/** * Counts the locked resources in this project.<p> * * @param project the project to count the locked resources in * * @return the amount of locked resources in this project */ public int countLockedResources(CmsProject project) { // count locks return m_lockManager.countExclusiveLocksInProject(project); }
/** * Returns the indirect lock of a resource depending on siblings lock state.<p> * * @param siblings the list of siblings * @param resourcename the name of the resource * * @return the indirect lock of the resource or the null lock */ private CmsLock getSiblingsLock(List<CmsResource> siblings, String resourcename) { for (int i = 0; i < siblings.size(); i++) { CmsResource sibling = siblings.get(i); CmsLock exclusiveLock = getDirectLock(sibling.getRootPath()); if (exclusiveLock != null) { // a sibling is already locked return internalSiblingLock(exclusiveLock, resourcename); } } // no locked siblings found return null; }
/** * Returns the lock state of a resource.<p> * * @param dbc the current database context * @param resource the resource to return the lock state for * * @return the lock state of the resource * * @throws CmsException if something goes wrong */ public CmsLock getLock(CmsDbContext dbc, CmsResource resource) throws CmsException { return m_lockManager.getLock(dbc, resource); }
CmsLock lock = getDirectLock(resource.getRootPath()); if ((lock == null) && includeSiblings) { List<CmsResource> siblings = internalReadSiblings(dbc, resource); lock = getSiblingsLock(siblings, resource.getRootPath()); lock = getParentLock(resource.getRootPath());
CmsLock currentLock = getLock(dbc, resource); checkLockable(dbc, resource, user, project, type, currentLock); lockResource(newLock); String lockedPath = lock.getResourceName(); if (lockedPath.startsWith(resourceName) && !lockedPath.equals(resourceName)) { unlockResource(lockedPath, false);
CmsLock lock = getLock(dbc, resource).getEditionLock(); if (lockedPath.startsWith(resourcename) && !lockedPath.equals(resourcename)) { unlockResource(lockedPath, false); unlockResource(resourcename, true); unlockResource(resourcename, false); return lock; List<CmsResource> siblings = internalReadSiblings(dbc, resource); for (int i = 0; i < siblings.size(); i++) { CmsResource sibling = siblings.get(i); unlockResource(sibling.getRootPath(), true); unlockResource(sibling.getRootPath(), false); break; // it can only be one! if (removeSystemLock && !getLock(dbc, resource).getSystemLock().isUnlocked()) { return unlockResource(resourcename, true);
/** * Returns the inherited lock of a resource.<p> * * @param resourcename the name of the resource * @return the inherited lock or the null lock */ private CmsLock getParentLock(String resourcename) { CmsLock parentFolderLock = getParentFolderLock(resourcename); if (!parentFolderLock.isNullLock()) { return new CmsLock( resourcename, parentFolderLock.getUserId(), parentFolderLock.getProject(), CmsLockType.INHERITED); } return CmsLock.getNullLock(); }
/** * Returns all locked resources in a given folder.<p> * * @param dbc the current database context * @param resource the folder to search in * @param filter the lock filter * * @return a list of locked resource paths (relative to current site) * * @throws CmsException if the current project is locked */ public List getLockedResources(CmsDbContext dbc, CmsResource resource, CmsLockFilter filter) throws CmsException { List lockedResources = new ArrayList(); // get locked resources Iterator it = m_lockManager.getLocks(dbc, resource.getRootPath(), filter).iterator(); while (it.hasNext()) { CmsLock lock = (CmsLock)it.next(); lockedResources.add(dbc.removeSiteRoot(lock.getResourceName())); } Collections.sort(lockedResources); return lockedResources; }
if (!getParentLock(siblingName).isNullLock()) { type = CmsLockType.SHARED_INHERITED;
m_lockManager.addResource(dbc, resource, dbc.currentUser(), project, type); boolean changedProjectLastModified = false; if (!resource.getState().isUnchanged() && !resource.getState().isKeep()) {
driverManager.m_lockManager = new CmsLockManager(driverManager);
CmsLock lock = getDirectLock(resource.getRootPath()); if ((lock == null) && includeSiblings) { List siblings = internalReadSiblings(dbc, resource); lock = getSiblingsLock(siblings, resource.getRootPath()); lock = getParentLock(resource.getRootPath());
CmsLock currentLock = getLock(dbc, resource); checkLockable(dbc, resource, user, project, type, currentLock); lockResource(newLock); String lockedPath = lock.getResourceName(); if (lockedPath.startsWith(resourceName) && !lockedPath.equals(resourceName)) { unlockResource(lockedPath, false);
CmsLock lock = getLock(dbc, resource).getEditionLock(); if (lockedPath.startsWith(resourcename) && !lockedPath.equals(resourcename)) { unlockResource(lockedPath, false); unlockResource(resourcename, true); unlockResource(resourcename, false); return lock; List siblings = internalReadSiblings(dbc, resource); for (int i = 0; i < siblings.size(); i++) { CmsResource sibling = (CmsResource)siblings.get(i); unlockResource(sibling.getRootPath(), true); unlockResource(sibling.getRootPath(), false); break; // it can only be one! if (removeSystemLock && !getLock(dbc, resource).getSystemLock().isUnlocked()) { return unlockResource(resourcename, true);
/** * Returns the inherited lock of a resource.<p> * * @param resourcename the name of the resource * @return the inherited lock or the null lock */ private CmsLock getParentLock(String resourcename) { CmsLock parentFolderLock = getParentFolderLock(resourcename); if (!parentFolderLock.isNullLock()) { return new CmsLock( resourcename, parentFolderLock.getUserId(), parentFolderLock.getProject(), CmsLockType.INHERITED); } return CmsLock.getNullLock(); }
/** * Returns all locked resources in a given folder.<p> * * @param dbc the current database context * @param resource the folder to search in * @param filter the lock filter * * @return a list of locked resource paths (relative to current site) * * @throws CmsException if the current project is locked */ public List<String> getLockedResources(CmsDbContext dbc, CmsResource resource, CmsLockFilter filter) throws CmsException { List<String> lockedResources = new ArrayList<String>(); // get locked resources Iterator<CmsLock> it = m_lockManager.getLocks(dbc, resource.getRootPath(), filter).iterator(); while (it.hasNext()) { CmsLock lock = it.next(); lockedResources.add(dbc.removeSiteRoot(lock.getResourceName())); } Collections.sort(lockedResources); return lockedResources; }
if (!getParentLock(siblingName).isNullLock()) { type = CmsLockType.SHARED_INHERITED;
m_lockManager.addResource(dbc, resource, dbc.currentUser(), project, type);
driverManager.m_lockManager = new CmsLockManager(driverManager);
/** * Returns the lock state of a resource.<p> * * @param dbc the current database context * @param resource the resource to return the lock state for * * @return the lock state of the resource * * @throws CmsException if something goes wrong */ public CmsLock getLock(CmsDbContext dbc, CmsResource resource) throws CmsException { return m_lockManager.getLock(dbc, resource); }