// Path: eu.hydrologis.stage.libs/src/eu/hydrologis/stage/libs/log/StageLogger.java
// public class StageLogger {
// 
//     public static final boolean LOG_INFO = true;
//     public static final boolean LOG_DEBUG = false;
//     public static final boolean LOG_ERROR = true;
// 
//     private static final String SEP = ":: ";
// 
//     private static SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// 
//     public static void logInfo( Object owner, String msg ) {
//         if (LOG_INFO) {
//             msg = toMessage(owner, msg);
//             System.out.println(msg);
//         }
//     }
// 
//     public static void logDebug( Object owner, String msg ) {
//         if (LOG_DEBUG) {
//             msg = toMessage(owner, msg);
//             System.out.println(msg);
//         }
//     }
// 
//     public static void logError( Object owner, String msg, Throwable e ) {
//         if (LOG_ERROR) {
//             msg = toMessage(owner, msg);
//             System.err.println(msg);
//             e.printStackTrace();
//         }
//     }
// 
//     public static void logError( Object owner, Throwable e ) {
//         logError(owner, null, e);
//     }
// 
//     private static String toMessage( Object owner, String msg ) {
//         if (msg == null)
//             msg = "";
//         String newMsg = f.format(new Date()) + SEP;
//         if (owner instanceof String) {
//             newMsg = newMsg + owner + SEP;
//         } else {
//             newMsg = newMsg + owner.getClass().getSimpleName() + SEP;
//         }
//         newMsg = newMsg + msg;
//         return newMsg;
//     }
// 
// }


import java.io.File;
import eu.hydrologis.stage.libs.log.StageLogger;
    /**
     * Add to the relative file path the data folder. 
     * 
     * @param relativePath the relative path.
     * @param isOutFile <code>true</code>, if the path is supposed to be an outfile, in which
     *          case the file doesn't exist, but the folder has to. 
     * @return the complete absolute path.
     */
    public static File makeRelativeDataPathToFile( String relativePath, boolean isOutFile ) {
        int firstSlash = relativePath.indexOf('/');
        if (firstSlash > 2 || firstSlash == -1) {
            // it is assumed to be relative
            File dataFolder = getInstance().getDataFolder(User.getCurrentUserName());
            File file = new File(dataFolder, relativePath);
            return file;
        } else {
            File absolutePathFile = new File(relativePath);
            // if (!isOutFile) {
            // if (absolutePathFile.exists()) {
            // // it is an absolute path to an existing file, leave it as is
            // return absolutePathFile;
            // }
            // } else {
            // File parentFile = absolutePathFile.getParentFile();
            // if (parentFile != null && parentFile.exists()) {
            // // it is an absolute path to a file to be created,
            // // leave it if the folder exists
            // return absolutePathFile;
            // }
            // }
// Path: eu.hydrologis.stage.libs/src/eu/hydrologis/stage/libs/log/StageLogger.java
// public class StageLogger {
// 
//     public static final boolean LOG_INFO = true;
//     public static final boolean LOG_DEBUG = false;
//     public static final boolean LOG_ERROR = true;
// 
//     private static final String SEP = ":: ";
// 
//     private static SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// 
//     public static void logInfo( Object owner, String msg ) {
//         if (LOG_INFO) {
//             msg = toMessage(owner, msg);
//             System.out.println(msg);
//         }
//     }
// 
//     public static void logDebug( Object owner, String msg ) {
//         if (LOG_DEBUG) {
//             msg = toMessage(owner, msg);
//             System.out.println(msg);
//         }
//     }
// 
//     public static void logError( Object owner, String msg, Throwable e ) {
//         if (LOG_ERROR) {
//             msg = toMessage(owner, msg);
//             System.err.println(msg);
//             e.printStackTrace();
//         }
//     }
// 
//     public static void logError( Object owner, Throwable e ) {
//         logError(owner, null, e);
//     }
// 
//     private static String toMessage( Object owner, String msg ) {
//         if (msg == null)
//             msg = "";
//         String newMsg = f.format(new Date()) + SEP;
//         if (owner instanceof String) {
//             newMsg = newMsg + owner + SEP;
//         } else {
//             newMsg = newMsg + owner.getClass().getSimpleName() + SEP;
//         }
//         newMsg = newMsg + msg;
//         return newMsg;
//     }
// 
// }


// Path: eu.hydrologis.stage.libs/src/eu/hydrologis/stage/libs/workspace/StageWorkspace.java
import java.io.File;
import eu.hydrologis.stage.libs.log.StageLogger;

    /**
     * Add to the relative file path the data folder. 
     * 
     * @param relativePath the relative path.
     * @param isOutFile <code>true</code>, if the path is supposed to be an outfile, in which
     *          case the file doesn't exist, but the folder has to. 
     * @return the complete absolute path.
     */
    public static File makeRelativeDataPathToFile( String relativePath, boolean isOutFile ) {
        int firstSlash = relativePath.indexOf('/');
        if (firstSlash > 2 || firstSlash == -1) {
            // it is assumed to be relative
            File dataFolder = getInstance().getDataFolder(User.getCurrentUserName());
            File file = new File(dataFolder, relativePath);
            return file;
        } else {
            File absolutePathFile = new File(relativePath);
            // if (!isOutFile) {
            // if (absolutePathFile.exists()) {
            // // it is an absolute path to an existing file, leave it as is
            // return absolutePathFile;
            // }
            // } else {
            // File parentFile = absolutePathFile.getParentFile();
            // if (parentFile != null && parentFile.exists()) {
            // // it is an absolute path to a file to be created,
            // // leave it if the folder exists
            // return absolutePathFile;
            // }
            // }
            return absolutePathFile;