ar.com.zauber.garfio.modules.jira.model.actions.UpdateLogWorkAction.java Source code

Java tutorial

Introduction

Here is the source code for ar.com.zauber.garfio.modules.jira.model.actions.UpdateLogWorkAction.java

Source

/**
 * Copyright (c) 2007-2009 Zauber S.A. <http://www.zauber.com.ar/>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package ar.com.zauber.garfio.modules.jira.model.actions;

import java.util.List;

import org.apache.commons.lang.Validate;

import ar.com.zauber.garfio.modules.jira.model.JiraIssue;
import ar.com.zauber.garfio.modules.jira.model.JiraTrackerSession;
import ar.com.zauber.garfio.modules.model.Action;
import ar.com.zauber.garfio.modules.model.MustNotExecuteException;

import com.atlassian.jira.rpc.soap.beans.RemoteWorklog;

/**
 * Updates the log work field in the tracker.
 * 
 * 
 * @author Juan F. Codagnone
 * @since Oct 14, 2007
 */
public class UpdateLogWorkAction implements Action {
    private final JiraTrackerSession session;
    private final JiraIssue issue;

    /** constructor */
    public UpdateLogWorkAction(final JiraIssue issue, final JiraTrackerSession session, final String value) {

        Validate.notNull(issue);
        Validate.notNull(session);
        Validate.notEmpty(value);

        this.issue = issue;
        this.session = session;
    }

    /** @see Action#execute() */
    public final void execute() {

        // TODO find a jira installation that allows to test this.
        try {
            final RemoteWorklog[] worklogs = session.getJiraSoapService().getWorklogs(session.getToken(),
                    issue.getId());

            for (final RemoteWorklog worklog : worklogs) {
                System.out.println(worklog.getComment());
                System.out.println(worklog.getTimeSpentInSeconds());
            }

        } catch (final Exception e) {
            throw new RuntimeException(e);
        }
    }

    /** @see Action#preExecutionValidation(List) 
     * @throws MustNotExecuteException on error */
    public final void preExecutionValidation(final List<Action> allActions) throws MustNotExecuteException {
        // TODO Auto-generated method stub
    }

}