use of org.jaffa.applications.jaffa.modules.admin.components.viewerhyperlinkconfig.ui.exceptions.ViewerHyperlinkConfigException in project jaffa-framework by jaffa-projects.
the class ViewerHyperlinkConfigComponent method storeFile.
private void storeFile(String fileName, String contents) throws ApplicationExceptions {
Writer writer = null;
try {
writer = new BufferedWriter(new FileWriter(URLHelper.newExtendedURL(fileName).getPath(), false));
writer.write(contents);
writer.flush();
if (log.isDebugEnabled())
log.debug("Stored to the file: " + fileName + " and then flushing the cache in the TextTag");
// flush the properties cache in the TextTag
TextTag.reloadViewerHyperlinkConfig();
} catch (MalformedURLException e) {
ApplicationExceptions appExps = new ApplicationExceptions();
appExps.add(new ViewerHyperlinkConfigException(ViewerHyperlinkConfigException.PROP_FILE_STORE_ERROR, fileName));
throw appExps;
} catch (IOException e) {
ApplicationExceptions appExps = new ApplicationExceptions();
appExps.add(new ViewerHyperlinkConfigException(ViewerHyperlinkConfigException.PROP_FILE_STORE_ERROR, fileName));
throw appExps;
} finally {
try {
if (writer != null)
writer.close();
} catch (IOException e) {
// do nothing
}
}
}
use of org.jaffa.applications.jaffa.modules.admin.components.viewerhyperlinkconfig.ui.exceptions.ViewerHyperlinkConfigException in project jaffa-framework by jaffa-projects.
the class ViewerHyperlinkConfigComponent method display.
/**
* Brings up the first screen of the component.
* @throws ApplicationExceptions Indicates some functional error.
* @throws FrameworkException Indicates some system error.
* @return The FormKey.
*/
public FormKey display() throws ApplicationExceptions, FrameworkException {
// ensure that the properties are correctly set in the framework.properties file
m_domainFieldViewerComponentMappingFileName = (String) Config.getProperty(Config.PROP_DOMAIN_FIELD_VIEWER_COMPONENT_MAPPING_FILE, null);
m_keyFieldPerViewerComponentFileName = (String) Config.getProperty(Config.PROP_KEY_FIELD_PER_VIEWER_COMPONENT_FILE, null);
if (m_domainFieldViewerComponentMappingFileName == null || m_keyFieldPerViewerComponentFileName == null) {
ApplicationExceptions appExps = new ApplicationExceptions();
appExps.add(new ViewerHyperlinkConfigException(ViewerHyperlinkConfigException.PROP_INVALID_SETUP));
throw appExps;
}
// load the 2 files
loadDomainFieldViewerComponentMappingFile();
loadKeyFieldPerViewerComponentFile();
if (m_screens == null) {
m_screens = new ArrayList();
addScreens(m_screens);
}
return determineFormKey();
}
use of org.jaffa.applications.jaffa.modules.admin.components.viewerhyperlinkconfig.ui.exceptions.ViewerHyperlinkConfigException in project jaffa-framework by jaffa-projects.
the class ViewerHyperlinkConfigComponent method loadFile.
private String loadFile(String fileName) throws ApplicationExceptions {
Reader reader = null;
try {
InputStream is = URLHelper.getInputStream(fileName);
if (is == null) {
ApplicationExceptions appExps = new ApplicationExceptions();
appExps.add(new ViewerHyperlinkConfigException(ViewerHyperlinkConfigException.PROP_FILE_READ_ERROR, fileName));
throw appExps;
}
reader = new BufferedReader(new InputStreamReader(is));
StringBuffer buf = new StringBuffer();
int i;
while ((i = reader.read()) != -1) buf.append((char) i);
if (log.isDebugEnabled())
log.debug("Loaded the properties from file: " + fileName);
return buf.toString();
} catch (IOException e) {
ApplicationExceptions appExps = new ApplicationExceptions();
appExps.add(new ViewerHyperlinkConfigException(ViewerHyperlinkConfigException.PROP_FILE_READ_ERROR, fileName));
throw appExps;
} finally {
try {
if (reader != null)
reader.close();
} catch (IOException e) {
// do nothing
}
}
}
Aggregations