@DeclareRoles(value={"org.imixs.ACCESSLEVEL.NOACCESS","org.imixs.ACCESSLEVEL.READERACCESS","org.imixs.ACCESSLEVEL.AUTHORACCESS","org.imixs.ACCESSLEVEL.EDITORACCESS","org.imixs.ACCESSLEVEL.MANAGERACCESS"}) @RolesAllowed(value={"org.imixs.ACCESSLEVEL.NOACCESS","org.imixs.ACCESSLEVEL.READERACCESS","org.imixs.ACCESSLEVEL.AUTHORACCESS","org.imixs.ACCESSLEVEL.EDITORACCESS","org.imixs.ACCESSLEVEL.MANAGERACCESS"}) public class DocumentService extends Object
The Bean holds an instance of an EntityPersistenceManager for the persistence unit 'org.imixs.workflow.jpa' to manage the Document entity bean class. The Document entity bean is used to store the attributes of a ItemCollection into the connected database.
The save() method persists any instance of an ItemCollection. If a ItemCollection is saved the first time the DocumentService generates the attribute $uniqueid which will be included in the ItemCollection returned by this method. If a ItemCollection was saved before the method updates the corresponding Document Object.
The load() and find() methods are used to read ItemCollections from the database. The remove() method deletes a saved ItemCollection from the database.
All methods expect and return Instances of the object org.imixs.workflow.ItemCollection which is no entity EJB. So these objects are not managed by any instance of an EntityPersistenceManager.
A collection of ItemCollections can be read using the find() method using EQL syntax.
Additional to the basic functionality to save and load instances of the object org.imixs.workflow.ItemCollection the method also manages the read- and writeAccess for each instance of an ItemCollection. Therefore the save() method scans an ItemCollection for the attributes '$ReadAccess' and '$WriteAccess'. The DocumentService verifies in each call of the save() load(), remove() and find() methods if the current callerPrincipal is granted to the affected entities. If an ItemCollection was saved with read- or writeAccess the access to an Instance of a saved ItemCollection will be protected for a callerPrincipal with missing read- or writeAccess.
Document| Modifier and Type | Field and Description |
|---|---|
static String |
ACCESSLEVEL_AUTHORACCESS |
static String |
ACCESSLEVEL_EDITORACCESS |
static String |
ACCESSLEVEL_MANAGERACCESS |
static String |
ACCESSLEVEL_NOACCESS |
static String |
ACCESSLEVEL_READERACCESS |
protected javax.enterprise.event.Event<DocumentEvent> |
documentEvents |
static String |
IMMUTABLE |
static String |
INVALID_PARAMETER |
static String |
INVALID_UNIQUEID |
static String |
ISAUTHOR |
static String |
NOINDEX |
static String |
OPERATION_NOTALLOWED |
static String |
READACCESS |
static String |
USER_GROUP_LIST |
protected javax.enterprise.event.Event<UserGroupEvent> |
userGroupEvents |
static String |
WRITEACCESS |
| Constructor and Description |
|---|
DocumentService() |
| Modifier and Type | Method and Description |
|---|---|
void |
backup(String query,
String filePath)
This method creates a backup of the result set form a Lucene search query.
|
int |
count(String searchTerm)
Returns the total hits for a given search query.
|
int |
count(String sSearchTerm,
int maxResult)
Returns the total hits for a given search query.
|
int |
countPages(String searchTerm,
int pageSize)
Returns the total pages for a given search term and a given page size.
|
List<ItemCollection> |
find(String searchTerm,
int pageSize,
int pageIndex)
The method returns a list of ItemCollections by calling the
LuceneSearchService.
|
List<ItemCollection> |
find(String searchTerm,
int pageSize,
int pageIndex,
String sortBy,
boolean sortReverse)
The method returns a sorted list of ItemCollections by calling the
LuceneSearchService.
|
List<ItemCollection> |
findDocumentsByRef(String uniqueIdRef,
int pageSize,
int pageIndex)
The method returns a collection of ItemCollections referred by a $uniqueid.
|
String |
getAccessRoles()
Returns a comma separated list of additional Access-Roles defined for this
service
|
Boolean |
getDisableOptimisticLocking() |
List<ItemCollection> |
getDocumentsByQuery(String query)
Returns all documents of by JPQL statement
|
List<ItemCollection> |
getDocumentsByQuery(String query,
int maxResult)
Returns all documents of by JPQL statement.
|
List<ItemCollection> |
getDocumentsByQuery(String query,
int firstResult,
int maxResult)
Returns all documents of by JPQL statement.
|
List<ItemCollection> |
getDocumentsByType(String type)
Returns an unordered list of all documents of a specific type.
|
List<String> |
getUserNameList()
This method returns a list of user names, roles and application groups the
user belongs to.
|
boolean |
isUserContained(List<String> nameList)
This method returns true, if at least one element of the current UserNameList
is contained in a given name list.
|
boolean |
isUserInRole(String rolename)
Test if the caller has a given security role.
|
ItemCollection |
load(String id)
This method loads an ItemCollection from the Database.
|
void |
remove(ItemCollection document)
This method removes an ItemCollection from the database.
|
void |
restore(String filePath)
This method restores a backup from the file system and imports the Documents
into the database.
|
ItemCollection |
save(ItemCollection document)
This Method saves an ItemCollection into the database.
|
ItemCollection |
saveByNewTransaction(ItemCollection itemcol)
This method saves a workitem in a new transaction.
|
void |
setAccessRoles(String accessRoles) |
void |
setDisableOptimisticLocking(Boolean disableOptimisticLocking)
returns the disable optimistic locking status
|
public static final String ACCESSLEVEL_NOACCESS
public static final String ACCESSLEVEL_READERACCESS
public static final String ACCESSLEVEL_AUTHORACCESS
public static final String ACCESSLEVEL_EDITORACCESS
public static final String ACCESSLEVEL_MANAGERACCESS
public static final String READACCESS
public static final String WRITEACCESS
public static final String ISAUTHOR
public static final String NOINDEX
public static final String IMMUTABLE
public static final String USER_GROUP_LIST
public static final String OPERATION_NOTALLOWED
public static final String INVALID_PARAMETER
public static final String INVALID_UNIQUEID
@Inject protected javax.enterprise.event.Event<DocumentEvent> documentEvents
@Inject protected javax.enterprise.event.Event<UserGroupEvent> userGroupEvents
public String getAccessRoles()
public void setAccessRoles(String accessRoles)
public void setDisableOptimisticLocking(Boolean disableOptimisticLocking)
public Boolean getDisableOptimisticLocking()
public List<String> getUserNameList()
A client can extend the list of user groups associated with a userId by reacting on the CDI event 'UserGrouptEvent'.
UserGroupEventpublic boolean isUserContained(List<String> nameList)
nameList - public boolean isUserInRole(String rolename)
rolename - public ItemCollection save(ItemCollection document) throws AccessDeniedException
The Method returns an updated instance of the ItemCollection containing the attributes $modified, $created, and $uniqueId
The method throws an AccessDeniedException if the CallerPrincipal is not allowed to save or update the ItemCollection in the database. The CallerPrincipial should have at least the access Role org.imixs.ACCESSLEVEL.AUTHORACCESS
The method adds/updates the document into the lucene index.
The method returns a itemCollection without the $VersionNumber from the persisted entity. (see issue #226)
issue #230: The document will be marked as 'saved' so that the methods load() and getDocumentsByQuery() can evaluate this flag. Depending on the state, the methods can decide the correct behavior. In general we detach a document in the load() and getDocumentsByQuery() method. This is for performance reasons and the fact, that a ItemCollection can hold byte arrays which will be copied by reference. In cases where these methods are called after a document was saved (document is now managed), in one single transaction, the detach call will discard the changes made by the save() method. For that reason we flag the entity and evaluate this flag in the load method evaluates the save status.
ItemCollection - to be savedAccessDeniedExceptionpublic ItemCollection saveByNewTransaction(ItemCollection itemcol) throws AccessDeniedException
workitem= sessionContext.getBusinessObject(EntityService.class)
.saveByNewTransaction(workitem);
itemcol - AccessDeniedExceptionpublic ItemCollection load(String id)
The method checks if the CallerPrincipal has read access to Document stored in the database. If not, the method returns null.
Note: The method dose not throw an AccessDeniedException if the user is not allowed to read the entity to prevent a aggressor with informations about the existence of that specific Document.
The CallerPrincipial need to have at least the access level org.imixs.ACCESSLEVEL.READACCESS
issue #230 In case a document is not flagged (not saved during same transaction), we detach the loaded entity. In case a document is flagged (saved during save transaction) we may not detach it, but make a deepCopy (clone) of the document instance. This will avoid the effect, that data written to a document get lost in a long running transaction with save and load calls.
id - - the $uniqueid of the ItemCollection to be loadedpublic void remove(ItemCollection document) throws AccessDeniedException
The CallerPrincipial should have at least the access Role org.imixs.ACCESSLEVEL.AUTHORACCESS
Also the method removes the document form the lucene index.
ItemCollection - to be removedAccessDeniedExceptionpublic int count(String searchTerm) throws QueryException
sSearchTerm - QueryException - in case the searchterm is not understandable.search(String, int, int, Sort, Operator)public int count(String sSearchTerm, int maxResult) throws QueryException
sSearchTerm - maxResult - - max search resultdefaultOperator - - optional to change the default search operatorQueryException - in case the searchterm is not understandable.search(String, int, int, Sort, Operator)public int countPages(String searchTerm, int pageSize) throws QueryException
searchTerm - pageSize - QueryException - in case the searchterm is not understandable.count(String sSearchTerm)public List<ItemCollection> find(String searchTerm, int pageSize, int pageIndex) throws QueryException
The method returns only ItemCollections which are readable by the CallerPrincipal. With the pageSize and pageNumber it is possible to paginate.
searchTerm - - Lucene search termpageSize - - total docs per pagepageIndex - - number of page to start (default = 0)QueryExceptionLuceneSearchServicepublic List<ItemCollection> find(String searchTerm, int pageSize, int pageIndex, String sortBy, boolean sortReverse) throws QueryException
The method expects an valid Lucene search term. The method returns only ItemCollections which are readable by the CallerPrincipal. With the pageSize and pageNumber it is possible to paginate.
searchTerm - - Lucene search termpageSize - - total docs per pagepageIndex - - number of page to start (default = 0)sortBy - -optional field to sort the resultsortReverse - - optional sort directionQueryExceptionLuceneSearchServicepublic List<ItemCollection> findDocumentsByRef(String uniqueIdRef, int pageSize, int pageIndex)
The method returns only ItemCollections which are readable by the CallerPrincipal. With the pageSize and pageNumber it is possible to paginate.
uniqueIdRef - - $uniqueId to be referred by the collected documentspageSize - - total docs per pagepageIndex - - number of page to start (default = 0)public List<ItemCollection> getDocumentsByType(String type)
type - InvalidAccessExceptionpublic List<ItemCollection> getDocumentsByQuery(String query)
query - - JPQL statementpublic List<ItemCollection> getDocumentsByQuery(String query, int maxResult)
query - - JPQL statementmaxResult - - maximum result setpublic List<ItemCollection> getDocumentsByQuery(String query, int firstResult, int maxResult)
query - - JPQL statementmaxResult - - maximum result setpublic void backup(String query, String filePath) throws IOException, QueryException
entities - IOExceptionQueryExceptionpublic void restore(String filePath) throws IOException
filepath - IOExceptionCopyright © 2006–2019 Imixs Software Solutions GmbH. All rights reserved.