Class AGHttpRepoClient

java.lang.Object
com.franz.agraph.http.AGHttpRepoClient
All Implemented Interfaces:
AutoCloseable

public class AGHttpRepoClient extends Object implements AutoCloseable
The HTTP layer for interacting with AllegroGraph.
  • Field Details

  • Constructor Details

  • Method Details

    • getDefaultSessionLifetime

      public static long getDefaultSessionLifetime()
      Gets the default lifetime of sessions spawned by any instance unless otherwise specified by setSessionLifetime(int)
      Returns:
      long defaultSessionLifetimeInSeconds
    • setDefaultSessionLifetime

      public static void setDefaultSessionLifetime(int lifetimeInSeconds)
      Sets the default lifetime of sessions spawned by any instance when none is specified by setSessionLifetime(int)

      Defaults to 3600 seconds (1 hour).

      Parameters:
      lifetimeInSeconds - Number of seconds before the session times out
    • getStorableValue

      public static Value getStorableValue(Value v, AGValueFactory vf, boolean allowExternalBlankNodeIds)
    • getApplicationResource

      public static Resource getApplicationResource(Resource stored, AGValueFactory vf)
      Returns the application Resource for a given stored resource.

      This method is intended for use within the AG client library, not for use by applications.

      Parameters:
      stored - a stored resource
      vf - a value factory that can create new store values
      Returns:
      the application resource
      Since:
      v4.4
      See Also:
    • getApplicationValue

      public static Value getApplicationValue(Value stored, AGValueFactory vf)
      Returns the application Value for a given stored value.

      This method is intended for use within the AG client library, not for use by applications.

      Parameters:
      stored - a stored value
      vf - a value factory that can create new store values
      Returns:
      the application value
      Since:
      v4.4
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getRoot

      public String getRoot() throws AGHttpException
      Throws:
      AGHttpException
    • usingMainPortForSessions

      public boolean usingMainPortForSessions()
      Checks the System property com.franz.agraph.http.useMainPortForSessions (defaults to false).
      Returns:
      boolean true if proxying sessions through the main server port.
    • getValueFactory

      public AGValueFactory getValueFactory()
    • getSessionLifetime

      public int getSessionLifetime()
      Returns the 'lifetime' for a dedicated session spawned by this instance.
      Returns:
      lifetime in seconds
    • setSessionLifetime

      public void setSessionLifetime(int lifetimeInSeconds)
      Sets the 'lifetime' for a dedicated session spawned by this instance.
      Parameters:
      lifetimeInSeconds - an integer number of seconds
    • getSessionLoadInitFile

      public boolean getSessionLoadInitFile()
      Returns true if the initfile (if any) will be loaded by dedicated sessions spawned by this instance.
      Returns:
      boolean the current setting of 'loadInitFile'
    • setSessionLoadInitFile

      public void setSessionLoadInitFile(boolean loadInitFile)
      When true, dedicated sessions will load the initfile upon creation.
      Parameters:
      loadInitFile - boolean indicating the new value to set
    • addSessionLoadScript

      public void addSessionLoadScript(String scriptName)
      Adds a 'script' for a dedicated session spawned by this instance.
      Parameters:
      scriptName - the name of the script to be added to the list of scripts loaded for this session
    • getPreferredTQRFormat

      public TupleQueryResultFormat getPreferredTQRFormat()
      Fetch the preferred TupleQueryResultFormat.
      Returns:
      TupleQueryResultFormat the current preferred format
    • setPreferredTQRFormat

      public void setPreferredTQRFormat(TupleQueryResultFormat preferredTQRFormat)
      Set the preferred TupleQueryResultFormat
      Parameters:
      preferredTQRFormat - the new value to set as preferred
    • getPreferredBQRFormat

      public BooleanQueryResultFormat getPreferredBQRFormat()
    • setPreferredBQRFormat

      public void setPreferredBQRFormat(BooleanQueryResultFormat preferredBQRFormat)
    • getDefaultRDFFormat

      public RDFFormat getDefaultRDFFormat()
      Gets the default RDFFormat to use in making requests that return RDF statements; the format should support contexts.

      Gets System property com.franz.agraph.http.defaultRDFFormat (NQUADS and TRIX are currently supported), defaults to TRIX if the property is not present, and returns the corresponding RDFFormat.

      Returns:
      an RDFFormat, either NQUADS or TRIX
    • getPreferredRDFFormat

      public RDFFormat getPreferredRDFFormat()
      Gets the RDFFormat to use in making requests that return RDF statements.

      Defaults to the format returned by getDefaultRDFFormat()

      Returns:
      an RDFFormat, either NQUADS or TRIX
    • setPreferredRDFFormat

      public void setPreferredRDFFormat(RDFFormat preferredRDFFormat)
      Sets the RDFFormat to use in making requests that return RDF statements; the format must support contexts.

      AGRDFFormat.NQUADS and RDFFormat.TRIX are currently supported. Defaults to the format returned by getDefaultRDFFormat()

      Parameters:
      preferredRDFFormat - The new RDFFormat to set as preferred
    • getServerURL

      public String getServerURL()
    • getHTTPClient

      public AGHTTPClient getHTTPClient()
    • getStatements

      public void getStatements(Resource subj, IRI pred, Value obj, String includeInferred, RDFHandler handler, Resource... contexts) throws RDFHandlerException, AGHttpException
      Throws:
      RDFHandlerException
      AGHttpException
    • getStatementsCountLimit

      public void getStatementsCountLimit(int limit, Resource subj, IRI pred, Value obj, String includeInferred, AGResponseHandler handler, Resource... contexts) throws AGHttpException
      Retrieves the count of statements matching the provided subject, predicate, object and contexts, but does not read more than a specified number of statements; feeds the result to the response handler.
      Parameters:
      limit - Maximum number of statements to count
      subj - Subject filter
      pred - Predicate filter
      obj - Object filter
      includeInferred - If true, inferred triples will be included in the set
      handler - Response handler
      contexts - Optional context filter
      Throws:
      AGHttpException - if an error occurs.
    • getStatementsLimit

      public void getStatementsLimit(int limit, Resource subj, IRI pred, Value obj, String includeInferred, AGResponseHandler handler, Resource... contexts) throws AGHttpException
      Retrieves up to a specified number of statements matching the provided subject, predicate, object and contexts, and feeds the result to the response handler.
      Parameters:
      limit - Maximum number of statements to retrieve
      subj - Subject filter
      pred - Predicate filter
      obj - Object filter
      includeInferred - If true, inferred triples will be included in the result
      handler - Response handler
      contexts - Optional context filter
      Throws:
      AGHttpException - if an error occurs.
    • getStatements

      public void getStatements(Resource subj, IRI pred, Value obj, String includeInferred, AGResponseHandler handler, Resource... contexts) throws AGHttpException
      Throws:
      AGHttpException
    • getStatements

      public void getStatements(RDFHandler handler, String... ids) throws AGHttpException
      Throws:
      AGHttpException
    • getStatements

      public void getStatements(AGResponseHandler handler, String... ids) throws AGHttpException
      Throws:
      AGHttpException
    • addStatements

      public void addStatements(Resource subj, IRI pred, Value obj, Resource... contexts) throws AGHttpException
      Throws:
      AGHttpException
    • deleteStatements

      public void deleteStatements(Resource subj, IRI pred, Value obj, Resource... contexts) throws AGHttpException
      Throws:
      AGHttpException
    • isDedicatedSession

      public boolean isDedicatedSession()
    • isAutoCommit

      public boolean isAutoCommit() throws AGHttpException
      Throws:
      AGHttpException
    • setAutoCommit

      public void setAutoCommit(boolean autoCommit) throws AGHttpException
      Throws:
      AGHttpException
    • getUploadCommitPeriod

      public int getUploadCommitPeriod()
      Gets the commit period used when uploading statements.
      Returns:
      int The value of the current commit period in triples
      See Also:
    • setUploadCommitPeriod

      public void setUploadCommitPeriod(int period)
      Sets the commit period to use when uploading statements.

      Causes a commit to happen after every period=N added statements inside a call to

      upload(String, HttpEntity, String, boolean, String, IRI, RDFFormat, Resource...)

      Defaults to period=0, meaning that no commits are done in an upload.

      Setting period > 0 can be used to work around the fact that uploading a huge amount of statements in a single transaction will require excessive amounts of memory.

      Parameters:
      period - A non-negative integer
      See Also:
    • commit

      public void commit(AGHttpRepoClient.CommitPhase phase, Xid xid) throws AGHttpException
      Prepares or finalizes a previous prepared commit depending on the value of phase.
      Parameters:
      phase - CommitPhase.PREPARE or CommitPhase.COMMIT
      xid - The transaction xid
      Throws:
      AGHttpException - if an error occurs.
    • commit

      public void commit() throws AGHttpException
      Throws:
      AGHttpException
    • rollback

      public void rollback() throws AGHttpException
      Throws:
      AGHttpException
    • rollback

      public void rollback(Xid xid) throws AGHttpException
      Aborts a previously prepared commit
      Parameters:
      xid - The transaction id of the prepared commit to abort.
      Throws:
      AGHttpException - if an error occurs.
    • getPreparedTransactions

      public Xid[] getPreparedTransactions() throws DecoderException
      Returns:
      an array of Xids of transactions that are in the prepared state on the server.
      Throws:
      DecoderException - if the response from the server is invalid.
    • setSendRollbackHeader

      public void setSendRollbackHeader(boolean sendRollbackHeader)
      When set to true, an x-rollback header will be passed with each request made by this AGHttpRepoClient instance.
      Parameters:
      sendRollbackHeader - boolean indicating whether each request should include a rollback header.
    • clearNamespaces

      public void clearNamespaces() throws AGHttpException
      Throws:
      AGHttpException
    • upload

      public void upload(Reader contents, String baseURI, RDFFormat dataFormat, boolean overwrite, org.json.JSONObject attributes, Resource... contexts) throws RDFParseException, AGHttpException
      Throws:
      RDFParseException
      AGHttpException
    • upload

      public void upload(InputStream contents, String baseURI, RDFFormat dataFormat, boolean overwrite, org.json.JSONObject attributes, Resource... contexts) throws RDFParseException, AGHttpException
      Throws:
      RDFParseException
      AGHttpException
    • upload

      public void upload(InputStream contents, String baseURI, RDFFormat dataFormat, boolean overwrite, long size, String contentEncoding, org.json.JSONObject attributes, Resource... contexts) throws RDFParseException, AGHttpException
      Throws:
      RDFParseException
      AGHttpException
    • sendRDFTransaction

      public void sendRDFTransaction(InputStream rdftransaction) throws AGHttpException
      Throws:
      AGHttpException
    • sendRDFTransaction

      public void sendRDFTransaction(InputStream rdftransaction, org.json.JSONObject attributes) throws AGHttpException
      Throws:
      AGHttpException
    • uploadJSON

      public void uploadJSON(org.json.JSONArray rows, Resource... contexts) throws AGHttpException
      Throws:
      AGHttpException
    • uploadJSON

      public void uploadJSON(String url, org.json.JSONArray rows, Resource... contexts) throws AGHttpException
      Throws:
      AGHttpException
    • deleteJSON

      public void deleteJSON(org.json.JSONArray rows, Resource... contexts) throws AGHttpException
      Throws:
      AGHttpException
    • load

      public void load(IRI source, String baseURI, RDFFormat dataFormat, Resource... contexts) throws AGHttpException
      Throws:
      AGHttpException
    • load

      public void load(IRI source, String baseURI, RDFFormat dataFormat, org.json.JSONObject attributes, Resource... contexts) throws AGHttpException
      Throws:
      AGHttpException
    • load

      public void load(String serverAbsolutePath, String baseURI, RDFFormat dataFormat, Resource... contexts) throws AGHttpException
      Throws:
      AGHttpException
    • load

      public void load(String serverAbsolutePath, String baseURI, RDFFormat dataFormat, org.json.JSONObject attributes, Resource... contexts) throws AGHttpException
      Throws:
      AGHttpException
    • upload

      public void upload(org.apache.http.HttpEntity reqEntity, String baseURI, boolean overwrite, String serverSideFile, IRI serverSideURL, RDFFormat dataFormat, org.json.JSONObject attributes, Resource... contexts) throws AGHttpException
      Throws:
      AGHttpException
    • upload

      public void upload(org.apache.http.HttpEntity reqEntity, String baseURI, boolean overwrite, String serverSideFile, IRI serverSideURL, RDFFormat dataFormat, org.json.JSONObject attributes, String contentEncoding, Resource... contexts) throws AGHttpException
      Throws:
      AGHttpException
    • upload

      public void upload(String url, org.apache.http.HttpEntity reqEntity, String baseURI, boolean overwrite, String serverSideFile, IRI serverSideURL, RDFFormat dataFormat, Resource... contexts) throws AGHttpException
      Throws:
      AGHttpException
    • upload

      public void upload(String url, org.apache.http.HttpEntity reqEntity, String baseURI, boolean overwrite, String serverSideFile, IRI serverSideURL, RDFFormat dataFormat, org.json.JSONObject attributes, Resource... contexts) throws AGHttpException
      Throws:
      AGHttpException
    • upload

      public void upload(String url, org.apache.http.HttpEntity reqEntity, String baseURI, boolean overwrite, String serverSideFile, IRI serverSideURL, RDFFormat dataFormat, org.json.JSONObject attributes, String contentEncoding, Resource... contexts) throws AGHttpException
      Throws:
      AGHttpException
    • getContextIDs

      public TupleQueryResult getContextIDs() throws AGHttpException
      Throws:
      AGHttpException
    • getContextIDs

      public void getContextIDs(TupleQueryResultHandler handler) throws TupleQueryResultHandlerException, AGHttpException
      Throws:
      TupleQueryResultHandlerException
      AGHttpException
    • size

      public long size(Resource... contexts) throws AGHttpException
      Throws:
      AGHttpException
    • getNamespaces

      public TupleQueryResult getNamespaces() throws AGHttpException
      Throws:
      AGHttpException
    • getNamespaces

      public void getNamespaces(TupleQueryResultHandler handler) throws TupleQueryResultHandlerException, AGHttpException
      Throws:
      TupleQueryResultHandlerException
      AGHttpException
    • getNamespace

      public String getNamespace(String prefix) throws AGHttpException
      Throws:
      AGHttpException
    • setNamespacePrefix

      public void setNamespacePrefix(String prefix, String name) throws AGHttpException
      Throws:
      AGHttpException
    • removeNamespacePrefix

      public void removeNamespacePrefix(String prefix) throws AGHttpException
      Throws:
      AGHttpException
    • getQueryOptions

      public TupleQueryResult getQueryOptions() throws AGHttpException
      Throws:
      AGHttpException
    • getQueryOptions

      public void getQueryOptions(TupleQueryResultHandler handler) throws TupleQueryResultHandlerException, AGHttpException
      Throws:
      TupleQueryResultHandlerException
      AGHttpException
    • getQueryOption

      public String getQueryOption(String name) throws AGHttpException
      Throws:
      AGHttpException
    • setQueryOption

      public void setQueryOption(String name, String value) throws AGHttpException
      Throws:
      AGHttpException
    • removeQueryOption

      public void removeQueryOption(String name) throws AGHttpException
      Throws:
      AGHttpException
    • query

      public void query(AGQuery q, boolean analyzeOnly, AGResponseHandler handler) throws AGHttpException
      Throws:
      AGHttpException
    • deleteSavedQuery

      public void deleteSavedQuery(String queryName) throws AGHttpException
      Throws:
      AGHttpException
    • close

      public void close() throws AGHttpException
      Specified by:
      close in interface AutoCloseable
      Throws:
      AGHttpException
    • createFreetextIndex

      public void createFreetextIndex(String name, List<String> predicates, boolean indexLiterals, List<String> indexLiteralTypes, String indexResources, List<String> indexFields, int minimumWordSize, List<String> stopWords, List<String> wordFilters, List<String> innerChars, List<String> borderChars, String tokenizer) throws AGHttpException
      Creates a new freetext index with the given parameters.
      Parameters:
      name - the name of the new index
      predicates - the predicates that will cause triples to be indexed
      indexLiterals - true if literals should be indexed
      indexLiteralTypes - the datatypes of Literals that should be indexed.
      indexResources - true if resources should be indexed
      indexFields - the fields (s, p, o, g) to index.
      minimumWordSize - the smallest word that will be indexed.
      stopWords - list of words that will not be indexed
      wordFilters - filters to apply to words before they are indexed.
      innerChars - list of characters that constitute a word
      borderChars - list of characters that can begin/terminate a word
      tokenizer - the name of a supported tokenizer
      Throws:
      AGHttpException - if there's a problem with the index parameters or handling the request.

      See also the protocol documentation for freetext index parameters

      .
    • deleteFreetextIndex

      public void deleteFreetextIndex(String index) throws AGHttpException
      Delete the freetext index of the given name.
      Parameters:
      index - the name of the index to delete
      Throws:
      AGHttpException - if an error occurs while deleting
    • listFreetextIndices

      public List<String> listFreetextIndices() throws AGHttpException
      Lists the free text indices defined on the repository.
      Returns:
      a list of index names
      Throws:
      AGHttpException - if an error occurs with the request
    • getFreetextIndices

      @Deprecated public String[] getFreetextIndices() throws AGHttpException
      Deprecated.
      Returns:
      String[] the list of defined freetext indices
      Throws:
      AGHttpException - if there is a problem with the request
      See Also:
    • getFreetextIndexConfiguration

      public org.json.JSONObject getFreetextIndexConfiguration(String index) throws AGHttpException, org.json.JSONException
      Gets the configuration of the given index.
      Parameters:
      index - the name of the index to lookup
      Returns:
      JSONObject a description of the index configuration
      Throws:
      AGHttpException - if there is an error delivering the request
      org.json.JSONException - if there is an error parsing the request into JSON
    • getFreetextPredicates

      public String[] getFreetextPredicates(String index) throws AGHttpException
      Throws:
      AGHttpException
    • evalFreetextQuery

      public void evalFreetextQuery(String pattern, String expression, String index, boolean sorted, int limit, int offset, AGResponseHandler handler) throws AGHttpException
      Throws:
      AGHttpException
    • registerPredicateMapping

      public void registerPredicateMapping(IRI predicate, IRI primitiveType) throws AGHttpException
      Throws:
      AGHttpException
    • deletePredicateMapping

      public void deletePredicateMapping(IRI predicate) throws AGHttpException
      Throws:
      AGHttpException
    • getPredicateMappings

      public String[] getPredicateMappings() throws AGHttpException
      Throws:
      AGHttpException
    • registerDatatypeMapping

      public void registerDatatypeMapping(IRI datatype, IRI primitiveType) throws AGHttpException
      Throws:
      AGHttpException
    • deleteDatatypeMapping

      public void deleteDatatypeMapping(IRI datatype) throws AGHttpException
      Throws:
      AGHttpException
    • getDatatypeMappings

      public String[] getDatatypeMappings() throws AGHttpException
      Throws:
      AGHttpException
    • clearMappings

      public void clearMappings() throws AGHttpException
      Throws:
      AGHttpException
    • clearMappings

      public void clearMappings(boolean includeAutoEncodedPrimitiveTypes) throws AGHttpException
      Throws:
      AGHttpException
    • addRules

      public void addRules(String rules) throws AGHttpException
      Throws:
      AGHttpException
    • addRules

      public void addRules(InputStream rulestream) throws AGHttpException
      Throws:
      AGHttpException
    • evalInServer

      public String evalInServer(String lispForm) throws AGHttpException
      Throws:
      AGHttpException
    • evalInServer

      public String evalInServer(InputStream stream) throws AGHttpException
      Throws:
      AGHttpException
    • ping

      public void ping() throws AGHttpException
      Throws:
      AGHttpException
    • getGeoTypes

      public String[] getGeoTypes() throws AGHttpException
      Throws:
      AGHttpException
    • registerCartesianType

      public String registerCartesianType(float stripWidth, float xmin, float xmax, float ymin, float ymax) throws AGHttpException
      Throws:
      AGHttpException
    • registerSphericalType

      public String registerSphericalType(float stripWidth, String unit, float latmin, float longmin, float latmax, float longmax) throws AGHttpException
      Throws:
      AGHttpException
    • registerPolygon

      public void registerPolygon(String polygon, List<String> points) throws AGHttpException
      Throws:
      AGHttpException
    • getGeoBox

      public void getGeoBox(String type_uri, String predicate_uri, float xmin, float xmax, float ymin, float ymax, int limit, boolean infer, AGResponseHandler handler) throws AGHttpException
      Throws:
      AGHttpException
    • getGeoCircle

      public void getGeoCircle(String type_uri, String predicate_uri, float x, float y, float radius, int limit, boolean infer, AGResponseHandler handler) throws AGHttpException
      Throws:
      AGHttpException
    • getGeoHaversine

      public void getGeoHaversine(String type_uri, String predicate_uri, float lat, float lon, float radius, String unit, int limit, boolean infer, AGResponseHandler handler) throws AGHttpException
      Throws:
      AGHttpException
    • getGeoPolygon

      public void getGeoPolygon(String type_uri, String predicate_uri, String polygon, int limit, boolean infer, AGResponseHandler handler) throws AGHttpException
      Throws:
      AGHttpException
    • registerSNAGenerator

      public void registerSNAGenerator(String generator, List<String> objectOfs, List<String> subjectOfs, List<String> undirecteds, String query) throws AGHttpException
      Throws:
      AGHttpException
    • registerSNANeighborMatrix

      public void registerSNANeighborMatrix(String matrix, String generator, List<String> group, int depth) throws AGHttpException
      Throws:
      AGHttpException
    • listIndices

      public List<String> listIndices(boolean listValid) throws AGHttpException
      Returns a list of indices for this repository. When listValid is true, return all possible valid index types for this store; when listValid is false, return only the current actively managed index types.
      Parameters:
      listValid - true yields all valid types, false yields active types
      Returns:
      list of indices, never null
      Throws:
      AGHttpException - if there is a problem with the request
    • addIndex

      public void addIndex(String index) throws AGHttpException
      Adds the given index to the list of actively managed indices. This will take affect on the next commit.
      Parameters:
      index - a valid index type
      Throws:
      AGHttpException - if there is a problem with the request
      See Also:
    • dropIndex

      public void dropIndex(String index) throws AGHttpException
      Drops the given index from the list of actively managed indices. This will take affect on the next commit.
      Parameters:
      index - a valid index type
      Throws:
      AGHttpException - if there is a problem with the request
      See Also:
    • registerEncodableNamespace

      public void registerEncodableNamespace(String namespace, String format) throws AGHttpException
      Throws:
      AGHttpException
    • unregisterEncodableNamespace

      public void unregisterEncodableNamespace(String namespace) throws AGHttpException
      Throws:
      AGHttpException
    • enableTripleCache

      public void enableTripleCache(long size) throws AGHttpException
      Enables the spogi cache in this repository.
      Parameters:
      size - the size of the cache, in triples
      Throws:
      AGHttpException - if there is a problem with the request
    • registerEncodableNamespaces

      public void registerEncodableNamespaces(org.json.JSONArray formattedNamespaces) throws AGHttpException
      Throws:
      AGHttpException
    • getEncodableNamespaces

      public TupleQueryResult getEncodableNamespaces() throws AGHttpException
      Throws:
      AGHttpException
    • callStoredProcEncoded

      @Deprecated public String callStoredProcEncoded(String functionName, String moduleName, String argsEncoded) throws AGHttpException
      Deprecated.
      The stored proc feature and API are experimental, and subject to change in a future release.
      Invoke a stored procedure on the AllegroGraph server. The args must already be encoded, and the response is encoded.

      Low-level access to the data sent to the server can be done with:

      
       {@link AGDeserializer#decodeAndDeserialize(String) AGDeserializer.decodeAndDeserialize}(
           callStoredProcEncoded(functionName, moduleName,
               {@link AGSerializer#serializeAndEncode(Object[]) AGSerializer.serializeAndEncode}(args)));
       

      If an error occurs in the stored procedure then result will be a two element vector with the first element being the string "_fail_" and the second element being the error message (also a string).

      callStoredProc(String, String, Object...) does this encoding, decoding, and throws exceptions for error result.

      Parameters:
      functionName - stored proc lisp function, for example "addTwo"
      moduleName - lisp FASL file name, for example "example.fasl"
      argsEncoded - byte-encoded arguments to the stored procedure
      Returns:
      String byte-encoded response from stored proc
      Throws:
      AGHttpException - if there is a problem with the request
      Since:
      v4.2
      See Also:
    • callStoredProc

      @Deprecated public Object callStoredProc(String functionName, String moduleName, Object... args) throws AGHttpException
      Deprecated.
      The stored proc feature and API are experimental, and subject to change in a future release.
      Invoke a stored procedure on the AllegroGraph server.

      The input arguments and the return value can be: String, Integer, null, byte[], or Object[] or List of these (can be nested).

      Parameters:
      functionName - stored proc lisp function, for example "addTwo"
      moduleName - lisp FASL file name, for example "example.fasl"
      args - arguments to the stored proc
      Returns:
      Object return value of stored proc
      Throws:
      AGCustomStoredProcException - for errors from stored proc
      AGHttpException
      Since:
      v4.2
      See Also:
    • getStoreID

      public long getStoreID() throws AGHttpException
      Returns the storeID as a long
      Returns:
      The store ID
      Throws:
      AGHttpException - if there is a problem with the request
    • getTripleCacheSize

      public long getTripleCacheSize() throws AGHttpException
      Returns the size of the spogi cache.
      Returns:
      long the size of the spogi cache, in triples
      Throws:
      AGHttpException - if there is a problem with the request
    • disableTripleCache

      public void disableTripleCache() throws AGHttpException
      Disables the spogi triple cache.
      Throws:
      AGHttpException - if there is a problem with the request
    • getBlankNodes

      public String[] getBlankNodes(int blankNodeAmount) throws AGHttpException
      Throws:
      AGHttpException
    • deleteDuplicates

      public void deleteDuplicates(String comparisonMode) throws AGHttpException
      Deletes all duplicates from the store.

      The comparisonMode determines what will be deemed a "duplicate".

      If comparisonMode is "spog", quad parts (s,p,o,g) will all be compared when looking for duplicates.

      If comparisonMode is "spo", only the (s,p,o) parts will be compared; the same triple in different graphs will thus be deemed duplicates.

      See also the protocol documentation for deleting duplicates

      Parameters:
      comparisonMode - determines what is a duplicate
      Throws:
      AGHttpException - if there is a problem with the request
    • getDuplicateStatements

      public void getDuplicateStatements(String comparisonMode, RDFHandler handler) throws AGHttpException, RDFHandlerException
      Throws:
      AGHttpException
      RDFHandlerException
    • materialize

      public long materialize(AGMaterializer materializer) throws AGHttpException
      Materializes inferred statements (generates and adds them to the store).

      The materializer's configuration determines how statements are materialized.

      Parameters:
      materializer - the materializer to use
      Returns:
      long the number of statements added
      Throws:
      AGHttpException - if there is a problem with the request
      See Also:
    • deleteMaterialized

      public long deleteMaterialized(Resource inferredGraph) throws RepositoryException
      Deletes materialized statements.
      Parameters:
      inferredGraph - Graph to delete the triples from. If null the default graph will be used.
      Returns:
      long the number of statements deleted
      Throws:
      AGHttpException - if there is a problem with the request
      RepositoryException
      See Also:
    • optimizeIndices

      public void optimizeIndices(Boolean wait, int level) throws AGHttpException
      Throws:
      AGHttpException
    • optimizeIndices

      public void optimizeIndices(Boolean wait) throws AGHttpException
      Throws:
      AGHttpException
    • getSpinFunction

      public String getSpinFunction(String uri) throws AGHttpException
      Parameters:
      uri - name of the SPIN magic property to retrieve
      Returns:
      String a string representation of the property definition
      Throws:
      AGHttpException - if there is a problem with the request
      Since:
      v4.4
    • listSpinFunctions

      public TupleQueryResult listSpinFunctions() throws AGHttpException
      Returns:
      TupleQueryResult a list of defined SPIN magic properties
      Throws:
      AGHttpException - if there is a problem with the request
      Since:
      v4.4
    • putSpinFunction

      public void putSpinFunction(AGSpinFunction fn) throws AGHttpException
      Parameters:
      fn - the SPIN magic property to add
      Throws:
      AGHttpException - if there is a problem with the request
      Since:
      v4.4
    • deleteSpinFunction

      public void deleteSpinFunction(String uri) throws AGHttpException
      Parameters:
      uri - name of the SPIN magic property to delete
      Throws:
      AGHttpException - if there is a problem with the request
      Since:
      v4.4
    • deleteHardSpinFunction

      public void deleteHardSpinFunction(String uri) throws AGHttpException
      Parameters:
      uri - name of the SPIN magic property to delete
      Throws:
      AGHttpException - if there is a problem with the request
      Since:
      v4.4
    • getSpinMagicProperty

      public String getSpinMagicProperty(String uri) throws AGHttpException
      Parameters:
      uri - name of the SPIN magic property to retrieve
      Returns:
      String a string representation of the property definition
      Throws:
      AGHttpException - if there is a problem with the request
      Since:
      v4.4
    • listSpinMagicProperties

      public TupleQueryResult listSpinMagicProperties() throws AGHttpException
      Returns:
      TupleQueryResult a list of defined SPIN magic properties
      Throws:
      AGHttpException - if there is a problem with the request
      Since:
      v4.4
    • putSpinMagicProperty

      public void putSpinMagicProperty(AGSpinMagicProperty fn) throws AGHttpException
      Parameters:
      fn - the SPIN magic property to add
      Throws:
      AGHttpException - if there is a problem with the request
      Since:
      v4.4
    • deleteSpinMagicProperty

      public void deleteSpinMagicProperty(String uri) throws AGHttpException
      Parameters:
      uri - The uri naming the SPIN magic property to delete
      Throws:
      AGHttpException - if there is a problem with the request
      Since:
      v4.4
    • deleteHardSpinMagicProperty

      public void deleteHardSpinMagicProperty(String uri) throws AGHttpException
      Parameters:
      uri - The uri naming the SPIN magic property to delete
      Throws:
      AGHttpException - if there is a problem with the request
      Since:
      v4.4
    • getAllowExternalBlankNodeIds

      public boolean getAllowExternalBlankNodeIds()
      Returns:
      true iff this HTTP/Storage layer allows external blank node ids.
      Since:
      v4.4
      See Also:
    • setAllowExternalBlankNodeIds

      public void setAllowExternalBlankNodeIds(boolean allow)
      Enables/Disables an option to support external blank nodes (experimental).

      Disabled by default. Enable it from an AGRepositoryConnection using:

      conn.prepareHttpRepoClient().setAllowExternalBlankNodeIds(true);

      An external blank node is a blank node whose id is not generated by AllegroGraph. Applications should normally request new blank nodes from AllegroGraph [via the AGValueFactory#createBNode() method in the Sesame api, or via the AGModel#createResource() method in the Jena adapter]; this helps to avoid unintended blank node id collisions (particularly in a multi-user setting) and enables blank nodes to be stored more efficiently, etc.

      Previously, for applications that did use an external blank node id [such as via AGValueFactory#createBNode("ex") in Sesame, or in Jena via AGModel#createResource(AnonId.create("ex"))] or an external blank node factory [such as ValueFactoryImpl#createBNode() in Sesame or ResourceFactory#createResource() in Jena], there were some issues that arose. When the application tried to add a statement such as [_:ex p a] over HTTP, the AllegroGraph server allocates a new blank node id to use in place of the external blank node id _:ex, so that the actual statement stored is something like [_:bF010696Fx1 p a].

      There are 2 issues with this:

      1) adding a second statement such as [_:ex q b] in a subsequent request will result in another new bnode id being allocated, so that the statement stored might be [_:bF010696Fx2 q b], and the link between the two statements (that exists client side via blank node _:ex) is now lost.

      2) trying to get the statement [_:ex p a] will fail, because the actual statement stored is [_:bF010696Fx1 p a].

      Note that these issues arise with external blank node ids because the server does not know their scope, and by default assumes that the scope is limited to the HTTP request in order to avoid blank node conflicts. When AG-allocated blank node ids are used instead, the two issues above do not arise (they are stored as is, and they will be found as expected with a get). In short, AG-allocated blank nodes round-trip, external blank nodes do not.

      One workaround for this is to have applications declare that they want external blank nodes to round-trip. An external blank node can exist for the life of an application, and that life can exceed the life of an AllegroGraph server instance, so adding a statement with an external blank node will need to persist the external blank node's id somehow. AllegroGraph doesn't currently allow storing blank nodes with an arbitrary external id, so this workaround converts them to URI's (of the form "urn:x-bnode:id" by default) for storage, and recovers the blank nodes with correct ids when the values are retrieved in queries, so that applications continue to transparently deal with BNodes and see the expected behavior w.r.t. issues 1) and 2) above.

      When enabling the workaround described here, the application must take responsibility for using an external blank node factory that avoids blank node conflicts, and must also be willing to incur the additional costs of storing external blank nodes as URIs. When the workaround is disabled (allow=false, the default), the application must avoid using external blank nodes with AG (using AG-allocated blank nodes instead); using external blank node ids when they are not allowed will result in an explanatory exception (as opposed to quietly exhibiting the two problems described above).

      This method and approach are experimental and subject to change.

      Parameters:
      allow - true enables a workaround to support external bnodes
      Since:
      v4.4
      See Also:
    • getStorableResource

      public Resource getStorableResource(Resource r, AGValueFactory vf)
      Returns a storable Resource for the given Resource.

      The intent is that the returned resource can be stored in an AG repository, will round-trip if added to and retrieved from the repository, and that the given Resource can be cheaply recreated from the returned resource.

      This method simply returns the original resource when it is a URI or a BNode with an AG generated blank node id (these can be stored and will round-trip). For external BNodes (with an id that does not look like it was generated by AG), a URI of the form "urn:x-bnode:id" is returned when the connection allows external blank nodes; otherwise, an IllegalArgumentException is thrown explaining the need to either avoid external blank nodes or enable the workaround for external blank nodes.

      This method is intended for use within the AG client library, not for use by applications.

      Parameters:
      r - a resource
      vf - a value factory that can create new store values
      Returns:
      a storable resource for the given resource
      Since:
      v4.4
      See Also:
    • getStorableValue

      public Value getStorableValue(Value v, AGValueFactory vf)
      Returns a storable Value for the given Value.

      The intent is that the returned value can be stored in an AG repository, will round-trip if added to and retrieved from the repository, and that the given Value can be cheaply recreated from the returned value.

      This method simply returns the original value when it is a URI, Literal, or BNode with AG generated blank node id (these can be stored and will round-trip). For external BNodes (with an id that does not look like it was generated by AG), a URI of the form "urn:x-bnode:id" is returned when the connection allows external blank nodes; otherwise, an IllegalArgumentException is thrown explaining the need to either avoid external blank nodes or enable the workaround for external blank nodes.

      This method is intended for use within the AG client library, not for use by applications.

      Parameters:
      v - a value
      vf - a value factory that can create new store values
      Returns:
      a storable value for the given value
      Since:
      v4.4
      See Also:
    • setMasqueradeAsUser

      public void setMasqueradeAsUser(String user) throws RepositoryException
      Sets the AG user for X-Masquerade-As-User requests.

      For AG superusers only. This allows AG superusers to run requests as another user in a dedicated session.

      Parameters:
      user - the user for X-Masquerade-As-User requests
      Throws:
      RepositoryException - if an error occurs
    • addAttributeDefinition

      public void addAttributeDefinition(String name, List<String> allowedValues, boolean ordered, long minimum, long maximum) throws AGHttpException
      HTTP client layer function for requesting that AG define a new attribute. Only parameters explicitly set by the client will be passed to the request.
      Parameters:
      name - the name of the attribute being defined
      allowedValues - list of allowed values (null means all values allowed)
      ordered - true if allowedValues are ordered
      minimum - the minimum number of times this attribute can be specified
      maximum - the maximum number of times this attribute can be specified
      Throws:
      AGHttpException - if there's a problem with the request
    • deleteAttributeDefinition

      public void deleteAttributeDefinition(String name) throws AGHttpException
      HTTP client layer function for requesting that AG deletes an existing attribute.
      Parameters:
      name - the attribute to delete
      Throws:
      AGHttpException - if there's a problem with the request
    • getAttributeDefinition

      public org.json.JSONArray getAttributeDefinition() throws AGHttpException, org.json.JSONException
      Fetch all attribute definitions.
      Returns:
      JSONArray containing a JSONObject for each attribute
      Throws:
      AGHttpException - if there's a problem with the request
      org.json.JSONException - if there's a problem parsing the request into JSON
    • getAttributeDefinition

      public org.json.JSONArray getAttributeDefinition(String name) throws AGHttpException, org.json.JSONException
      Fetch the attribute definition named by NAME. Return all definitions if NAME is null.
      Parameters:
      name - of the attribute
      Returns:
      a JSONArray containing a JSONObject for the attribute found, or all attributes if NAME is null
      Throws:
      AGHttpException - if there's a problem with the request
      org.json.JSONException - if there's a problem parsing the request into JSON
    • getStaticAttributeFilter

      public String getStaticAttributeFilter() throws AGHttpException
      Throws:
      AGHttpException
    • setStaticAttributeFilter

      public void setStaticAttributeFilter(String filter) throws AGHttpException
      Throws:
      AGHttpException
    • deleteStaticAttributeFilter

      public void deleteStaticAttributeFilter() throws AGHttpException
      Throws:
      AGHttpException
    • getNDGeospatialDatatypeAutomation

      public boolean getNDGeospatialDatatypeAutomation() throws AGHttpException
      Throws:
      AGHttpException
    • enableNDGeospatialDatatypeAutomation

      public void enableNDGeospatialDatatypeAutomation() throws AGHttpException
      Throws:
      AGHttpException
    • disableNDGeospatialDatatypeAutomation

      public void disableNDGeospatialDatatypeAutomation() throws AGHttpException
      Throws:
      AGHttpException
    • getUserAttributes

      public String getUserAttributes()
      Return the current userAttributes setting for this connection.
      Returns:
      String containing a json representation of the attributes
    • setUserAttributes

      public void setUserAttributes(String value)
      Set the user attributes for this connection.
      Parameters:
      value - , a String containing a serialized JSON object of the attributes
    • getTransactionSettings

      public TransactionSettings getTransactionSettings()
      Gets the distributed transaction settings.
      Returns:
      Settings (possibly null).
    • setTransactionSettings

      public void setTransactionSettings(TransactionSettings transactionSettings)
      Change the transaction settings related to multi-master replication.
      Parameters:
      transactionSettings - New settings or null, meaning "use server-chosen defaults for all settings".
    • warmup

      public void warmup()
      Asks the server to read store's internal data structures into memory. Use warmup(WarmupConfig) to specify which structures should be read.
    • warmup

      public void warmup(WarmupConfig config)
      Asks the server to read store's internal data structures into memory.
      Parameters:
      config - Config object that can be used to specify which structures should be read into memory. If this parameter is null then the choice will be left to the server.