<commit_before>/*
 * (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and contributors.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser General Public License
 * (LGPL) version 2.1 which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl.html
 *
 * This library 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.
 *
 * Contributors:
 *     tdelprat
 *     bdelbosc
 */
package org.nuxeo.elasticsearch.commands;

import java.io.IOException;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonFactory;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;
import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.CoreSession;
import org.nuxeo.ecm.core.api.DocumentModel;
import org.nuxeo.ecm.core.api.IdRef;
import org.nuxeo.ecm.core.api.repository.RepositoryManager;
import org.nuxeo.ecm.core.event.Event;
import org.nuxeo.ecm.core.event.impl.EventContextImpl;
import org.nuxeo.elasticsearch.listener.EventConstants;
import org.nuxeo.runtime.api.Framework;

/**
 *
 * Holds information about what type of indexing operation must be processed.
 * IndexingCommands are create "on the fly" via a Synchronous event listener and
 * at commit time the system will merge the commands and generate events for the
 * sync commands.
 *
 * @author <a href="mailto:<EMAIL>">Tiry</a>
 *
 */
public class IndexingCommand {

    public static final String INSERT = "ES_INSERT";

    public static final String UPDATE = "ES_UPDATE";

    public static final String UPDATE_SECURITY = "ES_UPDATE_SECURITY";

    public static final String DELETE = "ES_DELETE";

    public static final String PREFIX = "IndexingCommand-";

    protected String name;

    protected boolean sync;

    protected boolean recurse;

    protected DocumentModel targetDocument;

    protected String uid;

    protected String path;
<commit_msg>NXP-14956: make IndexingCommand Serializable for Redis<commit_after>/*
 * (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and contributors.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser General Public License
 * (LGPL) version 2.1 which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl.html
 *
 * This library 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.
 *
 * Contributors:
 *     tdelprat
 *     bdelbosc
 */
package org.nuxeo.elasticsearch.commands;

import java.io.IOException;
import java.io.Serializable;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonFactory;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;
import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.CoreSession;
import org.nuxeo.ecm.core.api.DocumentModel;
import org.nuxeo.ecm.core.api.IdRef;
import org.nuxeo.ecm.core.api.repository.RepositoryManager;
import org.nuxeo.ecm.core.event.Event;
import org.nuxeo.ecm.core.event.impl.EventContextImpl;
import org.nuxeo.elasticsearch.listener.EventConstants;
import org.nuxeo.runtime.api.Framework;

/**
 *
 * Holds information about what type of indexing operation must be processed.
 * IndexingCommands are create "on the fly" via a Synchronous event listener and
 * at commit time the system will merge the commands and generate events for the
 * sync commands.
 *
 * @author <a href="mailto:<EMAIL>">Tiry</a>
 *
 */
public class IndexingCommand implements Serializable {

    private static final long serialVersionUID = 1L;

    public static final String INSERT = "ES_INSERT";

    public static final String UPDATE = "ES_UPDATE";

    public static final String UPDATE_SECURITY = "ES_UPDATE_SECURITY";

    public static final String DELETE = "ES_DELETE";

    public static final String PREFIX = "IndexingCommand-";

    protected String name;

    protected boolean sync;

    protected boolean recurse;

    protected transient DocumentModel targetDocument;

    protected String uid;

    protected String path;

{'fraction_non_alphanumeric': 0.08586065573770492, 'fraction_numerical': 0.0036885245901639345, 'mean_word_length': 4.328602620087336, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '5532523', 'n_tokens_mistral': 1472, 'n_tokens_neox': 1388, 'n_words': 456}