public class AGServer extends Object implements Closeable
An AGServer references
AGCatalog
s,
which reference
AGRepositories
, from which
connections
may be obtained,
on which data is manipulated and queried.
AGServer provides methods for User (and Role) Management.
AGServer also provides federated
repositories.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_HTTP_PORT
Default AG server port for HTTP connections.
|
static int |
DEFAULT_HTTPS_PORT
Default AG server port for HTTPS connections.
|
Constructor and Description |
---|
AGServer(AGHTTPClient httpClient)
Creates an instance for interacting with an AllegroGraph server.
|
AGServer(String serverURL)
Creates an instance for interacting with an AllegroGraph server.
|
AGServer(String username,
String password,
AGHTTPClient httpClient)
Creates an instance for interacting with an AllegroGraph server.
|
AGServer(String serverURL,
String username,
String password)
Creates an instance for interacting with an AllegroGraph server.
|
Modifier and Type | Method and Description |
---|---|
void |
addRole(String role)
Adds a role to this server.
|
void |
addRoleAccess(String role,
boolean read,
boolean write,
String catalog,
String repository)
Adds to a role's access list for this server.
|
void |
addRolePermission(String role,
String permission)
Adds to a role's permission list.
|
void |
addRoleSecurityFilter(String role,
String type,
String s,
String p,
String o,
String g)
Adds a security filter for a role.
|
void |
addUser(String user,
String password)
Adds a user to the server.
|
void |
addUserAccess(String user,
boolean read,
boolean write,
String catalog,
String repository)
Adds to a user's access list for this server.
|
void |
addUserPermission(String user,
String permission)
Adds to a user's permission list.
|
void |
addUserRole(String user,
String role)
Adds a role for this user.
|
void |
addUserSecurityFilter(String user,
String type,
String s,
String p,
String o,
String g)
Adds a security filter for a user.
|
void |
changeUserPassword(String user,
String password)
Change the password for USER to PASSWORD
|
void |
close()
Close the HTTP connection resources to the AllegroGraph server.
|
AGCatalog |
createCatalog(String catalogID)
Returns an AGCatalog instance for the given catalogID.
|
AGRepository |
createRepository(String reponame)
Creates or opens a repository in the root catalog.
|
AGRepository |
createRepository(String reponame,
AGCatalog catalog,
boolean strict)
Creates or opens a repository in the specified catalog.
|
AGRepository |
createRepository(String reponame,
String catname)
Creates or opens a repository in the specified catalog.
|
AGRepository |
createRepository(String reponame,
String catname,
boolean strict)
Creates or opens a repository in the specified catalog.
|
static AGRepository |
createRepository(String repoName,
String catalogName,
String serverURL,
String username,
String password)
Creates or opens a repository in the specified catalog.
|
AGRepositoryConnection |
createRepositoryConnection(String reponame,
AGCatalog cat,
boolean strict)
Creates or opens a repository in the specified catalog.
|
AGRepositoryConnection |
createRepositoryConnection(String reponame,
String catname,
boolean strict)
Creates or opens a repository in the specified catalog.
|
static AGRepositoryConnection |
createRepositoryConnection(String repoName,
String catalogName,
String serverURL,
String username,
String password)
Creates or opens a repository in the specified catalog.
|
void |
deleteCatalog(String catalogID)
Deletes any catalog with the given repository id.
|
void |
deleteRepository(String reponame,
String catname)
Deletes a repository.
|
void |
deleteRole(String role)
Deletes a role from this server.
|
void |
deleteRoleAccess(String role,
boolean read,
boolean write,
String catalog,
String repository)
Deletes from a role's access list for this server.
|
void |
deleteRolePermission(String role,
String permission)
Delete from a role's permission list.
|
void |
deleteRoleSecurityFilter(String role,
String type,
String s,
String p,
String o,
String g)
Deletes a security filter for a role.
|
void |
deleteUser(String user)
Deletes a user from the server.
|
void |
deleteUserAccess(String user,
boolean read,
boolean write,
String catalog,
String repository)
Deletes from a user's access list for this server.
|
void |
deleteUserPermission(String user,
String permission)
Deletes from a user's permission list.
|
void |
deleteUserRole(String user,
String role)
Deletes a role for this user.
|
void |
deleteUserSecurityFilter(String user,
String type,
String s,
String p,
String o,
String g)
Deletes a security filter for a user.
|
AGVirtualRepository |
federate(AGAbstractRepository... repositories)
Creates a federated view of multiple repositories.
|
String |
getBuildDate() |
AGCatalog |
getCatalog()
Returns the unnamed root catalog for this AllegroGraph server.
|
AGCatalog |
getCatalog(String catalogID)
Gets the catalog instance for a given catalog id.
|
AGServerVersion |
getComparableVersion() |
ScheduledExecutorService |
getExecutor()
Gets the default executor object that will be used by connections
to schedule maintenance operations.
|
AGHTTPClient |
getHTTPClient()
Returns the AGHTTPClient instance for this server.
|
String |
getLogFile()
Retrieves the whole log file as a single string.
|
String |
getPassword() |
String |
getRevision() |
AGCatalog |
getRootCatalog()
Returns the unnamed root catalog for this AllegroGraph server.
|
String |
getServerURL()
Returns the URL of this AllegroGraph server.
|
String |
getUser() |
String |
getVersion() |
List<String> |
listCatalogs()
Returns a List of catalog ids known to this AllegroGraph server.
|
org.json.JSONArray |
listRoleAccess(String role)
Returns a role's access list for this server.
|
List<String> |
listRolePermissions(String role)
Returns a list of permissions for a role.
|
List<String> |
listRoles()
Returns a list of roles known to this server.
|
org.json.JSONArray |
listRoleSecurityFilters(String role,
String type)
Returns a list of security filters of the given type for a role
|
org.json.JSONArray |
listUserAccess(String user)
Returns a user's access list for this server.
|
org.json.JSONArray |
listUserEffectiveAccess(String user)
Returns a user's effective access list for this server.
|
List<String> |
listUserEffectivePermissions(String user)
Returns a list of effective permissions for a user.
|
List<String> |
listUserPermissions(String user)
Returns a list of permissions for a user.
|
List<String> |
listUserRoles(String user)
Returns a list of roles for a user.
|
List<String> |
listUsers()
Returns a List of user ids known to this AllegroGraph server.
|
org.json.JSONArray |
listUserSecurityFilters(String user,
String type)
Returns a list of security filters of the given type for a user
|
Reader |
readLogFile()
Retrieves the log file as a text stream.
|
void |
setExecutor(ScheduledExecutorService executor)
Changes the default executor object that will be used by connections
to schedule maintenance operations.
|
AGVirtualRepository |
virtualRepository(String storeSpec)
Creates a virtual repository with the given store specification.
|
public static final int DEFAULT_HTTP_PORT
public static final int DEFAULT_HTTPS_PORT
public AGServer(String serverURL, String username, String password)
Uses Basic authentication.
serverURL
- the URL of the server (trailing slashes are removed)username
- a user id for authenticating with the serverpassword
- a password for authenticating with the serverAGServer(String)
public AGServer(String username, String password, AGHTTPClient httpClient)
Uses Basic authentication with the server as configured in the httpClient instance.
username
- a user id for authenticating with the serverpassword
- a password for authenticating with the serverhttpClient
- the AGHTTPClient instance to usepublic AGServer(AGHTTPClient httpClient)
Attempts X.509 server and client authentication when no username and password have been set in the httpClient, and properties such as
javax.net.ssl.keyStore,
javax.net.ssl.keyStorePassword,
javax.net.ssl.keyStoreType, and
javax.net.ssl.trustStore
have been set appropriately.
Also set SSL directives in the server's config file, e.g:
SSLPort 10036
SSLClientAuthRequired true
SSLClientAuthUsernameField CN
SSLCertificate /path/agraph.cert
SSLCAFile /path/ca.cert
For more details, see Server configuration.
httpClient
- the AGHTTPClient instance to useAGServer(String)
public AGServer(String serverURL)
Uses a new default AGHTTPClient instance having the given serverURL.
Attempts X.509 server and client authentication when properties such as
javax.net.ssl.keyStore,
javax.net.ssl.keyStorePassword,
javax.net.ssl.keyStoreType, and
javax.net.ssl.trustStore
have been set appropriately.
Also set SSL directives in the server's config file, e.g:
SSLPort 10036
SSLClientAuthRequired true
SSLClientAuthUsernameField CN
SSLCertificate /path/agraph.cert
SSLCAFile /path/ca.cert
For more details, see Server configuration.
serverURL
- the URL of the server (trailing slashes are removed)AGServer(String, String, String)
,
AGServer(AGHTTPClient)
public static AGRepository createRepository(String repoName, String catalogName, String serverURL, String username, String password) throws RepositoryException
repoName
- name of the repository to createcatalogName
- name of the catalog where repoName will be createdserverURL
- URL at which the AG server is foundusername
- name of the authenticating user, or nullpassword
- password (plaintext) of the authenticating user, or nullAGRepository
instance for the newly created repositoryRepositoryException
- if there is an error with this requestpublic static AGRepositoryConnection createRepositoryConnection(String repoName, String catalogName, String serverURL, String username, String password) throws RepositoryException
repoName
- name of the repository to createcatalogName
- name of the catalog where repoName will be createdserverURL
- URL at which the AG server is foundusername
- name of the authenticating user, or nullpassword
- password (plaintext) of the authenticating user, or nullRepositoryException
- if there is an error with this request.public String getServerURL()
public String getUser()
public String getPassword()
public AGHTTPClient getHTTPClient()
public String getVersion() throws AGHttpException
AGHttpException
- if there is an error with this requestpublic AGServerVersion getComparableVersion() throws AGHttpException
AGHttpException
- if there is no cachedServerVersion and there was an error with getVersion() request.public String getBuildDate() throws AGHttpException
AGHttpException
- if there is an error with this requestpublic String getRevision() throws AGHttpException
AGHttpException
- if there is an error with this requestpublic AGCatalog getRootCatalog()
getCatalog()
public List<String> listCatalogs() throws AGHttpException
AGHttpException
- if there is an error with this requestpublic AGCatalog getCatalog(String catalogID) throws AGHttpException
Returns the root catalog if the id is a root id. If the catalog Id is not found on the server, returns null.
catalogID
- a catalog idAGHttpException
- if there is an error with this requestpublic AGCatalog getCatalog()
public AGCatalog createCatalog(String catalogID) throws AGHttpException
If the catalog already exists on the server, an AGCatalog instance is simply returned. If the catalog does not exist, it is created if the server has been configured to allow dynamic catalogs; otherwise, an exception is thrown.
catalogID
- the id (the name) of the catalogAGHttpException
- if there is an error with this requestpublic void deleteCatalog(String catalogID) throws AGHttpException
This method only applies to dynamically created catalogs.
catalogID
- the name of the catalog to deleteAGHttpException
- if there is an error with this requestpublic AGVirtualRepository virtualRepository(String storeSpec)
The storeSpec parameter is a string using the minilanguage for store specification described in the HTTP protocol document (see the store parameter there).
This syntax can be used to create federations, graph-filtered stores, reasoning stores, and compositions thereof.
storeSpec
- the store specificationstoreSpec
public AGVirtualRepository federate(AGAbstractRepository... repositories)
repositories
- repositories that will compose the virtual repositorypublic void close()
close
in interface Closeable
close
in interface AutoCloseable
public List<String> listUsers() throws AGHttpException
AGHttpException
- if there is an error with this requestpublic void addUser(String user, String password) throws AGHttpException
user
- user id to addpassword
- user's passwordAGHttpException
- if there is an error with this requestpublic void deleteUser(String user) throws AGHttpException
user
- user id to deleteAGHttpException
- if there is an error with this requestpublic void addUserAccess(String user, boolean read, boolean write, String catalog, String repository) throws AGHttpException
Access is documented here.
user
- user idread
- read accesswrite
- write accesscatalog
- catalog id, or "*" (or null) for all catalogsrepository
- repository id, or "*" (or null) for all repos, in the given catalog(s)AGHttpException
- if there is an error with this requestpublic void deleteUserAccess(String user, boolean read, boolean write, String catalog, String repository) throws AGHttpException
Access is documented here.
user
- user idread
- read accesswrite
- write accesscatalog
- catalog id, or "*" (or null) for all catalogsrepository
- repository id, or "*" (or null) for all repos, in the given catalog(s)AGHttpException
- if there is an error with this requestpublic org.json.JSONArray listUserAccess(String user) throws AGHttpException
Access is documented here.
user
- user iduser
's access listAGHttpException
- if there is an error with this requestpublic void addUserSecurityFilter(String user, String type, String s, String p, String o, String g) throws AGHttpException
user
- user idtype
- filter type is "allow" or "disallow"s
- subject to allow/disallow, in NTriples formatp
- predicate to allow/disallow, in NTriples formato
- object to allow/disallow, in NTriples formatg
- graph to allow/disallow, in NTriples formatAGHttpException
- if there is an error with this requestpublic void deleteUserSecurityFilter(String user, String type, String s, String p, String o, String g) throws AGHttpException
user
- user idtype
- filter type is "allow" or "disallow"s
- subject to allow/disallow, in NTriples formatp
- predicate to allow/disallow, in NTriples formato
- object to allow/disallow, in NTriples formatg
- graph to allow/disallow, in NTriples formatAGHttpException
- if there is an error with this requestpublic org.json.JSONArray listUserSecurityFilters(String user, String type) throws AGHttpException
user
- user idtype
- filter type is "allow" or "disallow"user
's security filtersAGHttpException
- if there is an error with this requestpublic void changeUserPassword(String user, String password) throws AGHttpException
user
- user idpassword
- the new password to require for userAGHttpException
- if there is an error with this requestpublic org.json.JSONArray listUserEffectiveAccess(String user) throws AGHttpException
Includes the access granted to roles that this user has.
user
- user iduser
's effective accessAGHttpException
- if there is an error with this requestpublic List<String> listUserPermissions(String user) throws AGHttpException
Permissions are documented here.
user
- user idAGHttpException
- if there is an error with this requestpublic List<String> listUserEffectivePermissions(String user) throws AGHttpException
Includes the permission granted to roles that this user has.
Permissions are documented here.
user
- user idAGHttpException
- if there is an error with this requestpublic void addUserPermission(String user, String permission) throws AGHttpException
user
- user idpermission
- "super" or "eval" or "session"AGHttpException
- if there is an error with this requestpublic void deleteUserPermission(String user, String permission) throws AGHttpException
user
- user idpermission
- "super" or "eval" or "session"AGHttpException
- if there is an error with this requestpublic List<String> listRoles() throws AGHttpException
AGHttpException
- if there is an error with this requestpublic void addRole(String role) throws AGHttpException
role
- role idAGHttpException
- if there is an error with this requestpublic void addRoleAccess(String role, boolean read, boolean write, String catalog, String repository) throws AGHttpException
Access is documented here.
role
- role idread
- read accesswrite
- write accesscatalog
- catalog id, or "*" (or null) for all catalogsrepository
- repository id, or "*" (or null) for all repos, in the given catalog(s)AGHttpException
- if there is an error with this requestpublic org.json.JSONArray listRoleAccess(String role) throws AGHttpException
Access is documented here.
role
- role idAGHttpException
- if there is an error with this requestpublic void addRoleSecurityFilter(String role, String type, String s, String p, String o, String g) throws AGHttpException
role
- role idtype
- filter type is "allow" or "disallow"s
- subject to allow/disallow, in NTriples formatp
- predicate to allow/disallow, in NTriples formato
- object to allow/disallow, in NTriples formatg
- graph to allow/disallow, in NTriples formatAGHttpException
- if there is an error with this requestpublic org.json.JSONArray listRoleSecurityFilters(String role, String type) throws AGHttpException
role
- role idtype
- filter type is "allow" or "disallow"AGHttpException
- if there is an error with this requestpublic void deleteRoleSecurityFilter(String role, String type, String s, String p, String o, String g) throws AGHttpException
role
- role idtype
- filter type is "allow" or "disallow"s
- subject to allow/disallow, in NTriples formatp
- predicate to allow/disallow, in NTriples formato
- object to allow/disallow, in NTriples formatg
- graph to allow/disallow, in NTriples formatAGHttpException
- if there is an error with this requestpublic List<String> listUserRoles(String user) throws AGHttpException
user
- the user to lookupAGHttpException
- if there is an error with this requestpublic void addUserRole(String user, String role) throws AGHttpException
user
- user idrole
- role idAGHttpException
- if there is an error with this requestpublic void deleteUserRole(String user, String role) throws AGHttpException
user
- user idrole
- role idAGHttpException
- if there is an error with this requestpublic void deleteRoleAccess(String role, boolean read, boolean write, String catalog, String repository) throws AGHttpException
role
- role idread
- read accesswrite
- write accesscatalog
- catalog id, or "*" (or null) for all catalogsrepository
- repository id, or "*" (or null) for all repos, in the given catalog(s)AGHttpException
- if there is an error with this requestpublic void deleteRole(String role) throws AGHttpException
role
- role idAGHttpException
- if there is an error with this requestpublic void addRolePermission(String role, String permission) throws AGHttpException
role
- role idpermission
- "super" or "eval" or "session"AGHttpException
- if there is an error with this requestpublic void deleteRolePermission(String role, String permission) throws AGHttpException
role
- role idpermission
- "super" or "eval" or "session"AGHttpException
- if there is an error with this requestpublic List<String> listRolePermissions(String role) throws AGHttpException
Permissions are documented here.
role
- role idAGHttpException
- if there is an error with this requestpublic ScheduledExecutorService getExecutor()
public void setExecutor(ScheduledExecutorService executor)
executor
- An executor instancepublic AGRepository createRepository(String reponame, AGCatalog catalog, boolean strict) throws RepositoryException
reponame
- name of the repository to createcatalog
- AGCatalog instance where the repository will be createdstrict
- if true, throw an exception if the repository exists.
Otherwise the existing repository will be opened.AGRepository
instance for the newly created repositoryRepositoryException
- if there is an error with this requestpublic AGRepository createRepository(String reponame, String catname, boolean strict) throws RepositoryException
reponame
- name of the repository to createcatname
- name of the catalog in which to create the repositorystrict
- if true, throw an exception if the repository exists.
Otherwise the existing repository will be opened.AGRepository
instance for the newly created repositoryRepositoryException
- if there is an error with this requestpublic AGRepository createRepository(String reponame, String catname) throws RepositoryException
reponame
- name of the repository to createcatname
- name of the catalog in which to create the repositoryAGRepository
instance for the newly created repositoryRepositoryException
- if there is an error with this requestpublic AGRepository createRepository(String reponame) throws RepositoryException
reponame
- name of the repository to createAGRepository
instance for the newly created repositoryRepositoryException
- if there is an error with this requestpublic AGRepositoryConnection createRepositoryConnection(String reponame, AGCatalog cat, boolean strict) throws RepositoryException
reponame
- name of the repository to createcat
- catalog in which to create the repositorystrict
- if true, throw an exception if the repository exists.
Otherwise the existing repository will be opened.RepositoryException
- if there is an error with this request.public AGRepositoryConnection createRepositoryConnection(String reponame, String catname, boolean strict) throws RepositoryException
reponame
- name of the repository to createcatname
- name of the catalog in which to create the repositorystrict
- if true, throw an exception if the repository exists.
Otherwise the existing repository will be opened.RepositoryException
- if there is an error with this request.public void deleteRepository(String reponame, String catname)
reponame
- Repository name.catname
- Catalog name, null or an empty string maps to the root catalog.public String getLogFile() throws AGHttpException
AGHttpException
- if there is an error with this requestpublic Reader readLogFile()
Copyright © 2024 Franz Inc.. All rights reserved.