code: protected void removeRepositoryLocally(String repositoryName, boolean forceRemove) throws RepositoryCreationException
     {
        try
        {
           // extract list of all datasources
           ManageableRepository repositorty = repositoryService.getRepository(repositoryName);
           Set<String> datasources = extractDataSourceNames(repositorty.getConfiguration(), false);
  
           // close all opened sessions
           for (String workspaceName : repositorty.getWorkspaceNames())
           {
              WorkspaceContainerFacade wc = repositorty.getWorkspaceContainer(workspaceName);
              SessionRegistry sessionRegistry = (SessionRegistry)wc.getComponent(SessionRegistry.class);
  
              sessionRegistry.closeSessions(workspaceName);
           }
  
           // remove repository from configuration
           repositoryService.removeRepository(repositoryName, forceRemove);
           repositoryService.getConfig().retain();
           
           // unbind datasource and close connections
           for (String dsName : datasources)
           {
              try
              {
                 // we suppose that lookup() method returns the same instance of datasource by the same name
                 DataSource ds = (DataSource)initialContextInitializer.getInitialContext().lookup(dsName);
                 initialContextInitializer.getInitialContextBinder().unbind(dsName);
  
                 // close datasource
                 if (ds instanceof CloseableDataSource)
                 {
                    ((CloseableDataSource)ds).close();
                 }
              }
              catch (NamingException e)
              {
                 LOG.error("Can't unbind datasource " + dsName, e);
              }
              catch (FileNotFoundException e)
              {
                 LOG.error("Can't unbind datasource " + dsName, e);
              }
              catch (XMLStreamException e)
              {
                 LOG.error("Can't unbind datasource " + dsName, e);
              }
           }
        }
        catch (RepositoryException e)
        {
           throw new RepositoryCreationException("Can't remove repository", e);
        }
        catch (RepositoryConfigurationException e)
        {
           throw new RepositoryCreationException("Can't remove repository", e);
        }
     }
docs: Remove repository locally.
  
  @param repositoryName
  the repository name
  @throws RepositoryCreationException