code: public void internalRemoveWorkspace(final String workspaceName) throws RepositoryException
     {
        SecurityHelper.validateSecurityPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
  
        final WorkspaceContainer workspaceContainer = repositoryContainer.getWorkspaceContainer(workspaceName);
        try
        {
           SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
           {
              public Void run()
              {
                 workspaceContainer.stop();
                 return null;
              }
           });
        }
        catch (Exception e)
        {
           throw new RepositoryException(e);
        }
        SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
        {
           public Void run()
           {
              repositoryContainer.unregisterComponent(workspaceName);
              return null;
           }
        });
  
        config.getWorkspaceEntries().remove(repositoryContainer.getWorkspaceEntry(workspaceName));
  
        for (WorkspaceManagingListener listener : workspaceListeners)
        {
           listener.onWorkspaceRemove(workspaceName);
        }
     }
docs: Internal Remove Workspace.
  
  @param workspaceName workspace name
  @throws RepositoryException error of remove