示例#1
0
 @GET
 @Path("/settings/{apiKeyId}")
 @Produces({MediaType.APPLICATION_JSON})
 public String getConnectorSettings(@PathParam("apiKeyId") long apiKeyId)
     throws UpdateFailedException, IOException {
   final ApiKey apiKey = guestService.getApiKey(apiKeyId);
   final long guestId = AuthHelper.getGuestId();
   if (apiKey.getGuestId() != guestId)
     throw new RuntimeException("attempt to retrieve ApiKey from another guest!");
   final Object settings = settingsService.getConnectorSettings(apiKey.getId());
   String json = mapper.writeValueAsString(settings);
   return json;
 }
示例#2
0
 @POST
 @Path("/settings/{apiKeyId}")
 @Produces({MediaType.APPLICATION_JSON})
 public StatusModel saveConnectorSettings(
     @PathParam("apiKeyId") long apiKeyId, @FormParam("json") String json) {
   final ApiKey apiKey = guestService.getApiKey(apiKeyId);
   final long guestId = AuthHelper.getGuestId();
   try {
     if (apiKey.getGuestId() != guestId)
       throw new RuntimeException("attempt to retrieve ApiKey from another guest!");
     settingsService.saveConnectorSettings(apiKey.getId(), json);
   } catch (Throwable e) {
     return new StatusModel(false, e.getMessage());
   }
   return new StatusModel(true, "saved connector settings");
 }
示例#3
0
 @GET
 @Path("/filters")
 @Produces({MediaType.APPLICATION_JSON})
 public String getConnectorFilterState() {
   long vieweeId = AuthHelper.getGuestId();
   try {
     StringBuilder sb =
         new StringBuilder("module=API component=connectorStore action=getConnectorFilterState")
             .append(" guestId=")
             .append(vieweeId);
     logger.info(sb.toString());
     return settingsService.getConnectorFilterState(vieweeId);
   } catch (Exception e) {
     StringBuilder sb =
         new StringBuilder("module=API component=connectorStore action=getConnectorFilterState")
             .append(" guestId=")
             .append(vieweeId)
             .append(" stackTrace=<![CDATA[")
             .append(Utils.stackTrace(e))
             .append("]]>");
     logger.warn(sb.toString());
     return gson.toJson(new StatusModel(false, "Failed to get filters: " + e.getMessage()));
   }
 }