code: boolean migrationRequired() throws RepositoryException
     {
        Session session = service.getStorageSession();
  
        try
        {
           if (session.itemExists(storagePathOld))
           {
              return true;
           }
  
           try
           {
              Node node = (Node)session.getItem(service.getStoragePath());
              return node.isNodeType(JOS_ORGANIZATION_NODETYPE_OLD);
           }
           catch (PathNotFoundException e)
           {
              return false;
           }
        }
        finally
        {
           session.logout();
        }
     }
docs: Method to know if migration is need.
  @return true if migration is need false otherwise.
  @throws RepositoryException