view src/main/java/org/icedrobot/ika/runtime/scm/Repository.java @ 12:5fa4fe467471

Refactor framework and plugins.
author Mario Torre <neugens.limasoftware@gmail.com>
date Tue, 29 Mar 2011 23:53:18 +0200
parents src/main/java/org/icedrobot/ika/plugins/scm/Repository.java@b2827d00500a
children 17afcf8034a6
line wrap: on
line source

/*
 * IKA - IcedRobot Kiosk Application
 * Copyright (C) 2011  IcedRobot team
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.icedrobot.ika.runtime.scm;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import java.util.logging.Level;
import java.util.logging.Logger;

import org.icedrobot.ika.plugins.IkaPluginException;

/**
 * @author Mario Torre <neugens.limasoftware@gmail.com>
 */
public abstract class Repository {

    protected String name;
    protected File baseDirectory;
    protected File fullPath;

    protected String relativePath;
    protected String remotePath;
    protected String branch;

    public abstract void create();
    abstract public void initPatchQueue();
    public abstract void applyPatchQueue();
    public abstract void makeClone();
    public abstract Repository makeSubRepository(String name,
                                                 String relativePath,
                                                 String branch);

    /**
     * Create the directory under which this repository will be located if it
     * doesn't exist.
     */
    public void createRoot() {
        getFullPath().mkdir();
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @return the baseDirectory
     */
    public File getBaseDirectory() {
        return baseDirectory;
    }

    /**
     * @return the fullPath
     */
    public File getFullPath() {
        try {
            return fullPath.getCanonicalFile();
        } catch (IOException ex) {
            throw new IkaPluginException(ex.toString(), ex);
        }
    }

    /**
     * @return the relativePath
     */
    public String getRelativePath() {
        return relativePath;
    }

    /**
     * @return the remotePath
     */
    public String getRemotePath() {
        return remotePath;
    }

    /**
     * @return the branch
     */
    public String getBranch() {
        return branch;
    }

    @Override
    public String toString() {
        return fullPath.toString();
    }
}