getServletContext().log(
"No directory data for: " + path, ex);
}
// Create Json response
JsonObject rsp = new JsonObject();
// Get the directory specific data
if ((directory != null) && (directory.isIndexingAllowedBoolean())) {
if (directory.getDescription() != null) {
rsp.addParameter(Configuration.dirDescParam, directory.getDescription());
}
if (directory.getLatitude() != null) {
rsp.addParameter(Configuration.latParam, directory.getLatitude());
}
if (directory.getLongitude() != null) {
rsp.addParameter(Configuration.lngParam, directory.getLongitude());
}
if (directory.getDate() != null) {
rsp.addParameter(Configuration.dirDateParam, directory.getDate());
}
rsp.addParameter(Configuration.groupParam,
(directory.getGroup() == null ? Configuration.publicGroup : directory.getGroup().getGroupName()));
List<Attribute> dirAttributes = directory.getAttributes();
if (dirAttributes != null) {
JsonArray attributes = new JsonArray();
for (Attribute attribute: dirAttributes) {
attributes.addItem(attribute.getName());
}
rsp.addParameter(Configuration.attrParam, attributes);
}
}
else {
rsp.addParameter(Configuration.dirDescParam, JsonEntity.NULL);
}
getServletContext().log("Json response: " + rsp.toString());
// Reply the Json response
response.setContentType(Configuration.jsonContentType);
response.setCharacterEncoding(Configuration.contentEncoding);
PrintWriter out = response.getWriter();
out.print(rsp.toString());
out.flush();
tx.commit();
} catch (AuthenticationException ex) {
getServletContext().log("Unauthorized user", ex);
tx.rollback();