connectionUtils/src/main/java/com/ge/research/semtk/sparqlX/NeptuneSparqlEndpointInterface.java
@SuppressWarnings({ "unchecked" })
	private String uploadFromS3(String keyName, String format) throws Exception {
		// start the upload
        //curl blast-cluster.cluster-ceg7ggop9fho.us-east-1.neptune.amazonaws.com:8182/loader
        //-X POST 
        //-H 'Content-Type: application/json'
        //-d 
        //'{ "source" : "s3://blast-neptune/Proposal.owl", 
        //   "format" : "rdfxml", 
        //   "iamRoleArn" : "arn:aws:iam::378058653094:role/NeptuneLoadFromS3", 
        //   "region" : "us-east-1", 
        //   "failOnError" : "TRUE", 
        //   "parserConfiguration" : { "namedGraphUri" : "http://kdl.ge.com/blast-ontology" } 
        // }'
		
		HttpHost targetHost = this.buildHttpHost();
        CloseableHttpClient httpclient = this.buildHttpClient(targetHost.getSchemeName());
		BasicHttpContext localcontext = this.buildHttpContext(targetHost);
		HttpPost httppost = new HttpPost(this.getUploadURL());
		
		httppost.addHeader("Content-Type", "application/json");
		
		JSONObject parametersJSON = new JSONObject();
		parametersJSON.put("source", "s3://" + this.s3Conn.getName() + "/" + keyName);
		parametersJSON.put("format", format);
		parametersJSON.put("iamRoleArn", this.iamRoleArn);
		parametersJSON.put("queueRequest", "TRUE");
		parametersJSON.put("region", this.s3Conn.getRegion());
		parametersJSON.put("failOnError", "TRUE");
		
		JSONObject parserConfig = new JSONObject();
		parserConfig.put("namedGraphUri", this.getGraph());
		parametersJSON.put("parserConfiguration", parserConfig);
		
		HttpEntity entity = new ByteArrayEntity(parametersJSON.toString().getBytes("UTF-8"));
		httppost.setEntity(entity);
		
		HttpResponse response_http = httpclient.execute(targetHost, httppost, localcontext);
		
		HttpEntity resp_entity = response_http.getEntity();
		String responseTxt = EntityUtils.toString(resp_entity, "UTF-8");
		JSONObject response = (JSONObject) new JSONParser().parse(responseTxt);
		
		// make sure there's a payload.loadId, otherwise throw an Exception
		if (response.containsKey("status") && response.get("status").equals("200 OK")) {
			if (!response.containsKey("payload") || ! ((JSONObject)response.get("payload")).containsKey("loadId")) {
				throw new Exception("Neptune responded with success but can't find payload.loadId in: " + response.toJSONString());
			}
		} else if (response.containsKey("detailedMessage")) {
			throw new Exception((String)response.get("detailedMessage"));
		} else {
			throw new Exception(responseTxt);
		}
		
		return (String)((JSONObject)response.get("payload")).get("loadId");
	}
/**
	 * I can't find docs for using a Java API to do this.
	 * https://docs.aws.amazon.com/neptune/latest/userguide/bulk-load.html
	 *    - doesn't have a 'Java' sub-bullet
	 *    
	 * @param keyName
	 * @param format - https://docs.aws.amazon.com/neptune/latest/userguide/bulk-load-tutorial-format.html
	 * @return
	 * @throws Exception
	 */
I can't find docs for using a Java API to do this.


I can ' t find docs for using a Java API to do this .
@SuppressWarnings({ "unchecked" })
	private String uploadFromS3(String keyName, String format) throws Exception {
		HttpHost targetHost = this.buildHttpHost();
        CloseableHttpClient httpclient = this.buildHttpClient(targetHost.getSchemeName());
		BasicHttpContext localcontext = this.buildHttpContext(targetHost);
		HttpPost httppost = new HttpPost(this.getUploadURL());
		httppost.addHeader("Content-Type", "application/json");
		JSONObject parametersJSON = new JSONObject();
		parametersJSON.put("source", "s3://" + this.s3Conn.getName() + "/" + keyName);
		parametersJSON.put("format", format);
		parametersJSON.put("iamRoleArn", this.iamRoleArn);
		parametersJSON.put("queueRequest", "TRUE");
		parametersJSON.put("region", this.s3Conn.getRegion());
		parametersJSON.put("failOnError", "TRUE");
		JSONObject parserConfig = new JSONObject();
		parserConfig.put("namedGraphUri", this.getGraph());
		parametersJSON.put("parserConfiguration", parserConfig);
		HttpEntity entity = new ByteArrayEntity(parametersJSON.toString().getBytes("UTF-8"));
		httppost.setEntity(entity);
		HttpResponse response_http = httpclient.execute(targetHost, httppost, localcontext);
		HttpEntity resp_entity = response_http.getEntity();
		String responseTxt = EntityUtils.toString(resp_entity, "UTF-8");
		JSONObject response = (JSONObject) new JSONParser().parse(responseTxt);
		if (response.containsKey("status") && response.get("status").equals("200 OK")) {
			if (!response.containsKey("payload") || ! ((JSONObject)response.get("payload")).containsKey("loadId")) {
				throw new Exception("Neptune responded with success but can't find payload.loadId in: " + response.toJSONString());
			}
		} else if (response.containsKey("detailedMessage")) {
			throw new Exception((String)response.get("detailedMessage"));
		} else {
			throw new Exception(responseTxt);
		}
		return (String)((JSONObject)response.get("payload")).get("loadId");
	}
@ SuppressWarnings ( { "unchecked" } ) private String uploadFromS3 ( String keyName , String format ) throws Exception { HttpHost targetHost = this . buildHttpHost ( ) ; CloseableHttpClient httpclient = this . buildHttpClient ( targetHost . getSchemeName ( ) ) ; BasicHttpContext localcontext = this . buildHttpContext ( targetHost ) ; HttpPost httppost = new HttpPost ( this . getUploadURL ( ) ) ; httppost . addHeader ( "Content-Type" , "application/json" ) ; JSONObject parametersJSON = new JSONObject ( ) ; parametersJSON . put ( "source" , "s3://" + this . s3Conn . getName ( ) + "/" + keyName ) ; parametersJSON . put ( "format" , format ) ; parametersJSON . put ( "iamRoleArn" , this . iamRoleArn ) ; parametersJSON . put ( "queueRequest" , "TRUE" ) ; parametersJSON . put ( "region" , this . s3Conn . getRegion ( ) ) ; parametersJSON . put ( "failOnError" , "TRUE" ) ; JSONObject parserConfig = new JSONObject ( ) ; parserConfig . put ( "namedGraphUri" , this . getGraph ( ) ) ; parametersJSON . put ( "parserConfiguration" , parserConfig ) ; HttpEntity entity = new ByteArrayEntity ( parametersJSON . toString ( ) . getBytes ( "UTF-8" ) ) ; httppost . setEntity ( entity ) ; HttpResponse response_http = httpclient . execute ( targetHost , httppost , localcontext ) ; HttpEntity resp_entity = response_http . getEntity ( ) ; String responseTxt = EntityUtils . toString ( resp_entity , "UTF-8" ) ; JSONObject response = ( JSONObject ) new JSONParser ( ) . parse ( responseTxt ) ; if ( response . containsKey ( "status" ) && response . get ( "status" ) . equals ( "200 OK" ) ) { if ( ! response . containsKey ( "payload" ) || ! ( ( JSONObject ) response . get ( "payload" ) ) . containsKey ( "loadId" ) ) { throw new Exception ( "Neptune responded with success but can't find payload.loadId in: " + response . toJSONString ( ) ) ; } } else if ( response . containsKey ( "detailedMessage" ) ) { throw new Exception ( ( String ) response . get ( "detailedMessage" ) ) ; } else { throw new Exception ( responseTxt ) ; } return ( String ) ( ( JSONObject ) response . get ( "payload" ) ) . get ( "loadId" ) ; }
I can't find docs for using a Java API to do this.
I can ' t find docs for using a Java API to do this .
// start the upload //curl blast-cluster.cluster-ceg7ggop9fho.us-east-1.neptune.amazonaws.com:8182/loader //-X POST  //-H 'Content-Type: application/json' //-d  //'{ "source" : "s3://blast-neptune/Proposal.owl",  //   "format" : "rdfxml",  //   "iamRoleArn" : "arn:aws:iam::378058653094:role/NeptuneLoadFromS3",  //   "region" : "us-east-1",  //   "failOnError" : "TRUE",  //   "parserConfiguration" : { "namedGraphUri" : "http://kdl.ge.com/blast-ontology" }  // }' // make sure there's a payload.loadId, otherwise throw an Exception