public void checkConsistency(CmsObject cms) {

        if (!m_internal || (cms == null)) {
            return;
        }

        // in case of static resource links use the null UUID
        if (CmsStaticResourceHandler.isStaticResourceUri(m_target)) {
            m_structureId = CmsUUID.getNullUUID();
            return;
        }

        try {
            if (m_structureId == null) {
                // try by path
                throw new CmsException(Messages.get().container(Messages.LOG_BROKEN_LINK_NO_ID_0));
            }
            // first look for the resource with the given structure id
            String rootPath = null;
            CmsResource res;
            try {
                res = cms.readResource(m_structureId, CmsResourceFilter.ALL);
                rootPath = res.getRootPath();
                if (!res.getRootPath().equals(m_target)) {
                    // update path if needed
                    if (LOG.isDebugEnabled()) {
                        LOG.debug(
                            Messages.get().getBundle().key(
                                Messages.LOG_BROKEN_LINK_UPDATED_BY_ID_3,
                                m_structureId,
                                m_target,
                                res.getRootPath()));
                    }

                }
            } catch (CmsException e) {
                // not found
                throw new CmsVfsResourceNotFoundException(
                    org.opencms.db.generic.Messages.get().container(
                        org.opencms.db.generic.Messages.ERR_READ_RESOURCE_1,
                        m_target),
                    e);
            }
            if ((rootPath != null) && !rootPath.equals(m_target)) {
                // set the new target
                m_target = res.getRootPath();
                setUri();
                // update xml node
                CmsLinkUpdateUtil.updateXml(this, m_element, true);
            }
        } catch (CmsException e) {
            if (LOG.isDebugEnabled()) {
                LOG.debug(Messages.get().getBundle().key(Messages.LOG_BROKEN_LINK_BY_ID_2, m_target, m_structureId), e);
            }
            if (CmsStringUtil.isEmptyOrWhitespaceOnly(m_target)) {
                // no correction is possible
                return;
            }
            // go on with the resource with the given path
            String siteRoot = cms.getRequestContext().getSiteRoot();
            try {
                cms.getRequestContext().setSiteRoot("");
                // now look for the resource with the given path
                CmsResource res = cms.readResource(m_target, CmsResourceFilter.ALL);
                if (!res.getStructureId().equals(m_structureId)) {
                    // update structure id if needed
                    if (LOG.isDebugEnabled()) {
                        LOG.debug(
                            Messages.get().getBundle().key(
                                Messages.LOG_BROKEN_LINK_UPDATED_BY_NAME_3,
                                m_target,
                                m_structureId,
                                res.getStructureId()));
                    }
                    m_target = res.getRootPath(); // could change by a translation rule
                    m_structureId = res.getStructureId();
                    CmsLinkUpdateUtil.updateXml(this, m_element, true);
                }
            } catch (CmsException e1) {
                // no correction was possible
                if (LOG.isDebugEnabled()) {
                    LOG.debug(Messages.get().getBundle().key(Messages.LOG_BROKEN_LINK_BY_NAME_1, m_target), e1);
                }
                m_structureId = null;
            } finally {
                cms.getRequestContext().setSiteRoot(siteRoot);
            }
        }
    }
public void checkConsistency ( CmsObject cms ) { if ( ! m_internal || ( cms == null ) ) { return ; } if ( CmsStaticResourceHandler . isStaticResourceUri ( m_target ) ) { m_structureId = CmsUUID . getNullUUID ( ) ; return ; } try { if ( m_structureId == null ) { throw new CmsException ( Messages . get ( ) . container ( Messages . LOG_BROKEN_LINK_NO_ID_0 ) ) ; } String rootPath = null ; CmsResource res ; try { res = cms . readResource ( m_structureId , CmsResourceFilter . ALL ) ; rootPath = res . getRootPath ( ) ; if ( ! res . getRootPath ( ) . equals ( m_target ) ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( Messages . get ( ) . getBundle ( ) . key ( Messages . LOG_BROKEN_LINK_UPDATED_BY_ID_3 , m_structureId , m_target , res . getRootPath ( ) ) ) ; } } } catch ( CmsException e ) { throw new CmsVfsResourceNotFoundException ( org . opencms . db . generic . Messages . get ( ) . container ( org . opencms . db . generic . Messages . ERR_READ_RESOURCE_1 , m_target ) , e ) ; } if ( ( rootPath != null ) && ! rootPath . equals ( m_target ) ) { m_target = res . getRootPath ( ) ; setUri ( ) ; CmsLinkUpdateUtil . updateXml ( this , m_element , true ) ; } } catch ( CmsException e ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( Messages . get ( ) . getBundle ( ) . key ( Messages . LOG_BROKEN_LINK_BY_ID_2 , m_target , m_structureId ) , e ) ; } if ( CmsStringUtil . isEmptyOrWhitespaceOnly ( m_target ) ) { return ; } String siteRoot = cms . getRequestContext ( ) . getSiteRoot ( ) ; try { cms . getRequestContext ( ) . setSiteRoot ( "" ) ; CmsResource res = cms . readResource ( m_target , CmsResourceFilter . ALL ) ; if ( ! res . getStructureId ( ) . equals ( m_structureId ) ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( Messages . get ( ) . getBundle ( ) . key ( Messages . LOG_BROKEN_LINK_UPDATED_BY_NAME_3 , m_target , m_structureId , res . getStructureId ( ) ) ) ; } m_target = res . getRootPath ( ) ; m_structureId = res . getStructureId ( ) ; CmsLinkUpdateUtil . updateXml ( this , m_element , true ) ; } } catch ( CmsException e1 ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( Messages . get ( ) . getBundle ( ) . key ( Messages . LOG_BROKEN_LINK_BY_NAME_1 , m_target ) , e1 ) ; } m_structureId = null ; } finally { cms . getRequestContext ( ) . setSiteRoot ( siteRoot ) ; } } }
Checks and updates the structure id or the path of the target.<p>

@param cms the cms context