Search in sources :

Example 1 with PrismObject

use of com.evolveum.midpoint.prism.PrismObject in project midpoint by Evolveum.

the class ResourceCredentialsEditor method createPasswordPolicyList.

private List<ObjectReferenceType> createPasswordPolicyList() {
    passPolicyMap.clear();
    OperationResult result = new OperationResult(OPERATION_LOAD_PASSWORD_POLICIES);
    Task task = getPageBase().createSimpleTask(OPERATION_LOAD_PASSWORD_POLICIES);
    List<PrismObject<ValuePolicyType>> policies = null;
    List<ObjectReferenceType> references = new ArrayList<>();
    try {
        policies = getPageBase().getModelService().searchObjects(ValuePolicyType.class, new ObjectQuery(), null, task, result);
        result.recomputeStatus();
    } catch (CommonException | RuntimeException e) {
        result.recordFatalError("Couldn't load password policies.", e);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load password policies", e);
    }
    if (policies != null) {
        ObjectReferenceType ref;
        for (PrismObject<ValuePolicyType> policy : policies) {
            passPolicyMap.put(policy.getOid(), WebComponentUtil.getName(policy));
            ref = new ObjectReferenceType();
            ref.setType(ValuePolicyType.COMPLEX_TYPE);
            ref.setOid(policy.getOid());
            references.add(ref);
        }
    }
    return references;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) PrismObject(com.evolveum.midpoint.prism.PrismObject) CommonException(com.evolveum.midpoint.util.exception.CommonException)

Example 2 with PrismObject

use of com.evolveum.midpoint.prism.PrismObject in project midpoint by Evolveum.

the class PageSecurityQuestions method loadPageModel.

private PasswordQuestionsDto loadPageModel() {
    LOGGER.debug("Loading user.");
    final String userOid = getPageParameters().get(SESSION_ATTRIBUTE_POID).toString();
    PrismObject<UserType> user = runPrivileged(new Producer<PrismObject<UserType>>() {

        @Override
        public PrismObject<UserType> run() {
            Task task = createAnonymousTask(OPERATION_LOAD_USER);
            OperationResult subResult = task.getResult();
            try {
                Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch());
                return getModelService().getObject(UserType.class, userOid, options, task, subResult);
            } catch (ObjectNotFoundException | SchemaException | SecurityViolationException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
                LOGGER.error("Error getting user {}: {}", userOid, e.getMessage(), e);
                // we do not want to provide any information to the attacker.
                return null;
            }
        }
    });
    principalModel.setObject(user);
    PasswordQuestionsDto dto = new PasswordQuestionsDto();
    dto.setSecurityAnswers(createUsersSecurityQuestionsList(user));
    return dto;
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) Collection(java.util.Collection) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) PasswordQuestionsDto(com.evolveum.midpoint.web.page.admin.home.dto.PasswordQuestionsDto)

Example 3 with PrismObject

use of com.evolveum.midpoint.prism.PrismObject in project midpoint by Evolveum.

the class OrgTreeProvider method getChildren.

@Override
public Iterator<? extends SelectableBean<OrgType>> getChildren(SelectableBean<OrgType> node) {
    //    	getAvailableData().clear();
    LOGGER.debug("Loading children for {}", new Object[] { node });
    Iterator<SelectableBean<OrgType>> iterator = null;
    ObjectQuery query = QueryBuilder.queryFor(ObjectType.class, getPageBase().getPrismContext()).isDirectChildOf(// TODO what if getValue==null
    node.getValue().getOid()).asc(ObjectType.F_NAME).build();
    OperationResult result = new OperationResult(LOAD_ORG_UNITS);
    try {
        //            Collection<SelectorOptions<GetOperationOptions>> options = WebModelServiceUtils.createOptionsForParentOrgRefs();
        Collection<SelectorOptions<GetOperationOptions>> options = null;
        Task task = getPageBase().createSimpleTask(LOAD_ORG_UNITS);
        List<PrismObject<OrgType>> units = getModelService().searchObjects(OrgType.class, query, options, task, result);
        LOGGER.debug("Found {} units.", units.size());
        List<SelectableBean<OrgType>> list = new ArrayList<SelectableBean<OrgType>>();
        for (PrismObject<OrgType> unit : units) {
            SelectableBean<OrgType> selectable = createObjectWrapper(node, unit);
            list.add(selectable);
        //                if (getAvailableData().contains(selectable)){
        //                	getAvailableData().remove(selectable);
        //                } 
        //                getAvailableData().add(selectable);
        }
        getAvailableData().addAll(list);
        //            Collections.sort(list);
        iterator = list.iterator();
    } catch (Exception ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load children", ex);
        result.recordFatalError("Unable to load org unit", ex);
    } finally {
        result.computeStatus();
    }
    if (WebComponentUtil.showResultInPage(result)) {
        getPageBase().showResult(result);
        throw new RestartResponseException(PageOrgTree.class);
    }
    if (iterator == null) {
        iterator = new ArrayList<SelectableBean<OrgType>>().iterator();
    }
    LOGGER.debug("Finished loading children.");
    return iterator;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) RestartResponseException(org.apache.wicket.RestartResponseException) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) PrismObject(com.evolveum.midpoint.prism.PrismObject) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) RestartResponseException(org.apache.wicket.RestartResponseException) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean)

Example 4 with PrismObject

use of com.evolveum.midpoint.prism.PrismObject in project midpoint by Evolveum.

the class TestObjectQuery method testMatchEqualNonEmptyAgainstEmptyItem.

@Test
public void testMatchEqualNonEmptyAgainstEmptyItem() throws Exception {
    PrismObject user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML);
    // jack has no locality
    ObjectFilter filter = QueryBuilder.queryFor(UserType.class, PrismTestUtil.getPrismContext()).item(UserType.F_LOCALITY).eq("some").buildFilter();
    boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry);
    AssertJUnit.assertFalse("filter matches object, but it should not", match);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) UserType(com.evolveum.midpoint.prism.foo.UserType) Test(org.testng.annotations.Test)

Example 5 with PrismObject

use of com.evolveum.midpoint.prism.PrismObject in project midpoint by Evolveum.

the class TestObjectQuery method testMatchAndFilter.

@Test
public void testMatchAndFilter() throws Exception {
    PrismObject user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML);
    ObjectFilter filter = QueryBuilder.queryFor(UserType.class, PrismTestUtil.getPrismContext()).item(UserType.F_GIVEN_NAME).eq("Jack").matchingCaseIgnore().and().item(UserType.F_FULL_NAME).contains("arr").buildFilter();
    boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry);
    AssertJUnit.assertTrue("filter does not match object", match);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) UserType(com.evolveum.midpoint.prism.foo.UserType) Test(org.testng.annotations.Test)

Aggregations

PrismObject (com.evolveum.midpoint.prism.PrismObject)696 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)484 Test (org.testng.annotations.Test)317 Task (com.evolveum.midpoint.task.api.Task)307 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)288 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)147 ArrayList (java.util.ArrayList)113 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)92 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)72 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)72 SearchResultMetadata (com.evolveum.midpoint.schema.SearchResultMetadata)68 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)61 List (java.util.List)61 QName (javax.xml.namespace.QName)60 SystemException (com.evolveum.midpoint.util.exception.SystemException)46 File (java.io.File)46 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)44 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)42 ObjectPaging (com.evolveum.midpoint.prism.query.ObjectPaging)40 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)38