예제 #1
0
        private static TaskType[] listTasks(modelPortType modelPort)
        {
            // Let's say we want to retrieve tasks' next scheduled time (because this may be a costly operation if
            // JDBC based quartz scheduler is used, the fetching of this attribute has to be explicitly requested)
            SelectorQualifiedGetOptionType getNextScheduledTimeOption = new SelectorQualifiedGetOptionType();

            // prepare a selector (described by path) + options (saying to retrieve that attribute)
            ObjectSelectorType selector = new ObjectSelectorType();

            selector.path = createItemPathType("nextRunStartTimestamp");
            getNextScheduledTimeOption.selector = selector;

            GetOperationOptionsType selectorOptions = new GetOperationOptionsType();

            selectorOptions.retrieve           = RetrieveOptionType.include;
            selectorOptions.retrieveSpecified  = true;
            getNextScheduledTimeOption.options = selectorOptions;

            SelectorQualifiedGetOptionType[] operationOptions = new SelectorQualifiedGetOptionType[] { getNextScheduledTimeOption };

            searchObjects         request  = new searchObjects(TASK_TYPE, null, operationOptions);
            searchObjectsResponse response = modelPort.searchObjects(request);

            ObjectListType  objectList = response.objectList;
            List <TaskType> tasks      = new List <TaskType>();

            foreach (ObjectType1 object1 in response.objectList.@object)
            {
                tasks.Add((TaskType)object1);
            }
            return(tasks.ToArray());
        }
예제 #2
0
        private static ObjectType1[] listObjects(modelPortType modelPort, XmlQualifiedName type)
        {
            searchObjects         request  = new searchObjects(type, null, null);
            searchObjectsResponse response = modelPort.searchObjects(request);

            ObjectListType objectList = response.objectList;

            ObjectType1[] objects = objectList.@object;
            return(objects);
        }
예제 #3
0
        private static RoleType searchRoleByName(modelPortType modelPort, String roleName)
        {
            QueryType query = new QueryType();

            query.filter = createNameFilter(roleName);

            searchObjects         request  = new searchObjects(ROLE_TYPE, query, null);
            searchObjectsResponse response = modelPort.searchObjects(request);

            return((RoleType)getOneObject(response, roleName));
        }
예제 #4
0
        private static UserType searchUserByName(modelPortType modelPort, String username)
        {
            QueryType query = new QueryType();

            query.filter = createNameFilter(username);

            searchObjects         request  = new searchObjects(USER_TYPE, query, null);
            searchObjectsResponse response = modelPort.searchObjects(request);

            return((UserType)getOneObject(response, username));
        }
예제 #5
0
        private static ObjectType1[] listRequestableRoles(modelPortType modelPort)
        {
            SearchFilterType filter = createRequestableFilter();
            QueryType        query  = new QueryType();

            query.filter = filter;

            searchObjects         request  = new searchObjects(ROLE_TYPE, query, null);
            searchObjectsResponse response = modelPort.searchObjects(request);

            ObjectListType objectList = response.objectList;

            ObjectType1[] objects = objectList.@object;
            return(objects);
        }
예제 #6
0
        private static ObjectType1[] listObjectsRestrictedAndSorted(modelPortType modelPort, XmlQualifiedName type)
        {
            // let's say we want to get first 3 users, sorted alphabetically by user name

            QueryType  queryType  = new QueryType();        // holds search query + paging options
            PagingType pagingType = new PagingType();

            pagingType.maxSize = 3;
            ItemPathType orderBy = createItemPathType("name");

            pagingType.orderBy        = orderBy;
            pagingType.orderDirection = OrderDirectionType.ascending;

            queryType.paging = pagingType;

            searchObjects         request  = new searchObjects(type, queryType, null);
            searchObjectsResponse response = modelPort.searchObjects(request);

            ObjectListType objectList = response.objectList;

            ObjectType1[] objects = objectList.@object;
            return(objects);
        }
예제 #7
0
        private static ObjectType1[] listRequestableRoles(modelPortType modelPort)
        {
            SearchFilterType filter = createRequestableFilter();
            QueryType query = new QueryType();
            query.filter = filter;
            
            searchObjects request = new searchObjects(ROLE_TYPE, query, null);
            searchObjectsResponse response = modelPort.searchObjects(request);

            ObjectListType objectList = response.objectList;
            ObjectType1[] objects = objectList.@object;
            return objects;
        }
예제 #8
0
   	    private static RoleType searchRoleByName(modelPortType modelPort, String roleName) 
        {
            QueryType query = new QueryType();
            query.filter = createNameFilter(roleName);

            searchObjects request = new searchObjects(ROLE_TYPE, query, null);
            searchObjectsResponse response = modelPort.searchObjects(request);
            return (RoleType) getOneObject(response, roleName);
    	}
예제 #9
0
        private static UserType searchUserByName(modelPortType modelPort, String username)
        {
            QueryType query = new QueryType();
            query.filter = createNameFilter(username);

            searchObjects request = new searchObjects(USER_TYPE, query, null);
            searchObjectsResponse response = modelPort.searchObjects(request);
            return (UserType) getOneObject(response, username);
        }
예제 #10
0
        private static TaskType[] listTasks(modelPortType modelPort) 
        {
            // Let's say we want to retrieve tasks' next scheduled time (because this may be a costly operation if
            // JDBC based quartz scheduler is used, the fetching of this attribute has to be explicitly requested)
            SelectorQualifiedGetOptionType getNextScheduledTimeOption = new SelectorQualifiedGetOptionType();

            // prepare a selector (described by path) + options (saying to retrieve that attribute)
            ObjectSelectorType selector = new ObjectSelectorType();
            selector.path = createItemPathType("nextRunStartTimestamp");
            getNextScheduledTimeOption.selector = selector;
        
            GetOperationOptionsType selectorOptions = new GetOperationOptionsType();
            selectorOptions.retrieve = RetrieveOptionType.include;
            selectorOptions.retrieveSpecified = true;
            getNextScheduledTimeOption.options = selectorOptions;

            SelectorQualifiedGetOptionType[] operationOptions = new SelectorQualifiedGetOptionType[] { getNextScheduledTimeOption };

            searchObjects request = new searchObjects(TASK_TYPE, null, operationOptions);
            searchObjectsResponse response = modelPort.searchObjects(request);

            ObjectListType objectList = response.objectList;
            List<TaskType> tasks = new List<TaskType>();
            foreach (ObjectType1 object1 in response.objectList.@object)
            {
                tasks.Add((TaskType)object1);
            }
            return tasks.ToArray();
        }
예제 #11
0
        private static ObjectType1[] listObjectsRestrictedAndSorted(modelPortType modelPort, XmlQualifiedName type)
        {
            // let's say we want to get first 3 users, sorted alphabetically by user name

            QueryType queryType = new QueryType();          // holds search query + paging options
            PagingType pagingType = new PagingType();
            pagingType.maxSize = 3;
            ItemPathType orderBy = createItemPathType("name");
            pagingType.orderBy = orderBy;
            pagingType.orderDirection = OrderDirectionType.ascending;

            queryType.paging = pagingType;

            searchObjects request = new searchObjects(type, queryType, null);
            searchObjectsResponse response = modelPort.searchObjects(request);

            ObjectListType objectList = response.objectList;
            ObjectType1[] objects = objectList.@object;
            return objects;
        }
예제 #12
0
        private static ObjectType1[] listObjects(modelPortType modelPort, XmlQualifiedName type)
        {
            searchObjects request = new searchObjects(type, null, null);
            searchObjectsResponse response = modelPort.searchObjects(request);

            ObjectListType objectList = response.objectList;
            ObjectType1[] objects = objectList.@object;
            return objects;
        }
        /// <summary>
        /// Searches for the given user using the given Midpoint model port.
        /// Returns the UserType object for the user if they exist.
        /// </summary>
        /// <param name="modelPort">The model port used to run search Midpoint.</param>
        /// <param name="username">The username to search for.</param>
        /// <returns>The UserType object for the requested user, or null if not found.</returns>
        public static UserType searchUserByName(modelPortType modelPort, string username)
        {
            // WARNING: in a real case make sure that the username is properly escaped before putting it in XML
            XmlElement filter = parseElement(
                            "<equal xmlns='" + SEARCHUSER_NS + "' xmlns:c='" + NS_COMMON + "' >" +
                                "<path>c:name</path>" +
                                "<value>" + username + "</value>" +
                            "</equal>"
            );
            QueryType query = new QueryType();
            // Set filter value - webservices name is apparently 'Any'?
            query.Any = filter;
            // Create an empty array since it can't be uninitialised
            ObjectOperationOptionsType[] options = new ObjectOperationOptionsType[0];

            searchObjects request = new searchObjects(getTypeUri(new UserType()), query, options);
            searchObjectsResponse response = modelPort.searchObjects(request);

            ObjectListType objectList = response.objectList;
            ObjectType[] objects = objectList.@object;

            if (objects != null)
            {
                switch (objects.Length)
                {
                    case 0:
                        return null;
                        break;
                    case 1:
                        return (UserType)objects[0];
                        break;
                    default:
                        throw new ArgumentException("Expected to find a single user with username '" + username + "' but found " + objects.Length + " users instead");
                }
            }
            else
            {
                return null;
            }
        }