当前位置: 首页>>代码示例>>Java>>正文


Java MediaType.APPLICATION_OCTET_STREAM属性代码示例

本文整理汇总了Java中javax.ws.rs.core.MediaType.APPLICATION_OCTET_STREAM属性的典型用法代码示例。如果您正苦于以下问题:Java MediaType.APPLICATION_OCTET_STREAM属性的具体用法?Java MediaType.APPLICATION_OCTET_STREAM怎么用?Java MediaType.APPLICATION_OCTET_STREAM使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.ws.rs.core.MediaType的用法示例。


在下文中一共展示了MediaType.APPLICATION_OCTET_STREAM属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: postRoot

/** Handle HTTP POST request for the root. */
@POST
@Path("/")
@Consumes({"*/*"})
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response postRoot(
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(UserParam.NAME) @DefaultValue(UserParam.DEFAULT)
        final UserParam username,
    @QueryParam(DoAsParam.NAME) @DefaultValue(DoAsParam.DEFAULT)
        final DoAsParam doAsUser,
    @QueryParam(PostOpParam.NAME) @DefaultValue(PostOpParam.DEFAULT)
        final PostOpParam op,
    @QueryParam(ConcatSourcesParam.NAME) @DefaultValue(ConcatSourcesParam.DEFAULT)
        final ConcatSourcesParam concatSrcs,
    @QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
        final BufferSizeParam bufferSize,
    @QueryParam(ExcludeDatanodesParam.NAME) @DefaultValue(ExcludeDatanodesParam.DEFAULT)
        final ExcludeDatanodesParam excludeDatanodes,
    @QueryParam(NewLengthParam.NAME) @DefaultValue(NewLengthParam.DEFAULT)
        final NewLengthParam newLength
    ) throws IOException, InterruptedException {
  return post(ugi, delegation, username, doAsUser, ROOT, op, concatSrcs,
      bufferSize, excludeDatanodes, newLength);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:NamenodeWebHdfsMethods.java

示例2: createObject

/**
 * Creates a new object.
 *
 * This originally used application/octet-stream;qs=1001 as a workaround
 * for JERSEY-2636, to ensure requests without a Content-Type get routed here.
 * This qs value does not parse with newer versions of Jersey, as qs values
 * must be between 0 and 1.  We use qs=1.000 to mark where this historical
 * anomaly had been.
 *
 * @param contentDisposition the content Disposition value
 * @param requestContentType the request content type
 * @param slug the slug value
 * @param requestBodyStream  the request body stream
 * @param link the link value
 * @param digest the digest header
 * @return 201
 * @throws InvalidChecksumException if invalid checksum exception occurred
 * @throws IOException if IO exception occurred
 * @throws MalformedRdfException if malformed rdf exception occurred
 */
@POST
@Consumes({MediaType.APPLICATION_OCTET_STREAM + ";qs=1.000", WILDCARD})
@Produces({TURTLE_WITH_CHARSET + ";qs=1.0", JSON_LD + ";qs=0.8",
        N3_WITH_CHARSET, N3_ALT2_WITH_CHARSET, RDF_XML, NTRIPLES, TEXT_PLAIN_WITH_CHARSET,
        TURTLE_X, TEXT_HTML_WITH_CHARSET, "*/*"})
public Response createObject(@HeaderParam(CONTENT_DISPOSITION) final ContentDisposition contentDisposition,
                             @HeaderParam(CONTENT_TYPE) final MediaType requestContentType,
                             @HeaderParam("Slug") final String slug,
                             @ContentLocation final InputStream requestBodyStream,
                             @HeaderParam(LINK) final String link,
                             @HeaderParam("Digest") final String digest)
        throws InvalidChecksumException, IOException, MalformedRdfException {
    LOGGER.info("POST: {}", externalPath);

    final ContainerService containerService = getContainerService();
    final URI resourceUri = createFromPath(externalPath);

    //check that resource exists
    if (!containerService.exists(resourceUri)) {
        if (!isRoot(resourceUri)) {
            return status(NOT_FOUND).build();
        } else {
            createRoot();
        }
    }

    final String newResourceName = slug == null ? UUID.randomUUID().toString() : slug;
    final String resourcePath = (isRoot(resourceUri) ? "" : resourceUri.getPath());
    final URI newResourceUri = createFromPath(resourcePath + "/" + newResourceName);
    final Container container = containerService.findOrCreate(newResourceUri);
    final Model model = ModelFactory.createDefaultModel();

    model.read(requestBodyStream, container.getIdentifier().toString(), "TTL");
    final Stream<Triple> triples = model.listStatements().toList().stream().map(Statement::asTriple);
    container.updateTriples(triples);
    return created(toExternalURI(container.getIdentifier(), headers)).build();
}
 
开发者ID:duraspace,项目名称:lambdora,代码行数:57,代码来源:LambdoraLdp.java

示例3: setZNodeAsOctet

@PUT
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public void setZNodeAsOctet(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @DefaultValue("false") @QueryParam("null") String setNull,
        @Context UriInfo ui, byte[] data) throws InterruptedException,
        KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    if (setNull.equals("true")) {
        data = null;
    }

    zk.setData(path, data, version);
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:26,代码来源:ZNodeResource.java

示例4: setZNode

@PUT
@Produces( { MediaType.APPLICATION_JSON, "application/javascript",
        MediaType.APPLICATION_XML })
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public Response setZNode(
        @PathParam("path") String path,
        @QueryParam("callback") String callback,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @DefaultValue("base64") @QueryParam("dataformat") String dataformat,
        @DefaultValue("false") @QueryParam("null") String setNull,
        @Context UriInfo ui, byte[] data) throws InterruptedException,
        KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    if (setNull.equals("true")) {
        data = null;
    }

    Stat stat = zk.setData(path, data, version);

    ZStat zstat = new ZStat(path, ui.getAbsolutePath().toString(), null,
            null, stat.getCzxid(), stat.getMzxid(), stat.getCtime(), stat
                    .getMtime(), stat.getVersion(), stat.getCversion(),
            stat.getAversion(), stat.getEphemeralOwner(), stat
                    .getDataLength(), stat.getNumChildren(), stat
                    .getPzxid());

    return Response.status(Response.Status.OK).entity(
            new JSONWithPadding(zstat, callback)).build();
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:40,代码来源:ZNodeResource.java

示例5: getStream

@GET
@Path("stream")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public StreamingOutput getStream() {
	return new StreamingOutput() {
		@Override
		public void write(OutputStream output) throws IOException, WebApplicationException {
			output.write(new byte[] { 1, 2, 3 });
		}
	};
}
 
开发者ID:holon-platform,项目名称:holon-jaxrs,代码行数:11,代码来源:TestJaxrsClient.java

示例6: uploadOfficeSiteLogo

@PUT
@Path("/{id}/logo")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response uploadOfficeSiteLogo(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext, @PathParam("id") long id,
		@Multipart("file") Attachment attachment, @Multipart("fileName") String fileName,
		@Multipart("fileType") String fileType, @Multipart("fileSize") long fileSize);
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:9,代码来源:OfficeSiteManagement.java

示例7: getZNodeListAsOctet

@GET
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response getZNodeListAsOctet(@PathParam("path") String path)
        throws InterruptedException, KeeperException {
    ensurePathNotNull(path);

    Stat stat = new Stat();
    byte[] data = zk.getData(path, false, stat);

    if (data == null) {
        return Response.status(Response.Status.NO_CONTENT).build();
    } else {
        return Response.status(Response.Status.OK).entity(data).build();
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:15,代码来源:ZNodeResource.java

示例8: getSimpleCsv

/**
 * Return simple data as CSV input stream. There is no specific computation.
 * 
 * @param subscription
 *            The subscription identifier.
 * @param file
 *            The user file name to use in download response.
 * @return the stream ready to be read during the serialization.
 */
@GET
@Path("{subscription:\\d+}/{file:.*-simple.csv}")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response getSimpleCsv(@PathParam("subscription") final int subscription,
		@PathParam("file") final String file) {
	log.info("Standard report requested by '{}' for subscription '{}'",
			SecurityContextHolder.getContext().getAuthentication().getName(), subscription);
	return AbstractToolPluginResource.download(new CsvSimpleOutput(getSimpleData(subscription)), file).build();
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:18,代码来源:JiraExportPluginResource.java

示例9: existsZNodeAsOctet

@HEAD
@Produces( { MediaType.APPLICATION_OCTET_STREAM })
public Response existsZNodeAsOctet(@PathParam("path") String path,
        @Context UriInfo ui) throws InterruptedException, KeeperException {
    Stat stat = zk.exists(path, false);
    if (stat == null) {
        throwNotFound(path, ui);
    }
    return Response.status(Response.Status.NO_CONTENT).build();
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:10,代码来源:ZNodeResource.java

示例10: pdf

@GET
@Path("pdf")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public InputStream pdf(@QueryParam("key") String key) throws Exception {
    String tenantId = tenantHolder.getTenantId();
    StoreDTO storeDto = storeConnector.getStore("cms/html/r/pdf", key,
            tenantId);

    return storeDto.getDataSource().getInputStream();
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:10,代码来源:CmsResource.java

示例11: getDbBackupFile

@ApiOperation(value = "Backs up server database",
        notes = "Trigger database backup, place backup on server and make it avaliable for download",
        response = ServerStatusResponse.class)
@ApiResponses(value = {@ApiResponse(code = 200, message = "Successful operation"),
        @ApiResponse(code = 400, message = "In case of any error", response = ErrorCodeDto.class) })
@OscAuth
@Path("/backup-db")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@POST
public Response getDbBackupFile(@Context HttpHeaders headers, @ApiParam(required = true) BackupRequest request) {

    this.userContext.setUser(OscAuthFilter.getUsername(headers));
    logger.info(this.userContext.getCurrentUser()+" is generating a backap of the database");
    StreamingOutput fileStream = new StreamingOutput() {
        @Override
        public void write(OutputStream output) throws IOException, WebApplicationException {
            try {
                ServerMgmtApis.this.backupService.dispatch(request);
                File encryptedBackupFile = ServerMgmtApis.this.backupService.getEncryptedBackupFile(request.getBackupFileName());
                output.write(Files.readAllBytes(encryptedBackupFile.toPath()));
                output.flush();
            } catch (Exception e) {
                throw new InternalServerErrorException("Backup could not be generated",e);
            }
        }
    };
    return Response
            .ok(fileStream, MediaType.APPLICATION_OCTET_STREAM)
            .header("content-disposition", "attachment; filename = oscServerDBBackup.zip")
            .build();
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:31,代码来源:ServerMgmtApis.java

示例12: attachments

@GET
@Path("attachments")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public InputStream attachments(@QueryParam("key") String key,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    String tenantId = tenantHolder.getTenantId();
    StoreDTO storeDto = storeConnector.getStore("cms/html/r/attachments",
            key, tenantId);
    ServletUtils.setFileDownloadHeader(request, response,
            storeDto.getDisplayName());

    return storeDto.getDataSource().getInputStream();
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:14,代码来源:CmsResource.java

示例13: getSlaComputationsCsvWithCustomFields

/**
 * Return SLA computations and custom field data as CSV input stream.
 * 
 * @param subscription
 *            The subscription identifier.
 * @param file
 *            The user file name to use in download response.
 * @return the stream ready to be read during the serialization.
 */
@GET
@Path("{subscription:\\d+}/{file:.*-full.csv}")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response getSlaComputationsCsvWithCustomFields(@PathParam("subscription") final int subscription,
		@PathParam("file") final String file) {
	log.info("SLA+ report requested by '{}' for subscription '{}'",
			SecurityContextHolder.getContext().getAuthentication().getName(), subscription);
	final long start = System.currentTimeMillis();
	final JiraSlaComputations slaComputations = getSlaComputations(subscription, true);
	final DataSource dataSource = slaComputations.getDataSource();

	// Components
	final Map<Integer, Collection<Integer>> componentAssociations = jiraDao.getComponentsAssociation(dataSource,
			slaComputations.getJira());
	log.info("Retrieved components associations : {}", componentAssociations.size());
	final Map<Integer, String> components = jiraDao.getComponents(dataSource, slaComputations.getJira());
	log.info("Retrieved components configurations : {}", components.size());

	// Custom fields
	final List<CustomFieldValue> customFieldValues = jiraDao.getCustomFieldValues(dataSource,
			slaComputations.getJira());
	log.info("Retrieved custom fields : {}", customFieldValues.size());
	final Map<Integer, CustomFieldEditor> customFields = getCustomFields(dataSource, customFieldValues,
			slaComputations.getJira());
	log.info("Retrieved custom field configurations : {}", customFields.size());

	// Parent relationships
	final Map<Integer, Integer> subTasks = jiraDao.getSubTasks(dataSource, slaComputations.getJira());
	log.info("Retrieved parent relashionships : {}", subTasks.size());

	log.info("End of full report data gathering, took {}",
			DurationFormatUtils.formatDurationHMS(System.currentTimeMillis() - start));
	return AbstractToolPluginResource.download(new CsvWithCustomFieldsStreamingOutput(slaComputations,
			customFieldValues, customFields, componentAssociations, components, subTasks), file).build();
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:44,代码来源:JiraExportPluginResource.java

示例14: getOfficeSiteLogo

@GET
@Path("/{id}/logo")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response getOfficeSiteLogo(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext, @PathParam("id") long id);
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:6,代码来源:OfficeSiteManagement.java

示例15: createZNode

@POST
@Produces( { MediaType.APPLICATION_JSON, "application/javascript",
        MediaType.APPLICATION_XML })
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public Response createZNode(
        @PathParam("path") String path,
        @QueryParam("callback") String callback,
        @DefaultValue("create") @QueryParam("op") String op,
        @QueryParam("name") String name,
        @DefaultValue("base64") @QueryParam("dataformat") String dataformat,
        @DefaultValue("false") @QueryParam("null") String setNull,
        @DefaultValue("false") @QueryParam("sequence") String sequence,
        @DefaultValue("false") @QueryParam("ephemeral") String ephemeral,
        @Context UriInfo ui, byte[] data) throws InterruptedException,
        KeeperException {
    ensurePathNotNull(path);

    if (path.equals("/")) {
        path += name;
    } else {
        path += "/" + name;
    }

    if (!op.equals("create")) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad operaton " + op)).build());
    }

    if (setNull.equals("true")) {
        data = null;
    }

    CreateMode createMode;
    if (sequence.equals("true")) {
        if (ephemeral.equals("false")) {
            createMode = CreateMode.PERSISTENT_SEQUENTIAL;
        } else {
            createMode = CreateMode.EPHEMERAL_SEQUENTIAL;
        }
    } else if (ephemeral.equals("false")) {
        createMode = CreateMode.PERSISTENT;
    } else {
        createMode = CreateMode.EPHEMERAL;
    }

    String newPath = zk.create(path, data, Ids.OPEN_ACL_UNSAFE, createMode);

    URI uri = ui.getAbsolutePathBuilder().path(newPath).build();

    return Response.created(uri).entity(
            new JSONWithPadding(new ZPath(newPath, ui.getAbsolutePath()
                    .toString()))).build();
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:55,代码来源:ZNodeResource.java


注:本文中的javax.ws.rs.core.MediaType.APPLICATION_OCTET_STREAM属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。