/** * Locks the current resource.<p> * * @throws CmsException in case locking the resource fails */ private void ensureLock() throws CmsException { if (m_lockActionRecord == null) { m_lockActionRecord = CmsLockUtil.ensureLock(m_cms, m_resource); } }
/** Private constructor. * @param cms the cms user context. * @param resource the resource to lock and read. * @throws CmsException thrown if locking fails. */ private LockedFile(CmsObject cms, CmsResource resource) throws CmsException { m_lockRecord = CmsLockUtil.ensureLock(cms, resource); m_file = cms.readFile(resource); m_new = false; m_cms = cms; }
/** * Locks the given resource with a temporary, if not already locked by the current user. * Will throw an exception if the resource could not be locked for the current user.<p> * * @param resource the resource to lock * * @return the assigned lock * * @throws CmsException if the resource could not be locked */ protected CmsLockActionRecord ensureLock(CmsResource resource) throws CmsException { CmsObject cms = getCmsObject(); return CmsLockUtil.ensureLock(cms, resource); }
try { for (CmsResource resource : resources) { CmsLockActionRecord record = ensureLock(cms, resource); lockMap.put(resource, record);
CmsResource resource = i.next(); CmsLockActionRecord lockRecord = CmsLockUtil.ensureLock(cms, resource); try {
/** * @see org.opencms.ui.components.I_CmsFilePropertyEditHandler#start() */ public void start() { CmsObject cms = A_CmsUI.getCmsObject(); try { CmsResource res = cms.readResource(m_editId); m_lockActionRecord = CmsLockUtil.ensureLock(cms, res); CmsAppWorkplaceUi.get().disableGlobalShortcuts(); m_fileTable.startEdit(m_editId, m_editProperty, this); } catch (CmsException e) { CmsErrorDialog.showErrorDialog(e); LOG.debug(e.getLocalizedMessage(), e); } }
String resourcePath = cms.getRequestContext().removeSiteRoot(resource.getRootPath()); CmsLockActionRecord lockRecord = CmsLockUtil.ensureLock(cms, resource); try {
/** * Touches a resource and all its children.<p> * * This method also rewrites the content for all files in the subtree. * * @param resourcePath the site path of the resource * * @throws Exception if something goes wrong */ public void touchResource(String resourcePath) throws Exception { CmsResource resource = m_cms.readResource(resourcePath); CmsLockActionRecord action = CmsLockUtil.ensureLock(m_cms, resource); try { OpenCms.getWorkplaceManager().flushMessageCache(); // One important reason for touching resources via the shell is to write mapped values containing // localization macros to properties, so we flush the workplace messages immediately before the touch operation // in case an older version of the workplace messages (not containing the keys we need) has already been cached touchSingleResource(m_cms, resourcePath, System.currentTimeMillis(), true, true, true); } finally { if (action.getChange() == LockChange.locked) { m_cms.unlockResource(resource); } } }
CmsLockActionRecord actionRecord = null; try { actionRecord = CmsLockUtil.ensureLock(m_context.getCms(), resource); touchSingleResource( m_context.getCms().getSitePath(resource),
/** * Undeletes the selected files * * @return the ids of the modified resources * * @throws CmsException if something goes wrong */ protected List<CmsUUID> undelete() throws CmsException { List<CmsUUID> modifiedResources = new ArrayList<CmsUUID>(); CmsObject cms = m_context.getCms(); for (CmsResource resource : m_context.getResources()) { CmsLockActionRecord actionRecord = null; try { actionRecord = CmsLockUtil.ensureLock(m_context.getCms(), resource); cms.undeleteResource(cms.getSitePath(resource), true); modifiedResources.add(resource.getStructureId()); } finally { if ((actionRecord != null) && (actionRecord.getChange() == LockChange.locked)) { try { cms.unlockResource(resource); } catch (CmsLockException e) { LOG.warn(e.getLocalizedMessage(), e); } } } } return modifiedResources; }
/** * @see org.opencms.ui.dialogs.CmsNewDialog#handleSelection(org.opencms.ade.galleries.shared.CmsResourceTypeBean) */ @Override public void handleSelection(CmsResourceTypeBean typeBean) { CmsResource changeRes = m_dialogContext.getResources().get(0); CmsObject cms = A_CmsUI.getCmsObject(); CmsLockActionRecord lockRecord = null; try { lockRecord = CmsLockUtil.ensureLock(cms, changeRes); cms.chtype(cms.getSitePath(changeRes), OpenCms.getResourceManager().getResourceType(typeBean.getType())); m_dialogContext.finish(Arrays.asList(changeRes.getStructureId())); } catch (CmsException e) { m_dialogContext.error(e); } finally { if ((lockRecord != null) && (lockRecord.getChange() == LockChange.locked)) { try { cms.unlockResource(changeRes); m_dialogContext.finish(Arrays.asList(changeRes.getStructureId())); } catch (CmsException e) { LOG.error(e.getLocalizedMessage()); } } } }
actionRecord = CmsLockUtil.ensureLock(m_context.getCms(), resource); CmsResourceUndoMode mode = CmsResourceUndoMode.getUndoMode(undoMove, recursive); cms.undoChanges(cms.getSitePath(resource), mode);
for (CmsResource resource : m_context.getResources()) { changedIds.add(resource.getStructureId()); CmsLockActionRecord lockRecord = CmsLockUtil.ensureLock(cms, resource); try { cms.deleteResource(cms.getSitePath(resource), mode);
/** The dialog mode. */ public static enum DialogMode { /** Allow copy only. */ copy, /** Allow copy and move. */ copy_and_move, /** Allow move only. */ move }
CmsLockActionRecord actionRecord = null; try { actionRecord = CmsLockUtil.ensureLock(m_context.getCms(), resource);
actionRecord = CmsLockUtil.ensureLock(cms, fileToModify2); m_localeContext.getComparisonLocale().toString(); CmsProperty prop = cms.readPropertyObject(
actionRecord = CmsLockUtil.ensureLock(cms, fileToModify2); m_localeContext.getComparisonLocale().toString(); CmsProperty prop = cms.readPropertyObject(
CmsLockActionRecord record = CmsLockUtil.ensureLock(m_cms, secondaryPage); try { m_cms.deleteRelationsFromResource(
CmsLockActionRecord actionRecord = CmsLockUtil.ensureLock(cms, resource); try { Map<String, CmsProperty> ownProps = getPropertiesByName(cms.readPropertyObjects(resource, false));
CmsLockActionRecord record = CmsLockUtil.ensureLock(m_cms, resourceToModify); try { m_cms.deleteRelationsFromResource(resourceToModify, typeFilter);