use of net.sourceforge.plantuml.png.MetadataTag in project plantuml-server by plantuml.
the class PlantUmlServlet method doGet.
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
request.setCharacterEncoding("UTF-8");
String text = request.getParameter("text");
String metadata = request.getParameter("metadata");
if (metadata != null) {
InputStream img = null;
try {
img = getImage(new URL(metadata));
MetadataTag metadataTag = new MetadataTag(img, "plantuml");
String data = metadataTag.getData();
if (data != null) {
text = data;
}
} finally {
if (img != null) {
img.close();
}
}
}
try {
text = getTextFromUrl(request, text);
} catch (Exception e) {
e.printStackTrace();
}
// no Text form has been submitted
if (text == null || text.trim().isEmpty()) {
redirectNow(request, response, DEFAULT_ENCODED_TEXT);
return;
}
final String encoded = getTranscoder().encode(text);
request.setAttribute("decoded", text);
request.setAttribute("encoded", encoded);
// check if an image map is necessary
if (text != null && PlantumlUtils.hasCMapData(text)) {
request.setAttribute("mapneeded", Boolean.TRUE);
}
// forward to index.jsp
final RequestDispatcher dispatcher = request.getRequestDispatcher("/index.jsp");
dispatcher.forward(request, response);
}
use of net.sourceforge.plantuml.png.MetadataTag in project jqa-core-framework by buschmais.
the class ExecutablesTest method plantuml.
@Test
void plantuml() throws Exception {
RuleSet ruleSet = RuleSetTestHelper.readRuleSet("/executables.adoc", RuleConfiguration.DEFAULT);
Concept concept = verifyConceptExecutable(ruleSet, "test:PlantUML", SourceExecutable.class, StructuralNode.class, "plantuml");
StructuralNode abstractBlock = (StructuralNode) concept.getExecutable().getSource();
String imagesDirectoryAttribute = (String) abstractBlock.getDocument().getAttributes().get(AsciidoctorFactory.ATTRIBUTE_IMAGES_OUT_DIR);
assertThat(imagesDirectoryAttribute, notNullValue());
File imagesOutDir = new File(imagesDirectoryAttribute);
assertThat(imagesOutDir.exists(), equalTo(true));
String fileName = (String) abstractBlock.getAttributes().get("target");
assertThat(fileName, notNullValue());
File diagramFile = new File(imagesOutDir, fileName);
assertThat("Expected file " + diagramFile + " does not exist.", diagramFile.exists(), equalTo(true));
String diagramMetadata = new MetadataTag(diagramFile, "plantuml").getData();
assertThat(diagramMetadata, containsString("@startuml"));
assertThat(diagramMetadata, containsString("@enduml"));
}
Aggregations