code: private void migrateProfiles() throws Exception
     {
        Session session = service.getStorageSession();
        try
        {
           if (session.itemExists(usersStorageOld))
           {
              NodeIterator iterator = ((ExtendedNode)session.getItem(usersStorageOld)).getNodesLazily();
              UserProfileHandlerImpl uph = ((UserProfileHandlerImpl)service.getUserProfileHandler());
              while (iterator.hasNext())
              {
                 Node oldUserNode = iterator.nextNode();
                 uph.migrateProfile(oldUserNode);
              }
           }
        }
        finally
        {
           session.logout();
        }
  
     }
docs: Method for profiles migration.
  @throws Exception