/** * @see org.opencms.file.wrapper.I_CmsResourceWrapper#getLock(org.opencms.file.CmsObject, org.opencms.file.CmsResource) */ public CmsLock getLock(CmsObject cms, CmsResource resource) throws CmsException { if (m_isWrappedResource) { return cms.getLock(resource); } return null; }
/** * @see org.opencms.file.wrapper.I_CmsResourceWrapper#getLock(org.opencms.file.CmsObject, org.opencms.file.CmsResource) */ public CmsLock getLock(CmsObject cms, CmsResource resource) throws CmsException { if (m_isWrappedResource) { return cms.getLock(resource); } return null; }
/** * Returns the lock state for a specified resource name.<p> * * If the resource is waiting to be publish you might get a lock of type {@link CmsLockType#PUBLISH}.<p> * * @param resourcename the name if the resource to get the lock state for (full current site relative path) * * @return the lock state for the specified resource * * @throws CmsException if something goes wrong */ public CmsLock getLock(String resourcename) throws CmsException { CmsResource resource = readResource(resourcename, CmsResourceFilter.ALL); return getLock(resource); }
/** * Returns the lock state for a specified resource name.<p> * * If the resource is waiting to be publish you might get a lock of type {@link CmsLockType#PUBLISH}.<p> * * @param resourcename the name if the resource to get the lock state for (full current site relative path) * * @return the lock state for the specified resource * * @throws CmsException if something goes wrong */ public CmsLock getLock(String resourcename) throws CmsException { CmsResource resource = readResource(resourcename, CmsResourceFilter.ALL); return getLock(resource); }
/** * Returns the the lock for the given resource.<p> * * @return the lock the given resource */ public CmsLock getLock() { if (m_lock == null) { try { m_lock = getCms().getLock(m_resource); } catch (Throwable e) { m_lock = CmsLock.getNullLock(); LOG.error(e.getLocalizedMessage(), e); } } return m_lock; }
/** * @see org.opencms.file.wrapper.A_CmsResourceWrapper#getLock(org.opencms.file.CmsObject, org.opencms.file.CmsResource) */ @Override public CmsLock getLock(CmsObject cms, CmsResource resource) throws CmsException { CmsResource org = getResource(cms, resource.getStructureId()); if (org != null) { return cms.getLock(org); } return null; }
/** * @see org.opencms.file.wrapper.A_CmsResourceWrapper#getLock(org.opencms.file.CmsObject, org.opencms.file.CmsResource) */ @Override public CmsLock getLock(CmsObject cms, CmsResource resource) throws CmsException { CmsResource org = cms.readResource(resource.getStructureId()); //CmsResource org = getResource(cms, resource.getRootPath(), CmsResourceFilter.DEFAULT); if (org != null) { return cms.getLock(org); } return null; }
/** * Returns the the lock for the given resource.<p> * * @return the lock the given resource */ public CmsLock getLock() { if (m_lock == null) { try { m_lock = getCms().getLock(m_resource); } catch (Throwable e) { m_lock = CmsLock.getNullLock(); LOG.error(e.getLocalizedMessage(), e); } } return m_lock; }
/** * Tries to lock a resource and throws an exception if it can't be locked.<p> * * Returns true only if the resource wasn't already locked before.<p> * * @param cms the CMS context * @param resource the resource to lock * @return true if the resource wasn't already locked * * @throws CmsException if something goes wrong */ public static boolean ensureLock(CmsObject cms, CmsResource resource) throws CmsException { CmsLock lock = cms.getLock(resource); if (lock.isOwnedBy(cms.getRequestContext().getCurrentUser())) { return false; } cms.lockResourceTemporary(resource); return true; }
/** * @see org.opencms.file.wrapper.A_CmsResourceWrapper#getLock(org.opencms.file.CmsObject, org.opencms.file.CmsResource) */ @Override public CmsLock getLock(CmsObject cms, CmsResource resource) throws CmsException { CmsResource xmlPage = cms.readResource(resource.getStructureId()); //CmsResource xmlPage = findXmlPage(cms, resource.getRootPath()); if (xmlPage != null) { I_CmsResourceType resType = OpenCms.getResourceManager().getResourceType(xmlPage.getTypeId()); if (resType instanceof CmsResourceTypeXmlPage) { return cms.getLock(xmlPage); } } return null; }
/** * @see org.opencms.file.wrapper.A_CmsResourceWrapper#getLock(org.opencms.file.CmsObject, org.opencms.file.CmsResource) */ @Override public CmsLock getLock(CmsObject cms, CmsResource resource) throws CmsException { CmsResource xmlPage = cms.readResource(resource.getStructureId()); //CmsResource xmlPage = findXmlPage(cms, resource.getRootPath()); if (xmlPage != null) { I_CmsResourceType resType = OpenCms.getResourceManager().getResourceType(xmlPage.getTypeId()); if (resType instanceof CmsResourceTypeXmlPage) { return cms.getLock(xmlPage); } } return null; }
/** * Checks that the resource is not locked by another user.<p> * * @param resource the resource * @return true if the resource is not locked by another user * * @throws CmsException if something goes wrong */ private boolean checkLock(CmsResource resource) throws CmsException { CmsLock lock = m_cms.getLock(resource); return lock.isUnlocked() || lock.getUserId().equals(m_cms.getRequestContext().getCurrentUser().getId()); }
/** * @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.file.wrapper.A_CmsResourceWrapper#getLock(org.opencms.file.CmsObject, org.opencms.file.CmsResource) */ @Override public CmsLock getLock(CmsObject cms, CmsResource resource) throws CmsException { if (checkTypeId(resource.getTypeId())) { CmsWrappedResource wrap = new CmsWrappedResource(resource); wrap.setRootPath(CmsResourceWrapperUtils.removeFileExtension(cms, resource.getRootPath(), getExtension())); return cms.getLock(wrap.getResource()); } return null; }
/** * @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.file.wrapper.A_CmsResourceWrapper#getLock(org.opencms.file.CmsObject, org.opencms.file.CmsResource) */ @Override public CmsLock getLock(CmsObject cms, CmsResource resource) throws CmsException { if (checkTypeId(resource.getTypeId())) { CmsWrappedResource wrap = new CmsWrappedResource(resource); wrap.setRootPath(CmsResourceWrapperUtils.removeFileExtension(cms, resource.getRootPath(), getExtension())); return cms.getLock(wrap.getResource()); } return null; }
/** * 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); } }
/** * Deletes the given resource which is part of a form session project.<p> * * @param cms the CMS context to use * @param res the resource to delete * * @throws CmsException if something goes wrong */ private void deleteResourceFromProject(CmsObject cms, CmsResource res) throws CmsException { CmsLock lock = cms.getLock(res); if (lock.isUnlocked() || lock.isLockableBy(cms.getRequestContext().getCurrentUser())) { cms.lockResourceTemporary(res); } else { cms.changeLock(res); } cms.deleteResource(cms.getSitePath(res), CmsResource.DELETE_PRESERVE_SIBLINGS); }
/** * @see org.opencms.gwt.shared.rpc.I_CmsVfsService#getFileReplaceInfo(org.opencms.util.CmsUUID) */ public CmsReplaceInfo getFileReplaceInfo(CmsUUID structureId) throws CmsRpcException { CmsReplaceInfo result = null; try { CmsObject cms = getCmsObject(); CmsResource res = cms.readResource(structureId, CmsResourceFilter.IGNORE_EXPIRATION); CmsListInfoBean fileInfo = getPageInfo(res); boolean isLockable = cms.getLock(res).isLockableBy(cms.getRequestContext().getCurrentUser()); long maxFileSize = OpenCms.getWorkplaceManager().getFileBytesMaxUploadSize(cms); result = new CmsReplaceInfo(fileInfo, cms.getSitePath(res), isLockable, maxFileSize); } catch (Throwable e) { error(e); } return result; }
/** * @see org.opencms.workflow.CmsDefaultPublishResourceFormatter.I_PublishResourceValidator#getInfoForResource(org.opencms.file.CmsResource) */ public CmsPublishResourceInfo getInfoForResource(CmsResource resource) throws CmsException { String info; CmsPublishResourceInfo.Type infoType; CmsPublishResourceInfo infoObj; CmsLock lock = m_cms.getLock(resource); info = Messages.get().getBundle(getLocale()).key( Messages.GUI_RESOURCE_LOCKED_BY_2, getOuAwareName(m_cms, m_cms.readUser(lock.getUserId()).getName()), getOuAwareName(m_cms, lock.getProject().getName())); infoType = CmsPublishResourceInfo.Type.LOCKED; infoObj = new CmsPublishResourceInfo(info, infoType); return infoObj; } }