public void run() {
    File tmpDir = null;
    try {
      tmpDir = WidgetsetUtil.createTempDir();

      WidgetsetUtil.createWidgetset(tmpDir, widgetset, getIncludeWidgetsets());

      compiler =
          new WidgetsetCompiler(
              outputLog, widgetset, tmpDir.getAbsolutePath(), getClasspathEntries(tmpDir));

      try {
        compiler.compileWidgetset();
      } catch (InterruptedException e1) {
        Thread.currentThread().interrupt();
      }

      File compiledWidgetset = new File(tmpDir, widgetset);
      if (compiledWidgetset.exists() && compiledWidgetset.isDirectory()) {
        String ws = ControlPanelPortletUtil.getWidgetsetDir() + widgetset;
        WidgetsetUtil.rotateWidgetsetBackups(ws);
        WidgetsetUtil.backupOldWidgetset(ws);
        File destDir = new File(ws);

        outputLog.log("Copying widgetset from " + compiledWidgetset + " to " + destDir);

        System.out.println("Copying widgetset from " + compiledWidgetset + " to " + destDir);

        FileUtils.copyDirectory(compiledWidgetset, destDir);

        outputLog.log("Copying done");
        System.out.println("Copying done");
      }

    } catch (IOException e) {
      log.warn("Could not compile widgetsets.", e);
      System.out.println("Could not compile widgetsets. " + e.getMessage());
    } finally {
      try {
        System.out.println("Remove temp directory");
        FileUtils.deleteDirectory(tmpDir);
        System.out.println("Removing done...");
      } catch (IOException e) {
        log.warn("Could not delete temporary directory: " + tmpDir, e);
        System.out.println("Could not delete temporary directory: " + tmpDir + "  " + e);
      }

      compilationFinished();
    }
  }
 /**
  * Render.
  *
  * @param request the request
  * @param response the response
  * @param model the model
  * @return the string
  */
 @RenderMapping
 public String render(
     final RenderRequest request, final RenderResponse response, final Model model) {
   m_objLog.trace("render::start");
   String page = request.getParameter("jspPage");
   if (page == null) {
     page = "../shared/register";
     if (this.isLoggedInOrg(request)) {
       page = "registerLoggedIn";
     }
   }
   final String error = request.getParameter("error");
   if (error != null) {
     model.addAttribute("error", error);
     m_objLog.warn("Handing over error " + error);
     final String ePage = request.getParameter("errorPage");
     if (ePage != null) {
       page = ePage;
     }
   } /*
      * else { model.addAttribute("data", new BerliosProject()); }
      */
   m_objLog.trace("render::end(" + page + ")");
   return page;
 }
  public DebateItemReference remove(Long debateItemReferencePK)
      throws NoSuchDebateItemReferenceException, SystemException {
    Session session = null;

    try {
      session = openSession();

      DebateItemReference debateItemReference =
          (DebateItemReference) session.get(DebateItemReferenceImpl.class, debateItemReferencePK);

      if (debateItemReference == null) {
        if (_log.isWarnEnabled()) {
          _log.warn("No DebateItemReference exists with the primary key " + debateItemReferencePK);
        }

        throw new NoSuchDebateItemReferenceException(
            "No DebateItemReference exists with the primary key " + debateItemReferencePK);
      }

      return remove(debateItemReference);
    } catch (NoSuchDebateItemReferenceException nsee) {
      throw nsee;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }
  /**
   * Removes the proposal rating with the primary key from the database. Also notifies the
   * appropriate model listeners.
   *
   * @param primaryKey the primary key of the proposal rating
   * @return the proposal rating that was removed
   * @throws com.ext.portlet.NoSuchProposalRatingException if a proposal rating with the primary key
   *     could not be found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public ProposalRating remove(Serializable primaryKey)
      throws NoSuchProposalRatingException, SystemException {
    Session session = null;

    try {
      session = openSession();

      ProposalRating proposalRating =
          (ProposalRating) session.get(ProposalRatingImpl.class, primaryKey);

      if (proposalRating == null) {
        if (_log.isWarnEnabled()) {
          _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
        }

        throw new NoSuchProposalRatingException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
      }

      return remove(proposalRating);
    } catch (NoSuchProposalRatingException nsee) {
      throw nsee;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }
  /**
   * @deprecated Use <code>update(DebateItemReference debateItemReference, boolean merge)</code>.
   */
  public DebateItemReference update(DebateItemReference debateItemReference)
      throws SystemException {
    if (_log.isWarnEnabled()) {
      _log.warn(
          "Using the deprecated update(DebateItemReference debateItemReference) method. Use update(DebateItemReference debateItemReference, boolean merge) instead.");
    }

    return update(debateItemReference, false);
  }
 public static String getCode(String country) {
   String code = countries.get(country);
   if (code == null) {
     for (String name : countries.keySet()) {
       if (name.contains(country)) {
         code = countries.get(name);
       }
     }
   }
   if (code == null) {
     LOG.warn("Could not map " + country);
   }
   return code;
 }
  public DebateItemReference findByPrimaryKey(Long debateItemReferencePK)
      throws NoSuchDebateItemReferenceException, SystemException {
    DebateItemReference debateItemReference = fetchByPrimaryKey(debateItemReferencePK);

    if (debateItemReference == null) {
      if (_log.isWarnEnabled()) {
        _log.warn("No DebateItemReference exists with the primary key " + debateItemReferencePK);
      }

      throw new NoSuchDebateItemReferenceException(
          "No DebateItemReference exists with the primary key " + debateItemReferencePK);
    }

    return debateItemReference;
  }
  /**
   * Deletes the book from the database. Also notifies the appropriate model listeners.
   *
   * @param book the book
   * @throws SystemException if a system exception occurred
   */
  public void deleteBook(Book book) throws SystemException {
    bookPersistence.remove(book);

    Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());

    if (indexer != null) {
      try {
        indexer.delete(book);
      } catch (SearchException se) {
        if (_log.isWarnEnabled()) {
          _log.warn(se, se);
        }
      }
    }
  }
  /**
   * Returns the proposal rating with the primary key or throws a {@link
   * com.liferay.portal.NoSuchModelException} if it could not be found.
   *
   * @param primaryKey the primary key of the proposal rating
   * @return the proposal rating
   * @throws com.ext.portlet.NoSuchProposalRatingException if a proposal rating with the primary key
   *     could not be found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public ProposalRating findByPrimaryKey(Serializable primaryKey)
      throws NoSuchProposalRatingException, SystemException {
    ProposalRating proposalRating = fetchByPrimaryKey(primaryKey);

    if (proposalRating == null) {
      if (_log.isWarnEnabled()) {
        _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
      }

      throw new NoSuchProposalRatingException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
    }

    return proposalRating;
  }
    protected Layout fetchImportedLayout(
        PortletDataContext portletDataContext, JSONObject jsonObject) {

      Map<Long, Layout> layouts =
          (Map<Long, Layout>) portletDataContext.getNewPrimaryKeysMap(Layout.class + ".layout");

      long layoutId = jsonObject.getLong("layoutId");

      Layout layout = layouts.get(layoutId);

      if (layout == null) {
        if (_log.isWarnEnabled()) {
          _log.warn("Unable to find layout with ID " + layoutId);
        }
      }

      return layout;
    }
  /**
   * Updates the book in the database or adds it if it does not yet exist. Also notifies the
   * appropriate model listeners.
   *
   * @param book the book
   * @param merge whether to merge the book with the current session. See {@link
   *     com.liferay.portal.service.persistence.BatchSession#update(com.liferay.portal.kernel.dao.orm.Session,
   *     com.liferay.portal.model.BaseModel, boolean)} for an explanation.
   * @return the book that was updated
   * @throws SystemException if a system exception occurred
   */
  public Book updateBook(Book book, boolean merge) throws SystemException {
    book.setNew(false);

    book = bookPersistence.update(book, merge);

    Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());

    if (indexer != null) {
      try {
        indexer.reindex(book);
      } catch (SearchException se) {
        if (_log.isWarnEnabled()) {
          _log.warn(se, se);
        }
      }
    }

    return book;
  }