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
50 public class IntegrityChangeLogCommand
51 extends AbstractChangeLogCommand
52 {
53
54
55
56 @Override
57 public ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repository, ScmFileSet fileSet,
58 Date startDate, Date endDate, ScmBranch branch,
59 String datePattern )
60 throws ScmException
61 {
62
63 if ( null == startDate || null == endDate )
64 {
65 throw new ScmException( "Both 'startDate' and 'endDate' must be specified!" );
66 }
67 if ( startDate.after( endDate ) )
68 {
69 throw new ScmException( "'stateDate' is not allowed to occur after 'endDate'!" );
70 }
71 getLogger().info(
72 "Attempting to obtain change log for date range: '" + Sandbox.RLOG_DATEFORMAT.format( startDate ) + "' to '"
73 + Sandbox.RLOG_DATEFORMAT.format( endDate ) + "'" );
74 ChangeLogScmResult result;
75 IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
76 try
77 {
78 result = new ChangeLogScmResult( iRepo.getSandbox().getChangeLog( startDate, endDate ),
79 new ScmResult( "si rlog", "", "", true ) );
80 }
81 catch ( APIException aex )
82 {
83 ExceptionHandler eh = new ExceptionHandler( aex );
84 getLogger().error( "MKS API Exception: " + eh.getMessage() );
85 getLogger().info( eh.getCommand() + " exited with return code " + eh.getExitCode() );
86 result =
87 new ChangeLogScmResult( eh.getCommand(), eh.getMessage(), "Exit Code: " + eh.getExitCode(), false );
88 }
89
90 return result;
91 }
92
93 }