Search in sources :

Example 1 with MidPointApplication

use of com.evolveum.midpoint.web.security.MidPointApplication in project midpoint by Evolveum.

the class ReportCreateHandlerDto method getReportParams.

public String getReportParams() {
    PrismObject<TaskType> taskObject = taskDto.getTaskType().asPrismObject();
    PrismContainer<ReportParameterType> container = taskObject.findContainer(new ItemPath(TaskType.F_EXTENSION, ReportConstants.REPORT_PARAMS_PROPERTY_NAME));
    if (container == null || container.isEmpty()) {
        return null;
    }
    PrismContainerValue<ReportParameterType> pcv = container.getValue();
    PrismContext prismContext = ((MidPointApplication) Application.get()).getPrismContext();
    try {
        return WebXmlUtil.stripNamespaceDeclarations(prismContext.xmlSerializer().serialize(pcv, ReportConstants.REPORT_PARAMS_PROPERTY_NAME));
    } catch (SchemaException e) {
        throw new SystemException("Couldn't serialize report parameters: " + e.getMessage(), e);
    }
}
Also used : MidPointApplication(com.evolveum.midpoint.web.security.MidPointApplication) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SystemException(com.evolveum.midpoint.util.exception.SystemException) PrismContext(com.evolveum.midpoint.prism.PrismContext) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) ReportParameterType(com.evolveum.midpoint.xml.ns._public.common.common_3.ReportParameterType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 2 with MidPointApplication

use of com.evolveum.midpoint.web.security.MidPointApplication in project midpoint by Evolveum.

the class ScriptExecutionHandlerDto method getScript.

public String getScript() {
    ExecuteScriptType script = taskDto.getExtensionPropertyRealValue(SchemaConstants.SE_EXECUTE_SCRIPT, ExecuteScriptType.class);
    if (script == null) {
        return null;
    }
    PrismContext prismContext = ((MidPointApplication) Application.get()).getPrismContext();
    try {
        return WebXmlUtil.stripNamespaceDeclarations(prismContext.xmlSerializer().serializeAnyData(script, SchemaConstants.SE_EXECUTE_SCRIPT));
    } catch (SchemaException e) {
        throw new SystemException("Couldn't serialize script: " + e.getMessage(), e);
    }
}
Also used : MidPointApplication(com.evolveum.midpoint.web.security.MidPointApplication) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExecuteScriptType(com.evolveum.midpoint.xml.ns._public.model.scripting_3.ExecuteScriptType) SystemException(com.evolveum.midpoint.util.exception.SystemException) PrismContext(com.evolveum.midpoint.prism.PrismContext)

Example 3 with MidPointApplication

use of com.evolveum.midpoint.web.security.MidPointApplication in project midpoint by Evolveum.

the class QueryBasedHandlerDto method getObjectQuery.

public String getObjectQuery() {
    QueryType query = taskDto.getExtensionPropertyRealValue(SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY, QueryType.class);
    if (query == null) {
        return null;
    }
    PrismContext prismContext = ((MidPointApplication) Application.get()).getPrismContext();
    try {
        return WebXmlUtil.stripNamespaceDeclarations(prismContext.xmlSerializer().serializeAnyData(query, SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY));
    } catch (SchemaException e) {
        throw new SystemException("Couldn't serialize query: " + e.getMessage(), e);
    }
}
Also used : MidPointApplication(com.evolveum.midpoint.web.security.MidPointApplication) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SystemException(com.evolveum.midpoint.util.exception.SystemException) PrismContext(com.evolveum.midpoint.prism.PrismContext) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType)

Example 4 with MidPointApplication

use of com.evolveum.midpoint.web.security.MidPointApplication in project midpoint by Evolveum.

the class TaskDto method getObjectQuery.

public String getObjectQuery() {
    QueryType queryType = getExtensionPropertyRealValue(SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY, QueryType.class);
    PrismContext prismContext = ((MidPointApplication) Application.get()).getPrismContext();
    try {
        return prismContext.xmlSerializer().serializeAnyData(queryType, SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY);
    } catch (SchemaException e) {
        throw new SystemException("Couldn't serialize query: " + e.getMessage(), e);
    }
}
Also used : MidPointApplication(com.evolveum.midpoint.web.security.MidPointApplication) PrismContext(com.evolveum.midpoint.prism.PrismContext) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType)

Example 5 with MidPointApplication

use of com.evolveum.midpoint.web.security.MidPointApplication 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)

Aggregations

MidPointApplication (com.evolveum.midpoint.web.security.MidPointApplication)10 PrismContext (com.evolveum.midpoint.prism.PrismContext)6 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)4 SystemException (com.evolveum.midpoint.util.exception.SystemException)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 WebApplicationConfiguration (com.evolveum.midpoint.web.security.WebApplicationConfiguration)3 File (org.apache.wicket.util.file.File)3 QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)2 FileInputStream (java.io.FileInputStream)2 InputStreamReader (java.io.InputStreamReader)2 ReaderInputStream (org.apache.commons.io.input.ReaderInputStream)2 RestartResponseException (org.apache.wicket.RestartResponseException)2 FileUpload (org.apache.wicket.markup.html.form.upload.FileUpload)2 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 Task (com.evolveum.midpoint.task.api.Task)1 DescriptorLoader (com.evolveum.midpoint.web.application.DescriptorLoader)1 AjaxDownloadBehaviorFromFile (com.evolveum.midpoint.web.component.AjaxDownloadBehaviorFromFile)1 ObjectViewDto (com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto)1 ReportDto (com.evolveum.midpoint.web.page.admin.reports.dto.ReportDto)1