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.server;
020
021import java.util.List;
022
023import javax.servlet.http.HttpServletRequest;
024import javax.ws.rs.ext.MessageBodyReader;
025import javax.ws.rs.ext.MessageBodyWriter;
026
027/**
028 * A registry of REST bindings. Provides methods for checking if a given operation is allowed to be invoked in a REST
029 * call.
030 * <p>
031 * The binding registry is synchronized.
032 *
033 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
034 */
035public interface AutomationServer {
036
037    /**
038     * Gets a binding given an operation.
039     *
040     * @param name the operation name.
041     */
042    RestBinding getOperationBinding(String name);
043
044    /**
045     * Gets a binding given a chain name.
046     *
047     * @param name the chain name
048     */
049    RestBinding getChainBinding(String name);
050
051    /**
052     * Gets an array of registered bindings.
053     */
054    RestBinding[] getBindings();
055
056    /**
057     * Registers a new operation binding.
058     *
059     * @param binding the new binding to register
060     * @deprecated since 10.3 unused
061     */
062    @Deprecated
063    void addBinding(RestBinding binding);
064
065    /**
066     * Removes a binding for the given operation name.
067     *
068     * @param binding the binding to remove
069     * @return the removed binding if any, otherwise null
070     * @deprecated since 10.3 unused
071     */
072    @Deprecated
073    RestBinding removeBinding(RestBinding binding);
074
075    /**
076     * Checks if the given operation name is allowed in a REST call.
077     */
078    boolean accept(String name, boolean isChain, HttpServletRequest req);
079
080    /**
081     * Returns all the registered writers
082     *
083     * @since 5.8
084     */
085    List<Class<? extends MessageBodyWriter<?>>> getWriters();
086
087    /**
088     * @return all the registered readers
089     * @since 5.8
090     */
091    List<Class<? extends MessageBodyReader<?>>> getReaders();
092
093}