public boolean unlock() throws CmsException { if (!m_lockRecord.getChange().equals(LockChange.unchanged) || m_new) { m_cms.unlockResource(m_file); return true; } else { return false; } }
@SuppressWarnings("synthetic-access") public void close() { for (Map.Entry<CmsResource, CmsLockActionRecord> entry : lockMap.entrySet()) { if (entry.getValue().getChange() == LockChange.locked) { CmsResource resourceToUnlock = entry.getKey(); // the resource may have been moved, so we read it again to get the correct path try { resourceToUnlock = cms.readResource(entry.getKey().getStructureId(), CmsResourceFilter.ALL); } catch (CmsException e) { LOG.error(e.getLocalizedMessage(), e); } try { cms.unlockResource(resourceToUnlock); } catch (CmsException e) { LOG.warn(e.getLocalizedMessage(), e); } } } } };
/** * Clears the resource lock.<p> * * @throws CmsException in case reading the resource fails */ private void clearLock() throws CmsException { if ((m_lockActionRecord != null) && (m_lockActionRecord.getChange() == LockChange.locked)) { CmsResource updatedRes = m_cms.readResource(m_resource.getStructureId(), CmsResourceFilter.ALL); try { m_cms.unlockResource(updatedRes); } catch (CmsLockException e) { LOG.warn(e.getLocalizedMessage(), e); } m_lockActionRecord = null; } }
String.valueOf(enableNotification)); } finally { if (lockRecord.getChange() == LockChange.locked) { cms.unlockResource(resource);
/** * Cancels the edit process. Unlocks the resource if required.<p> * * @see org.opencms.ui.components.I_CmsFilePropertyEditHandler#cancel() */ public void cancel() { if (m_lockActionRecord.getChange() == LockChange.locked) { CmsObject cms = A_CmsUI.getCmsObject(); try { CmsResource res = cms.readResource(m_editId); cms.unlockResource(res); } catch (CmsException e) { LOG.warn("Failed to unlock resource " + m_editId.toString(), e); } } CmsAppWorkplaceUi.get().enableGlobalShortcuts(); }
String.valueOf(enableNotification)); } finally { if (lockRecord.getChange() == LockChange.locked) { cms.unlockResource(resource);
/** * 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); } } }
/** * 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; }
changedIds.add(resource.getStructureId()); } finally { if ((actionRecord != null) && (actionRecord.getChange() == LockChange.locked)) { try { m_context.getCms().unlockResource(resource);
/** * @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()); } } } }
cms.deleteResource(cms.getSitePath(resource), mode); } finally { if (lockRecord.getChange().equals(LockChange.locked)) { if (!resource.getState().isNew()) { try {
if ((actionRecord != null) && (actionRecord.getChange() == LockChange.locked)) { try { m_context.getCms().unlockResource(cms.readResource(resource.getStructureId()));
cms.writeResource(resource); } finally { if ((actionRecord != null) && (actionRecord.getChange() == LockChange.locked)) { try { cms.unlockResource(resource);
/** The dialog mode. */ public static enum DialogMode { /** Allow copy only. */ copy, /** Allow copy and move. */ copy_and_move, /** Allow move only. */ move }
if ((actionRecord != null) && (actionRecord.getChange() == LockChange.locked)) { try { cms.unlockResource(fileToModify2);
CmsRelationType.LOCALE_VARIANT.getName()); } finally { if (record.getChange() == LockChange.locked) { m_cms.unlockResource(secondaryPage);
if ((actionRecord != null) && (actionRecord.getChange() == LockChange.locked)) { try { cms.unlockResource(fileToModify2);
if (m_lockActionRecord.getChange() == LockChange.locked) { CmsResource updatedRes = cms.readResource(res.getStructureId(), CmsResourceFilter.ALL); try {
adjustLocalesForElement(resourceCopy); } finally { if ((record != null) && (record.getChange() == LockChange.locked)) { m_cms.unlockResource(resourceCopy);
m_cms.deleteRelationsFromResource(resourceToModify, typeFilter); } finally { if (record.getChange() == LockChange.locked) { m_cms.unlockResource(resourceToModify);