001/*
002 * (C) Copyright 2006-2011 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 *     bstefanescu
018 */
019package org.nuxeo.ecm.automation.core.operations;
020
021import java.io.IOException;
022import java.net.URL;
023
024import org.nuxeo.ecm.automation.OperationContext;
025import org.nuxeo.ecm.automation.OperationException;
026import org.nuxeo.ecm.automation.core.AutomationComponent;
027import org.nuxeo.ecm.automation.core.Constants;
028import org.nuxeo.ecm.automation.core.annotations.Context;
029import org.nuxeo.ecm.automation.core.annotations.Operation;
030import org.nuxeo.ecm.automation.core.annotations.OperationMethod;
031import org.nuxeo.ecm.automation.core.annotations.Param;
032import org.nuxeo.ecm.automation.core.scripting.Scripting;
033
034/**
035 * Save the session - TODO remove this?
036 *
037 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
038 * @deprecated Not enabled for now since not fully implemented. To activate it uncomment the registration from
039 *             {@link AutomationComponent#activate(org.nuxeo.runtime.model.ComponentContext)} and enable the unit test.
040 */
041@Deprecated
042@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" })
043public class RunScriptFile {
044
045    public static final String ID = "RunScriptFile";
046
047    @Context
048    protected OperationContext ctx;
049
050    @Param(name = "script")
051    protected URL script;
052
053    @OperationMethod
054    public void run() throws OperationException, IOException {
055        Scripting.run(ctx, script);
056    }
057
058}