Search in sources :

Example 86 with PolyStringType

use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.

the class JAXBUtilTest method testUnmarshallerIso88592.

@Test
public void testUnmarshallerIso88592() throws JAXBException, SchemaException, FileNotFoundException {
    // GIVEN
    UserType user = JaxbTestUtil.getInstance().unmarshalElement(new File("src/test/resources/util/user-8859-2.xml"), UserType.class).getValue();
    // WHEN
    PolyStringType fullname = user.getFullName();
    // THEN
    assertTrue("National characters incorrectly decoded", "Jožko Nováčik".equals(fullname.getOrig()));
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) File(java.io.File) Test(org.testng.annotations.Test)

Example 87 with PolyStringType

use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.

the class JAXBUtilTest method testUnmarshallerStringIso88592.

@Test
public void testUnmarshallerStringIso88592() throws JAXBException, SchemaException {
    // GIVEN
    String s = "<?xml version='1.0' encoding='iso-8859-2'?> " + "<user oid='deadbeef-c001-f00d-1111-222233330001'" + "      xmlns:t='http://prism.evolveum.com/xml/ns/public/types-3'" + "      xmlns='http://midpoint.evolveum.com/xml/ns/public/common/common-3'>" + "	<fullName><t:orig>Jožko Nováčik</t:orig><t:norm>jozko novacik</t:norm></fullName>" + "</user>";
    UserType user = JaxbTestUtil.getInstance().unmarshalElement(s, UserType.class).getValue();
    // WHEN
    PolyStringType fullname = user.getFullName();
    // THEN
    assertTrue("Diacritics correctly decoded", "Jožko Nováčik".equals(fullname.getOrig()));
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 88 with PolyStringType

use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.

the class JAXBUtilTest method testUnmarshallerStringUtf8.

@Test
public void testUnmarshallerStringUtf8() throws JAXBException, SchemaException {
    // GIVEN
    String s = "<?xml version='1.0' encoding='utf-8'?> " + "<user oid='deadbeef-c001-f00d-1111-222233330001'" + "      xmlns:t='http://prism.evolveum.com/xml/ns/public/types-3'" + "      xmlns='http://midpoint.evolveum.com/xml/ns/public/common/common-3'>" + "	<fullName><t:orig>Jožko Nováčik</t:orig><t:norm>jozko novacik</t:norm></fullName>" + "</user>";
    UserType user = JaxbTestUtil.getInstance().unmarshalElement(s, UserType.class).getValue();
    // WHEN
    PolyStringType fullname = user.getFullName();
    // THEN
    assertTrue("Diacritics correctly decoded", "Jožko Nováčik".equals(fullname.getOrig()));
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 89 with PolyStringType

use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.

the class ModelClientUtil method createPolyStringType.

public static PolyStringType createPolyStringType(String string, Document doc) {
    PolyStringType polyStringType = new PolyStringType();
    polyStringType.getContent().add(string);
    return polyStringType;
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType)

Example 90 with PolyStringType

use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.

the class ImportAccountsFromResourceTaskHandler method launch.

/**
     * Launch an import. Calling this method will start import in a new
     * thread, possibly on a different node.
     */
public void launch(ResourceType resource, QName objectclass, Task task, OperationResult parentResult) {
    LOGGER.info("Launching import from resource {} as asynchronous task", ObjectTypeUtil.toShortString(resource));
    OperationResult result = parentResult.createSubresult(ImportAccountsFromResourceTaskHandler.class.getName() + ".launch");
    result.addParam("resource", resource);
    result.addParam("objectclass", objectclass);
    // TODO
    // Set handler URI so we will be called back
    task.setHandlerUri(HANDLER_URI);
    // Readable task name
    PolyStringType polyString = new PolyStringType("Import from resource " + resource.getName());
    task.setName(polyString);
    // Set reference to the resource
    task.setObjectRef(ObjectTypeUtil.createObjectRef(resource));
    try {
        PrismProperty<?> objectclassProp = objectclassPropertyDefinition.instantiate();
        objectclassProp.setRealValue(objectclass);
        task.setExtensionProperty(objectclassProp);
        // just to be sure (if the task was already persistent)
        task.savePendingModifications(result);
    //          task.modify(modifications, result);
    } catch (ObjectNotFoundException e) {
        LOGGER.error("Task object not found, expecting it to exist (task {})", task, e);
        result.recordFatalError("Task object not found", e);
        throw new IllegalStateException("Task object not found, expecting it to exist", e);
    } catch (ObjectAlreadyExistsException e) {
        LOGGER.error("Task object wasn't updated (task {})", task, e);
        result.recordFatalError("Task object wasn't updated", e);
        throw new IllegalStateException("Task object wasn't updated", e);
    } catch (SchemaException e) {
        LOGGER.error("Error dealing with schema (task {})", task, e);
        result.recordFatalError("Error dealing with schema", e);
        throw new IllegalStateException("Error dealing with schema", e);
    }
    // Switch task to background. This will start new thread and call
    // the run(task) method.
    // Note: the thread may be actually started on a different node
    taskManager.switchToBackground(task, result);
    result.setBackgroundTaskOid(task.getOid());
    result.computeStatus("Import launch failed");
    LOGGER.trace("Import from resource {} switched to background, control thread returning with task {}", ObjectTypeUtil.toShortString(resource), task);
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)

Aggregations

PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)94 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)28 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)26 Test (org.testng.annotations.Test)23 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)20 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)14 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)12 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)12 QName (javax.xml.namespace.QName)11 Task (com.evolveum.midpoint.task.api.Task)10 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)10 File (java.io.File)10 PrismObject (com.evolveum.midpoint.prism.PrismObject)9 OrgType (com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)8 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)7 ArrayList (java.util.ArrayList)7 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)5 AbstractInternalModelIntegrationTest (com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)4 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)4 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)4