Class DocumentNodeDescriber
ExtendedSession.getNodeByIdentifier(String)
directly: only ItemNotFoundException means that no node carries an
id, and any other repository failure reaches the caller.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of a space group's library folder.static final StringThe statement reading a page of the files under a folder: the folder's path, thejcr:uuidcondition, then the ordering property.static final intThe bound on the unreadable search index hits after a file listing's cursor: once a full page leaves more than this many unreadable hits after the cursor and no readable one, the listing reports the index as broken rather than end the walk.static final StringThe path under which every space's group folder lies. -
Method Summary
Modifier and TypeMethodDescriptiondescribe(org.exoplatform.services.jcr.core.ExtendedSession session, Collection<String> ids, org.exoplatform.social.core.space.spi.SpaceService spaceService) Describes some nodes, whoever may see them.describeForIndex(org.exoplatform.services.jcr.core.ExtendedSession session, Collection<String> ids, org.exoplatform.social.core.space.spi.SpaceService spaceService) Describes some files for a search index built outside Documents, whoever may see them.getAccess(org.exoplatform.services.jcr.core.ExtendedSession session, Collection<String> ids) Tells which of some nodes are files the session's user may read, and which of them he may edit.getFolderAccess(org.exoplatform.services.jcr.core.ExtendedSession session, Collection<String> ids) Tells which of some nodes are folders the session's user may open, and which of them he may edit.listFileIds(org.exoplatform.services.jcr.core.ExtendedSession session, String folderId, String afterId, int limit) Lists a page of the files under a folder, its sub-folders included, whoever may see them, ordered byjcr:uuid.static StringlistFileIdsStatement(String folderPath, String afterId) Builds the statement reading a page of the files under a folder.static org.exoplatform.documents.constant.DocumentNodeTypetypeOf(javax.jcr.Node node)
-
Field Details
-
SPACES_PATH_PREFIX
The path under which every space's group folder lies.- See Also:
-
LIBRARY_FOLDER_NAME
The name of a space group's library folder.- See Also:
-
LIST_FILE_IDS_QUERY
The statement reading a page of the files under a folder: the folder's path, thejcr:uuidcondition, then the ordering property.- See Also:
-
MAX_UNREADABLE_HITS
public static final int MAX_UNREADABLE_HITSThe bound on the unreadable search index hits after a file listing's cursor: once a full page leaves more than this many unreadable hits after the cursor and no readable one, the listing reports the index as broken rather than end the walk. Pages double while they hold no readable hit, so a last page may step over up to about twice as many before the folder ends.- See Also:
-
-
Method Details
-
getAccess
public static Map<String,Boolean> getAccess(org.exoplatform.services.jcr.core.ExtendedSession session, Collection<String> ids) throws javax.jcr.RepositoryException Tells which of some nodes are files the session's user may read, and which of them he may edit.- Parameters:
session- a session of the userids- node identifiers- Returns:
- for each id naming a file the user may read, whether he may edit it; ids naming no node, a node he may not read or another kind of node are absent
- Throws:
javax.jcr.RepositoryException- when the repository fails otherwise reading a node; a failure of the edit check reads as read only
-
getFolderAccess
public static Map<String,Boolean> getFolderAccess(org.exoplatform.services.jcr.core.ExtendedSession session, Collection<String> ids) throws javax.jcr.RepositoryException Tells which of some nodes are folders the session's user may open, and which of them he may edit. A folder is typed astypeOf(Node)types it, so a library root is one, and a shortcut is not: a caller resolves a shortcut to its target first.- Parameters:
session- a session of the userids- node identifiers- Returns:
- for each id naming a folder the user may open, whether he may edit it; ids naming no node, a node he may not read or another kind of node are absent
- Throws:
javax.jcr.RepositoryException- when the repository fails otherwise reading a node; a failure of the edit check reads as read only
-
describe
public static Map<String,org.exoplatform.documents.model.DocumentNodeInfo> describe(org.exoplatform.services.jcr.core.ExtendedSession session, Collection<String> ids, org.exoplatform.social.core.space.spi.SpaceService spaceService) throws javax.jcr.RepositoryException Describes some nodes, whoever may see them.- Parameters:
session- a session that may read every node, a system sessionids- node identifiersspaceService- the service resolving a library's space- Returns:
- each id's description, plus, for a shortcut whose chain ends on a node that is not a shortcut, that node's description under its id; an id no node carries is absent
- Throws:
javax.jcr.RepositoryException- when the repository fails otherwise than by finding no node
-
describeForIndex
public static Map<String,org.exoplatform.documents.model.DocumentIndexInfo> describeForIndex(org.exoplatform.services.jcr.core.ExtendedSession session, Collection<String> ids, org.exoplatform.social.core.space.spi.SpaceService spaceService) throws javax.jcr.RepositoryException Describes some files for a search index built outside Documents, whoever may see them.- Parameters:
session- a session that may read every node, a system sessionids- node identifiersspaceService- the service resolving a library's space- Returns:
- each id naming a file and its description, in the order of the
ids, every
urlnull; an id no node carries, naming a folder, a shortcut or another kind of node, or naming a file in the trash (itself trashed, or under a trashed folder) is absent - Throws:
javax.jcr.RepositoryException- when the repository fails otherwise than by finding no node
-
listFileIds
public static List<String> listFileIds(org.exoplatform.services.jcr.core.ExtendedSession session, String folderId, String afterId, int limit) throws javax.jcr.RepositoryException Lists a page of the files under a folder, its sub-folders included, whoever may see them, ordered byjcr:uuid. Documents makes every file it stores referenceable, so its identifier is itsjcr:uuid; a file that is not referenceable carries nojcr:uuidand is not listed.The end of the folder is decided from the rows the query returns, never from the nodes loaded: the search index can hold a hit whose node no longer exists (a file deleted since it was indexed), which the node iterator would skip silently and so shorten the page. Each row's path is read from the repository's item data, without loading the node; a hit with no item is counted and skipped. It cannot move the cursor, since its
jcr:uuidis not readable, so the next query asks for as many more rows as there are unreadable hits after the cursor, and for twice the last page when that page held no readable hit, so that a run of unreadable hits reaches the bound in a few queries; the page still ends atlimitfiles. A row whose node now lies outside the folder (a file moved since it was indexed) moves the cursor but is not listed.- Parameters:
session- a session that may read every node, a system sessionfolderId- the folder's identifierafterId- the identifier the page starts after, null for the first pagelimit- the most identifiers returned- Returns:
- up to
limitfile identifiers followingafterId, fewer only when the query has no row left; empty when no folder carriesfolderId - Throws:
javax.jcr.RepositoryException- when the repository fails otherwise than by finding no node, or when a full page leaves more thanMAX_UNREADABLE_HITSunreadable hits after the cursor and no readable one
-
listFileIdsStatement
Builds the statement reading a page of the files under a folder.- Parameters:
folderPath- the folder's pathafterId- the identifier the page starts after, null for the first page- Returns:
- a JCR SQL statement, its string literals escaped
-
typeOf
public static org.exoplatform.documents.constant.DocumentNodeType typeOf(javax.jcr.Node node) throws javax.jcr.RepositoryException - Parameters:
node- a node- Returns:
- what the node is, read from its own primary type: a version's
frozen node is
DocumentNodeType.OTHER, whatever it froze - Throws:
javax.jcr.RepositoryException- when the type cannot be read
-