1 package org.apache.maven.scm.provider.integrity.command.changelog;
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 org.apache.maven.scm.ScmBranch;
24 import org.apache.maven.scm.ScmException;
25 import org.apache.maven.scm.ScmFileSet;
26 import org.apache.maven.scm.ScmResult;
27 import org.apache.maven.scm.command.changelog.AbstractChangeLogCommand;
28 import org.apache.maven.scm.command.changelog.ChangeLogScmResult;
29 import org.apache.maven.scm.provider.ScmProviderRepository;
30 import org.apache.maven.scm.provider.integrity.ExceptionHandler;
31 import org.apache.maven.scm.provider.integrity.Sandbox;
32 import org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository;
33
34 import java.util.Date;
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 public class IntegrityChangeLogCommand
50 extends AbstractChangeLogCommand
51 {
52
53
54
55 @Override
56 public ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repository, ScmFileSet fileSet,
57 Date startDate, Date endDate, ScmBranch branch,
58 String datePattern )
59 throws ScmException
60 {
61
62 if ( null == startDate || null == endDate )
63 {
64 throw new ScmException( "Both 'startDate' and 'endDate' must be specified!" );
65 }
66 if ( startDate.after( endDate ) )
67 {
68 throw new ScmException( "'stateDate' is not allowed to occur after 'endDate'!" );
69 }
70 getLogger().info(
71 "Attempting to obtain change log for date range: '" + Sandbox.RLOG_DATEFORMAT.format( startDate ) + "' to '"
72 + Sandbox.RLOG_DATEFORMAT.format( endDate ) + "'" );
73 ChangeLogScmResult result;
74 IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
75 try
76 {
77 result = new ChangeLogScmResult( iRepo.getSandbox().getChangeLog( startDate, endDate ),
78 new ScmResult( "si rlog", "", "", true ) );
79 }
80 catch ( APIException aex )
81 {
82 ExceptionHandler eh = new ExceptionHandler( aex );
83 getLogger().error( "MKS API Exception: " + eh.getMessage() );
84 getLogger().info( eh.getCommand() + " exited with return code " + eh.getExitCode() );
85 result =
86 new ChangeLogScmResult( eh.getCommand(), eh.getMessage(), "Exit Code: " + eh.getExitCode(), false );
87 }
88
89 return result;
90 }
91
92 }