sparqlGraphLibrary/src/main/java/com/ge/research/semtk/edc/JobTracker.java
public boolean jobExists(String jobId) throws AuthorizationException, Exception {

		if(jobId == null){
			throw new Exception("Cannot check if job exists: jobId is null");
		}
		
		String query = String.format("  \n" +
				"prefix job:<http://research.ge.com/semtk/services/job#> \n" +
		        "prefix XMLSchema:<http://www.w3.org/2001/XMLSchema#> \n" +
				"SELECT ?id ?userName \n" +
		        "from <" + this.sei.getGraph() + "> " +
				"where { \n" +
				"   ?Job a job:Job. \n" +
				"   ?Job job:id ?id. \n" +
				"      VALUES ?id { '%s' }. \n" +
				"   ?Job job:userName ?userName. \n" +
				"}",
				SparqlToXUtils.safeSparqlString(jobId));
		
		Table jobTable = this.createSuperuserEndpoint().executeQueryToTable(query);
	    int rows = jobTable.getNumRows();
		
	    if (rows == 0) {
	    	// job does not exist
	    	return false;
	    	
	    } else if (rows == 1) {
	    	// is user authorized
	    	String jobUserName = jobTable.getCell(0, "userName");
	    	AuthorizationManager.throwExceptionIfNotJobOwner(jobUserName, "job " + jobId);
	    	
	    	// yes: one job and authorized
	    	return true;
	    	
	    } else {
	    	// multiple owners is possible in collision.  Lock everyone out.
	    	String userNames = String.join(",", jobTable.getColumn("userName"));
	    	throw new Exception("Job jobId=" + jobId + " has multiple owners: " + userNames);
	    }		
	}
/**
	 * Does jobId exist
	 * @param jobId
	 * @return
	 * @throws AuthorizationException - job exists but user is not authorized
	 * @throws Exception - any other error
	 */
Does jobId exist
@param jobId
@return
@throws AuthorizationException - job exists but user is not authorized
@throws Exception - any other error
Does jobId exist @param jobId @return @throws AuthorizationException - job exists but user is not authorized @throws Exception - any other error
public boolean jobExists(String jobId) throws AuthorizationException, Exception {
		if(jobId == null){
			throw new Exception("Cannot check if job exists: jobId is null");
		}
		String query = String.format("  \n" +
				"prefix job:<http://research.ge.com/semtk/services/job#> \n" +
		        "prefix XMLSchema:<http://www.w3.org/2001/XMLSchema#> \n" +
				"SELECT ?id ?userName \n" +
		        "from <" + this.sei.getGraph() + "> " +
				"where { \n" +
				"   ?Job a job:Job. \n" +
				"   ?Job job:id ?id. \n" +
				"      VALUES ?id { '%s' }. \n" +
				"   ?Job job:userName ?userName. \n" +
				"}",
				SparqlToXUtils.safeSparqlString(jobId));
		Table jobTable = this.createSuperuserEndpoint().executeQueryToTable(query);
	    int rows = jobTable.getNumRows();
	    if (rows == 0) {
	    	return false;
	    } else if (rows == 1) {
	    	String jobUserName = jobTable.getCell(0, "userName");
	    	AuthorizationManager.throwExceptionIfNotJobOwner(jobUserName, "job " + jobId);
	    	return true;
	    } else {
	    	String userNames = String.join(",", jobTable.getColumn("userName"));
	    	throw new Exception("Job jobId=" + jobId + " has multiple owners: " + userNames);
	    }		
	}
public boolean jobExists ( String jobId ) throws AuthorizationException , Exception { if ( jobId == null ) { throw new Exception ( "Cannot check if job exists: jobId is null" ) ; } String query = String . format ( "  \n" + "prefix job:<http://research.ge.com/semtk/services/job#> \n" + "prefix XMLSchema:<http://www.w3.org/2001/XMLSchema#> \n" + "SELECT ?id ?userName \n" + "from <" + this . sei . getGraph ( ) + "> " + "where { \n" + "   ?Job a job:Job. \n" + "   ?Job job:id ?id. \n" + "      VALUES ?id { '%s' }. \n" + "   ?Job job:userName ?userName. \n" + "}" , SparqlToXUtils . safeSparqlString ( jobId ) ) ; Table jobTable = this . createSuperuserEndpoint ( ) . executeQueryToTable ( query ) ; int rows = jobTable . getNumRows ( ) ; if ( rows == 0 ) { return false ; } else if ( rows == 1 ) { String jobUserName = jobTable . getCell ( 0 , "userName" ) ; AuthorizationManager . throwExceptionIfNotJobOwner ( jobUserName , "job " + jobId ) ; return true ; } else { String userNames = String . join ( "," , jobTable . getColumn ( "userName" ) ) ; throw new Exception ( "Job jobId=" + jobId + " has multiple owners: " + userNames ) ; } }
Does jobId exist
 @param jobId
 @return
 @throws AuthorizationException - job exists but user is not authorized
 @throws Exception - any other error
Does jobId exist @param jobId @return @throws AuthorizationException - job exists but user is not authorized @throws Exception - any other error
// job does not exist // is user authorized // yes: one job and authorized // multiple owners is possible in collision.  Lock everyone out.