@POST
 @Path(PATH_RELATIONSHIP_EXTENSION_METHOD)
 public Response invokeRelationshipExtension(
     @PathParam("name") String name,
     @PathParam("method") String method,
     @PathParam("relationshipId") long relationshipId,
     String data) {
   try {
     return output.ok(
         this.invokeRelationshipExtension(
             relationshipId, name, method, input.readParameterList(data)));
   } catch (RelationshipNotFoundException e) {
     return output.notFound(e);
   } catch (BadInputException e) {
     return output.badRequest(e);
   } catch (PluginLookupException e) {
     return output.notFound(e);
   } catch (BadPluginInvocationException e) {
     return output.badRequest(e.getCause());
   } catch (PluginInvocationFailureException e) {
     return output.serverError(e.getCause());
   } catch (Exception e) {
     return output.serverError(e.getCause());
   }
 }
Example #2
0
  @GET
  public Response getServiceDefinition() {
    ConsoleServiceRepresentation result =
        new ConsoleServiceRepresentation(SERVICE_PATH, sessionFactory.supportedEngines());

    return output.ok(result);
  }
 @GET
 @Path(PATH_EXTENSION)
 public Response getExtensionList(@PathParam("name") String name) {
   try {
     return output.ok(this.extensionList(name));
   } catch (PluginLookupException e) {
     return output.notFound(e);
   }
 }
 @GET
 @Path(PATH_GRAPHDB_EXTENSION_METHOD)
 public Response getGraphDatabaseExtensionDescription(
     @PathParam("name") String name, @PathParam("method") String method) {
   try {
     return output.ok(this.describeGraphDatabaseExtension(name, method));
   } catch (PluginLookupException e) {
     return output.notFound(e);
   }
 }
Example #5
0
  @POST
  public Response exec(@Context InputFormat input, String data) {
    Map<String, Object> args;
    try {
      args = input.readMap(data);
    } catch (BadInputException e) {
      return output.badRequest(e);
    }

    if (!args.containsKey("command")) {
      return Response.status(Status.BAD_REQUEST)
          .entity("Expected command argument not present.")
          .build();
    }

    ScriptSession scriptSession;
    try {
      scriptSession = getSession(args);
    } catch (IllegalArgumentException e) {
      return output.badRequest(e);
    }

    log.debug(scriptSession.toString());
    try {
      Pair<String, String> result = scriptSession.evaluate((String) args.get("command"));
      List<Representation> list =
          new ArrayList<Representation>(
              asList(
                  ValueRepresentation.string(result.first()),
                  ValueRepresentation.string(result.other())));

      return output.ok(new ListRepresentation(RepresentationType.STRING, list));
    } catch (Exception e) {
      List<Representation> list =
          new ArrayList<Representation>(
              asList(
                  ValueRepresentation.string(e.getClass() + " : " + e.getMessage() + "\n"),
                  ValueRepresentation.string(null)));
      return output.ok(new ListRepresentation(RepresentationType.STRING, list));
    }
  }
  @GET
  @Produces(MediaType.APPLICATION_JSON)
  public Response getDiscoveryDocument() throws URISyntaxException {
    String webAdminManagementUri =
        configuration.getString(
            Configurator.MANAGEMENT_PATH_PROPERTY_KEY, Configurator.DEFAULT_MANAGEMENT_API_PATH);
    String dataUri =
        configuration.getString(
            Configurator.REST_API_PATH_PROPERTY_KEY, Configurator.DEFAULT_DATA_API_PATH);

    DiscoveryRepresentation dr = new DiscoveryRepresentation(webAdminManagementUri, dataUri);
    return outputFormat.ok(dr);
  }
 @GET
 @Path(PATH_RELATIONSHIP_EXTENSION_METHOD)
 public Response getRelationshipExtensionDescription(
     @PathParam("name") String name,
     @PathParam("method") String method,
     @PathParam("relationshipId") long relationshipId) {
   try {
     return output.ok(this.describeRelationshipExtension(name, method));
   } catch (PluginLookupException e) {
     return output.notFound(e);
   } catch (Exception e) {
     return output.serverError(e.getCause());
   }
 }
 @POST
 @Path(PATH_GRAPHDB_EXTENSION_METHOD)
 public Response invokeGraphDatabaseExtension(
     @PathParam("name") String name, @PathParam("method") String method, String data) {
   try {
     return output.ok(
         this.invokeGraphDatabaseExtension(name, method, input.readParameterList(data)));
   } catch (BadInputException e) {
     return output.badRequest(e);
   } catch (PluginLookupException e) {
     return output.notFound(e);
   } catch (BadPluginInvocationException e) {
     return output.badRequest(e.getCause());
   } catch (SyntaxException e) {
     return output.badRequest(e.getCause());
   } catch (PluginInvocationFailureException e) {
     return output.serverError(e.getCause());
   } catch (Exception e) {
     return output.serverError(e);
   }
 }
 @GET
 public Response getExtensionsList() {
   return output.ok(this.extensionsList());
 }