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()); }
/** * Method updateNotifier * * @param value * @param element * @param counter * @param xmlTag */ //CHECKSTYLE_OFF: LineLength protected void updateNotifier( Notifier value, String xmlTag, Counter counter, Element element ) { Element root = element; Counter innerCount = new Counter( counter.getDepth() + 1 ); findAndReplaceSimpleElement( innerCount, root, "type", value.getType(), "mail" ); findAndReplaceSimpleElement( innerCount, root, "sendOnError", value.isSendOnError() ? null : String.valueOf( value.isSendOnError() ), "true" ); findAndReplaceSimpleElement( innerCount, root, "sendOnFailure", value.isSendOnFailure() ? null : String.valueOf( value.isSendOnFailure() ), "true" ); findAndReplaceSimpleElement( innerCount, root, "sendOnSuccess", value.isSendOnSuccess() ? null : String.valueOf( value.isSendOnSuccess() ), "true" ); findAndReplaceSimpleElement( innerCount, root, "sendOnWarning", value.isSendOnWarning() ? null : String.valueOf( value.isSendOnWarning() ), "true" ); findAndReplaceSimpleElement( innerCount, root, "address", value.getAddress(), null ); findAndReplaceProperties( innerCount, root, "configuration", value.getConfiguration() ); }
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 ); } } }
private void visitCiManagementNotifier( ModelVisitor visitor, Notifier notifier ) { Properties configuration = notifier.getConfiguration(); if ( configuration != null ) { Iterator<Entry<Object, Object>> configurationElementIterator = configuration.entrySet().iterator(); while ( configurationElementIterator.hasNext() ) { Entry<Object, Object> configurationElement = configurationElementIterator.next(); String configurationElementKey = (String) configurationElement.getKey(); String configurationElementValue = (String) configurationElement.getKey(); visitor.visitCiManagementNotifierConfiguration( configurationElementKey, configurationElementValue ); configurationElementValue = visitor.replaceCiManagementNotifierConfiguration( configurationElementKey, configurationElementValue ); if ( configurationElementValue == null ) configurationElementIterator.remove(); else configurationElement.setValue( configurationElementValue ); } } }
/** * Method updateNotifier * * @param value * @param element * @param counter * @param xmlTag */ protected void updateNotifier( Notifier value, String xmlTag, Counter counter, Element element ) { Element root = element; Counter innerCount = new Counter( counter.getDepth() + 1 ); findAndReplaceSimpleElement( innerCount, root, "type", value.getType(), "mail" ); findAndReplaceSimpleElement( innerCount, root, "sendOnError", value.isSendOnError() ? null : String.valueOf( value.isSendOnError() ), "true" ); findAndReplaceSimpleElement( innerCount, root, "sendOnFailure", value.isSendOnFailure() ? null : String.valueOf( value.isSendOnFailure() ), "true" ); findAndReplaceSimpleElement( innerCount, root, "sendOnSuccess", value.isSendOnSuccess() ? null : String.valueOf( value.isSendOnSuccess() ), "true" ); findAndReplaceSimpleElement( innerCount, root, "sendOnWarning", value.isSendOnWarning() ? null : String.valueOf( value.isSendOnWarning() ), "true" ); findAndReplaceSimpleElement( innerCount, root, "address", value.getAddress(), null ); findAndReplaceProperties( innerCount, root, "configuration", value.getConfiguration() ); }
protected void mergeNotifier_Configuration( Notifier target, Notifier source, boolean sourceDominant, Map<Object, Object> context ) { Properties merged = new Properties(); if ( sourceDominant ) { merged.putAll( target.getConfiguration() ); merged.putAll( source.getConfiguration() ); } else { merged.putAll( source.getConfiguration() ); merged.putAll( target.getConfiguration() ); } target.setConfiguration( merged ); }
private void writeNotifier(Notifier notifier, String tagName, XmlSerializer serializer) throws java.io.IOException { serializer.startTag(NAMESPACE, tagName); flush(serializer); StringBuffer b = b(serializer); int start = b.length(); if ((notifier.getType() != null) && !notifier.getType().equals("mail")) { writeValue(serializer, "type", notifier.getType(), notifier); } if (notifier.isSendOnError() != true) { writeValue(serializer, "sendOnError", String.valueOf(notifier.isSendOnError()), notifier); } if (notifier.isSendOnFailure() != true) { writeValue(serializer, "sendOnFailure", String.valueOf(notifier.isSendOnFailure()), notifier); } if (notifier.isSendOnSuccess() != true) { writeValue(serializer, "sendOnSuccess", String.valueOf(notifier.isSendOnSuccess()), notifier); } if (notifier.isSendOnWarning() != true) { writeValue(serializer, "sendOnWarning", String.valueOf(notifier.isSendOnWarning()), notifier); } if (notifier.getAddress() != null) { writeValue(serializer, "address", notifier.getAddress(), notifier); } if ((notifier.getConfiguration() != null) && (notifier.getConfiguration().size() > 0)) { serializer.startTag(NAMESPACE, "configuration"); for (Iterator iter = notifier.getConfiguration().keySet().iterator(); iter.hasNext();) { String key = (String) iter.next(); String value = (String) notifier.getConfiguration().get(key); serializer.startTag(NAMESPACE, "" + key + "").text(value).endTag(NAMESPACE, "" + key + ""); } serializer.endTag(NAMESPACE, "configuration"); } serializer.endTag(NAMESPACE, tagName).flush(); logLocation(notifier, "", start, b.length()); }
protected void mergeNotifier( Notifier target, Notifier source, boolean sourceDominant, Map<Object, Object> context ) { mergeNotifier_Type( target, source, sourceDominant, context ); mergeNotifier_Address( target, source, sourceDominant, context ); mergeNotifier_Configuration( target, source, sourceDominant, context ); mergeNotifier_SendOnError( target, source, sourceDominant, context ); mergeNotifier_SendOnFailure( target, source, sourceDominant, context ); mergeNotifier_SendOnSuccess( target, source, sourceDominant, context ); mergeNotifier_SendOnWarning( target, source, sourceDominant, context ); }
protected void mergeNotifier_Type( Notifier target, Notifier source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getType(); if ( src != null ) { if ( sourceDominant || target.getType() == null ) { target.setType( src ); } } }
protected void mergeNotifier_Address( Notifier target, Notifier source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getAddress(); if ( src != null ) { if ( sourceDominant || target.getAddress() == null ) { target.setAddress( src ); } } }
protected void mergeNotifier_SendOnError( Notifier target, Notifier source, boolean sourceDominant, Map<Object, Object> context ) { if ( sourceDominant ) { target.setSendOnError( source.isSendOnError() ); } }
protected void mergeNotifier_SendOnFailure( Notifier target, Notifier source, boolean sourceDominant, Map<Object, Object> context ) { if ( sourceDominant ) { target.setSendOnFailure( source.isSendOnFailure() ); } }
protected void mergeNotifier_SendOnSuccess( Notifier target, Notifier source, boolean sourceDominant, Map<Object, Object> context ) { if ( sourceDominant ) { target.setSendOnSuccess( source.isSendOnSuccess() ); } }
protected void mergeNotifier_SendOnWarning( Notifier target, Notifier source, boolean sourceDominant, Map<Object, Object> context ) { if ( sourceDominant ) { target.setSendOnWarning( source.isSendOnWarning() ); } }
@Override public Notifier replaceCiManagementNotifier( Notifier notifier ) { return notifier; }
@Override public void visitCiManagementNotifier( Notifier notifier ) { }
/** * Method iterateNotifier * * @param counter * @param childTag * @param parentTag * @param list * @param parent */ protected void iterateNotifier( Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag ) { boolean shouldExist = list != null && list.size() > 0; Element element = updateElement( counter, parent, parentTag, shouldExist ); if ( shouldExist ) { Iterator it = list.iterator(); Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator(); if ( !elIt.hasNext() ) { elIt = null; } Counter innerCount = new Counter( counter.getDepth() + 1 ); while ( it.hasNext() ) { Notifier value = (Notifier) it.next(); Element el; if ( elIt != null && elIt.hasNext() ) { el = (Element) elIt.next(); if ( !elIt.hasNext() ) { elIt = null; } } else { el = factory.element( childTag, element.getNamespace() ); insertAtPreferredLocation( element, el, innerCount ); } updateNotifier( value, childTag, innerCount, el ); innerCount.increaseCount(); } if ( elIt != null ) { while ( elIt.hasNext() ) { elIt.next(); elIt.remove(); } } } }
protected Object getNotifierKey( Notifier object ) { return object; }
Notifier replaceCiManagementNotifier( Notifier notifier );
void visitCiManagementNotifier( Notifier notifier );