001/*
002 * (C) Copyright 2015 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Antoine Taillefer <ataillefer@nuxeo.com>
018 */
019package org.nuxeo.drive.elasticsearch.operations.test;
020
021import java.io.Serializable;
022import java.util.HashMap;
023import java.util.Map;
024
025import org.nuxeo.ecm.automation.AutomationService;
026import org.nuxeo.ecm.automation.OperationContext;
027import org.nuxeo.ecm.automation.OperationException;
028import org.nuxeo.ecm.automation.core.Constants;
029import org.nuxeo.ecm.automation.core.annotations.Context;
030import org.nuxeo.ecm.automation.core.annotations.Operation;
031import org.nuxeo.ecm.automation.core.annotations.OperationMethod;
032import org.nuxeo.ecm.automation.elasticsearch.ElasticsearchWaitForIndexingOperation;
033import org.nuxeo.runtime.api.Framework;
034
035/**
036 * Waits for Elasticsearch audit completion.
037 *
038 * @since 7.3
039 */
040@Operation(id = NuxeoDriveWaitForElasticsearchCompletion.ID, category = Constants.CAT_SERVICES, label = "Nuxeo Drive: Wait for Elasticsearch audit completion")
041public class NuxeoDriveWaitForElasticsearchCompletion {
042
043    public static final String ID = "NuxeoDrive.WaitForElasticsearchCompletion";
044
045    @Context
046    protected OperationContext ctx;
047
048    @OperationMethod
049    public void run() throws OperationException {
050        Map<String, Serializable> params = new HashMap<>();
051        params.put("refresh", true);
052        params.put("waitForAudit", true);
053        Framework.getService(AutomationService.class).run(ctx, ElasticsearchWaitForIndexingOperation.ID, params);
054    }
055
056}