Search in sources :

Example 26 with PrismObject

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

the class PageTaskAdd method createResourceList.

private List<TaskAddResourcesDto> createResourceList() {
    OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCES);
    Task task = createSimpleTask(OPERATION_LOAD_RESOURCES);
    List<PrismObject<ResourceType>> resources = null;
    List<TaskAddResourcesDto> resourceList = new ArrayList<TaskAddResourcesDto>();
    try {
        resources = getModelService().searchObjects(ResourceType.class, new ObjectQuery(), null, task, result);
        result.recomputeStatus();
    } catch (Exception ex) {
        result.recordFatalError("Couldn't get resource list.", ex);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't get resource list", ex);
    }
    // }
    if (resources != null) {
        ResourceType item = null;
        for (PrismObject<ResourceType> resource : resources) {
            item = resource.asObjectable();
            resourceList.add(new TaskAddResourcesDto(item.getOid(), WebComponentUtil.getOrigStringFromPoly(item.getName())));
        }
    }
    return resourceList;
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) TaskAddResourcesDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskAddResourcesDto) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SystemException(com.evolveum.midpoint.util.exception.SystemException)

Example 27 with PrismObject

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

the class PageTaskEdit method initLayout.

protected void initLayout() {
    refreshModel = new Model(new AutoRefreshDto());
    refreshModel.getObject().setInterval(getRefreshInterval());
    IModel<PrismObject<TaskType>> prismObjectModel = new AbstractReadOnlyModel<PrismObject<TaskType>>() {

        @Override
        public PrismObject<TaskType> getObject() {
            return objectWrapperModel.getObject().getObject();
        }
    };
    final TaskSummaryPanel summaryPanel = new TaskSummaryPanel(ID_SUMMARY_PANEL, prismObjectModel, refreshModel, this);
    summaryPanel.setOutputMarkupId(true);
    add(summaryPanel);
    mainPanel = new TaskMainPanel(ID_MAIN_PANEL, objectWrapperModel, taskDtoModel, showAdvancedFeaturesModel, this);
    mainPanel.setOutputMarkupId(true);
    add(mainPanel);
    summaryPanel.getRefreshPanel().startRefreshing(this, null);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) PrismObject(com.evolveum.midpoint.prism.PrismObject) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) AutoRefreshDto(com.evolveum.midpoint.web.component.refresh.AutoRefreshDto)

Example 28 with PrismObject

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

the class RoleMemberPanel method createTenantList.

private List<OrgType> createTenantList() {
    ObjectQuery query = QueryBuilder.queryFor(OrgType.class, getPrismContext()).item(OrgType.F_TENANT).eq(true).build();
    List<PrismObject<OrgType>> orgs = WebModelServiceUtils.searchObjects(OrgType.class, query, new OperationResult("Tenant search"), getPageBase());
    List<OrgType> orgTypes = new ArrayList<>();
    for (PrismObject<OrgType> org : orgs) {
        orgTypes.add(org.asObjectable());
    }
    return orgTypes;
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 29 with PrismObject

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

the class NodeDtoProvider method internalIterator.

@Override
public Iterator<? extends NodeDto> internalIterator(long first, long count) {
    Collection<String> selectedOids = getSelectedOids();
    getAvailableData().clear();
    OperationResult result = new OperationResult(OPERATION_LIST_NODES);
    Task task = getTaskManager().createTaskInstance(OPERATION_LIST_NODES);
    try {
        ObjectPaging paging = createPaging(first, count);
        ObjectQuery query = getQuery();
        if (query == null) {
            query = new ObjectQuery();
        }
        query.setPaging(paging);
        List<PrismObject<NodeType>> nodes = getModel().searchObjects(NodeType.class, query, null, task, result);
        for (PrismObject<NodeType> node : nodes) {
            getAvailableData().add(createNodeDto(node));
        }
        result.recordSuccess();
    } catch (Exception ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Unhandled exception when listing nodes", ex);
        result.recordFatalError("Couldn't list nodes.", ex);
    }
    setSelectedOids(selectedOids);
    return getAvailableData().iterator();
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) NodeType(com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 30 with PrismObject

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

the class InitialDataImport method init.

public void init() throws SchemaException {
    LOGGER.info("Starting initial object import (if necessary).");
    OperationResult mainResult = new OperationResult(OPERATION_INITIAL_OBJECTS_IMPORT);
    Task task = taskManager.createTaskInstance(OPERATION_INITIAL_OBJECTS_IMPORT);
    task.setChannel(SchemaConstants.CHANNEL_GUI_INIT_URI);
    int count = 0;
    int errors = 0;
    File[] files = getInitialImportObjects();
    LOGGER.debug("Files to be imported: {}.", Arrays.toString(files));
    // We need to provide a fake Spring security context here.
    // We have to fake it because we do not have anything in the repository yet. And to get
    // something to the repository we need a context. Chicken and egg. So we fake the egg.
    SecurityContext securityContext = SecurityContextHolder.getContext();
    UserType userAdministrator = new UserType();
    prismContext.adopt(userAdministrator);
    userAdministrator.setName(new PolyStringType(new PolyString("initAdmin", "initAdmin")));
    MidPointPrincipal principal = new MidPointPrincipal(userAdministrator);
    AuthorizationType superAutzType = new AuthorizationType();
    prismContext.adopt(superAutzType, RoleType.class, new ItemPath(RoleType.F_AUTHORIZATION));
    superAutzType.getAction().add(AuthorizationConstants.AUTZ_ALL_URL);
    Authorization superAutz = new Authorization(superAutzType);
    Collection<Authorization> authorities = principal.getAuthorities();
    authorities.add(superAutz);
    Authentication authentication = new PreAuthenticatedAuthenticationToken(principal, null);
    securityContext.setAuthentication(authentication);
    for (File file : files) {
        try {
            LOGGER.debug("Considering initial import of file {}.", file.getName());
            PrismObject object = prismContext.parseObject(file);
            if (ReportType.class.equals(object.getCompileTimeClass())) {
                ReportTypeUtil.applyDefinition(object, prismContext);
            }
            Boolean importObject = importObject(object, file, task, mainResult);
            if (importObject == null) {
                continue;
            }
            if (importObject) {
                count++;
            } else {
                errors++;
            }
        } catch (Exception ex) {
            LoggingUtils.logUnexpectedException(LOGGER, "Couldn't import file {}", ex, file.getName());
            mainResult.recordFatalError("Couldn't import file '" + file.getName() + "'", ex);
        }
    }
    securityContext.setAuthentication(null);
    mainResult.recomputeStatus("Couldn't import objects.");
    LOGGER.info("Initial object import finished ({} objects imported, {} errors)", count, errors);
    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace("Initialization status:\n" + mainResult.debugDump());
    }
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) Task(com.evolveum.midpoint.task.api.Task) PreAuthenticatedAuthenticationToken(org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) URISyntaxException(java.net.URISyntaxException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) IOException(java.io.IOException) Authorization(com.evolveum.midpoint.security.api.Authorization) PrismObject(com.evolveum.midpoint.prism.PrismObject) Authentication(org.springframework.security.core.Authentication) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) SecurityContext(org.springframework.security.core.context.SecurityContext) AuthorizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.AuthorizationType) File(java.io.File) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) MidPointPrincipal(com.evolveum.midpoint.security.api.MidPointPrincipal) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

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