public Object ResolveArgumentGroup(IActor resolvedActor, String[] parameters, ExecutionContextImpl executionContext) { log.Debug("resolvedActor inside resolveArgumentGroup: " + resolvedActor); if (resolvedActor == null) { if (parameters.Length != 1) { throw new SystemException("argument group expects exactly one parameter instead of " + parameters.Length); } String groupId = parameters[0]; IGroup group = null; try { group = executionContext.GetOrganisationComponent().FindGroupById(groupId); } catch (OrganisationRuntimeException e) { throw new SystemException("can't resolve group-argument with parameter " + groupId + " : " + e.Message); } return(group); } else { if (parameters.Length != 1) { throw new SystemException("argument group expects exactly one parameter (membership-type) instead of " + parameters.Length); } IUser user = null; IGroup group = null; String membershipType = parameters[0]; try { group = executionContext.GetOrganisationComponent().FindGroupByMembership(resolvedActor.Id, membershipType); } catch (InvalidCastException e) { throw new SystemException("can't resolve group-argument : a group must be calculated from a User, not a " + resolvedActor.GetType().FullName, e); } catch (OrganisationRuntimeException e) { throw new SystemException("can't resolve group-argument : can't find the hierarchy-memberschip of User " + user.Id + " and membership-type " + membershipType + " : " + e.Message, e); } return(group); } }
public Object ResolveArgumentRole(IActor resolvedActor, String[] parameters, ExecutionContextImpl executionContext) { if (parameters.Length != 1) { throw new SystemException("argument role expects exactly one parameter (role-name) instead of " + parameters.Length); } IActor actor = null; if (resolvedActor == null) { try { actor = (IActor)executionContext.GetAttribute(parameters[0]); } catch (InvalidCastException e) { throw new SystemException("argument attribute(" + parameters[0] + ") does not contain an actor : " + executionContext.GetAttribute(parameters[0]).GetType().FullName, e); } } else { String roleName = parameters[0].Trim(); try { IList users = executionContext.GetOrganisationComponent().FindUsersByGroupAndRole(resolvedActor.Id, roleName); if (users.Count < 1) { throw new SystemException("no users have role " + roleName + " for group " + resolvedActor.Id); } actor = (IUser)users[0]; // TODO : create a new group if more then one user is returned on the query... } catch (InvalidCastException e) { throw new SystemException("can't resolve role-argument : a role must be calculated from a Group, not a " + resolvedActor.GetType().FullName, e); } catch (OrganisationRuntimeException e) { throw new SystemException("can't resolve role-argument : can't find the users that perform role " + roleName + " for group " + resolvedActor.Id + " : " + e.Message); } } return(actor); }
public Object ResolveArgumentActor(IActor resolvedActor, String[] parameters, ExecutionContextImpl executionContext) { if (parameters.Length != 1) { throw new SystemException("argument actor expects exactly one (the actor-id) parameter instead of " + parameters.Length); } IActor actor = null; try { actor = executionContext.GetOrganisationComponent().FindActorById(parameters[0]); } catch (OrganisationRuntimeException e) { throw new SystemException("can't resolve actor-argument with parameter " + parameters[0], e); } return(actor); }