Interface ProjectLogic
-
public interface ProjectLogicDelegated Access's logic interface- Author:
- Bryan Holladay (holladay@longsight.com)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanaddChildrenNodes(Object node, String userId, List<ListOptionSerialized> blankRestrictedTools, boolean onlyAccessNodes, List<String> accessAdminNodes, boolean shopping, boolean shoppingPeriodTool)Adds children node to a node that hasn't had it's children populated.voidclearNodeCache()clears DelegatedAccess's own node cacheTreeModelcreateAccessTreeModelForUser(String userId, boolean addDirectChildren, boolean cascade)returns the tree model of a user's delegated access.TreeModelcreateEntireTreeModelForUser(String userId, boolean addDirectChildren, boolean cascade)This returns a full tree model for a user.TreeModelcreateTreeModelForShoppingPeriod(String userId)returns the tree model that looks up the shopping period information for the sites the user has access tovoiddeleteEmptyNonSiteNodes(String hierarchyId)Deletes empty non sites nodes in a hierarchy (nodes that doesn't start with /site/ and has no children)Set<String>filterShoppingPeriodEditNodes(Set<String> nodeIds)filters out any node id that the user doesn't have permission to modify shopping period settingsSet<String>filterShoppingPeriodEditNodes(Set<String> nodeIds, String userId)filters out any node id that the user doesn't have permission to modify shopping period settingsSet<HierarchyNodeSerialized>getAccessAdminNodesForUser(String userId)Returns a set of hierarchy nodes that the user has been assigned accessAdmin privileges for.List<AccessSearchResult>getAccessAtLevel(List<String> nodeSelectOrder, boolean includeLowerPerms)returns a list of results for every level that is passed in.List<AccessSearchResult>getAccessForUser(User user)returns a list of AccessSearchResult based on the user idStringgetAddDAMyworkspaceJobStatus()returns the status of the job for adding delegated access tool to user's my workspace.HierarchyNodeSerializedgetCachedNode(String id)returns a HierarchyNodeSerialized nodeMap<String,HierarchyNodeSerialized>getCachedNodes(String[] ids)returns a map of HierarchyNodesString[]getCurrentUsersAccessToSite(String siteRef)This returns an array of {realm, role} for which the user has delegated access to.Set<HierarchyNodeSerialized>getDirectNodes(String nodeId)returns a set of direct children nodes for passed in node idList<ListOptionSerialized>getEntireToolsList()returns a blank (unselected) list of all the tool options for restricting toolsTreeModelgetEntireTreePlusUserPerms(String userId)This returns the entire tree plus any permissions set for a userDategetHierarchyJobLastRunDate(String nodeId)returns the hierarchyjoblastrundate date for the node Id and hierarchy userMap<String,Set<String>>getHierarchySearchOptions(Map<String,String> hierarchySearchMap)NodeModelgetNodeModel(String nodeId, String userId)This will return a fully instantiated NodeModel for that user and id.Map<String,List<String>>getNodesBySiteRef(String[] siteRef, String hierarchyId)Returns a map of {siteRef, nodeId}Map<String,String>getRealmRoleDisplay(boolean shopping)returns a map of all role options and their realm/role ids separated by a ':'.HierarchyNodeSerializedgetRootNodeId()returns the root node for DAMap<String,AccessNode>getUserAccessForSite(String siteRef)Returns a map of UserId -> AccessNodebooleanhasAccessAdminNodes(String userId)returns whether the user has any "access admin" permissionbooleanhasAllowBecomeUserPerm(String userId)returns whether the user has any "allowBecomeUser" permissionbooleanhasDelegatedAccessNodes(String userId)returns whether the user has any delegated accessbooleanhasShoppingPeriodAdminNodes(String userId)Returns whether the user has any shopping period admin accessvoidinitializeDelegatedAccessSession()updates the user's Session adding all of the user's site and role access to the delegatedaccess.accessmap Session attribute.booleanisShoppingPeriodOpenForSite(Date startDate, Date endDate, String[] nodeAccessRealmRole, String[] restrictedAuthTools, String[] restrictedPublicTools)Call this function to determine if the shopping period is available for a set of settingsbooleanisUserAllowBecomeUser(String userId, String siteRef)returns true if the user has site access and has the "allowBecomeUser" permission set for this site or any of it's parentsvoidremoveAccess(String nodeId, String userId, int accessType)This will remove access at the node id passed in.voidremoveAllPermsForUser(String userId)Removes all permissions for a uservoidremoveNode(String nodeId)Removes this node an all permissions and children nodesvoidremoveNode(HierarchyNode node)Removes this node and all permissions and children nodesvoidsaveHierarchyJobLastRunDate(Date runDate, String nodeId)Saves the date for the last time the hierarchy job ran successfullyvoidscheduleAddDAMyworkspaceJobStatus()Schedules the AddDAMyworkspace job to run immediatelyList<SearchResult>searchUsers(String search)Returns a list of SearchResults for the user searchList<SiteSearchResult>searchUserSites(String search, Map<String,Object> advancedOptions, boolean shoppingPeriod, boolean activeShoppingData)Searches user access sites by siteId and siteTitle and propsvoidsyncMyworkspaceToolForUser(String userId)This will ensure the Delegated Access tool is synced with the user's MyWorkspace.voidupdateAddDAMyworkspaceJobStatus(String status)removes the old status and updates it with the string passed invoidupdateNodePermissionsForUser(DefaultMutableTreeNode node, String userId)Removes old user permissions and replaces it with the passed in information.voidupdateNodePermissionsForUser(NodeModel nodeModel, String userId)Map<String,String>updateShoppingPeriodSettings(DefaultMutableTreeNode node)Call this method if you want to update a node and all it's children it will only update nodes that start with /site/
-
-
-
Method Detail
-
getCurrentUsersAccessToSite
String[] getCurrentUsersAccessToSite(String siteRef)
This returns an array of {realm, role} for which the user has delegated access to. If nothing is found, then it returns null. This function also updates the denied tools session map- Parameters:
siteRef-- Returns:
-
searchUsers
List<SearchResult> searchUsers(String search)
Returns a list of SearchResults for the user search- Parameters:
search-first-last-- Returns:
-
updateNodePermissionsForUser
void updateNodePermissionsForUser(DefaultMutableTreeNode node, String userId)
Removes old user permissions and replaces it with the passed in information.- Parameters:
nodeModel-userId-
-
initializeDelegatedAccessSession
void initializeDelegatedAccessSession()
updates the user's Session adding all of the user's site and role access to the delegatedaccess.accessmap Session attribute. This controls the user's permissions for that site. If the nodeId doesn't have an access role specified, it will grant the inherited access role.
-
searchUserSites
List<SiteSearchResult> searchUserSites(String search, Map<String,Object> advancedOptions, boolean shoppingPeriod, boolean activeShoppingData)
Searches user access sites by siteId and siteTitle and props- Parameters:
search-advancedOptions-shoppingPeriod-activeShoppingData-- Returns:
-
createAccessTreeModelForUser
TreeModel createAccessTreeModelForUser(String userId, boolean addDirectChildren, boolean cascade)
returns the tree model of a user's delegated access. Each node in the tree has the NodeModel object completely initialized.- Parameters:
userId-addDirectChildren-cascade-- Returns:
-
createEntireTreeModelForUser
TreeModel createEntireTreeModelForUser(String userId, boolean addDirectChildren, boolean cascade)
This returns a full tree model for a user. It will reference both their access and shopping period admin permissions.- Parameters:
userId-addDirectChildren-cascade-- Returns:
-
createTreeModelForShoppingPeriod
TreeModel createTreeModelForShoppingPeriod(String userId)
returns the tree model that looks up the shopping period information for the sites the user has access to- Parameters:
userId-- Returns:
-
addChildrenNodes
boolean addChildrenNodes(Object node, String userId, List<ListOptionSerialized> blankRestrictedTools, boolean onlyAccessNodes, List<String> accessAdminNodes, boolean shopping, boolean shoppingPeriodTool)
Adds children node to a node that hasn't had it's children populated. This is used to increase the efficiency of the tree so you can create the structure on the fly with ajax- Parameters:
node-userId-blankRestrictedTools-onlyAccessNodes-accessAdminNodes-shopping-shoppingPeriodTool-- Returns:
-
getEntireToolsList
List<ListOptionSerialized> getEntireToolsList()
returns a blank (unselected) list of all the tool options for restricting tools- Returns:
-
getNodeModel
NodeModel getNodeModel(String nodeId, String userId)
This will return a fully instantiated NodeModel for that user and id. It will look up it's parents nodes and instantiate them as well.- Parameters:
nodeId-userId-- Returns:
-
getCachedNode
HierarchyNodeSerialized getCachedNode(String id)
returns a HierarchyNodeSerialized node- Parameters:
id-- Returns:
-
getCachedNodes
Map<String,HierarchyNodeSerialized> getCachedNodes(String[] ids)
returns a map of HierarchyNodes- Parameters:
ids-- Returns:
-
getEntireTreePlusUserPerms
TreeModel getEntireTreePlusUserPerms(String userId)
This returns the entire tree plus any permissions set for a user- Parameters:
userId-- Returns:
-
hasShoppingPeriodAdminNodes
boolean hasShoppingPeriodAdminNodes(String userId)
Returns whether the user has any shopping period admin access- Parameters:
userId-- Returns:
-
hasDelegatedAccessNodes
boolean hasDelegatedAccessNodes(String userId)
returns whether the user has any delegated access- Parameters:
userId-- Returns:
-
hasAccessAdminNodes
boolean hasAccessAdminNodes(String userId)
returns whether the user has any "access admin" permission- Parameters:
userId-- Returns:
-
hasAllowBecomeUserPerm
boolean hasAllowBecomeUserPerm(String userId)
returns whether the user has any "allowBecomeUser" permission- Parameters:
userId-- Returns:
-
getNodesBySiteRef
Map<String,List<String>> getNodesBySiteRef(String[] siteRef, String hierarchyId)
Returns a map of {siteRef, nodeId}- Parameters:
siteRef-hierarchyId-- Returns:
-
saveHierarchyJobLastRunDate
void saveHierarchyJobLastRunDate(Date runDate, String nodeId)
Saves the date for the last time the hierarchy job ran successfully- Parameters:
runDate-nodeId-
-
getHierarchyJobLastRunDate
Date getHierarchyJobLastRunDate(String nodeId)
returns the hierarchyjoblastrundate date for the node Id and hierarchy user- Parameters:
nodeId-- Returns:
-
removeNode
void removeNode(String nodeId)
Removes this node an all permissions and children nodes- Parameters:
nodeId-
-
removeNode
void removeNode(HierarchyNode node)
Removes this node and all permissions and children nodes- Parameters:
node-
-
deleteEmptyNonSiteNodes
void deleteEmptyNonSiteNodes(String hierarchyId)
Deletes empty non sites nodes in a hierarchy (nodes that doesn't start with /site/ and has no children)- Parameters:
hierarchyId-
-
clearNodeCache
void clearNodeCache()
clears DelegatedAccess's own node cache
-
getRealmRoleDisplay
Map<String,String> getRealmRoleDisplay(boolean shopping)
returns a map of all role options and their realm/role ids separated by a ':'. For example: Instructor => !site.template.course:Instructor- Parameters:
shopping-- Returns:
-
getAccessAdminNodesForUser
Set<HierarchyNodeSerialized> getAccessAdminNodesForUser(String userId)
Returns a set of hierarchy nodes that the user has been assigned accessAdmin privileges for.- Parameters:
userId-- Returns:
-
isShoppingPeriodOpenForSite
boolean isShoppingPeriodOpenForSite(Date startDate, Date endDate, String[] nodeAccessRealmRole, String[] restrictedAuthTools, String[] restrictedPublicTools)
Call this function to determine if the shopping period is available for a set of settings- Parameters:
startDate-endDate-nodeAccessRealmRole-restrictedAuthTools-restrictedPublicTools-- Returns:
-
syncMyworkspaceToolForUser
void syncMyworkspaceToolForUser(String userId)
This will ensure the Delegated Access tool is synced with the user's MyWorkspace. Another words, if the user has no permissions in DA, then the tool will be removed from the user's My Workspace. If they are granted access somewhere, then this will add the tool to thier My Workspace this is turned on/off by a sakai.property delegatedaccess.sync.myworkspacetool- Parameters:
userId-
-
getUserAccessForSite
Map<String,AccessNode> getUserAccessForSite(String siteRef)
Returns a map of UserId -> AccessNode- Parameters:
siteRef-- Returns:
-
updateShoppingPeriodSettings
Map<String,String> updateShoppingPeriodSettings(DefaultMutableTreeNode node)
Call this method if you want to update a node and all it's children it will only update nodes that start with /site/- Parameters:
node-- Returns:
- a map of errors and the stack trace
-
getAddDAMyworkspaceJobStatus
String getAddDAMyworkspaceJobStatus()
returns the status of the job for adding delegated access tool to user's my workspace. This can be null or a string- Returns:
-
updateAddDAMyworkspaceJobStatus
void updateAddDAMyworkspaceJobStatus(String status)
removes the old status and updates it with the string passed in- Parameters:
status-
-
scheduleAddDAMyworkspaceJobStatus
void scheduleAddDAMyworkspaceJobStatus()
Schedules the AddDAMyworkspace job to run immediately
-
isUserAllowBecomeUser
boolean isUserAllowBecomeUser(String userId, String siteRef)
returns true if the user has site access and has the "allowBecomeUser" permission set for this site or any of it's parents- Parameters:
userId-siteRef-- Returns:
-
getRootNodeId
HierarchyNodeSerialized getRootNodeId()
returns the root node for DA- Returns:
-
getDirectNodes
Set<HierarchyNodeSerialized> getDirectNodes(String nodeId)
returns a set of direct children nodes for passed in node id- Parameters:
nodeId-- Returns:
-
getAccessForUser
List<AccessSearchResult> getAccessForUser(User user)
returns a list of AccessSearchResult based on the user id- Parameters:
userId-- Returns:
-
getAccessAtLevel
List<AccessSearchResult> getAccessAtLevel(List<String> nodeSelectOrder, boolean includeLowerPerms)
returns a list of results for every level that is passed in. expects a list of ordered node ids- Parameters:
nodeSelectOrder-includeLowerPerms-- Returns:
-
removeAccess
void removeAccess(String nodeId, String userId, int accessType)
This will remove access at the node id passed in. The types are: DelegatedAccessConstants.TYPE_ACCESS DelegatedAccessConstants.TYPE_ACCESS_SHOPPING_PERIOD_USER DelegatedAccessConstants.TYPE_ACCESS_ADMIN- Parameters:
nodeId-userId-accessType-
-
removeAllPermsForUser
void removeAllPermsForUser(String userId)
Removes all permissions for a user- Parameters:
userId-
-
getHierarchySearchOptions
Map<String,Set<String>> getHierarchySearchOptions(Map<String,String> hierarchySearchMap)
-
filterShoppingPeriodEditNodes
Set<String> filterShoppingPeriodEditNodes(Set<String> nodeIds)
filters out any node id that the user doesn't have permission to modify shopping period settings- Parameters:
nodeIds-- Returns:
-
-