Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.googlecode.mad.mvntools.settingsutil.filestore;
 
 import java.io.File;
- Apache License 2.0 -
Mojo to back up the Files in a x.xml-file

LastChangedBy: $Author: marthaler.worb@gmail.com $
LastChangedDate: $Date: 2010-12-29 14:23:06 +0100 (Mi, 29 Dez 2010) $

Author(s):
daniel marthaler
Version:
$Revision: 22 $
Since:
24.12.2010
Goal:
backup
public class BackupFilestore extends AbstractFilestore {
    
    public BackupFilestore() {
        super();
        this. = "SettingsUtil:backup";
    }
    
    @Override
    @SuppressWarnings("unchecked")
    protected void myExecute() {
        
        TreeMap<StringTreeMap<StringString>> myMap = new TreeMap<StringTreeMap<StringString>>();
        
        String temp = null;
        
        temp = this..loadFile(this.getRootPath() + this.);
        
        if ((temp != null) && (temp.length() > 0)) {
            try {
                myMap = (TreeMap<StringTreeMap<StringString>>) this..fromXML(temp);
            } catch (final Exception e) {
                this.getLog().debug("unmarshaling not possible");
            }
        }
        
        TreeMap<StringStringfiles = myMap.get(this.);
        if (files == null) {
            files = new TreeMap<StringString>();
        }
        
        for (final String string : this.) {
            files.put(. + stringthis..loadFile(this.getRootPath() + string));
        }
        
        for (final String string : this.) {
            
            final File folder = new File(this.getRootPath() + string);
            if (folder.exists() && folder.isDirectory()) {
                final String[] ff = folder.list();
                for (final String theFile : ff) {
                    files.put(. + string + this. + theFilethis..loadFile(this.getRootPath() + string + this. + theFile));
                }
            }
            
        }
        
        myMap.put(this.files);
        
        this..replaceFileWithNewContent(this.getRootPath() + this.this..toXML(myMap));
        
    }
New to GrepCode? Check out our FAQ X