001/*
002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     bstefanescu
011 */
012package org.nuxeo.ecm.automation.core.operations;
013
014import java.io.IOException;
015import java.net.URL;
016
017import org.nuxeo.ecm.automation.OperationContext;
018import org.nuxeo.ecm.automation.OperationException;
019import org.nuxeo.ecm.automation.core.AutomationComponent;
020import org.nuxeo.ecm.automation.core.Constants;
021import org.nuxeo.ecm.automation.core.annotations.Context;
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.scripting.Scripting;
026
027/**
028 * Save the session - TODO remove this?
029 *
030 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
031 * @deprecated Not enabled for now since not fully implemented. To activate it uncomment the registration from
032 *             {@link AutomationComponent#activate(org.nuxeo.runtime.model.ComponentContext)} and enable the unit test.
033 */
034@Deprecated
035@Operation(id = RunScriptFile.ID, category = Constants.CAT_SCRIPTING, label = "Run Script File", description = "Run a script file in the current context. The file is located using the bundle class loader.", aliases = { "Context.RunScriptFile" })
036public class RunScriptFile {
037
038    public static final String ID = "RunScriptFile";
039
040    @Context
041    protected OperationContext ctx;
042
043    @Param(name = "script")
044    protected URL script;
045
046    @OperationMethod
047    public void run() throws OperationException, IOException {
048        Scripting.run(ctx, script);
049    }
050
051}