public String lockIfExists(String sitePath) throws CmsRpcException {

        CmsObject cms = getCmsObject();
        String errorMessage = null;
        try {
            if (cms.existsResource(sitePath, CmsResourceFilter.IGNORE_EXPIRATION)) {

                try {
                    ensureLock(cms.readResource(sitePath, CmsResourceFilter.IGNORE_EXPIRATION));
                } catch (CmsException e) {
                    errorMessage = e.getLocalizedMessage(OpenCms.getWorkplaceManager().getWorkplaceLocale(cms));
                }

            } else {
                // check if parent folder may be locked by the current user
                String parentFolder = CmsResource.getParentFolder(sitePath);
                while ((parentFolder != null)
                    && !cms.existsResource(parentFolder, CmsResourceFilter.IGNORE_EXPIRATION)) {
                    parentFolder = CmsResource.getParentFolder(parentFolder);
                }
                if (parentFolder != null) {
                    CmsResource ancestorFolder = cms.readResource(parentFolder, CmsResourceFilter.IGNORE_EXPIRATION);
                    CmsUser user = cms.getRequestContext().getCurrentUser();
                    CmsLock lock = cms.getLock(ancestorFolder);
                    if (!lock.isLockableBy(user)) {
                        errorMessage = "Can not lock parent folder '" + parentFolder + "'.";
                    }
                } else {
                    errorMessage = "Can not access any parent folder.";
                }
            }
        } catch (Throwable e) {
            error(e);
        }

        return errorMessage;
    }
public String lockIfExists ( String sitePath ) throws CmsRpcException { CmsObject cms = getCmsObject ( ) ; String errorMessage = null ; try { if ( cms . existsResource ( sitePath , CmsResourceFilter . IGNORE_EXPIRATION ) ) { try { ensureLock ( cms . readResource ( sitePath , CmsResourceFilter . IGNORE_EXPIRATION ) ) ; } catch ( CmsException e ) { errorMessage = e . getLocalizedMessage ( OpenCms . getWorkplaceManager ( ) . getWorkplaceLocale ( cms ) ) ; } } else { String parentFolder = CmsResource . getParentFolder ( sitePath ) ; while ( ( parentFolder != null ) && ! cms . existsResource ( parentFolder , CmsResourceFilter . IGNORE_EXPIRATION ) ) { parentFolder = CmsResource . getParentFolder ( parentFolder ) ; } if ( parentFolder != null ) { CmsResource ancestorFolder = cms . readResource ( parentFolder , CmsResourceFilter . IGNORE_EXPIRATION ) ; CmsUser user = cms . getRequestContext ( ) . getCurrentUser ( ) ; CmsLock lock = cms . getLock ( ancestorFolder ) ; if ( ! lock . isLockableBy ( user ) ) { errorMessage = "Can not lock parent folder '" + parentFolder + "'." ; } } else { errorMessage = "Can not access any parent folder." ; } } } catch ( Throwable e ) { error ( e ) ; } return errorMessage ; }
@see org.opencms.gwt.shared.rpc.I_CmsCoreService#lockIfExists(java.lang.String)