| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
package com.atlassian.core.propertyset; |
| 8 |
|
|
| 9 |
|
import com.opensymphony.module.propertyset.PropertySet; |
| 10 |
|
import com.opensymphony.module.propertyset.PropertyException; |
| 11 |
|
import com.opensymphony.module.propertyset.PropertySetSchema; |
| 12 |
|
import com.opensymphony.module.propertyset.PropertySetManager; |
| 13 |
|
import com.opensymphony.module.propertyset.memory.SerializablePropertySet; |
| 14 |
|
import com.opensymphony.util.DataUtil; |
| 15 |
|
|
| 16 |
|
import java.io.Serializable; |
| 17 |
|
import java.util.*; |
| 18 |
|
|
| 19 |
|
import org.w3c.dom.Document; |
| 20 |
|
|
| 21 |
|
|
| 22 |
|
|
| 23 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
|
|
|
| 0% |
Uncovered Elements: 229 (229) |
Complexity: 71 |
Complexity Density: 0.49 |
|
| 31 |
|
public class CachingPropertySet implements PropertySet, Serializable |
| 32 |
|
{ |
| 33 |
|
private PropertySet decoratedPS; |
| 34 |
|
private SerializablePropertySet cachePS; |
| 35 |
|
private Map existantKeyCache; |
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
@param |
| 45 |
|
@param |
| 46 |
|
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.44 |
|
| 47 |
0
|
public void init(Map config, Map args)... |
| 48 |
|
{ |
| 49 |
0
|
decoratedPS = (PropertySet) args.get("PropertySet"); |
| 50 |
|
|
| 51 |
0
|
String serializableName = (String) config.get("serializableName"); |
| 52 |
|
|
| 53 |
0
|
if (serializableName == null) |
| 54 |
|
{ |
| 55 |
0
|
serializableName = "serializable"; |
| 56 |
|
} |
| 57 |
|
|
| 58 |
0
|
cachePS = (SerializablePropertySet) PropertySetManager.getInstance(serializableName, null); |
| 59 |
0
|
existantKeyCache = new HashMap(); |
| 60 |
|
|
| 61 |
0
|
Boolean bulkload = (Boolean) args.get("bulkload"); |
| 62 |
|
|
| 63 |
0
|
if ((bulkload != null) && bulkload.booleanValue()) |
| 64 |
|
{ |
| 65 |
0
|
PropertySetManager.clone(decoratedPS, cachePS); |
| 66 |
|
} |
| 67 |
|
} |
| 68 |
|
|
|
|
|
| 0% |
Uncovered Elements: 37 (37) |
Complexity: 10 |
Complexity Density: 0.53 |
|
| 69 |
0
|
public void setAsActualType(String key, Object value) throws PropertyException... |
| 70 |
|
{ |
| 71 |
0
|
if (value instanceof Boolean) |
| 72 |
|
{ |
| 73 |
0
|
setBoolean(key, DataUtil.getBoolean((Boolean) value)); |
| 74 |
|
} |
| 75 |
0
|
else if (value instanceof Integer) |
| 76 |
|
{ |
| 77 |
0
|
setInt(key, DataUtil.getInt((Integer) value)); |
| 78 |
|
} |
| 79 |
0
|
else if (value instanceof Long) |
| 80 |
|
{ |
| 81 |
0
|
setLong(key, DataUtil.getLong((Long) value)); |
| 82 |
|
} |
| 83 |
0
|
else if (value instanceof Double) |
| 84 |
|
{ |
| 85 |
0
|
setDouble(key, DataUtil.getDouble((Double) value)); |
| 86 |
|
} |
| 87 |
0
|
else if (value instanceof String) |
| 88 |
|
{ |
| 89 |
0
|
setString(key, (String) value); |
| 90 |
|
} |
| 91 |
0
|
else if (value instanceof Date) |
| 92 |
|
{ |
| 93 |
0
|
setDate(key, (Date) value); |
| 94 |
|
} |
| 95 |
0
|
else if (value instanceof Document) |
| 96 |
|
{ |
| 97 |
0
|
setXML(key, (Document) value); |
| 98 |
|
} |
| 99 |
0
|
else if (value instanceof byte[]) |
| 100 |
|
{ |
| 101 |
0
|
setData(key, (byte[]) value); |
| 102 |
|
} |
| 103 |
0
|
else if (value instanceof Properties) |
| 104 |
|
{ |
| 105 |
0
|
setProperties(key, (Properties) value); |
| 106 |
|
} |
| 107 |
|
else |
| 108 |
|
{ |
| 109 |
0
|
setObject(key, value); |
| 110 |
|
} |
| 111 |
|
} |
| 112 |
|
|
|
|
|
| 0% |
Uncovered Elements: 34 (34) |
Complexity: 11 |
Complexity Density: 0.32 |
|
| 113 |
0
|
public Object getAsActualType(String key) throws PropertyException... |
| 114 |
|
{ |
| 115 |
0
|
int type = getType(key); |
| 116 |
0
|
Object value = null; |
| 117 |
|
|
| 118 |
0
|
switch (type) |
| 119 |
|
{ |
| 120 |
0
|
case BOOLEAN: |
| 121 |
0
|
value = new Boolean(getBoolean(key)); |
| 122 |
0
|
break; |
| 123 |
|
|
| 124 |
0
|
case INT: |
| 125 |
0
|
value = new Integer(getInt(key)); |
| 126 |
0
|
break; |
| 127 |
|
|
| 128 |
0
|
case LONG: |
| 129 |
0
|
value = new Long(getLong(key)); |
| 130 |
0
|
break; |
| 131 |
|
|
| 132 |
0
|
case DOUBLE: |
| 133 |
0
|
value = new Double(getDouble(key)); |
| 134 |
0
|
break; |
| 135 |
|
|
| 136 |
0
|
case STRING: |
| 137 |
0
|
value = getString(key); |
| 138 |
0
|
break; |
| 139 |
|
|
| 140 |
0
|
case DATE: |
| 141 |
0
|
value = getDate(key); |
| 142 |
0
|
break; |
| 143 |
|
|
| 144 |
0
|
case XML: |
| 145 |
0
|
value = getXML(key); |
| 146 |
0
|
break; |
| 147 |
|
|
| 148 |
0
|
case DATA: |
| 149 |
0
|
value = getData(key); |
| 150 |
0
|
break; |
| 151 |
|
|
| 152 |
0
|
case PROPERTIES: |
| 153 |
0
|
value = getProperties(key); |
| 154 |
0
|
break; |
| 155 |
|
|
| 156 |
0
|
case OBJECT: |
| 157 |
0
|
value = getObject(key); |
| 158 |
0
|
break; |
| 159 |
|
} |
| 160 |
|
|
| 161 |
0
|
return value; |
| 162 |
|
} |
| 163 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 164 |
0
|
public void setBoolean(String key, boolean value) throws PropertyException... |
| 165 |
|
{ |
| 166 |
0
|
decoratedPS.setBoolean(key, value); |
| 167 |
0
|
cachePS.setBoolean(key, value); |
| 168 |
|
|
| 169 |
|
|
| 170 |
0
|
existantKeyCache.remove(key); |
| 171 |
|
} |
| 172 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 173 |
0
|
public boolean getBoolean(String key) throws PropertyException... |
| 174 |
|
{ |
| 175 |
0
|
if (!cachePS.exists(key)) |
| 176 |
|
{ |
| 177 |
0
|
cachePS.setBoolean(key, decoratedPS.getBoolean(key)); |
| 178 |
|
} |
| 179 |
|
|
| 180 |
0
|
return cachePS.getBoolean(key); |
| 181 |
|
} |
| 182 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 183 |
0
|
public void setData(String key, byte[] value) throws PropertyException... |
| 184 |
|
{ |
| 185 |
0
|
decoratedPS.setData(key, value); |
| 186 |
0
|
cachePS.setData(key, value); |
| 187 |
|
|
| 188 |
|
|
| 189 |
0
|
existantKeyCache.remove(key); |
| 190 |
|
} |
| 191 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 192 |
0
|
public byte[] getData(String key) throws PropertyException... |
| 193 |
|
{ |
| 194 |
0
|
if (!cachePS.exists(key)) |
| 195 |
|
{ |
| 196 |
0
|
cachePS.setData(key, decoratedPS.getData(key)); |
| 197 |
|
} |
| 198 |
|
|
| 199 |
0
|
return cachePS.getData(key); |
| 200 |
|
} |
| 201 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 202 |
0
|
public void setDate(String key, Date value) throws PropertyException... |
| 203 |
|
{ |
| 204 |
0
|
decoratedPS.setDate(key, value); |
| 205 |
0
|
cachePS.setDate(key, value); |
| 206 |
|
|
| 207 |
|
|
| 208 |
0
|
existantKeyCache.remove(key); |
| 209 |
|
} |
| 210 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 211 |
0
|
public Date getDate(String key) throws PropertyException... |
| 212 |
|
{ |
| 213 |
0
|
if (!cachePS.exists(key)) |
| 214 |
|
{ |
| 215 |
0
|
cachePS.setDate(key, decoratedPS.getDate(key)); |
| 216 |
|
} |
| 217 |
|
|
| 218 |
0
|
return cachePS.getDate(key); |
| 219 |
|
} |
| 220 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 221 |
0
|
public void setDouble(String key, double value) throws PropertyException... |
| 222 |
|
{ |
| 223 |
0
|
decoratedPS.setDouble(key, value); |
| 224 |
0
|
cachePS.setDouble(key, value); |
| 225 |
|
|
| 226 |
|
|
| 227 |
0
|
existantKeyCache.remove(key); |
| 228 |
|
} |
| 229 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 230 |
0
|
public double getDouble(String key) throws PropertyException... |
| 231 |
|
{ |
| 232 |
0
|
if (!cachePS.exists(key)) |
| 233 |
|
{ |
| 234 |
0
|
cachePS.setDouble(key, decoratedPS.getDouble(key)); |
| 235 |
|
} |
| 236 |
|
|
| 237 |
0
|
return cachePS.getDouble(key); |
| 238 |
|
} |
| 239 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 240 |
0
|
public void setInt(String key, int value) throws PropertyException... |
| 241 |
|
{ |
| 242 |
0
|
decoratedPS.setInt(key, value); |
| 243 |
0
|
cachePS.setInt(key, value); |
| 244 |
|
|
| 245 |
|
|
| 246 |
0
|
existantKeyCache.remove(key); |
| 247 |
|
} |
| 248 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 249 |
0
|
public int getInt(String key) throws PropertyException... |
| 250 |
|
{ |
| 251 |
0
|
if (!cachePS.exists(key)) |
| 252 |
|
{ |
| 253 |
0
|
cachePS.setInt(key, decoratedPS.getInt(key)); |
| 254 |
|
} |
| 255 |
|
|
| 256 |
0
|
return cachePS.getInt(key); |
| 257 |
|
} |
| 258 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 259 |
0
|
public Collection getKeys() throws PropertyException... |
| 260 |
|
{ |
| 261 |
0
|
return decoratedPS.getKeys(); |
| 262 |
|
} |
| 263 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 264 |
0
|
public Collection getKeys(int type) throws PropertyException... |
| 265 |
|
{ |
| 266 |
0
|
return decoratedPS.getKeys(type); |
| 267 |
|
} |
| 268 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 269 |
0
|
public Collection getKeys(String prefix) throws PropertyException... |
| 270 |
|
{ |
| 271 |
0
|
return decoratedPS.getKeys(prefix); |
| 272 |
|
} |
| 273 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 274 |
0
|
public Collection getKeys(String prefix, int type) throws PropertyException... |
| 275 |
|
{ |
| 276 |
0
|
return decoratedPS.getKeys(prefix, type); |
| 277 |
|
} |
| 278 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 279 |
0
|
public void setLong(String key, long value) throws PropertyException... |
| 280 |
|
{ |
| 281 |
0
|
decoratedPS.setLong(key, value); |
| 282 |
0
|
cachePS.setLong(key, value); |
| 283 |
|
|
| 284 |
|
|
| 285 |
0
|
existantKeyCache.remove(key); |
| 286 |
|
} |
| 287 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 288 |
0
|
public long getLong(String key) throws PropertyException... |
| 289 |
|
{ |
| 290 |
0
|
if (!cachePS.exists(key)) |
| 291 |
|
{ |
| 292 |
0
|
cachePS.setLong(key, decoratedPS.getLong(key)); |
| 293 |
|
} |
| 294 |
|
|
| 295 |
0
|
return cachePS.getLong(key); |
| 296 |
|
} |
| 297 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 298 |
0
|
public void setObject(String key, Object value) throws PropertyException... |
| 299 |
|
{ |
| 300 |
0
|
decoratedPS.setObject(key, value); |
| 301 |
0
|
cachePS.setObject(key, value); |
| 302 |
|
|
| 303 |
|
|
| 304 |
0
|
existantKeyCache.remove(key); |
| 305 |
|
} |
| 306 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 307 |
0
|
public Object getObject(String key) throws PropertyException... |
| 308 |
|
{ |
| 309 |
0
|
if (!cachePS.exists(key)) |
| 310 |
|
{ |
| 311 |
0
|
cachePS.setObject(key, decoratedPS.getObject(key)); |
| 312 |
|
} |
| 313 |
|
|
| 314 |
0
|
return cachePS.getObject(key); |
| 315 |
|
} |
| 316 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 317 |
0
|
public void setProperties(String key, Properties value) throws PropertyException... |
| 318 |
|
{ |
| 319 |
0
|
decoratedPS.setProperties(key, value); |
| 320 |
0
|
cachePS.setProperties(key, value); |
| 321 |
|
|
| 322 |
|
|
| 323 |
0
|
existantKeyCache.remove(key); |
| 324 |
|
} |
| 325 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 326 |
0
|
public Properties getProperties(String key) throws PropertyException... |
| 327 |
|
{ |
| 328 |
0
|
if (!cachePS.exists(key)) |
| 329 |
|
{ |
| 330 |
0
|
cachePS.setProperties(key, decoratedPS.getProperties(key)); |
| 331 |
|
} |
| 332 |
|
|
| 333 |
0
|
return cachePS.getProperties(key); |
| 334 |
|
} |
| 335 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 336 |
0
|
public void setSchema(PropertySetSchema schema) throws PropertyException... |
| 337 |
|
{ |
| 338 |
0
|
decoratedPS.setSchema(schema); |
| 339 |
|
} |
| 340 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 341 |
0
|
public PropertySetSchema getSchema() throws PropertyException... |
| 342 |
|
{ |
| 343 |
0
|
return decoratedPS.getSchema(); |
| 344 |
|
} |
| 345 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 346 |
0
|
public boolean isSettable(String property)... |
| 347 |
|
{ |
| 348 |
0
|
return decoratedPS.isSettable(property); |
| 349 |
|
} |
| 350 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 351 |
0
|
public void setString(String key, String value) throws PropertyException... |
| 352 |
|
{ |
| 353 |
0
|
decoratedPS.setString(key, value); |
| 354 |
0
|
cachePS.setString(key, value); |
| 355 |
|
|
| 356 |
|
|
| 357 |
0
|
existantKeyCache.remove(key); |
| 358 |
|
} |
| 359 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 360 |
0
|
public String getString(String key) throws PropertyException... |
| 361 |
|
{ |
| 362 |
0
|
if (!cachePS.exists(key)) |
| 363 |
|
{ |
| 364 |
0
|
cachePS.setString(key, decoratedPS.getString(key)); |
| 365 |
|
} |
| 366 |
|
|
| 367 |
0
|
return cachePS.getString(key); |
| 368 |
|
} |
| 369 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 370 |
0
|
public void setText(String key, String value) throws PropertyException... |
| 371 |
|
{ |
| 372 |
0
|
decoratedPS.setText(key, value); |
| 373 |
0
|
cachePS.setText(key, value); |
| 374 |
|
|
| 375 |
|
|
| 376 |
0
|
existantKeyCache.remove(key); |
| 377 |
|
} |
| 378 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 379 |
0
|
public String getText(String key) throws PropertyException... |
| 380 |
|
{ |
| 381 |
0
|
if (!cachePS.exists(key)) |
| 382 |
|
{ |
| 383 |
0
|
cachePS.setText(key, decoratedPS.getText(key)); |
| 384 |
|
} |
| 385 |
|
|
| 386 |
0
|
return cachePS.getText(key); |
| 387 |
|
} |
| 388 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 389 |
0
|
public int getType(String key) throws PropertyException... |
| 390 |
|
{ |
| 391 |
0
|
return decoratedPS.getType(key); |
| 392 |
|
} |
| 393 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 394 |
0
|
public void setXML(String key, Document value) throws PropertyException... |
| 395 |
|
{ |
| 396 |
0
|
decoratedPS.setXML(key, value); |
| 397 |
0
|
cachePS.setXML(key, value); |
| 398 |
|
|
| 399 |
|
|
| 400 |
0
|
existantKeyCache.remove(key); |
| 401 |
|
} |
| 402 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 403 |
0
|
public Document getXML(String key) throws PropertyException... |
| 404 |
|
{ |
| 405 |
0
|
if (!cachePS.exists(key)) |
| 406 |
|
{ |
| 407 |
0
|
cachePS.setXML(key, decoratedPS.getXML(key)); |
| 408 |
|
} |
| 409 |
|
|
| 410 |
0
|
return cachePS.getXML(key); |
| 411 |
|
} |
| 412 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 413 |
0
|
public boolean exists(String key) throws PropertyException... |
| 414 |
|
{ |
| 415 |
|
|
| 416 |
|
|
| 417 |
0
|
if (existantKeyCache.containsKey(key)) |
| 418 |
|
{ |
| 419 |
0
|
return Boolean.TRUE.equals(existantKeyCache.get(key)); |
| 420 |
|
} |
| 421 |
|
|
| 422 |
0
|
boolean keyExists = decoratedPS.exists(key); |
| 423 |
|
|
| 424 |
|
|
| 425 |
0
|
existantKeyCache.put(key, new Boolean(keyExists)); |
| 426 |
0
|
return keyExists; |
| 427 |
|
} |
| 428 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 429 |
0
|
public void remove(String key) throws PropertyException... |
| 430 |
|
{ |
| 431 |
0
|
existantKeyCache.remove(key); |
| 432 |
0
|
cachePS.remove(key); |
| 433 |
0
|
decoratedPS.remove(key); |
| 434 |
|
} |
| 435 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 436 |
0
|
public boolean supportsType(int type)... |
| 437 |
|
{ |
| 438 |
0
|
return decoratedPS.supportsType(type); |
| 439 |
|
} |
| 440 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 441 |
0
|
public boolean supportsTypes()... |
| 442 |
|
{ |
| 443 |
0
|
return decoratedPS.supportsTypes(); |
| 444 |
|
} |
| 445 |
|
} |