StringBuffer out = new StringBuffer();
try {
String id = incXML.substring(incXML.indexOf("<id>") + 4, incXML
.indexOf("</id>"));
TextBean textBean = null;
Collection<TextBean> col = null;
col = TextFinder.findByTextid(id);
Iterator<TextBean> it = col.iterator();
out.append(toXML("totalno", "1"));
out.append("<status>");
out.append("OK");
out.append("</status>\n");
out.append("<step>");
out.append("GETONE");
out.append("</step>\n");
out.append("<texts>\n");
// writes all but the rest of languages
if (it.hasNext()) {
textBean = it.next();
out.append("<entry>\n");
out.append(toXML("id", textBean.getId().toString()));
// out.append(toXML("text", textBean.getText()));
out.append(toXML("text", encode(textBean.getText())));
out.append(toXML("document", textBean.getDocument()));
out.append(toXML("tscreated", textBean.getTscreated()
.toString().substring(0, 16)));
if (null != textBean.getTsupdated()) {
out.append(toXML("tsupdated", textBean.getTsupdated()
.toString().substring(0, 16)));
} else {
out.append(toXML("tsupdated", ""));
}
out.append(toXML("createdby", textBean.getCreatedby()));
out.append(toXML("updatedby", textBean.getUpdatedby()));
out.append("<languages>\n");
out.append(toXML(textBean.getLanguageid(), encode(textBean
.getText())));
}
// if we have more languages write them
while (it.hasNext()) {
textBean = it.next();
out.append(toXML(textBean.getLanguageid(), encode(textBean
.getText())));
}
out.append("</languages>\n");
out.append("</entry>\n");
out.append("</texts>\n");