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


Java BatchOptions类代码示例

本文整理汇总了Java中org.apache.olingo.server.api.deserializer.batch.BatchOptions的典型用法代码示例。如果您正苦于以下问题:Java BatchOptions类的具体用法?Java BatchOptions怎么用?Java BatchOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BatchOptions类属于org.apache.olingo.server.api.deserializer.batch包,在下文中一共展示了BatchOptions类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processBatch

import org.apache.olingo.server.api.deserializer.batch.BatchOptions; //导入依赖的package包/类
@Override
public void processBatch(BatchFacade facade, ODataRequest request, ODataResponse response)
		throws ODataApplicationException, ODataLibraryException {
	String boundary = facade.extractBoundaryFromContentType(request.getHeader(HttpHeader.CONTENT_TYPE));
	BatchOptions options = BatchOptions.with().rawBaseUri(request.getRawBaseUri())
			.rawServiceResolutionUri(request.getRawServiceResolutionUri())
			.build();		
	List<BatchRequestPart> requestParts = odata.createFixedFormatDeserializer()
			.parseBatchRequest(request.getBody(), boundary, options);

	List<ODataResponsePart> responseParts = new ArrayList<ODataResponsePart>();
	for (final BatchRequestPart part : requestParts) {
		responseParts.add(facade.handleBatchRequest(part));
	}
	InputStream responseContent = odata.createFixedFormatSerializer().batchResponse(responseParts, boundary);		
	response.setHeader(HttpHeader.CONTENT_TYPE, ContentType.MULTIPART_MIXED.toContentTypeString());
	response.setContent(responseContent);
	response.setStatusCode(HttpStatusCode.ACCEPTED.getStatusCode());
}
 
开发者ID:jbaliuka,项目名称:sql-analytic,代码行数:20,代码来源:SQLBatchProcessor.java

示例2: processBatch

import org.apache.olingo.server.api.deserializer.batch.BatchOptions; //导入依赖的package包/类
@Override
public void processBatch(BatchFacade facade, ODataRequest request, ODataResponse response)
		throws ODataApplicationException, ODataLibraryException {

	// 1. Extract the boundary
	final String boundary = facade.extractBoundaryFromContentType(request.getHeader(HttpHeader.CONTENT_TYPE));
	// 2. Prepare the batch options
	final BatchOptions options = BatchOptions.with().rawBaseUri(request.getRawBaseUri())
			.rawServiceResolutionUri(request.getRawServiceResolutionUri()).build();

	// 3. Deserialize the batch request
	final List<BatchRequestPart> requestParts = odata.createFixedFormatDeserializer()
			.parseBatchRequest(request.getBody(), boundary, options);

	// 4. Execute the batch request parts
	final List<ODataResponsePart> responseParts = new ArrayList<ODataResponsePart>();
	for (final BatchRequestPart part : requestParts) {
		responseParts.add(facade.handleBatchRequest(part));
	}

	// 5. Create a new boundary for the response
	final String responseBoundary = "batch_" + UUID.randomUUID().toString();

	// 6. Serialize the response content
	final InputStream responseContent = odata.createFixedFormatSerializer().batchResponse(responseParts,
			responseBoundary);

	// 7. Setup response
	response.setHeader(HttpHeader.CONTENT_TYPE, ContentType.MULTIPART_MIXED + ";boundary=" + responseBoundary);
	response.setContent(responseContent);
	response.setStatusCode(HttpStatusCode.ACCEPTED.getStatusCode());

}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:34,代码来源:SparqlBatchProcessor.java

示例3: parseBatchRequest

import org.apache.olingo.server.api.deserializer.batch.BatchOptions; //导入依赖的package包/类
@Override
public List<BatchRequestPart> parseBatchRequest(final InputStream content, final String boundary,
    final BatchOptions options)
        throws BatchDeserializerException {
  final BatchParser parser = new BatchParser();

  return parser.parseBatchRequest(content, boundary, options);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:9,代码来源:FixedFormatDeserializerImpl.java

示例4: parseBatchRequest

import org.apache.olingo.server.api.deserializer.batch.BatchOptions; //导入依赖的package包/类
public List<BatchRequestPart> parseBatchRequest(final InputStream content, final String boundary,
    final BatchOptions options)
    throws BatchDeserializerException {
  this.options = options;

  BatchRequestTransformator transformator = new BatchRequestTransformator(options.getRawBaseUri(),
      options.getRawServiceResolutionUri());
  return parse(content, boundary, transformator);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:10,代码来源:BatchParser.java

示例5: boundaryParameterWithQuotes

import org.apache.olingo.server.api.deserializer.batch.BatchOptions; //导入依赖的package包/类
@Test
public void boundaryParameterWithQuotes() throws Exception {
  final String boundary = "batch_1.2+34:2j)0?";
  final String batch = "--" + boundary + CRLF
      + GET_REQUEST
      + "--" + boundary + "--";
  final List<BatchRequestPart> batchRequestParts = new BatchParser().parseBatchRequest(
      IOUtils.toInputStream(batch),
      boundary,
      BatchOptions.with().isStrict(true).rawBaseUri(SERVICE_ROOT).build());

  Assert.assertNotNull(batchRequestParts);
  Assert.assertFalse(batchRequestParts.isEmpty());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:15,代码来源:BatchRequestParserTest.java

示例6: parse

import org.apache.olingo.server.api.deserializer.batch.BatchOptions; //导入依赖的package包/类
private List<BatchRequestPart> parse(final InputStream in, final boolean isStrict)
    throws BatchDeserializerException {
  final List<BatchRequestPart> batchRequestParts =
      new BatchParser().parseBatchRequest(in, BOUNDARY,
          BatchOptions.with().isStrict(isStrict).rawBaseUri(SERVICE_ROOT).build());
  Assert.assertNotNull(batchRequestParts);
  return batchRequestParts;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:9,代码来源:BatchRequestParserTest.java

示例7: parseInvalidBatchBody

import org.apache.olingo.server.api.deserializer.batch.BatchOptions; //导入依赖的package包/类
private void parseInvalidBatchBody(final String batch, final MessageKeys key, final boolean isStrict) {
  try {
    new BatchParser().parseBatchRequest(IOUtils.toInputStream(batch), BOUNDARY,
        BatchOptions.with().isStrict(isStrict).rawBaseUri(SERVICE_ROOT).build());
    Assert.fail("No exception thrown. Expected: " + key);
  } catch (BatchDeserializerException e) {
    Assert.assertEquals(key, e.getMessageKey());
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:10,代码来源:BatchRequestParserTest.java

示例8: processBatch

import org.apache.olingo.server.api.deserializer.batch.BatchOptions; //导入依赖的package包/类
@Override
public void processBatch(final BatchFacade fascade, final ODataRequest request, final ODataResponse response)
    throws ODataApplicationException, BatchSerializerException, ODataLibraryException {
  final String boundary = getBoundary(request.getHeader(HttpHeader.CONTENT_TYPE));
  final BatchOptions options = BatchOptions.with().isStrict(true).rawBaseUri(BASE_URI).build();
  final List<BatchRequestPart> parts =
      odata.createFixedFormatDeserializer().parseBatchRequest(request.getBody(), boundary, options);
  final List<ODataResponsePart> responseParts = new ArrayList<ODataResponsePart>();

  for (BatchRequestPart part : parts) {
    for (final ODataRequest oDataRequest : part.getRequests()) {
      // Mock the processor for a given requests
      when(oDataHandler.process(oDataRequest)).then(new Answer<ODataResponse>() {
        @Override
        public ODataResponse answer(final InvocationOnMock invocation) throws Throwable {
          Object[] arguments = invocation.getArguments();

          return buildResponse((ODataRequest) arguments[0]);
        }
      });
    }

    responseParts.add(fascade.handleBatchRequest(part));
  }

  final String responeBoundary = "batch_" + UUID.randomUUID().toString();
  final InputStream responseStream =
      odata.createFixedFormatSerializer().batchResponse(responseParts, responeBoundary);

  response.setStatusCode(HttpStatusCode.ACCEPTED.getStatusCode());
  response.setHeader(HttpHeader.CONTENT_TYPE, ContentType.MULTIPART_MIXED + ";boundary=" + responeBoundary);
  response.setContent(responseStream);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:34,代码来源:MockedBatchHandlerTest.java

示例9: processBatch

import org.apache.olingo.server.api.deserializer.batch.BatchOptions; //导入依赖的package包/类
@Override
public void processBatch(final BatchFacade facade, final ODataRequest request, final ODataResponse response)
    throws ODataApplicationException, ODataLibraryException {
  
  // 1. Extract the boundary
  final String boundary = facade.extractBoundaryFromContentType(request.getHeader(HttpHeader.CONTENT_TYPE));
  
  // 2. Prepare the batch options
  final BatchOptions options = BatchOptions.with().rawBaseUri(request.getRawBaseUri())
                                                  .rawServiceResolutionUri(request.getRawServiceResolutionUri())
                                                  .build();
  
  // 3. Deserialize the batch request
  final List<BatchRequestPart> requestParts = odata.createFixedFormatDeserializer()
                                                   .parseBatchRequest(request.getBody(), boundary, options);
  
  // 4. Execute the batch request parts
  final List<ODataResponsePart> responseParts = new ArrayList<ODataResponsePart>();
  for (final BatchRequestPart part : requestParts) {
    responseParts.add(facade.handleBatchRequest(part));
  }

  // 5. Serialize the response content
  final InputStream responseContent = odata.createFixedFormatSerializer().batchResponse(responseParts, boundary);
  
  // 6. Create a new boundary for the response
  final String responseBoundary = "batch_" + UUID.randomUUID().toString();

  // 7. Setup response
  response.setHeader(HttpHeader.CONTENT_TYPE, ContentType.MULTIPART_MIXED + ";boundary=" + responseBoundary);
  response.setContent(responseContent);
  response.setStatusCode(HttpStatusCode.ACCEPTED.getStatusCode());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:34,代码来源:DemoBatchProcessor.java

示例10: processBatch

import org.apache.olingo.server.api.deserializer.batch.BatchOptions; //导入依赖的package包/类
@Override
public void processBatch(final BatchFacade facade, final ODataRequest request, final ODataResponse response)
    throws ODataApplicationException, ODataLibraryException {
  
  // 1. Extract the boundary
  final String boundary = facade.extractBoundaryFromContentType(request.getHeader(HttpHeader.CONTENT_TYPE));
  
  // 2. Prepare the batch options
  final BatchOptions options = BatchOptions.with().rawBaseUri(request.getRawBaseUri())
                                                  .rawServiceResolutionUri(request.getRawServiceResolutionUri())
                                                  .build();
  
  // 3. Deserialize the batch request
  final List<BatchRequestPart> requestParts = odata.createFixedFormatDeserializer()
                                                   .parseBatchRequest(request.getBody(), boundary, options);
  
  // 4. Execute the batch request parts
  final List<ODataResponsePart> responseParts = new ArrayList<ODataResponsePart>();
  for (final BatchRequestPart part : requestParts) {
    responseParts.add(facade.handleBatchRequest(part));
  }

  // 5. Create a new boundary for the response
  final String responseBoundary = "batch_" + UUID.randomUUID().toString();

  // 6. Serialize the response content
  final InputStream responseContent = odata.createFixedFormatSerializer().batchResponse(responseParts, responseBoundary);

  // 7. Setup response
  response.setHeader(HttpHeader.CONTENT_TYPE, ContentType.MULTIPART_MIXED + ";boundary=" + responseBoundary);
  response.setContent(responseContent);
  response.setStatusCode(HttpStatusCode.ACCEPTED.getStatusCode());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:34,代码来源:DemoBatchProcessor.java

示例11: processBatch

import org.apache.olingo.server.api.deserializer.batch.BatchOptions; //导入依赖的package包/类
@Override
public void processBatch(final BatchFacade facade, final ODataRequest request, final ODataResponse response)
    throws ODataApplicationException, ODataLibraryException {
  // only the first batch call (process batch) must be handled in a separate way for async support
  // because a changeset has to be wrapped within a process batch call
  if(odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).hasRespondAsync()) {
    TechnicalAsyncService asyncService = TechnicalAsyncService.getInstance();
    BatchProcessor processor = new TechnicalBatchProcessor(dataProvider);
    processor.init(odata, serviceMetadata);
    AsyncProcessor<BatchProcessor> asyncProcessor = asyncService.register(processor, BatchProcessor.class);
    asyncProcessor.prepareFor().processBatch(facade, request, response);
    String location = asyncProcessor.processAsync();
    TechnicalAsyncService.acceptedResponse(response, location);
    //
    return;
  }


  final boolean continueOnError =
      odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).hasContinueOnError();

  final String boundary = facade.extractBoundaryFromContentType(request.getHeader(HttpHeader.CONTENT_TYPE));
  final BatchOptions options = BatchOptions.with()
      .rawBaseUri(request.getRawBaseUri())
      .rawServiceResolutionUri(request.getRawServiceResolutionUri()).build();
  final List<BatchRequestPart> parts = odata.createFixedFormatDeserializer().parseBatchRequest(request.getBody(),
      boundary, options);
  final List<ODataResponsePart> responseParts = new ArrayList<ODataResponsePart>();

  for (BatchRequestPart part : parts) {
    final ODataResponsePart responsePart = facade.handleBatchRequest(part);
    responseParts.add(responsePart); // Also add failed responses.
    final int statusCode = responsePart.getResponses().get(0).getStatusCode();

    if ((statusCode >= 400 && statusCode <= 600) && !continueOnError) {

      // Perform some additional actions.
      // ...

      break; // Stop processing, but serialize responses to all recent requests.
    }
  }

  final String responseBoundary = "batch_" + UUID.randomUUID().toString();
  final InputStream responseContent =
      odata.createFixedFormatSerializer().batchResponse(responseParts, responseBoundary);
  response.setHeader(HttpHeader.CONTENT_TYPE, ContentType.MULTIPART_MIXED + ";boundary=" + responseBoundary);
  response.setContent(responseContent);
  response.setStatusCode(HttpStatusCode.OK.getStatusCode());
  if (continueOnError) {
    response.setHeader(HttpHeader.PREFERENCE_APPLIED,
        PreferencesApplied.with().continueOnError().build().toValueString());
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:55,代码来源:TechnicalBatchProcessor.java

示例12: parseBatchRequest

import org.apache.olingo.server.api.deserializer.batch.BatchOptions; //导入依赖的package包/类
/**
 * Reads batch data from an InputStream.
 * @param content the data as multipart input stream
 * @param boundary the boundary between the parts
 * @param options options for the deserializer
 * @return a list of batch-request parts
 */
public List<BatchRequestPart> parseBatchRequest(InputStream content, String boundary, BatchOptions options)
    throws BatchDeserializerException;
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:10,代码来源:FixedFormatDeserializer.java


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