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 */ 061 void addBinding(RestBinding binding); 062 063 /** 064 * Removes a binding for the given operation name. 065 * 066 * @param binding the binding to remove 067 * @return the removed binding if any, otherwise null 068 */ 069 RestBinding removeBinding(RestBinding binding); 070 071 /** 072 * Checks if the given operation name is allowed in a REST call. 073 */ 074 boolean accept(String name, boolean isChain, HttpServletRequest req); 075 076 /** 077 * Returns all the registered writers 078 * 079 * @return 080 * @since 5.8 081 */ 082 List<Class<? extends MessageBodyWriter<?>>> getWriters(); 083 084 /** 085 * @return all the registered readers 086 * @since 5.8 087 */ 088 List<Class<? extends MessageBodyReader<?>>> getReaders(); 089 090}