001/*
002 * (C) Copyright 2013 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl-2.1.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Thomas Roger
016 */
017
018package org.nuxeo.ecm.automation.jsf.operations;
019
020import org.jboss.seam.core.Events;
021import org.nuxeo.ecm.automation.core.Constants;
022import org.nuxeo.ecm.automation.core.annotations.Operation;
023import org.nuxeo.ecm.automation.core.annotations.OperationMethod;
024import org.nuxeo.ecm.automation.core.annotations.Param;
025import org.nuxeo.ecm.automation.core.util.StringList;
026
027/**
028 * Operation that raises configurable seam events.
029 *
030 * @since 5.7
031 */
032@Operation(id = RaiseSeamEvents.ID, category = Constants.CAT_UI, requires = Constants.SEAM_CONTEXT, label = "Raise Seam events", description = "Raise Seam events without parameters. This is a void operation - the input object is returned back as the output", aliases = { "Seam.RaiseEvents" })
033public class RaiseSeamEvents {
034
035    public static final String ID = "WebUI.RaiseSeamEvents";
036
037    @Param(name = "seamEvents", required = true)
038    protected StringList seamEvents;
039
040    @OperationMethod
041    public void run() {
042        if (seamEvents != null) {
043            for (String event : seamEvents) {
044                Events.instance().raiseEvent(event);
045            }
046        }
047    }
048
049}