Search in sources :

Example 1 with BusinessFunctionException

use of org.jaffa.applications.jaffa.modules.admin.components.businessfunction.ui.exceptions.BusinessFunctionException in project jaffa-framework by jaffa-projects.

the class BusinessFunctionComponent method retrieveFileContents.

/**
 * This retrieves the the file contents of the business-function xml file.
 * @throws FrameworkException, ApplicationExceptions if any error occurs.
 */
protected void retrieveFileContents() throws FrameworkException, ApplicationExceptions {
    ApplicationExceptions appExps = new ApplicationExceptions();
    URL url = null;
    BufferedReader reader = null;
    try {
        url = URLHelper.newExtendedURL(DEFAULT_LOCATION_FOR_XML_FILE);
        String absoluteFileName = url.getPath();
        // clear the widget cache
        getUserSession().getWidgetCache(getComponentId()).clear();
        // read the contents of the file
        reader = new BufferedReader(new FileReader(absoluteFileName));
        StringBuffer buf = new StringBuffer();
        String str = null;
        while ((str = reader.readLine()) != null) {
            buf.append(str);
            buf.append("\r\n");
        }
        m_fileContents = buf.toString();
    } catch (MalformedURLException e) {
        appExps.add(new BusinessFunctionException(BusinessFunctionException.PROP_FILENOTFOUND_ERROR, StringHelper.convertToHTML(DEFAULT_LOCATION_FOR_XML_FILE)));
        throw appExps;
    } catch (IOException e) {
        appExps.add(new BusinessFunctionException(BusinessFunctionException.PROP_FILEREAD_ERROR, StringHelper.convertToHTML(e.getMessage())));
        throw appExps;
    } finally {
        if (reader != null)
            try {
                reader.close();
            } catch (IOException e) {
                String str = "Exception thrown while closing the Reader Stream";
                log.error(str, e);
                appExps.add(new BusinessFunctionException(BusinessFunctionException.PROP_FILEREAD_ERROR, StringHelper.convertToHTML(e.getMessage())));
                throw appExps;
            }
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) BusinessFunctionException(org.jaffa.applications.jaffa.modules.admin.components.businessfunction.ui.exceptions.BusinessFunctionException) URL(java.net.URL)

Aggregations

MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 BusinessFunctionException (org.jaffa.applications.jaffa.modules.admin.components.businessfunction.ui.exceptions.BusinessFunctionException)1 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)1