use of org.openntf.domino.rest.service.IGraphFactory in project org.openntf.domino by OpenNTF.
the class InfoResource method performRequest.
@GET
@Produces(MediaType.APPLICATION_JSON)
@SuppressWarnings("nls")
public Response performRequest(@Context final UriInfo uriInfo, @PathParam(Routes.NAMESPACE) final String namespace) throws JsonException, IOException {
String jsonEntity = null;
ResponseBuilder builder = Response.ok();
ParamMap pm = Parameters.toParamMap(uriInfo);
StringWriter sw = new StringWriter();
DFramedTransactionalGraph<?> graph = this.getGraph(namespace);
JsonGraphWriter writer = new JsonGraphWriter(sw, graph, pm, false, true, false);
// writer.outObject(null);
List<String> items = pm.get(Parameters.ITEM);
if (items != null && items.size() > 0) {
IGraphFactory factory = this.getService().getFactory(namespace);
if (factory != null) {
for (String item : items) {
Object curResult = factory.processRequest(namespace, item, uriInfo.getQueryParameters());
writer.outObject(curResult);
}
} else {
System.err.println("No Factory found for namespace: " + namespace);
}
}
jsonEntity = sw.toString();
builder.type(MediaType.APPLICATION_JSON_TYPE).entity(jsonEntity);
Response response = builder.build();
return response;
}
use of org.openntf.domino.rest.service.IGraphFactory in project org.openntf.domino by OpenNTF.
the class CommandResource method performCommand.
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response performCommand(@Context final UriInfo uriInfo, @PathParam(Routes.NAMESPACE) final String namespace) throws JsonException, IOException {
String jsonEntity = null;
ResponseBuilder builder = Response.ok();
ParamMap pm = Parameters.toParamMap(uriInfo);
StringWriter sw = new StringWriter();
DFramedTransactionalGraph<?> graph = this.getGraph(namespace);
JsonGraphWriter writer = new JsonGraphWriter(sw, graph, pm, false, true, false);
// writer.outObject(null);
List<String> commands = pm.get(Parameters.COMMAND);
if (commands != null && commands.size() > 0) {
IGraphFactory factory = this.getService().getFactory(namespace);
if (factory != null) {
for (String command : commands) {
// System.out.println("TEMP DEBUG processing command " +
// command + " in namespace " + namespace);
Object curResult = factory.processCommand(namespace, command, uriInfo.getQueryParameters());
writer.outObject(curResult);
}
} else {
System.err.println("No Factory found for namespace: " + namespace);
}
}
jsonEntity = sw.toString();
builder.type(MediaType.APPLICATION_JSON_TYPE).entity(jsonEntity);
Response response = builder.build();
return response;
}
Aggregations