Refine search
@POST @Path("/run") @Consumes(MediaType.MULTIPART_FORM_DATA) public Response uploadFile(@FormDataParam("scriptfile") InputStream uploadedInputStream, @FormDataParam("scriptfile") FormDataContentDisposition fileDetail) { try { if (!otpServer.scriptingService.enableScriptingWebService) return Response.status(Status.FORBIDDEN) .entity("Scripting web-service is desactivated for security reasons.\n") .build(); String scriptContent = IOUtils.toString(uploadedInputStream, Charsets.UTF_8.name()); Object retval = otpServer.scriptingService.runScript(fileDetail.getFileName(), scriptContent); return Response.ok().entity(retval).build(); } catch (Throwable e) { return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.toString()) .type(MediaType.TEXT_PLAIN).build(); } }
@POST @Path(CoordConsts.SVC_RSC_PUT_OBJECT) @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) @Deprecated public JSONArray putObject( @FormDataParam(CoordConsts.SVC_KEY_API_KEY) String apiKey, @FormDataParam(CoordConsts.SVC_KEY_VERSION) String clientVersion, @FormDataParam(CoordConsts.SVC_KEY_NETWORK_NAME) String networkName, @FormDataParam(CoordConsts.SVC_KEY_SNAPSHOT_NAME) String snapshotName, @FormDataParam(CoordConsts.SVC_KEY_OBJECT_NAME) String objectName, @FormDataParam(CoordConsts.SVC_KEY_FILE) InputStream fileStream) { try { _logger.infof("WMS:putObject %s %s %s / %s\n", apiKey, networkName, snapshotName, objectName); return successResponse(new JSONObject().put("result", "successfully uploaded custom object"));
/** * @see StateQueries */ @Path("/files/{name}") @PUT @Consumes(MediaType.MULTIPART_FORM_DATA) public Response putFile( @PathParam("name") String name, @FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetails) { return StateQueries.putFile(stateStore, name, uploadedInputStream, fileDetails); }
/** * Set value for a parameter specified by key * <p></p> * The parameters can be a hive variable or a configuration. To set key as a hive variable, the key should be prefixed * with 'hivevar:'. To set key as configuration parameter, the key should be prefixed with 'hiveconf:' If no prefix is * attached, the parameter is set as configuration. * * @param sessionid session handle object * @param key parameter key * @param value parameter value * @return APIResult object indicating if set operation was successful */ @PUT @Path("params") @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN}) public APIResult setParam(@FormDataParam("sessionid") LensSessionHandle sessionid, @FormDataParam("key") String key, @FormDataParam("value") String value) { sessionService.setSessionParameter(sessionid, key, value); return new APIResult(Status.SUCCEEDED, "Set param succeeded"); }
@POST @Consumes(MediaType.MULTIPART_FORM_DATA) public Response getUpload(@FormDataParam("file") InputStream inputStream, @FormDataParam("file") FormDataContentDisposition header, @FormDataParam("path") String path) { try { saveFile(inputStream, path + "/" + header.getFileName()); } catch (IOException e) { LOGGER.error("Error while saving {}", path, e); return Response.status(Status.CONFLICT).build(); } return Response.ok().build(); }
/** * Parses the query and returns parameters that are found in the query. * * @param sessionid The sessionid in which user is working * @param query The HQL query * @return {@link org.apache.lens.api.query.save.ParameterParserResponse} ParameterParserResponse object */ @POST @Path("/savedqueries/parameters") public ParameterParserResponse getParameters( @QueryParam("sessionid") LensSessionHandle sessionid, @FormDataParam("query") String query) { return new ParameterParser(query).extractParameters(); }
@FormDataParam("label") public void setLabel(String label) { this.label = label; }
private MultiPart computeMultiPart( Method method, Object[] parameter ) { FormDataMultiPart result = new FormDataMultiPart(); Annotation[][] parameterAnnotations = method.getParameterAnnotations(); for( int i = 0; i < parameterAnnotations.length; i++ ) { Annotation[] annotations = parameterAnnotations[ i ]; FormDataParam param = extractAnnotation( annotations, FormDataParam.class ); if( param != null ) { result.field( param.value(), parameter[ i ], determinePartContentType( parameter[ i ] ) ); } } return result.getFields().isEmpty() ? null : result; }
@POST @Path(CoordConsts.SVC_RSC_GET_QUESTION_TEMPLATES) @Produces(MediaType.APPLICATION_JSON) @Deprecated public JSONArray getQuestionTemplates(@FormDataParam(CoordConsts.SVC_KEY_API_KEY) String apiKey) { try { _logger.infof("WMS:getQuestionTemplates %s\n", apiKey); checkStringParam(apiKey, "API key"); checkApiKeyValidity(apiKey); Map<String, String> questionTemplates = Main.getQuestionTemplates(); if (questionTemplates == null) { return failureResponse("Question templates dir is not configured"); } else { return successResponse( new JSONObject().put(CoordConsts.SVC_KEY_QUESTION_LIST, questionTemplates)); } } catch (Exception e) { String stackTrace = Throwables.getStackTraceAsString(e); _logger.errorf("WMS:getQuestionTemplates exception: %s\n", stackTrace); return failureResponse(e.getMessage()); } }
@PUT @ApiOperation(value = "Updates a Pulsar Function currently running in cluster mode") @ApiResponses(value = { @ApiResponse(code = 403, message = "The requester doesn't have admin permissions"), @ApiResponse(code = 400, message = "Invalid request (function doesn't exist, etc.)"), @ApiResponse(code = 200, message = "Pulsar Function successfully updated") }) @Path("/{tenant}/{namespace}/{functionName}") @Consumes(MediaType.MULTIPART_FORM_DATA) public Response updateFunction(final @PathParam("tenant") String tenant, final @PathParam("namespace") String namespace, final @PathParam("functionName") String functionName, final @FormDataParam("data") InputStream uploadedInputStream, final @FormDataParam("data") FormDataContentDisposition fileDetail, final @FormDataParam("url") String functionPkgUrl, final @FormDataParam("functionDetails") String functionDetailsJson, final @FormDataParam("functionConfig") String functionConfigJson) { return functions.updateFunction(tenant, namespace, functionName, uploadedInputStream, fileDetail, functionPkgUrl, functionDetailsJson, functionConfigJson, clientAppId()); }
@POST @RolesAllowed ( value = {"admin"} ) @Consumes(MediaType.MULTIPART_FORM_DATA) public Response deployForm(@FormDataParam("id") ModelRef modelRef, @FormDataParam("pmml") Model model){ return doDeploy(modelRef, model); }
@POST @Path("/dictionary") public TexeraWebResponse uploadDictionaryFile( @FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail) throws Exception { StringBuilder dictionary = new StringBuilder(); String line = ""; try (BufferedReader br = new BufferedReader(new InputStreamReader(uploadedInputStream))) { while ((line = br.readLine()) != null) { dictionary.append(line); } } catch (IOException e) { throw new TexeraWebException("Error occurred whlie uploading dictionary"); } String fileName = fileDetail.getFileName(); // save the dictionary DictionaryManager dictionaryManager = DictionaryManager.getInstance(); dictionaryManager.addDictionary(fileName, dictionary.toString()); return new TexeraWebResponse(0, "Dictionary is uploaded"); }
@FormDataParam("display-enabled") @JsonProperty("display-enabled") public void setDisplayEnabled(boolean displayEnabled) { this.displayEnabled = displayEnabled; }
} else if (paramAnnotation instanceof FormDataParam) { p = new Param(((FormDataParam)paramAnnotation).value(), type); formParams.add(p); } else if (paramAnnotation instanceof HeaderParam) {
@POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.TEXT_PLAIN) @Path("/file") public String create(@FormDataParam("file") InputStream fileInputStream, @FormDataParam("file") FormDataContentDisposition contentDispositionHeader) { return "done"; } }
@POST @Path(CoordConsts.SVC_RSC_AUTO_COMPLETE) @Produces(MediaType.APPLICATION_JSON) public JSONArray autoComplete( @FormDataParam(CoordConsts.SVC_KEY_API_KEY) String apiKey, @FormDataParam(CoordConsts.SVC_KEY_VERSION) String clientVersion, @FormDataParam(CoordConsts.SVC_KEY_NETWORK_NAME) String networkName, @FormDataParam(CoordConsts.SVC_KEY_SNAPSHOT_NAME) String snapshotName, @FormDataParam(CoordConsts.SVC_KEY_COMPLETION_TYPE) String completionType, @FormDataParam(CoordConsts.SVC_KEY_QUERY) String query, @FormDataParam(CoordConsts.SVC_KEY_MAX_SUGGESTIONS) String maxSuggestions) { try { _logger.infof("WMS:autoComplete %s %s %s\n", completionType, query, maxSuggestions); "There was a problem getting Autocomplete suggestions - network or snapshot does not exist!"); return successResponse(new JSONObject().put(CoordConsts.SVC_KEY_SUGGESTIONS, answer)); } catch (IllegalArgumentException | AccessControlException e) { _logger.errorf("WMS:autoComplete exception: %s\n", e.getMessage());
/** * @see StateQueries */ @Path("{sanitizedServiceName}/state/files/{name}") @PUT @Consumes(MediaType.MULTIPART_FORM_DATA) public Response putFile( @PathParam("sanitizedServiceName") String sanitizedServiceName, @PathParam("name") String name, @FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetails) { Optional<StateStore> stateStore = getStateStore(sanitizedServiceName); if (!stateStore.isPresent()) { return ResponseUtils.serviceNotFoundResponse(sanitizedServiceName); } return StateQueries.putFile(stateStore.get(), name, uploadedInputStream, fileDetails); }
@POST @Consumes(MediaType.MULTIPART_FORM_DATA) public Response uploadFiles(@FormDataParam("file_upload") InputStream uploadedInputStream, @FormDataParam("file_upload") FormDataContentDisposition fileDetail) { try { String filePath = fileManagement.saveFile(uploadedInputStream, fileDetail.getFileName()); // return ok("{fileName: " + filePath + "}"); return ok(Notifications.success(filePath)); } catch (Exception e) { logger.error(e.toString()); return fail(); } }
@FormDataParam("main-doc") @JsonProperty("main-doc") public void setMainDoc(String mainDoc) { this.mainDoc = mainDoc; }
@POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_XML) @Path("{id}/templates/upload") @ApiOperation( value = "Uploads a template", required = false @FormDataParam(DISCONNECTED_NODE_ACKNOWLEDGED) @DefaultValue("false") final Boolean disconnectedNodeAcknowledged, @FormDataParam("template") final InputStream in) throws InterruptedException {