use of org.jdom2.Content in project jspwiki by apache.
the class AtomFeed method getItems.
private Collection getItems() {
ArrayList<Element> list = new ArrayList<Element>();
WikiEngine engine = m_wikiContext.getEngine();
ServletContext servletContext = null;
if (m_wikiContext.getHttpRequest() != null)
servletContext = m_wikiContext.getHttpRequest().getSession().getServletContext();
for (Iterator i = m_entries.iterator(); i.hasNext(); ) {
Entry e = (Entry) i.next();
WikiPage p = e.getPage();
Element entryEl = getElement("entry");
//
// Mandatory elements
//
entryEl.addContent(getElement("id").setText(getEntryID(e)));
entryEl.addContent(getElement("title").setAttribute("type", "html").setText(e.getTitle()));
entryEl.addContent(getElement("updated").setText(DateFormatUtils.formatUTC(p.getLastModified(), RFC3339FORMAT)));
//
// Optional elements
//
entryEl.addContent(getElement("author").addContent(getElement("name").setText(e.getAuthor())));
entryEl.addContent(getElement("link").setAttribute("rel", "alternate").setAttribute("href", e.getURL()));
entryEl.addContent(getElement("content").setAttribute("type", "html").setText(e.getContent()));
if (engine.getAttachmentManager().hasAttachments(p) && servletContext != null) {
try {
Collection c = engine.getAttachmentManager().listAttachments(p);
for (Iterator a = c.iterator(); a.hasNext(); ) {
Attachment att = (Attachment) a.next();
Element attEl = getElement("link");
attEl.setAttribute("rel", "enclosure");
attEl.setAttribute("href", engine.getURL(WikiContext.ATTACH, att.getName(), null, true));
attEl.setAttribute("length", Long.toString(att.getSize()));
attEl.setAttribute("type", getMimeType(servletContext, att.getFileName()));
entryEl.addContent(attEl);
}
} catch (ProviderException ex) {
// FIXME: log.info("Can't get attachment data",ex);
}
}
list.add(entryEl);
}
return list;
}
use of org.jdom2.Content in project pom-manipulation-ext by release-engineering.
the class PomIO method write.
private void write(final Project project, final File pom, final Model model) throws ManipulationException {
try {
final String manifestInformation = project.isInheritanceRoot() ? ManifestUtils.getManifestInformation() : null;
MavenJDOMWriter mjw = new MavenJDOMWriter(model);
// We possibly could store the EOL type in the Project when we first read
// the file but we would then have to do a dual read, then write as opposed
// to a read, then read + write now.
LineSeparator ls = determineEOL(pom);
mjw.setLineSeparator(ls);
mjw.write(model, pom, new DocumentModifier() {
@Override
public void postProcess(final Document doc) {
// Only add the modified by to the top level pom.
if (project.isExecutionRoot()) {
final Iterator<Content> it = doc.getContent(new ContentFilter(ContentFilter.COMMENT)).iterator();
while (it.hasNext()) {
final Comment c = (Comment) it.next();
if (c.toString().contains(MODIFIED_BY)) {
it.remove();
}
}
doc.addContent(Collections.<Content>singletonList(new Comment("\nModified by POM Manipulation Extension for Maven " + manifestInformation + "\n")));
}
}
});
} catch (final IOException e) {
throw new ManipulationException("Failed to read POM for rewrite: %s. Reason: %s", e, pom, e.getMessage());
} catch (final JDOMException e) {
throw new ManipulationException("Failed to parse POM for rewrite: %s. Reason: %s", e, pom, e.getMessage());
}
}
use of org.jdom2.Content in project qpp-conversion-tool by CMSgov.
the class Converter method transform.
/**
* Transform the content in a given input stream
*
* @param inStream source content
* @return a transformed representation of the source content
* @throws XmlException during transform
*/
private JsonWrapper transform(InputStream inStream) {
Element doc = XmlUtils.parseXmlStream(inStream);
decoded = XmlDecoderEngine.decodeXml(context, doc);
JsonWrapper qpp = null;
if (null != decoded) {
DEV_LOG.info("Decoded template ID {}", decoded.getType());
if (!context.isDoDefaults()) {
DefaultDecoder.removeDefaultNode(decoded.getChildNodes());
}
if (context.isDoValidation()) {
QrdaValidator validator = new QrdaValidator(context);
details.addAll(validator.validate(decoded));
}
if (details.isEmpty()) {
qpp = encode();
}
} else {
Detail detail = Detail.forErrorCode(ErrorCode.NOT_VALID_QRDA_DOCUMENT.format(Context.REPORTING_YEAR, Context.IG_URL));
details.add(detail);
}
return qpp;
}
use of org.jdom2.Content in project aws-doc-sdk-examples by awsdocs.
the class SendNotifications method handleVoiceMessage.
public String handleVoiceMessage(String myDom) throws JDOMException, IOException {
String mobileNum = "";
List<String> listVal = new ArrayList<>();
listVal.add("application/json");
Map<String, List<String>> values = new HashMap<>();
values.put("Content-Type", listVal);
ClientOverrideConfiguration config2 = ClientOverrideConfiguration.builder().headers(values).build();
PinpointSmsVoiceClient client = PinpointSmsVoiceClient.builder().overrideConfiguration(config2).region(Region.US_EAST_1).build();
SAXBuilder builder = new SAXBuilder();
Document jdomDocument = builder.build(new InputSource(new StringReader(myDom)));
org.jdom2.Element root = jdomDocument.getRootElement();
// get a list of children elements.
List<org.jdom2.Element> students = root.getChildren("Student");
for (org.jdom2.Element element : students) {
mobileNum = element.getChildText("Phone");
sendVoiceMsg(client, mobileNum);
}
client.close();
return mobileNum;
}
use of org.jdom2.Content in project jena by apache.
the class GMLWriter method buildPolygon.
private static Element buildPolygon(final Polygon polygon, final String srsName) {
Element gmlRoot = new Element(polygon.getGeometryType(), GML_NAMESPACE);
gmlRoot.setAttribute("srsName", srsName);
if (!polygon.isEmpty()) {
LineString lineString = polygon.getExteriorRing();
CustomCoordinateSequence coordSequence = (CustomCoordinateSequence) lineString.getCoordinateSequence();
// Find exterior shell
Element exterior = new Element("exterior", GML_NAMESPACE);
Element exteriorLinearRing = new Element("LinearRing", GML_NAMESPACE);
Element exteriorPosList = new Element("posList", GML_NAMESPACE);
exteriorPosList.addContent(convertToGMLText(coordSequence));
exteriorLinearRing.addContent(exteriorPosList);
exterior.addContent(exteriorLinearRing);
gmlRoot.addContent(exterior);
// Find inner holes
int interiorRings = polygon.getNumInteriorRing();
for (int i = 0; i < interiorRings; i++) {
// flush all content
Element interior = new Element("interior", GML_NAMESPACE);
Element interiorLinearRing = new Element("LinearRing", GML_NAMESPACE);
Element innerPosList = new Element("posList", GML_NAMESPACE);
LineString innerLineString = polygon.getInteriorRingN(i);
CustomCoordinateSequence innerCoordSequence = (CustomCoordinateSequence) innerLineString.getCoordinateSequence();
innerPosList.addContent(convertToGMLText(innerCoordSequence));
interiorLinearRing.addContent(innerPosList);
interior.addContent(interiorLinearRing);
gmlRoot.addContent(interior);
}
} else {
// Do nothing to the GML
}
return gmlRoot;
}
Aggregations