code: public void importWorkspace(String wsName, InputStream xmlStream) throws RepositoryException, IOException
     {
        createWorkspace(wsName);
        SessionImpl sysSession = getSystemSession(wsName);
  
        try
        {
           Map<String, Object> context = new HashMap<String, Object>();
           context.put(ContentImporter.RESPECT_PROPERTY_DEFINITIONS_CONSTRAINTS, true);
  
           NodeData rootData = ((NodeData)((NodeImpl)sysSession.getRootNode()).getData());
           TransactionableDataManager dataManager = sysSession.getTransientNodesManager().getTransactManager();
           
           cleanWorkspace(dataManager);
  
           StreamImporter importer =
              new ExportImportFactory().getWorkspaceImporter(rootData, ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW,
                 dataManager, dataManager, sysSession.getWorkspace().getNodeTypesHolder(),
                 sysSession.getLocationFactory(), sysSession.getValueFactory(), getNamespaceRegistry(),
                 sysSession.getAccessManager(), sysSession.getUserState(), context, this, wsName);
           importer.importStream(xmlStream);
        }
        finally
        {
           sysSession.logout();
        }
     }
docs: {@inheritDoc}