// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java
// @Singleton
// public class Context {
// 	
// 	private final Configuration configuration = new Configuration();
// 	
// 	private Injector injector;
// 	
// 	private final GitUtils gitUtils;
// 	
// 	private final ExecutorService commandRunnerPool;
// 
// 	public Context() {
// 		gitUtils = null;
// 		commandRunnerPool = null;
// 	}
// 	
// 	public Context(GitUtils gitUtils) {
// 		this(gitUtils, null);
// 	}
// 	
// 	@Inject
// 	public Context(GitUtils gitUtils,
// 			@Named("commandRunnerPool") ExecutorService commandRunnerPool) {
// 		this.gitUtils = gitUtils;
// 		this.commandRunnerPool = commandRunnerPool;
// 	}
// 
// 	public Configuration configuration() {
// 		return configuration;
// 	}
// 	
// 	public Injector getInjector() {
// 		return injector;
// 	}
// 	
// 	public ExecutorService getCommandRunnerPool() {
// 		return commandRunnerPool;
// 	}
// 	
// 	public void setInjector(Injector injector) {
// 		this.injector = injector;
// 	}
// 	
// 	public GitUtils getGitUtils() {
// 		return gitUtils;
// 	}
// 
// }
// 
// Path: server/core/src/main/java/org/kercoin/magrit/core/build/QueueService.java
// @ImplementedBy(QueueServiceImpl.class)
// public interface QueueService {
// 	Future<BuildResult> enqueueBuild(UserIdentity committer, Repository repository,
// 			String sha1, String command, boolean force) throws Exception;
// 	
// 	void addCallback(BuildLifeCycleListener callback);
// 
// 	void removeCallback(BuildLifeCycleListener callback);
// 	
// 	Collection<Pair<Repository, String>> getScheduledTasks();
// 	Collection<Pair<Repository, String>> getCurrentTasks();
// 	
// }
// 
// Path: server/core/src/main/java/org/kercoin/magrit/core/user/UserIdentity.java
// public class UserIdentity {
// 	private final String email;
// 	private final String name;
// 	private final String toString;
// 
// 	public UserIdentity(String email, String name) {
// 		super();
// 		this.email = email;
// 		this.name = name;
// 		this.toString = String.format("\"%s\" <%s>", name, email);
// 	}
// 	
// 	public String getEmail() {
// 		return email;
// 	}
// 	
// 	public String getName() {
// 		return name;
// 	}
// 	
// 	@Override
// 	public String toString() {
// 		return toString;
// 	}
// 
// 	@Override
// 	public int hashCode() {
// 		final int prime = 31;
// 		int result = 1;
// 		result = prime * result
// 				+ ((toString == null) ? 0 : toString.hashCode());
// 		return result;
// 	}
// 
// 	@Override
// 	public boolean equals(Object obj) {
// 		if (this == obj)
// 			return true;
// 		if (obj == null)
// 			return false;
// 		if (getClass() != obj.getClass())
// 			return false;
// 		UserIdentity other = (UserIdentity) obj;
// 		if (toString == null) {
// 			if (other.toString != null)
// 				return false;
// 		} else if (!toString.equals(other.toString))
// 			return false;
// 		return true;
// 	}
// 	
// 	
// }
// 
// Path: server/core/src/main/java/org/kercoin/magrit/core/user/UserIdentityService.java
// @ImplementedBy(UserIdentityServiceImpl.class)
// public interface UserIdentityService {
// 	UserIdentity find(String login) throws AccessControlException;
// }


import org.kercoin.magrit.core.Context;
import org.kercoin.magrit.core.build.QueueService;
import org.kercoin.magrit.core.user.UserIdentity;
import org.kercoin.magrit.core.user.UserIdentityService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.security.AccessControlException;
import java.util.Scanner;
import org.apache.sshd.server.Environment;
import org.eclipse.jgit.errors.AmbiguousObjectException;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
/*
Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file.

This file is part of Magrit.

Magrit is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.

Magrit 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 Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public
License along with Magrit.
If not, see <http://www.gnu.org/licenses/>.
*/
package org.kercoin.magrit.sshd.commands;




public class SendBuildCommand extends AbstractCommand<SendBuildCommand> {

	protected final Logger log = LoggerFactory.getLogger(getClass());

	@Singleton
	public static class SendBuildCommandProvider implements CommandProvider<SendBuildCommand> {

		private final Context ctx;
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java
// @Singleton
// public class Context {
// 	
// 	private final Configuration configuration = new Configuration();
// 	
// 	private Injector injector;
// 	
// 	private final GitUtils gitUtils;
// 	
// 	private final ExecutorService commandRunnerPool;
// 
// 	public Context() {
// 		gitUtils = null;
// 		commandRunnerPool = null;
// 	}
// 	
// 	public Context(GitUtils gitUtils) {
// 		this(gitUtils, null);
// 	}
// 	
// 	@Inject
// 	public Context(GitUtils gitUtils,
// 			@Named("commandRunnerPool") ExecutorService commandRunnerPool) {
// 		this.gitUtils = gitUtils;
// 		this.commandRunnerPool = commandRunnerPool;
// 	}
// 
// 	public Configuration configuration() {
// 		return configuration;
// 	}
// 	
// 	public Injector getInjector() {
// 		return injector;
// 	}
// 	
// 	public ExecutorService getCommandRunnerPool() {
// 		return commandRunnerPool;
// 	}
// 	
// 	public void setInjector(Injector injector) {
// 		this.injector = injector;
// 	}
// 	
// 	public GitUtils getGitUtils() {
// 		return gitUtils;
// 	}
// 
// }
// 
// Path: server/core/src/main/java/org/kercoin/magrit/core/build/QueueService.java
// @ImplementedBy(QueueServiceImpl.class)
// public interface QueueService {
// 	Future<BuildResult> enqueueBuild(UserIdentity committer, Repository repository,
// 			String sha1, String command, boolean force) throws Exception;
// 	
// 	void addCallback(BuildLifeCycleListener callback);
// 
// 	void removeCallback(BuildLifeCycleListener callback);
// 	
// 	Collection<Pair<Repository, String>> getScheduledTasks();
// 	Collection<Pair<Repository, String>> getCurrentTasks();
// 	
// }
// 
// Path: server/core/src/main/java/org/kercoin/magrit/core/user/UserIdentity.java
// public class UserIdentity {
// 	private final String email;
// 	private final String name;
// 	private final String toString;
// 
// 	public UserIdentity(String email, String name) {
// 		super();
// 		this.email = email;
// 		this.name = name;
// 		this.toString = String.format("\"%s\" <%s>", name, email);
// 	}
// 	
// 	public String getEmail() {
// 		return email;
// 	}
// 	
// 	public String getName() {
// 		return name;
// 	}
// 	
// 	@Override
// 	public String toString() {
// 		return toString;
// 	}
// 
// 	@Override
// 	public int hashCode() {
// 		final int prime = 31;
// 		int result = 1;
// 		result = prime * result
// 				+ ((toString == null) ? 0 : toString.hashCode());
// 		return result;
// 	}
// 
// 	@Override
// 	public boolean equals(Object obj) {
// 		if (this == obj)
// 			return true;
// 		if (obj == null)
// 			return false;
// 		if (getClass() != obj.getClass())
// 			return false;
// 		UserIdentity other = (UserIdentity) obj;
// 		if (toString == null) {
// 			if (other.toString != null)
// 				return false;
// 		} else if (!toString.equals(other.toString))
// 			return false;
// 		return true;
// 	}
// 	
// 	
// }
// 
// Path: server/core/src/main/java/org/kercoin/magrit/core/user/UserIdentityService.java
// @ImplementedBy(UserIdentityServiceImpl.class)
// public interface UserIdentityService {
// 	UserIdentity find(String login) throws AccessControlException;
// }


// Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/SendBuildCommand.java
import org.kercoin.magrit.core.Context;
import org.kercoin.magrit.core.build.QueueService;
import org.kercoin.magrit.core.user.UserIdentity;
import org.kercoin.magrit.core.user.UserIdentityService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.security.AccessControlException;
import java.util.Scanner;
import org.apache.sshd.server.Environment;
import org.eclipse.jgit.errors.AmbiguousObjectException;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;

/*
Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file.

This file is part of Magrit.

Magrit is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.

Magrit 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 Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public
License along with Magrit.
If not, see <http://www.gnu.org/licenses/>.
*/
package org.kercoin.magrit.sshd.commands;




public class SendBuildCommand extends AbstractCommand<SendBuildCommand> {

	protected final Logger log = LoggerFactory.getLogger(getClass());

	@Singleton
	public static class SendBuildCommandProvider implements CommandProvider<SendBuildCommand> {

		private final Context ctx;
		private final QueueService buildQueueService;