public class TripleStore extends java.lang.Object implements SourceConnectorClient, java.io.Serializable
A triple store holds items and triples from the sources to which it is connected. For triples with text and binary objects, an object is only retrieved from the source when its summary meets a search criterion.
The triple store has methods to connect and disconnect sources, to read items and triples in all connected sources and to search for triples in all connected sources. It has methods to create, delete, and update items and triples in connected sources that it owns.
Modifier and Type | Field and Description |
---|---|
static long |
hasCredentialRelationNr
The numeric identifier of the special item representing
the "has credential" verb
|
static long |
hasSecretDigestRelationNr
The numeric identifier of the special item representing
the "has secret digest" verb
|
static long |
highestLevelNr
The numeric identifier of the special item representing
the highest access level
|
static long |
inferiorPermissionRelationNr
The numeric identifier of the special item representing
the inferior permission relation verb
|
static long |
isAccessLevelRelationNr
The numeric identifier of the special item representing
the "is access level relation" verb
|
static long |
lowestLevelNr
The numeric identifier of the special item representing
the lowest access level
|
static long |
specialItemSource
The special item source number.
|
static long |
superiorPermissionRelationNr
The numeric identifier of the special item representing
the superior permission relation verb
|
Constructor and Description |
---|
TripleStore(int stringCacheSize,
int binaryCacheSize)
Construct a new triple store
|
Modifier and Type | Method and Description |
---|---|
java.util.List<AccessLevel> |
accessLevels(StoreSession session)
Get the access levels visible to a store session
|
boolean |
allTriplesVisible(Item subject,
Item verb,
StoreSession session)
Determine whether all the triples with given subject and verb
are visible to the requesting session.
|
void |
applyDelta(long sourceNr,
Delta delta,
boolean load)
Apply a delta
|
void |
close()
Close the store
|
void |
connect(SourceConnector connector,
StoreSession session)
Connect to a source
|
void |
create(SourceConnector connector,
StoreSession session)
Create a source
|
AccessLevel |
createAccessLevel(long sourceNr,
AccessLevel onlyReadLevel,
AccessLevel readOrWriteLevel,
StoreSession session)
Create a new access level with given access levels
|
Item |
createCredential(AccessLevel level,
StoreSession session)
Create a credential for an access level.
|
AccessLevel |
createLockedAccessLevel(long sourceNr,
AccessLevel onlyReadLevel,
AccessLevel readOrWriteLevel,
StoreSession session)
Create a new access level with given access levels,
and with its item locked.
|
Item |
createLockedItem(long sourceNr,
AccessLevel onlyReadLevel,
AccessLevel readOrWriteLevel,
StoreSession session)
Create a new item and return it locked
|
AccessLevel |
createNamedAccessLevel(long sourceNr,
java.lang.String name,
AccessLevel onlyReadLevel,
AccessLevel readOrWriteLevel,
StoreSession session)
Create a named access level in a given source and with
given only-read and read-or-write access levels.
|
Item |
createNamedItem(long sourceNr,
java.lang.String name,
AccessLevel onlyReadLevel,
AccessLevel readOrWriteLevel,
StoreSession session)
Create a named item in a source, with access levels set to given
values.
|
StoreSession |
createStoreSession(Item credential,
byte[] secret,
StoreSession requestingSession)
Create a store session with the access level that has a credential
|
Triple |
createTriple(Item subject,
Item verb,
Datum object,
StoreSession session)
Create a new triple
|
Item |
createUnlockedItem(SourceConnector connector,
AccessLevel onlyReadLevel,
AccessLevel readOrWriteLevel,
StoreSession session)
Create a new item and return it unlocked
|
boolean |
deleteCredential(Item credential,
StoreSession session)
Delete a credential
|
boolean |
deleteItem(Item it,
StoreSession session)
Delete an item
|
boolean |
deleteTriple(Triple t,
StoreSession session)
Delete a triple.
|
void |
disconnect(long sourceNr)
Disconnect a source
|
boolean |
ensureNoMatchingTriples(Item subject,
Item verb,
StoreSession session)
Ensure that there are no triples with a given subject
and verb
|
byte[] |
generateSecret(Item credential,
StoreSession session)
Generate a secret for a credential, and store its digest as the
unique secret digest for the credential
|
AccessLevel |
getAccessLevel(Item item,
StoreSession session)
Get the access level represented by an item
|
Item |
getAccessLevelRelationItem()
Get the item that is the verb such that the subject
of a triple with this verb represents an access level.
|
AccessLevelRelationsStatus |
getAccessLevelRelationsStatus(StoreSession session)
Get the superiority permissions and relations that are visible
to a store session
|
AccessLevel |
getAdminAccessLevel(long sourceNr)
Get the administration access level of a source.
|
java.util.List<Triple> |
getAllTriples(Item subject,
Item verb,
StoreSession session)
Get all the triples with given subject and verb, or
return null if some are not visible to the requesting session.
|
long |
getHighestAccessLevelNr()
Return the numeric identifier of the highest access level
|
long |
getIsAccessLevelRelationNr() |
Item |
getItem(Id id,
StoreSession session)
Get an item.
|
java.lang.String |
getItemName(Item item,
StoreSession session)
Get the name of an item if it is a named item.
|
Logger |
getLogger()
Get the logger
|
long |
getLowestAccessLevelNr()
Return the numeric identifier of the lowest access level
|
Item |
getNamedItem(long sourceNr,
java.lang.String name,
StoreSession session)
Get a named item in a source
|
AccessLevel |
getOrCreateNamedAccessLevel(long sourceNr,
java.lang.String name,
StoreSession session)
Get or create a named access level from a source, with
write access level set to the access level of the
requesting session, and read access level set to
the lowest level.
|
Item |
getOrCreateNamedItem(long sourceNr,
java.lang.String name,
StoreSession session)
Get a named item in a source, creating it if it does not exist.
|
SourceConnector |
getSourceConnector(long sourceNr)
Get the connector for a given source
|
Item |
getSpecialItemByName(java.lang.String name)
Get a special item, given its name
|
long |
getSpecialItemSourceNr() |
Triple |
getTriple(Id id,
StoreSession session)
Get a triple.
|
Datum |
getTripleObject(Triple t,
StoreSession session)
Get the object of a triple
|
java.util.List<Triple> |
getTriples(Item subject,
Item verb,
Datum object,
StoreSession session)
Get the triples with given subject, verb, and object
|
java.util.Set<AccessLevel> |
getVisibleInferiors(AccessLevel level,
StoreSession session)
Get the set of access levels that are inferior to a given level
and that are visible to the requesting store session
|
java.util.Set<AccessLevel> |
getVisibleSuperiors(AccessLevel level,
StoreSession session)
Get the set of access levels that are superior to a given level
and that are visible to the requesting store session
|
java.util.List<org.lacibus.settheoryrels.OrderedPair<AccessLevel>> |
impliedAccessLevelRelationships(StoreSession session)
List the implied access level relationships that are
readable at the session access level
|
SessionIssuer |
initialize()
Return a session issuer when the store has been initialised.
|
boolean |
isHighestAccessLevel(AccessLevel level)
Determine whether an access level is the highest
access level
|
boolean |
isKnown(long sourceNr)
Determine whether a source is known.
|
boolean |
isOperational(long sourceNr)
Determine whether a source is operational.
|
boolean |
isSpecialItem(Item it)
Determine whether an item is a special item.
|
boolean |
isStatedAccessRelationship(AccessLevel superior,
AccessLevel inferior)
Determine whether one access level is stated to be
superior to another
|
java.util.List<Item> |
lockObjectsOfItem(Item item,
Item[] verbs,
StoreSession storeSession)
Lock the item objects of triples whose subject is
a given item and whose verbs are in a given set
of verbs.
|
void |
log(java.lang.Exception e)
Report an exception
|
void |
log(java.lang.String message)
Report status or an error
|
AccessLevel |
lowestAccessLevel()
Get the lowest access level
|
boolean |
nameItem(Item item,
java.lang.String name,
StoreSession session)
Give an item a unique name.
|
void |
orderByObjectSubjectVerb(java.util.List<Triple> triples)
Sort a list of triples by object, then subject, then verb
|
void |
orderBySubjectVerbObject(java.util.List<Triple> triples)
Sort a list of triples by subject, then verb, then object
|
void |
orderByVerbObjectSubject(java.util.List<Triple> triples)
Sort a list of triples by verb, then object, then subject
|
Triple |
replaceTripleObject(Triple t,
Datum object,
StoreSession session)
Replace a triple's object
|
boolean |
retireAccessLevel(AccessLevel level,
AccessLevel replacement,
StoreSession session)
Retire an access level and replace it by by another.
|
boolean |
setInferiorPermission(AccessLevel inferior,
AccessLevel superior,
StoreSession session)
Permit one access level to be inferior to another.
|
void |
setLogger(Logger logger)
Set the logger
|
boolean |
setSuperiorPermission(AccessLevel superior,
AccessLevel inferior,
StoreSession session)
Permit one access level to be superior to another.
|
Triple |
setUniqueObject(Item subject,
Item verb,
Datum object,
StoreSession session)
Ensure there is a unique triple with a given subject and verb, and that
it has a given object.
|
Triple |
setUniqueTriple(Item subject,
Item verb,
Datum object,
StoreSession session)
Ensure there is a unique triple with a given subject, verb and object.
|
int |
sizeIndicator()
Get an indication of the size of the triple store.
|
java.lang.String |
specialItemName(Item it)
Get the name of a special item
|
Triple |
uniqueTriple(Item subject,
Item verb,
Datum object,
StoreSession session)
Get the unique triple with the given subject, verb, and object,
if it is readable by the requesting store session.
|
void |
unlockObjects(java.util.List<Item> objects,
StoreSession storeSession)
Unlock the objects in a list of objects.
|
boolean |
unsetInferiorPermission(AccessLevel inferior,
AccessLevel superior,
StoreSession session)
Remove a permission that an access level can be inferior
to another.
|
boolean |
unsetSuperiorPermission(AccessLevel superior,
AccessLevel inferior,
StoreSession session)
Remove a permission that an access level can be superior
to another.
|
public static final long specialItemSource
public static final long lowestLevelNr
public static final long highestLevelNr
public static final long isAccessLevelRelationNr
public static final long superiorPermissionRelationNr
public static final long inferiorPermissionRelationNr
public static final long hasCredentialRelationNr
public static final long hasSecretDigestRelationNr
public TripleStore(int stringCacheSize, int binaryCacheSize)
stringCacheSize
- the number of strings in
the string cachebinaryCacheSize
- the number of byte arrays in
the binary cachepublic int sizeIndicator()
public Logger getLogger()
logger
- the logger to be setpublic void setLogger(Logger logger)
logger
- the logger to be setpublic void log(java.lang.String message)
message
- the status or error to be reportedpublic void log(java.lang.Exception e)
message
- the status or error to be reportedpublic SessionIssuer initialize() throws TripleStoreFatalException, TripleStoreNonFatalException
Return a session issuer when the store has been initialised.
If the store is in its initial state, initialise it and return a session issuer.If it is already being initialized by another thread, wait until that process has completed, then return null.If the store has already been initialized, return null.
The session issuer is returned so that the software that set up the triple store is able to obtain store sessions and use it. This software is responsible for controlling the use of the issuer and the sessions that it issues to maintain secure access to the data in the store.
TripleStoreFatalException
TripleStoreNonFatalException
public void close()
public void create(SourceConnector connector, StoreSession session) throws java.lang.Exception
connector
- a source connector for the sourcesession
- the requesting store sessionjava.lang.Exception
public void connect(SourceConnector connector, StoreSession session) throws java.lang.Exception
connector
- a source connector for the sourcesession
- the requesting store sessionjava.lang.Exception
public void disconnect(long sourceNr) throws TripleStoreNonFatalException, TripleStoreFatalException, SourceConnectorException, NotInOperationException
sourceNr
- the numeric identifier of the source to
be disconnectedTripleStoreFatalException
SourceConnectorException
NotInOperationException
TripleStoreNonFatalException
public boolean isKnown(long sourceNr)
sourceNr
- the numeric identifier of a sourcepublic SourceConnector getSourceConnector(long sourceNr)
sourceNr
- the numeric identifier of a sourcepublic boolean isOperational(long sourceNr)
sourceNr
- the numeric identifier of a sourcepublic AccessLevel getAdminAccessLevel(long sourceNr) throws NotInOperationException
Get the administration access level of a source.
This method is typically invoked by an application after it has connected a source, to perform initialization and management operations.
sourceNr
- a numeric source identifierNotInOperationException
public void applyDelta(long sourceNr, Delta delta, boolean load) throws TripleStoreNonFatalException, SourceConnectorException, TripleStoreFatalException, NotInOperationException
Apply a delta
A delta is an instruction to add, remove or change an item or triple.
When a source is loaded while being connected, or when the triple store is synchronizing with a source, a set of deltas is loaded from it.
applyDelta
in interface SourceConnectorClient
sourceNr
- the numeric identifier of the source
originating the deltadelta
- a deltaload
- true if the delta is loaded in a load
operation, false if in a sync operationTripleStoreNonFatalException
TripleStoreFatalException
SourceConnectorException
NotInOperationException
public Item getAccessLevelRelationItem()
public long getLowestAccessLevelNr()
SourceConnectorClient
getLowestAccessLevelNr
in interface SourceConnectorClient
public long getHighestAccessLevelNr()
SourceConnectorClient
getHighestAccessLevelNr
in interface SourceConnectorClient
public boolean isHighestAccessLevel(AccessLevel level) throws TripleStoreNonFatalException
level
- an access levelTripleStoreNonFatalException
public AccessLevel lowestAccessLevel() throws NotInOperationException
NotInOperationException
- if the triple store
is not in operationpublic AccessLevel createAccessLevel(long sourceNr, AccessLevel onlyReadLevel, AccessLevel readOrWriteLevel, StoreSession session) throws NotInOperationException, SourceConnectorException, TripleStoreNonFatalException, TripleStoreFatalException
Create a new access level with given access levels
The new access level will be stated to be inferior to the session level, to ensure that the operation can be reversed within the same session.
The session must therefore have write access to its level item.
The session may not be at the lowest access level, since this cannot be superior to another level.
sourceNr
- the numeric identifier of the source
in which the access level is to be created.onlyReadLevel
- the only-read access level that
the new access level is to havereadOrWriteLevel
- the read-or-write access level
that the new access level is to havesession
- the requesting store sessionNotInOperationException
SourceConnectorException
TripleStoreNonFatalException
TripleStoreFatalException
public AccessLevel createLockedAccessLevel(long sourceNr, AccessLevel onlyReadLevel, AccessLevel readOrWriteLevel, StoreSession session) throws NotInOperationException, SourceConnectorException, TripleStoreNonFatalException, TripleStoreFatalException
Create a new access level with given access levels, and with its item locked.
The new access level will be stated to be inferior to the session level, to ensure that the operation can be reversed within the same session.
The session must therefore have write access to its level item.
The session may not be at the lowest access level, since this cannot be superior to another level.
sourceNr
- the numeric identifier of the source
in which the access level is to be created.onlyReadLevel
- the only-read access level that
the new access level is to havereadOrWriteLevel
- the read-or-write access level
that the new access level is to havesession
- the requesting store sessionNotInOperationException
SourceConnectorException
TripleStoreNonFatalException
TripleStoreFatalException
public AccessLevel getOrCreateNamedAccessLevel(long sourceNr, java.lang.String name, StoreSession session) throws NotInOperationException, SourceConnectorException, TripleStoreNonFatalException, TripleStoreFatalException
Get or create a named access level from a source, with write access level set to the access level of the requesting session, and read access level set to the lowest level.
The access level's item is related to a given name by the source item of the source. Only one such item can exist an any particular source. (The access level's item is a named item like those created by the namedItem method.)
sourceNr
- the numeric identifier of the source of
the itemname
- the name for the access level. This forms
the key by which the named access level or its item can
be retrieved.session
- the store session requesting the operation.NotInOperationException
SourceConnectorException
TripleStoreNonFatalException
TripleStoreFatalException
public AccessLevel createNamedAccessLevel(long sourceNr, java.lang.String name, AccessLevel onlyReadLevel, AccessLevel readOrWriteLevel, StoreSession session) throws NotInOperationException, SourceConnectorException, TripleStoreNonFatalException, TripleStoreFatalException
Create a named access level in a given source and with given only-read and read-or-write access levels.
The access level's item is related to a given name by the source item of the source. Only one such item can exist an any particular source. (The access level's item is a named item like those created by the namedItem method.)
sourceNr
- the numeric identifier of the source in
which the access level is to be created.name
- the name for the access level. This forms
the key by which the named access level or its item can
be retrieved.onlyReadLevel
- the only-read level of the access
level to be createdreadOrWriteLevel
- the read-or-write level of the access
level to be createdsession
- the store session requesting the operation.NotInOperationException
SourceConnectorException
TripleStoreNonFatalException
TripleStoreFatalException
public AccessLevel getAccessLevel(Item item, StoreSession session) throws NotInOperationException, TripleStoreNonFatalException
item
- the identifying itemsession
- the requesting store session, which
must have read access to the item.NotInOperationException
TripleStoreNonFatalException
public java.util.List<AccessLevel> accessLevels(StoreSession session) throws TripleStoreNonFatalException
session
- a store sessionTripleStoreNonFatalException
public boolean setSuperiorPermission(AccessLevel superior, AccessLevel inferior, StoreSession session) throws NotInOperationException, TripleStoreNonFatalException, TripleStoreFatalException, SourceConnectorException
Permit one access level to be superior to another. If the other is already permitted to be the inferior of the pair, make a stated superiority relationship between them.
The requesting store session must have locked the level that is permitted to be the superior one, and have read access to the other. Neither level may be being replaced.
superior
- the level that is permitted to be the
superior oneinferior
- the level that the superior is permitted
to be superior tosession
- the requesting store sessionNotInOperationException
TripleStoreNonFatalException
TripleStoreFatalException
SourceConnectorException
public boolean setInferiorPermission(AccessLevel inferior, AccessLevel superior, StoreSession session) throws NotInOperationException, TripleStoreNonFatalException, TripleStoreFatalException, SourceConnectorException
Permit one access level to be inferior to another. If the other is already permitted to be the superior of the pair, make a stated superiority relationship between them.
The requesting store session must have locked the level that is permitted to be the inferior one, and have read access to the other. Neither level may be being replaced.
inferior
- the level that is permitted to be the
inferior onesuperior
- the level that the inferior is permitted
to be inferior tosession
- the requesting store sessionNotInOperationException
TripleStoreNonFatalException
TripleStoreFatalException
SourceConnectorException
public boolean unsetSuperiorPermission(AccessLevel superior, AccessLevel inferior, StoreSession session) throws NotInOperationException, TripleStoreNonFatalException, TripleStoreFatalException, SourceConnectorException
Remove a permission that an access level can be superior to another. Any stated relationship that the level is superior to the other is removed also.
The requesting store session must have locked the superior level and have read access to the other level, and must continue to have write access to the superior level and read access to the other level once the permission has been removed. Neither level may be being replaced.
superior
- the level that is permitted to be
superior to the other oneinferior
- the level that the superior level is
permitted to be superior tosession
- the requesting store sessionNotInOperationException
TripleStoreNonFatalException
TripleStoreFatalException
SourceConnectorException
public boolean unsetInferiorPermission(AccessLevel inferior, AccessLevel superior, StoreSession session) throws NotInOperationException, TripleStoreNonFatalException, TripleStoreFatalException, SourceConnectorException
Remove a permission that an access level can be inferior to another. Any stated relationship that the other level is superior to the level is removed also.
The requesting store session must have locked the inferior level and have read access to the other level, and must continue to have write access to the inferior level and read access to the other level once the permission has been removed. Neither level may be being replaced.
inferior
- the level that is permitted to be
inferior to the other onesuperior
- the level that the inferior level is
permitted to be inferior tosession
- the requesting store sessionNotInOperationException
TripleStoreNonFatalException
TripleStoreFatalException
SourceConnectorException
public boolean isStatedAccessRelationship(AccessLevel superior, AccessLevel inferior) throws NotInOperationException, TripleStoreNonFatalException
superior
- the possibly superior levelinferior
- the possibly inferior levelNotInOperationException
TripleStoreNonFatalException
public java.util.List<org.lacibus.settheoryrels.OrderedPair<AccessLevel>> impliedAccessLevelRelationships(StoreSession session) throws NotInOperationException, TripleStoreNonFatalException
session
- the store session requesting the
operationNotInOperationException
TripleStoreNonFatalException
public AccessLevelRelationsStatus getAccessLevelRelationsStatus(StoreSession session) throws TripleStoreNonFatalException, TripleStoreFatalException, SourceConnectorException, NotInOperationException
session
- a store sessionTripleStoreNonFatalException
TripleStoreFatalException
SourceConnectorException
NotInOperationException
public java.util.Set<AccessLevel> getVisibleSuperiors(AccessLevel level, StoreSession session) throws TripleStoreNonFatalException, NotInOperationException
level
- an access levelsession
- the requesting store sessionTripleStoreNonFatalException
NotInOperationException
public java.util.Set<AccessLevel> getVisibleInferiors(AccessLevel level, StoreSession session) throws TripleStoreNonFatalException, NotInOperationException
level
- an access levelsession
- the requesting store sessionTripleStoreNonFatalException
NotInOperationException
public boolean retireAccessLevel(AccessLevel level, AccessLevel replacement, StoreSession session) throws NotInOperationException, TripleStoreNonFatalException, TripleStoreFatalException, SourceConnectorException
Retire an access level and replace it by by another.
The requesting session must have locked the retired access level. The retired level must not be the highest or lowest access level, and must not be the same as the access level of the requesting session. The replacement may not be the highest access level. It may be the lowest access level. If it is not, the requesting session must have locked it. It must not be the same as the access level that it is replacing, and must not itself have been replaced.
Retirement of an access level implies the removal of its stated relationships, the deletion of its representing item, and the consequent deletion of all triples of which that item is subject, verb, or object. Note that the same session may not be able to create another level with the same relationships as the retired level.
Testing whether one access level is superior to another is a frequently-used operation. It is performed without using code that is synchronized on the access levels in question, to avoid deadlocks, and to improve performance. The retirement mechanism must work under these circumstances.
When an access level is retired, its "replacement" field is set to reference its replacement. This is an atomic operation. The replacement is used in place of the level when the only-read or the read-or-write level of an item has been retired, and access to the item is checked.
If the access level of a session is replaced, the replacement field is not used when checking whether the session can read or write an item. Instead, a TripleStoreNonFatalException is thrown.
Once the "replacement" field has been changed, the access level remains usable for a considerable time. A thread that has tested the access level and determined that it has not been retired should encounter no problems if the level is retired while the thread is using it.
Changes to item read and write levels, and access level replacements, are all done by threads that have obtained the access levels lock. An item can therefore not have its read or write access level set to a level that has been retired.
A background task goes through the items and replaces retired only-read and read-or-write levels with their replacements. By this means, all references in the triple store to the retired level are eventually removed.
level
- the access level to be replaced.
This level will be deleted once it has been replaced.replacement
- the replacement access levelsession
- the requesting sessionNotInOperationException
TripleStoreNonFatalException
TripleStoreFatalException
SourceConnectorException
public Item createCredential(AccessLevel level, StoreSession session) throws NotInOperationException, TripleStoreNonFatalException, SourceConnectorException, TripleStoreFatalException
level
- an access levelsession
- the requesting store session, whose access level
must be superior to the admin access level of the source of the
access level that will have the credentialNotInOperationException
TripleStoreNonFatalException
SourceConnectorException
TripleStoreFatalException
public byte[] generateSecret(Item credential, StoreSession session) throws java.security.NoSuchAlgorithmException, NotInOperationException, TripleStoreNonFatalException, SourceConnectorException, TripleStoreFatalException
credential
- a credentialsession
- the requesting store session, whose access level
must be superior to the admin access level of the source of the
credentialjava.security.NoSuchAlgorithmException
NotInOperationException
TripleStoreNonFatalException
SourceConnectorException
TripleStoreFatalException
public StoreSession createStoreSession(Item credential, byte[] secret, StoreSession requestingSession) throws TripleStoreNonFatalException, TripleStoreFatalException, SourceConnectorException, NotInOperationException, java.security.NoSuchAlgorithmException
credential
- a credentialsecret
- the credential's secretrequestingSession
- TripleStoreNonFatalException
TripleStoreFatalException
SourceConnectorException
NotInOperationException
java.security.NoSuchAlgorithmException
public boolean deleteCredential(Item credential, StoreSession session) throws NotInOperationException, TripleStoreNonFatalException, SourceConnectorException, TripleStoreFatalException
credential
- the credential to be deletedsession
- the requesting store session, whose access level
must be superior to the admin access level of the source of the
credentialNotInOperationException
TripleStoreNonFatalException
SourceConnectorException
TripleStoreFatalException
public long getSpecialItemSourceNr()
getSpecialItemSourceNr
in interface SourceConnectorClient
public long getIsAccessLevelRelationNr()
getIsAccessLevelRelationNr
in interface SourceConnectorClient
public Item createUnlockedItem(SourceConnector connector, AccessLevel onlyReadLevel, AccessLevel readOrWriteLevel, StoreSession session) throws NotInOperationException, SourceConnectorException, TripleStoreNonFatalException, TripleStoreFatalException
connector
- the connector to the source in which
the item is to be writtenonlyReadLevel
- the only-read level that the item
is to havereadOrWriteLevel
- the read-or-write level that the
item is to havesession
- the store session requesting creation of
the new item.NotInOperationException
SourceConnectorException
TripleStoreNonFatalException
TripleStoreFatalException
public Item createLockedItem(long sourceNr, AccessLevel onlyReadLevel, AccessLevel readOrWriteLevel, StoreSession session) throws NotInOperationException, SourceConnectorException, TripleStoreNonFatalException, TripleStoreFatalException
sourceNr
- the numeric identifier of the source in
which the item is to be writtenonlyReadLevel
- the only-read level that the item
is to havereadOrWriteLevel
- the read-or-write level that the
item is to havesession
- the store session requesting creation of
the new item.NotInOperationException
SourceConnectorException
TripleStoreNonFatalException
TripleStoreFatalException
public Item getOrCreateNamedItem(long sourceNr, java.lang.String name, StoreSession session) throws NotInOperationException, SourceConnectorException, TripleStoreFatalException, TripleStoreNonFatalException
Get a named item in a source, creating it if it does not exist. If a new named item is created, it has read-or-write access level set to the access level of the requesting session, and only-read access level set to the lowest level.
The item is related to a given name by the source item of the source. Only one such item can exist in any particular source.
sourceNr
- the numeric identifier of the source of the item.name
- the name for the item. This forms the key by which
the named item can be retrieved.session
- the store session requesting the operation.NotInOperationException
TripleStoreNonFatalException
TripleStoreFatalException
SourceConnectorException
public Item createNamedItem(long sourceNr, java.lang.String name, AccessLevel onlyReadLevel, AccessLevel readOrWriteLevel, StoreSession session) throws NotInOperationException, SourceConnectorException, TripleStoreFatalException, TripleStoreNonFatalException
Create a named item in a source, with access levels set to given values.
The item is related to a given name by the source item of the source. Only one such item can exist in any particular source.
sourceNr
- the numeric identifier of the source of the item.name
- the name for the item. This forms the key by which
the named item can be retrieved.onlyReadLevel
- the only-read access level that the newly-created
item is to havereadOrWriteLevel
- the read-or-write access level that the newly-
created item is to have.session
- the store session requesting the operation.NotInOperationException
TripleStoreNonFatalException
TripleStoreFatalException
SourceConnectorException
public boolean nameItem(Item item, java.lang.String name, StoreSession session) throws TripleStoreNonFatalException, SourceConnectorException, NotInOperationException, TripleStoreFatalException
Give an item a unique name. If the item already has a name, then rename it.
The item is related to a given name by the source item of its source. Only one such item can exist in any particular source.
If the item already has the given name, no change is made.
item
- the item to be named. It must be locked by the
requesting store session before this method is invoked.name
- the name that the item is to havesession
- the requesting store sessionTripleStoreNonFatalException
SourceConnectorException
NotInOperationException
TripleStoreFatalException
public Item getNamedItem(long sourceNr, java.lang.String name, StoreSession session) throws TripleStoreNonFatalException, SourceConnectorException, TripleStoreFatalException, NotInOperationException
sourceNr
- the numeric identifier of a sourcename
- the name of a named item in the sourcesession
- the requesting store sessionTripleStoreNonFatalException
SourceConnectorException
TripleStoreFatalException
NotInOperationException
public Item getItem(Id id, StoreSession session) throws NotInOperationException, TripleStoreNonFatalException
Get an item.
The requesting store session must have read access to the item. The item must be from a connected source
id
- the item's identifiersession
- the requesting store sessionNotInOperationException
TripleStoreNonFatalException
public java.lang.String getItemName(Item item, StoreSession session) throws NotInOperationException, SourceConnectorException, TripleStoreNonFatalException, TripleStoreFatalException
item
- an itemsession
- the requesting sessionNotInOperationException
SourceConnectorException
TripleStoreNonFatalException
TripleStoreFatalException
public boolean deleteItem(Item it, StoreSession session) throws NotInOperationException, TripleStoreNonFatalException, SourceConnectorException
Delete an item
The item is marked as deleted and is deleted from the store.
The item must not be a special item or the item of an access level or a source item.
it
- the item to be deletedsession
- the store session requesting deletion of the item.
The item must have been locked by this session for the operation to
succeed.NotInOperationException
TripleStoreNonFatalException
SourceConnectorException
public boolean isSpecialItem(Item it) throws TripleStoreNonFatalException, NotInOperationException
it
- an itemNotInOperationException
TripleStoreNonFatalException
public java.lang.String specialItemName(Item it) throws NotInOperationException
it
- a special itemNotInOperationException
public Item getSpecialItemByName(java.lang.String name) throws NotInOperationException
name
- a nameNotInOperationException
public java.util.List<Item> lockObjectsOfItem(Item item, Item[] verbs, StoreSession storeSession) throws TripleStoreNonFatalException
Lock the item objects of triples whose subject is a given item and whose verbs are in a given set of verbs.
This method is used by applications that need to process an item and other items related to it together - for example that need to delete an item together with the items related to it.
item
- the given item. It must have been
locked by the requesting session when the method
is invoked.verbs
- the verbs of triples whose subject
is the given item and whose item objects are to be
locked.storeSession
- the requesting store session.TripleStoreNonFatalException
public void unlockObjects(java.util.List<Item> objects, StoreSession storeSession)
objects
- a list of objectsstoreSession
- the requesting store sessionpublic Triple getTriple(Id id, StoreSession session) throws NotInOperationException, TripleStoreNonFatalException
Get a triple.
The requesting session must have read access to the triple's subject and verb, and to the object if this is an item. The triple must be from a connected source.
id
- the identifier of the requested triplesession
- the requesting store sessionNotInOperationException
TripleStoreNonFatalException
public Triple createTriple(Item subject, Item verb, Datum object, StoreSession session) throws NotInOperationException, SourceConnectorException, TripleStoreNonFatalException, TripleStoreFatalException
subject
- the item that is the triple's subject.
This item must have been locked by the requesting store
session for the operation to succeed, and the requesting
store session must have write access to it.verb
- the item that is the triple's verb. The
requesting store session must have read access to the verb.
The verb must not be a special item (triples with special
items as verbs are created by special-purpose methods).object
- the Datum to be set as the triple's object.
The requesting store session must have read access to its
value if that value is an item.session
- the store session requesting creation of the
new triple.NotInOperationException
SourceConnectorException
TripleStoreNonFatalException
TripleStoreFatalException
public Triple replaceTripleObject(Triple t, Datum object, StoreSession session) throws NotInOperationException, TripleStoreNonFatalException, TripleStoreFatalException, SourceConnectorException
Replace a triple's object
Note that the triple will not change, but a new triple with updated information - including the object and summary value - will be returned and should be used in place of the original triple. The new triple will have a different numeric identifier to the original triple.
t
- the triple whose object is to be replaced. Its subject
must have been locked by the requesting store session. The
requesting store session must have read access to its verb.
The verb must not be a special item or a source item (triples
with special items or source items as verbs are updated by
special-purpose methods).object
- the datum that is to be the triple's new object.
The requesting store session must have read access to its value
if that value is an item.session
- the store session requesting the triple be updated.NotInOperationException
TripleStoreNonFatalException
SourceConnectorException
TripleStoreFatalException
public Datum getTripleObject(Triple t, StoreSession session) throws NotInOperationException, SourceConnectorException, TripleStoreNonFatalException, TripleStoreFatalException
session
- the store session requesting the operation.
It must have read access to the subject and verb, and to the
object if this is an item.t
- the triple whose object is to be returnedNotInOperationException
TripleStoreNonFatalException
SourceConnectorException
TripleStoreFatalException
public boolean deleteTriple(Triple t, StoreSession session) throws NotInOperationException, TripleStoreNonFatalException, SourceConnectorException, TripleStoreFatalException
t
- the triple to be deleted. Its subject must have been
locked by the requesting store session and the requesting store
session must have write access to it. The requesting store
session must have read access to its verb, and to its object if
this is an item. The verb must not be a special item or a source
item (triples with special items or source items as verbs are
deleted by special-purpose methods).session
- the store session requesting the triple be deleted.NotInOperationException
TripleStoreNonFatalException
SourceConnectorException
TripleStoreFatalException
public java.util.List<Triple> getTriples(Item subject, Item verb, Datum object, StoreSession session) throws TripleStoreNonFatalException, TripleStoreFatalException, SourceConnectorException, NotInOperationException
subject
- the given subject, or null, in which case all
subjects matchverb
- the given verb, or null, in which case all verbs
matchobject
- the given object, or null, in which case all
objects matchsession
- the store session requesting the triples.NotInOperationException
TripleStoreNonFatalException
TripleStoreFatalException
SourceConnectorException
public java.util.List<Triple> getAllTriples(Item subject, Item verb, StoreSession session) throws TripleStoreNonFatalException, TripleStoreFatalException, SourceConnectorException, NotInOperationException
subject
- the given subjectverb
- the given verbsession
- the store session requesting the triples.NotInOperationException
TripleStoreNonFatalException
TripleStoreFatalException
SourceConnectorException
public boolean allTriplesVisible(Item subject, Item verb, StoreSession session) throws TripleStoreNonFatalException, TripleStoreFatalException, SourceConnectorException, NotInOperationException
subject
- the given subjectverb
- the given verbsession
- the requesting store session.NotInOperationException
TripleStoreNonFatalException
TripleStoreFatalException
SourceConnectorException
public void orderBySubjectVerbObject(java.util.List<Triple> triples) throws NotInOperationException
triples
- the list to be sortedNotInOperationException
- if the triple store is not in operationpublic void orderByVerbObjectSubject(java.util.List<Triple> triples) throws NotInOperationException
triples
- the list to be sortedNotInOperationException
- if the triple store is not in operationpublic void orderByObjectSubjectVerb(java.util.List<Triple> triples) throws NotInOperationException
triples
- the list to be sortedNotInOperationException
- if the triple store is not in operationpublic Triple uniqueTriple(Item subject, Item verb, Datum object, StoreSession session) throws NotInOperationException, TripleStoreNonFatalException, TripleStoreFatalException, SourceConnectorException
subject
- the given subject, or null, in which case all
subjects matchverb
- the given verb, or null, in which case all verbs
matchobject
- the given object, or null, in which case all
objects matchsession
- the store session requesting the triples.NotInOperationException
TripleStoreNonFatalException
TripleStoreFatalException
SourceConnectorException
public Triple setUniqueTriple(Item subject, Item verb, Datum object, StoreSession session) throws NotInOperationException, TripleStoreNonFatalException, TripleStoreFatalException, SourceConnectorException
subject
- the given subject. It must be locked by the requesting
store session before this method is invokedverb
- the given verb. The requesting store session must have read
access to itobject
- the given object. The requesting store session must have
read access to it if it is an item.session
- the requesting store sessionNotInOperationException
TripleStoreNonFatalException
TripleStoreFatalException
SourceConnectorException
public Triple setUniqueObject(Item subject, Item verb, Datum object, StoreSession session) throws NotInOperationException, TripleStoreNonFatalException, TripleStoreFatalException, SourceConnectorException
subject
- the given subject. It must be locked by the requesting store
session before this method is invokedverb
- the given verb. The requesting store session must have read
access to itobject
- the given object. The requesting store session must have read
access to it if it is an item.session
- the requesting store sessionNotInOperationException
TripleStoreNonFatalException
TripleStoreFatalException
SourceConnectorException
public boolean ensureNoMatchingTriples(Item subject, Item verb, StoreSession session) throws NotInOperationException, TripleStoreNonFatalException, TripleStoreFatalException, SourceConnectorException
subject
- the subjectverb
- the verbsession
- the requesting store sessionNotInOperationException
TripleStoreNonFatalException
TripleStoreFatalException
SourceConnectorException