Search in sources :

Example 11 with UMAException

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;
}
Also used : TemplateModelException(freemarker.template.TemplateModelException) GregorianCalendar(java.util.GregorianCalendar) TemplateModel(freemarker.template.TemplateModel) UMAException(com.ibm.uma.UMAException) SimpleScalar(freemarker.template.SimpleScalar)

Example 12 with UMAException

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;
}
Also used : FileNotFoundException(java.io.FileNotFoundException) FileReader(java.io.FileReader) UMAException(com.ibm.uma.UMAException) IOException(java.io.IOException) File(java.io.File)

Example 13 with UMAException

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);
}
Also used : FileWriter(java.io.FileWriter) IOException(java.io.IOException) UMAException(com.ibm.uma.UMAException) File(java.io.File)

Aggregations

UMAException (com.ibm.uma.UMAException)13 IOException (java.io.IOException)6 File (java.io.File)5 TemplateModel (freemarker.template.TemplateModel)4 TemplateModelException (freemarker.template.TemplateModelException)4 SimpleScalar (freemarker.template.SimpleScalar)3 FileNotFoundException (java.io.FileNotFoundException)2 Vector (java.util.Vector)2 ConfigurationImpl (com.ibm.j9.uma.configuration.ConfigurationImpl)1 Flag (com.ibm.j9tools.om.Flag)1 UMA (com.ibm.uma.UMA)1 UMABadPhaseNameException (com.ibm.uma.UMABadPhaseNameException)1 Artifact (com.ibm.uma.om.Artifact)1 Command (com.ibm.uma.om.Command)1 Dependency (com.ibm.uma.om.Dependency)1 Export (com.ibm.uma.om.Export)1 Flag (com.ibm.uma.om.Flag)1 Include (com.ibm.uma.om.Include)1 Library (com.ibm.uma.om.Library)1 MakefileStub (com.ibm.uma.om.MakefileStub)1