List of usage examples for org.eclipse.jgit.transport URIish URIish
public URIish()
From source file:com.madgag.agit.GitTestUtils.java
License:Open Source License
public static URIish integrationGitServerURIFor(String repoPath) throws URISyntaxException, IOException, FileNotFoundException, UnknownHostException { return new URIish().setScheme("ssh").setUser(RSA_USER) // use RSA user by default - mini-git-server currently requires publickey auth .setHost(gitServerHostAddress()).setPort(29418).setPath(repoPath); }
From source file:org.eclipse.egit.ui.internal.components.RepositorySelectionPage.java
License:Open Source License
/** * Create repository selection page, allowing user specifying URI or * (optionally) choosing from preconfigured remotes list. * <p>/*from www . ja v a2s. c om*/ * Wizard page is created without image, just with text description. * * @param sourceSelection * true if dialog is used for source selection; false otherwise * (destination selection). This indicates appropriate text * messages. * @param configuredRemotes * list of configured remotes that user may select as an * alternative to manual URI specification. Remotes appear in * given order in GUI, with * {@value Constants#DEFAULT_REMOTE_NAME} as the default choice. * List may be null or empty - no remotes configurations appear * in this case. Note that the provided list may be changed by * this constructor. * @param presetUri * the pre-set URI, may be null */ public RepositorySelectionPage(final boolean sourceSelection, final List<RemoteConfig> configuredRemotes, String presetUri) { super(RepositorySelectionPage.class.getName()); this.uri = new URIish(); this.sourceSelection = sourceSelection; String preset = presetUri; if (presetUri == null) { Clipboard clippy = new Clipboard(Display.getCurrent()); String text = (String) clippy.getContents(TextTransfer.getInstance()); try { if (text != null) { text = text.trim(); int index = text.indexOf(' '); if (index > 0) text = text.substring(0, index); URIish u = new URIish(text); if (Transport.canHandleProtocol(u, FS.DETECTED)) { if (Protocol.GIT.handles(u) || Protocol.SSH.handles(u) || text.endsWith(Constants.DOT_GIT)) preset = text; } } } catch (URISyntaxException e) { // ignore, preset is null } clippy.dispose(); } this.presetUri = preset; this.configuredRemotes = getUsableConfigs(configuredRemotes); this.remoteConfig = selectDefaultRemoteConfig(); selection = RepositorySelection.INVALID_SELECTION; if (sourceSelection) { setTitle(UIText.RepositorySelectionPage_sourceSelectionTitle); setDescription(UIText.RepositorySelectionPage_sourceSelectionDescription); } else { setTitle(UIText.RepositorySelectionPage_destinationSelectionTitle); setDescription(UIText.RepositorySelectionPage_destinationSelectionDescription); } }
From source file:org.eclipse.ptp.internal.rdt.sync.git.core.JGitRepo.java
License:Open Source License
/** * Build the URI for the remote host as needed by the transport. Since the * transport will use an external SSH session, we do not need to provide * user, host, or password. However, the function for opening a transport * throws an exception if the host is null or empty length. So we set it to * a dummy string./*from w ww . jav a2s . com*/ * * @return URIish */ private URIish buildURI(String directory) { return new URIish() // .setUser(connection.getUsername()) .setHost("none") //$NON-NLS-1$ // .setPass("") .setScheme("ssh") //$NON-NLS-1$ .setPath(directory + "/" + GitSyncService.gitDir); //$NON-NLS-1$ // Should use remote path seperator but first // 315720 has to be fixed }
From source file:org.eclipse.ptp.rdt.sync.git.core.GitRemoteSyncConnection.java
License:Open Source License
/** * Build the URI for the remote host as needed by the transport. Since the * transport will use an external SSH session, we do not need to provide * user, host, or password. However, the function for opening a transport * throws an exception if the host is null or empty length. So we set it to * a dummy string./*w ww .j ava2s.c o m*/ * * @return URIish */ private URIish buildURI() { return new URIish() // .setUser(connection.getUsername()) .setHost("none") //$NON-NLS-1$ // .setPass("") .setScheme("ssh") //$NON-NLS-1$ .setPath(remoteDirectory + "/" + gitDir); //$NON-NLS-1$ //Should use remote path seperator but first 315720 has to be fixed }
From source file:org.jboss.tools.openshift.express.internal.ui.command.TailFilesHandler.java
License:Open Source License
/** * Starting the tail process on the remote OpenShift Platform. This method * relies on the JGit SSH support (including JSch) to open a connection AND * execute a command in a single invocation. The connection establishement * requires an SSH key, and the passphrase is prompted to the user if * necessary.//from ww w .j a v a 2s. c om * @param sshUrl * @param filePattern * @param optionsAndFile * @param console * @return * @throws URISyntaxException * @throws IOException */ private TailServerLogWorker startTailProcess(final String sshUrl, final String optionsAndFile, final MessageConsole console) throws URISyntaxException, IOException { JSch.setLogger(new JschToEclipseLogger()); final SshSessionFactory sshSessionFactory = SshSessionFactory.getInstance(); URI uri = new URI(sshUrl); uri.getHost(); final URIish urish = new URIish().setHost(uri.getHost()).setUser(uri.getUserInfo()); RemoteSession remoteSession = sshSessionFactory.getSession(urish, CredentialsProvider.getDefault(), FS.DETECTED, 0); final String command = new TailCommandBuilder(optionsAndFile).build(); Logger.debug("ssh command to execute: " + command); Process process = remoteSession.exec(command, 0); return new TailServerLogWorker(console, process, remoteSession); }
From source file:org.jboss.tools.openshift.express.internal.ui.utils.OpenShiftSshSessionFactory.java
License:Open Source License
static URIish getSshUri(IApplication application) { final String host = application.getName() + "-" + application.getDomain().getId() + "." + application.getDomain().getSuffix(); final String user = application.getUUID(); final URIish uri = new URIish().setHost(host).setPort(22).setUser(user); return uri;/* w w w. j a v a 2 s .c o m*/ }
From source file:org.jboss.tools.openshift.express.internal.ui.utils.SSHSessionRepository.java
License:Open Source License
static URIish getSshUri(IApplication application) throws URISyntaxException { final URI sshURI = new URI(application.getSshUrl()); final String host = sshURI.getHost(); final String user = sshURI.getUserInfo(); final URIish uri = new URIish().setHost(host).setPort(22).setUser(user); return uri;//from ww w .j a v a2 s. co m }
From source file:org.libreoffice.ci.gerrit.buildbot.publisher.JenkinsLogPublisher.java
License:Mozilla Public License
@Override public String publishLog(BuildbotConfig config, String ticket, String boxId, TaskStatus status, InputStream in) {/*w ww .j av a 2 s . co m*/ final String cmd = JENKINS_SSH_COMMAND + " --display " + ticket + "_" + boxId + " --dump-build-number " + " --job " + config.getExternalLogViewerJob() + " --result " + (status.isSuccess() ? "0" : "1") + " --log -"; OutputStream errStream = newErrorBufferStream(); OutputStream outStream = newErrorBufferStream(); URIish jenkins = null; try { jenkins = new URIish().setHost(config.getExternalLogViewerHost()); RemoteSession ssh = connect(jenkins); Process proc = ssh.exec(cmd, 0/*timeout*/); StreamCopyThread out = new StreamCopyThread(proc.getInputStream(), outStream); StreamCopyThread err = new StreamCopyThread(proc.getErrorStream(), errStream); StreamCopyThread inp = new StreamCopyThread(in, proc.getOutputStream()); out.start(); err.start(); inp.start(); try { out.flush(); err.flush(); inp.flush(); proc.waitFor(); proc.exitValue(); out.halt(); err.halt(); inp.halt(); } catch (InterruptedException interrupted) { log.error("process interupted: ", interrupted); } ssh.disconnect(); } catch (IOException e) { log.error(String.format( "Error pushing log to %s:\n" + " Exception: %s\n" + " Command: %s\n" + " Output: %s", jenkins, e, cmd, errStream), e); return null; } String result = String.format("%s/job/%s/%s", config.getExternalLogViewerUrl(), config.getExternalLogViewerJob(), outStream.toString().trim()); log.debug("log url: {}", result); return result; }
From source file:org.libreoffice.ci.gerrit.buildbot.publisher.JenkinsLogPublisher.java
License:Mozilla Public License
@Override public String testChannel(BuildbotConfig config) { final String cmd = JENKINS_TEST_CHANNEL; StringBuilder builder = new StringBuilder(cmd.length()).append(">ssh ") .append(config.getExternalLogViewerHost()).append(" ").append(cmd).append("\n"); OutputStream errStream = newErrorBufferStream(); OutputStream outStream = newErrorBufferStream(); URIish jenkins = null;/*from w w w. ja va 2 s . com*/ try { jenkins = new URIish().setHost(config.getExternalLogViewerHost()); RemoteSession ssh = connect(jenkins); Process proc = ssh.exec(cmd, 0/*timeout*/); StreamCopyThread out = new StreamCopyThread(proc.getInputStream(), outStream); StreamCopyThread err = new StreamCopyThread(proc.getErrorStream(), errStream); out.start(); err.start(); try { out.flush(); err.flush(); proc.waitFor(); proc.exitValue(); out.halt(); err.halt(); } catch (InterruptedException interrupted) { log.error("process interupted: ", interrupted); } ssh.disconnect(); return builder.append("<").append(outStream.toString()).toString(); } catch (IOException e) { log.error(String.format( "Error testing log channel\n" + " Exception: %s\n" + " Command: %s\n" + " Output: %s", jenkins, e, cmd, errStream), e); return null; } }
From source file:org.nbgit.ui.wizards.ClonePathsWizardPanel.java
License:Open Source License
/** * Invoked when the second page of wizard <em>Clone External Repository</em> * (aka <em>Clone Other...</em>) is displayed and one of the * <em>Change...</em> buttons is pressed. It displays a repository chooser * dialog.//from ww w.j a v a 2 s .co m * * @param titleMsgKey resource bundle key for the title of the repository * chooser dialog * @return {@code } of the selected repository if one was selected, * {@code HgURL.NO_URL} if the <em>Clear Path</em> button was * selected, {@code null} otherwise (button <em>Cancel</em> pressed * or the dialog closed without pressing any of the above buttons) */ private URIish changeUrl(String titleMsgKey) { int repoModeMask = GitRepositoryUI.FLAG_URL_ENABLED | GitRepositoryUI.FLAG_SHOW_HINTS; String title = getMessage(titleMsgKey); final JButton set = new JButton(); final JButton clear = new JButton(); Mnemonics.setLocalizedText(set, getMessage("changePullPushPath.Set")); //NOI18N Mnemonics.setLocalizedText(clear, getMessage("changePullPushPath.Clear")); //NOI18N final GitRepositoryUI repository = new GitRepositoryUI(repoModeMask, title, true); set.setEnabled(repository.isValid()); clear.setDefaultCapable(false); final DialogDescriptor dialogDescriptor = new DialogDescriptor( GitUtils.addContainerBorder(repository.getPanel()), title, //title true, //modal new Object[] { set, clear, CANCEL_OPTION }, set, //default option DEFAULT_ALIGN, //alignment new HelpCtx(ClonePathsWizardPanel.class.getName() + ".change"), //NOI18N null); //action listener dialogDescriptor.setClosingOptions(new Object[] { clear, CANCEL_OPTION }); final NotificationLineSupport notificationLineSupport = dialogDescriptor.createNotificationLineSupport(); class RepositoryChangeListener implements ChangeListener, ActionListener { private Dialog dialog; public void setDialog(Dialog dialog) { this.dialog = dialog; } public void stateChanged(ChangeEvent e) { assert e.getSource() == repository; boolean isValid = repository.isValid(); dialogDescriptor.setValid(isValid); set.setEnabled(isValid); if (isValid) { notificationLineSupport.clearMessages(); } else { String errMsg = repository.getMessage(); if ((errMsg != null) && (errMsg.length() != 0)) { notificationLineSupport.setErrorMessage(errMsg); } else { notificationLineSupport.clearMessages(); } } } public void actionPerformed(ActionEvent e) { if (e.getSource() != set) { return; } try { //remember the selected URL: dialogDescriptor.setValue(repository.getUrl()); /* * option "set" is not closing so we must handle closing * of the dialog explictly here: */ dialog.setVisible(false); dialog.dispose(); } catch (MalformedURLException ex) { repository.setInvalid(); notificationLineSupport.setErrorMessage(ex.getMessage()); } catch (URISyntaxException ex) { repository.setInvalid(); notificationLineSupport.setErrorMessage(ex.getMessage()); } } } RepositoryChangeListener optionListener = new RepositoryChangeListener(); repository.addChangeListener(optionListener); dialogDescriptor.setButtonListener(optionListener); Dialog dialog = DialogDisplayer.getDefault().createDialog(dialogDescriptor); optionListener.setDialog(dialog); dialog.pack(); dialog.setVisible(true); Object selectedValue = dialogDescriptor.getValue(); assert (selectedValue instanceof URIish) || (selectedValue == clear) || (selectedValue == CANCEL_OPTION) || (selectedValue == CLOSED_OPTION); if (selectedValue instanceof URIish) { return (URIish) selectedValue; } else if (selectedValue == clear) { return new URIish(); // NO_URL } else { return null; //CANCEL_OPTION, CLOSED_OPTION } }