| 1 | |
package com.aurea.maven.plugins.sonic.sdm; |
| 2 | |
|
| 3 | |
import java.util.ArrayList; |
| 4 | |
import java.util.List; |
| 5 | |
|
| 6 | |
import org.codehaus.plexus.util.xml.Xpp3Dom; |
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
public class QueueMapping { |
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
private String id; |
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
private final List<String> includes; |
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
private final List<String> excludes; |
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
private String parameterSetId; |
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | 0 | private boolean suppressJNDI = true; |
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | 0 | public QueueMapping() { |
| 46 | |
|
| 47 | 0 | includes = new ArrayList<String>(); |
| 48 | 0 | excludes = new ArrayList<String>(); |
| 49 | 0 | } |
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
public QueueMapping(final String _id, final String _include) { |
| 58 | |
|
| 59 | 0 | this(); |
| 60 | 0 | setId(_id); |
| 61 | 0 | includes.add(_include); |
| 62 | 0 | } |
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | |
|
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
|
| 91 | |
|
| 92 | |
|
| 93 | |
|
| 94 | |
|
| 95 | |
|
| 96 | |
|
| 97 | |
public QueueMapping(final Xpp3Dom _dom) { |
| 98 | |
|
| 99 | 0 | this(); |
| 100 | |
|
| 101 | 0 | final Xpp3Dom idElement = _dom.getChild("id"); |
| 102 | 0 | if (idElement == null) { |
| 103 | 0 | throw new RuntimeException("id element is required in a queueMapping"); |
| 104 | |
} |
| 105 | 0 | setId(_dom.getChild("id").getValue()); |
| 106 | |
|
| 107 | 0 | final Xpp3Dom parameterSetElement = _dom.getChild("parameterSet"); |
| 108 | 0 | if (parameterSetElement != null) { |
| 109 | 0 | setParameterSetId(parameterSetElement.getValue()); |
| 110 | |
} |
| 111 | |
|
| 112 | |
|
| 113 | |
|
| 114 | |
|
| 115 | |
|
| 116 | 0 | final Xpp3Dom includesElement = _dom.getChild("includes"); |
| 117 | 0 | if (includesElement != null) { |
| 118 | 0 | for (final Xpp3Dom includeElement : includesElement.getChildren("include")) { |
| 119 | 0 | addInclude(includeElement.getValue()); |
| 120 | |
} |
| 121 | |
} else { |
| 122 | 0 | addInclude(".*"); |
| 123 | |
} |
| 124 | |
|
| 125 | 0 | final Xpp3Dom excludesElement = _dom.getChild("excludes"); |
| 126 | 0 | if (excludesElement != null) { |
| 127 | 0 | for (final Xpp3Dom excludeElement : excludesElement.getChildren("exclude")) { |
| 128 | 0 | addExclude(excludeElement.getValue()); |
| 129 | |
} |
| 130 | |
} |
| 131 | 0 | } |
| 132 | |
|
| 133 | |
|
| 134 | |
|
| 135 | |
|
| 136 | |
|
| 137 | |
|
| 138 | |
|
| 139 | |
|
| 140 | |
public boolean matches(final String _queueName) { |
| 141 | |
|
| 142 | |
|
| 143 | 0 | for (final String exclude : excludes) { |
| 144 | 0 | if (_queueName.matches(exclude)) { |
| 145 | 0 | return false; |
| 146 | |
} |
| 147 | 0 | } |
| 148 | |
|
| 149 | |
|
| 150 | 0 | for (final String include : includes) { |
| 151 | 0 | if (_queueName.matches(include)) { |
| 152 | 0 | return true; |
| 153 | |
} |
| 154 | 0 | } |
| 155 | |
|
| 156 | |
|
| 157 | 0 | return false; |
| 158 | |
} |
| 159 | |
|
| 160 | |
public String getId() { |
| 161 | |
|
| 162 | 0 | return id; |
| 163 | |
} |
| 164 | |
|
| 165 | |
public void setId(final String _id) { |
| 166 | |
|
| 167 | 0 | id = _id; |
| 168 | 0 | } |
| 169 | |
|
| 170 | |
public void addInclude(final String _regex) { |
| 171 | |
|
| 172 | 0 | if (_regex == null) { |
| 173 | 0 | throw new IllegalArgumentException("Regex must not be null"); |
| 174 | |
} |
| 175 | 0 | includes.add(_regex); |
| 176 | 0 | } |
| 177 | |
|
| 178 | |
public void addExclude(final String _regex) { |
| 179 | |
|
| 180 | 0 | if (_regex == null) { |
| 181 | 0 | throw new IllegalArgumentException("Regex must not be null"); |
| 182 | |
} |
| 183 | 0 | excludes.add(_regex); |
| 184 | 0 | } |
| 185 | |
|
| 186 | |
public void setParameterSetId(final String _parameterSetId) { |
| 187 | |
|
| 188 | 0 | parameterSetId = _parameterSetId; |
| 189 | 0 | } |
| 190 | |
|
| 191 | |
public String getParameterSetId() { |
| 192 | |
|
| 193 | 0 | return parameterSetId; |
| 194 | |
} |
| 195 | |
|
| 196 | |
public void setSuppressJNDI(final boolean _suppressJNDI) { |
| 197 | |
|
| 198 | 0 | suppressJNDI = _suppressJNDI; |
| 199 | 0 | } |
| 200 | |
|
| 201 | |
public boolean isSuppressJNDI() { |
| 202 | |
|
| 203 | 0 | return suppressJNDI; |
| 204 | |
} |
| 205 | |
|
| 206 | |
@Override |
| 207 | |
public String toString() { |
| 208 | |
|
| 209 | 0 | return String.format("id: %s, includes: %s, excludes: %s", getId(), includes, excludes); |
| 210 | |
} |
| 211 | |
} |