Search in sources :

Example 1 with ObjectViewDto

use of com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto in project midpoint by Evolveum.

the class MultipleAssignmentSelectorPanel method createTenantOrgDto.

private AssignmentEditorDto createTenantOrgDto() {
    //doesn't matter the type
    AssignmentEditorDtoType aType = AssignmentEditorDtoType.ROLE;
    ObjectReferenceType targetRef = new ObjectReferenceType();
    targetRef.setOid("");
    targetRef.setType(aType.getQname());
    targetRef.setTargetName(new PolyStringType(""));
    AssignmentType assignment = new AssignmentType();
    assignment.setTargetRef(targetRef);
    AssignmentEditorDto tenantOrgDto = new AssignmentEditorDto(UserDtoStatus.ADD, assignment, getPageBase());
    if (tenantEditorObject != null && tenantEditorObject.size() > 0) {
        OrgType org = tenantEditorObject.get(0);
        ObjectViewDto<OrgType> dto = new ObjectViewDto(org.getOid(), tenantEditorObject.get(0).getName() == null ? "" : tenantEditorObject.get(0).getName().toString());
        dto.setType(OrgType.class);
        tenantOrgDto.setTenantRef(dto);
    }
    if (orgEditorObject != null && orgEditorObject.size() > 0) {
        OrgType org = orgEditorObject.get(0);
        ObjectViewDto<OrgType> dto = new ObjectViewDto(org.getOid(), orgEditorObject.get(0).getName() == null ? "" : orgEditorObject.get(0).getName().toString());
        dto.setType(OrgType.class);
        tenantOrgDto.setOrgRef(dto);
    }
    return tenantOrgDto;
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) ObjectViewDto(com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto)

Example 2 with ObjectViewDto

use of com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto in project midpoint by Evolveum.

the class CertDefinitionDto method loadOwnerReference.

private ObjectViewDto loadOwnerReference(ObjectReferenceType ref) {
    ObjectViewDto dto;
    if (ref != null) {
        if (ref.getTargetName() != null) {
            dto = new ObjectViewDto(ref.getOid(), WebComponentUtil.getOrigStringFromPoly(ref.getTargetName()));
            dto.setType(UserType.class);
            return dto;
        } else {
            dto = new ObjectViewDto(ObjectViewDto.BAD_OID);
            dto.setType(UserType.class);
            return dto;
        }
    } else {
        dto = new ObjectViewDto();
        dto.setType(UserType.class);
        return dto;
    }
}
Also used : ObjectViewDto(com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto)

Example 3 with ObjectViewDto

use of com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto in project midpoint by Evolveum.

the class PageDebugView method loadObject.

private ObjectViewDto loadObject() {
    StringValue objectOid = getPageParameters().get(PARAM_OBJECT_ID);
    if (objectOid == null || StringUtils.isEmpty(objectOid.toString())) {
        getSession().error(getString("pageDebugView.message.oidNotDefined"));
        throw new RestartResponseException(PageDebugList.class);
    }
    Task task = createSimpleTask(OPERATION_LOAD_OBJECT);
    //todo is this result != null ?
    OperationResult result = task.getResult();
    ObjectViewDto dto = null;
    try {
        MidPointApplication application = PageDebugView.this.getMidpointApplication();
        GetOperationOptions rootOptions = GetOperationOptions.createRaw();
        rootOptions.setResolveNames(true);
        rootOptions.setTolerateRawData(true);
        Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(rootOptions);
        // FIXME: ObjectType.class will not work well here. We need more specific type.
        //todo on page debug list create page params, put there oid and class for object type and send that to this page....read it here
        Class type = ObjectType.class;
        StringValue objectType = getPageParameters().get(PARAM_OBJECT_TYPE);
        if (objectType != null && StringUtils.isNotBlank(objectType.toString())) {
            type = getPrismContext().getSchemaRegistry().determineCompileTimeClass(new QName(SchemaConstantsGenerated.NS_COMMON, objectType.toString()));
        }
        // TODO make this configurable (or at least do not show campaign cases in production)
        if (UserType.class.isAssignableFrom(type)) {
            options.add(SelectorOptions.create(UserType.F_JPEG_PHOTO, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE)));
        }
        if (LookupTableType.class.isAssignableFrom(type)) {
            options.add(SelectorOptions.create(LookupTableType.F_ROW, GetOperationOptions.createRetrieve(new RelationalValueSearchQuery(ObjectPaging.createPaging(PrismConstants.T_ID, OrderDirection.ASCENDING)))));
        }
        if (AccessCertificationCampaignType.class.isAssignableFrom(type)) {
            options.add(SelectorOptions.create(AccessCertificationCampaignType.F_CASE, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE)));
        }
        PrismObject<ObjectType> object = getModelService().getObject(type, objectOid.toString(), options, task, result);
        PrismContext context = application.getPrismContext();
        String lex = context.serializerFor(dataLanguage).serialize(object);
        dto = new ObjectViewDto(object.getOid(), WebComponentUtil.getName(object), object, lex);
        result.recomputeStatus();
    } catch (Exception ex) {
        result.recordFatalError("Couldn't load object.", ex);
    }
    if (dto == null) {
        showResult(result);
        throw new RestartResponseException(PageDebugList.class);
    }
    showResult(result, false);
    if (!WebComponentUtil.isSuccessOrHandledErrorOrWarning(result)) {
        showResult(result, false);
        throw new RestartResponseException(PageDebugList.class);
    }
    return dto;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) QName(javax.xml.namespace.QName) PrismContext(com.evolveum.midpoint.prism.PrismContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) RestartResponseException(org.apache.wicket.RestartResponseException) MidPointApplication(com.evolveum.midpoint.web.security.MidPointApplication) RestartResponseException(org.apache.wicket.RestartResponseException) StringValue(org.apache.wicket.util.string.StringValue) ObjectViewDto(com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto)

Example 4 with ObjectViewDto

use of com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto in project midpoint by Evolveum.

the class PageDebugList method loadResources.

private List<ObjectViewDto> loadResources() {
    List<ObjectViewDto> objects = new ArrayList<>();
    try {
        OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCES);
        List<PrismObject<ResourceType>> list = WebModelServiceUtils.searchObjects(ResourceType.class, null, SelectorOptions.createCollection(GetOperationOptions.createRaw()), result, this, null);
        for (PrismObject obj : list) {
            ObjectViewDto dto = new ObjectViewDto(obj.getOid(), WebComponentUtil.getName(obj));
            objects.add(dto);
        }
    } catch (Exception ex) {
    // todo implement error handling
    }
    Collections.sort(objects, (o1, o2) -> String.CASE_INSENSITIVE_ORDER.compare(o1.getName(), o2.getName()));
    return objects;
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectViewDto(com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Example 5 with ObjectViewDto

use of com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto in project midpoint by Evolveum.

the class SystemConfigPanel method initLayout.

protected void initLayout() {
    ChooseTypePanel<ValuePolicyType> passPolicyChoosePanel = new ChooseTypePanel<ValuePolicyType>(ID_GLOBAL_PASSWORD_POLICY_CHOOSER, new PropertyModel<ObjectViewDto<ValuePolicyType>>(getModel(), SystemConfigurationDto.F_PASSWORD_POLICY));
    ChooseTypePanel<SecurityPolicyType> securityPolicyChoosePanel = new ChooseTypePanel<SecurityPolicyType>(ID_GLOBAL_SECURITY_POLICY_CHOOSER, new PropertyModel<ObjectViewDto<SecurityPolicyType>>(getModel(), SystemConfigurationDto.F_SECURITY_POLICY));
    add(passPolicyChoosePanel);
    add(securityPolicyChoosePanel);
    ObjectPolicyConfigurationEditor objectPolicyEditor = new ObjectPolicyConfigurationEditor(ID_OBJECT_POLICY_EDITOR, new PropertyModel<List<ObjectPolicyConfigurationTypeDto>>(getModel(), SystemConfigurationDto.F_OBJECT_POLICY_LIST));
    add(objectPolicyEditor);
    DropDownChoice<AEPlevel> aepLevel = new DropDownChoice<>(ID_GLOBAL_AEP, new PropertyModel<AEPlevel>(getModel(), SystemConfigurationDto.F_AEP_LEVEL), WebComponentUtil.createReadonlyModelFromEnum(AEPlevel.class), new EnumChoiceRenderer<AEPlevel>(SystemConfigPanel.this));
    aepLevel.setOutputMarkupId(true);
    if (aepLevel.getModel().getObject() == null) {
        aepLevel.getModel().setObject(null);
    }
    aepLevel.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    add(aepLevel);
    TextField<String> auditRecordsField = WebComponentUtil.createAjaxTextField(ID_CLEANUP_AUDIT_RECORDS, new PropertyModel<String>(getModel(), SystemConfigurationDto.F_AUDIT_CLEANUP));
    TextField<String> closedTasksField = WebComponentUtil.createAjaxTextField(ID_CLEANUP_CLOSED_TASKS, new PropertyModel<String>(getModel(), SystemConfigurationDto.F_TASK_CLEANUP));
    add(auditRecordsField);
    add(closedTasksField);
    createTooltip(ID_CLEANUP_AUDIT_RECORDS_TOOLTIP);
    createTooltip(ID_CLEANUP_CLOSED_TASKS_TOOLTIP);
    CheckBox experimentalCodeCheck = WebComponentUtil.createAjaxCheckBox(ID_EXPERIMENTAL_CODE_CHECKBOX, new PropertyModel<Boolean>(getModel(), SystemConfigurationDto.F_ENABLE_EXPERIMENTAL_CODE));
    add(experimentalCodeCheck);
}
Also used : ValuePolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType) AEPlevel(com.evolveum.midpoint.web.page.admin.configuration.dto.AEPlevel) SecurityPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) CheckBox(org.apache.wicket.markup.html.form.CheckBox) List(java.util.List) ObjectViewDto(com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto) ObjectPolicyConfigurationEditor(com.evolveum.midpoint.web.component.ObjectPolicyConfigurationEditor)

Aggregations

ObjectViewDto (com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto)9 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)5 Task (com.evolveum.midpoint.task.api.Task)4 RestartResponseException (org.apache.wicket.RestartResponseException)4 PrismContext (com.evolveum.midpoint.prism.PrismContext)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)2 MidPointApplication (com.evolveum.midpoint.web.security.MidPointApplication)2 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)2 StringValue (org.apache.wicket.util.string.StringValue)2 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)1 GetOperationOptionsBuilder (com.evolveum.midpoint.schema.GetOperationOptionsBuilder)1 Holder (com.evolveum.midpoint.util.Holder)1 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)1 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 ObjectPolicyConfigurationEditor (com.evolveum.midpoint.web.component.ObjectPolicyConfigurationEditor)1 AEPlevel (com.evolveum.midpoint.web.page.admin.configuration.dto.AEPlevel)1 SecurityPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType)1 ValuePolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType)1