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