org.nuiton.wikitty
Class WikittyProxy

java.lang.Object
  extended by org.nuiton.wikitty.WikittyProxy

public class WikittyProxy
extends Object

Wikitty proxy is used to transform wikitty object used by WikittyService into business objects used by applications. It also manage securityToken for WikittyServiceSecurity.

Version:
$Revision: 700 $ Last update: $Date: 2011-01-31 16:25:48 +0100 (lun., 31 janv. 2011) $ by : $Author: bpoussin $
Author:
poussin

Field Summary
protected  String securityToken
          Security token.
protected static org.nuiton.util.TimeTrace timeTrace
           
protected  WikittyServiceEnhanced wikittyService
          Delegated wikitty service.
 
Constructor Summary
WikittyProxy()
          Empty constructor (uninitialized wikittyService).
WikittyProxy(org.nuiton.util.ApplicationConfig config)
           
WikittyProxy(org.nuiton.util.ApplicationConfig config, WikittyService wikittyService)
           
WikittyProxy(WikittyService wikittyService)
          Constructor with wikittyService.
 
Method Summary
<E extends BusinessEntity>
E
cast(BusinessEntity source, Class<E> target)
          Cast Business object to another Business Object If source don't have target extension, this extension is added
 WikittyEvent clear()
          Use with caution : It will delete ALL indexes from search engine !
 void delete(Collection<String> ids)
           
 void delete(String id)
           
 void deleteExtension(Collection<String> extNames)
           
 void deleteExtension(String extName)
           
 WikittyEvent deleteTree(String treeNodeId)
          Delete specified tree node and all sub nodes.
<E extends BusinessEntity>
PagedResult<E>
findAllByCriteria(Class<E> clazz, Criteria criteria)
          Search object that correspond to criteria and that have all extension needed by BusinessEntity (clazz).
 PagedResult<Wikitty> findAllByCriteria(Criteria criteria)
           
<E extends BusinessEntityImpl>
PagedResult<E>
findAllByExample(E e, int firstIndex, int endIndex, String... fieldFacet)
          Null field are not used in search request.
 PagedResult<String> findAllIdByCriteria(Criteria criteria)
           
 TreeNodeResult<String> findAllIdTreeNode(String wikittyId, int depth, boolean count, Criteria filter)
          Return just wikitty Id in result
<E extends BusinessEntity>
E
findByCriteria(Class<E> clazz, Criteria criteria)
           
 Wikitty findByCriteria(Criteria criteria)
           
<E extends BusinessEntityImpl>
E
findByExample(E e)
          Null field are not used in search request.
<E extends BusinessEntity>
Map<E,Integer>
findTreeNode(Class<E> clazz, String wikittyId, Criteria filter)
          Deprecated. since 3.1: use findTreeNode(java.lang.String, int, boolean, org.nuiton.wikitty.search.Criteria) or open new ticket with your need
<E extends BusinessEntity>
Map<E,Integer>
findTreeNode(Class<E> clazz, String wikittyId, Criteria filter, boolean checkExtension)
          Deprecated. since 3.1: use findTreeNode(java.lang.String, int, boolean, org.nuiton.wikitty.search.Criteria) or open new ticket with your need
<E extends BusinessEntity>
TreeNodeResult<E>
findTreeNode(Class<E> clazz, String wikittyId, int depth, boolean count, Criteria filter)
          Recupere une portion d'arbre a partir de l'id passer en parametre.
 TreeNodeResult<Wikitty> findTreeNode(String wikittyId, int depth, boolean count, Criteria filter)
          Recupere une portion d'arbre a partir de l'id passer en parametre.
 List<String> getAllExtensionIds()
          Return all extension id (ex: "extName[version])").
 List<String> getAllExtensionsRequires(String extensionName)
          Return all extension id (ex: "extName[version])") where extensionName is required.
static Map<String,org.nuiton.util.TimeTrace.CallStat> getCallCount()
           
 WikittyUser getLoggedInUser()
          Get the #WikittyUser that is logged in.
 String getSecurityToken()
           
static org.nuiton.util.TimeTrace getTimeTrace()
           
 Wikitty getWikitty(BusinessEntity entity)
          Method to get the Wikitty encapsulated into a BusinessEntity
 WikittyService getWikittyService()
           
<E extends BusinessEntity>
boolean
hasType(Class<E> clazz, String wikittyId)
           
 boolean isMember(String groupName)
          Check that the logged in user is in a group.
 void login(String login, String password)
           
 void logout()
           
<E extends BusinessEntity>
List<E>
restore(Class<E> clazz, List<String> id)
           
<E extends BusinessEntity>
List<E>
restore(Class<E> clazz, List<String> id, boolean checkExtension)
          Restore wikitty entity with specified id or null if entity can't be be found.
<E extends BusinessEntity>
E
restore(Class<E> clazz, String id)
          Restore wikitty entity with specified id or null if entity can't be found.
<E extends BusinessEntity>
E
restore(Class<E> clazz, String id, boolean checkExtension)
          Restore wikitty entity with specified id or null if entity can't be found.
 List<Wikitty> restore(List<String> id)
          Restore wikitty entity with specified id or null if entity can't be be found.
 Wikitty restore(String id)
          Restore wikitty entity with specified id or null if entity can't be found.
 WikittyExtension restoreExtension(String extensionId)
          Load extension from id.
 WikittyExtension restoreExtensionLastVersion(String extensionName)
          Search extension with name in last version.
<E extends BusinessEntity>
Map.Entry<E,Integer>
restoreNode(Class<E> clazz, String wikittyId, Criteria filter)
          Deprecated. since 3.1: use findTreeNode(java.lang.String, int, boolean, org.nuiton.wikitty.search.Criteria) or open new ticket with your need
<E extends BusinessEntity>
Map.Entry<E,Integer>
restoreNode(Class<E> clazz, String wikittyId, Criteria filter, boolean checkExtension)
          Deprecated. since 3.1: use findTreeNode(java.lang.String, int, boolean, org.nuiton.wikitty.search.Criteria) or open new ticket with your need
 Wikitty restoreVersion(String wikittyId, String version)
           
 void setSecurityToken(String securityToken)
           
 void setWikittyService(WikittyService wikittyService)
           
<E extends BusinessEntity>
E
store(E e)
           
<E extends BusinessEntity>
List<E>
store(List<E> objets)
          Store to WikittyService objects.
 Wikitty store(Wikitty w)
           
 WikittyEvent storeExtension(Collection<WikittyExtension> exts)
          Manage Update and creation.
 WikittyEvent storeExtension(WikittyExtension ext)
          Manage Update and creation.
 List<Wikitty> storeWikitty(List<Wikitty> wikitties)
           
 void syncSearchEngine()
          Synchronize search engine with wikitty storage engine, i.e. clear and reindex all object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

timeTrace

protected static org.nuiton.util.TimeTrace timeTrace

wikittyService

protected WikittyServiceEnhanced wikittyService
Delegated wikitty service.


securityToken

protected String securityToken
Security token.

See Also:
WikittyServiceSecurity.login(String, String)
Constructor Detail

WikittyProxy

public WikittyProxy()
Empty constructor (uninitialized wikittyService).


WikittyProxy

public WikittyProxy(org.nuiton.util.ApplicationConfig config)

WikittyProxy

public WikittyProxy(WikittyService wikittyService)
Constructor with wikittyService.

Parameters:
wikittyService - wikitty service

WikittyProxy

public WikittyProxy(org.nuiton.util.ApplicationConfig config,
                    WikittyService wikittyService)
Method Detail

getTimeTrace

public static org.nuiton.util.TimeTrace getTimeTrace()

getCallCount

public static Map<String,org.nuiton.util.TimeTrace.CallStat> getCallCount()

login

public void login(String login,
                  String password)

logout

public void logout()

getSecurityToken

public String getSecurityToken()

setSecurityToken

public void setSecurityToken(String securityToken)

getWikittyService

public WikittyService getWikittyService()

setWikittyService

public void setWikittyService(WikittyService wikittyService)

cast

public <E extends BusinessEntity> E cast(BusinessEntity source,
                                         Class<E> target)
Cast Business object to another Business Object If source don't have target extension, this extension is added

Parameters:
source - business entity source
target - business entity class wanted
Returns:
new instance of object wanted

store

public <E extends BusinessEntity> E store(E e)

store

public Wikitty store(Wikitty w)

store

public <E extends BusinessEntity> List<E> store(List<E> objets)
Store to WikittyService objects.

Type Parameters:
E - object type
Parameters:
objets - list
Returns:
updated objects list

storeWikitty

public List<Wikitty> storeWikitty(List<Wikitty> wikitties)

restore

public <E extends BusinessEntity> E restore(Class<E> clazz,
                                            String id,
                                            boolean checkExtension)
Restore wikitty entity with specified id or null if entity can't be found.

Type Parameters:
E - object type
Parameters:
clazz - entity class
id - entity id
checkExtension - if true check that Wikitty result has all extension declared in clazz
Returns:
wikitty entity with specified id or null if entity can't be found

restore

public Wikitty restore(String id)
Restore wikitty entity with specified id or null if entity can't be found.

Parameters:
id - entity id
Returns:
wikitty entity with specified id or null if entity can't be found

restore

public <E extends BusinessEntity> E restore(Class<E> clazz,
                                            String id)
Restore wikitty entity with specified id or null if entity can't be found.

Type Parameters:
E - object type
Parameters:
clazz - entity class
id - entity id
Returns:
wikitty entity with specified id or null if entity can't be found

restore

public List<Wikitty> restore(List<String> id)
Restore wikitty entity with specified id or null if entity can't be be found.

Parameters:
id - entity id
Returns:
wikitty entity with specified id or null if entity can't be found

restore

public <E extends BusinessEntity> List<E> restore(Class<E> clazz,
                                                  List<String> id,
                                                  boolean checkExtension)
Restore wikitty entity with specified id or null if entity can't be be found.

Type Parameters:
E - object type
Parameters:
clazz - entity class
id - entity id
checkExtension - if true check that Wikitty result has all extension
Returns:
wikitty entity with specified id or null if entity can't be found or if one wikitty don't have extension wanted by E type

restore

public <E extends BusinessEntity> List<E> restore(Class<E> clazz,
                                                  List<String> id)

delete

public void delete(String id)

delete

public void delete(Collection<String> ids)

findAllByExample

public <E extends BusinessEntityImpl> PagedResult<E> findAllByExample(E e,
                                                                      int firstIndex,
                                                                      int endIndex,
                                                                      String... fieldFacet)
Null field are not used in search request.

Parameters:
e - sample wikitty
firstIndex -
endIndex -
fieldFacet -
Returns:

findByExample

public <E extends BusinessEntityImpl> E findByExample(E e)
Null field are not used in search request.

Parameters:
e - sample wikitty
Returns:

findAllByCriteria

public <E extends BusinessEntity> PagedResult<E> findAllByCriteria(Class<E> clazz,
                                                                   Criteria criteria)
Search object that correspond to criteria and that have all extension needed by BusinessEntity (clazz). If criteria is null, find all extensions else if criteria is empty return nothing.

Type Parameters:
E - object type
Parameters:
clazz - entity class
criteria - criteria
Returns:
paged result

findAllByCriteria

public PagedResult<Wikitty> findAllByCriteria(Criteria criteria)

findAllIdByCriteria

public PagedResult<String> findAllIdByCriteria(Criteria criteria)

findTreeNode

public TreeNodeResult<Wikitty> findTreeNode(String wikittyId,
                                            int depth,
                                            boolean count,
                                            Criteria filter)
Recupere une portion d'arbre a partir de l'id passer en parametre. L'id doit etre celui d'un WikittyTreeNode. Ce WikittyTreeNode est alors le root de l'arbre retourne. Return Wikitty in result, those Wikitties have WikittyTreeNode extension

Parameters:
clazz - business class wanted to replace id in TreeNodeResult
wikittyId - root
depth - profondeur de noeud a recuperer
count - vrai si l'on veut le nombre de piece attaches sur le noeud (piece des enfants compris)
filter - filter pour compter les pieces attachees
Returns:
Since:
3.1

findTreeNode

public <E extends BusinessEntity> TreeNodeResult<E> findTreeNode(Class<E> clazz,
                                                                 String wikittyId,
                                                                 int depth,
                                                                 boolean count,
                                                                 Criteria filter)
Recupere une portion d'arbre a partir de l'id passer en parametre. L'id doit etre celui d'un WikittyTreeNode. Ce WikittyTreeNode est alors le root de l'arbre retourne. Return E in result

Parameters:
clazz - business class wanted to replace id in TreeNodeResult
wikittyId - root
depth - profondeur de noeud a recuperer
count - vrai si l'on veut le nombre de piece attaches sur le noeud (piece des enfants compris)
filter - filter pour compter les pieces attachees
Returns:
Since:
3.1

findAllIdTreeNode

public TreeNodeResult<String> findAllIdTreeNode(String wikittyId,
                                                int depth,
                                                boolean count,
                                                Criteria filter)
Return just wikitty Id in result

Parameters:
wikittyId -
depth -
count -
filter -
Returns:
Since:
3.1

findByCriteria

public <E extends BusinessEntity> E findByCriteria(Class<E> clazz,
                                                   Criteria criteria)

findByCriteria

public Wikitty findByCriteria(Criteria criteria)

deleteTree

public WikittyEvent deleteTree(String treeNodeId)
Delete specified tree node and all sub nodes.

Parameters:
treeNodeId - tree node id to delete
Returns:
if at least one node has been deleted

restoreNode

@Deprecated
public <E extends BusinessEntity> Map.Entry<E,Integer> restoreNode(Class<E> clazz,
                                                                              String wikittyId,
                                                                              Criteria filter)
Deprecated. since 3.1: use findTreeNode(java.lang.String, int, boolean, org.nuiton.wikitty.search.Criteria) or open new ticket with your need

Restore node with wikittyId passed in argument and count of attachment in subtree begin with this node

Type Parameters:
E -
Parameters:
clazz -
wikittyId -
filter -
Returns:

restoreNode

@Deprecated
public <E extends BusinessEntity> Map.Entry<E,Integer> restoreNode(Class<E> clazz,
                                                                              String wikittyId,
                                                                              Criteria filter,
                                                                              boolean checkExtension)
Deprecated. since 3.1: use findTreeNode(java.lang.String, int, boolean, org.nuiton.wikitty.search.Criteria) or open new ticket with your need

Restore node with wikittyId passed in argument and count of attachment in subtree begin with this node ATTENTION: extension is never checked.

Type Parameters:
E -
Parameters:
clazz -
wikittyId -
filter -
checkExtension - not used

findTreeNode

@Deprecated
public <E extends BusinessEntity> Map<E,Integer> findTreeNode(Class<E> clazz,
                                                                         String wikittyId,
                                                                         Criteria filter)
Deprecated. since 3.1: use findTreeNode(java.lang.String, int, boolean, org.nuiton.wikitty.search.Criteria) or open new ticket with your need

Return only children of wikittyId passed in argument

Parameters:
clazz -
wikittyId -
filter -
Returns:

findTreeNode

@Deprecated
public <E extends BusinessEntity> Map<E,Integer> findTreeNode(Class<E> clazz,
                                                                         String wikittyId,
                                                                         Criteria filter,
                                                                         boolean checkExtension)
Deprecated. since 3.1: use findTreeNode(java.lang.String, int, boolean, org.nuiton.wikitty.search.Criteria) or open new ticket with your need

Return only children of wikittyId passed in argument ATTENTION: extension is never checked.


restoreVersion

public Wikitty restoreVersion(String wikittyId,
                              String version)

hasType

public <E extends BusinessEntity> boolean hasType(Class<E> clazz,
                                                  String wikittyId)

storeExtension

public WikittyEvent storeExtension(WikittyExtension ext)
Manage Update and creation.

Parameters:
ext - extension to be persisted
Returns:
update response

storeExtension

public WikittyEvent storeExtension(Collection<WikittyExtension> exts)
Manage Update and creation.

Parameters:
exts - list of wikitty extension to be persisted
Returns:
update response

restoreExtension

public WikittyExtension restoreExtension(String extensionId)
Load extension from id. Id is 'name[version]'.

Parameters:
extensionId - extension id to restore
Returns:
the corresponding object, exception if no such object found.

restoreExtensionLastVersion

public WikittyExtension restoreExtensionLastVersion(String extensionName)
Search extension with name in last version.

Parameters:
extensionName - extension name
Returns:
the corresponding object, exception if no such object found.

deleteExtension

public void deleteExtension(String extName)

deleteExtension

public void deleteExtension(Collection<String> extNames)

getAllExtensionIds

public List<String> getAllExtensionIds()
Return all extension id (ex: "extName[version])").

Returns:
extension id list

getAllExtensionsRequires

public List<String> getAllExtensionsRequires(String extensionName)
Return all extension id (ex: "extName[version])") where extensionName is required.

Parameters:
extensionName - extension name
Returns:
extensions

clear

public WikittyEvent clear()
Use with caution : It will delete ALL indexes from search engine ! This operation should be disabled in production environment.


syncSearchEngine

public void syncSearchEngine()
Synchronize search engine with wikitty storage engine, i.e. clear and reindex all object.


getWikitty

public Wikitty getWikitty(BusinessEntity entity)
Method to get the Wikitty encapsulated into a BusinessEntity

Parameters:
entity - the BusinessEntity encapsulating the Wikitty
Returns:
the wikitty encapsulated

isMember

public boolean isMember(String groupName)
Check that the logged in user is in a group. A #SecurityException might be thrown at runtime if the #WikittyUser session timed out.

Parameters:
groupName - the name of the group to check
Returns:
true is the logged in user is in the group

getLoggedInUser

public WikittyUser getLoggedInUser()
Get the #WikittyUser that is logged in. A #SecurityException might be thrown at runtime if the #WikittyUser session timed out.

Returns:
the logged in #WikittyUser


Copyright © 2009-2011 CodeLutin. All Rights Reserved.