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.mantis.model.actions; import org.apache.commons.lang.Validate; import org.mantisbt.connect.JMTException; import org.mantisbt.connect.service.AccountData; import ar.com.zauber.garfio.modules.mantis.model.MantisIssue; import ar.com.zauber.garfio.modules.mantis.model.MantisTrackerSession; /** * Close an issue as solved. * * @author Fernando Zunino * @author Juan F. Codagnone * @since 09/02/2007 */ public class ResolveIssueAction extends AbstractIssueAction { /** user id */ private String uid; /** * Creates the ResolveIssueAction. * * @param issue issue to close * @param session session */ public ResolveIssueAction(final MantisIssue issue, final MantisTrackerSession session, final String uid) { super(issue, session); Validate.notEmpty(uid); this.uid = uid; } /** @see Action#execute() */ public final void execute() { try { final AccountData closingUser = getLoggedUser(); mantisIssue.fix(closingUser); } catch (final JMTException e) { throw new RuntimeException(e); } } /** * @return the logged in user * @throws JMTException on error */ private AccountData getLoggedUser() throws JMTException { final AccountData[] users = session.getSession() .getProjectUsers(mantisIssue.getIssueData().getProject().getId().longValue(), 0); AccountData ret = null; for (final AccountData user : users) { if (user.getName().equals(uid)) { ret = user; break; } } return ret; } }