@Test public void testUserCredentials() throws Exception{ Migrator migrator = createMigrator(); PrismContext prismContext = PrismTestUtil.getPrismContext(); PrismObject<UserType> oldUser = prismContext.parseObject(new File(TEST_DIR + "/user-migrate-credentials.xml")); PrismObject<UserType> newUser = migrator.migrate(oldUser); UserType newUserType = newUser.asObjectable(); assertNull("Credentials in migrated object must be null.", newUserType.getCredentials()); assertNotNull("Migrated user must contain assignment.", newUserType.getAssignment()); assertEquals("Migrated user must contain 1 assignment.", newUserType.getAssignment().size(), 1); AssignmentType superUserRole = newUserType.getAssignment().get(0); assertNotNull("Target ref in the user's assignment must not be null.", superUserRole.getTargetRef()); assertEquals(superUserRole.getTargetRef().getOid(), SystemObjectsType.ROLE_SUPERUSER.value()); }
public <I extends ObjectType, O extends ObjectType> PrismObject<O> migrate(PrismObject<I> original) { Class<I> origType = original.getCompileTimeClass(); if (ObjectTemplateType.class.isAssignableFrom(origType)) { PrismObject<ObjectTemplateType> out = migrateObjectTemplate((PrismObject<ObjectTemplateType>) original); return (PrismObject<O>) out; } if (ResourceType.class.isAssignableFrom(origType)) { PrismObject<ResourceType> out = migrateResource((PrismObject<ResourceType>) original); return (PrismObject<O>) out; } if (FocusType.class.isAssignableFrom(origType)) { PrismObject<FocusType> out = migrateFocus((PrismObject<FocusType>) original); original = (PrismObject<I>) out; } if (UserType.class.isAssignableFrom(origType)) { PrismObject<UserType> out = migrateUser((PrismObject<UserType>) original); return (PrismObject<O>) out; } return (PrismObject<O>) original; }
Migrator { public <I extends ObjectType, O extends ObjectType> PrismObject<O> migrate(PrismObject<I> original) { Class<I> origType = original.getCompileTimeClass(); if (ObjectTemplateType.class.isAssignableFrom(origType)) { PrismObject<ObjectTemplateType> out = migrateObjectTemplate((PrismObject<ObjectTemplateType>) original); return (PrismObject<O>) out; } if (ResourceType.class.isAssignableFrom(origType)) { PrismObject<ResourceType> out = migrateResource((PrismObject<ResourceType>) original); return (PrismObject<O>) out; } if (FocusType.class.isAssignableFrom(origType)) { PrismObject<FocusType> out = migrateFocus((PrismObject<FocusType>) original); original = (PrismObject<I>) out; } if (UserType.class.isAssignableFrom(origType)) { PrismObject<UserType> out = migrateUser((PrismObject<UserType>) original); return (PrismObject<O>) out; } return (PrismObject<O>) original; } }
Migrator { public <I extends ObjectType, O extends ObjectType> PrismObject<O> migrate(PrismObject<I> original) { Class<I> origType = original.getCompileTimeClass(); if (ObjectTemplateType.class.isAssignableFrom(origType)) { PrismObject<ObjectTemplateType> out = migrateObjectTemplate((PrismObject<ObjectTemplateType>) original); return (PrismObject<O>) out; } if (ResourceType.class.isAssignableFrom(origType)) { PrismObject<ResourceType> out = migrateResource((PrismObject<ResourceType>) original); return (PrismObject<O>) out; } if (FocusType.class.isAssignableFrom(origType)) { PrismObject<FocusType> out = migrateFocus((PrismObject<FocusType>) original); original = (PrismObject<I>) out; } if (UserType.class.isAssignableFrom(origType)) { PrismObject<UserType> out = migrateUser((PrismObject<UserType>) original); return (PrismObject<O>) out; } return (PrismObject<O>) original; }  }
Migrator { public <I extends ObjectType, O extends ObjectType> PrismObject<O> migrate(PrismObject<I> original) { Class<I> origType = original.getCompileTimeClass(); if (ObjectTemplateType.class.isAssignableFrom(origType)) { PrismObject<ObjectTemplateType> out = migrateObjectTemplate((PrismObject<ObjectTemplateType>) original); return (PrismObject<O>) out; } if (ResourceType.class.isAssignableFrom(origType)) { PrismObject<ResourceType> out = migrateResource((PrismObject<ResourceType>) original); return (PrismObject<O>) out; } if (FocusType.class.isAssignableFrom(origType)) { PrismObject<FocusType> out = migrateFocus((PrismObject<FocusType>) original); original = (PrismObject<I>) out; } if (UserType.class.isAssignableFrom(origType)) { PrismObject<UserType> out = migrateUser((PrismObject<UserType>) original); return (PrismObject<O>) out; } return (PrismObject<O>) original; }  PrismObject<O> migrate(PrismObject<I> original); }
Migrator { public <I extends ObjectType, O extends ObjectType> PrismObject<O> migrate(PrismObject<I> original) { Class<I> origType = original.getCompileTimeClass(); if (ObjectTemplateType.class.isAssignableFrom(origType)) { PrismObject<ObjectTemplateType> out = migrateObjectTemplate((PrismObject<ObjectTemplateType>) original); return (PrismObject<O>) out; } if (ResourceType.class.isAssignableFrom(origType)) { PrismObject<ResourceType> out = migrateResource((PrismObject<ResourceType>) original); return (PrismObject<O>) out; } if (FocusType.class.isAssignableFrom(origType)) { PrismObject<FocusType> out = migrateFocus((PrismObject<FocusType>) original); original = (PrismObject<I>) out; } if (UserType.class.isAssignableFrom(origType)) { PrismObject<UserType> out = migrateUser((PrismObject<UserType>) original); return (PrismObject<O>) out; } return (PrismObject<O>) original; }  PrismObject<O> migrate(PrismObject<I> original);  }