private List<org.apache.archiva.metadata.model.MailingList> convertMailingLists( List<MailingList> mailingLists ) { List<org.apache.archiva.metadata.model.MailingList> l = new ArrayList<>(); for ( MailingList mailingList : mailingLists ) { org.apache.archiva.metadata.model.MailingList newMailingList = new org.apache.archiva.metadata.model.MailingList(); newMailingList.setName( mailingList.getName() ); newMailingList.setMainArchiveUrl( mailingList.getArchive() ); newMailingList.setPostAddress( mailingList.getPost() ); newMailingList.setSubscribeAddress( mailingList.getSubscribe() ); newMailingList.setUnsubscribeAddress( mailingList.getUnsubscribe() ); newMailingList.setOtherArchives( mailingList.getOtherArchives() ); l.add( newMailingList ); } return l; }
private void visitMailingList( ModelVisitor visitor, MailingList mailingList ) { List<String> otherArchives = mailingList.getOtherArchives(); if ( otherArchives != null ) { ListIterator<String> otherArchiveIterator = otherArchives.listIterator(); while ( otherArchiveIterator.hasNext() ) { String otherArchive = otherArchiveIterator.next(); visitor.visitMailingListOtherArchive( otherArchive ); otherArchive = visitor.replaceMailingListOtherArchive( otherArchive ); if ( otherArchive == null ) otherArchiveIterator.remove(); else otherArchiveIterator.set( otherArchive ); } } }
private void writeMailingList(MailingList mailingList, String tagName, XmlSerializer serializer) throws java.io.IOException { serializer.startTag(NAMESPACE, tagName); flush(serializer); StringBuffer b = b(serializer); int start = b.length(); if (mailingList.getName() != null) { writeValue(serializer, "name", mailingList.getName(), mailingList); } if (mailingList.getSubscribe() != null) { writeValue(serializer, "subscribe", mailingList.getSubscribe(), mailingList); } if (mailingList.getUnsubscribe() != null) { writeValue(serializer, "unsubscribe", mailingList.getUnsubscribe(), mailingList); } if (mailingList.getPost() != null) { writeValue(serializer, "post", mailingList.getPost(), mailingList); } if (mailingList.getArchive() != null) { writeValue(serializer, "archive", mailingList.getArchive(), mailingList); } if ((mailingList.getOtherArchives() != null) && (mailingList.getOtherArchives().size() > 0)) { serializer.startTag(NAMESPACE, "otherArchives"); flush(serializer); InputLocation otherLoc = mailingList.getLocation("otherArchives"); int index = 0; for (Iterator iter = mailingList.getOtherArchives().iterator(); iter.hasNext();) { String otherArchive = (String) iter.next(); writeValue(serializer, "otherArchive", otherArchive, otherLoc, index); index = index + 1; } serializer.endTag(NAMESPACE, "otherArchives"); } serializer.endTag(NAMESPACE, tagName).flush(); logLocation(mailingList, "", start, b.length()); }
/** * Method updateMailingList * * @param value * @param element * @param counter * @param xmlTag */ protected void updateMailingList( MailingList value, String xmlTag, Counter counter, Element element ) { Element root = element; Counter innerCount = new Counter( counter.getDepth() + 1 ); findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null ); findAndReplaceSimpleElement( innerCount, root, "subscribe", value.getSubscribe(), null ); findAndReplaceSimpleElement( innerCount, root, "unsubscribe", value.getUnsubscribe(), null ); findAndReplaceSimpleElement( innerCount, root, "post", value.getPost(), null ); findAndReplaceSimpleElement( innerCount, root, "archive", value.getArchive(), null ); findAndReplaceSimpleLists( innerCount, root, value.getOtherArchives(), "otherArchives", "otherArchive" ); }
public void testProjectInheritance() throws Exception { MavenProject p4 = getProject( projectFile( "p4" ) ); assertEquals( "p4", p4.getName() ); // ---------------------------------------------------------------------- // Value inherited from p3 // ---------------------------------------------------------------------- assertEquals( "2000", p4.getInceptionYear() ); // ---------------------------------------------------------------------- // Value taken from p2 // ---------------------------------------------------------------------- assertEquals( "mailing-list", ( (MailingList) p4.getMailingLists().get( 0 ) ).getName() ); // ---------------------------------------------------------------------- // Value taken from p1 // ---------------------------------------------------------------------- assertEquals( "scm-url/p2/p3/p4", p4.getScm().getUrl() ); // ---------------------------------------------------------------------- // Value taken from p4 // ---------------------------------------------------------------------- assertEquals( "Codehaus", p4.getOrganization().getName() ); // ---------------------------------------------------------------------- // Value taken from super model // ---------------------------------------------------------------------- assertEquals( "4.0.0", p4.getModelVersion() ); assertEquals( "4.0.0", p4.getModelVersion() ); }
protected void mergeMailingList( MailingList target, MailingList source, boolean sourceDominant, Map<Object, Object> context ) { mergeMailingList_Name( target, source, sourceDominant, context ); mergeMailingList_Subscribe( target, source, sourceDominant, context ); mergeMailingList_Unsubscribe( target, source, sourceDominant, context ); mergeMailingList_Post( target, source, sourceDominant, context ); mergeMailingList_OtherArchives( target, source, sourceDominant, context ); }
protected void mergeMailingList_Name( MailingList target, MailingList source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getName(); if ( src != null ) { if ( sourceDominant || target.getName() == null ) { target.setName( src ); target.setLocation( "name", source.getLocation( "name" ) ); } } }
protected void mergeMailingList_Subscribe( MailingList target, MailingList source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getSubscribe(); if ( src != null ) { if ( sourceDominant || target.getSubscribe() == null ) { target.setSubscribe( src ); target.setLocation( "subscribe", source.getLocation( "subscribe" ) ); } } }
protected void mergeMailingList_Unsubscribe( MailingList target, MailingList source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getUnsubscribe(); if ( src != null ) { if ( sourceDominant || target.getUnsubscribe() == null ) { target.setUnsubscribe( src ); target.setLocation( "unsubscribe", source.getLocation( "unsubscribe" ) ); } } }
protected void mergeMailingList_Post( MailingList target, MailingList source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getPost(); if ( src != null ) { if ( sourceDominant || target.getPost() == null ) { target.setPost( src ); target.setLocation( "post", source.getLocation( "post" ) ); } } }
protected void mergeMailingList_Archive( MailingList target, MailingList source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getArchive(); if ( src != null ) { if ( sourceDominant || target.getArchive() == null ) { target.setArchive( src ); target.setLocation( "archive", source.getLocation( "archive" ) ); } } }
protected void mergeMailingList_OtherArchives( MailingList target, MailingList source, boolean sourceDominant, Map<Object, Object> context ) { List<String> src = source.getOtherArchives(); if ( !src.isEmpty() ) { List<String> tgt = target.getOtherArchives(); List<String> merged = new ArrayList<String>( tgt.size() + src.size() ); merged.addAll( tgt ); merged.addAll( src ); target.setOtherArchives( merged ); } }
@Override protected void mergeModel_MailingLists( Model target, Model source, boolean sourceDominant, Map<Object, Object> context ) { if ( target.getMailingLists().isEmpty() ) { target.setMailingLists( new ArrayList<MailingList>( source.getMailingLists() ) ); } }
@Override public MailingList replaceMailingList( MailingList mailingList ) { return mailingList; }
@Override public void visitMailingList( MailingList mailingList ) { }
@Override public List<MailingList> get( Model model ) { return model.getMailingLists(); }
@Override public void set( Model model, List<MailingList> value ) { model.setMailingLists( value ); }
/** * Method iterateMailingList * * @param counter * @param childTag * @param parentTag * @param list * @param parent */ protected void iterateMailingList( 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() ) { MailingList value = (MailingList) 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 ); } updateMailingList( value, childTag, innerCount, el ); innerCount.increaseCount(); } if ( elIt != null ) { while ( elIt.hasNext() ) { elIt.next(); elIt.remove(); } } } }
public void setMailingLists( List<MailingList> mailingLists ) { getModel().setMailingLists( mailingLists ); }
public List<MailingList> getMailingLists() { return getModel().getMailingLists(); }
public void addMailingList( MailingList mailingList ) { getModel().addMailingList( mailingList ); }
protected Object getMailingListKey( MailingList object ) { return object; }
@Override public void addMailingList(final MailingList mailingList) { getDelegate().addMailingList(mailingList); }
public void addMailingList( MailingList mailingList ) { }
MailingList replaceMailingList( MailingList mailingList );
void visitMailingList( MailingList mailingList );