/** * Builds a string representation of the current state.<p> * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuffer buf = new StringBuffer(); buf.append("[CmsLock: resource: "); buf.append(getResourceName()); buf.append(", type: "); buf.append(getType()); buf.append(", project: "); buf.append(getProjectId()); buf.append(", user: "); buf.append(getUserId()); if (getRelatedLock() != null) { buf.append(", related lock: "); buf.append(getRelatedLock().getType()); } buf.append("]"); return buf.toString(); }
/** * Builds a string representation of the current state.<p> * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuffer buf = new StringBuffer(); buf.append("[CmsLock: resource: "); buf.append(getResourceName()); buf.append(", type: "); buf.append(getType()); buf.append(", project: "); buf.append(getProjectId()); buf.append(", user: "); buf.append(getUserId()); if (getRelatedLock() != null) { buf.append(", related lock: "); buf.append(getRelatedLock().getType()); } buf.append("]"); return buf.toString(); }
stmt.setString(2, sysLock.getUserId().toString()); stmt.setString(3, sysLock.getProjectId().toString()); stmt.setInt(4, sysLock.getType().hashCode()); stmt.executeUpdate(); count++; stmt.setString(2, editLock.getUserId().toString()); stmt.setString(3, editLock.getProjectId().toString()); stmt.setInt(4, editLock.getType().hashCode()); stmt.executeUpdate(); count++;
stmt.setString(2, sysLock.getUserId().toString()); stmt.setString(3, sysLock.getProjectId().toString()); stmt.setInt(4, sysLock.getType().hashCode()); stmt.executeUpdate(); count++; stmt.setString(2, editLock.getUserId().toString()); stmt.setString(3, editLock.getProjectId().toString()); stmt.setInt(4, editLock.getType().hashCode()); stmt.executeUpdate(); count++;
/** * Moves a lock during the move resource operation.<p> * * @param source the source root path * @param destination the destination root path */ public void moveResource(String source, String destination) { CmsLock lock = OpenCms.getMemoryMonitor().getCachedLock(source); if (lock != null) { OpenCms.getMemoryMonitor().uncacheLock(lock.getResourceName()); CmsLock newLock = new CmsLock(destination, lock.getUserId(), lock.getProject(), lock.getType()); lock = lock.getRelatedLock(); if ((lock != null) && !lock.isNullLock()) { CmsLock relatedLock = new CmsLock(destination, lock.getUserId(), lock.getProject(), lock.getType()); newLock.setRelatedLock(relatedLock); } OpenCms.getMemoryMonitor().cacheLock(newLock); } }
/** * Moves a lock during the move resource operation.<p> * * @param source the source root path * @param destination the destination root path */ public void moveResource(String source, String destination) { CmsLock lock = OpenCms.getMemoryMonitor().getCachedLock(source); if (lock != null) { OpenCms.getMemoryMonitor().uncacheLock(lock.getResourceName()); CmsLock newLock = new CmsLock(destination, lock.getUserId(), lock.getProject(), lock.getType()); lock = lock.getRelatedLock(); if ((lock != null) && !lock.isNullLock()) { CmsLock relatedLock = new CmsLock(destination, lock.getUserId(), lock.getProject(), lock.getType()); newLock.setRelatedLock(relatedLock); } OpenCms.getMemoryMonitor().cacheLock(newLock); } }
/** * Returns the lock state of the current resource.<p> * * @return the lock state of the current resource */ public int getLockState() { if (CmsStringUtil.isEmptyOrWhitespaceOnly(getLockedByName())) { // unlocked return 0; } if (!getLockedByName().equals(getCurrentOuRelativeName(m_request.currentUser().getName())) || !getLockedInProjectId().equals(m_request.currentProject().getUuid())) { // locked by other user and/or project return 1; } if (getLock().getType().isShared()) { // shared lock return 2; } // exclusive lock return 3; }
/** * Returns the lock state of the current resource.<p> * * @return the lock state of the current resource */ public int getLockState() { if (CmsStringUtil.isEmptyOrWhitespaceOnly(getLockedByName())) { // unlocked return 0; } if (!getLockedByName().equals(getCurrentOuRelativeName(m_request.getCurrentUser().getName())) || !getLockedInProjectId().equals(m_request.getCurrentProject().getUuid())) { // locked by other user and/or project return 1; } if (getLock().getType().isShared()) { // shared lock return 2; } // exclusive lock return 3; }
match = m_types.contains(lock.getType()); match = match || (m_includeParents && lock.isInherited());
match = m_types.contains(lock.getType()); match = match || (m_includeParents && lock.isInherited());
if (lock.getType().isSharedExclusive()) { List<String> locks = OpenCms.getMemoryMonitor().getAllCachedLockPaths();
if (lock.getType().isSharedExclusive()) { List locks = OpenCms.getMemoryMonitor().getAllCachedLockPaths();
/** * Generates a client side lock info object representing the current lock state of the given resource.<p> * * @param resource the resource * * @return the client lock * * @throws CmsException if something goes wrong */ private CmsClientLock generateClientLock(CmsResource resource) throws CmsException { CmsObject cms = getCmsObject(); CmsLock lock = cms.getLock(resource); CmsClientLock clientLock = new CmsClientLock(); clientLock.setLockType(CmsClientLock.LockType.valueOf(lock.getType().getMode())); CmsUUID ownerId = lock.getUserId(); if (!lock.isUnlocked() && (ownerId != null)) { clientLock.setLockOwner(cms.readUser(ownerId).getDisplayName(cms, cms.getRequestContext().getLocale())); clientLock.setOwnedByUser(cms.getRequestContext().getCurrentUser().getId().equals(ownerId)); } return clientLock; }
/** * Returns the lock information to the given resource.<p> * * @param resource the resource * * @return lock information, if the page is locked by another user * * @throws CmsException if something goes wrong reading the lock owner user */ private String getLockInfo(CmsResource resource) throws CmsException { CmsObject cms = getCmsObject(); CmsResourceUtil resourceUtil = new CmsResourceUtil(cms, resource); CmsLock lock = resourceUtil.getLock(); String lockInfo = null; if (!lock.isLockableBy(cms.getRequestContext().getCurrentUser())) { if (lock.getType() == CmsLockType.PUBLISH) { lockInfo = Messages.get().getBundle(OpenCms.getWorkplaceManager().getWorkplaceLocale(cms)).key( Messages.GUI_LOCKED_FOR_PUBLISH_0); } else { CmsUser lockOwner = cms.readUser(lock.getUserId()); lockInfo = Messages.get().getBundle(OpenCms.getWorkplaceManager().getWorkplaceLocale(cms)).key( Messages.GUI_LOCKED_BY_1, lockOwner.getFullName()); } } return lockInfo; }
exclusiveLock.getUserId(), exclusiveLock.getProject(), exclusiveLock.getSystemLock().getType());
exclusiveLock.getUserId(), exclusiveLock.getProject(), exclusiveLock.getSystemLock().getType());
|| (currentLock.getType() != type) || !currentLock.isOwnedInProjectBy(user, project)) {
|| (currentLock.getType() != type) || !currentLock.isOwnedInProjectBy(user, project)) {
LockIcon icon = LockIcon.NONE; String iconTitle = null; CmsLockType lockType = lock.getType(); if (!lock.isOwnedBy(cms.getRequestContext().getCurrentUser())) { if ((lockType == CmsLockType.EXCLUSIVE)