1 package org.apache.maven.scm.provider.integrity.command.remove;
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.remove.AbstractRemoveCommand;
27 import org.apache.maven.scm.command.remove.RemoveScmResult;
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 public class IntegrityRemoveCommand
42 extends AbstractRemoveCommand
43 {
44
45
46
47 @Override
48 public RemoveScmResult executeRemoveCommand( ScmProviderRepository repository, ScmFileSet fileSet, String message )
49 throws ScmException
50 {
51 getLogger().info( "Attempting to un-register sandbox in directory " + fileSet.getBasedir().getAbsolutePath() );
52 RemoveScmResult result;
53 IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
54 try
55 {
56 Sandbox siSandbox = iRepo.getSandbox();
57 Response res = siSandbox.drop();
58 int exitCode = res.getExitCode();
59 boolean success = ( exitCode == 0 ? true : false );
60 result = new RemoveScmResult( res.getCommandString(), "", "Exit Code: " + exitCode, success );
61 }
62 catch ( APIException aex )
63 {
64 ExceptionHandler eh = new ExceptionHandler( aex );
65 getLogger().error( "MKS API Exception: " + eh.getMessage() );
66 getLogger().info( eh.getCommand() + " exited with return code " + eh.getExitCode() );
67 result = new RemoveScmResult( eh.getCommand(), eh.getMessage(), "Exit Code: " + eh.getExitCode(), false );
68 }
69
70 return result;
71 }
72
73 }