private void setContentAsSource(CmsFile file1, CmsFile file2) throws CmsException, UnsupportedEncodingException {

        CmsObject cms = getCms();
        if (CmsStringUtil.isNotEmpty(getParamElement())) {
            I_CmsXmlDocument resource1;
            I_CmsXmlDocument resource2;
            if (CmsResourceTypeXmlPage.isXmlPage(file1)) {
                resource1 = CmsXmlPageFactory.unmarshal(cms, file1);
            } else {
                resource1 = CmsXmlContentFactory.unmarshal(cms, file1);
            }
            if (CmsResourceTypeXmlPage.isXmlPage(file2)) {
                resource2 = CmsXmlPageFactory.unmarshal(cms, file2);
            } else {
                resource2 = CmsXmlContentFactory.unmarshal(cms, file2);
            }
            I_CmsXmlContentValue value1 = resource1.getValue(
                getParamElement(),
                CmsLocaleManager.getLocale(getParamLocale()));
            I_CmsXmlContentValue value2 = resource2.getValue(
                getParamElement(),
                CmsLocaleManager.getLocale(getParamLocale()));
            if (value1 == null) {
                m_differenceDialog.setOriginalSource("");
            } else {
                m_differenceDialog.setOriginalSource(value1.getStringValue(cms));
            }
            if (value2 == null) {
                m_differenceDialog.setCopySource("");
            } else {
                m_differenceDialog.setCopySource(value2.getStringValue(cms));
            }
        } else if (CmsResourceComparisonDialog.COMPARE_ALL_ELEMENTS.equals(getParamCompare())) {
            I_CmsXmlDocument resource1;
            I_CmsXmlDocument resource2;
            if (CmsResourceTypeXmlPage.isXmlPage(file1)) {
                resource1 = CmsXmlPageFactory.unmarshal(cms, file1);
            } else {
                resource1 = CmsXmlContentFactory.unmarshal(cms, file1);
            }
            if (CmsResourceTypeXmlPage.isXmlPage(file2)) {
                resource2 = CmsXmlPageFactory.unmarshal(cms, file2);
            } else {
                resource2 = CmsXmlContentFactory.unmarshal(cms, file2);
            }
            m_differenceDialog.setOriginalSource(extractElements(resource1));
            m_differenceDialog.setCopySource(extractElements(resource2));

        } else {
            // compare whole plain text file
            m_differenceDialog.setOriginalSource(
                new String(file1.getContents(), cms.getRequestContext().getEncoding()));
            m_differenceDialog.setCopySource(new String(file2.getContents(), cms.getRequestContext().getEncoding()));
        }
    }
private void setContentAsSource ( CmsFile file1 , CmsFile file2 ) throws CmsException , UnsupportedEncodingException { CmsObject cms = getCms ( ) ; if ( CmsStringUtil . isNotEmpty ( getParamElement ( ) ) ) { I_CmsXmlDocument resource1 ; I_CmsXmlDocument resource2 ; if ( CmsResourceTypeXmlPage . isXmlPage ( file1 ) ) { resource1 = CmsXmlPageFactory . unmarshal ( cms , file1 ) ; } else { resource1 = CmsXmlContentFactory . unmarshal ( cms , file1 ) ; } if ( CmsResourceTypeXmlPage . isXmlPage ( file2 ) ) { resource2 = CmsXmlPageFactory . unmarshal ( cms , file2 ) ; } else { resource2 = CmsXmlContentFactory . unmarshal ( cms , file2 ) ; } I_CmsXmlContentValue value1 = resource1 . getValue ( getParamElement ( ) , CmsLocaleManager . getLocale ( getParamLocale ( ) ) ) ; I_CmsXmlContentValue value2 = resource2 . getValue ( getParamElement ( ) , CmsLocaleManager . getLocale ( getParamLocale ( ) ) ) ; if ( value1 == null ) { m_differenceDialog . setOriginalSource ( "" ) ; } else { m_differenceDialog . setOriginalSource ( value1 . getStringValue ( cms ) ) ; } if ( value2 == null ) { m_differenceDialog . setCopySource ( "" ) ; } else { m_differenceDialog . setCopySource ( value2 . getStringValue ( cms ) ) ; } } else if ( CmsResourceComparisonDialog . COMPARE_ALL_ELEMENTS . equals ( getParamCompare ( ) ) ) { I_CmsXmlDocument resource1 ; I_CmsXmlDocument resource2 ; if ( CmsResourceTypeXmlPage . isXmlPage ( file1 ) ) { resource1 = CmsXmlPageFactory . unmarshal ( cms , file1 ) ; } else { resource1 = CmsXmlContentFactory . unmarshal ( cms , file1 ) ; } if ( CmsResourceTypeXmlPage . isXmlPage ( file2 ) ) { resource2 = CmsXmlPageFactory . unmarshal ( cms , file2 ) ; } else { resource2 = CmsXmlContentFactory . unmarshal ( cms , file2 ) ; } m_differenceDialog . setOriginalSource ( extractElements ( resource1 ) ) ; m_differenceDialog . setCopySource ( extractElements ( resource2 ) ) ; } else { m_differenceDialog . setOriginalSource ( new String ( file1 . getContents ( ) , cms . getRequestContext ( ) . getEncoding ( ) ) ) ; m_differenceDialog . setCopySource ( new String ( file2 . getContents ( ) , cms . getRequestContext ( ) . getEncoding ( ) ) ) ; } }
Extracts the content from the files according to the file type.<p>

@param file1 the first file to compare
@param file2 the second file to compare

@throws CmsException if something goes wrong
@throws UnsupportedEncodingException if the encoding of one file is not supported