in src/main/java/org/apache/maven/plugin/doap/DoapMojo.java [1591:1669]
private void writeContributor(
XMLWriter writer, Contributor developerOrContributor, String xmlsPrefix, String doapType) {
if (developerOrContributor == null) {
return;
}
if (doapType == null || doapType.isEmpty()) {
throw new IllegalArgumentException("doapType is required.");
}
String name = developerOrContributor.getName();
String email = developerOrContributor.getEmail();
String organization = developerOrContributor.getOrganization();
String organizationUrl = developerOrContributor.getOrganizationUrl();
String homepage = developerOrContributor.getUrl();
String nodeId = null;
// Name is required to write doap
if (name == null || name.isEmpty()) {
messages.addMessage(
new String[] {"project", "developers|contributors", "developer|contributor", "name"},
null,
UserMessages.REQUIRED);
return;
}
if (!(organization == null || organization.isEmpty())
|| !(organizationUrl == null || organizationUrl.isEmpty())) {
DoapUtil.Organization doapOrganization = DoapUtil.addOrganization(organization, organizationUrl);
nodeId = DoapUtil.getNodeId();
doapOrganization.addMember(nodeId);
}
DoapUtil.writeStartElement(writer, xmlsPrefix, doapType);
DoapUtil.writeStartElement(writer, "foaf", "Person");
if (nodeId != null && !nodeId.isEmpty()) {
writer.addAttribute("rdf:nodeID", nodeId);
}
DoapUtil.writeStartElement(writer, "foaf", "name");
writer.writeText(name);
writer.endElement(); // foaf:name
if (email != null && !email.isEmpty()) {
if (DoapUtil.isValidEmail(email)) {
DoapUtil.writeRdfResourceElement(writer, "foaf", "mbox", "mailto:" + email);
} else {
messages.addMessage(
new String[] {"project", "developers|contributors", "developer|contributor", "email"},
null,
UserMessages.INVALID_EMAIL);
}
}
if ((organization != null && !organization.isEmpty())
&& (organizationUrl != null && !organizationUrl.isEmpty())) {
try {
new URL(organizationUrl);
DoapUtil.addOrganization(organization, organizationUrl);
} catch (MalformedURLException e) {
messages.addMessage(
new String[] {"project", "developers|contributors", "developer|contributor", "organizationUrl"},
organizationUrl,
UserMessages.INVALID_URL);
}
}
if (homepage != null && !homepage.isEmpty()) {
try {
new URL(homepage);
DoapUtil.writeRdfResourceElement(writer, "foaf", "homepage", homepage);
} catch (MalformedURLException e) {
messages.addMessage(
new String[] {"project", "developers|contributors", "developer|contributor", "homepage"},
homepage,
UserMessages.INVALID_URL);
}
}
writer.endElement(); // foaf:Person
writer.endElement(); // doapType
}