Mercurial > hg > icedrobot > ika
view src/org/icedrobot/ika/plugins/scm/Repository.java @ 4:82de5424529c
Moved SCM Repository abstraction to different location.
author | Mario Torre <neugens.limasoftware@gmail.com> |
---|---|
date | Tue, 08 Mar 2011 00:20:49 +0100 |
parents | src/org/icedrobot/ika/plugins/borg/Repository.java@91ff28c21e0b |
children | 24bc15b8e27b |
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.plugins.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 applyPatchQueue(); public abstract void makeClone(); public abstract Repository makeSubRepository(String name, String relativePath, String branch); protected static void exec(String command, File path) { try { System.err.println("command: " + command + ", path: " + path); Process process = Runtime.getRuntime().exec(command, null, path); InputStream is = process.getInputStream(); InputStreamReader reader = new InputStreamReader(is); BufferedReader br = new BufferedReader(reader); String line; while ((line = br.readLine()) != null) { System.out.println(line); } } catch (IOException ex) { Logger.getLogger(Repository.class.getName()). log(Level.SEVERE, "cannot execute: " + command, ex); throw new IkaPluginException("cannot execute: " + command, ex); } } /** * */ 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(); } }