All pastes #577077 Raw Edit

Something

public java v1 · immutable
·published 2007-06-19 19:34 UTC
rendered paste body
/* * FXRssResource.java * * Created on January 26, 2006, 3:19 PM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package com.xxxx.fxopencms.xxx;import java.io.BufferedWriter;import java.io.FileWriter;import java.io.File; import java.text.ParsePosition;import java.text.SimpleDateFormat;import java.util.Date;import java.util.Iterator;import java.util.List;import java.util.Locale;import java.util.regex.Matcher;import java.util.regex.Pattern;import java.io.FileOutputStream;import java.io.OutputStreamWriter;import java.io.Writer;import java.io.UnsupportedEncodingException;import java.io.IOException;  import java.util.ArrayList;import org.opencms.jsp.CmsJspActionElement;import org.opencms.file.CmsObject;import org.opencms.file.CmsProperty;import java.util.List;import org.opencms.file.CmsResourceFilter;import org.opencms.file.CmsProperty;import org.opencms.file.CmsResource;import com.xxxx.fxopencms.xxx.FXConstants;import java.text.SimpleDateFormat;import java.util.Date;import org.opencms.db.CmsDefaultUsers;import org.opencms.file.CmsFile;import org.opencms.file.CmsObject;import org.opencms.file.CmsProperty;import org.opencms.main.CmsException;import org.opencms.main.FXResource;import org.opencms.main.OpenCms;import org.opencms.report.CmsShellReport;import org.opencms.xml.content.CmsXmlContent;import org.opencms.xml.content.CmsXmlContentFactory;import org.opencms.xml.types.CmsXmlHtmlValue;import com.opencms.htmlconverter.CmsHtmlConverter;import org.w3c.tidy.Tidy;import org.w3c.tidy.Configuration;import org.w3c.tidy.Node;import org.w3c.tidy.Out;import org.w3c.tidy.OutImpl;import org.w3c.tidy.PPrint;/**  * * This class provides Rss generating file access functionality which is specific for * project. */public class FXRssResource {    public FXResource fxres;    public CmsObject cmsObject;    public FXRssResourceThread mThreadForGeneratingRss = null;    //String sfSiteRoot = "/sites/xxx";    String sfSiteRoot = "";        public FXRssResource(String sIdToUseForCmsObj, String sPassToUseForCmsObj) {        try {             cmsObject = OpenCms.initCmsObject((new CmsDefaultUsers()).getUserGuest());            System.out.println("sIdToUseForCmsObj, sPassToUseForCmsOb =5 " + sIdToUseForCmsObj + "," + sPassToUseForCmsObj);            String sUserLoginStatus = cmsObject.loginUser(sIdToUseForCmsObj, sPassToUseForCmsObj);            System.out.println("sUserLoginStatus =5  " + sUserLoginStatus );            cmsObject.getRequestContext().setSiteRoot("/sites/xxx/");            cmsObject.getRequestContext().setCurrentProject(cmsObject.readProject("Offline"));            fxres = new FXResource(cmsObject);        } catch (Exception e) {            e.printStackTrace();        }    }        /**     * This method generates RSS file     * @param cmsObj CmsObject cms object     * @param siteRoot String specifies where the latest files are to be retrived from     * @param numListed int specifies the number of files to be retrived     * @param rss_path_ String specifies the directory path where to write the files     * @param xml_name String specifies the name of the file to write     * @return description_of_param     */        public void generateRssAllThread() {        try {            mThreadForGeneratingRss = new FXRssResourceThread();            mThreadForGeneratingRss.start(); //this will ensure that we are starting the thread mThreadForHashUpdateFromDB only once.                    } catch (Exception e) {            e.printStackTrace();            System.out.println(e.getMessage());        }    }       private static File parent(File f) {         String dirname = f.getParent();             if (dirname == null) {                 if (f.isAbsolute())                     return new File(File.separator);                 else                     return new File(System.getProperty("user.dir"));             }         return new File(dirname);     }         public String normalizeURLs(String sStringToProcess)    {                //SOME ARE MISSING        //http://www.xxx.com/export/sites/xxx/            /2006/04/charting_center/Weekly_Chart_Analysis/04-14-06weekly1.gif        //http://www.xxx.com/export/sites/xxx/story-images/2006/04/charting_center/Weekly_Chart_Analysis/04-14-06weekly1.gif        //SOME ARE        //http://www.xxx.com/export/sites/xxx/             2006/04/charting_center/Weekly_Chart_Analysis/04-17-06cot1.gif        //http://www.xxx.com/export/sites/xxx/story-images/2006/04/charting_center/Weekly_Chart_Analysis/04-17-06cot1.gif        //WRONG FOUND      http://www.xxx.com/export/sites/xxx/2006/04/special_report/Special_Reports/Outlook2006.1.gif        // ADDED story-images/        // in    xxx/story-images/2006/        //      CORREWCTED http://www.xxx.com/export/sites/xxx/story-images/2006/04/special_report/Special_Reports/Outlook2006.1.gif                sStringToProcess = sStringToProcess.replaceAll("src=\"/story-images/", "src=\"http://www.xxx.com/export/sites/xxx/story-images/");           sStringToProcess = sStringToProcess.replaceAll("SRC=\"/story-images/", "SRC=\"http://www.xxx.com/export/sites/xxx/story-images/");        sStringToProcess = sStringToProcess.replaceAll("href=\"/story-images/", "href=\"http://www.xxx.com/export/sites/xxx/story-images/");           sStringToProcess = sStringToProcess.replaceAll("HREF=\"/story-images/", "HREF=\"http://www.xxx.com/export/sites/xxx/story-images/");                sStringToProcess = sStringToProcess.replaceAll("src=\"/opencms/opencms/", "src=\"http://www.xxx.com/export/sites/xxx/story-images/");            sStringToProcess = sStringToProcess.replaceAll("SRC=\"/opencms/opencms/", "SRC=\"http://www.xxx.com/export/sites/xxx/story-images/");        sStringToProcess = sStringToProcess.replaceAll("href=\"/opencms/opencms/", "href=\"http://www.xxx.com/export/sites/xxx/");        sStringToProcess = sStringToProcess.replaceAll("HREF=\"/opencms/opencms/", "HREF=\"http://www.xxx.com/export/sites/xxx/");        //FOUND A BAD LINK:        //APPEARS       href="/story-images/2006/04/special_report/Special_Reports/2006_outlook_0406.pdf"        //APPEARS       href="http://www.xxx.com/export/sites/xxx/story-images/2006/04/special_report/Special_Reports/2006_outlook_0406.pdf"        //CORRECT       href="http://www.xxx.com/export/sites/xxx/story-images/2006/04/special_report/Special_Reports/2006_outlook_0406.pdf"                sStringToProcess = sStringToProcess.replaceAll("story-images/story-images/", "story-images/");                //sStringToProcess = sStringToProcess.replaceAll("HREF=\"/opencms/opencms/", "HREF=\"http://www.xxx.com/export/sites/xxx/");                    //http://www.xxx.com/export/sites/xxx/2006/04/currency/weeklies/CAD_04-14-06.gif//http://www.xxx.com/export/sites/xxx/story-images/2006/04/currency/weeklies/CAD_04-14-06.gif                return sStringToProcess;    }    private String cleanHTML(String htmlInput) {    /** regular expression for cleanup. */    String[] m_cleanupPatterns = {        "<o:p>.*(\\r\\n)*.*</o:p>",        "<o:p>.*(\\r\\n)*.*</O:p>",        "<\\?xml:.*(\\r\\n).*/>",        "<\\?xml:.*(\\r\\n).*(\\r\\n).*/\\?>",        "<\\?xml:.*(\\r\\n).*(\\r\\n).*/>",        "<\\?xml:(.*(\\r\\n)).*/\\?>",        "<o:SmartTagType.*(\\r\\n)*.*/>",        "<o:smarttagtype.*(\\r\\n)*.*/>"};    /** patterns for cleanup. */    Pattern[] m_clearStyle;    /** the input encoding. */    String m_encoding;            /** the operation mode. */    List m_mode;    /** regular expression for replace. */    String[] m_replacePatterns = {"&#160;", "(\\r\\n){2,}", "–"};    /** patterns for replace. */    Pattern[] m_replaceStyle;    /** values for replace. */    String[] m_replaceValues = {"&nbsp;", "", "&ndash;"};            String parsedHtml = new String();        parsedHtml = htmlInput.trim();        // create the regexp for cleanup        m_clearStyle = new Pattern[m_cleanupPatterns.length];        for (int i = 0; i < m_cleanupPatterns.length; i++) {            m_clearStyle[i] = Pattern.compile(m_cleanupPatterns[i]);        }        // create the regexp for replace        m_replaceStyle = new Pattern[m_replacePatterns.length];        for (int i = 0; i < m_replacePatterns.length; i++) {            m_replaceStyle[i] = Pattern.compile(m_replacePatterns[i]);        }                // process all cleanup regexp        for (int i = 0; i < m_cleanupPatterns.length; i++) {            parsedHtml = m_clearStyle[i].matcher(parsedHtml).replaceAll("");        }        // process all replace regexp        for (int i = 0; i < m_replacePatterns.length; i++) {            parsedHtml = m_replaceStyle[i].matcher(parsedHtml).replaceAll(m_replaceValues[i]);        }        return parsedHtml;    }        public String replaceSpecialCharacters(String sPassedStringToProcess)    {        String sStringToProcess = "";        if(sPassedStringToProcess != null){        sStringToProcess = sPassedStringToProcess;        //http://www.xxx.com/story/strategy_pieces/trade_or_fade/The_Moment_of_Truth_1145248240833.html        //cd /usr/datum/xxx_xmlfeed/ && mv *.xml /usr/datum/xxx_xmlfeed/archives/        // /usr/local/xxx/tomcat/webapps/ROOT/WEB-INF/classes/com/xxxx/fxopencms/xxx                            sStringToProcess = sStringToProcess.replaceAll(" & "," and "); //only safe way to replace &                                        sStringToProcess = sStringToProcess.replaceAll("<img ", "<br><img ");                    sStringToProcess = sStringToProcess.replaceAll("<IMG ", "<br><img ");                    //sStringToProcess = sStringToProcess.replaceAll("“","&#147;");                    //sStringToProcess = sStringToProcess.replaceAll("”","&#148;");                                        sStringToProcess = sStringToProcess.replaceAll("“","\"");                    sStringToProcess = sStringToProcess.replaceAll("”","\"");                                                            sStringToProcess = sStringToProcess.replaceAll("•","-"); //was &#149;                    sStringToProcess = sStringToProcess.replaceAll("–","-");                    sStringToProcess = sStringToProcess.replaceAll("¡","&#161;");                    sStringToProcess = sStringToProcess.replaceAll("¢","&#162;");                    sStringToProcess = sStringToProcess.replaceAll("£","&#163;");                    sStringToProcess = sStringToProcess.replaceAll("¤","&#164;");                    sStringToProcess = sStringToProcess.replaceAll("¥","&#165;");                    sStringToProcess = sStringToProcess.replaceAll("¦","&#166;");                    sStringToProcess = sStringToProcess.replaceAll("§","&#167;");                    sStringToProcess = sStringToProcess.replaceAll("¨","&#168;");                    sStringToProcess = sStringToProcess.replaceAll("©","&#169;");                    sStringToProcess = sStringToProcess.replaceAll("ª","&#170;");                    sStringToProcess = sStringToProcess.replaceAll("«","&#171;");                    sStringToProcess = sStringToProcess.replaceAll("¬","&#172;");                    sStringToProcess = sStringToProcess.replaceAll("­","&#173;");                    sStringToProcess = sStringToProcess.replaceAll("®","&#174;");                    sStringToProcess = sStringToProcess.replaceAll("¯","&#175;");                    sStringToProcess = sStringToProcess.replaceAll("°","&#176;");                    sStringToProcess = sStringToProcess.replaceAll("±","&#177;");                    sStringToProcess = sStringToProcess.replaceAll("²","&#178;");                    sStringToProcess = sStringToProcess.replaceAll("³","&#179;");                    sStringToProcess = sStringToProcess.replaceAll("´","&#180;");                    sStringToProcess = sStringToProcess.replaceAll("µ","&#181;");                    sStringToProcess = sStringToProcess.replaceAll("","&#182;");                    sStringToProcess = sStringToProcess.replaceAll("·","-"); //&#183;                    sStringToProcess = sStringToProcess.replaceAll("¸","&#184;");                    sStringToProcess = sStringToProcess.replaceAll("¹","&#185;");                    sStringToProcess = sStringToProcess.replaceAll("º","&#186;");                    sStringToProcess = sStringToProcess.replaceAll("»","&#187;");                    sStringToProcess = sStringToProcess.replaceAll("¼","&#188;");                    sStringToProcess = sStringToProcess.replaceAll("½","&#189;");                    sStringToProcess = sStringToProcess.replaceAll("¾","&#190;");                    sStringToProcess = sStringToProcess.replaceAll("¿","&#191;");                    sStringToProcess = sStringToProcess.replaceAll("À","&#192;");                    sStringToProcess = sStringToProcess.replaceAll("Á","&#193;");                    sStringToProcess = sStringToProcess.replaceAll("Â","&#194;");                    sStringToProcess = sStringToProcess.replaceAll("Ã","&#195;");                    sStringToProcess = sStringToProcess.replaceAll("Ä","&#196;");                    sStringToProcess = sStringToProcess.replaceAll("Å","&#197;");                    sStringToProcess = sStringToProcess.replaceAll("Æ","&#198;");                    sStringToProcess = sStringToProcess.replaceAll("Ç","&#199;");                    sStringToProcess = sStringToProcess.replaceAll("È","&#200;");                    sStringToProcess = sStringToProcess.replaceAll("É","&#201;");                    sStringToProcess = sStringToProcess.replaceAll("Ê","&#202;");                    sStringToProcess = sStringToProcess.replaceAll("Ë","&#203;");                    sStringToProcess = sStringToProcess.replaceAll("Ì","&#204;");                    sStringToProcess = sStringToProcess.replaceAll("Í","&#205;");                    sStringToProcess = sStringToProcess.replaceAll("Î","&#206;");                    sStringToProcess = sStringToProcess.replaceAll("Ï","&#207;");                    sStringToProcess = sStringToProcess.replaceAll("Ð","&#208;");                    sStringToProcess = sStringToProcess.replaceAll("Ñ","&#209;");                    sStringToProcess = sStringToProcess.replaceAll("Ò","&#210;");                    sStringToProcess = sStringToProcess.replaceAll("Ó","&#211;");                    sStringToProcess = sStringToProcess.replaceAll("Ô","&#212;");                    sStringToProcess = sStringToProcess.replaceAll("Õ","&#213;");                    sStringToProcess = sStringToProcess.replaceAll("Ö","&#214;");                    sStringToProcess = sStringToProcess.replaceAll("×","&#215;");                    sStringToProcess = sStringToProcess.replaceAll("Ø","&#216;");                    sStringToProcess = sStringToProcess.replaceAll("Ù","&#217;");                    sStringToProcess = sStringToProcess.replaceAll("Ú","&#218;");                    sStringToProcess = sStringToProcess.replaceAll("Û","&#219;");                    sStringToProcess = sStringToProcess.replaceAll("Ü","&#220;");                    sStringToProcess = sStringToProcess.replaceAll("Ý","&#221;");                    sStringToProcess = sStringToProcess.replaceAll("Þ","&#222;");                    sStringToProcess = sStringToProcess.replaceAll("ß","&#223;");                    sStringToProcess = sStringToProcess.replaceAll("à","&#224;");                    sStringToProcess = sStringToProcess.replaceAll("á","&#225;");                    sStringToProcess = sStringToProcess.replaceAll("â","&#226;");                    sStringToProcess = sStringToProcess.replaceAll("ã","&#227;");                    sStringToProcess = sStringToProcess.replaceAll("ä","&#228;");                    sStringToProcess = sStringToProcess.replaceAll("å","&#229;");                    sStringToProcess = sStringToProcess.replaceAll("æ","&#230;");                    sStringToProcess = sStringToProcess.replaceAll("ç","&#231;");                    sStringToProcess = sStringToProcess.replaceAll("è","&#232;");                    sStringToProcess = sStringToProcess.replaceAll("é","&#233;");                    sStringToProcess = sStringToProcess.replaceAll("ê","&#234;");                    sStringToProcess = sStringToProcess.replaceAll("ë","&#235;");                    sStringToProcess = sStringToProcess.replaceAll("ì","&#236;");                    sStringToProcess = sStringToProcess.replaceAll("í","&#237;");                    sStringToProcess = sStringToProcess.replaceAll("î","&#238;");                    sStringToProcess = sStringToProcess.replaceAll("ï","&#239;");                    sStringToProcess = sStringToProcess.replaceAll("ð","&#240;");                    sStringToProcess = sStringToProcess.replaceAll("ñ","&#241;");                    sStringToProcess = sStringToProcess.replaceAll("ò","&#242;");                    sStringToProcess = sStringToProcess.replaceAll("ó","&#243;");                    sStringToProcess = sStringToProcess.replaceAll("ô","&#244;");                    sStringToProcess = sStringToProcess.replaceAll("õ","&#245;");                    sStringToProcess = sStringToProcess.replaceAll("ö","&#246;");                    sStringToProcess = sStringToProcess.replaceAll("÷","&#247;");                    sStringToProcess = sStringToProcess.replaceAll("ø","&#248;");                    sStringToProcess = sStringToProcess.replaceAll("ù","&#249;");                    sStringToProcess = sStringToProcess.replaceAll("ú","&#250;");                    sStringToProcess = sStringToProcess.replaceAll("û","&#251;");                    sStringToProcess = sStringToProcess.replaceAll("ü","&#252;");                    sStringToProcess = sStringToProcess.replaceAll("ý","&#253;");                    sStringToProcess = sStringToProcess.replaceAll("þ","&#254;");                    sStringToProcess = sStringToProcess.replaceAll("ÿ","&#255;");                    //sStringToProcess = sStringToProcess.replaceAll("’","&rsquo;");                    //sStringToProcess = sStringToProcess.replaceAll("’","&rsquo;");                    //sStringToProcess = sStringToProcess.replaceAll("‚","&sbquo;");                    sStringToProcess = sStringToProcess.replaceAll("‚","&sbquo;");                    //sStringToProcess = sStringToProcess.replaceAll("’","&#146;");                    sStringToProcess = sStringToProcess.replaceAll("‘","&#145;");                    sStringToProcess = sStringToProcess.replaceAll("€","&amp;euro;");                            }        return sStringToProcess;    }    public void generateRssAll()     {        try {        String sArticle = "";         CmsFile fileForAvantGo;                         System.out.println("FXRssResource - generateRssAll new v 5");        List resultList = fxres.getLatestFiles("/sites/xxx", 15);         SimpleDateFormat inputDateFormat = new SimpleDateFormat(FXConstants.DATE_FORMAT);        String sRssItem = "";        String sRssItemFullAndImages = "";        String sRssItemKeywords = "";        String sRssItemFull = "";        String sxxxxTR_news = "";        int iUniqueIDofFile;        int iCountOfMaxArticlesForxxxxTR = 0;        FXListItem item;                Newfxitem: for (int i = 0; i < resultList.size(); i++) {                            item = (FXListItem) resultList.get(i);            //MAKE THE RSS            String sArticleXMLElementText1plainText = "";            String sArticleXMLElementText2plainText = "";            String sArticleXMLElementText1HTML = "";            String sArticleXMLElementText2HTML = "";            while( Pattern.matches("(.*?)2005(.*?)", item.getDate() ) ){                System.out.println("Found year 2005 in article given as item.getDate() = ["+item.getDate()+"]");                i++;                item = (FXListItem) resultList.get(i);            }                                          System.out.println("About to get a new fileResource and file");            String fileResource = "";            CmsFile file = null;        try {                        fileResource = item.getFile(); //"/story/charting_center/weekly_chart_analysis/5085_eur_gbp_large_triangle_setup.html";            file = cmsObject.readFile(sfSiteRoot + fileResource);                        if(existsResource(cmsObject, fileResource) ){                System.out.println("Resource read ");            }            else {                System.out.println("Resource failed to be read, getting next one");                i++;                item = (FXListItem) resultList.get(i);                fileResource = item.getFile(); //"/story/charting_center/weekly_chart_analysis/5085_eur_gbp_large_triangle_setup.html";                file = cmsObject.readFile(sfSiteRoot + fileResource);                                        }                        } catch(Exception exc) {            System.out.println("exception occured in getFile or redFile!");            System.out.println("fileResource = " + fileResource);            System.out.println("sfSiteRoot = " + sfSiteRoot);            System.out.println("trying next");            i++;            item = (FXListItem) resultList.get(i);            fileResource = item.getFile(); //"/story/charting_center/weekly_chart_analysis/5085_eur_gbp_large_triangle_setup.html";            file = cmsObject.readFile(sfSiteRoot + fileResource);                    }                        //fileResource        if (fileResource.contains("_xxxxtr")){             System.out.println("FOUND _xxxxtr in path of 'fileResource' = [" + fileResource + "] it is only for xxx+ news, therefore skipping for RSS generation and broadcast");            continue Newfxitem;        }        if (fileResource.contains("guest_trade_ideas")){             System.out.println("FOUND guest_trade_ideas in path of 'fileResource' = [" + fileResource + "] it is only for xxx+ news, therefore skipping for RSS generation and broadcast");            continue Newfxitem;        }                                    iUniqueIDofFile = java.lang.Math.abs( file.getResourceId().hashCode() );            try {                // get default locale from the new article                Locale locale = (Locale)OpenCms.getLocaleManager().getDefaultLocales(cmsObject, file.getRootPath()).get(0);                // load article text (anything in <Content>, should just be text1 & text2)                CmsXmlContent fileContent = CmsXmlContentFactory.unmarshal(cmsObject, file, false);                List fileList = fileContent.getValues("element", locale);                if (fileList.size() > 0) {                    Iterator iter = fileList.iterator();                    while (iter.hasNext()) {                        sArticleXMLElementText1plainText = ((CmsXmlHtmlValue)iter.next()).getPlainText(cmsObject);                        sArticleXMLElementText2plainText = ((CmsXmlHtmlValue)iter.next()).getPlainText(cmsObject);                    }                }                if (fileList.size() > 0) {                    Iterator iter = fileList.iterator();                    while (iter.hasNext()) {                        sArticleXMLElementText1HTML = ((CmsXmlHtmlValue)iter.next()).getStringValue(cmsObject);                        sArticleXMLElementText2HTML = ((CmsXmlHtmlValue)iter.next()).getStringValue(cmsObject);                    }                }                                  sArticleXMLElementText1HTML = replaceSpecialCharacters(sArticleXMLElementText1HTML);                sArticleXMLElementText2HTML = replaceSpecialCharacters(sArticleXMLElementText2HTML);                sArticleXMLElementText1plainText = replaceSpecialCharacters(sArticleXMLElementText1plainText);                sArticleXMLElementText2plainText = replaceSpecialCharacters(sArticleXMLElementText2plainText);                                            } catch (CmsException e) {}                    String sUniqueIncimentedIdForArticle = "";                                        ParsePosition pp = new ParsePosition(0);                    Date theDate = inputDateFormat.parse(item.getDate(), pp);                    if (theDate == null) {                        continue;                    }                    SimpleDateFormat outputDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");                    //SimpleDateFormat outputDateFormat = new SimpleDateFormat("EEE', 'dd' 'MMM' 'yyyy' 'HH:mm:ss' 'Z", Locale.US);                    String outputDate = outputDateFormat.format(theDate);                                        //dateformat for xxx keywords.xml feed                                        SimpleDateFormat outputDateFormatForKeywords = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");                    //SimpleDateFormat outputDateFormat = new SimpleDateFormat("EEE', 'dd' 'MMM' 'yyyy' 'HH:mm:ss' 'Z", Locale.US);                    String outputDateForKeywords = outputDateFormatForKeywords.format(theDate); //2006-05-03T17:54:30-04:00 old: Mon, 23 Apr 2007 13:52:34 -0400                    //getFile = /story/xxx_reports/Euro_Strengthens_Ahead_of_NFP_1141994436831.html                    Pattern p = Pattern.compile("(.*)/(.*?).html");                    Matcher m = p.matcher(item.getFile());                    String sExtractedSecondsStringFromItem = "empty - RegEx for content not found in file or file not loaded";                    if (m.find() == true) {                        sExtractedSecondsStringFromItem = m.group(2);                    }                    else {                        long totalMilliseconds = System.currentTimeMillis();                        //sExtractedSecondsStringFromItem = (String) totalMilliseconds.toString();                        sExtractedSecondsStringFromItem = String.valueOf(totalMilliseconds) + "_XA";                        // comment and for debuging: System.outx.println("DEBUG FXRssResource - first match failed");                    }                                        Pattern p1 = Pattern.compile("(.*)_(.*?).html");                    Matcher m1 = p1.matcher(item.getFile());                    if (m1.find() == true) {                        sUniqueIncimentedIdForArticle = m1.group(2);                    }                    else {                        sUniqueIncimentedIdForArticle = String.valueOf(iUniqueIDofFile);                    }                                        //String sForYahooFeedSummary = sArticleXMLElementText1plainText; //I decided to use Text - because all headers for stories on [http://biz.yahoo.com/xxxx/] are in plain text (bodies are in HTML) sArticleXMLElementText1HTML;                                                       //String sForYahooFeedBody = sArticleXMLElementText1HTML + "<br><br>" +sArticleXMLElementText2HTML;/*                    sForYahooFeedBody = sForYahooFeedBody.replaceAll("<o:","<"); //this addresses special Microsoft tags that get into the output from copy paste from MSFT docs by analysts                    sForYahooFeedBody = sForYahooFeedBody.replaceAll("<o:","<"); //this addresses special Microsoft tags that get into the output from copy paste from MSFT docs by analysts                    sForYahooFeedBody = sForYahooFeedBody.replaceAll("</o:","</"); //this addresses special Microsoft tags that get into the output from copy paste from MSFT docs by analysts                    sForYahooFeedBody = sForYahooFeedBody.replaceAll("<O:","<"); //this addresses special Microsoft tags that get into the output from copy paste from MSFT docs by analysts                    sForYahooFeedBody = sForYahooFeedBody.replaceAll("</O:","</"); //this addresses special Microsoft tags that get into the output from copy paste from MSFT docs by analysts*/                    //sArticle = sArticle.replaceAll("src=\"/opencms/opencms/", "src=\"http://www.xxx.com/export/sites/xxx/");                    sArticle = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +                     "<article>\n" +                     //"   <id>" + iUniqueIDofFile + "</id>\n" + //"   <id>" + sExtractedSecondsStringFromItem + "</id>\n" +                     "   <id>" + sUniqueIncimentedIdForArticle + "</id>\n" + //"   <id>" + sExtractedSecondsStringFromItem + "</id>\n" +                                                 "   <timestamp>" + outputDate + "</timestamp>\n" +                     "   <published>no</published>\n" +                     "   <already_published_link></already_published_link>\n" +                     "   <media_type>text</media_type>\n" +                     "   <access_type>free</access_type>\n" +                     "   <topics>\n" +                     "     <topic>USD</topic>\n" +                     "   </topics>\n" +                     "   <title>" + replaceSpecialCharacters( item.getTitle() ) + "</title>\n" +                     "   <summary><![CDATA[" + replaceSpecialCharacters( sArticleXMLElementText1plainText ) + "<br />\n]]></summary>\n" +                     "   <author>" + replaceSpecialCharacters( item.getAuthor() ) + " strategist@xxx.com</author>\n" +                     "   <industries>\n" +                     "	     <industry>Financial - Money Ctr. Banks</industry>\n" +                     "   </industries>\n" +                     "   <body><![CDATA[" + replaceSpecialCharacters(sArticleXMLElementText1HTML + "<br><br>" +sArticleXMLElementText2HTML) + "<br />\n]]>\n" +                    "   </body>\n" +                     "</article>";                                        // comment and for debuging: System.outx.println("sArticle = <TEXTAREA>" + sArticle + "</TEXTAREA><HR>");                    //getFile = /story/xxx_reports/Euro_Strengthens_Ahead_of_NFP_1141994436831.html                    Pattern pForFileNameToWrite = Pattern.compile("(.*)/(.*?).html");                    Matcher mForFileNameToWrite = pForFileNameToWrite.matcher(item.getFile());                    String sExtractedFileNameForXML = "empty - RegEx for content not found in file or file not loaded";                    if (mForFileNameToWrite.find() == true) {                        sExtractedFileNameForXML = mForFileNameToWrite.group(2);                    }                    else {                        // comment and for debuging: System.outx.println("Problem occured in matching the file name - item.getFile() = " + item.getFile() + " ");                    }                    sArticle = normalizeURLs(sArticle);/*                    sArticle = sArticle.replaceAll("src=\"/story-images/", "src=\"http://www.xxx.com/export/sites/xxx/");                       sArticle = sArticle.replaceAll("SRC=\"/story-images/", "SRC=\"http://www.xxx.com/export/sites/xxx/");                                        sArticle = sArticle.replaceAll("src=\"/opencms/opencms/", "src=\"http://www.xxx.com/export/sites/xxx/");                        sArticle = sArticle.replaceAll("SRC=\"/opencms/opencms/", "SRC=\"http://www.xxx.com/export/sites/xxx/");                    sArticle = sArticle.replaceAll("href=\"/opencms/opencms/", "href=\"http://www.xxx.com/export/sites/xxx/");                    sArticle = sArticle.replaceAll("HREF=\"/opencms/opencms/", "HREF=\"http://www.xxx.com/export/sites/xxx/");*/                                                            //-----[WRITING YAHOO FILE TO OS FS ------//                    //-----[WRITING YAHOO FILE TO OS FS ------//                    //-----[WRITING YAHOO FILE TO OS FS ------//                    //-----[WRITING YAHOO FILE TO OS FS ------//                    //-----[WRITING YAHOO FILE TO OS FS ------//                                        //We also want to check if this directory is here and is writable:                    String sAbsolutePathToWriteYahooExportDirectoryOnUNIX = "/usr/local/xxx/resources/new_articles_for_yahoo/";                    String sAbsolutePathToWriteYahooExportDirectoryOnWINDOWS = "C:\\Program Files\\netbeans-4.1\\enterprise1\\jakarta-tomcat-5.5.7\\bin\\new_articles_for_yahoo\\";                    //String sNameOfYahooFile = sExtractedFileNameForXML + ".xml";                    String sNameOfYahooFile = sExtractedFileNameForXML + ".xml";                    String sEntirePathOfFileToWriteYahooExportTo = sAbsolutePathToWriteYahooExportDirectoryOnUNIX + sNameOfYahooFile;                    File destination_file = new File(sEntirePathOfFileToWriteYahooExportTo);                    //per http://javaalmanac.com/egs/java.io/WriteISOLatin1.html                    try {                        File parentdir = parent(destination_file);                         if( !(sArticleXMLElementText2HTML.equals("")) )                        {                            if (parentdir.exists()){                                if (parentdir.canWrite()){                                    //BufferedWriter out_fullForEachNewArticleForYahoo = new BufferedWriter(new FileWriter(sEntirePathOfFileToWriteYahooExportTo)); //this is export to raw OS FS for use by external means                                        Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(sEntirePathOfFileToWriteYahooExportTo), "8859_1"));                                        out.write(sArticle);                                        out.close();                                                          //out_fullForEachNewArticleForYahoo.write(sArticle);                                    //out_fullForEachNewArticleForYahoo.close();                                                            }                            }                            else {                                //System.out.println("write to UNIX FX ("+sEntirePathOfFileToWriteYahooExportTo+") has failed");                                //else { //write to UNIX system failed, because we might be on the windows env; attempting to write to windows env.                                sEntirePathOfFileToWriteYahooExportTo = sAbsolutePathToWriteYahooExportDirectoryOnWINDOWS + sNameOfYahooFile;                                destination_file = new File(sEntirePathOfFileToWriteYahooExportTo);                                parentdir = parent(destination_file);                                if (parentdir.exists()){                                    if (parentdir.canWrite()){                                        Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(sEntirePathOfFileToWriteYahooExportTo), "8859_1"));                                        out.write(sArticle);                                        out.close();                                        //BufferedWriter out_fullForEachNewArticleForYahoo = new BufferedWriter(new FileWriter(sEntirePathOfFileToWriteYahooExportTo)); //this is export to raw OS FS for use by external means                                        //out_fullForEachNewArticleForYahoo.write(sArticle);                                        //out_fullForEachNewArticleForYahoo.close();                                                                }                                }                            }                        }                    } catch (UnsupportedEncodingException e) {                    } catch (IOException e) {                    }                                        //ADD TO REGULAR RSS FEED                    ParsePosition pPaternForRssDataMatechUp = new ParsePosition(0);                    Date theDateForRssItem = inputDateFormat.parse(item.getDate(), pPaternForRssDataMatechUp);                    SimpleDateFormat outputDateFormatForRss = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US); //Mon, 23 Apr 2007 12:36:10 -0400                    String outputDateForRssItem = outputDateFormatForRss.format(theDateForRssItem);                    SimpleDateFormat outputDateFormatForRssForKeywords = new SimpleDateFormat("yyyy-MM-dd HH:mm:ssZ", Locale.US);  //2007-03-29T14:13:16-05:00                    String outputDateForRssItemForKeywords = outputDateFormatForRssForKeywords.format(theDateForRssItem);                                        outputDateForRssItemForKeywords = outputDateForRssItemForKeywords.replaceAll(" ", "T");                    outputDateForRssItemForKeywords = outputDateForRssItemForKeywords.replaceAll("-0400", "-04:00"); //Hot fix for Google sitemaps format                    outputDateForRssItemForKeywords = outputDateForRssItemForKeywords.replaceAll("-0500", "-05:00"); //Hot fix for Google sitemaps format                    outputDateForRssItemForKeywords = outputDateForRssItemForKeywords.replaceAll("-0600", "-06:00"); //Hot fix for Google sitemaps format                                                    //sArticleXMLElementText1plainText = sArticleXMLElementText1plainText.replaceAll("&", "and");                        sArticleXMLElementText1plainText = sArticleXMLElementText1plainText.replaceAll("\n", " ");                                         sArticleXMLElementText1plainText = sArticleXMLElementText1plainText.replaceAll("<(.*?)>", " ");                        sArticleXMLElementText1plainText = sArticleXMLElementText1plainText.replaceAll("<[^>]+>"," ");                        sArticleXMLElementText1plainText = sArticleXMLElementText1plainText.replaceAll("  ", " ");                        sArticleXMLElementText1plainText = sArticleXMLElementText1plainText.replaceAll("^\\s+", " ");                        sArticleXMLElementText1plainText = sArticleXMLElementText1plainText.replaceAll("^ ", "");                        sArticleXMLElementText1plainText = sArticleXMLElementText1plainText.replaceAll(" $", "");                        sArticleXMLElementText1plainText = sArticleXMLElementText1plainText.replaceAll("\\s+$", "");                        sArticleXMLElementText1plainText = sArticleXMLElementText1plainText.replaceAll("\\b\\s{2,}\\b", " ");                        //added here                        //sArticleXMLElementText2plainText = sArticleXMLElementText2plainText.replaceAll("&", "and");                        sArticleXMLElementText2plainText = sArticleXMLElementText2plainText.replaceAll("\n", " ");                                         sArticleXMLElementText2plainText = sArticleXMLElementText2plainText.replaceAll("<(.*?)>", " ");                        sArticleXMLElementText2plainText = sArticleXMLElementText2plainText.replaceAll("<[^>]+>"," ");                        sArticleXMLElementText2plainText = sArticleXMLElementText2plainText.replaceAll("  ", " ");                        sArticleXMLElementText2plainText = sArticleXMLElementText2plainText.replaceAll("^\\s+", " ");                        sArticleXMLElementText2plainText = sArticleXMLElementText2plainText.replaceAll("^ ", "");                        sArticleXMLElementText2plainText = sArticleXMLElementText2plainText.replaceAll(" $", "");                        sArticleXMLElementText2plainText = sArticleXMLElementText2plainText.replaceAll("\\s+$", "");                        sArticleXMLElementText2plainText = sArticleXMLElementText2plainText.replaceAll("\\b\\s{2,}\\b", " ");                    String sDescriptionForRss = "";                    if(sArticleXMLElementText1plainText != null && sArticleXMLElementText1plainText.indexOf(" ", 150) != -1){                        sDescriptionForRss = sArticleXMLElementText1plainText.substring(0, sArticleXMLElementText1plainText.indexOf(" ", 150) ) + "...";                    }                    else {                        sDescriptionForRss = sArticleXMLElementText2plainText;                    }                        try {                            if(sArticleXMLElementText1plainText != null && sArticleXMLElementText1plainText.indexOf(" ", 150) != -1){                                sDescriptionForRss = sArticleXMLElementText1plainText.substring(0, sArticleXMLElementText1plainText.indexOf(" ", 150) ) + "...";                            }                            else if (sArticleXMLElementText1plainText != null){                                sDescriptionForRss = sArticleXMLElementText1plainText;                            }                             else{ //now this is in case description/summary is left blank entirely by analysts... when posting the data - we make use of the body/article data                                if(sArticleXMLElementText2plainText != null && sArticleXMLElementText2plainText.indexOf(" ", 150) != -1){                                    sDescriptionForRss = sArticleXMLElementText2plainText.substring(0, sArticleXMLElementText2plainText.indexOf(" ", 150) ) + "...";                                }                                else{                                    sDescriptionForRss = "See the article..."; //todo, but this is in a very rare case that if summary is empty and body is under 150 characters...                                }                            }                        } catch ( StringIndexOutOfBoundsException e ){                            // comment and for debuging: System.outx.println("StringIndexOutOfBoundsException occured ");                        }                        sDescriptionForRss = sDescriptionForRss.replaceAll("&", " and ");                        sDescriptionForRss = sDescriptionForRss.replaceAll("\n", " ");                                         sDescriptionForRss = sDescriptionForRss.replaceAll("<(.*?)>", " ");                        sDescriptionForRss = sDescriptionForRss.replaceAll("<[^>]+>"," ");                        sDescriptionForRss = sDescriptionForRss.replaceAll("  ", " ");                        sDescriptionForRss = sDescriptionForRss.replaceAll("^\\s+", " ");                        sDescriptionForRss = sDescriptionForRss.replaceAll("^ ", "");                        sDescriptionForRss = sDescriptionForRss.replaceAll(" $", "");                        sDescriptionForRss = sDescriptionForRss.replaceAll("\\s+$", "");                        sDescriptionForRss = sDescriptionForRss.replaceAll("\\b\\s{2,}\\b", " ");                                                if(sDescriptionForRss.equals("")){                            sDescriptionForRss = "See the article...";                        }                        sRssItem +=                                "   <item>\n" +                                "    <title>" + replaceSpecialCharacters( item.getTitle() ) + "</title>\n" +                                "    <link>http://www.xxx.com" + item.getFile() + "?engine=rss&amp;keyword=article</link>\n" +                                "    <author>" + replaceSpecialCharacters( item.getAuthor() ) + " strategist@xxx.com</author>\n" +                                 "    <description>" + sDescriptionForRss + "</description>\n" +                                "    <pubDate>" + outputDateForRssItem + "</pubDate>\n" +  //<pubDate>2006-02-16 12:31:12</pubDate>                                "    <guid>http://www.xxx.com" + item.getFile() + "</guid>\n" + //ideally should have tag isPermaLink="false" per http://feedvalidator.org/docs/error/InvalidHttpGUID.html                                "   </item>\n";                                            CmsProperty propertyObject = cmsObject.readPropertyObject(sfSiteRoot + fileResource, "Keywords", false);                    String sPropertyKeywords = "";                                        if (propertyObject != null)                    {                        sPropertyKeywords = propertyObject.getValue();                    }                    if (propertyObject == null)                    {                        sPropertyKeywords = "";                    }                    if (sPropertyKeywords == null)                    {                        sPropertyKeywords = "";                    }                                                                                CmsProperty propertyObject2 = cmsObject.readPropertyObject(sfSiteRoot + fileResource, "Stockticker", false);                    String sPropertyStockTicker = "";                                        if (propertyObject2 != null)                    {                        sPropertyStockTicker = propertyObject2.getValue();                    }                                        if (propertyObject2 == null)                    {                        sPropertyStockTicker = "";                    }                    if (sPropertyStockTicker == null)                    {                        sPropertyStockTicker = "";                    }                                            sRssItemKeywords +=                                "   <url>\n" +                                "    <loc>http://www.xxx.com" + item.getFile() + "</loc>\n" +                                "    <news:news>\n" +                                "       <news:publication_date>" + outputDateForRssItemForKeywords + "</news:publication_date>\n" +  //new: 2006-05-03T17:54:30-04:00 old: <pubDate>2006-02-16 12:31:12</pubDate>                                "       <news:keywords>Business</news:keywords>\n" +                                "       <news:stock_tickers>" + sPropertyStockTicker + "</news:stock_tickers>\n" +                                "    </news:news>\n" +                                "   </url>\n";                                                String sRssDescriptionForRssWoImages = sArticleXMLElementText1HTML + "<br /><br />" + sArticleXMLElementText2HTML;                                                sRssDescriptionForRssWoImages = cleanHTML(sRssDescriptionForRssWoImages);                        sRssDescriptionForRssWoImages= sRssDescriptionForRssWoImages.replaceAll("&", "&amp;");                        sRssDescriptionForRssWoImages = sRssDescriptionForRssWoImages.replaceAll("<img(.*?)>", "&lt;br /&gt;");                        sRssDescriptionForRssWoImages = sRssDescriptionForRssWoImages.replaceAll("<IMG(.*?)>", "&lt;br /&gt;");                        sRssDescriptionForRssWoImages = sRssDescriptionForRssWoImages.replaceAll("\n", " ");                        sRssDescriptionForRssWoImages = sRssDescriptionForRssWoImages.replaceAll("<", "&lt;");                        sRssDescriptionForRssWoImages = sRssDescriptionForRssWoImages.replaceAll(">", "&gt;");    /*                        sRssDescriptionForRssWoImages= sRssDescriptionForRssWoImages.replaceAll("&rsquo;", "'");                        sRssDescriptionForRssWoImages= sRssDescriptionForRssWoImages.replaceAll("&ndash;", "-");                        sRssDescriptionForRssWoImages= sRssDescriptionForRssWoImages.replaceAll("&middot;", "·"); //sRssDescriptionForRssWoImages= sRssDescriptionForRssWoImages.replaceAll("&middot;", "·");                        sRssDescriptionForRssWoImages= sRssDescriptionForRssWoImages.replaceAll("&nbsp;", " ");                        sRssDescriptionForRssWoImages= sRssDescriptionForRssWoImages.replaceAll("&ldquo;", "\"");                        sRssDescriptionForRssWoImages= sRssDescriptionForRssWoImages.replaceAll("&rdquo;", "\"");                        sRssDescriptionForRssWoImages= sRssDescriptionForRssWoImages.replaceAll("&bull;", "·");                        sRssDescriptionForRssWoImages= sRssDescriptionForRssWoImages.replaceAll("&mdash;", "—");    */                         //sRssDescriptionForRssWoImages= sRssDescriptionForRssWoImages.replaceAll("&(.*?);", " ");                        sRssItemFull +=                                "   <item>\n" +                                "    <title>" + replaceSpecialCharacters( item.getTitle() ) + "</title>\n" +                                "    <link>http://www.xxx.com" + item.getFile() + "?engine=rss&amp;keyword=article</link>\n" +                                "    <description>" + replaceSpecialCharacters( sRssDescriptionForRssWoImages ) + "</description>\n" +                                "    <pubDate>" + outputDateForRssItem + "</pubDate>\n" +  //<pubDate>2006-02-16 12:31:12</pubDate>                                "    <guid>http://www.xxx.com" + item.getFile() + "</guid>\n" +                                "   </item>\n";                        //http://www.xxx.com/feeds/full-images.php                        String sRssDescriptionForRssWithImages = sArticleXMLElementText1HTML + "<br /><br />" + sArticleXMLElementText2HTML;                        sRssDescriptionForRssWithImages = sRssDescriptionForRssWithImages.replaceAll("&", "&amp;");                        sRssDescriptionForRssWithImages = cleanHTML(sRssDescriptionForRssWithImages);                        sRssDescriptionForRssWithImages = sRssDescriptionForRssWithImages.replaceAll("\n", " ");                        sRssDescriptionForRssWithImages = sRssDescriptionForRssWithImages.replaceAll("<o:","<"); //this addresses special Microsoft tags that get into the output from copy paste from MSFT docs by analysts                        sRssDescriptionForRssWithImages = sRssDescriptionForRssWithImages.replaceAll("</o:","</"); //this addresses special Microsoft tags that get into the output from copy paste from MSFT docs by analysts                        sRssDescriptionForRssWithImages = sRssDescriptionForRssWithImages.replaceAll("<O:","<"); //this addresses special Microsoft tags that get into the output from copy paste from MSFT docs by analysts                        sRssDescriptionForRssWithImages = sRssDescriptionForRssWithImages.replaceAll("</O:","</"); //this addresses special Microsoft tags that get into the output from copy paste from MSFT docs by analysts                        sRssDescriptionForRssWithImages = sRssDescriptionForRssWithImages.replaceAll("<", "&lt;");                        sRssDescriptionForRssWithImages = sRssDescriptionForRssWithImages.replaceAll(">", "&gt;");                        //sRssDescriptionForRssWithImages = sRssDescriptionForRssWithImages.replaceAll("src=\"/story-images/", "src=\"http://www.xxx.com/export/sites/xxx/");                           //sRssDescriptionForRssWithImages = sRssDescriptionForRssWithImages.replaceAll("SRC=\"/story-images/", "SRC=\"http://www.xxx.com/export/sites/xxx/");                        sRssDescriptionForRssWithImages = normalizeURLs(sRssDescriptionForRssWithImages);                        //src="http://www.xxx.com/export/sites/xxx/story-images/2006/04/currency_crosses/Crosses/04-13-06cross2.gif"                        //src="/opencms/opencms/story-images/2006/04/currency_crosses/Crosses/04-13-06cross2.gif"                                                //sRssDescriptionForRssWithImages = sRssDescriptionForRssWithImages.replaceAll("src=\"/opencms/opencms/", "src=\"http://www.xxx.com/export/sites/xxx/");                        //sRssDescriptionForRssWithImages = sRssDescriptionForRssWithImages.replaceAll("SRC=\"/opencms/opencms/", "SRC=\"http://www.xxx.com/export/sites/xxx/");                        //sRssDescriptionForRssWithImages = sRssDescriptionForRssWithImages.replaceAll("href=\"/opencms/opencms/", "href=\"http://www.xxx.com/export/sites/xxx/");                        //sRssDescriptionForRssWithImages = sRssDescriptionForRssWithImages.replaceAll("HREF=\"/opencms/opencms/", "HREF=\"http://www.xxx.com/export/sites/xxx/");                        // http://xxx.opencms.prod.xxxx.com/export/sites/xxx/story-images/archive/daily_fundamentals/ssi_3_30_06_1.gif                        // http://xxx.opencms.prod.xxxx.com/export/sites/xxx/story-images/archive/market_brief/03-29-06MB.gif                                                sRssItemFullAndImages +=                                "   <item>\n" +                                "    <title>" + item.getTitle() + "</title>\n" +                                "    <link>http://www.xxx.com" + item.getFile() + "?engine=rss&amp;keyword=article</link>\n" +                                "    <author>" + replaceSpecialCharacters( item.getAuthor() ) + " strategist@xxx.com</author>\n" +                                 "    <description>" + sRssDescriptionForRssWithImages + "</description>\n" +                                "    <pubDate>" + outputDateForRssItem + "</pubDate>\n" +  //<pubDate>2006-02-16 12:31:12</pubDate>                                "    <guid>http://www.xxx.com" + item.getFile() + "</guid>\n" +                                "   </item>\n";                                                Tidy tidy = new Tidy();                        tidy.setWord2000(true);                                                                        if (iCountOfMaxArticlesForxxxxTR++ < 7){                        sxxxxTR_news += "<div class=\"headlinesDate\">" + item.getDate() + "</div>\n" +                             "<a name=\"#"+iUniqueIDofFile+"_b\"></a>" +                            "<div id=\"plus_sign\" class=\"plus_sign\">\n" +                             "<a style=\"font-family:Verdana, sans-serif; font-size:14px; font-weight:bold; color:#E86F0D\" class=\"effect10\" onClick=\"javascript:displayContent('"+iUniqueIDofFile+"')\" href=\"#"+iUniqueIDofFile+"_b\">\n" +                             "<div>" + item.getTitle() + "</div>\n" +                             "<img border=\"0\" height=\"1\" width=\"1\" src=\"/images/plus.gif\"></a>\n" +                             "</div>\n" +                             "<a name=\"#"+iUniqueIDofFile+"_b\"></a>\n" +                             "<div style=\"display:none;\" id=\""+iUniqueIDofFile+"\" class=\""+iUniqueIDofFile+"_b\">\n" +                             "<div id=\"minus_sign\" class=\"minus_sign\">\n" +                             "<a onClick=\"displayContent('"+iUniqueIDofFile+"');\" href=\"#"+iUniqueIDofFile+"_b\"><img alt=\"expand article\" border=\"0\" height=\"18\" width=\"96\" src=\"/images/minus.gif\"></a>\n" +                             "</div>\n" +                             "<div style=\"font-family:Georgia,serif;font-size:11px;font-weight:normal;color:#30303E;line-height:19px;text-align:left\">" + item.getAuthor() + "<br>\n" +                             sRssDescriptionForRssWithImages +                            "<hr>\n" +                             "</div>\n" +                             "</div>\n" +                            "\n";                                                    }                }                                   //WRTING xxxxTR AND REFCOFX NEWS EXPORT TO OS FS                    //WRTING xxxxTR AND REFCOFX NEWS EXPORT TO OS FS                    //WRTING xxxxTR AND REFCOFX NEWS EXPORT TO OS FS                    //WRTING xxxxTR AND REFCOFX NEWS EXPORT TO OS FS                    //WRTING xxxxTR AND REFCOFX NEWS EXPORT TO OS FS                                      //We also want to check if this directory is here and is writable:                    String sAbsolutePathToWritexxxxTRExportDirectoryOnUNIX = "/usr/local/xxx/resources/new_articles_for_xxxxTR/";                    String sAbsolutePathToWritexxxxTRExportDirectoryOnWINDOWS = "C:\\Program Files\\netbeans-4.1\\enterprise1\\jakarta-tomcat-5.5.7\\bin\\new_articles_for_xxxxTR\\";                    String sNameOfxxxxTRFile = "All_latest_xxx_Articles_for_xxxxTR_ready.html";                    String sEntirePathOfFileToWritexxxxTRExportTo = sAbsolutePathToWritexxxxTRExportDirectoryOnUNIX + sNameOfxxxxTRFile;                      File destination_file = new File(sEntirePathOfFileToWritexxxxTRExportTo);                    File parentdir = parent(destination_file);                     if (parentdir.exists()){                        if (parentdir.canWrite()){                            //BufferedWriter out_fullForEachNewArticleForxxxxTR = new BufferedWriter(new FileWriter(sEntirePathOfFileToWritexxxxTRExportTo)); //this is export to raw OS FS for use by external means                            //out_fullForEachNewArticleForxxxxTR.write(sxxxxTR_news);                            //out_fullForEachNewArticleForxxxxTR.close();                                    Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(sEntirePathOfFileToWritexxxxTRExportTo), "8859_1"));                            out.write(sxxxxTR_news);                            out.close();                                                    }                    }                    else { //write to UNIX system failed, because we might be on the windows env; attempting to write to windows env.                        sEntirePathOfFileToWritexxxxTRExportTo = sAbsolutePathToWritexxxxTRExportDirectoryOnWINDOWS + sNameOfxxxxTRFile;                        destination_file = new File(sEntirePathOfFileToWritexxxxTRExportTo);                        parentdir = parent(destination_file);                        if (parentdir.exists()){                            if (parentdir.canWrite()){                                //BufferedWriter out_fullForEachNewArticleForxxxxTR = new BufferedWriter(new FileWriter(sEntirePathOfFileToWritexxxxTRExportTo)); //this is export to raw OS FS for use by external means                                //out_fullForEachNewArticleForxxxxTR.write(sxxxxTR_news);                                //out_fullForEachNewArticleForxxxxTR.close();                                            Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(sEntirePathOfFileToWritexxxxTRExportTo), "8859_1"));                                out.write(sxxxxTR_news);                                out.close();                            }                        }                    }                                                //BufferedWriter out_fullForxxxxTR_ready = new BufferedWriter(new FileWriter("All_latest_xxx_Articles_for_xxxxTR_ready.html")); //this is export to raw OS FS for use by external means            //out_fullForxxxxTR_ready.write(sxxxxTR_news);            //out_fullForxxxxTR_ready.close();            //BEGIN FORMING THE RSS FEEDS            //REGULAR RSS FEED            Date dCurrentDateNow = new Date();            SimpleDateFormat outputDateFormatForRssTop = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US);            String sOutputDateTimeNowForRss = outputDateFormatForRssTop.format(dCurrentDateNow);                        String sRssStart =                    "<?xml version=\"1.0\" encoding=\"UTF-8\" ?> \n" +                    " <rss version=\"2.0\">\n" +                    "  <channel>\n" +                    "   <title>Currency Trading News by xxx</title> \n" +                    "   <link>http://www.xxx.com</link> \n" +                    "   <language>en-us</language>\n" +                    "   <description>Forex news about foreign exchange rates and reports on world business events that affect the currency market provided by xxx.</description> \n" +                    "   <lastBuildDate>" + sOutputDateTimeNowForRss + "</lastBuildDate> \n"; //Tue, 14 Feb 2006 20:57:44 +0100                        String sRssEnding = " </channel>\n</rss>\n";            String sRssStartKeywords =                    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +                    "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\n" +                    "        xmlns:news=\"http://www.google.com/schemas/sitemap-news/0.9\">\n";            String sRssEndingKeywords = "</urlset>\n";                                    String sRssRegularFeed = sRssStart + sRssItem + sRssEnding;            // comment and for debuging: System.outx.println("sRssRegularFeed = <TEXTAREA COLS=70 ROWS=20>" + sRssRegularFeed + "</TEXTAREA><HR>");                        String sRssRegularFeedFullWithoutImages = sRssStart + sRssItemFull + sRssEnding;            // comment and for debuging: System.outx.println("sRssRegularFeed = <TEXTAREA COLS=70 ROWS=20>" + sRssRegularFeedFullWithoutImages + "</TEXTAREA><HR>");                        String sRssRegularFeedFullWithImages = sRssStart + sRssItemFullAndImages + sRssEnding;            // comment and for debuging: System.outx.println("sRssRegularFeed = <TEXTAREA COLS=70 ROWS=20>" + sRssRegularFeedFullWithImages + "</TEXTAREA><HR>");            String sRssRegularWithKeywords = sRssStartKeywords + sRssItemKeywords + sRssEndingKeywords;                        // IMPORTANT !!! DO NOT FORGET TO CHANGE THE PHP FILE TYPE TO XML mimetypes.properties to have .php render as text/xml instead of text/html what might upset certain poor RSS readers                        //TESTING            //http://www.google.com/reader/view/feed/http%3A%2F%2Fwww.ingearx.info%2Fxxxx1%2Fxml_full1c.xml?q=http%3A%2F%2Fwww.ingearx.info%2Fxxxx1%2Fxml_full1c.xml            //http://blogs.law.harvard.edu/tech/rss            //http://www.xxx.com/index2.php?option=com_rss&feed=RSS2.0&no_html=1            writeStringAsFileToVFS(cmsObject, sRssRegularFeed, sfSiteRoot + "/" + "index2.php");            writeStringAsFileToVFS(cmsObject, sRssRegularFeed, sfSiteRoot + "/" + "feeds/rss.xml");            //http://www.xxx.com/feeds/full.php                        writeStringAsFileToVFS(cmsObject, sRssRegularFeedFullWithoutImages, sfSiteRoot + "/" + "feeds/full.php");            writeStringAsFileToVFS(cmsObject, sRssRegularFeedFullWithoutImages, sfSiteRoot + "/" + "feeds/full.xml");            //http://www.xxx.com/feeds/full-images.php            writeStringAsFileToVFS(cmsObject, sRssRegularFeedFullWithImages, sfSiteRoot + "/" + "feeds/full-images.php");            writeStringAsFileToVFS(cmsObject, sRssRegularFeedFullWithImages, sfSiteRoot + "/" + "feeds/full-images.xml");            writeStringAsFileToVFS(cmsObject, sRssRegularWithKeywords, sfSiteRoot + "/" + "feeds/newsmap.xml");             String sRssRegularFeedFullWithoutImages2 = sRssRegularFeedFullWithImages;            sRssRegularFeedFullWithoutImages2 = sRssRegularFeedFullWithoutImages2.replaceAll("\n", " ");            sRssRegularFeedFullWithoutImages2 = sRssRegularFeedFullWithoutImages2.replaceAll("\r", " ");            sRssRegularFeedFullWithoutImages2 = sRssRegularFeedFullWithoutImages2.replaceAll("\n\r", " ");            sRssRegularFeedFullWithoutImages2 = sRssRegularFeedFullWithoutImages2.replaceAll("  ", " ");            sRssRegularFeedFullWithoutImages2 = sRssRegularFeedFullWithoutImages2.replaceAll("  ", " ");            sRssRegularFeedFullWithoutImages2 = sRssRegularFeedFullWithoutImages2.replaceAll("<img(.*?)>", "&lt;br /&gt;");            //<img(.*?)>", "&lt;br /&gt;");            //<img title="funda 5 5 06_1" alt="funda 5 5 06_1" src="http://www.xxx.com/export/sites/xxx/story-images/2006/05/xxx_reports            sRssRegularFeedFullWithoutImages2 = sRssRegularFeedFullWithoutImages2.replaceAll("<IMG(.*?)>", "&lt;br /&gt;");                        //http://www.xxx.com/feeds/full.php            writeStringAsFileToVFS(cmsObject, sRssRegularFeedFullWithoutImages2, sfSiteRoot + "/" + "feeds/full-noimages.xml");            writeStringAsFileToVFS(cmsObject, sRssRegularFeedFullWithoutImages2, sfSiteRoot + "/" + "feeds/full2.xml");            writeStringAsFileToVFS(cmsObject, sRssRegularFeedFullWithoutImages2, sfSiteRoot + "/" + "feeds/full.xml");                                                String sAvantGoDocument = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +"<site>\n" +"	<page>\n" +"		<pageid>1</pageid>\n" +"		<content>\n" +"			&lt;a href=&quot;article.1." + avantGoGetArticleData("/sites/xxx", "", 0, "fileId", cmsObject, fxres) + ".php&quot;&gt;" + avantGoGetArticleData("/sites/xxx", "", 0, "title", cmsObject, fxres) + "&lt;/a&gt; " + avantGoGetArticleData("/sites/xxx", "", 0, "introHTML", cmsObject, fxres) + "&amp;amp;nbsp;&lt;a href=&quot;article.1." + avantGoGetArticleData("/sites/xxx", "", 0, "fileId", cmsObject, fxres) + ".php&quot;&gt;Read More&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;\n" +"			&lt;a href=&quot;article.1." + avantGoGetArticleData("/sites/xxx", "", 1, "fileId", cmsObject, fxres) + ".php&quot;&gt;" + avantGoGetArticleData("/sites/xxx", "", 1, "title", cmsObject, fxres) + "&lt;/a&gt; " + avantGoGetArticleData("/sites/xxx", "", 1, "introHTML", cmsObject, fxres) + "&amp;amp;nbsp;&lt;a href=&quot;article.1." + avantGoGetArticleData("/sites/xxx", "", 1, "fileId", cmsObject, fxres) + ".php&quot;&gt;Read More&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;\n" +"			&lt;a href=&quot;article.1." + avantGoGetArticleData("/sites/xxx", "", 2, "fileId", cmsObject, fxres) + ".php&quot;&gt;" + avantGoGetArticleData("/sites/xxx", "", 2, "title", cmsObject, fxres) + "&lt;/a&gt; " + avantGoGetArticleData("/sites/xxx", "", 2, "introHTML", cmsObject, fxres) + "&amp;amp;nbsp;&lt;a href=&quot;article.1." + avantGoGetArticleData("/sites/xxx", "", 2, "fileId", cmsObject, fxres) + ".php&quot;&gt;Read More&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;\n" +"			&lt;a href=&quot;article.1." + avantGoGetArticleData("/sites/xxx", "", 3, "fileId", cmsObject, fxres) + ".php&quot;&gt;" + avantGoGetArticleData("/sites/xxx", "", 3, "title", cmsObject, fxres) + "&lt;/a&gt; " + avantGoGetArticleData("/sites/xxx", "", 3, "introHTML", cmsObject, fxres) + "&amp;amp;nbsp;&lt;a href=&quot;article.1." + avantGoGetArticleData("/sites/xxx", "", 3, "fileId", cmsObject, fxres) + ".php&quot;&gt;Read More&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;\n" +"			&lt;a href=&quot;article.1." + avantGoGetArticleData("/sites/xxx", "", 4, "fileId", cmsObject, fxres) + ".php&quot;&gt;" + avantGoGetArticleData("/sites/xxx", "", 4, "title", cmsObject, fxres) + "&lt;/a&gt; " + avantGoGetArticleData("/sites/xxx", "", 4, "introHTML", cmsObject, fxres) + "&amp;amp;nbsp;&lt;a href=&quot;article.1." + avantGoGetArticleData("/sites/xxx", "", 4, "fileId", cmsObject, fxres) + ".php&quot;&gt;Read More&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;\n" +"		</content>\n" +"	</page>\n" +	"	<page>\n" +"		<pageid>4</pageid>\n" +"		<content>\n" +"			&lt;a href=&quot;article.4." + avantGoGetArticleData("/sites/xxx", "/story/currency/eur_fundamentals", 0, "fileId", cmsObject, fxres) + ".php&quot;&gt;" + avantGoGetArticleData("/sites/xxx", "/story/currency/eur_fundamentals", 0, "title", cmsObject, fxres) + "&lt;/a&gt; " + avantGoGetArticleData("/sites/xxx", "/story/currency/eur_fundamentals", 0, "introHTML", cmsObject, fxres) + "&amp;amp;nbsp;&lt;a href=&quot;article.4." + avantGoGetArticleData("/sites/xxx", "/story/currency/eur_fundamentals", 0, "fileId", cmsObject, fxres) + ".php&quot;&gt;Read More&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;\n" +"			&lt;a href=&quot;article.4." + avantGoGetArticleData("/sites/xxx", "/story/currency/eur_fundamentals", 1, "fileId", cmsObject, fxres) + ".php&quot;&gt;" + avantGoGetArticleData("/sites/xxx", "/story/currency/eur_fundamentals", 1, "title", cmsObject, fxres) + "&lt;/a&gt; " + avantGoGetArticleData("/sites/xxx", "/story/currency/eur_fundamentals", 1, "introHTML", cmsObject, fxres) + "&amp;amp;nbsp;&lt;a href=&quot;article.4." + avantGoGetArticleData("/sites/xxx", "/story/currency/eur_fundamentals", 1, "fileId", cmsObject, fxres) + ".php&quot;&gt;Read More&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;\n" +"		</content>\n" +"	</page>\n" +"	<page>\n" +"		<pageid>5</pageid>\n" +"		<content>\n" +"			&lt;a href=&quot;article.5." + avantGoGetArticleData("/sites/xxx", "/story/currency/jpy_fundamentals", 0, "fileId", cmsObject, fxres) + ".php&quot;&gt;" + avantGoGetArticleData("/sites/xxx", "/story/currency/jpy_fundamentals", 0, "title", cmsObject, fxres) + "&lt;/a&gt; " + avantGoGetArticleData("/sites/xxx", "/story/currency/jpy_fundamentals", 0, "introHTML", cmsObject, fxres) + "&amp;amp;nbsp;&lt;a href=&quot;article.5." + avantGoGetArticleData("/sites/xxx", "/story/currency/jpy_fundamentals", 0, "fileId", cmsObject, fxres) + ".php&quot;&gt;Read More&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;\n" +"			&lt;a href=&quot;article.5." + avantGoGetArticleData("/sites/xxx", "/story/currency/jpy_fundamentals", 1, "fileId", cmsObject, fxres) + ".php&quot;&gt;" + avantGoGetArticleData("/sites/xxx", "/story/currency/jpy_fundamentals", 1, "title", cmsObject, fxres) + "&lt;/a&gt; " + avantGoGetArticleData("/sites/xxx", "/story/currency/jpy_fundamentals", 1, "introHTML", cmsObject, fxres) + "&amp;amp;nbsp;&lt;a href=&quot;article.5." + avantGoGetArticleData("/sites/xxx", "/story/currency/jpy_fundamentals", 1, "fileId", cmsObject, fxres) + ".php&quot;&gt;Read More&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;\n" +"		</content>\n" +"	</page>\n" +"	<page>\n" +"		<pageid>6</pageid>\n" +"		<content>\n" +"			&lt;a href=&quot;article.6." + avantGoGetArticleData("/sites/xxx", "/story/currency/gbp_fundamentals", 0, "fileId", cmsObject, fxres) + ".php&quot;&gt;" + avantGoGetArticleData("/sites/xxx", "/story/currency/gbp_fundamentals", 0, "title", cmsObject, fxres) + "&lt;/a&gt; " + avantGoGetArticleData("/sites/xxx", "/story/currency/gbp_fundamentals", 0, "introHTML", cmsObject, fxres) + "&amp;amp;nbsp;&lt;a href=&quot;article.6." + avantGoGetArticleData("/sites/xxx", "/story/currency/gbp_fundamentals", 0, "fileId", cmsObject, fxres) + ".php&quot;&gt;Read More&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;\n" +"			&lt;a href=&quot;article.6." + avantGoGetArticleData("/sites/xxx", "/story/currency/gbp_fundamentals", 1, "fileId", cmsObject, fxres) + ".php&quot;&gt;" + avantGoGetArticleData("/sites/xxx", "/story/currency/gbp_fundamentals", 1, "title", cmsObject, fxres) + "&lt;/a&gt; " + avantGoGetArticleData("/sites/xxx", "/story/currency/gbp_fundamentals", 1, "introHTML", cmsObject, fxres) + "&amp;amp;nbsp;&lt;a href=&quot;article.6." + avantGoGetArticleData("/sites/xxx", "/story/currency/gbp_fundamentals", 1, "fileId", cmsObject, fxres) + ".php&quot;&gt;Read More&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;\n" +"		</content>\n" +"	</page>\n" +"	<page>\n" +"		<pageid>7</pageid>\n" +"		<content>\n" +"			&lt;a href=&quot;article.7." + avantGoGetArticleData("/sites/xxx", "/story/currency/aud_fundamentals", 0, "fileId", cmsObject, fxres) + ".php&quot;&gt;" + avantGoGetArticleData("/sites/xxx", "/story/currency/aud_fundamentals", 0, "title", cmsObject, fxres) + "&lt;/a&gt; " + avantGoGetArticleData("/sites/xxx", "/story/currency/aud_fundamentals", 0, "introHTML", cmsObject, fxres) + "&amp;amp;nbsp;&lt;a href=&quot;article.7." + avantGoGetArticleData("/sites/xxx", "/story/currency/aud_fundamentals", 0, "fileId", cmsObject, fxres) + ".php&quot;&gt;Read More&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;\n" +"			&lt;a href=&quot;article.7." + avantGoGetArticleData("/sites/xxx", "/story/currency/aud_fundamentals", 1, "fileId", cmsObject, fxres) + ".php&quot;&gt;" + avantGoGetArticleData("/sites/xxx", "/story/currency/aud_fundamentals", 1, "title", cmsObject, fxres) + "&lt;/a&gt; " + avantGoGetArticleData("/sites/xxx", "/story/currency/aud_fundamentals", 1, "introHTML", cmsObject, fxres) + "&amp;amp;nbsp;&lt;a href=&quot;article.7." + avantGoGetArticleData("/sites/xxx", "/story/currency/aud_fundamentals", 1, "fileId", cmsObject, fxres) + ".php&quot;&gt;Read More&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;\n" +"		</content>\n" +"	</page>\n" +"	<page>\n" +"		<pageid>8</pageid>\n" +"		<content>\n" +"			&lt;a href=&quot;article.8." + avantGoGetArticleData("/sites/xxx", "/story/currency/cad_fundamentals", 0, "fileId", cmsObject, fxres) + ".php&quot;&gt;" + avantGoGetArticleData("/sites/xxx", "/story/currency/cad_fundamentals", 0, "title", cmsObject, fxres) + "&lt;/a&gt; " + avantGoGetArticleData("/sites/xxx", "/story/currency/cad_fundamentals", 0, "introHTML", cmsObject, fxres) + "&amp;amp;nbsp;&lt;a href=&quot;article.8." + avantGoGetArticleData("/sites/xxx", "/story/currency/cad_fundamentals", 0, "fileId", cmsObject, fxres) + ".php&quot;&gt;Read More&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;\n" +"			&lt;a href=&quot;article.8." + avantGoGetArticleData("/sites/xxx", "/story/currency/cad_fundamentals", 1, "fileId", cmsObject, fxres) + ".php&quot;&gt;" + avantGoGetArticleData("/sites/xxx", "/story/currency/cad_fundamentals", 1, "title", cmsObject, fxres) + "&lt;/a&gt; " + avantGoGetArticleData("/sites/xxx", "/story/currency/cad_fundamentals", 1, "introHTML", cmsObject, fxres) + "&amp;amp;nbsp;&lt;a href=&quot;article.8." + avantGoGetArticleData("/sites/xxx", "/story/currency/cad_fundamentals", 1, "fileId", cmsObject, fxres) + ".php&quot;&gt;Read More&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;\n" +"		</content>\n" +"	</page>\n" +"	<page>\n" +"		<pageid>9</pageid>\n" +"		<content>\n" +"			&lt;a href=&quot;article.9." + avantGoGetArticleData("/sites/xxx", "/story/currency/nzd_fundamentals", 0, "fileId", cmsObject, fxres) + ".php&quot;&gt;" + avantGoGetArticleData("/sites/xxx", "/story/currency/nzd_fundamentals", 0, "title", cmsObject, fxres) + "&lt;/a&gt; " + avantGoGetArticleData("/sites/xxx", "/story/currency/nzd_fundamentals", 0, "introHTML", cmsObject, fxres) + "&amp;amp;nbsp;&lt;a href=&quot;article.9." + avantGoGetArticleData("/sites/xxx", "/story/currency/nzd_fundamentals", 0, "fileId", cmsObject, fxres) + ".php&quot;&gt;Read More&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;\n" +"			&lt;a href=&quot;article.9." + avantGoGetArticleData("/sites/xxx", "/story/currency/nzd_fundamentals", 1, "fileId", cmsObject, fxres) + ".php&quot;&gt;" + avantGoGetArticleData("/sites/xxx", "/story/currency/nzd_fundamentals", 1, "title", cmsObject, fxres) + "&lt;/a&gt; " + avantGoGetArticleData("/sites/xxx", "/story/currency/nzd_fundamentals", 1, "introHTML", cmsObject, fxres) + "&amp;amp;nbsp;&lt;a href=&quot;article.9." + avantGoGetArticleData("/sites/xxx", "/story/currency/nzd_fundamentals", 1, "fileId", cmsObject, fxres) + ".php&quot;&gt;Read More&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;\n" +"		</content>\n" +"	</page>\n" +"	<page>\n" +"		<pageid>10</pageid>\n" +"		<content>\n" +"			&lt;a href=&quot;article.10." + avantGoGetArticleData("/sites/xxx", "/story/currency/chf_fundamentals", 0, "fileId", cmsObject, fxres) + ".php&quot;&gt;" + avantGoGetArticleData("/sites/xxx", "/story/currency/chf_fundamentals", 0, "title", cmsObject, fxres) + "&lt;/a&gt; " + avantGoGetArticleData("/sites/xxx", "/story/currency/chf_fundamentals", 0, "introHTML", cmsObject, fxres) + "&amp;amp;nbsp;&lt;a href=&quot;article.10." + avantGoGetArticleData("/sites/xxx", "/story/currency/chf_fundamentals", 0, "fileId", cmsObject, fxres) + ".php&quot;&gt;Read More&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;\n" +"			&lt;a href=&quot;article.10." + avantGoGetArticleData("/sites/xxx", "/story/currency/chf_fundamentals", 1, "fileId", cmsObject, fxres) + ".php&quot;&gt;" + avantGoGetArticleData("/sites/xxx", "/story/currency/chf_fundamentals", 1, "title", cmsObject, fxres) + "&lt;/a&gt; " + avantGoGetArticleData("/sites/xxx", "/story/currency/chf_fundamentals", 1, "introHTML", cmsObject, fxres) + "&amp;amp;nbsp;&lt;a href=&quot;article.10." + avantGoGetArticleData("/sites/xxx", "/story/currency/chf_fundamentals", 1, "fileId", cmsObject, fxres) + ".php&quot;&gt;Read More&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;\n" +"		</content>\n" +"	</page>\n" +"	<page>\n" +"	<article>\n" +"		<pageid>3</pageid>\n" +"		<content>\n" +"                       " + avantGoGetArticleData("/sites/xxx", "calendar", 0, "firstElementOnly", cmsObject, fxres) + "Please visit xxx.com for detailed information and news about each event.&lt;br /&gt;Data supplied by Briefing.com</content>\n" +"	</article>\n" +"	</page>\n" +"	<article>\n" +"		<id>" + avantGoGetArticleData("/sites/xxx", "", 0, "fileId", cmsObject, fxres) + "</id>\n" +"		<pageid>1</pageid>\n" +"		<title>" + avantGoGetArticleData("/sites/xxx", "", 0, "title", cmsObject, fxres) + "</title>\n" +"		<date>" + avantGoGetArticleData("/sites/xxx", "", 0, "time", cmsObject, fxres) + "</date>\n" +"		<author>" + avantGoGetArticleData("/sites/xxx", "", 0, "author", cmsObject, fxres) + "</author>\n" +"		<content>" + avantGoGetArticleData("/sites/xxx", "", 0, "fullHTML", cmsObject, fxres) + "</content>\n" +"	</article>\n" +"	<article>\n" +"		<id>" + avantGoGetArticleData("/sites/xxx", "", 1, "fileId", cmsObject, fxres) + "</id>\n" +"		<pageid>1</pageid>\n" +"		<title>" + avantGoGetArticleData("/sites/xxx", "", 1, "title", cmsObject, fxres) + "</title>\n" +"		<date>" + avantGoGetArticleData("/sites/xxx", "", 1, "time", cmsObject, fxres) + "</date>\n" +"		<author>" + avantGoGetArticleData("/sites/xxx", "", 1, "author", cmsObject, fxres) + "</author>\n" +"		<content>" + avantGoGetArticleData("/sites/xxx", "", 1, "fullHTML", cmsObject, fxres) + "</content>\n" +"	</article>\n" +"	<article>\n" +"		<id>" + avantGoGetArticleData("/sites/xxx", "", 2, "fileId", cmsObject, fxres) + "</id>\n" +"		<pageid>1</pageid>\n" +"		<title>" + avantGoGetArticleData("/sites/xxx", "", 2, "title", cmsObject, fxres) + "</title>\n" +"		<date>" + avantGoGetArticleData("/sites/xxx", "", 2, "time", cmsObject, fxres) + "</date>\n" +"		<author>" + avantGoGetArticleData("/sites/xxx", "", 2, "author", cmsObject, fxres) + "</author>\n" +"		<content>" + avantGoGetArticleData("/sites/xxx", "", 2, "fullHTML", cmsObject, fxres) + "</content>\n" +"	</article>\n" +"	<article>\n" +"		<id>" + avantGoGetArticleData("/sites/xxx", "", 3, "fileId", cmsObject, fxres) + "</id>\n" +"		<pageid>1</pageid>\n" +"		<title>" + avantGoGetArticleData("/sites/xxx", "", 3, "title", cmsObject, fxres) + "</title>\n" +"		<date>" + avantGoGetArticleData("/sites/xxx", "", 3, "time", cmsObject, fxres) + "</date>\n" +"		<author>" + avantGoGetArticleData("/sites/xxx", "", 3, "author", cmsObject, fxres) + "</author>\n" +"		<content>" + avantGoGetArticleData("/sites/xxx", "", 3, "fullHTML", cmsObject, fxres) + "</content>\n" +"	</article>\n" +"	<article>\n" +"		<id>" + avantGoGetArticleData("/sites/xxx", "", 4, "fileId", cmsObject, fxres) + "</id>\n" +"		<pageid>1</pageid>\n" +"		<title>" + avantGoGetArticleData("/sites/xxx", "", 4, "title", cmsObject, fxres) + "</title>\n" +"		<date>" + avantGoGetArticleData("/sites/xxx", "", 4, "time", cmsObject, fxres) + "</date>\n" +"		<author>" + avantGoGetArticleData("/sites/xxx", "", 4, "author", cmsObject, fxres) + "</author>\n" +"		<content>" + avantGoGetArticleData("/sites/xxx", "", 4, "fullHTML", cmsObject, fxres) + "</content>\n" +"	</article>\n" +"	<article>\n" +"		<id>0</id>\n" + //why is this 0 - shouldn't this be a uniqe id so that AvantGo would know that they need to update this aricle data to clients?"		<pageid>1</pageid>\n" +"		<title>" + avantGoGetArticleData("/sites/xxx", "/story/xxx_reports/daily_brief", 0, "title", cmsObject, fxres) + "</title>\n" +"		<date>" + avantGoGetArticleData("/sites/xxx", "/story/xxx_reports/daily_brief", 0, "time", cmsObject, fxres) + "</date>\n" +"		<author>" + avantGoGetArticleData("/sites/xxx", "/story/xxx_reports/daily_brief", 0, "author", cmsObject, fxres) + "</author>\n" +"		<content>" + avantGoGetArticleData("/sites/xxx", "/story/xxx_reports/daily_brief", 0, "fullHTML", cmsObject, fxres) + "</content>\n" +"	</article>\n" +"	<article>\n" +"		<id>" + avantGoGetArticleData("/sites/xxx", "/story/currency/eur_fundamentals", 0, "fileId", cmsObject, fxres) + "</id>\n" +"		<pageid>4</pageid>\n" +"		<title>" + avantGoGetArticleData("/sites/xxx", "/story/currency/eur_fundamentals", 0, "title", cmsObject, fxres) + "</title>\n" +"		<date>" + avantGoGetArticleData("/sites/xxx", "/story/currency/eur_fundamentals", 0, "time", cmsObject, fxres) + "</date>\n" +"		<author>" + avantGoGetArticleData("/sites/xxx", "/story/currency/eur_fundamentals", 0, "author", cmsObject, fxres) + "</author>\n" +"		<content>" + avantGoGetArticleData("/sites/xxx", "/story/currency/eur_fundamentals", 0, "fullHTML", cmsObject, fxres) + "</content>\n" +"	</article>\n" +"	<article>\n" +"		<id>" + avantGoGetArticleData("/sites/xxx", "/story/currency/eur_fundamentals", 1, "fileId", cmsObject, fxres) + "</id>\n" +"		<pageid>4</pageid>\n" +"		<title>" + avantGoGetArticleData("/sites/xxx", "/story/currency/eur_fundamentals", 1, "title", cmsObject, fxres) + "</title>\n" +"		<date>" + avantGoGetArticleData("/sites/xxx", "/story/currency/eur_fundamentals", 1, "time", cmsObject, fxres) + "</date>\n" +"		<author>" + avantGoGetArticleData("/sites/xxx", "/story/currency/eur_fundamentals", 1, "author", cmsObject, fxres) + "</author>\n" +"		<content>" + avantGoGetArticleData("/sites/xxx", "/story/currency/eur_fundamentals", 1, "fullHTML", cmsObject, fxres) + "</content>\n" +"	</article>\n" +"	<article>\n" +"		<id>" + avantGoGetArticleData("/sites/xxx", "/story/currency/jpy_fundamentals", 0, "fileId", cmsObject, fxres) + "</id>\n" +"		<pageid>5</pageid>\n" +"		<title>" + avantGoGetArticleData("/sites/xxx", "/story/currency/jpy_fundamentals", 0, "title", cmsObject, fxres) + "</title>\n" +"		<date>" + avantGoGetArticleData("/sites/xxx", "/story/currency/jpy_fundamentals", 0, "time", cmsObject, fxres) + "</date>\n" +"		<author>" + avantGoGetArticleData("/sites/xxx", "/story/currency/jpy_fundamentals", 0, "author", cmsObject, fxres) + "</author>\n" +"		<content>" + avantGoGetArticleData("/sites/xxx", "/story/currency/jpy_fundamentals", 0, "fullHTML", cmsObject, fxres) + "</content>\n" +"	</article>\n" +"	<article>\n" +"		<id>" + avantGoGetArticleData("/sites/xxx", "/story/currency/jpy_fundamentals", 1, "fileId", cmsObject, fxres) + "</id>\n" +"		<pageid>5</pageid>\n" +"		<title>" + avantGoGetArticleData("/sites/xxx", "/story/currency/jpy_fundamentals", 1, "title", cmsObject, fxres) + "</title>\n" +"		<date>" + avantGoGetArticleData("/sites/xxx", "/story/currency/jpy_fundamentals", 1, "time", cmsObject, fxres) + "</date>\n" +"		<author>" + avantGoGetArticleData("/sites/xxx", "/story/currency/jpy_fundamentals", 1, "author", cmsObject, fxres) + "</author>\n" +"		<content>" + avantGoGetArticleData("/sites/xxx", "/story/currency/jpy_fundamentals", 1, "fullHTML", cmsObject, fxres) + "</content>\n" +"	</article>\n" +"	<article>\n" +"		<id>" + avantGoGetArticleData("/sites/xxx", "/story/currency/gbp_fundamentals", 0, "fileId", cmsObject, fxres) + "</id>\n" +"		<pageid>6</pageid>\n" +"		<title>" + avantGoGetArticleData("/sites/xxx", "/story/currency/gbp_fundamentals", 0, "title", cmsObject, fxres) + "</title>\n" +"		<date>" + avantGoGetArticleData("/sites/xxx", "/story/currency/gbp_fundamentals", 0, "time", cmsObject, fxres) + "</date>\n" +"		<author>" + avantGoGetArticleData("/sites/xxx", "/story/currency/gbp_fundamentals", 0, "author", cmsObject, fxres) + "</author>\n" +"		<content>" + avantGoGetArticleData("/sites/xxx", "/story/currency/gbp_fundamentals", 0, "fullHTML", cmsObject, fxres) + "</content>\n" +"	</article>\n" +"	<article>\n" +"		<id>" + avantGoGetArticleData("/sites/xxx", "/story/currency/gbp_fundamentals", 1, "fileId", cmsObject, fxres) + "</id>\n" +"		<pageid>6</pageid>\n" +"		<title>" + avantGoGetArticleData("/sites/xxx", "/story/currency/gbp_fundamentals", 1, "title", cmsObject, fxres) + "</title>\n" +"		<date>" + avantGoGetArticleData("/sites/xxx", "/story/currency/gbp_fundamentals", 1, "time", cmsObject, fxres) + "</date>\n" +"		<author>" + avantGoGetArticleData("/sites/xxx", "/story/currency/gbp_fundamentals", 1, "author", cmsObject, fxres) + "</author>\n" +"		<content>" + avantGoGetArticleData("/sites/xxx", "/story/currency/gbp_fundamentals", 1, "fullHTML", cmsObject, fxres) + "</content>\n" +"	</article>\n" +"	<article>\n" +"		<id>" + avantGoGetArticleData("/sites/xxx", "/story/currency/aud_fundamentals", 0, "fileId", cmsObject, fxres) + "</id>\n" +"		<pageid>7</pageid>\n" +"		<title>" + avantGoGetArticleData("/sites/xxx", "/story/currency/aud_fundamentals", 0, "title", cmsObject, fxres) + "</title>\n" +"		<date>" + avantGoGetArticleData("/sites/xxx", "/story/currency/aud_fundamentals", 0, "time", cmsObject, fxres) + "</date>\n" +"		<author>" + avantGoGetArticleData("/sites/xxx", "/story/currency/aud_fundamentals", 0, "author", cmsObject, fxres) + "</author>\n" +"		<content>" + avantGoGetArticleData("/sites/xxx", "/story/currency/aud_fundamentals", 0, "fullHTML", cmsObject, fxres) + "</content>\n" +"	</article>\n" +"	<article>\n" +"		<id>" + avantGoGetArticleData("/sites/xxx", "/story/currency/aud_fundamentals", 1, "fileId", cmsObject, fxres) + "</id>\n" +"		<pageid>7</pageid>\n" +"		<title>" + avantGoGetArticleData("/sites/xxx", "/story/currency/aud_fundamentals", 1, "title", cmsObject, fxres) + "</title>\n" +"		<date>" + avantGoGetArticleData("/sites/xxx", "/story/currency/aud_fundamentals", 1, "time", cmsObject, fxres) + "</date>\n" +"		<author>" + avantGoGetArticleData("/sites/xxx", "/story/currency/aud_fundamentals", 1, "author", cmsObject, fxres) + "</author>\n" +"		<content>" + avantGoGetArticleData("/sites/xxx", "/story/currency/aud_fundamentals", 1, "fullHTML", cmsObject, fxres) + "</content>\n" +"	</article>\n" +"	<article>\n" +"		<id>" + avantGoGetArticleData("/sites/xxx", "/story/currency/cad_fundamentals", 0, "fileId", cmsObject, fxres) + "</id>\n" +"		<pageid>8</pageid>\n" +"		<title>" + avantGoGetArticleData("/sites/xxx", "/story/currency/cad_fundamentals", 0, "title", cmsObject, fxres) + "</title>\n" +"		<date>" + avantGoGetArticleData("/sites/xxx", "/story/currency/cad_fundamentals", 0, "time", cmsObject, fxres) + "</date>\n" +"		<author>" + avantGoGetArticleData("/sites/xxx", "/story/currency/cad_fundamentals", 0, "author", cmsObject, fxres) + "</author>\n" +"		<content>" + avantGoGetArticleData("/sites/xxx", "/story/currency/cad_fundamentals", 0, "fullHTML", cmsObject, fxres) + "</content>\n" +"	</article>\n" +"	<article>\n" +"		<id>" + avantGoGetArticleData("/sites/xxx", "/story/currency/cad_fundamentals", 1, "fileId", cmsObject, fxres) + "</id>\n" +"		<pageid>8</pageid>\n" +"		<title>" + avantGoGetArticleData("/sites/xxx", "/story/currency/cad_fundamentals", 1, "title", cmsObject, fxres) + "</title>\n" +"		<date>" + avantGoGetArticleData("/sites/xxx", "/story/currency/cad_fundamentals", 1, "time", cmsObject, fxres) + "</date>\n" +"		<author>" + avantGoGetArticleData("/sites/xxx", "/story/currency/cad_fundamentals", 1, "author", cmsObject, fxres) + "</author>\n" +"		<content>" + avantGoGetArticleData("/sites/xxx", "/story/currency/cad_fundamentals", 1, "fullHTML", cmsObject, fxres) + "</content>\n" +"	</article>\n" +"	<article>\n" +"		<id>" + avantGoGetArticleData("/sites/xxx", "/story/currency/nzd_fundamentals", 0, "fileId", cmsObject, fxres) + "</id>\n" +"		<pageid>9</pageid>\n" +"		<title>" + avantGoGetArticleData("/sites/xxx", "/story/currency/nzd_fundamentals", 0, "title", cmsObject, fxres) + "</title>\n" +"		<date>" + avantGoGetArticleData("/sites/xxx", "/story/currency/nzd_fundamentals", 0, "time", cmsObject, fxres) + "</date>\n" +"		<author>" + avantGoGetArticleData("/sites/xxx", "/story/currency/nzd_fundamentals", 0, "author", cmsObject, fxres) + "</author>\n" +"		<content>" + avantGoGetArticleData("/sites/xxx", "/story/currency/nzd_fundamentals", 0, "fullHTML", cmsObject, fxres) + "</content>\n" +"	</article>\n" +"	<article>\n" +"		<id>" + avantGoGetArticleData("/sites/xxx", "/story/currency/nzd_fundamentals", 1, "fileId", cmsObject, fxres) + "</id>\n" +"		<pageid>9</pageid>\n" +"		<title>" + avantGoGetArticleData("/sites/xxx", "/story/currency/nzd_fundamentals", 1, "title", cmsObject, fxres) + "</title>\n" +"		<date>" + avantGoGetArticleData("/sites/xxx", "/story/currency/nzd_fundamentals", 1, "time", cmsObject, fxres) + "</date>\n" +"		<author>" + avantGoGetArticleData("/sites/xxx", "/story/currency/nzd_fundamentals", 1, "author", cmsObject, fxres) + "</author>\n" +"		<content>" + avantGoGetArticleData("/sites/xxx", "/story/currency/nzd_fundamentals", 1, "fullHTML", cmsObject, fxres) + "</content>\n" +"	</article>\n" +"	<article>\n" +"		<id>" + avantGoGetArticleData("/sites/xxx", "/story/currency/chf_fundamentals", 0, "fileId", cmsObject, fxres) + "</id>\n" +"		<pageid>10</pageid>\n" +"		<title>" + avantGoGetArticleData("/sites/xxx", "/story/currency/chf_fundamentals", 0, "title", cmsObject, fxres) + "</title>\n" +"		<date>" + avantGoGetArticleData("/sites/xxx", "/story/currency/chf_fundamentals", 0, "time", cmsObject, fxres) + "</date>\n" +"		<author>" + avantGoGetArticleData("/sites/xxx", "/story/currency/chf_fundamentals", 0, "author", cmsObject, fxres) + "</author>\n" +"		<content>" + avantGoGetArticleData("/sites/xxx", "/story/currency/chf_fundamentals", 0, "fullHTML", cmsObject, fxres) + "</content>\n" +"	</article>\n" +"	<article>\n" +"		<id>" + avantGoGetArticleData("/sites/xxx", "/story/currency/chf_fundamentals", 1, "fileId", cmsObject, fxres) + "</id>\n" +"		<pageid>10</pageid>\n" +"		<title>" + avantGoGetArticleData("/sites/xxx", "/story/currency/chf_fundamentals", 1, "title", cmsObject, fxres) + "</title>\n" +"		<date>" + avantGoGetArticleData("/sites/xxx", "/story/currency/chf_fundamentals", 1, "time", cmsObject, fxres) + "</date>\n" +"		<author>" + avantGoGetArticleData("/sites/xxx", "/story/currency/chf_fundamentals", 1, "author", cmsObject, fxres) + "</author>\n" +"		<content>" + avantGoGetArticleData("/sites/xxx", "/story/currency/chf_fundamentals", 1, "fullHTML", cmsObject, fxres) + "</content>\n" +"	</article>\n" +"</site>\n";                        //http://www.xxx.com/avantgo_xml.php            //writeStringAsFileToVFS(cmsObject, sAvantGoDocument, sfSiteRoot + "/" + "avantgo_xml.php");                        sAvantGoDocument = sAvantGoDocument.replaceAll("&gt.", "&gt;.");            sAvantGoDocument = sAvantGoDocument.replaceAll("<?xml:namespace prefix = st1 ns = \"urn:schemas-microsoft-com:office:smarttags\" />", "");            sAvantGoDocument = sAvantGoDocument.replaceAll(":", "&#58;");            sAvantGoDocument = sAvantGoDocument.replaceAll("null", "");            sAvantGoDocument = sAvantGoDocument.replaceAll(". .", "");            writeStringAsFileToVFS(cmsObject, sAvantGoDocument, sfSiteRoot + "/" + "feeds/avantgo_xml.xml");                                } catch (Exception e) {            System.out.println("Exception occured in FXRssResource");            e.printStackTrace();            System.out.println(e.getMessage());        }    }   public void testingGetFiles() {       try {            List resultListForAvantGo;            resultListForAvantGo = (List) fxres.getFiles("", "/story/currency/chf_fundamentals", 2 );            System.out.println("avantGoGetArticleData - AFTER resultListForAvantGo.size() = " + resultListForAvantGo.size()  );        } catch (Exception e) {            e.printStackTrace();            //return "Error occured in importCalendar: " + e.getMessage();        }              }           public String avantGoGetArticleData(String sNameOfSite, String sPathOfDirectoryFiles, int iPositionOfArticleInReference, String sWhatIsRequested, CmsObject cmsObj, FXResource fxres) {        String sResult = "--[inital declaration of sResult - SOMETHING SOMEWHERE NEEDS CORRECTION]--";        //AvantGo        //objects declarations for AvantGo        List resultListForAvantGo;// = fxres.getLatestFiles("/sites/xxx", 5);        FXListItem itemForAvantGo; // = (FXListItem) resultList.get(1);        String fileResourceForAvantGo = "";        Locale localeForAvantGo;        CmsFile fileForAvantGo;        int iUniqueIDofFileAvantGo;        try {            if (sPathOfDirectoryFiles.equals("")){                resultListForAvantGo = fxres.getLatestFiles(sNameOfSite, (iPositionOfArticleInReference+1) );            }            else if (sPathOfDirectoryFiles.equals("calendar")){                resultListForAvantGo = fxres.getLatestFiles("/sites/xxx", 1 );            }            else {                    resultListForAvantGo = (List) fxres.getFiles(sNameOfSite, sPathOfDirectoryFiles, (iPositionOfArticleInReference+1) );                    if ( resultListForAvantGo == null ){                        resultListForAvantGo = (List) fxres.getFiles(sNameOfSite, sPathOfDirectoryFiles, (iPositionOfArticleInReference) );                    }            }            //itemForAvantGo = (FXListItem) resultListForAvantGo.get(0);            itemForAvantGo = (FXListItem) resultListForAvantGo.get(iPositionOfArticleInReference);            if (sPathOfDirectoryFiles.equals("calendar")){                fileResourceForAvantGo = "/calendar/briefing/calendar_data_ready_for_avant_go.html";            }             else if ( !(sPathOfDirectoryFiles.equals("calendar")) ) {                fileResourceForAvantGo = itemForAvantGo.getFile(); //"/story/charting_center/weekly_chart_analysis/5085_eur_gbp_large_triangle_setup.html";            }                //itemForAvantGo = (FXListItem) resultListForAvantGo.get(iPositionOfArticleInReference);                //fileResourceForAvantGo = itemForAvantGo.getFile(); //"/story/charting_center/weekly_chart_analysis/5085_eur_gbp_large_triangle_setup.html";        //out.println("fileResourceForAvantGo (from /sites/xxx/story/currency/eur_fundamentals) = " + fileResourceForAvantGo + "<HR>");        fileForAvantGo = cmsObj.readFile(sfSiteRoot+fileResourceForAvantGo);        iUniqueIDofFileAvantGo = java.lang.Math.abs( fileForAvantGo.getResourceId().hashCode() );        String sArticleXMLElementText1HTMLForAvantGo = "";        String sArticleXMLElementText2HTMLForAvantGo = "";                try {            // get default locale from the new article            localeForAvantGo = (Locale)OpenCms.getLocaleManager().getDefaultLocales(cmsObj, fileForAvantGo.getRootPath()).get(0);            // load article text (anything in <Content>, should just be text1 & text2)            CmsXmlContent fileContent = CmsXmlContentFactory.unmarshal(cmsObj, fileForAvantGo, false);            List fileList = fileContent.getValues("element", localeForAvantGo);            if (fileList.size() > 0) {                Iterator iter = fileList.iterator();                 while (iter.hasNext()) {                    sArticleXMLElementText1HTMLForAvantGo = ((CmsXmlHtmlValue)iter.next()).getPlainText(cmsObj);                     if ( !(sPathOfDirectoryFiles.equals("calendar")) ) {                        sArticleXMLElementText2HTMLForAvantGo = ((CmsXmlHtmlValue)iter.next()).getPlainText(cmsObj);                    }                }            }        } catch (CmsException e) {}        String sAllOfTextForAvantGo = sArticleXMLElementText1HTMLForAvantGo + "<br /><br />" + sArticleXMLElementText2HTMLForAvantGo;        sAllOfTextForAvantGo = sAllOfTextForAvantGo.replaceAll("&", "&amp;");        sAllOfTextForAvantGo = sAllOfTextForAvantGo.replaceAll("<img (.*)>", "&lt;br /&gt;");        sAllOfTextForAvantGo = sAllOfTextForAvantGo.replaceAll("<IMG (.*)>", "&lt;br /&gt;");        sAllOfTextForAvantGo = sAllOfTextForAvantGo.replaceAll("href=\"/opencms/opencms/", "href=\"http://www.xxx.com/export/sites/xxx/");        sAllOfTextForAvantGo = sAllOfTextForAvantGo.replaceAll("HREF=\"/opencms/opencms/", "HREF=\"http://www.xxx.com/export/sites/xxx/");        sAllOfTextForAvantGo = sAllOfTextForAvantGo.replaceAll("<?xml:namespace prefix = st1 ns = \"urn:schemas-microsoft-com:office:smarttags\" />", "");        sAllOfTextForAvantGo = sAllOfTextForAvantGo.replaceAll("\n", " ");        sAllOfTextForAvantGo = sAllOfTextForAvantGo.replaceAll("<", "&lt;");        sAllOfTextForAvantGo = sAllOfTextForAvantGo.replaceAll(">", "&gt;");                        /////////TRYING TO GET INTRO FOR TEXT        String sInitialTextForAvantGo = "";        String sDescriptionForRss = "";                //sInitialTextForAvantGo = sAllOfTextForAvantGo.substring(0, (sAllOfTextForAvantGo.indexOf("&gt;", 350)+3) ) + "..."; //will return the substring of first 0 - x charcters - where x is the first ">" (closing HTML tag) charcter after xth character                                    if(sAllOfTextForAvantGo != null && sAllOfTextForAvantGo.indexOf(" ", 150) != -1){                        sInitialTextForAvantGo = sAllOfTextForAvantGo.substring(0, sAllOfTextForAvantGo.indexOf(" ", 150) ) + "...";                    }                    else {                        sInitialTextForAvantGo = " - please see article - ";                    }                        try {                            if(sAllOfTextForAvantGo != null && sAllOfTextForAvantGo.indexOf(" ", 150) != -1){                                sInitialTextForAvantGo = sAllOfTextForAvantGo.substring(0, sAllOfTextForAvantGo.indexOf(" ", 150) ) + "...";                            }                            else if (sAllOfTextForAvantGo != null){                                sInitialTextForAvantGo = sAllOfTextForAvantGo;                            }                             else{ //now this is in case description/summary is left blank entirely by analysts... when posting the data - we make use of the body/article data                                if(sAllOfTextForAvantGo != null && sAllOfTextForAvantGo.indexOf(" ", 150) != -1){                                    sInitialTextForAvantGo = sAllOfTextForAvantGo.substring(0, sAllOfTextForAvantGo.indexOf(" ", 150) ) + "...";                                }                                else{                                    sInitialTextForAvantGo = "See the article..."; //todo, but this is in a very rare case that if summary is empty and body is under 150 characters...                                }                            }                        } catch ( StringIndexOutOfBoundsException e ){                            System.out.println("Exception occurred in Avantgo section");                            // comment and for debuging: System.outx.println("StringIndexOutOfBoundsException occured ");                        }////        //sInitialTextForAvantGo = sAllOfTextForAvantGo.substring(0, (sAllOfTextForAvantGo.indexOf("&gt;", 350)+3) ) + "..."; //will return the substring of first 0 - x charcters - where x is the first ">" (closing HTML tag) charcter after xth character        String sEntireHTMLTextForAvantGo = sAllOfTextForAvantGo;        if(sWhatIsRequested.equals("title")) {            return itemForAvantGo.getTitle();        }        else if (sWhatIsRequested.equals("time")) {            return itemForAvantGo.getDate();        }        else if (sWhatIsRequested.equals("author")) {            return itemForAvantGo.getAuthor();        }        else if (sWhatIsRequested.equals("fileId")) {            return String.valueOf(iUniqueIDofFileAvantGo); // (string) iUniqueIDofFileAvantGo;        }        else if (sWhatIsRequested.equals("introHTML")) {            return sInitialTextForAvantGo;        }        else if (sWhatIsRequested.equals("fullHTML")) {            return sEntireHTMLTextForAvantGo;        }        else if (sWhatIsRequested.equals("fullHTML")) {            return sEntireHTMLTextForAvantGo;        }        else if (sPathOfDirectoryFiles.equals("calendar")) { //else if (sWhatIsRequested.equals("firstElementOnly")) {            return sAllOfTextForAvantGo; //this will be only the first element of the item        }        else {            return " - please see the article - ";        }                } catch (Exception e) {                                //if ( resultListForAvantGo == null ){                        System.out.println("resultListForAvantGo == null");                    //}            e.printStackTrace();            //return "Error occured in importCalendar: " + e.getMessage();        }           return sResult;}       public boolean existsResource(CmsObject cms, String res) {        try {            cms.readFile(res);        } catch (Exception e) {            return false;        }        return true;    }    //delete delete delete    public String readFileContent(String filename, CmsObject m_cms) {        try {            //Comment/optional debug info: System.out.println(m_cms.readFile(filename));            //Comment/optional debug info: System.out.println(new String(m_cms.readFile(filename).getContents()));            return new String(m_cms.readFile(filename).getContents());        } catch(Exception exc) {            System.out.println("exception occured in readFileContent for file: " + filename );            return "problem occured during read, filename " + filename;        }        //return "problem occured during read, filename " + filename;    }    public String writeStringAsFileToVFS(CmsObject cmsObject, String sDataRssDataPageToWrite, String sNameOfPathAndFileToWriteToOnVFS) {        String sResult = "";        try {             if (existsResource(cmsObject,sNameOfPathAndFileToWriteToOnVFS)) {                //Comment/optional debug info: System.out.println("resource [" + rss_path_+xml_name+ "] exists.");                cmsObject.lockResource(sNameOfPathAndFileToWriteToOnVFS);                //cms_.replaceResource(rss_path_+xml_name,"plain",null,xml_content.getBytes());                cmsObject.replaceResource(sNameOfPathAndFileToWriteToOnVFS, 1, sDataRssDataPageToWrite.getBytes(), null);                cmsObject.unlockResource(sNameOfPathAndFileToWriteToOnVFS);                cmsObject.publishResource(sNameOfPathAndFileToWriteToOnVFS, true, new CmsShellReport( cmsObject.getRequestContext().getLocale()) );                //Comment/optional debug info: System.out.println("RSS file updated: "+rss_path_+xml_name);                return "Calendar generation is done, RSS file updated";            } else {                //Comment/optional debug info: System.out.println("resource [" + rss_path_+xml_name+ "] does NOT exist.");                //cms_.createResource(rss_path_,xml_name,"plain",null,xml_content.getBytes());                cmsObject.createResource(sNameOfPathAndFileToWriteToOnVFS, 1, sDataRssDataPageToWrite.getBytes(), null);                cmsObject.lockResource(sNameOfPathAndFileToWriteToOnVFS);                cmsObject.unlockResource(sNameOfPathAndFileToWriteToOnVFS);                cmsObject.publishResource(sNameOfPathAndFileToWriteToOnVFS, true, new CmsShellReport( cmsObject.getRequestContext().getLocale()) );                //Comment/optional debug info: System.out.println("RSS file created: "+rss_path_+xml_name);                return "Calendar generation is done, RSS file created";            }        } catch(Exception exc) {            exc.printStackTrace();            System.out.println("exception occured in writeStringAsFileToVFS for file: " + sNameOfPathAndFileToWriteToOnVFS + " with data " + sDataRssDataPageToWrite );            return "exception occured in writeStringAsFileToVFS for file: " + sNameOfPathAndFileToWriteToOnVFS + " with data " + sDataRssDataPageToWrite;        }    }}/**  * Class FXCalendarResourceRSSThread begins a thread to pull data from DB every x minutes * @version 1.0 */class FXRssResourceThread extends Thread {    public void run() {        try {            FXRssResource fxresRss1 = new FXRssResource("Admin", "xxxx");            fxresRss1.generateRssAll();        } catch (Exception e) {            System.out.println("Run terminated by exception");            e.printStackTrace();        }    }}