/**
  * draft a page or site
  *
  * @param document to draft
  * @throws NoDraftException if no drafted with a problem
  */
 public static void draft(DocumentModel document) throws NoDraftException {
   try {
     if (LabsSiteConstants.State.PUBLISH.getState().equals(document.getCurrentLifeCycleState())) {
       LabsPublisher publisherAdapter = Tools.getAdapter(LabsPublisher.class, document, null);
       publisherAdapter.draft();
     }
   } catch (ClientException e) {
     throw new NoDraftException(LabsPublishService.NOT_DRAFT);
   }
 }
 /**
  * publish a page or site
  *
  * @param document to publish
  * @throws NoPublishException if no published with a problem
  */
 public static void publish(DocumentModel document, CoreSession session)
     throws NoPublishException {
   try {
     if (LabsSiteConstants.State.DRAFT.getState().equals(document.getCurrentLifeCycleState())) {
       LabsPublisher publisherAdapter = Tools.getAdapter(LabsPublisher.class, document, session);
       publisherAdapter.publish();
       if (Docs.SITE.type().equals(document.getType())) {
         LabsSite site = Tools.getAdapter(LabsSite.class, document, session);
         LabsPublisher publisher =
             Tools.getAdapter(LabsPublisher.class, site.getIndexDocument(), session);
         if (publisher.isDraft()) {
           publisher.publish();
         }
       }
     }
   } catch (ClientException e) {
     throw new NoPublishException(LabsPublishService.NOT_PUBLISHED);
   }
 }