@SuppressWarnings("deprecation")
    public void validateLinks(CmsObject cms) throws CmsException {

        if (m_report == null) {
            m_report = new CmsLogReport(cms.getRequestContext().getLocale(), CmsExternalLinksValidator.class);
        }

        m_report.println(
            Messages.get().container(Messages.RPT_VALIDATE_EXTERNAL_LINKS_BEGIN_0),
            I_CmsReport.FORMAT_HEADLINE);

        // get all links

        int pointerId = OpenCms.getResourceManager().getResourceType(
            CmsResourceTypePointer.getStaticTypeName()).getTypeId();
        CmsResourceFilter filter = CmsResourceFilter.ONLY_VISIBLE_NO_DELETED.addRequireType(pointerId);
        List<CmsResource> links = cms.readResources("/", filter);
        Iterator<CmsResource> iterator = links.iterator();
        Map<String, String> brokenLinks = new HashMap<String, String>();

        for (int i = 1; iterator.hasNext(); i++) {
            CmsFile link = cms.readFile(cms.getSitePath(iterator.next()), filter);
            String linkUrl = new String(link.getContents());

            // print to the report
            m_report.print(
                org.opencms.report.Messages.get().container(
                    org.opencms.report.Messages.RPT_SUCCESSION_1,
                    new Integer(i),
                    new Integer(links.size())),
                I_CmsReport.FORMAT_NOTE);
            m_report.print(Messages.get().container(Messages.RPT_VALIDATE_LINK_0), I_CmsReport.FORMAT_NOTE);
            m_report.print(
                org.opencms.report.Messages.get().container(
                    org.opencms.report.Messages.RPT_ARGUMENT_1,
                    link.getRootPath()));
            m_report.print(Messages.get().container(Messages.GUI_LINK_POINTING_TO_0), I_CmsReport.FORMAT_NOTE);
            m_report.print(
                org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_ARGUMENT_1, linkUrl));
            m_report.print(org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_DOTS_0));

            // check link and append it to the list of broken links, if test fails
            if (!checkUrl(cms, linkUrl)) {
                brokenLinks.put(link.getRootPath(), linkUrl);
                m_report.println(Messages.get().container(Messages.RPT_BROKEN_0), I_CmsReport.FORMAT_ERROR);
            } else {
                m_report.println(
                    org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_OK_0),
                    I_CmsReport.FORMAT_OK);
            }
        }

        m_report.println(
            Messages.get().container(
                Messages.RPT_LINK_VALIDATION_STAT_2,
                new Integer(links.size()),
                new Integer(brokenLinks.size())),
            I_CmsReport.FORMAT_HEADLINE);
        m_report.println(
            Messages.get().container(Messages.RPT_VALIDATE_EXTERNAL_LINKS_END_0),
            I_CmsReport.FORMAT_HEADLINE);

        OpenCms.getLinkManager().setPointerLinkValidationResult(new CmsExternalLinksValidationResult(brokenLinks));
    }
@ SuppressWarnings ( "deprecation" ) public void validateLinks ( CmsObject cms ) throws CmsException { if ( m_report == null ) { m_report = new CmsLogReport ( cms . getRequestContext ( ) . getLocale ( ) , CmsExternalLinksValidator . class ) ; } m_report . println ( Messages . get ( ) . container ( Messages . RPT_VALIDATE_EXTERNAL_LINKS_BEGIN_0 ) , I_CmsReport . FORMAT_HEADLINE ) ; int pointerId = OpenCms . getResourceManager ( ) . getResourceType ( CmsResourceTypePointer . getStaticTypeName ( ) ) . getTypeId ( ) ; CmsResourceFilter filter = CmsResourceFilter . ONLY_VISIBLE_NO_DELETED . addRequireType ( pointerId ) ; List < CmsResource > links = cms . readResources ( "/" , filter ) ; Iterator < CmsResource > iterator = links . iterator ( ) ; Map < String , String > brokenLinks = new HashMap < String , String > ( ) ; for ( int i = 1 ; iterator . hasNext ( ) ; i ++ ) { CmsFile link = cms . readFile ( cms . getSitePath ( iterator . next ( ) ) , filter ) ; String linkUrl = new String ( link . getContents ( ) ) ; m_report . print ( org . opencms . report . Messages . get ( ) . container ( org . opencms . report . Messages . RPT_SUCCESSION_1 , new Integer ( i ) , new Integer ( links . size ( ) ) ) , I_CmsReport . FORMAT_NOTE ) ; m_report . print ( Messages . get ( ) . container ( Messages . RPT_VALIDATE_LINK_0 ) , I_CmsReport . FORMAT_NOTE ) ; m_report . print ( org . opencms . report . Messages . get ( ) . container ( org . opencms . report . Messages . RPT_ARGUMENT_1 , link . getRootPath ( ) ) ) ; m_report . print ( Messages . get ( ) . container ( Messages . GUI_LINK_POINTING_TO_0 ) , I_CmsReport . FORMAT_NOTE ) ; m_report . print ( org . opencms . report . Messages . get ( ) . container ( org . opencms . report . Messages . RPT_ARGUMENT_1 , linkUrl ) ) ; m_report . print ( org . opencms . report . Messages . get ( ) . container ( org . opencms . report . Messages . RPT_DOTS_0 ) ) ; if ( ! checkUrl ( cms , linkUrl ) ) { brokenLinks . put ( link . getRootPath ( ) , linkUrl ) ; m_report . println ( Messages . get ( ) . container ( Messages . RPT_BROKEN_0 ) , I_CmsReport . FORMAT_ERROR ) ; } else { m_report . println ( org . opencms . report . Messages . get ( ) . container ( org . opencms . report . Messages . RPT_OK_0 ) , I_CmsReport . FORMAT_OK ) ; } } m_report . println ( Messages . get ( ) . container ( Messages . RPT_LINK_VALIDATION_STAT_2 , new Integer ( links . size ( ) ) , new Integer ( brokenLinks . size ( ) ) ) , I_CmsReport . FORMAT_HEADLINE ) ; m_report . println ( Messages . get ( ) . container ( Messages . RPT_VALIDATE_EXTERNAL_LINKS_END_0 ) , I_CmsReport . FORMAT_HEADLINE ) ; OpenCms . getLinkManager ( ) . setPointerLinkValidationResult ( new CmsExternalLinksValidationResult ( brokenLinks ) ) ; }
Validate all links.<p>

@param cms a OpenCms context object

@throws CmsException if something goes wrong