Search in sources :

Example 11 with ModelPortType

use of com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType in project midpoint by Evolveum.

the class Main method deleteTask.

private static void deleteTask(ModelPortType modelPort, String oid) throws FaultMessage {
    ObjectDeltaType deltaType = new ObjectDeltaType();
    deltaType.setObjectType(ModelClientUtil.getTypeQName(TaskType.class));
    deltaType.setChangeType(ChangeTypeType.DELETE);
    deltaType.setOid(oid);
    ObjectDeltaListType deltaListType = new ObjectDeltaListType();
    deltaListType.getDelta().add(deltaType);
    ModelExecuteOptionsType executeOptionsType = new ModelExecuteOptionsType();
    executeOptionsType.setRaw(true);
    modelPort.executeChanges(deltaListType, executeOptionsType);
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) ModelExecuteOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)

Example 12 with ModelPortType

use of com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType in project midpoint by Evolveum.

the class Main method createUserGuybrush.

private static String createUserGuybrush(ModelPortType modelPort, 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 = ModelClientUtil.createRoleAssignment(role.getOid());
        user.getAssignment().add(roleAssignment);
    }
    return createUser(modelPort, 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 13 with ModelPortType

use of com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType in project midpoint by Evolveum.

the class Main method getConfiguration.

private static SystemConfigurationType getConfiguration(ModelPortType modelPort) throws FaultMessage {
    Holder<ObjectType> objectHolder = new Holder<ObjectType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    modelPort.getObject(ModelClientUtil.getTypeQName(SystemConfigurationType.class), SystemObjectsType.SYSTEM_CONFIGURATION.value(), options, objectHolder, resultHolder);
    return (SystemConfigurationType) objectHolder.value;
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) Holder(javax.xml.ws.Holder) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Example 14 with ModelPortType

use of com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType in project midpoint by Evolveum.

the class Main method createModelPort.

public static ModelPortType createModelPort(String[] args) {
    String endpointUrl = DEFAULT_ENDPOINT_URL;
    if (args.length > 0) {
        endpointUrl = args[0];
    }
    System.out.println("Endpoint URL: " + endpointUrl);
    // uncomment this if you want to use Fiddler or any other proxy
    //ProxySelector.setDefault(new MyProxySelector("127.0.0.1", 8888));
    ModelService modelService = new ModelService();
    ModelPortType modelPort = modelService.getModelPort();
    BindingProvider bp = (BindingProvider) modelPort;
    Map<String, Object> requestContext = bp.getRequestContext();
    requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointUrl);
    org.apache.cxf.endpoint.Client client = ClientProxy.getClient(modelPort);
    org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();
    Map<String, Object> outProps = new HashMap<String, Object>();
    outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
    outProps.put(WSHandlerConstants.USER, ADM_USERNAME);
    outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
    outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, ClientPasswordHandler.class.getName());
    WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
    cxfEndpoint.getOutInterceptors().add(wssOut);
    // enable the following to get client-side logging of outgoing requests and incoming responses
    cxfEndpoint.getOutInterceptors().add(new LoggingOutInterceptor());
    cxfEndpoint.getInInterceptors().add(new LoggingInInterceptor());
    return modelPort;
}
Also used : HashMap(java.util.HashMap) ModelPortType(com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType) BindingProvider(javax.xml.ws.BindingProvider) ModelService(com.evolveum.midpoint.xml.ns._public.model.model_3.ModelService) LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) WSS4JOutInterceptor(org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor)

Example 15 with ModelPortType

use of com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType in project midpoint by Evolveum.

the class Main method listResources.

private static Collection<ResourceType> listResources(ModelPortType modelPort) throws SAXException, IOException, FaultMessage {
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    modelPort.searchObjects(ModelClientUtil.getTypeQName(ResourceType.class), null, options, objectListHolder, resultHolder);
    ObjectListType objectList = objectListHolder.value;
    return (Collection) objectList.getObject();
}
Also used : OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) Holder(javax.xml.ws.Holder) Collection(java.util.Collection) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Aggregations

ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)14 ObjectDeltaListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)13 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)13 ModelPortType (com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType)13 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)11 SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)10 Holder (javax.xml.ws.Holder)10 ObjectDeltaOperationListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType)8 ObjectListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)7 ModelExecuteOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType)7 RoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType)7 ObjectDeltaOperationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType)6 ModelService (com.evolveum.midpoint.xml.ns._public.model.model_3.ModelService)6 BindingProvider (javax.xml.ws.BindingProvider)6 WSS4JOutInterceptor (org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor)6 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)5 ItemDeltaType (com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)5 JAXBException (javax.xml.bind.JAXBException)5 FaultMessage (com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage)4 QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)4