<commit_before>/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package com.celements.mandatory;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.xwiki.component.annotation.Component;
import org.xwiki.component.annotation.Requirement;
import org.xwiki.context.Execution;
import org.xwiki.model.reference.DocumentReference;

import com.celements.common.classes.IClassCollectionRole;
import com.celements.pagetype.PageTypeClasses;
import com.celements.web.plugin.cmd.CreateDocumentCommand;
import com.celements.web.service.IWebUtilsService;
import com.xpn.xwiki.XWikiContext;
import com.xpn.xwiki.XWikiException;
import com.xpn.xwiki.doc.XWikiDocument;
import com.xpn.xwiki.objects.BaseObject;

@Component("celements.mandatory.wikipreferences")
public class XWikiXWikiPreferences implements IMandatoryDocumentRole {

  private static Log LOGGER = LogFactory.getFactory().getInstance(
      XWikiXWikiPreferences.class);

  @Requirement
  IWebUtilsService webUtils;

  @Requirement("celements.celPageTypeClasses")
  IClassCollectionRole pageTypeClasses;

  @Requirement
  Execution execution;

  protected XWikiContext getContext() {
    return (XWikiContext)execution.getContext().getProperty("xwikicontext");
  }

  private PageTypeClasses getPageTypeClasses() {
    return (PageTypeClasses) pageTypeClasses;
  }

  public void checkDocuments() throws XWikiException {
    LOGGER.trace("Start checkDocuments in XWikiXWikiPreferences for database ["
          + getContext().getDatabase() + "].");
    if (noMainWiki() && !isSkipCelementsWikiPreferences()) {
      LOGGER.trace("before checkXWikiPreferences for database ["
          + getContext().getDatabase() + "].");
      checkXWikiPreferences();
    } else {
      LOGGER.info("skip mandatory checkXWikiPreferences for database ["
          + getContext().getDatabase() + "], noMainWiki [" + noMainWiki()
          + "], skipCelementsParam [" + isSkipCelementsWikiPreferences() + "].");
    }
    LOGGER.trace("end checkDocuments in XWikiXWikiPreferences for database ["
        + getContext().getDatabase() + "].");<commit_msg>add checkXWikiPreferencesMainWiki call for main wiki in chekcDocuments<commit_after>/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package com.celements.mandatory;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.xwiki.component.annotation.Component;
import org.xwiki.component.annotation.Requirement;
import org.xwiki.context.Execution;
import org.xwiki.model.reference.DocumentReference;

import com.celements.common.classes.IClassCollectionRole;
import com.celements.pagetype.PageTypeClasses;
import com.celements.web.plugin.cmd.CreateDocumentCommand;
import com.celements.web.service.IWebUtilsService;
import com.xpn.xwiki.XWikiContext;
import com.xpn.xwiki.XWikiException;
import com.xpn.xwiki.doc.XWikiDocument;
import com.xpn.xwiki.objects.BaseObject;

@Component("celements.mandatory.wikipreferences")
public class XWikiXWikiPreferences implements IMandatoryDocumentRole {

  private static Log LOGGER = LogFactory.getFactory().getInstance(
      XWikiXWikiPreferences.class);

  @Requirement
  IWebUtilsService webUtils;

  @Requirement("celements.celPageTypeClasses")
  IClassCollectionRole pageTypeClasses;

  @Requirement
  Execution execution;

  protected XWikiContext getContext() {
    return (XWikiContext)execution.getContext().getProperty("xwikicontext");
  }

  private PageTypeClasses getPageTypeClasses() {
    return (PageTypeClasses) pageTypeClasses;
  }

  public void checkDocuments() throws XWikiException {
    LOGGER.debug("starting mandatory checkXWikiPreferences for database ["
        + getContext().getDatabase() + "], noMainWiki [" + noMainWiki()
        + "], skipCelementsParam [" + isSkipCelementsWikiPreferences() + "].");
    if (!isSkipCelementsWikiPreferences()) {
      if (noMainWiki()) {
        checkXWikiPreferences();
      } else {
        checkXWikiPreferencesMainWiki();
      }
    } else {
      LOGGER.info("skip mandatory checkXWikiPreferences for database ["
          + getContext().getDatabase() + "], noMainWiki [" + noMainWiki()
          + "], skipCelementsParam [" + isSkipCelementsWikiPreferences() + "].");
    }
    LOGGER.trace("end checkDocuments in XWikiXWikiPreferences for database ["
        + getContext().getDatabase() + "].");
{'fraction_non_alphanumeric': 0.09465822373761974, 'fraction_numerical': 0.004221464523461601, 'mean_word_length': 4.564588979223125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1791972', 'n_tokens_mistral': 1745, 'n_tokens_neox': 1695, 'n_words': 486}