1 package org.apache.maven.scm.provider.integrity.command.branch;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import com.mks.api.response.APIException;
23 import com.mks.api.response.Response;
24 import org.apache.maven.scm.ScmException;
25 import org.apache.maven.scm.ScmFile;
26 import org.apache.maven.scm.ScmFileSet;
27 import org.apache.maven.scm.ScmResult;
28 import org.apache.maven.scm.command.branch.AbstractBranchCommand;
29 import org.apache.maven.scm.command.branch.BranchScmResult;
30 import org.apache.maven.scm.provider.ScmProviderRepository;
31 import org.apache.maven.scm.provider.integrity.ExceptionHandler;
32 import org.apache.maven.scm.provider.integrity.Project;
33 import org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository;
34
35 import java.util.ArrayList;
36
37
38
39
40
41
42
43
44
45
46
47
48 public class IntegrityBranchCommand
49 extends AbstractBranchCommand
50 {
51
52
53
54 @Override
55 public BranchScmResult executeBranchCommand( ScmProviderRepository repository, ScmFileSet fileSet,
56 String branchName, String message )
57 throws ScmException
58 {
59 BranchScmResult result;
60 IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
61 Project siProject = iRepo.getProject();
62 getLogger().info(
63 "Attempting to branch project " + siProject.getProjectName() + " using branch name '" + branchName + "'" );
64 try
65 {
66 Project.validateTag( branchName );
67 Response res = siProject.createDevPath( branchName );
68 int exitCode = res.getExitCode();
69 boolean success = ( exitCode == 0 ? true : false );
70 ScmResult scmResult = new ScmResult( res.getCommandString(), "", "Exit Code: " + exitCode, success );
71 result = new BranchScmResult( new ArrayList<ScmFile>(), scmResult );
72 }
73 catch ( APIException aex )
74 {
75 ExceptionHandler eh = new ExceptionHandler( aex );
76 getLogger().error( "MKS API Exception: " + eh.getMessage() );
77 getLogger().info( eh.getCommand() + " exited with return code " + eh.getExitCode() );
78 result = new BranchScmResult( eh.getCommand(), eh.getMessage(), "Exit Code: " + eh.getExitCode(), false );
79 }
80 catch ( Exception e )
81 {
82 getLogger().error( "Failed to checkpoint project! " + e.getMessage() );
83 result = new BranchScmResult( "si createdevpath", e.getMessage(), "", false );
84 }
85
86 return result;
87 }
88
89 }