public boolean addProject(final Project project, final RedmineRepositoryConfig config) throws IOException, SAXException { LOGGER.info("Redmine add Project: " + project.getName()); _redmineProject = new com.taskadapter.redmineapi.bean.Project(); _redmineProject.setName(project.getName()); _redmineProject.setIdentifier(getRedmineId(project)); _redmineProject.setDescription(project.getDescription()); try { _redmineProject = _mgr.createProject(_redmineProject); return true; } catch (RedmineException e) { e.printStackTrace(); return false; } }
/** * @throws SAXException * @throws IOException * @throws MalformedURLException */ private void postData( final RedmineRepositoryConfig config, final Project project, final SCMConnectorConfig scmConfig, final String username, final String password, final String scm) { LOGGER.info("Redmine add Repository: " + scmConfig.getScmUrl()); // Check if Repository should be added if (!config.isAddRepositoryConfiguration()) { LOGGER.debug("Repository config is disabled"); return; } List<Cookie> cookies = (List<Cookie>) _wt.getDialog().getCookies(); for (Cookie cookie : cookies) { LOGGER.debug("Cookie: {}", cookie); _wc.putCookie(cookie.getName(), cookie.getValue()); } PostMethodWebRequest form = new PostMethodWebRequest( config.getServer().getUrl() + "/projects/" + project.getName() + "/repositories"); form.setParameter("authenticity_token", getAuthenticityToken(_wt.getPageSource())); form.setParameter("repository_scm", scm); form.setParameter("repository[url]", scmConfig.getProjectScmUrl(project.getName())); form.setParameter("repository[login]", username); form.setParameter("repository[password]", password); form.setParameter("commit", "Create"); try { LOGGER.debug("Posting: {}", form); _wc.getResponse(form); LOGGER.debug("Posted"); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SAXException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
private String getRedmineId(final Project project) { return project.getName(); }