Search in sources :

Example 41 with RoleType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.

the class Main method searchRoleByName.

private static RoleType searchRoleByName(ModelPortType modelPort, String roleName) throws SAXException, IOException, FaultMessage, JAXBException {
    // WARNING: in a real case make sure that the role name is properly escaped before putting it in XML
    SearchFilterType filter = ModelClientUtil.parseSearchFilterType("<equal xmlns='http://prism.evolveum.com/xml/ns/public/query-3' xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3' >" + "<path>c:name</path>" + "<value>" + roleName + "</value>" + "</equal>");
    QueryType query = new QueryType();
    query.setFilter(filter);
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    modelPort.searchObjects(ModelClientUtil.getTypeQName(RoleType.class), query, options, objectListHolder, resultHolder);
    ObjectListType objectList = objectListHolder.value;
    List<ObjectType> objects = objectList.getObject();
    if (objects.isEmpty()) {
        return null;
    }
    if (objects.size() == 1) {
        return (RoleType) objects.get(0);
    }
    throw new IllegalStateException("Expected to find a single role with name '" + roleName + "' but found " + objects.size() + " users instead");
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) Holder(javax.xml.ws.Holder) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Example 42 with RoleType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.

the class AbstractTestForExchangeConnector method createUserGuybrush.

protected String createUserGuybrush(RoleType role) throws FaultMessage {
    Document doc = ModelClientUtil.getDocumnent();
    UserType user = new UserType();
    user.setName(ModelClientUtil.createPolyStringType("guybrush", doc));
    user.setFullName(ModelClientUtil.createPolyStringType("Guybrush Threepwood", doc));
    user.setGivenName(ModelClientUtil.createPolyStringType("Guybrush", doc));
    user.setFamilyName(ModelClientUtil.createPolyStringType("Threepwood", doc));
    user.setEmailAddress("guybrush@meleeisland.net");
    user.getOrganization().add(ModelClientUtil.createPolyStringType("Pirate Brethren International", doc));
    user.getOrganizationalUnit().add(ModelClientUtil.createPolyStringType("Pirate Wannabes", doc));
    user.setCredentials(ModelClientUtil.createPasswordCredentials("IwannaBEaPIRATE"));
    if (role != null) {
        // create user with a role assignment
        AssignmentType roleAssignment = createRoleAssignment(role.getOid());
        user.getAssignment().add(roleAssignment);
    }
    return createUser(user);
}
Also used : AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) Document(org.w3c.dom.Document) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 43 with RoleType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.

the class PageRole method prepareObjectForAdd.

@Override
protected void prepareObjectForAdd(PrismObject<RoleType> focus) throws SchemaException {
    // TODO policyConstraints
    super.prepareObjectForAdd(focus);
    getObjectWrapper().getObjectOld().findOrCreateContainer(RoleType.F_POLICY_CONSTRAINTS);
    ObjectDelta<RoleType> delta = getObjectWrapper().getObjectOld().diff(getObjectWrapper().getObject());
    ContainerDelta<PolicyConstraintsType> policyConstraintsDelta = delta.findContainerDelta(new ItemPath(RoleType.F_POLICY_CONSTRAINTS));
    if (policyConstraintsDelta != null) {
        policyConstraintsDelta.applyTo(focus);
        return;
    }
    ContainerDelta maxAssignes = delta.findContainerDelta(new ItemPath(RoleType.F_POLICY_CONSTRAINTS, PolicyConstraintsType.F_MAX_ASSIGNEES));
    if (maxAssignes != null) {
        maxAssignes.applyTo(focus);
    }
    ContainerDelta minAssignes = delta.findContainerDelta(new ItemPath(RoleType.F_POLICY_CONSTRAINTS, PolicyConstraintsType.F_MIN_ASSIGNEES));
    if (minAssignes != null) {
        minAssignes.applyTo(focus);
    }
}
Also used : PolicyConstraintsType(com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintsType) ContainerDelta(com.evolveum.midpoint.prism.delta.ContainerDelta) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 44 with RoleType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.

the class PageRole method prepareObjectDeltaForModify.

@Override
protected void prepareObjectDeltaForModify(ObjectDelta<RoleType> focusDelta) throws SchemaException {
    super.prepareObjectDeltaForModify(focusDelta);
    ObjectDelta<RoleType> delta = getObjectWrapper().getObjectOld().diff(getObjectWrapper().getObject());
    ContainerDelta<PolicyConstraintsType> policyConstraintsDelta = delta.findContainerDelta(new ItemPath(RoleType.F_POLICY_CONSTRAINTS));
    if (policyConstraintsDelta != null) {
        focusDelta.addModification(policyConstraintsDelta);
        return;
    }
    ContainerDelta maxAssignes = delta.findContainerDelta(new ItemPath(RoleType.F_POLICY_CONSTRAINTS, PolicyConstraintsType.F_MAX_ASSIGNEES));
    if (maxAssignes != null) {
        focusDelta.addModification(maxAssignes);
    }
    ContainerDelta minAssignes = delta.findContainerDelta(new ItemPath(RoleType.F_POLICY_CONSTRAINTS, PolicyConstraintsType.F_MIN_ASSIGNEES));
    if (minAssignes != null) {
        focusDelta.addModification(minAssignes);
    }
}
Also used : PolicyConstraintsType(com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintsType) ContainerDelta(com.evolveum.midpoint.prism.delta.ContainerDelta) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 45 with RoleType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.

the class PageRoles method initColumns.

private List<IColumn<SelectableBean<RoleType>, String>> initColumns() {
    List<IColumn<SelectableBean<RoleType>, String>> columns = new ArrayList<>();
    IColumn column = new PropertyColumn(createStringResource("OrgType.displayName"), "value.displayName");
    columns.add(column);
    column = new PropertyColumn(createStringResource("OrgType.identifier"), "value.identifier");
    columns.add(column);
    column = new PropertyColumn(createStringResource("ObjectType.description"), "value.description");
    columns.add(column);
    return columns;
}
Also used : IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) ArrayList(java.util.ArrayList)

Aggregations

RoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType)67 Test (org.testng.annotations.Test)44 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)39 Task (com.evolveum.midpoint.task.api.Task)34 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)18 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)15 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)13 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)9 NameItemPathSegment (com.evolveum.midpoint.prism.path.NameItemPathSegment)8 AbstractRoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType)8 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)8 QName (javax.xml.namespace.QName)7 IdItemPathSegment (com.evolveum.midpoint.prism.path.IdItemPathSegment)6 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)6 PrismObject (com.evolveum.midpoint.prism.PrismObject)5 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)5 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)5 File (java.io.File)5 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)4 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)4