Search in sources :

Example 6 with ModelPortType

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

the class Upload method main.

public static void main(String[] args) {
    try {
        Options options = new Options();
        options.addOption(OPT_HELP, "help", false, "Print this help information");
        options.addOption(OPT_FILE_TO_UPLOAD, "file", true, "File to be uploaded (XML for the moment)");
        options.addOption(OPT_DIR_TO_UPLOAD, "dir", true, "Whole directory to be uploaded (XML files only for the moment)");
        options.addOption(OPT_URL, true, "Endpoint URL (default: " + DEFAULT_ENDPOINT_URL + ")");
        options.addOption(OPT_USER, "user", true, "User name (default: " + ADM_USERNAME + ")");
        options.addOption(OPT_PASSWORD, "password", true, "Password");
        options.addOption(OPT_FILE_FOR_RESULT, "file-for-result", true, "Name of the file to write operation result into");
        options.addOption(OPT_HIDE_RESULT, "hide-result", false, "Don't display detailed operation result (default: showing if not SUCCESS)");
        options.addOption(OPT_SHOW_RESULT, "show-result", false, "Always show detailed operation result (default: showing if not SUCCESS)");
        CommandLineParser parser = new GnuParser();
        CommandLine cmdline = parser.parse(options, args);
        if (cmdline.hasOption(OPT_HELP) || (!cmdline.hasOption(OPT_FILE_TO_UPLOAD) && !cmdline.hasOption(OPT_DIR_TO_UPLOAD))) {
            HelpFormatter helpFormatter = new HelpFormatter();
            helpFormatter.printHelp("upload", options);
            System.out.println("\nNote that currently it is possible to upload only one object per file (i.e. no <objects> tag), and the " + "file must be written using fully specified XML namespaces (i.e. namespace-guessing algorithm allowing to write data " + "without namespaces is not available).");
            System.exit(-1);
        }
        System.out.println("=================================================================");
        ModelPortType modelPort = createModelPort(cmdline);
        if (cmdline.hasOption(OPT_FILE_TO_UPLOAD)) {
            uploadFile(new File(cmdline.getOptionValue(OPT_FILE_TO_UPLOAD)), cmdline, modelPort);
        }
        if (cmdline.hasOption(OPT_DIR_TO_UPLOAD)) {
            uploadDir(cmdline.getOptionValue(OPT_DIR_TO_UPLOAD), cmdline, modelPort);
        }
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(-1);
    }
    if (error) {
        System.exit(-1);
    }
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) ModelPortType(com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType) GnuParser(org.apache.commons.cli.GnuParser) CommandLineParser(org.apache.commons.cli.CommandLineParser) File(java.io.File) IOException(java.io.IOException) JAXBException(javax.xml.bind.JAXBException) FileNotFoundException(java.io.FileNotFoundException)

Example 7 with ModelPortType

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

the class Main method deleteUser.

private static void deleteUser(ModelPortType modelPort, String oid) throws FaultMessage {
    ObjectDeltaType deltaType = new ObjectDeltaType();
    deltaType.setObjectType(ModelClientUtil.getTypeQName(UserType.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) ModelExecuteOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)

Example 8 with ModelPortType

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

the class Main method listRequestableRoles.

private static Collection<RoleType> listRequestableRoles(ModelPortType modelPort) throws SAXException, IOException, FaultMessage, JAXBException {
    SearchFilterType filter = ModelClientUtil.parseSearchFilterType("<equal xmlns='http://prism.evolveum.com/xml/ns/public/query-3' xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3' >" + "<path>c:requestable</path>" + "<value>true</value>" + "</equal>");
    QueryType query = new QueryType();
    query.setFilter(filter);
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    modelPort.searchObjects(ModelClientUtil.getTypeQName(RoleType.class), query, options, objectListHolder, resultHolder);
    ObjectListType objectList = objectListHolder.value;
    return (Collection) objectList.getObject();
}
Also used : SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) Holder(javax.xml.ws.Holder) Collection(java.util.Collection) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Example 9 with ModelPortType

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

the class Main method listUsers.

private static Collection<UserType> listUsers(ModelPortType modelPort) throws SAXException, IOException, FaultMessage {
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    // let's say we want to get first 3 users, sorted alphabetically by user name
    // holds search query + paging options
    QueryType queryType = new QueryType();
    PagingType pagingType = new PagingType();
    pagingType.setMaxSize(3);
    pagingType.setOrderBy(ModelClientUtil.createItemPathType("name"));
    pagingType.setOrderDirection(OrderDirectionType.ASCENDING);
    queryType.setPaging(pagingType);
    modelPort.searchObjects(ModelClientUtil.getTypeQName(UserType.class), queryType, 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) PagingType(com.evolveum.prism.xml.ns._public.query_3.PagingType) Collection(java.util.Collection) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Example 10 with ModelPortType

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

the class Main method createRole.

private static String createRole(ModelPortType modelPort, RoleType roleType) throws FaultMessage {
    ObjectDeltaType deltaType = new ObjectDeltaType();
    deltaType.setObjectType(ModelClientUtil.getTypeQName(RoleType.class));
    deltaType.setChangeType(ChangeTypeType.ADD);
    deltaType.setObjectToAdd(roleType);
    ObjectDeltaListType deltaListType = new ObjectDeltaListType();
    deltaListType.getDelta().add(deltaType);
    ObjectDeltaOperationListType operationListType = modelPort.executeChanges(deltaListType, null);
    return ModelClientUtil.getOidFromDeltaOperationList(operationListType, deltaType);
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) ObjectDeltaOperationListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)

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