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; import static ar.com.zauber.garfio.modules.common.utils.ConnectionUtils.*; import java.net.URI; import java.util.Properties; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.Validate; import ar.com.zauber.garfio.modules.GarfioModule; import ar.com.zauber.garfio.modules.mantis.MantisGarfioModule; import ar.com.zauber.garfio.modules.model.TrackerSession; import ar.com.zauber.garfio.modules.model.TrackerSessionProvider; import ar.com.zauber.garfio.modules.services.CommentFormatter; /** * {@link TrackerSessionProvider} implementation for Mantis * * @author Juan F. Codagnone * @since Apr 13, 2011 */ public class MantisTrackerSessionProvider implements TrackerSessionProvider { private final GarfioModule module = new MantisGarfioModule(); private final String garfioURL; private final String garfioPassword; /** * Creates the MantisTrackerSessionProvider. * */ public MantisTrackerSessionProvider(final URI garfioURL, final String garfioPassword) { Validate.notNull(garfioURL); Validate.isTrue(StringUtils.isNotBlank(garfioPassword)); this.garfioURL = garfioURL.toASCIIString(); this.garfioPassword = garfioPassword; } public TrackerSession getTrackerSession(final String repository, final String username, final CommentFormatter commentFormatter) { final Properties config = new Properties(); config.put(GARFIO_CONFIG_URL, garfioURL); config.put(GARFIO_CONFIG_PASS, garfioPassword); return module.getTrackerSession(commentFormatter, username, config); } }