public ScmResult executeCommand()

in maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/AbstractChangeLogCommand.java [70:120]


    public ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters)
            throws ScmException {
        Date startDate = parameters.getDate(CommandParameter.START_DATE, null);

        Date endDate = parameters.getDate(CommandParameter.END_DATE, null);

        int numDays = parameters.getInt(CommandParameter.NUM_DAYS, 0);

        Integer limit = parameters.getInt(CommandParameter.LIMIT, -1);
        if (limit < 1) {
            limit = null;
        }

        ScmBranch branch = (ScmBranch) parameters.getScmVersion(CommandParameter.BRANCH, null);

        ScmVersion version = parameters.getScmVersion(CommandParameter.SCM_VERSION, null);

        ScmVersion startVersion = parameters.getScmVersion(CommandParameter.START_SCM_VERSION, null);

        ScmVersion endVersion = parameters.getScmVersion(CommandParameter.END_SCM_VERSION, null);

        String datePattern = parameters.getString(CommandParameter.CHANGELOG_DATE_PATTERN, null);

        boolean versionOnly = startVersion == null && endVersion == null && version != null;

        if (versionOnly) {
            return executeChangeLogCommand(repository, fileSet, version, datePattern);
        } else if (startVersion != null || endVersion != null) {
            return executeChangeLogCommand(repository, fileSet, startVersion, endVersion, datePattern);
        } else {
            if (numDays != 0 && (startDate != null || endDate != null)) {
                throw new ScmException("Start or end date cannot be set if num days is set.");
            }

            if (endDate != null && startDate == null) {
                throw new ScmException("The end date is set but the start date isn't.");
            }

            if (numDays > 0) {
                @SuppressWarnings("checkstyle:magicnumber")
                int day = 24 * 60 * 60 * 1000;
                startDate = new Date(System.currentTimeMillis() - (long) numDays * day);

                endDate = new Date(System.currentTimeMillis() + (long) day);
            } else if (endDate == null) {
                endDate = new Date();
            }

            return executeChangeLogCommand(repository, fileSet, startDate, endDate, branch, datePattern);
        }
    }