1 | |
package org.apache.maven.scm.provider.vss; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.maven.scm.CommandParameters; |
23 | |
import org.apache.maven.scm.ScmException; |
24 | |
import org.apache.maven.scm.ScmFileSet; |
25 | |
import org.apache.maven.scm.command.add.AddScmResult; |
26 | |
import org.apache.maven.scm.command.changelog.ChangeLogScmResult; |
27 | |
import org.apache.maven.scm.command.checkin.CheckInScmResult; |
28 | |
import org.apache.maven.scm.command.checkout.CheckOutScmResult; |
29 | |
import org.apache.maven.scm.command.edit.EditScmResult; |
30 | |
import org.apache.maven.scm.command.status.StatusScmResult; |
31 | |
import org.apache.maven.scm.command.tag.TagScmResult; |
32 | |
import org.apache.maven.scm.command.update.UpdateScmResult; |
33 | |
import org.apache.maven.scm.provider.AbstractScmProvider; |
34 | |
import org.apache.maven.scm.provider.ScmProviderRepository; |
35 | |
import org.apache.maven.scm.provider.vss.commands.add.VssAddCommand; |
36 | |
import org.apache.maven.scm.provider.vss.commands.changelog.VssHistoryCommand; |
37 | |
import org.apache.maven.scm.provider.vss.commands.checkin.VssCheckInCommand; |
38 | |
import org.apache.maven.scm.provider.vss.commands.checkout.VssCheckOutCommand; |
39 | |
import org.apache.maven.scm.provider.vss.commands.edit.VssEditCommand; |
40 | |
import org.apache.maven.scm.provider.vss.commands.status.VssStatusCommand; |
41 | |
import org.apache.maven.scm.provider.vss.commands.tag.VssTagCommand; |
42 | |
import org.apache.maven.scm.provider.vss.commands.update.VssUpdateCommand; |
43 | |
import org.apache.maven.scm.provider.vss.repository.VssScmProviderRepository; |
44 | |
import org.apache.maven.scm.repository.ScmRepositoryException; |
45 | |
import org.codehaus.plexus.util.StringUtils; |
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | 12 | public class VssScmProvider |
53 | |
extends AbstractScmProvider |
54 | |
{ |
55 | |
|
56 | |
public static final String VSS_URL_FORMAT = "[username[|password]@]vssdir|projectPath"; |
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
public String getScmSpecificFilename() |
64 | |
{ |
65 | 0 | return "vssver.scc"; |
66 | |
} |
67 | |
|
68 | |
|
69 | |
public ScmProviderRepository makeProviderScmRepository( String scmSpecificUrl, char delimiter ) |
70 | |
throws ScmRepositoryException |
71 | |
{ |
72 | 14 | String user = null; |
73 | 14 | String password = null; |
74 | |
String vssDir; |
75 | |
String project; |
76 | |
|
77 | 14 | int index = scmSpecificUrl.indexOf( '@' ); |
78 | |
|
79 | 14 | String rest = scmSpecificUrl; |
80 | |
|
81 | 14 | if ( index != -1 ) |
82 | |
{ |
83 | 13 | String userAndPassword = scmSpecificUrl.substring( 0, index ); |
84 | |
|
85 | 13 | rest = scmSpecificUrl.substring( index + 1 ); |
86 | |
|
87 | 13 | index = userAndPassword.indexOf( delimiter ); |
88 | |
|
89 | 13 | if ( index != -1 ) |
90 | |
{ |
91 | 12 | user = userAndPassword.substring( 0, index ); |
92 | |
|
93 | 12 | password = userAndPassword.substring( index + 1 ); |
94 | |
} |
95 | |
else |
96 | |
{ |
97 | 1 | user = userAndPassword; |
98 | |
} |
99 | |
} |
100 | 14 | String[] tokens = StringUtils.split( rest, String.valueOf( delimiter ) ); |
101 | |
|
102 | 14 | if ( tokens.length < 2 ) |
103 | |
{ |
104 | 0 | throw new ScmRepositoryException( "Invalid SCM URL: The url has to be on the form: " + VSS_URL_FORMAT ); |
105 | |
} |
106 | |
else |
107 | |
{ |
108 | 14 | vssDir = tokens[0]; |
109 | |
|
110 | 14 | project = tokens[1]; |
111 | |
} |
112 | |
|
113 | 14 | return new VssScmProviderRepository( user, password, vssDir, project ); |
114 | |
} |
115 | |
|
116 | |
|
117 | |
public String getScmType() |
118 | |
{ |
119 | 0 | return "vss"; |
120 | |
} |
121 | |
|
122 | |
|
123 | |
public AddScmResult add( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) |
124 | |
throws ScmException |
125 | |
{ |
126 | |
|
127 | 0 | VssAddCommand command = new VssAddCommand(); |
128 | 0 | command.setLogger( getLogger() ); |
129 | |
|
130 | 0 | return (AddScmResult) command.execute( repository, fileSet, parameters ); |
131 | |
} |
132 | |
|
133 | |
public CheckInScmResult checkin( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) |
134 | |
throws ScmException |
135 | |
{ |
136 | 0 | VssCheckInCommand command = new VssCheckInCommand(); |
137 | |
|
138 | 0 | command.setLogger( getLogger() ); |
139 | |
|
140 | 0 | return (CheckInScmResult) command.execute( repository, fileSet, parameters ); |
141 | |
} |
142 | |
|
143 | |
|
144 | |
public CheckOutScmResult checkout( ScmProviderRepository repository, ScmFileSet fileSet, |
145 | |
CommandParameters parameters ) |
146 | |
throws ScmException |
147 | |
{ |
148 | 0 | VssCheckOutCommand command = new VssCheckOutCommand(); |
149 | |
|
150 | 0 | command.setLogger( getLogger() ); |
151 | |
|
152 | 0 | return (CheckOutScmResult) command.execute( repository, fileSet, parameters ); |
153 | |
} |
154 | |
|
155 | |
|
156 | |
public ChangeLogScmResult changelog( ScmProviderRepository repository, ScmFileSet fileSet, |
157 | |
CommandParameters parameters ) |
158 | |
throws ScmException |
159 | |
{ |
160 | 0 | VssHistoryCommand command = new VssHistoryCommand(); |
161 | |
|
162 | 0 | command.setLogger( getLogger() ); |
163 | |
|
164 | 0 | return (ChangeLogScmResult) command.execute( repository, fileSet, parameters ); |
165 | |
} |
166 | |
|
167 | |
public TagScmResult tag( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) |
168 | |
throws ScmException |
169 | |
{ |
170 | 0 | VssTagCommand command = new VssTagCommand(); |
171 | |
|
172 | 0 | command.setLogger( getLogger() ); |
173 | |
|
174 | 0 | return (TagScmResult) command.execute( repository, fileSet, parameters ); |
175 | |
} |
176 | |
|
177 | |
|
178 | |
public UpdateScmResult update( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) |
179 | |
throws ScmException |
180 | |
{ |
181 | 0 | VssUpdateCommand command = new VssUpdateCommand(); |
182 | |
|
183 | 0 | command.setLogger( getLogger() ); |
184 | |
|
185 | 0 | return (UpdateScmResult) command.execute( repository, fileSet, parameters ); |
186 | |
} |
187 | |
|
188 | |
|
189 | |
public StatusScmResult status( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) |
190 | |
throws ScmException |
191 | |
{ |
192 | 0 | VssStatusCommand command = new VssStatusCommand(); |
193 | |
|
194 | 0 | command.setLogger( getLogger() ); |
195 | |
|
196 | 0 | return (StatusScmResult) command.execute( repository, fileSet, parameters ); |
197 | |
} |
198 | |
|
199 | |
|
200 | |
public EditScmResult edit( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) |
201 | |
throws ScmException |
202 | |
{ |
203 | 0 | VssEditCommand command = new VssEditCommand(); |
204 | |
|
205 | 0 | command.setLogger( getLogger() ); |
206 | |
|
207 | 0 | return (EditScmResult) command.execute( repository, fileSet, parameters ); |
208 | |
} |
209 | |
|
210 | |
|
211 | |
|
212 | |
|
213 | |
|
214 | |
|
215 | |
|
216 | |
|
217 | |
|
218 | |
|
219 | |
|
220 | |
|
221 | |
|
222 | |
|
223 | |
|
224 | |
|
225 | |
|
226 | |
|
227 | |
|
228 | |
|
229 | |
|
230 | |
} |