code: public void finish() throws CmsException {
  
          m_finished = true;
          m_requiresCleanup = false;
          CmsProject project = getProject();
          CmsObject projectCms = OpenCms.initCmsObject(m_adminCms);
          projectCms.getRequestContext().setCurrentProject(project);
          if (m_configuration.isAutoPublish()) {
              // we don't necessarily publish with the user who has the locks on the resources, so we need to steal the locks
              List<CmsResource> projectResources = projectCms.readProjectView(project.getUuid(), CmsResource.STATE_KEEP);
              for (CmsResource projectResource : projectResources) {
                  CmsLock lock = projectCms.getLock(projectResource);
                  if (!lock.isUnlocked() && !lock.isLockableBy(projectCms.getRequestContext().getCurrentUser())) {
                      projectCms.changeLock(projectResource);
                  }
              }
              OpenCms.getPublishManager().publishProject(
                  projectCms,
                  new CmsLogReport(Locale.ENGLISH, CmsUgcSession.class));
          } else {
              // try to unlock everything - we don't need this in case of auto-publish, since publishing already unlocks the resources
              projectCms.unlockProject(project.getUuid());
          }
  
      }
docs: Finishes the session and publishes the changed resources if necessary.<p>
  
  @throws CmsException if something goes wrong