1 package org.apache.maven.scm.provider.integrity.command.unedit;
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.ScmFileSet;
26 import org.apache.maven.scm.command.unedit.AbstractUnEditCommand;
27 import org.apache.maven.scm.command.unedit.UnEditScmResult;
28 import org.apache.maven.scm.provider.ScmProviderRepository;
29 import org.apache.maven.scm.provider.integrity.ExceptionHandler;
30 import org.apache.maven.scm.provider.integrity.Sandbox;
31 import org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository;
32
33
34
35
36
37
38
39
40
41
42 public class IntegrityUnEditCommand
43 extends AbstractUnEditCommand
44 {
45
46
47
48 @Override
49 public UnEditScmResult executeUnEditCommand( ScmProviderRepository repository, ScmFileSet fileSet )
50 throws ScmException
51 {
52 getLogger().info( "Attempting to revert members in sandbox " + fileSet.getBasedir().getAbsolutePath() );
53 IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
54 UnEditScmResult result;
55 try
56 {
57 Sandbox siSandbox = iRepo.getSandbox();
58 Response res = siSandbox.revertMembers();
59 int exitCode = res.getExitCode();
60 boolean success = ( exitCode == 0 ? true : false );
61 result = new UnEditScmResult( res.getCommandString(), "", "Exit Code: " + exitCode, success );
62 }
63 catch ( APIException aex )
64 {
65 ExceptionHandler eh = new ExceptionHandler( aex );
66 getLogger().error( "MKS API Exception: " + eh.getMessage() );
67 getLogger().info( eh.getCommand() + " exited with return code " + eh.getExitCode() );
68 result = new UnEditScmResult( eh.getCommand(), eh.getMessage(), "Exit Code: " + eh.getExitCode(), false );
69 }
70
71 return result;
72 }
73 }