Java tutorial
/** * 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.StringUtils; import org.apache.commons.lang.Validate; 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.RemoteComment; /** * Adds a comment to an issue. * * @author Juan F. Codagnone * @since Oct 13, 2007 */ public class AddNoteToIssueAction implements Action { private final String id; private final JiraTrackerSession session; private final String note; /** Creates the AddNoteToIssueAction. */ public AddNoteToIssueAction(final String id, final JiraTrackerSession session, final String note) { Validate.notEmpty(id); Validate.notNull(session); Validate.isTrue(!StringUtils.isBlank(note)); this.id = id; this.session = session; this.note = note; } /** @see Action#execute() */ public final void execute() { final RemoteComment comment = new RemoteComment(); comment.setBody(note); try { session.getJiraSoapService().addComment(session.getToken(), id, comment); } catch (final Exception e) { throw new RuntimeException(e); } } /** @see Action#preExecutionValidation(List) * @throws MustNotExecuteException on error */ public void preExecutionValidation(final List<Action> allActions) throws MustNotExecuteException { // no preconditions } }