001 /****************************************************************
002 * Licensed to the Apache Software Foundation (ASF) under one *
003 * or more contributor license agreements. See the NOTICE file *
004 * distributed with this work for additional information *
005 * regarding copyright ownership. The ASF licenses this file *
006 * to you under the Apache License, Version 2.0 (the *
007 * "License"); you may not use this file except in compliance *
008 * with the License. You may obtain a copy of the License at *
009 * *
010 * http://www.apache.org/licenses/LICENSE-2.0 *
011 * *
012 * Unless required by applicable law or agreed to in writing, *
013 * software distributed under the License is distributed on an *
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
015 * KIND, either express or implied. See the License for the *
016 * specific language governing permissions and limitations *
017 * under the License. *
018 ****************************************************************/
019
020 package org.apache.james.rrt.lib;
021
022 import java.util.Collection;
023 import java.util.Map;
024
025 import javax.annotation.Resource;
026 import javax.management.NotCompliantMBeanException;
027 import javax.management.StandardMBean;
028
029 import org.apache.james.rrt.api.RecipientRewriteTable;
030 import org.apache.james.rrt.api.RecipientRewriteTableException;
031 import org.apache.james.rrt.api.RecipientRewriteTableManagementMBean;
032
033 /**
034 * Management for RecipientRewriteTables
035 */
036 public class RecipientRewriteTableManagement extends StandardMBean implements RecipientRewriteTableManagementMBean {
037
038 protected RecipientRewriteTableManagement() throws NotCompliantMBeanException {
039 super(RecipientRewriteTableManagementMBean.class);
040 }
041
042 private RecipientRewriteTable vut;
043
044 @Resource(name = "recipientrewritetable")
045 public void setManageableRecipientRewriteTable(RecipientRewriteTable vut) {
046 this.vut = vut;
047 }
048
049 /**
050 * @see
051 * org.apache.james.rrt.api.RecipientRewriteTableManagementMBean#addRegexMapping
052 * (java.lang.String, java.lang.String, java.lang.String)
053 */
054 public void addRegexMapping(String user, String domain, String regex) throws Exception {
055 try {
056 vut.addRegexMapping(user, domain, regex);
057 } catch (RecipientRewriteTableException e) {
058 throw new Exception(e.getMessage());
059 }
060 }
061
062 /**
063 * @see
064 * org.apache.james.rrt.api.RecipientRewriteTableManagementMBean#removeRegexMapping
065 * (java.lang.String, java.lang.String, java.lang.String)
066 */
067 public void removeRegexMapping(String user, String domain, String regex) throws Exception {
068 try {
069
070 vut.removeRegexMapping(user, domain, regex);
071 } catch (RecipientRewriteTableException e) {
072 throw new Exception(e.getMessage());
073 }
074 }
075
076 /**
077 * @see
078 * org.apache.james.rrt.api.RecipientRewriteTableManagementMBean#addAddressMapping
079 * (java.lang.String, java.lang.String, java.lang.String)
080 */
081 public void addAddressMapping(String user, String domain, String address) throws Exception {
082 try {
083
084 vut.addAddressMapping(user, domain, address);
085 } catch (RecipientRewriteTableException e) {
086 throw new Exception(e.getMessage());
087 }
088 }
089
090 /**
091 * @see
092 * org.apache.james.rrt.api.RecipientRewriteTableManagementMBean#removeAddressMapping
093 * (java.lang.String, java.lang.String, java.lang.String)
094 */
095 public void removeAddressMapping(String user, String domain, String address) throws Exception {
096 try {
097
098 vut.removeAddressMapping(user, domain, address);
099 } catch (RecipientRewriteTableException e) {
100 throw new Exception(e.getMessage());
101 }
102 }
103
104 /**
105 * @see
106 * org.apache.james.rrt.api.RecipientRewriteTableManagementMBean#addErrorMapping
107 * (java.lang.String, java.lang.String, java.lang.String)
108 */
109 public void addErrorMapping(String user, String domain, String error) throws Exception {
110 try {
111
112 vut.addErrorMapping(user, domain, error);
113 } catch (RecipientRewriteTableException e) {
114 throw new Exception(e.getMessage());
115 }
116 }
117
118 /**
119 * @see
120 * org.apache.james.rrt.api.RecipientRewriteTableManagementMBean#removeErrorMapping
121 * (java.lang.String, java.lang.String, java.lang.String)
122 */
123 public void removeErrorMapping(String user, String domain, String error) throws Exception {
124 try {
125
126 vut.removeErrorMapping(user, domain, error);
127 } catch (RecipientRewriteTableException e) {
128 throw new Exception(e.getMessage());
129 }
130 }
131
132 public void addDomainMapping(String domain, String targetDomain) throws Exception {
133 try {
134 vut.addAliasDomainMapping(domain, targetDomain);
135 } catch (RecipientRewriteTableException e) {
136 throw new Exception(e.getMessage());
137 }
138 }
139
140 public void removeDomainMapping(String domain, String targetDomain) throws Exception {
141 try {
142 vut.removeAliasDomainMapping(domain, targetDomain);
143 } catch (RecipientRewriteTableException e) {
144 throw new Exception(e.getMessage());
145 }
146 }
147
148 /**
149 * @see org.apache.james.rrt.api.RecipientRewriteTableManagementMBean
150 * #getUserDomainMappings(java.lang.String, java.lang.String)
151 */
152 public Collection<String> getUserDomainMappings(String user, String domain) throws Exception {
153 try {
154
155 return vut.getUserDomainMappings(user, domain);
156 } catch (RecipientRewriteTableException e) {
157 throw new Exception(e.getMessage());
158 }
159 }
160
161 /**
162 * @see
163 * org.apache.james.rrt.api.RecipientRewriteTableManagementMBean
164 * #addMapping(java.lang.String, java.lang.String, java.lang.String)
165 */
166 public void addMapping(String user, String domain, String mapping) throws Exception {
167 try {
168
169 vut.addMapping(user, domain, mapping);
170 } catch (RecipientRewriteTableException e) {
171 throw new Exception(e.getMessage());
172 }
173 }
174
175 /**
176 * @see
177 * org.apache.james.rrt.api.RecipientRewriteTableManagementMBean#removeMapping
178 * (java.lang.String, java.lang.String, java.lang.String)
179 */
180 public void removeMapping(String user, String domain, String mapping) throws Exception {
181 try {
182
183 vut.removeMapping(user, domain, mapping);
184 } catch (RecipientRewriteTableException e) {
185 throw new Exception(e.getMessage());
186 }
187 }
188
189 /**
190 * @see
191 * org.apache.james.rrt.api.RecipientRewriteTableManagementMBean#getAllMappings()
192 */
193 public Map<String, Collection<String>> getAllMappings() throws Exception {
194 try {
195
196 return vut.getAllMappings();
197 } catch (RecipientRewriteTableException e) {
198 throw new Exception(e.getMessage());
199 }
200 }
201
202 }