Package org.openrdf.rio

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


  @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

  {
    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

    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

      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

    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

    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

  }

  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

   * @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

   * @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 read(Repository store, String url, String syntax) throws Exception {
    RDFFormat format = null;
    if (syntax.equals("TURTLE") || syntax.equals("N3"))
      format = RDFFormat.TURTLE;
    else if (syntax.equals("RDFXML"))
      format = RDFFormat.RDFXML;
    else if (syntax.equals("NTRIPLES"))
View Full Code Here

TOP

Related Classes of org.openrdf.rio.RDFFormat

Copyright © 2018 www.massapicom. 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.