* Invoked to actually tag the workspace.
*/
public synchronized void doSubmit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
getACL().checkPermission(getPermission());
MultipartFormDataParser parser = new MultipartFormDataParser(req);
Map<SvnInfo,String> newTags = new HashMap<SvnInfo,String>();
int i=-1;
for (SvnInfo e : tags.keySet()) {
i++;
if(tags.size()>1 && parser.get("tag"+i)==null)
continue; // when tags.size()==1, UI won't show the checkbox.
newTags.put(e,parser.get("name" + i));
}
String credentialsId = parser.get("credentialsId");
StandardCredentials upc = null;
if (credentialsId != null) {
Item context = req.findAncestorObject(Item.class);
final List<Authentication> authentications = new ArrayList<Authentication>(2);
authentications.add(Jenkins.getAuthentication());
if (context.hasPermission(Item.CONFIGURE)) {
authentications.add(ACL.SYSTEM);
}
for (Authentication a : authentications) {
upc = CredentialsMatchers.firstOrNull(CredentialsProvider.lookupCredentials(StandardCredentials.class,
context,
a,
Collections.<DomainRequirement>emptyList()),
CredentialsMatchers.allOf(CredentialsMatchers.withId(credentialsId), CredentialsMatchers.anyOf(
CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class),
CredentialsMatchers.instanceOf(StandardCertificateCredentials.class),
CredentialsMatchers.instanceOf(SSHUserPrivateKey.class)
)
)
);
if (upc != null) {
break;
}
}
}
new TagWorkerThread(newTags,upc,parser.get("comment")).start();
rsp.sendRedirect(".");
}