/** * see {@link IConfig#getVersion()} */ @PermitAll // see above public String getVersion() { String version = getInternalValue("omero.version"); Pattern p = Pattern.compile(VERSION_REGEX); Matcher m = p.matcher(version); if (!m.matches()) { throw new InternalException("Bad version format:" + version); } return m.group(1); }
/** * see {@link IConfig#setConfigValueIfEquals(String, String, String)} */ @RolesAllowed("user") @Transactional(readOnly = false) // see above public boolean setConfigValueIfEquals(String key, String value, String test) throws ApiUsageException, SecurityViolation { key = prefs.resolveAlias(key); lock.writeLock().lock(); try { String current = getInternalValue(key); if (test == null) { if (current != null) { return false; } } else { if (!test.equals(current)) { return false; } } setConfigValue(key, value); return true; } finally { lock.writeLock().unlock(); } }
@PermitAll public Map<String, String> getConfigValues(String keyRegex) { if (keyRegex == null) { return Collections.emptyMap(); } Pattern p = Pattern.compile(keyRegex); Map<String, String> rv = new HashMap<String, String>(); Set<String> keys = prefs.getKeySet(); // Not resolving aliases since these come straight-from the prefs for (String key : keys) { if (p.matcher(key).find()) { if (prefs.canRead( currentDetails.getCurrentEventContext(), key)) { rv.put(key, getInternalValue(key)); } } } return rv; }
/** * see {@link IConfig#getConfigValue(String)} */ @PermitAll // see above public String getConfigValue(String key) { if (key == null) { return ""; } key = prefs.resolveAlias(key); if (!prefs.canRead(currentDetails.getCurrentEventContext(), key)) { throw new SecurityViolation("Cannot read configuration: " + key); } return getInternalValue(key); }