Search in sources :

Example 1 with TFileOutputStream

use of de.schlichtherle.truezip.file.TFileOutputStream in project alfresco-repository by Alfresco.

the class InstalledFiles method save.

/**
 * Saves the current modification details into the WAR
 */
public void save() {
    try {
        TFile file = new TFile(getFileLocation());
        if (file.exists() == false) {
            file.createNewFile();
        }
        TFileOutputStream os = new TFileOutputStream(file);
        try {
            for (String add : this.adds) {
                String output = MOD_ADD_FILE + DELIMITER + add + "\n";
                os.write(output.getBytes());
            }
            for (Map.Entry<String, String> update : this.updates.entrySet()) {
                String output = MOD_UPDATE_FILE + DELIMITER + update.getKey() + DELIMITER + update.getValue() + "\n";
                os.write(output.getBytes());
            }
            for (String mkdir : this.mkdirs) {
                String output = MOD_MK_DIR + DELIMITER + mkdir + "\n";
                os.write(output.getBytes());
            }
        } finally {
            os.close();
        }
    } catch (IOException exception) {
        throw new ModuleManagementToolException("Error whilst saving modifications file.", exception);
    }
}
Also used : TFile(de.schlichtherle.truezip.file.TFile) TFileOutputStream(de.schlichtherle.truezip.file.TFileOutputStream) IOException(java.io.IOException) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with TFileOutputStream

use of de.schlichtherle.truezip.file.TFileOutputStream in project alfresco-repository by Alfresco.

the class ModuleDetailsHelper method saveModuleDetails.

/**
 * Saves the module details to the war in the correct location based on the module id
 *
 * @param warLocation   the war location
 * @param moduleDetails      the module id
 */
public static void saveModuleDetails(String warLocation, ModuleDetails moduleDetails) {
    // Ensure that it is a valid set of properties
    String moduleId = moduleDetails.getId();
    try {
        String modulePropertiesFileLocation = getModulePropertiesFileLocation(warLocation, moduleId);
        TFile file = new TFile(modulePropertiesFileLocation);
        if (file.exists() == false) {
            file.createNewFile();
        }
        // Get all the module properties
        Properties moduleProperties = moduleDetails.getProperties();
        OutputStream os = new TFileOutputStream(file);
        try {
            moduleProperties.store(os, null);
        } finally {
            os.close();
        }
    } catch (IOException exception) {
        throw new ModuleManagementToolException("Unable to save module details into WAR file: \n" + "   Module: " + moduleDetails.getId() + "\n" + "   Properties: " + moduleDetails.getProperties(), exception);
    }
}
Also used : TFile(de.schlichtherle.truezip.file.TFile) OutputStream(java.io.OutputStream) TFileOutputStream(de.schlichtherle.truezip.file.TFileOutputStream) TFileOutputStream(de.schlichtherle.truezip.file.TFileOutputStream) IOException(java.io.IOException) Properties(java.util.Properties)

Aggregations

TFile (de.schlichtherle.truezip.file.TFile)2 TFileOutputStream (de.schlichtherle.truezip.file.TFileOutputStream)2 IOException (java.io.IOException)2 OutputStream (java.io.OutputStream)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Properties (java.util.Properties)1