Examples of RDFFormat


Examples of org.openrdf.rio.RDFFormat

    Resource[] contexts = (Resource[])model.get(CONTEXTS_KEY);
    boolean useInferencing = (Boolean)model.get(USE_INFERENCING_KEY);

    RDFWriterFactory rdfWriterFactory = (RDFWriterFactory)model.get(FACTORY_KEY);

    RDFFormat rdfFormat = rdfWriterFactory.getRDFFormat();

    try {
      OutputStream out = response.getOutputStream();
      RDFWriter rdfWriter = rdfWriterFactory.getWriter(out);

      response.setStatus(SC_OK);

      String mimeType = rdfFormat.getDefaultMIMEType();
      if (rdfFormat.hasCharset()) {
        Charset charset = rdfFormat.getCharset();
        mimeType += "; charset=" + charset.name();
      }
      response.setContentType(mimeType);

      String filename = "statements";
      if (rdfFormat.getDefaultFileExtension() != null) {
        filename += "." + rdfFormat.getDefaultFileExtension();
      }
      response.setHeader("Content-Disposition", "attachment; filename=" + filename);

      repositoryCon.exportStatements(subj, pred, obj, useInferencing, rdfWriter, contexts);
View Full Code Here

Examples of org.openrdf.rio.RDFFormat

    URL url = new URL(location);
    HttpURLConnection conn = (HttpURLConnection)url.openConnection();
    conn.setRequestMethod("PUT");
    conn.setDoOutput(true);

    RDFFormat dataFormat = RDFFormat.forFileName(file, RDFFormat.RDFXML);
    conn.setRequestProperty("Content-Type", dataFormat.getDefaultMIMEType());

    InputStream dataStream = ProtocolTest.class.getResourceAsStream(file);
    try {
      OutputStream connOut = conn.getOutputStream();
View Full Code Here

Examples of org.openrdf.rio.RDFFormat

  @SuppressWarnings("unchecked")
  public void render(Map model, HttpServletRequest request, HttpServletResponse response)
    throws IOException
  {
    RDFWriterFactory rdfWriterFactory = (RDFWriterFactory)model.get(FACTORY_KEY);
    RDFFormat rdfFormat = rdfWriterFactory.getRDFFormat();

    response.setStatus(SC_OK);
    setContentType(response, rdfFormat);
    setContentDisposition(model, response, rdfFormat);
View Full Code Here

Examples of org.openrdf.rio.RDFFormat

  {
    ProtocolUtil.logRequestParameters(request);

    String mimeType = HttpServerUtil.getMIMEType(request.getContentType());

    RDFFormat rdfFormat = Rio.getParserFormatForMIMEType(mimeType);
    if (rdfFormat == null) {
      throw new ClientHTTPException(SC_UNSUPPORTED_MEDIA_TYPE, "Unsupported MIME type: " + mimeType);
    }

    ValueFactory vf = repository.getValueFactory();

    Resource[] contexts = ProtocolUtil.parseContextParam(request, CONTEXT_PARAM_NAME, vf);
    URI baseURI = ProtocolUtil.parseURIParam(request, BASEURI_PARAM_NAME, vf);

    if (baseURI == null) {
      baseURI = vf.createURI("foo:bar");
      logger.info("no base URI specified, using dummy '{}'", baseURI);
    }

    InputStream in = request.getInputStream();
    try {
      boolean wasAutoCommit = repositoryCon.isAutoCommit();
      repositoryCon.setAutoCommit(false);

      if (replaceCurrent) {
        repositoryCon.clear(contexts);
      }
      repositoryCon.add(in, baseURI.toString(), rdfFormat, contexts);

      repositoryCon.setAutoCommit(wasAutoCommit);

      return new ModelAndView(EmptySuccessView.getInstance());
    }
    catch (UnsupportedRDFormatException e) {
      throw new ClientHTTPException(SC_UNSUPPORTED_MEDIA_TYPE, "No RDF parser available for format "
          + rdfFormat.getName());
    }
    catch (RDFParseException e) {
      ErrorInfo errInfo = new ErrorInfo(ErrorType.MALFORMED_DATA, e.getMessage());
      throw new ClientHTTPException(SC_BAD_REQUEST, errInfo.toString());
    }
View Full Code Here

Examples of org.openrdf.rio.RDFFormat

    Map<String, Object> result = new HashMap<String, Object>();

    Map<String, String> rdfFormats = new TreeMap<String, String>();

    for (RDFParserFactory factory : RDFParserRegistry.getInstance().getAll()) {
      RDFFormat format = factory.getRDFFormat();
      rdfFormats.put(format.getName(), format.getName());
    }

    result.put("formats", rdfFormats);

    return result;
View Full Code Here

Examples of org.openrdf.rio.RDFFormat

      result.setMethod(method);
      Header contentType = method.getResponseHeader("Content-Type");

      /* Interpret response for successful requests */
      if (HttpStatusCodes.isSuccess(method.getStatusCode())) {   
        RDFFormat format = guessFormat(contentType != null ? contentType.getValue() : null);
        Graph g = null;

        try {
          g = parseRdf(method, format);
        } catch (Exception e) {
View Full Code Here

Examples of org.openrdf.rio.RDFFormat

    RepositoryConnection con = manifestRep.getConnection();

    logger.debug("Loading manifest data");
    URL manifest = new URL(MANIFEST_FILE);
    RDFFormat rdfFormat = RDFFormat.forFileName(MANIFEST_FILE, RDFFormat.TURTLE);
    con.add(manifest, MANIFEST_FILE, rdfFormat);

    logger.info("Searching for sub-manifests");
    List<String> subManifestList = new ArrayList<String>();
View Full Code Here

Examples of org.openrdf.rio.RDFFormat

    throws Exception
  {
    RepositoryConnection con = dataRep.getConnection();
    con.setAutoCommit(false);
    try {
      RDFFormat rdfFormat = Rio.getParserFormatForFileName(graphURI.toString(), RDFFormat.TURTLE);
      RDFParser rdfParser = Rio.createParser(rdfFormat, dataRep.getValueFactory());
      rdfParser.setVerifyData(false);
      rdfParser.setDatatypeHandling(DatatypeHandling.IGNORE);
      // rdfParser.setPreserveBNodeIDs(true);
View Full Code Here

Examples of org.openrdf.rio.RDFFormat

  }

  private Set<Statement> readExpectedGraphQueryResult()
    throws Exception
  {
    RDFFormat rdfFormat = Rio.getParserFormatForFileName(resultFileURL);

    if (rdfFormat != null) {
      RDFParser parser = Rio.createParser(rdfFormat);
      parser.setDatatypeHandling(DatatypeHandling.IGNORE);
      parser.setPreserveBNodeIDs(true);
View Full Code Here

Examples of org.openrdf.rio.RDFFormat

   * @param url The <code>String</code> location of the data
   * @param syntax The <code>String</code> syntax of the data
   * @throws Exception For any problems encountered during read of data from the URL
   */
  public static void loadTriples(Repository store, File file, HashMap<String,String> parameters, Resource ... context) throws Exception {
    RDFFormat format = null;
    if (file.getName().endsWith(".nt"))
        format = RDFFormat.NTRIPLES;
    else if (file.getName().endsWith(".rdf"))
        format = RDFFormat.RDFXML;
    else if (file.getName().endsWith(".n3"))
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.