Search in sources :

Example 1 with ObjectType

use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.

the class ToolsUtils method serializeObject.

public static void serializeObject(Object object, Writer writer) throws JAXBException {
    if (object == null) {
        return;
    }
    Marshaller marshaller = JAXB_CONTEXT.createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_ENCODING, StandardCharsets.UTF_8.name());
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
    marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
    if (object instanceof ObjectType) {
        object = new JAXBElement(C_OBJECT, Object.class, object);
    }
    marshaller.marshal(object, writer);
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Marshaller(javax.xml.bind.Marshaller) JAXBElement(javax.xml.bind.JAXBElement)

Example 2 with ObjectType

use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.

the class PageAdminObjectDetails method saveOrPreviewPerformed.

public void saveOrPreviewPerformed(AjaxRequestTarget target, OperationResult result, boolean previewOnly) {
    boolean isAnythingChanged = processDeputyAssignments();
    ObjectWrapper<O> objectWrapper = getObjectWrapper();
    LOGGER.debug("Saving object {}", objectWrapper);
    // todo: improve, delta variable is quickfix for MID-1006
    // redirecting to user list page everytime user is created in repository
    // during user add in gui,
    // and we're not taking care about account/assignment create errors
    // (error message is still displayed)
    delta = null;
    Task task = createSimpleTask(OPERATION_SEND_TO_SUBMIT);
    ModelExecuteOptions options = getExecuteChangesOptions();
    LOGGER.debug("Using execute options {}.", new Object[] { options });
    try {
        reviveModels();
        delta = objectWrapper.getObjectDelta();
        if (objectWrapper.getOldDelta() != null) {
            delta = ObjectDelta.summarize(objectWrapper.getOldDelta(), delta);
        }
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("User delta computed from form:\n{}", new Object[] { delta.debugDump(3) });
        }
    } catch (Exception ex) {
        result.recordFatalError(getString("pageUser.message.cantCreateUser"), ex);
        LoggingUtils.logUnexpectedException(LOGGER, "Create user failed", ex);
        showResult(result);
        return;
    }
    switch(objectWrapper.getStatus()) {
        case ADDING:
            try {
                PrismObject<O> objectToAdd = delta.getObjectToAdd();
                WebComponentUtil.encryptCredentials(objectToAdd, true, getMidpointApplication());
                prepareObjectForAdd(objectToAdd);
                getPrismContext().adopt(objectToAdd, getCompileTimeClass());
                if (LOGGER.isTraceEnabled()) {
                    LOGGER.trace("Delta before add user:\n{}", new Object[] { delta.debugDump(3) });
                }
                if (!delta.isEmpty()) {
                    delta.revive(getPrismContext());
                    final Collection<ObjectDelta<? extends ObjectType>> deltas = WebComponentUtil.createDeltaCollection(delta);
                    final Collection<SimpleValidationError> validationErrors = performCustomValidation(objectToAdd, deltas);
                    if (checkValidationErrors(target, validationErrors)) {
                        return;
                    }
                    progressReporter.executeChanges(deltas, previewOnly, options, task, result, target);
                } else {
                    result.recordSuccess();
                }
            } catch (Exception ex) {
                result.recordFatalError(getString("pageFocus.message.cantCreateFocus"), ex);
                LoggingUtils.logUnexpectedException(LOGGER, "Create user failed", ex);
                showResult(result);
            }
            break;
        case MODIFYING:
            try {
                WebComponentUtil.encryptCredentials(delta, true, getMidpointApplication());
                prepareObjectDeltaForModify(delta);
                if (LOGGER.isTraceEnabled()) {
                    LOGGER.trace("Delta before modify user:\n{}", new Object[] { delta.debugDump(3) });
                }
                Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<>();
                if (!delta.isEmpty()) {
                    delta.revive(getPrismContext());
                    deltas.add(delta);
                }
                List<ObjectDelta<? extends ObjectType>> additionalDeltas = getAdditionalModifyDeltas(result);
                if (additionalDeltas != null) {
                    for (ObjectDelta additionalDelta : additionalDeltas) {
                        if (!additionalDelta.isEmpty()) {
                            additionalDelta.revive(getPrismContext());
                            deltas.add(additionalDelta);
                        }
                    }
                }
                if (delta.isEmpty() && ModelExecuteOptions.isReconcile(options)) {
                    ObjectDelta emptyDelta = ObjectDelta.createEmptyModifyDelta(getCompileTimeClass(), objectWrapper.getObject().getOid(), getPrismContext());
                    deltas.add(emptyDelta);
                    Collection<SimpleValidationError> validationErrors = performCustomValidation(null, deltas);
                    if (checkValidationErrors(target, validationErrors)) {
                        return;
                    }
                    progressReporter.executeChanges(deltas, previewOnly, options, task, result, target);
                } else if (!deltas.isEmpty()) {
                    Collection<SimpleValidationError> validationErrors = performCustomValidation(null, deltas);
                    if (checkValidationErrors(target, validationErrors)) {
                        return;
                    }
                    progressReporter.executeChanges(deltas, previewOnly, options, task, result, target);
                } else {
                    // from previous attempts (useful only if we would call finishProcessing at the end, but that's not the case now)
                    progressReporter.clearProgressPanel();
                    if (!previewOnly) {
                        if (!isAnythingChanged) {
                            result.recordWarning(getString("PageAdminObjectDetails.noChangesSave"));
                            showResult(result);
                        }
                        redirectBack();
                    } else {
                        warn(getString("PageAdminObjectDetails.noChangesPreview"));
                        target.add(getFeedbackPanel());
                    }
                }
            } catch (Exception ex) {
                if (!executeForceDelete(objectWrapper, task, options, result)) {
                    result.recordFatalError(getString("pageUser.message.cantUpdateUser"), ex);
                    LoggingUtils.logUnexpectedException(LOGGER, getString("pageUser.message.cantUpdateUser"), ex);
                } else {
                    result.recomputeStatus();
                }
                showResult(result);
            }
            break;
        // support for add/delete containers (e.g. delete credentials)
        default:
            error(getString("pageAdminFocus.message.unsupportedState", objectWrapper.getStatus()));
    }
    //		result.recomputeStatus();
    //
    //		if (!result.isInProgress()) {
    //			LOGGER.trace("Result NOT in progress, calling finishProcessing");
    //			finishProcessing(target, result, false);
    //		}
    LOGGER.trace("returning from saveOrPreviewPerformed");
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) AuthorizationException(com.evolveum.midpoint.util.exception.AuthorizationException) RestartResponseException(org.apache.wicket.RestartResponseException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) SystemException(com.evolveum.midpoint.util.exception.SystemException) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Collection(java.util.Collection) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) SimpleValidationError(com.evolveum.midpoint.web.util.validation.SimpleValidationError)

Example 3 with ObjectType

use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.

the class WorkItemPanel method initLayout.

protected void initLayout(Form mainForm, PageBase pageBase) {
    WebMarkupContainer additionalInfoColumn = new WebMarkupContainer(ID_ADDITIONAL_INFO_COLUMN);
    WebMarkupContainer historyContainer = new WebMarkupContainer(ID_HISTORY_CONTAINER);
    historyContainer.add(new ItemApprovalHistoryPanel(ID_HISTORY, new PropertyModel<>(getModel(), WorkItemDto.F_WORKFLOW_CONTEXT), UserProfileStorage.TableId.PAGE_WORK_ITEM_HISTORY_PANEL, (int) pageBase.getItemsPerPage(UserProfileStorage.TableId.PAGE_WORK_ITEM_HISTORY_PANEL)));
    final VisibleEnableBehaviour historyContainerVisible = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModelObject().hasHistory();
        }
    };
    historyContainer.add(historyContainerVisible);
    historyContainer.add(WebComponentUtil.createHelp(ID_HISTORY_HELP));
    additionalInfoColumn.add(historyContainer);
    WebMarkupContainer relatedWorkItemsContainer = new WebMarkupContainer(ID_RELATED_WORK_ITEMS_CONTAINER);
    final IModel<List<WorkItemDto>> relatedWorkItemsModel = new PropertyModel<>(getModel(), WorkItemDto.F_OTHER_WORK_ITEMS);
    final ISortableDataProvider<WorkItemDto, String> relatedWorkItemsProvider = new ListDataProvider<>(this, relatedWorkItemsModel);
    relatedWorkItemsContainer.add(new WorkItemsPanel(ID_RELATED_WORK_ITEMS, relatedWorkItemsProvider, null, 10, WorkItemsPanel.View.ITEMS_FOR_PROCESS));
    final VisibleEnableBehaviour relatedWorkItemsContainerVisible = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !relatedWorkItemsModel.getObject().isEmpty();
        }
    };
    relatedWorkItemsContainer.add(relatedWorkItemsContainerVisible);
    relatedWorkItemsContainer.add(WebComponentUtil.createHelp(ID_RELATED_WORK_ITEMS_HELP));
    additionalInfoColumn.add(relatedWorkItemsContainer);
    final WebMarkupContainer relatedWorkflowRequestsContainer = new WebMarkupContainer(ID_RELATED_REQUESTS_CONTAINER);
    final IModel<List<ProcessInstanceDto>> relatedWorkflowRequestsModel = new PropertyModel<>(getModel(), WorkItemDto.F_RELATED_WORKFLOW_REQUESTS);
    final ISortableDataProvider<ProcessInstanceDto, String> relatedWorkflowRequestsProvider = new ListDataProvider<>(this, relatedWorkflowRequestsModel);
    relatedWorkflowRequestsContainer.add(new ProcessInstancesPanel(ID_RELATED_REQUESTS, relatedWorkflowRequestsProvider, null, 10, ProcessInstancesPanel.View.TASKS_FOR_PROCESS, new PropertyModel<>(getModel(), WorkItemDto.F_PROCESS_INSTANCE_ID)));
    final VisibleEnableBehaviour relatedWorkflowRequestsContainerVisible = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !relatedWorkflowRequestsModel.getObject().isEmpty();
        }
    };
    relatedWorkflowRequestsContainer.add(relatedWorkflowRequestsContainerVisible);
    relatedWorkflowRequestsContainer.add(WebComponentUtil.createHelp(ID_RELATED_REQUESTS_HELP));
    additionalInfoColumn.add(relatedWorkflowRequestsContainer);
    final VisibleEnableBehaviour additionalInfoColumnVisible = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return historyContainerVisible.isVisible() || relatedWorkItemsContainerVisible.isVisible() || relatedWorkflowRequestsContainerVisible.isVisible();
        }
    };
    additionalInfoColumn.add(additionalInfoColumnVisible);
    add(additionalInfoColumn);
    WebMarkupContainer primaryInfoColumn = new WebMarkupContainer(ID_PRIMARY_INFO_COLUMN);
    //		primaryInfoColumn.add(new Label(ID_REQUESTED_BY, new PropertyModel(getModel(), WorkItemDto.F_REQUESTER_NAME)));
    //		primaryInfoColumn.add(new Label(ID_REQUESTED_BY_FULL_NAME, new PropertyModel(getModel(), WorkItemDto.F_REQUESTER_FULL_NAME)));
    //		primaryInfoColumn.add(new Label(ID_REQUESTED_ON, new PropertyModel(getModel(), WorkItemDto.F_STARTED_FORMATTED_FULL)));
    primaryInfoColumn.add(new Label(ID_WORK_ITEM_CREATED_ON, new PropertyModel(getModel(), WorkItemDto.F_CREATED_FORMATTED_FULL)));
    primaryInfoColumn.add(new Label(ID_WORK_ITEM_DEADLINE, new PropertyModel(getModel(), WorkItemDto.F_DEADLINE_FORMATTED_FULL)));
    primaryInfoColumn.add(new Label(ID_ORIGINALLY_ALLOCATED_TO, new PropertyModel(getModel(), WorkItemDto.F_ORIGINAL_ASSIGNEE_FULL)));
    primaryInfoColumn.add(new Label(ID_CURRENTLY_ALLOCATED_TO, new PropertyModel(getModel(), WorkItemDto.F_CURRENT_ASSIGNEES_FULL)));
    primaryInfoColumn.add(new Label(ID_CANDIDATES, new PropertyModel(getModel(), WorkItemDto.F_CANDIDATES)));
    WebMarkupContainer stageInfoContainer = new WebMarkupContainer(ID_STAGE_INFO_CONTAINER);
    primaryInfoColumn.add(stageInfoContainer);
    stageInfoContainer.add(new Label(ID_STAGE_INFO, new PropertyModel<String>(getModel(), WorkItemDto.F_STAGE_INFO)));
    stageInfoContainer.add(new VisibleBehaviour(() -> getModelObject().getStageInfo() != null));
    WebMarkupContainer escalationLevelInfoContainer = new WebMarkupContainer(ID_ESCALATION_LEVEL_INFO_CONTAINER);
    primaryInfoColumn.add(escalationLevelInfoContainer);
    escalationLevelInfoContainer.add(new Label(ID_ESCALATION_LEVEL_INFO, new PropertyModel<String>(getModel(), WorkItemDto.F_ESCALATION_LEVEL_INFO)));
    escalationLevelInfoContainer.add(new VisibleBehaviour(() -> getModelObject().getEscalationLevelInfo() != null));
    WebMarkupContainer requesterCommentContainer = new WebMarkupContainer(ID_REQUESTER_COMMENT_CONTAINER);
    requesterCommentContainer.setOutputMarkupId(true);
    primaryInfoColumn.add(requesterCommentContainer);
    requesterCommentContainer.add(new Label(ID_REQUESTER_COMMENT_MESSAGE, new PropertyModel<String>(getModel(), WorkItemDto.F_REQUESTER_COMMENT)));
    //primaryInfoColumn.add(new ScenePanel(ID_DELTAS_TO_BE_APPROVED, new PropertyModel<SceneDto>(getModel(), WorkItemDto.F_DELTAS)));
    primaryInfoColumn.add(new TaskChangesPanel(ID_DELTAS_TO_BE_APPROVED, new PropertyModel<>(getModel(), WorkItemDto.F_CHANGES)));
    primaryInfoColumn.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return additionalInfoColumnVisible.isVisible() ? "col-md-5" : "col-md-12";
        }
    }));
    add(primaryInfoColumn);
    add(new AjaxFallbackLink(ID_SHOW_REQUEST) {

        public void onClick(AjaxRequestTarget target) {
            String oid = WorkItemPanel.this.getModelObject().getTaskOid();
            if (oid != null) {
                PageParameters parameters = new PageParameters();
                parameters.add(OnePageParameterEncoder.PARAMETER, oid);
                getPageBase().navigateToNext(PageTaskEdit.class, parameters);
            }
        }
    });
    add(WebComponentUtil.createHelp(ID_SHOW_REQUEST_HELP));
    WebMarkupContainer additionalInformation = new InformationListPanel(ID_ADDITIONAL_INFORMATION, new PropertyModel<>(getModel(), WorkItemDto.F_ADDITIONAL_INFORMATION));
    add(additionalInformation);
    WorkItemDto dto = getModelObject();
    ApprovalStageDefinitionType level = WfContextUtil.getCurrentStageDefinition(dto.getWorkflowContext());
    WebMarkupContainer additionalAttribues = new WebMarkupContainer(ID_ADDITIONAL_ATTRIBUTES);
    add(additionalAttribues);
    additionalAttribues.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        public boolean isVisible() {
            return (level != null && level.getFormRef() != null && level.getFormRef().getOid() != null);
        }

        ;
    });
    if (level != null && level.getFormRef() != null && level.getFormRef().getOid() != null) {
        String formOid = level.getFormRef().getOid();
        ObjectType focus = dto.getFocus(pageBase);
        if (focus == null) {
            // TODO FIXME (this should not occur anyway)
            focus = new UserType(pageBase.getPrismContext());
        }
        Task task = pageBase.createSimpleTask(OPERATION_LOAD_CUSTOM_FORM);
        DynamicFormPanel<?> customForm = new DynamicFormPanel<>(ID_CUSTOM_FORM, focus.asPrismObject(), formOid, mainForm, task, pageBase);
        additionalAttribues.add(customForm);
    } else {
        additionalAttribues.add(new Label(ID_CUSTOM_FORM));
    }
    add(new TextArea<>(ID_APPROVER_COMMENT, new PropertyModel<String>(getModel(), WorkItemDto.F_APPROVER_COMMENT)));
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Task(com.evolveum.midpoint.task.api.Task) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) Label(org.apache.wicket.markup.html.basic.Label) AjaxFallbackLink(org.apache.wicket.ajax.markup.html.AjaxFallbackLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) TaskChangesPanel(com.evolveum.midpoint.web.page.admin.server.TaskChangesPanel) ItemApprovalHistoryPanel(com.evolveum.midpoint.web.component.wf.processes.itemApproval.ItemApprovalHistoryPanel) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ApprovalStageDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ApprovalStageDefinitionType) WorkItemDto(com.evolveum.midpoint.web.page.admin.workflow.dto.WorkItemDto) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ProcessInstanceDto(com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDto) PageTaskEdit(com.evolveum.midpoint.web.page.admin.server.PageTaskEdit) PropertyModel(org.apache.wicket.model.PropertyModel) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) AttributeModifier(org.apache.wicket.AttributeModifier) WorkItemsPanel(com.evolveum.midpoint.web.component.wf.WorkItemsPanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) DynamicFormPanel(com.evolveum.midpoint.web.component.prism.DynamicFormPanel) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 4 with ObjectType

use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.

the class AssignExecutor method execute.

@Override
public PipelineData execute(ActionExpressionType expression, PipelineData input, ExecutionContext context, OperationResult globalResult) throws ScriptExecutionException {
    boolean raw = getParamRaw(expression, input, context, globalResult);
    boolean dryRun = getParamDryRun(expression, input, context, globalResult);
    ActionParameterValueType resourceParameterValue = expressionHelper.getArgument(expression.getParameter(), PARAM_RESOURCE, false, false, NAME);
    ActionParameterValueType roleParameterValue = expressionHelper.getArgument(expression.getParameter(), PARAM_ROLE, false, false, NAME);
    Collection<ObjectReferenceType> resources;
    if (resourceParameterValue != null) {
        PipelineData data = expressionHelper.evaluateParameter(resourceParameterValue, null, input, context, globalResult);
        resources = data.getDataAsReferences(ResourceType.COMPLEX_TYPE);
    } else {
        resources = null;
    }
    Collection<ObjectReferenceType> roles;
    if (roleParameterValue != null) {
        PipelineData data = expressionHelper.evaluateParameter(roleParameterValue, null, input, context, globalResult);
        roles = data.getDataAsReferences(RoleType.COMPLEX_TYPE);
    } else {
        roles = null;
    }
    if (resources == null && roles == null) {
        throw new ScriptExecutionException("Nothing to assign: neither resource nor role specified");
    }
    for (PipelineItem item : input.getData()) {
        PrismValue value = item.getValue();
        OperationResult result = operationsHelper.createActionResult(item, this, context, globalResult);
        context.checkTaskStop();
        if (value instanceof PrismObjectValue && ((PrismObjectValue) value).asObjectable() instanceof FocusType) {
            PrismObject<? extends ObjectType> prismObject = ((PrismObjectValue) value).asPrismObject();
            ObjectType objectType = prismObject.asObjectable();
            long started = operationsHelper.recordStart(context, objectType);
            Throwable exception = null;
            try {
                operationsHelper.applyDelta(createDelta(objectType, resources, roles), operationsHelper.createExecutionOptions(raw), dryRun, context, result);
                operationsHelper.recordEnd(context, objectType, started, null);
            } catch (Throwable ex) {
                operationsHelper.recordEnd(context, objectType, started, ex);
                exception = processActionException(ex, NAME, value, context);
            }
            context.println((exception != null ? "Attempted to modify " : "Modified ") + prismObject.toString() + rawDrySuffix(raw, dryRun) + exceptionSuffix(exception));
        } else {
            //noinspection ThrowableNotThrown
            processActionException(new ScriptExecutionException("Item is not a PrismObject of FocusType"), NAME, value, context);
        }
        operationsHelper.trimAndCloneResult(result, globalResult, context);
    }
    // TODO updated objects?
    return input;
}
Also used : ScriptExecutionException(com.evolveum.midpoint.model.api.ScriptExecutionException) PipelineData(com.evolveum.midpoint.model.impl.scripting.PipelineData) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ActionParameterValueType(com.evolveum.midpoint.xml.ns._public.model.scripting_3.ActionParameterValueType) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) PipelineItem(com.evolveum.midpoint.model.api.PipelineItem) FocusType(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType)

Example 5 with ObjectType

use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.

the class PageMyPasswordQuestions method updateQuestions.

private void updateQuestions(String useroid, AjaxRequestTarget target) {
    Task task = createSimpleTask(OPERATION_SAVE_QUESTIONS);
    OperationResult result = new OperationResult(OPERATION_SAVE_QUESTIONS);
    SchemaRegistry registry = getPrismContext().getSchemaRegistry();
    SecurityQuestionAnswerType[] answerTypeList = new SecurityQuestionAnswerType[questionNumber];
    try {
        int listnum = 0;
        for (Iterator iterator = pqPanels.iterator(); iterator.hasNext(); ) {
            MyPasswordQuestionsPanel type = (MyPasswordQuestionsPanel) iterator.next();
            SecurityQuestionAnswerType answerType = new SecurityQuestionAnswerType();
            ProtectedStringType answer = new ProtectedStringType();
            answer.setClearValue(((TextField<String>) type.get(MyPasswordQuestionsPanel.F_ANSWER)).getModelObject());
            answerType.setQuestionAnswer(answer);
            //used apache's unescapeHtml method for special chars like \'
            String results = StringEscapeUtils.unescapeHtml((type.get(MyPasswordQuestionsPanel.F_QUESTION)).getDefaultModelObjectAsString());
            answerType.setQuestionIdentifier(getQuestionIdentifierFromQuestion(results));
            answerTypeList[listnum] = answerType;
            listnum++;
        }
        //if(answerTypeList.length !=)
        // fill in answerType data here
        ItemPath path = new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_SECURITY_QUESTIONS, SecurityQuestionsCredentialsType.F_QUESTION_ANSWER);
        ObjectDelta<UserType> objectDelta = ObjectDelta.createModificationReplaceContainer(UserType.class, useroid, path, getPrismContext(), answerTypeList);
        Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(objectDelta);
        getModelService().executeChanges(deltas, null, task, result);
        /*			
			System.out.println("getModel");
			 Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
			PasswordQuestionsDto dto = new PasswordQuestionsDto();
			 PrismObjectDefinition objDef =registry.findObjectDefinitionByCompileTimeClass(UserType.class);
			 Class<? extends ObjectType> type =  UserType.class;

			 final ItemPath valuePath = new ItemPath(SchemaConstantsGenerated.C_CREDENTIALS,
	                  CredentialsType.F_SECURITY_QUESTIONS, SecurityQuestionsCredentialsType.F_QUESTION_ANSWER); 
			 SecurityQuestionAnswerType secQuesAnsType= new SecurityQuestionAnswerType();
			 ProtectedStringType protStrType= new ProtectedStringType();
			 protStrType.setClearValue("deneme");
			 secQuesAnsType.setQuestionAnswer(protStrType);
			 dto.setSecurityAnswers(new ArrayList<SecurityQuestionAnswerType>());
			 dto.getSecurityAnswers().add(secQuesAnsType);

			PropertyDelta delta = PropertyDelta.createModificationReplaceProperty(valuePath, objDef, dto.getSecurityAnswers().get(0).getQuestionAnswer());
		//	PropertyDelta delta= PropertyDelta.createModifica

			 System.out.println("Update Questions3");
			deltas.add(ObjectDelta.createModifyDelta(useroid, delta, type, getPrismContext()));
			System.out.println("Update Questions4");
			getModelService().executeChanges(deltas, null, createSimpleTask(OPERATION_SAVE_QUESTIONS), result);
			System.out.println("Update Questions5");

			 */
        success(getString("message.success"));
        target.add(getFeedbackPanel());
    } catch (Exception ex) {
        error(getString("message.error"));
        target.add(getFeedbackPanel());
        ex.printStackTrace();
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) RestartResponseException(org.apache.wicket.RestartResponseException) EncryptionException(com.evolveum.midpoint.prism.crypto.EncryptionException) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Iterator(java.util.Iterator) MyPasswordQuestionsPanel(com.evolveum.midpoint.web.page.admin.home.component.MyPasswordQuestionsPanel) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) SchemaRegistry(com.evolveum.midpoint.prism.schema.SchemaRegistry) SecurityQuestionAnswerType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionAnswerType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)243 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)126 Test (org.testng.annotations.Test)97 Task (com.evolveum.midpoint.task.api.Task)82 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)79 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)78 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)68 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)55 ArrayList (java.util.ArrayList)51 Holder (javax.xml.ws.Holder)48 QName (javax.xml.namespace.QName)32 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)30 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)29 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)28 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)26 PrismObject (com.evolveum.midpoint.prism.PrismObject)25 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)25 SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)24 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)23 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)22