/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#getVisibility(org.opencms.file.CmsObject, CmsResourceUtil[]) */ @Override public CmsMenuItemVisibilityMode getVisibility(CmsObject cms, CmsResourceUtil[] resourceUtil) { // set inactive if lock is inherited if (resourceUtil[0].getLock().isInherited()) { return CmsMenuItemVisibilityMode.VISIBILITY_INACTIVE.addMessageKey( Messages.GUI_CONTEXTMENU_TITLE_INACTIVE_LOCK_INHERITED_0); } return CmsMenuItemVisibilityMode.VISIBILITY_ACTIVE; }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#getVisibility(org.opencms.file.CmsObject, CmsResourceUtil[]) */ @Override public CmsMenuItemVisibilityMode getVisibility(CmsObject cms, CmsResourceUtil[] resourceUtil) { // set inactive if lock is inherited if (resourceUtil[0].getLock().isInherited()) { return CmsMenuItemVisibilityMode.VISIBILITY_INACTIVE.addMessageKey(Messages.GUI_CONTEXTMENU_TITLE_INACTIVE_LOCK_INHERITED_0); } return CmsMenuItemVisibilityMode.VISIBILITY_ACTIVE; }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#getVisibility(org.opencms.file.CmsObject, CmsResourceUtil[]) */ @Override public CmsMenuItemVisibilityMode getVisibility(CmsObject cms, CmsResourceUtil[] resourceUtil) { if (resourceUtil[0].isEditable() && !resourceUtil[0].getProjectState().isLockedForPublishing() && !resourceUtil[0].getLock().isInherited()) { return CmsMenuItemVisibilityMode.VISIBILITY_ACTIVE; } else if (resourceUtil[0].getLock().isInherited()) { return CmsMenuItemVisibilityMode.VISIBILITY_INACTIVE.addMessageKey(Messages.GUI_CONTEXTMENU_TITLE_INACTIVE_LOCK_INHERITED_0); } return CmsMenuItemVisibilityMode.VISIBILITY_INVISIBLE; }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#getVisibility(org.opencms.file.CmsObject, CmsResourceUtil[]) */ @Override public CmsMenuItemVisibilityMode getVisibility(CmsObject cms, CmsResourceUtil[] resourceUtil) { if (resourceUtil[0].isEditable() && !resourceUtil[0].getProjectState().isLockedForPublishing() && !resourceUtil[0].getLock().isInherited()) { return CmsMenuItemVisibilityMode.VISIBILITY_ACTIVE; } else if (resourceUtil[0].getLock().isInherited()) { return CmsMenuItemVisibilityMode.VISIBILITY_INACTIVE.addMessageKey( Messages.GUI_CONTEXTMENU_TITLE_INACTIVE_LOCK_INHERITED_0); } return CmsMenuItemVisibilityMode.VISIBILITY_INVISIBLE; }
/** * @see org.opencms.repository.I_CmsRepositorySession#create(java.lang.String) */ public void create(String path) throws CmsException { path = validatePath(path); if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_CREATE_ITEM_1, path)); } // create the folder CmsResource res = m_cms.createResource(path, CmsResourceTypeFolder.RESOURCE_TYPE_ID); // unlock new created folders if lock is not inherited if (!m_cms.getLock(res).isInherited()) { m_cms.unlockResource(path); } }
/** * @see org.opencms.repository.I_CmsRepositorySession#create(java.lang.String) */ public void create(String path) throws CmsException { path = validatePath(path); if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_CREATE_ITEM_1, path)); } // create the folder CmsResource res = m_cms.createResource(path, CmsResourceTypeFolder.RESOURCE_TYPE_ID); // unlock new created folders if lock is not inherited if (!m_cms.getLock(res).isInherited()) { m_cms.unlockResource(path); } }
/** * Returns the id of the project which the resource belongs to.<p> * * @return the id of the project which the resource belongs to */ public CmsUUID getProjectId() { CmsUUID projectId = m_resource.getProjectLastModified(); if (!getLock().isUnlocked() && !getLock().isInherited()) { // use lock project ID only if lock is not inherited projectId = getLock().getProjectId(); } return projectId; }
/** * Returns the id of the project which the resource belongs to.<p> * * @return the id of the project which the resource belongs to */ public CmsUUID getProjectId() { CmsUUID projectId = m_resource.getProjectLastModified(); if (!getLock().isUnlocked() && !getLock().isInherited()) { // use lock project ID only if lock is not inherited projectId = getLock().getProjectId(); } return projectId; }
/** * @see org.opencms.workplace.CmsWorkplace#checkLock(String, CmsLockType) */ @Override public void checkLock(String resource, CmsLockType type) throws CmsException { CmsResource res = getCms().readResource(resource, CmsResourceFilter.ALL); CmsLock lock = getCms().getLock(res); if (!lock.isNullLock()) { setParamModified(Boolean.TRUE.toString()); } // for resources with siblings make sure all sibling have at least a // temporary lock if ((res.getSiblingCount() > 1) && (lock.isInherited())) { super.checkLock(resource, CmsLockType.TEMPORARY); } else { super.checkLock(resource, type); } }
/** * @see org.opencms.workplace.CmsWorkplace#checkLock(String, CmsLockType) */ @Override public void checkLock(String resource, CmsLockType type) throws CmsException { CmsResource res = getCms().readResource(resource, CmsResourceFilter.ALL); CmsLock lock = getCms().getLock(res); if (!lock.isNullLock()) { setParamModified(Boolean.TRUE.toString()); } // for resources with siblings make sure all sibling have at least a // temporary lock if ((res.getSiblingCount() > 1) && (lock.isInherited())) { super.checkLock(resource, CmsLockType.TEMPORARY); } else { super.checkLock(resource, type); } }
/** * 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(); }
if (!lock.isInherited()) { m_cms.lockResource(path); if (!m_cms.getLock(res).isInherited()) { m_cms.unlockResource(path);
if (!lock.isInherited()) { m_cms.lockResource(path); if (!m_cms.getLock(res).isInherited()) { m_cms.unlockResource(path);
/** * Tries to remove a lock on an ancestor of a given path owned by the current user.<p> * * @param cms the CMS context * @param folderPath the path for which the lock should be removed * * @throws CmsException if something goes wrong */ protected void tryToUnlock(CmsObject cms, String folderPath) throws CmsException { // Get path of first ancestor that actually exists while (!cms.existsResource(folderPath)) { folderPath = CmsResource.getParentFolder(folderPath); } CmsResource resource = cms.readResource(folderPath); CmsLock lock = cms.getLock(resource); // we are only interested in locks we can safely unlock, i.e. locks by the current user if (lock.isOwnedBy(cms.getRequestContext().getCurrentUser())) { // walk up the tree until we get to the location from which the lock is inherited while (lock.isInherited()) { folderPath = CmsResource.getParentFolder(folderPath); resource = cms.readResource(folderPath); lock = cms.getLock(resource); } cms.unlockResource(folderPath); } }
/** * Ensures that the resources to be released are unlocked.<p> * * @param project the project in which to operate * @param resources the resources for which the locks should be removed * * @throws CmsException if something goes wrong */ protected void clearLocks(CmsProject project, List<CmsResource> resources) throws CmsException { CmsObject rootCms = OpenCms.initCmsObject(m_adminCms); rootCms.getRequestContext().setCurrentProject(project); rootCms.getRequestContext().setSiteRoot(""); for (CmsResource resource : resources) { CmsLock lock = rootCms.getLock(resource); if (lock.isUnlocked()) { continue; } String currentPath = resource.getRootPath(); while (lock.isInherited()) { currentPath = CmsResource.getParentFolder(currentPath); lock = rootCms.getLock(currentPath); } rootCms.changeLock(currentPath); rootCms.unlockResource(currentPath); } }
/** * Recursively steps up to the resource that is the originator of the given * resource which has an inherited lock.<p> * * @param absoluteResourcename the absolute resource with the inherited lock * * @throws CmsException if something goes wrong */ private void unlockInherited(final String absoluteResourcename) throws CmsException { CmsObject cms = getCms(); CmsLock parentLock = getParentLock(absoluteResourcename); if (!parentLock.isNullLock()) { if (parentLock.isInherited()) { unlockInherited(parentLock.getResourceName()); } else { if (!parentLock.isLockableBy(cms.getRequestContext().getCurrentUser())) { cms.changeLock(cms.getRequestContext().removeSiteRoot(parentLock.getResourceName())); } cms.unlockResource(cms.getRequestContext().removeSiteRoot(parentLock.getResourceName())); } } } }
if (lock.isInherited()) { return CmsMenuItemVisibilityMode.VISIBILITY_INACTIVE.addMessageKey(Messages.GUI_CONTEXTMENU_TITLE_INACTIVE_PUBLISH_INHERITED_0);
if (lock.isInherited()) { return CmsMenuItemVisibilityMode.VISIBILITY_INACTIVE.addMessageKey( Messages.GUI_CONTEXTMENU_TITLE_INACTIVE_PUBLISH_INHERITED_0);
Messages.ERR_RESOURCE_LOCKED_FORPUBLISH_1, dbc.getRequestContext().getSitePath(resource)); } else if (currentLock.getEditionLock().isInherited()) { message = Messages.get().container( Messages.ERR_RESOURCE_LOCKED_INHERITED_1,