use of com.ibm.uma.UMAException in project openj9 by eclipse.
the class UMA method get.
public TemplateModel get(String arg0) throws TemplateModelException {
if (arg0.equals("spec")) {
return new Spec();
}
if (arg0.equals("year")) {
GregorianCalendar calendar = new GregorianCalendar();
return new SimpleScalar(Integer.toString(calendar.get(Calendar.YEAR)));
}
try {
TemplateModel platformExtension = com.ibm.uma.UMA.getUma().getPlatform().getDataModelExtension(com.ibm.uma.UMA.FREEMARKER_UMA, arg0);
if (platformExtension != null)
return platformExtension;
TemplateModel configurationExtension = com.ibm.uma.UMA.getUma().getConfiguration().getDataModelExtension(com.ibm.uma.UMA.FREEMARKER_UMA, arg0);
if (configurationExtension != null)
return configurationExtension;
} catch (UMAException e) {
throw new TemplateModelException(e);
}
return null;
}
use of com.ibm.uma.UMAException in project openj9 by eclipse.
the class FileAssistant method differentFromCopyOnDisk.
private boolean differentFromCopyOnDisk() throws UMAException {
File file = new File(filename);
if (!file.exists())
return true;
StringBuffer fileBuffer;
try {
FileReader fr = new FileReader(file);
char[] charArray = new char[1024];
fileBuffer = new StringBuffer();
int numRead;
while ((numRead = fr.read(charArray)) != -1) {
fileBuffer.append(charArray, 0, numRead);
}
if (buffer.toString().equals(fileBuffer.toString())) {
fr.close();
return false;
}
fr.close();
} catch (FileNotFoundException e) {
throw new UMAException(e);
} catch (IOException e) {
throw new UMAException(e);
}
return true;
}
use of com.ibm.uma.UMAException in project openj9 by eclipse.
the class FileAssistant method writeToDisk.
public void writeToDisk() throws UMAException {
if (!differentFromCopyOnDisk()) {
Logger.getLogger().println(Logger.InformationL2Log, "\tskipped writing [same as on file system]: " + filename);
return;
}
try {
File file = new File(filename);
file.delete();
FileWriter fw = new FileWriter(filename);
fw.write(buffer.toString());
fw.close();
} catch (IOException e) {
throw new UMAException(e);
}
Logger.getLogger().println(Logger.InformationL1Log, "\twrote: " + filename);
}
Aggregations