private void writeCiManagement(CiManagement ciManagement, String tagName, XmlSerializer serializer) throws java.io.IOException { serializer.startTag(NAMESPACE, tagName); flush(serializer); StringBuffer b = b(serializer); int start = b.length(); if (ciManagement.getSystem() != null) { writeValue(serializer, "system", ciManagement.getSystem(), ciManagement); } if (ciManagement.getUrl() != null) { writeValue(serializer, "url", ciManagement.getUrl(), ciManagement); } if ((ciManagement.getNotifiers() != null) && (ciManagement.getNotifiers().size() > 0)) { serializer.startTag(NAMESPACE, "notifiers"); for (Iterator iter = ciManagement.getNotifiers().iterator(); iter.hasNext();) { Notifier o = (Notifier) iter.next(); writeNotifier(o, "notifier", serializer); } serializer.endTag(NAMESPACE, "notifiers"); } serializer.endTag(NAMESPACE, tagName).flush(); logLocation(ciManagement, "", start, b.length()); }
private void visitCiManagement( ModelVisitor visitor, CiManagement ciManagement ) { List<Notifier> notifiers = ciManagement.getNotifiers(); if ( notifiers != null ) { ListIterator<Notifier> notifierIterator = notifiers.listIterator(); while ( notifierIterator.hasNext() ) { Notifier notifier = notifierIterator.next(); visitor.visitCiManagementNotifier( notifier ); visitCiManagementNotifier( visitor, notifier ); notifier = visitor.replaceCiManagementNotifier( notifier ); if ( notifier == null ) notifierIterator.remove(); else notifierIterator.set( notifier ); } } }
/** * Method updateCiManagement * * @param value * @param element * @param counter * @param xmlTag */ protected void updateCiManagement( CiManagement value, String xmlTag, Counter counter, Element element ) { boolean shouldExist = value != null; Element root = updateElement( counter, element, xmlTag, shouldExist ); if ( shouldExist ) { Counter innerCount = new Counter( counter.getDepth() + 1 ); findAndReplaceSimpleElement( innerCount, root, "system", value.getSystem(), null ); findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null ); iterateNotifier( innerCount, root, value.getNotifiers(), "notifiers", "notifier" ); } }
private org.apache.archiva.metadata.model.CiManagement convertCiManagement( CiManagement ciManagement ) { org.apache.archiva.metadata.model.CiManagement ci = null; if ( ciManagement != null ) { ci = new org.apache.archiva.metadata.model.CiManagement(); ci.setSystem( ciManagement.getSystem() ); ci.setUrl( ciManagement.getUrl() ); } return ci; }
protected void mergeCiManagement( CiManagement target, CiManagement source, boolean sourceDominant, Map<Object, Object> context ) { mergeCiManagement_System( target, source, sourceDominant, context ); mergeCiManagement_Url( target, source, sourceDominant, context ); mergeCiManagement_Notifiers( target, source, sourceDominant, context ); }
protected void mergeCiManagement_System( CiManagement target, CiManagement source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getSystem(); if ( src != null ) { if ( sourceDominant || target.getSystem() == null ) { target.setSystem( src ); target.setLocation( "system", source.getLocation( "system" ) ); } } }
protected void mergeCiManagement_Url( CiManagement target, CiManagement source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getUrl(); if ( src != null ) { if ( sourceDominant || target.getUrl() == null ) { target.setUrl( src ); target.setLocation( "url", source.getLocation( "url" ) ); } } }
public CiManagement getCiManagement() { return null; }
@Override public CiManagement replaceCiManagement( CiManagement ciManagement ) { return ciManagement; }
@Override public void visitCiManagement( CiManagement ciManagement ) { }
@Override public CiManagement get( Model model ) { return model.getCiManagement(); }
@Override public void set( Model model, CiManagement value ) { model.setCiManagement( value ); }
public CiManagement getCiManagement() { return getModel().getCiManagement(); }
public void setCiManagement( CiManagement ciManagement ) { getModel().setCiManagement( ciManagement ); }
/** * Attempt to create new jenkins client instance. If credentials are null, attempt to connect without authentication. * * @return null on failure */ private JenkinsClient setupJenkins(String url, String user, String token, CiManagement ciManagement) throws MojoExecutionException { String savedUrl = config.get("jenkinsUrl"); String savedUser = config.get("jenkinsUser"); String savedToken = config.get("jenkinsToken"); if (url == null) { if(savedUrl != null) { url = savedUrl; } else { // try to use <ciManagement> if(ciManagement != null && Pattern.matches(CI_MANAGEMENT_SYSTEM_NAME_PATTERN, ciManagement.getSystem()) && ciManagement.getUrl() != null) { url = ciManagement.getUrl(); log.info("Using Jenkins URL from <ciManagement> settings in POM."); } else { if(ciManagement != null) { log.warn("<ciManagement> settings found in POM but could not be used " + "because the CI system name does not match '"+ CI_MANAGEMENT_SYSTEM_NAME_PATTERN +"' " + "pattern or the URL is not set."); } } } } if (user == null) user = savedUser; if (token == null) token = savedToken; if (url == null) fail("Jenkins URL is a required parameter:\n" + "* 'jenkinsUrl' parameter is null.\n" + "* There is no suitable <ciManagement> setting in POM.\n" + "* There is no saved URL from previous executions.\n" + "URL must point to the root of the server."); // this is to avoid problems when connecting via https System.setProperty("jsse.enableSNIExtension", "false"); JenkinsClient jc; if (user == null || token == null) { jc = JenkinsClientFactory.createClient(url, log); // TODO url as argument? log.debug("Setting up the jenkins client without authentication."); } else { jc = JenkinsClientFactory.createClient(url, user, token, log); log.debug("Setting up the jenkins client with authentication."); } if (jc == null) { fail("Failed to connect to Jenkins. " + "Check if the server is accessible and URL (" + url + ") and credentials" + " (user = '" + user + "', token = '" + token + "') are correct."); } else { log.debug("Saving Jenkins access config."); config.put("jenkinsUrl", url); config.put("jenkinsUser", user); config.put("jenkinsToken", token); } return jc; }
@Override public CiManagement getCiManagement() { return getDelegate().getCiManagement(); }
@Override public void setCiManagement(final CiManagement management) { getDelegate().setCiManagement(management); }
public void setCiManagement( CiManagement ciManagement ) { }
CiManagement replaceCiManagement( CiManagement ciManagement );
void visitCiManagement( CiManagement ciManagement );