Mercurial > hg4j
comparison src/org/tmatesoft/hg/internal/remote/ConnectorBase.java @ 699:a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 08 Aug 2013 19:18:50 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
698:822f3a83ff57 | 699:a483b2b68a2e |
---|---|
1 /* | |
2 * Copyright (c) 2013 TMate Software Ltd | |
3 * | |
4 * This program is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; version 2 of the License. | |
7 * | |
8 * This program is distributed in the hope that it will be useful, | |
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 * GNU General Public License for more details. | |
12 * | |
13 * For information on how to redistribute this software under | |
14 * the terms of a license other than GNU General Public License | |
15 * contact TMate Software at support@hg4j.com | |
16 */ | |
17 package org.tmatesoft.hg.internal.remote; | |
18 | |
19 import java.io.InputStream; | |
20 import java.io.OutputStream; | |
21 import java.net.URI; | |
22 import java.util.Collection; | |
23 import java.util.List; | |
24 | |
25 import org.tmatesoft.hg.auth.HgAuthFailedException; | |
26 import org.tmatesoft.hg.core.HgRemoteConnectionException; | |
27 import org.tmatesoft.hg.core.Nodeid; | |
28 import org.tmatesoft.hg.core.SessionContext; | |
29 import org.tmatesoft.hg.repo.HgRemoteRepository.RemoteDescriptor; | |
30 import org.tmatesoft.hg.repo.HgRuntimeException; | |
31 import org.tmatesoft.hg.repo.HgRemoteRepository.Range; | |
32 | |
33 /** | |
34 * An abstract base class for {@link Connector} implementations, | |
35 * to keep binary compatibility once {@link Connector} interface changes. | |
36 * | |
37 * <p>Provides default implementation for {@link #getServerLocation()} that hides user credentials from uri, if any | |
38 * | |
39 * <p>Present method implementations are not expected to be invoked and do nothing, this may change in future to return | |
40 * reasonable error objects. New methods, added to {@link Connector}, will get default implementation in this class as well. | |
41 * | |
42 * @author Artem Tikhomirov | |
43 * @author TMate Software Ltd. | |
44 */ | |
45 public abstract class ConnectorBase implements Connector { | |
46 protected URI uri; | |
47 | |
48 protected ConnectorBase() { | |
49 } | |
50 | |
51 protected void setURI(URI uri) { | |
52 this.uri = uri; | |
53 } | |
54 | |
55 // clients may invoke this method, or call #setURI(URI) directly | |
56 public void init(RemoteDescriptor remote, SessionContext sessionContext, Object globalConfig) throws HgRuntimeException { | |
57 setURI(remote.getURI()); | |
58 } | |
59 | |
60 public String getServerLocation() { | |
61 if (uri == null) { | |
62 return ""; | |
63 } | |
64 if (uri.getUserInfo() == null) { | |
65 return uri.toString(); | |
66 } | |
67 if (uri.getPort() != -1) { | |
68 return String.format("%s://%s:%d%s", uri.getScheme(), uri.getHost(), uri.getPort(), uri.getPath()); | |
69 } else { | |
70 return String.format("%s://%s%s", uri.getScheme(), uri.getHost(), uri.getPath()); | |
71 } | |
72 } | |
73 | |
74 public void connect() throws HgAuthFailedException, HgRemoteConnectionException, HgRuntimeException { | |
75 } | |
76 | |
77 public void disconnect() throws HgRemoteConnectionException, HgRuntimeException { | |
78 } | |
79 | |
80 public void sessionBegin() throws HgRemoteConnectionException, HgRuntimeException { | |
81 } | |
82 | |
83 public void sessionEnd() throws HgRemoteConnectionException, HgRuntimeException { | |
84 } | |
85 | |
86 public String getCapabilities() throws HgRemoteConnectionException, HgRuntimeException { | |
87 return null; | |
88 } | |
89 | |
90 public InputStream heads() throws HgRemoteConnectionException, HgRuntimeException { | |
91 return null; | |
92 } | |
93 | |
94 public InputStream between(Collection<Range> ranges) throws HgRemoteConnectionException, HgRuntimeException { | |
95 return null; | |
96 } | |
97 | |
98 public InputStream branches(List<Nodeid> nodes) throws HgRemoteConnectionException, HgRuntimeException { | |
99 return null; | |
100 } | |
101 | |
102 public InputStream changegroup(List<Nodeid> roots) throws HgRemoteConnectionException, HgRuntimeException { | |
103 return null; | |
104 } | |
105 | |
106 public OutputStream unbundle(long outputLen, List<Nodeid> remoteHeads) throws HgRemoteConnectionException, HgRuntimeException { | |
107 return null; | |
108 } | |
109 | |
110 public InputStream pushkey(String opName, String namespace, String key, String oldValue, String newValue) throws HgRemoteConnectionException, HgRuntimeException { | |
111 return null; | |
112 } | |
113 | |
114 public InputStream listkeys(String namespace, String actionName) throws HgRemoteConnectionException, HgRuntimeException { | |
115 return null; | |
116 } | |
117 } |