use of org.jaffa.exceptions.ApplicationExceptions in project jaffa-framework by jaffa-projects.
the class QueueViewerAction method do_RelatedQueueHeader_View_Clicked.
public FormKey do_RelatedQueueHeader_View_Clicked(String rowNum) {
FormKey fk = null;
QueueViewerForm myForm = (QueueViewerForm) form;
QueueViewerComponent myComp = (QueueViewerComponent) myForm.getComponent();
try {
GridModel model = (GridModel) myForm.getRelatedQueueHeaderWM();
GridModelRow selectedRow = model.getRow(Integer.parseInt(rowNum));
if (selectedRow != null)
fk = myComp.viewMessage((java.lang.String) selectedRow.get("messageId"));
} catch (ApplicationExceptions e) {
if (log.isDebugEnabled())
log.debug("RelatedQueueHeader_View Failed");
myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, e);
} catch (FrameworkException e) {
log.error(null, e);
myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, "error.framework.general");
}
// The Viewer will be rendered in a new window
// We don't want to see the existing HistoryNav in that window
// Hence, initialize the HistoryNav
HistoryNav.initializeHistoryNav(request);
// Direct User back to current form
if (fk == null)
fk = myComp.getViewerFormKey();
return fk;
}
use of org.jaffa.exceptions.ApplicationExceptions 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;
}
}
}
use of org.jaffa.exceptions.ApplicationExceptions in project jaffa-framework by jaffa-projects.
the class FileExplorerComponent method retrieveFiles.
/**
* This retrieves the files for the base directory
* @throws ApplicationExceptions if any error occurs while reading the files.
* @throws FrameworkException if any error occurs.
*/
protected FileExplorerBean retrieveFiles(File path) throws FrameworkException, ApplicationExceptions {
// Path relative to the document root folder
String relPath = null;
if (path == null) {
path = m_root;
relPath = "";
} else {
if (!path.getAbsolutePath().startsWith(m_root.getAbsolutePath()))
throw new ApplicationExceptions(new FileExplorerException(FileExplorerException.ILLEGAL_ACCESS, path.getAbsolutePath()));
else
relPath = path.getAbsolutePath().substring(m_root.getAbsolutePath().length() + 1);
}
if (log.isDebugEnabled())
log.debug("Get List of Folders/Files For " + relPath + "[" + path.getAbsolutePath() + "]");
FileExplorerBean bean = new FileExplorerBean();
// @todo - implement uploads
// bean.setUploadAllowed(canUpload(relPath,path));
// Add in sub-folders
File[] dirs = path.listFiles(new FolderFilter(m_root));
if (dirs != null)
for (int i = 0; i < dirs.length; i++) {
String name = relPath + "/" + dirs[i].getName();
if (log.isDebugEnabled())
log.debug(i + ") Found Folder " + name + " -> " + dirs[i].getAbsolutePath());
bean.addFolder(dirs[i], canDownload(name, dirs[i]), false, /* @todo canRename(name,dirs[i])*/
canDelete(name, dirs[i]));
}
// Add in files
File[] files = path.listFiles(new FileFilter(m_root));
if (files != null)
for (int i = 0; i < files.length; i++) {
String name = relPath + "/" + files[i].getName();
if (log.isDebugEnabled())
log.debug(i + ") Found File " + name + " -> " + files[i].getAbsolutePath());
bean.addFile(files[i], canDownload(name, files[i]), false, /* @todo canRename(name,files[i]) */
canDelete(name, files[i]));
}
return bean;
}
use of org.jaffa.exceptions.ApplicationExceptions in project jaffa-framework by jaffa-projects.
the class Log4jConfigAction method do_Save_Clicked.
/**
* Event Handler for the 'Save' clicked event.
* This will copy the values from the Form to the Component and then invoke the performSave() method on the component.
* Finally it'll get the latest file contents of the log4j xml file.
* @return the FormKey for this screen.
*/
public FormKey do_Save_Clicked() {
FormKey fk = null;
Log4jConfigForm myForm = (Log4jConfigForm) form;
Log4jConfigComponent myComp = (Log4jConfigComponent) component;
try {
// Copy the values from Form to Component
myForm.doValidate();
// save the file contents
myComp.performSave();
// Get the latest values
fk = do_Refresh_Clicked();
} catch (ApplicationExceptions e) {
myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, e);
} catch (FrameworkException e) {
log.error(null, e);
myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, "error.framework.general");
}
if (fk == null)
fk = myComp.getLog4jConfigFormKey();
return fk;
}
use of org.jaffa.exceptions.ApplicationExceptions in project jaffa-framework by jaffa-projects.
the class MenuNavigationComponent method performSave.
/**
* This will perform the following tasks.
* - Saves the contents to navigation.xml.
* - Clears the cache and refreshes the menu.
* @param request The request we are processing.
* @throws FrameworkException , ApplicationExceptions if any error occurs.
*/
protected void performSave(HttpServletRequest request) throws FrameworkException, ApplicationExceptions {
ApplicationExceptions appExps = new ApplicationExceptions();
String prop = NavCache.getFileLocation();
BufferedWriter writer = null;
try {
// Create a URL for the resource file...
String absoluteFileName = URLHelper.newExtendedURL(prop).getPath();
// update the contents of the file
writer = new BufferedWriter(new FileWriter(absoluteFileName));
writer.write(getFileContents());
writer.flush();
clearCacheAndRefreshMenu(request);
} catch (MalformedURLException e) {
appExps.add(new MenuNavigationException(MenuNavigationException.PROP_BADURL_ERROR, prop, StringHelper.convertToHTML(e.getMessage())));
throw appExps;
} catch (IOException e) {
appExps.add(new MenuNavigationException(MenuNavigationException.PROP_FILEREAD_ERROR, StringHelper.convertToHTML(e.getMessage())));
throw appExps;
} finally {
if (writer != null)
try {
writer.close();
} catch (IOException e) {
String str = "Exception thrown while closing the Writer Stream";
log.error(str, e);
appExps.add(new MenuNavigationException(MenuNavigationException.PROP_FILEREAD_ERROR, StringHelper.convertToHTML(e.getMessage())));
throw appExps;
}
}
}
Aggregations