@Produces( { WILDCARD } ) public Response doDeleteRevisions( @PathParam( "pathId" ) String pathId, @DefaultValue( "false" ) @FormDataParam( "purgeFiles" ) boolean purgeFiles, @DefaultValue( "false" ) @FormDataParam( "purgeRevisions" ) boolean purgeRevisions, @DefaultValue( "false" ) @FormDataParam( "purgeSharedObjects" ) boolean purgeSharedObjects, @DefaultValue( "-1" ) @FormDataParam( "versionCount" ) int versionCount, @FormDataParam( "purgeBeforeDate" ) Date purgeBeforeDate, @DefaultValue( "*" ) @FormDataParam( "fileFilter" ) String fileFilter, @DefaultValue( "INFO" ) @FormDataParam( "logLevel" ) String logLevelName ) {
public Response importMetadataDatasourceLegacy( @PathParam( "domainId" ) String domainId, @FormDataParam( "metadataFile" ) InputStream metadataFile, @FormDataParam( "metadataFile" ) FormDataContentDisposition metadataFileInfo, @FormDataParam( OVERWRITE_IN_REPOS ) String overwrite, @FormDataParam( "localeFiles" ) List<FormDataBodyPart> localeFiles, @FormDataParam( "localeFiles" ) List<FormDataContentDisposition> localeFilesInfo, @FormDataParam( DATASOURCE_ACL ) RepositoryFileAclDto acl ) { return importMetadataDatasource( domainId, metadataFile, metadataFileInfo, overwrite, localeFiles, localeFilesInfo, acl ); }
/** * Loads an application from a ZIP file. * @param uploadedInputStream the uploaded archive * @param fileDetail the file details * @return a response */ @POST @Consumes( MediaType.MULTIPART_FORM_DATA ) Response loadApplication( @FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail );
/** * Handles the upload of a <em>single</em> file. Adds the given file to the current artifact template. * <p> * If the file already exists, is it <em>overridden</em> * * @return JSON with data required by JQuery-File-Upload (see https://github.com/blueimp/jQuery-File-Upload/wiki/Setup) */ @POST @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.MULTIPART_FORM_DATA) public Response onPost(@FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail, @FormDataParam("file") FormDataBodyPart body, @Context UriInfo uriInfo) { return onPost(uploadedInputStream, fileDetail, body, uriInfo, fileDetail.getFileName()); }
@PUT @Path( "/import" ) @Consumes( MediaType.MULTIPART_FORM_DATA ) @Produces( "text/plain" ) @StatusCodes( { @ResponseCode( code = 200, condition = "Status code indicating a success or failure while importing Mondrian schema XML. A response of:\n" + " * 2: Unspecified general error has occurred\n" + " * 3: Success\n" + " * 5: Authorization error" ) } ) public Response putMondrianSchema( @FormDataParam( UPLOAD_ANALYSIS ) InputStream uploadAnalysis, @FormDataParam( UPLOAD_ANALYSIS ) FormDataContentDisposition schemaFileInfo, @FormDataParam( CATALOG_ID ) String catalogName, // Optional @FormDataParam( ORIG_CATALOG_NAME ) String origCatalogName, // Optional @FormDataParam( DATASOURCE_NAME ) String datasourceName, // Optional @FormDataParam( OVERWRITE_IN_REPOS ) String overwrite, @FormDataParam( XMLA_ENABLED_FLAG ) String xmlaEnabledFlag, @FormDataParam( PARAMETERS ) String parameters, @FormDataParam( DATASOURCE_ACL ) RepositoryFileAclDto acl ) throws PentahoAccessControlException { return importMondrianSchema( uploadAnalysis, schemaFileInfo, catalogName, origCatalogName, datasourceName, overwrite, xmlaEnabledFlag, parameters, acl ); }
@POST @Path(SEGMENTATION) @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.MULTIPART_FORM_DATA) public Response processSentenceSegmentationPost(@FormDataParam(TEXT) String text) { return NerdRestProcessString.processSentenceSegmentation(text); }
/** * @see com.scienceminer.nerd.service.NerdRestProcessString#processLanguageIdentification(String) */ @POST @Path(LANGUAGE) @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.MULTIPART_FORM_DATA) public Response processLanguageIdentificationPost(@FormDataParam(TEXT) String text) { return NerdRestProcessString.processLanguageIdentification(text); }
@POST @ApiOperation(value = "Add a new entity or policy type to the catalog by uploading a Groovy script from browser using multipart/form-data", responseClass = "String") @Consumes(MediaType.MULTIPART_FORM_DATA) public Response createFromMultipart( @ApiParam(name = "groovyCode", value = "multipart/form-data file input field") @FormDataParam("groovyCode") InputStream uploadedInputStream, @FormDataParam("groovyCode") FormDataContentDisposition fileDetail) throws IOException ;
@PUT @Path("16x16") @Consumes(MediaType.MULTIPART_FORM_DATA) public Response post16x16Image(@FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataBodyPart body) { return this.putImage(Filename.FILENAME_SMALL_ICON, uploadedInputStream, body.getMediaType()); }
/** * Imports the given ZIP */ @POST @Consumes(MediaType.MULTIPART_FORM_DATA) public Response importRepositoryDump(@FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail) { ((IRepositoryAdministration) RepositoryFactory.getRepository()).doImport(uploadedInputStream); return Response.noContent().build(); }
@PUT @Path("50x50") @Consumes(MediaType.MULTIPART_FORM_DATA) public Response post50x50Image(@FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataBodyPart body) { return this.putImage(Filename.FILENAME_BIG_ICON, uploadedInputStream, body.getMediaType()); }
@POST @Consumes(MediaType.MULTIPART_FORM_DATA) public Response addAttachment(@FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail, @FormDataParam("title") String title, @FormDataParam("description") String description) { Attachment created = this.addAttachment(uploadedInputStream, fileDetail.getFileName(), title, description, Optional.<UUID>absent()); try { return Response.created(new URI(created.getSlug())).build(); } catch (URISyntaxException e) { logger.error("Failed to created attachment URI", e); return Response.serverError().build(); } } }
@POST @ApiOperation(value = "Add a new entity or policy type to the catalog by uploading a Groovy script from browser using multipart/form-data", responseClass = "String") @Consumes(MediaType.MULTIPART_FORM_DATA) public Response createFromMultipart( @ApiParam(name = "groovyCode", value = "multipart/form-data file input field") @FormDataParam("groovyCode") InputStream uploadedInputStream, @FormDataParam("groovyCode") FormDataContentDisposition fileDetail) throws IOException { return brooklyn().createCatalogEntryFromGroovyCode(CharStreams.toString(new InputStreamReader(uploadedInputStream, Charsets.UTF_8))); }
@POST @ApiOperation(value = "Imports the given zipped YAML files") @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.TEXT_PLAIN) public Response importYAML( @FormDataParam("file") InputStream uploadInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail, @FormDataParam("overwrite") @ApiParam(value = "true/false both not used") Boolean overwrite, @Context UriInfo uriInfo ) { LOGGER.debug("File {}", fileDetail); Converter converter = new Converter(); try { converter.convertY2X(uploadInputStream); } catch (Exception e) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( StringEscapeUtils.escapeHtml4(e.getMessage().trim()) ).type("text/plain").build(); } return Response.noContent().build(); } }
@Path("/initfromscript") @POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) public Response initfromscript(@FormDataParam("dynamicplugin") String dynamicPlugin) throws Exception { try { GroovyClassLoader gcl = new GroovyClassLoader(); Class classFromScript = gcl.parseClass(dynamicPlugin); Object objectFromScript = classFromScript.newInstance(); NdBenchClient client = (NdBenchClient) objectFromScript; ndBenchDriver.init(client); return sendSuccessResponse("NdBench client - dynamic plugin initiated with script!"); } catch (Exception e) { logger.error("Error initializing dynamic plugin from script", e); return sendErrorResponse("script initialization failed for dynamic plugin!"+e); } }
@Path("/initfromscript") @POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) public Response initfromscript(@FormDataParam("dynamicplugin") String dynamicPlugin) throws Exception { try { GroovyClassLoader gcl = new GroovyClassLoader(); Class classFromScript = gcl.parseClass(dynamicPlugin); Object objectFromScript = classFromScript.newInstance(); NdBenchClient client = (NdBenchClient) objectFromScript; ndBenchDriver.init(client); return sendSuccessResponse("NdBench client - dynamic plugin initiated with script!"); } catch (Exception e) { logger.error("Error initializing dynamic plugin from script", e); return sendErrorResponse("script initialization failed for dynamic plugin!"+e); } }
@PUT @Path("image.jpg") @Consumes(MediaType.MULTIPART_FORM_DATA) public Response putImage(@FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataBodyPart body) { try { SelfServiceMetaDataUtils.ensureDataXmlExists(this.id); } catch (IOException e) { throw new WebApplicationException(e); } RepositoryFileReference ref = new RepositoryFileReference(this.id, "image.jpg"); Response response = RestUtils.putContentToFile(ref, uploadedInputStream, body.getMediaType()); if (StringUtils.isEmpty(this.application.getImageUrl())) { this.application.setImageUrl("image.jpg"); persist(); } return response; }
@PUT @Path("icon.jpg") @Consumes(MediaType.MULTIPART_FORM_DATA) public Response putIcon(@FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataBodyPart body) { try { SelfServiceMetaDataUtils.ensureDataXmlExists(this.id); } catch (IOException e) { throw new WebApplicationException(e); } RepositoryFileReference ref = new RepositoryFileReference(this.id, "icon.jpg"); Response response = RestUtils.putContentToFile(ref, uploadedInputStream, body.getMediaType()); if (StringUtils.isEmpty(this.application.getIconUrl())) { this.application.setIconUrl("icon.jpg"); persist(); } return response; }
public Response onPost(@FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail, @FormDataParam("file") FormDataBodyPart body, @Context UriInfo uriInfo, String fileName) { // existence check not required as instantiation of the resource ensures that the object only exists if the resource exists FilesResource.LOGGER.debug("Beginning with file upload"); if (StringUtils.isEmpty(fileName)) { return Response.status(Status.BAD_REQUEST).build(); } RepositoryFileReference ref = this.fileName2fileRef(fileName, false); // TODO: instead of fixing the media type, we could overwrite the browser's mediatype by using some user configuration BufferedInputStream bis = new BufferedInputStream(uploadedInputStream); org.apache.tika.mime.MediaType mediaType = BackendUtils.getFixedMimeType(bis, fileName, org.apache.tika.mime.MediaType.parse(body.getMediaType().toString())); Response response = RestUtils.putContentToFile(ref, bis, mediaType); if (response.getStatus() == Status.INTERNAL_SERVER_ERROR.getStatusCode()) { return response; } try { BackendUtils.synchronizeReferences(RepositoryFactory.getRepository(), (ArtifactTemplateId) fileDir.getParent()); } catch (IOException e) { throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR); } String URL = RestUtils.getAbsoluteURL(this.fileDir) + Util.URLencode(fileName); return Response.created(RestUtils.createURI(URL)).entity(this.getAllFileMetas()).build(); }
@PUT @Consumes( {MediaType.MULTIPART_FORM_DATA}) @ApiOperation(value = "Resource currently works for BPMN4TOSCA plans only") public Response onPutFile( @FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail, @FormDataParam("file") FormDataBodyPart body ) { String fileName = fileDetail.getFileName(); RepositoryFileReference ref = new RepositoryFileReference(this.planId, fileName); RepositoryFileReference oldRef = this.getFileRef(); // if oldRef exists -> check for equality and afterwards overwrite the old content if (oldRef != null && !ref.equals(oldRef)) { // new filename sent RestUtils.delete(oldRef); PlansResource.setPlanModelReference(this.plan, this.planId, fileName); RestUtils.persist(this.res); } return RestUtils.putContentToFile(ref, uploadedInputStream, org.apache.tika.mime.MediaType.parse(body.getMediaType().toString())); }