Java Code Examples for org.springframework.http.MediaType#ALL_VALUE

The following examples show how to use org.springframework.http.MediaType#ALL_VALUE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PluginConfigController.java    From wecube-platform with Apache License 2.0 6 votes vote down vote up
@GetMapping(value = "/plugins/packages/export/{plugin-package-id:.+}", produces = { MediaType.ALL_VALUE })
public ResponseEntity<byte[]> exportPluginPackageRegistries(
        @PathVariable(value = "plugin-package-id") String pluginPackageId) {
    log.info("request received to export plugin package registries for {}", pluginPackageId);
    PluginRegistryInfo pluginRegistryInfo = pluginConfigService.exportPluginRegistersForOnePackage(pluginPackageId);
    byte[] filedataBytes = pluginRegistryInfo.getPluginPackageData().getBytes(Charset.forName("UTF-8"));
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
    
    DateFormat df = new SimpleDateFormat("yyyyMMdd");
    String sDate = df.format(new Date());
    String fileName = String.format("register-config-%s-%s.xml", pluginRegistryInfo.getPluginPackageName(), sDate);
    headers.add("Content-Disposition", String.format("attachment;filename=%s", fileName));
    return ResponseEntity.ok().headers(headers).contentLength(filedataBytes.length)
            .contentType(MediaType.APPLICATION_OCTET_STREAM).body(filedataBytes);
}
 
Example 2
Source File: WorkflowProcessDefinitionController.java    From wecube-platform with Apache License 2.0 6 votes vote down vote up
@GetMapping(value = "/process/definitions/{proc-def-id}/export", produces = { MediaType.ALL_VALUE })
public ResponseEntity<byte[]> exportProcessDefinition(@PathVariable("proc-def-id") String procDefId) {

    ProcDefInfoExportImportDto result = procDefService.exportProcessDefinition(procDefId);
    String filename = assembleProcessExportFilename(result);

    String filedata = convertResult(result);
    byte[] filedataBytes = StringUtilsEx.encodeBase64String(filedata.getBytes(Charset.forName("utf-8")))
            .getBytes(Charset.forName("utf-8"));
    // ByteArrayResource resource = new ByteArrayResource(filedataBytes);
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
    headers.add("Content-Disposition", String.format("attachment;filename=%s", filename));

    if (log.isInfoEnabled()) {
        log.info("finished export process definition,size={},filename={}", filedataBytes.length, filename);
    }
    return ResponseEntity.ok().headers(headers).contentLength(filedataBytes.length)
            .contentType(MediaType.APPLICATION_OCTET_STREAM).body(filedataBytes);
}
 
Example 3
Source File: HelloController.java    From springdoc-openapi with Apache License 2.0 5 votes vote down vote up
@Operation(description = "List all persons")
@SecurityRequirement(name = "bearer")
@ApiResponse(responseCode = "200", description = "", content = @Content(array = @ArraySchema(schema = @Schema(implementation = PersonDTO.class))))
@GetMapping(path = "/list", consumes = MediaType.ALL_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public List<PersonDTO> list() {
	PersonDTO person = new PersonDTO();
	person.setFirstName("Nass");
	return Collections.singletonList(person);
}
 
Example 4
Source File: HelloController.java    From springdoc-openapi with Apache License 2.0 5 votes vote down vote up
@Operation(description = "List all persons")
@ApiResponse(responseCode = "200", description = "", content = @Content(array = @ArraySchema(schema = @Schema(implementation = PersonDTO.class))))
@GetMapping(path = "/listTwo", consumes = MediaType.ALL_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public List<PersonDTO> listTwo() {
	PersonDTO person = new PersonDTO();
	person.setFirstName("Nass");
	return Collections.singletonList(person);
}
 
Example 5
Source File: HelloController2.java    From springdoc-openapi with Apache License 2.0 5 votes vote down vote up
@Operation(description = "List all persons")
@ApiResponse(responseCode = "200", description = "", content = @Content(array = @ArraySchema(schema = @Schema(implementation = PersonDTO.class))))
@GetMapping(path = "/list", consumes = MediaType.ALL_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public List<PersonDTO> list() {
	PersonDTO person = new PersonDTO();
	person.setFirstName("Nass");
	return Collections.singletonList(person);
}
 
Example 6
Source File: HelloController2.java    From springdoc-openapi with Apache License 2.0 5 votes vote down vote up
@Operation(description = "List all persons")
@ApiResponse(responseCode = "200", description = "", content = @Content(array = @ArraySchema(schema = @Schema(implementation = PersonDTO.class))))
@GetMapping(path = "/listTwo", consumes = MediaType.ALL_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public List<PersonDTO> listTwo() {
	PersonDTO person = new PersonDTO();
	person.setFirstName("Nass");
	return Collections.singletonList(person);
}
 
Example 7
Source File: BatchItemRequest.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Override
public String getHeader(final String name) {
    try {
        return batchItem.getHeaders().containsKey(name)
                ? batchItem.getHeaders().get(name).get(0).toString()
                : HttpHeaders.CONTENT_TYPE.equals(name) || HttpHeaders.ACCEPT.equals(name)
                ? MediaType.ALL_VALUE
                : super.getHeader(name);
    } catch (Exception e) {
        LOG.debug("While delegating to wrapped request", e);
        return null;
    }
}
 
Example 8
Source File: HelloController.java    From springdoc-openapi with Apache License 2.0 4 votes vote down vote up
@GetMapping(value = "/api/v2/timeout",
		consumes = { MediaType.ALL_VALUE },
		produces = { MediaType.APPLICATION_JSON_VALUE })
public Duration timeouts() {
	return Duration.ofSeconds(5);
}
 
Example 9
Source File: RequestMappingHandlerMappingTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@GetMapping(value = "/get", consumes = MediaType.ALL_VALUE)
public void get() {
}
 
Example 10
Source File: RequestMappingHandlerMappingTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@GetMapping(value = "/get", consumes = MediaType.ALL_VALUE)
public void get() {
}
 
Example 11
Source File: BatchItemRequest.java    From syncope with Apache License 2.0 4 votes vote down vote up
@Override
public String getContentType() {
    return batchItem.getHeaders().containsKey(HttpHeaders.CONTENT_TYPE)
            ? batchItem.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0).toString()
            : MediaType.ALL_VALUE;
}