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


Java HttpRequestEntity类代码示例

本文整理汇总了Java中eu.fusepool.p3.transformer.HttpRequestEntity的典型用法代码示例。如果您正苦于以下问题:Java HttpRequestEntity类的具体用法?Java HttpRequestEntity怎么用?Java HttpRequestEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: transform

import eu.fusepool.p3.transformer.HttpRequestEntity; //导入依赖的package包/类
@Override
public void transform(HttpRequestEntity entity, String requestId)
        throws IOException {

    logMessage(entity.getRequest());

    if (!fActive.add(requestId)) {
        throw new IllegalStateException("A request with ID " + requestId + " was already in progress.");
    }

    File output = output(requestId);
    ImmutablePair<MimeType, Properties> pair = exporterOptions(entity);
    fEngine.transform(
            downloadInput(entity).toURI(),
            fetchTransform(entity),
            output.toURI(),
            pair.getRight(),
            new CallbackWrapper(requestId, output, pair.getLeft())
    );
}
 
开发者ID:fusepoolP3,项目名称:p3-batchrefine,代码行数:21,代码来源:AsynchronousTransformer.java

示例2: transform

import eu.fusepool.p3.transformer.HttpRequestEntity; //导入依赖的package包/类
@Override
public Entity transform(HttpRequestEntity entity) throws IOException {
    final MimeType mimeType = entity.getType();
    final InputStream in = entity.getData();
    final Entity output = new WritingEntity() {
        @Override
        public MimeType getType() {
            return mimeType;
        }

        @Override
        public void writeData(OutputStream out) throws IOException {
            IOUtils.copy(in, out);
        }
    };

    return output;
}
 
开发者ID:fusepoolP3,项目名称:p3-pipeline-transformer,代码行数:19,代码来源:SimpleTransformer.java

示例3: generateRdf

import eu.fusepool.p3.transformer.HttpRequestEntity; //导入依赖的package包/类
/**
 * Get SIOC content from the RDF as text and return it.
 *
 * @param entity
 * @return
 * @throws IOException
 */
@Override
protected TripleCollection generateRdf(HttpRequestEntity entity) throws IOException {
    String text = "";
    Graph graph = Parser.getInstance().parse(entity.getData(), "text/turtle");
    Iterator<Triple> triples = graph.filter(null, SIOC.content, null);
    if (triples.hasNext()) {
        Literal literal = (Literal) triples.next().getObject();
        text = literal.getLexicalForm();
    }

    final TripleCollection result = new SimpleMGraph();
    final Resource resource = entity.getContentLocation() == null
            ? new BNode()
            : new UriRef(entity.getContentLocation().toString());
    final GraphNode node = new GraphNode(resource, result);
    node.addProperty(RDF.type, TEXUAL_CONTENT);
    node.addPropertyValue(SIOC.content, text);
    node.addPropertyValue(new UriRef("http://example.org/ontology#textLength"), text.length());
    return result;
}
 
开发者ID:fusepoolP3,项目名称:p3-pipeline-transformer,代码行数:28,代码来源:SimpleRdfConsumingTransformer.java

示例4: getDocuementURI

import eu.fusepool.p3.transformer.HttpRequestEntity; //导入依赖的package包/类
/**
 * Get docuemt URI either from content location header, or generate one if it's null.
 *
 * @param entity
 * @return
 */
protected static String getDocuementURI(HttpRequestEntity entity) {
    String documentURI;

    if (entity.getContentLocation() == null) {
        HttpServletRequest request = entity.getRequest();
        String baseURL = getBaseURL(request);
        String requestID = request.getHeader("X-Request-ID");

        if (StringUtils.isNotEmpty(requestID)) {
            documentURI = baseURL + requestID;
        } else {
            documentURI = baseURL + UUID.randomUUID().toString();
        }
    } else {
        documentURI = entity.getContentLocation().toString();
    }

    return documentURI;
}
 
开发者ID:fusepoolP3,项目名称:p3-dictionary-matcher-transformer,代码行数:26,代码来源:Utils.java

示例5: generateRdf

import eu.fusepool.p3.transformer.HttpRequestEntity; //导入依赖的package包/类
@Override
protected TripleCollection generateRdf(HttpRequestEntity entity) throws IOException {
	String rdfDataFormat = SupportedFormat.TURTLE;    	    	
	InputStream configIn = null;
	String queryString = entity.getRequest().getQueryString();
	log.info("Query string: " + queryString);
	//String configUri = getRequestParamValue(queryString, "config");	
	String configUri = entity.getRequest().getParameter("config");      	
	log.info("Config file URI: " + configUri);
	
	if(configUri != null) {    	  
	  configIn = getRemoteConfigFile(configUri);
	}
	
    final InputStream inputRdfData = entity.getData();
    TripleCollection duplicates = findSameEntities(inputRdfData, rdfDataFormat, configIn);
    return duplicates;
}
 
开发者ID:fusepoolP3,项目名称:p3-silkdedup,代码行数:19,代码来源:DuplicatesTransformer.java

示例6: processRequest

import eu.fusepool.p3.transformer.HttpRequestEntity; //导入依赖的package包/类
public void processRequest(String requestId) {

            HttpRequestEntity entity = fActive.get(requestId);
            if (entity == null) {
                fCallback.reportException(requestId,
                        new IllegalStateException("Request " + requestId + " is no longer active. " +
                                "Maybe there was an ID collision?"));
                return;
            }

            try {
                fCallback.responseAvailable(requestId, transform(entity));
            } catch (Exception ex) {
                fCallback.reportException(requestId, ex);
            }
        }
 
开发者ID:fusepoolP3,项目名称:p3-transformer-howto,代码行数:17,代码来源:AsyncSedTransformer.java

示例7: fetchTransform

import eu.fusepool.p3.transformer.HttpRequestEntity; //导入依赖的package包/类
protected JSONArray fetchTransform(HttpRequestEntity request)
        throws IOException {

    String transformURI = getSingleParameter(TRANSFORM_PARAMETER,
            request.getRequest());

    CloseableHttpClient client = null;
    CloseableHttpResponse response = null;

    try {
        HttpGet get = new HttpGet(transformURI);
        get.addHeader("Accept", "application/json");

        client = HttpClients.createDefault();
        response = performRequest(get, client);

        HttpEntity responseEntity = response.getEntity();
        if (responseEntity == null) {
            // TODO proper error reporting
            throw new IOException("Could not GET transform JSON from "
                    + transformURI + ".");
        }

        String encoding = null;
        if (responseEntity.getContentType() != null) {
            encoding = MimeTypes.getCharsetFromContentType(responseEntity.getContentType().getValue());
        }

        String transform = IOUtils.toString(responseEntity.getContent(),
                encoding == null ? "UTF-8" : encoding);

        return ParsingUtilities.evaluateJsonStringToArray(transform);
    } finally {
        IOUtils.closeQuietly(response);
        IOUtils.closeQuietly(client);
    }
}
 
开发者ID:fusepoolP3,项目名称:p3-batchrefine,代码行数:38,代码来源:BatchRefineTransformer.java

示例8: containsRDFMapping

import eu.fusepool.p3.transformer.HttpRequestEntity; //导入依赖的package包/类
protected boolean containsRDFMapping(HttpRequestEntity request) throws IOException {
    JSONArray transform = fetchTransform(request);
    for (int i = 0; i < transform.length(); i++) {
        JSONObject operation = transform.optJSONObject(i);
        if (operation != null && operation.get("op") == "rdf-extension/save-rdf-schema")
            return true;
    }
    return false;
}
 
开发者ID:fusepoolP3,项目名称:p3-batchrefine,代码行数:10,代码来源:BatchRefineTransformer.java

示例9: transform

import eu.fusepool.p3.transformer.HttpRequestEntity; //导入依赖的package包/类
@Override
public Entity transform(HttpRequestEntity entity) throws IOException {
    logMessage(entity.getRequest());

    final HttpRequestEntity request = cast(entity);

    final ImmutablePair<MimeType, Properties> options = exporterOptions(request);
    options.right.putAll(transformerConfig);
    final File input = downloadInput(entity);
    final File output = File.createTempFile("reply", "tmp");

    final ITransformEngine engine = getEngine();

    return new WritingEntity() {
        @Override
        public void writeData(OutputStream out) throws IOException {
            try {
                // Can't allow more than one transform at a time as OpenRefine is not
                // designed for that.
                synchronized (SynchronousTransformer.this) {
                    engine.transform(input.toURI(), fetchTransform(request), output.toURI(),
                            options.right);
                }

                try (FileInputStream stream = new FileInputStream(output)) {
                    IOUtils.copy(stream, out);
                }
            } finally {
                input.delete();
                output.delete();
            }
        }

        @Override
        public MimeType getType() {
            return options.left;
        }
    };
}
 
开发者ID:fusepoolP3,项目名称:p3-batchrefine,代码行数:40,代码来源:SynchronousTransformer.java

示例10: cast

import eu.fusepool.p3.transformer.HttpRequestEntity; //导入依赖的package包/类
private HttpRequestEntity cast(Entity entity) throws IOException {
    // TODO have to discuss with Reto how to properly:
    // 1 - handle/report error conditions (for now I just throw
    // IOException);
    // 2 - properly get the parameters from the enclosing HTTP request.
    if (!(entity instanceof HttpRequestEntity)) {
        throw new IOException("BatchRefineTransformer requires a "
                + HttpRequestEntity.class.getName());
    }

    return (HttpRequestEntity) entity;
}
 
开发者ID:fusepoolP3,项目名称:p3-batchrefine,代码行数:13,代码来源:SynchronousTransformer.java

示例11: transform

import eu.fusepool.p3.transformer.HttpRequestEntity; //导入依赖的package包/类
@Override
public Entity transform(HttpRequestEntity entity) throws IOException {
    // get mimetype of content
    final MimeType mimeType = entity.getType();

    // convert content to byte array
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    IOUtils.copy(entity.getData(), baos);
    final byte[] bytes = baos.toByteArray();

    // get content location header
    final URI contentLocation = entity.getContentLocation();

    // create Entity from content
    final Entity input = new InputStreamEntity() {
        @Override
        public MimeType getType() {
            return mimeType;
        }

        @Override
        public InputStream getData() throws IOException {
            return new ByteArrayInputStream(bytes);
        }

        @Override
        public URI getContentLocation() {
            return contentLocation;
        }
    };

    // run pipeline
    final Entity output = pipeline.run(input, accept);

    return output;
}
 
开发者ID:fusepoolP3,项目名称:p3-pipeline-transformer,代码行数:37,代码来源:PipelineTransformer.java

示例12: generateRdf

import eu.fusepool.p3.transformer.HttpRequestEntity; //导入依赖的package包/类
@Override
protected TripleCollection generateRdf(HttpRequestEntity entity) throws IOException {
    final String text = IOUtils.toString(entity.getData(), "UTF-8");
    final TripleCollection result = new SimpleMGraph();
    final Resource resource = entity.getContentLocation() == null
            ? new BNode()
            : new UriRef(entity.getContentLocation().toString());
    final GraphNode node = new GraphNode(resource, result);
    node.addProperty(RDF.type, TEXUAL_CONTENT);
    node.addPropertyValue(SIOC.content, text);
    node.addPropertyValue(new UriRef("http://example.org/ontology#textLength"), text.length());
    return result;
}
 
开发者ID:fusepoolP3,项目名称:p3-pipeline-transformer,代码行数:14,代码来源:SimpleRdfProducingTransformer.java

示例13: generateRdf

import eu.fusepool.p3.transformer.HttpRequestEntity; //导入依赖的package包/类
/**
 * Takes the RDF data sent by the client and the graph name (url) of the knowledge base to search
 * for points of interest nearby the locations described in the client graph and sends it back enriched with
 * information about the points of interest that have been found. It looks for the knowledge base name in the triple store
 * before fetching the data from the url.    
 */
@Override
protected TripleCollection generateRdf(HttpRequestEntity entity) throws IOException {
    TripleCollection resultGraph = null;
    String mediaType = entity.getType().toString();   
    Parser parser = Parser.getInstance();
    TripleCollection requestGraph = parser.parse( entity.getData(), mediaType);
    resultGraph = spatialDataEnhancer.enhance(kbDataUrl, requestGraph);
        
    return resultGraph;
    
}
 
开发者ID:fusepoolP3,项目名称:p3-geo-enriching-transformer,代码行数:18,代码来源:GeoEnrichingTransformer.java

示例14: transform

import eu.fusepool.p3.transformer.HttpRequestEntity; //导入依赖的package包/类
@Override
public void transform(HttpRequestEntity entity, String requestId) throws IOException {

    if (!fQueue.offer(requestId)) {
        throw new TooManyRequests("Too many requests on backlog.");
    }

    // This should generally not be a problem as we don't expect requestId
    // collisions.
    fActive.put(requestId, entity);
}
 
开发者ID:fusepoolP3,项目名称:p3-transformer-howto,代码行数:12,代码来源:AsyncSedTransformer.java

示例15: transform

import eu.fusepool.p3.transformer.HttpRequestEntity; //导入依赖的package包/类
@Override
public Entity transform(HttpRequestEntity entity) throws IOException {
    InputStream inputData = entity.getData();
    String sedSpec = checkedGet(entity, PAR_SCRIPT);

    final String transformed = Unix4j
            .from(inputData)
            .sed(sedSpec)
            .toStringResult();
        fLogger.info("transforming inputstream with: " + sedSpec);
    
    return wrapInEntity(transformed);
}
 
开发者ID:fusepoolP3,项目名称:p3-transformer-howto,代码行数:14,代码来源:SedTransformer.java


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