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.client.model; 020 021import java.io.Serializable; 022import java.util.HashMap; 023import java.util.Map; 024 025/** 026 * @author <a href="mailto:[email protected]">Bogdan Stefanescu</a> 027 */ 028public class OperationRegistry implements Serializable { 029 030 private static final long serialVersionUID = 7052919017498723129L; 031 032 protected Map<String, String> paths; 033 034 protected Map<String, OperationDocumentation> ops; 035 036 protected Map<String, OperationDocumentation> chains; 037 038 public OperationRegistry(Map<String, String> paths, Map<String, OperationDocumentation> ops, 039 Map<String, OperationDocumentation> chains) { 040 this.ops = ops; 041 this.chains = chains; 042 this.paths = paths; 043 } 044 045 public String getPath(String key) { 046 return paths.get(key); 047 } 048 049 public OperationDocumentation getOperation(String key) { 050 OperationDocumentation op = ops.get(key); 051 if (op == null) { 052 op = chains.get(key); 053 } 054 return op; 055 } 056 057 public Map<String, OperationDocumentation> getOperations() { 058 Map<String, OperationDocumentation> map = new HashMap<String, OperationDocumentation>(ops); 059 map.putAll(chains); 060 return map; 061 } 062}