diff --git a/announcements/src/org/labkey/announcements/model/AnnouncementManager.java b/announcements/src/org/labkey/announcements/model/AnnouncementManager.java index 71764726845..f9867d687fb 100644 --- a/announcements/src/org/labkey/announcements/model/AnnouncementManager.java +++ b/announcements/src/org/labkey/announcements/model/AnnouncementManager.java @@ -42,6 +42,7 @@ import org.labkey.api.data.CoreSchema; import org.labkey.api.data.DbScope; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.SQLFragment; import org.labkey.api.data.SimpleFilter; import org.labkey.api.data.Sort; @@ -779,7 +780,7 @@ public static Collection getEmailOptions() public static void saveDefaultEmailOption(Container c, int emailOption) { - PropertyManager.PropertyMap props = PropertyManager.getWritableProperties(c, "defaultEmailSettings", true); + WritablePropertyMap props = PropertyManager.getWritableProperties(c, "defaultEmailSettings", true); props.put("defaultEmailOption", Integer.toString(emailOption)); props.save(); } @@ -815,7 +816,7 @@ private static int validate(int option) public static void saveMessageBoardSettings(Container c, Settings settings) { - PropertyManager.PropertyMap props = PropertyManager.getWritableProperties(c, MESSAGE_BOARD_SETTINGS, true); + WritablePropertyMap props = PropertyManager.getWritableProperties(c, MESSAGE_BOARD_SETTINGS, true); props.clear(); // Get rid of old props (e.g., userList, see #13882) props.put("boardName", settings.getBoardName()); props.put("conversationName", settings.getConversationName()); diff --git a/api/src/org/labkey/api/data/Container.java b/api/src/org/labkey/api/data/Container.java index 231ec827632..389cb4f863e 100644 --- a/api/src/org/labkey/api/data/Container.java +++ b/api/src/org/labkey/api/data/Container.java @@ -31,7 +31,7 @@ import org.labkey.api.cache.BlockingCache; import org.labkey.api.cache.CacheManager; import org.labkey.api.collections.Sets; -import org.labkey.api.data.PropertyManager.PropertyMap; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.module.FolderType; import org.labkey.api.module.FolderTypeManager; import org.labkey.api.module.Module; @@ -1057,9 +1057,8 @@ public void setDefaultModule(Module module) { if (module == null) return; - PropertyMap props = PropertyManager.getWritableProperties(this, "defaultModules", true); + WritablePropertyMap props = PropertyManager.getWritableProperties(this, "defaultModules", true); props.put("name", module.getName()); - props.save(); ContainerManager.notifyContainerChange(getId(), ContainerManager.Property.Modules); _defaultModule = null; @@ -1079,7 +1078,7 @@ public void setActiveModules(Set modules, @Nullable User user) } boolean userHasEnableRestrictedModules = hasEnableRestrictedModules(user); - PropertyMap props = PropertyManager.getWritableProperties(this, "activeModules", true); + WritablePropertyMap props = PropertyManager.getWritableProperties(this, "activeModules", true); props.clear(); for (Module module : modules) { @@ -1199,7 +1198,7 @@ public boolean getAsBoolean() if (props.isEmpty() && init && null != ContainerManager.getForId(getId())) { //initialize properties cache - PropertyMap propsWritable = PropertyManager.getWritableProperties(this, "activeModules", true); + WritablePropertyMap propsWritable = PropertyManager.getWritableProperties(this, "activeModules", true); props = propsWritable; if (isProject()) diff --git a/api/src/org/labkey/api/data/ContainerManager.java b/api/src/org/labkey/api/data/ContainerManager.java index 4e3f18c101d..6c54b6c1fcd 100644 --- a/api/src/org/labkey/api/data/ContainerManager.java +++ b/api/src/org/labkey/api/data/ContainerManager.java @@ -46,6 +46,7 @@ import org.labkey.api.collections.ConcurrentHashSet; import org.labkey.api.data.Container.ContainerException; import org.labkey.api.data.Container.LockState; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.SimpleFilter.InClause; import org.labkey.api.data.dialect.SqlDialect; import org.labkey.api.data.validator.ColumnValidators; @@ -427,7 +428,7 @@ public static Container createContainerFromTemplate(Container parent, String nam public static void setRequireAuditComments(Container container, User user, @NotNull Boolean required) { - PropertyManager.PropertyMap props = PropertyManager.getWritableProperties(container, AUDIT_SETTINGS_PROPERTY_SET_NAME, true); + WritablePropertyMap props = PropertyManager.getWritableProperties(container, AUDIT_SETTINGS_PROPERTY_SET_NAME, true); String originalValue = props.get(REQUIRE_USER_COMMENTS_PROPERTY_NAME); props.put(REQUIRE_USER_COMMENTS_PROPERTY_NAME, required.toString()); props.save(); @@ -488,7 +489,7 @@ public static void setFolderType(Container c, FolderType folderType, User user, if (errorStrings.isEmpty()) { oldType.unconfigureContainer(c, user); - PropertyManager.PropertyMap props = PropertyManager.getWritableProperties(c, FOLDER_TYPE_PROPERTY_SET_NAME, true); + WritablePropertyMap props = PropertyManager.getWritableProperties(c, FOLDER_TYPE_PROPERTY_SET_NAME, true); props.put(FOLDER_TYPE_PROPERTY_NAME, folderType.getName()); if (c.isContainerTab()) @@ -703,14 +704,14 @@ public static boolean isContainerTabTypeOverridden(Container c) private static void setContainerTabDeleted(Container c, String tabName, String folderTypeName) { // Add prop in this category - PropertyManager.PropertyMap props = PropertyManager.getWritableProperties(c, TABFOLDER_CHILDREN_DELETED, true); + WritablePropertyMap props = PropertyManager.getWritableProperties(c, TABFOLDER_CHILDREN_DELETED, true); props.put(getDeletedTabKey(tabName, folderTypeName), "true"); props.save(); } public static void clearContainerTabDeleted(Container c, String tabName, String folderTypeName) { - PropertyManager.PropertyMap props = PropertyManager.getWritableProperties(c, TABFOLDER_CHILDREN_DELETED, true); + WritablePropertyMap props = PropertyManager.getWritableProperties(c, TABFOLDER_CHILDREN_DELETED, true); String key = getDeletedTabKey(tabName, folderTypeName); if (props.containsKey(key)) { diff --git a/api/src/org/labkey/api/data/PropertyManager.java b/api/src/org/labkey/api/data/PropertyManager.java index 32edac036cc..2974cb7e5e5 100644 --- a/api/src/org/labkey/api/data/PropertyManager.java +++ b/api/src/org/labkey/api/data/PropertyManager.java @@ -83,7 +83,7 @@ public static PropertyStore getEncryptedStore() * For global system properties that are attached to the root container * Returns an empty map if property set hasn't been created */ - public static @NotNull PropertyManager.PropertyMap getProperties(String category) + public static @NotNull PropertyMap getProperties(String category) { return STORE.getProperties(category); } @@ -92,7 +92,7 @@ public static PropertyStore getEncryptedStore() * For shared properties that are attached to a specific container * Returns an empty map if property set hasn't been created */ - public static @NotNull PropertyManager.PropertyMap getProperties(Container container, String category) + public static @NotNull PropertyMap getProperties(Container container, String category) { return STORE.getProperties(container, category); } @@ -101,12 +101,12 @@ public static PropertyStore getEncryptedStore() * For shared properties that are attached to a specific container and user * Returns an empty map if property set hasn't been created */ - public static @NotNull PropertyManager.PropertyMap getProperties(User user, Container container, String category) + public static @NotNull PropertyMap getProperties(User user, Container container, String category) { return STORE.getProperties(user, container, category); } - private static boolean assertWritableProperties(@Nullable PropertyMap writableProps, boolean create) + private static boolean assertWritableProperties(@Nullable WritablePropertyMap writableProps, boolean create) { // getWritableProperties() will return null if an existing map is not found and create is false. if (writableProps == null) @@ -282,8 +282,8 @@ public static PropertyEntry[] findPropertyEntries(@Nullable User user, @Nullable } // Instances of this specific class are guaranteed to be immutable; all mutating Map methods (put(), remove(), etc.) - // will throw exceptions. keySet(), values(), entrySet(), and mapIterator() return immutable data structures. - // Instances of subclass WritablePropertyMap ARE mutable and can be saved, deleted, etc. + // throw exceptions. keySet(), values(), entrySet(), and mapIterator() return immutable data structures. + // Instances of subclass WritablePropertyMap, however, are mutable Maps and can be saved & deleted. public static class PropertyMap extends AbstractMapDecorator implements InitializingBean { private int _set; @@ -293,10 +293,6 @@ public static class PropertyMap extends AbstractMapDecorator imp private final PropertyEncryption _propertyEncryption; private final AbstractPropertyStore _store; - private boolean _modified = false; - private Set _removedKeys = null; - private boolean _locked = false; - protected PropertyMap(int set, @NotNull User user, @NotNull String objectId, @NotNull String category, PropertyEncryption propertyEncryption, AbstractPropertyStore store, Map map) { super(map); @@ -343,6 +339,44 @@ PropertyEncryption getEncryptionAlgorithm() return _propertyEncryption; } + @Override + public String toString() + { + return getClass().getSimpleName() + ": " + _objectId + ", " + _category + ", " + _user.getDisplayName(null) + ": " + super.toString(); + } + + @Override + public boolean equals(Object o) + { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + PropertyMap that = (PropertyMap) o; + + if (!_user.equals(that._user)) return false; + if (!_category.equals(that._category)) return false; + + return _objectId.equals(that._objectId); + } + + @Override + public int hashCode() + { + int result = _user.hashCode(); + result = 31 * result + _objectId.hashCode(); + result = 31 * result + _category.hashCode(); + return result; + } + + // TODO: Once all repos are migrated to use WritablePropertyMaps, everything below will be moved to WritablePropertyMap. + // _locked handling will be removed and cache checking will simply forbid WritablePropertyMap. + // I believe that InitializingBean & afterPropertiesSet() can be removed, since we're now loading the map before + // constructing WritablePropertyMap. + + private boolean _modified = false; + private Set _removedKeys = null; + private boolean _locked = false; + @Override public String remove(Object key) { @@ -377,12 +411,6 @@ public String put(String key, @Nullable String value) return super.put(key, value); } - @Override - public String toString() - { - return getClass().getSimpleName() + ": " + _objectId + ", " + _category + ", " + _user.getDisplayName(null) + ": " + super.toString(); - } - @Override public void putAll(Map m) { @@ -403,29 +431,6 @@ public void clear() super.clear(); } - @Override - public boolean equals(Object o) - { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - PropertyMap that = (PropertyMap) o; - - if (!_user.equals(that._user)) return false; - if (!_category.equals(that._category)) return false; - - return _objectId.equals(that._objectId); - } - - @Override - public int hashCode() - { - int result = _user.hashCode(); - result = 31 * result + _objectId.hashCode(); - result = 31 * result + _category.hashCode(); - return result; - } - public boolean isModified() { return _modified; @@ -565,7 +570,7 @@ public boolean isLocked() } /** - * This subclass is mutable and can be saved, deleted, etc. + * This subclass is a mutable Map and can be saved & deleted */ public static class WritablePropertyMap extends PropertyMap { @@ -836,7 +841,7 @@ private void testPropertyStore(PropertyStore store, PropertyStoreTest test) private void testProperties(PropertyStore store, User user, Container test, String category) { - PropertyMap m = store.getWritableProperties(user, test, category, true); + WritablePropertyMap m = store.getWritableProperties(user, test, category, true); assertNotNull(m); m.clear(); m.save(); @@ -884,7 +889,7 @@ public void run() private void testProps() { - PropertyMap map = store.getWritableProperties(c, category, true); + WritablePropertyMap map = store.getWritableProperties(c, category, true); map.put("foo", "abc"); map.put("bar", "xyz"); map.save(); diff --git a/api/src/org/labkey/api/message/digest/MessageDigest.java b/api/src/org/labkey/api/message/digest/MessageDigest.java index 566d4c2a492..0cc99554732 100644 --- a/api/src/org/labkey/api/message/digest/MessageDigest.java +++ b/api/src/org/labkey/api/message/digest/MessageDigest.java @@ -18,6 +18,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.util.ExceptionUtil; import org.labkey.api.util.JobRunner; import org.quartz.Job; @@ -132,7 +133,7 @@ private Date getLastSuccessful() private void setLastSuccessful(Date last) { - PropertyManager.PropertyMap props = PropertyManager.getWritableProperties(getName(), true); + WritablePropertyMap props = PropertyManager.getWritableProperties(getName(), true); props.put(LAST_KEY, String.valueOf(last.getTime())); props.save(); } diff --git a/api/src/org/labkey/api/miniprofiler/MiniProfiler.java b/api/src/org/labkey/api/miniprofiler/MiniProfiler.java index db553bc461c..6c2c2fe6092 100644 --- a/api/src/org/labkey/api/miniprofiler/MiniProfiler.java +++ b/api/src/org/labkey/api/miniprofiler/MiniProfiler.java @@ -23,6 +23,7 @@ import org.labkey.api.data.BeanObjectFactory; import org.labkey.api.data.ContainerManager; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.module.ModuleLoader; import org.labkey.api.security.User; import org.labkey.api.security.permissions.TroubleshooterPermission; @@ -139,7 +140,7 @@ public static void saveSettings(@NotNull Settings settings, @NotNull User user) // Troubleshooting stacktraces are site-wide only setCollectTroubleshootingStackTraces(settings._collectTroubleshootingStackTraces); - PropertyManager.PropertyMap map = PropertyManager.getWritableProperties(user, ContainerManager.getRoot(), CATEGORY, true); + WritablePropertyMap map = PropertyManager.getWritableProperties(user, ContainerManager.getRoot(), CATEGORY, true); SETTINGS_FACTORY.toStringMap(settings, map); map.save(); SETTINGS_CACHE.remove(user); diff --git a/api/src/org/labkey/api/module/FolderTypeManager.java b/api/src/org/labkey/api/module/FolderTypeManager.java index 9e97ac41cc0..66006d80690 100644 --- a/api/src/org/labkey/api/module/FolderTypeManager.java +++ b/api/src/org/labkey/api/module/FolderTypeManager.java @@ -23,6 +23,7 @@ import org.labkey.api.data.Container; import org.labkey.api.data.ContainerManager; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.resource.Resource; import org.labkey.api.settings.StandardStartupPropertyHandler; import org.labkey.api.settings.StartupProperty; @@ -242,7 +243,7 @@ public FolderType getDefaultFolderType() */ public void setEnabledFolderTypes(Collection enabledFolderTypes, FolderType defaultFolderType) { - PropertyManager.PropertyMap enabledStates = PropertyManager.getWritableProperties(ContainerManager.getRoot(), FOLDER_TYPE_ENABLED_STATE, true); + WritablePropertyMap enabledStates = PropertyManager.getWritableProperties(ContainerManager.getRoot(), FOLDER_TYPE_ENABLED_STATE, true); // Reset completely based on the supplied config enabledStates.clear(); for (FolderType folderType : getAllFolderTypes()) @@ -253,7 +254,7 @@ public void setEnabledFolderTypes(Collection enabledFolderTypes, Fol if (defaultFolderType != null && enabledFolderTypes.contains(defaultFolderType)) { - PropertyManager.PropertyMap propDefaultFolderType = PropertyManager.getWritableProperties(ContainerManager.getRoot(), FOLDER_TYPE_DEFAULT, true); + WritablePropertyMap propDefaultFolderType = PropertyManager.getWritableProperties(ContainerManager.getRoot(), FOLDER_TYPE_DEFAULT, true); propDefaultFolderType.put(FOLDER_TYPE_DEFAULT, defaultFolderType.getName()); propDefaultFolderType.save(); } @@ -349,7 +350,7 @@ private void populateDisabledFolderTypesWithStartupProps(String value) { if (value != null) { - PropertyManager.PropertyMap enabledStates = PropertyManager.getWritableProperties(ContainerManager.getRoot(), FOLDER_TYPE_ENABLED_STATE, true); + WritablePropertyMap enabledStates = PropertyManager.getWritableProperties(ContainerManager.getRoot(), FOLDER_TYPE_ENABLED_STATE, true); for (String folderTypeName : StringUtils.split(value, ';')) enabledStates.put(folderTypeName, Boolean.toString(false)); enabledStates.save(); diff --git a/api/src/org/labkey/api/module/ModuleProperty.java b/api/src/org/labkey/api/module/ModuleProperty.java index f5c213b2a6d..7f8ef85c2bf 100644 --- a/api/src/org/labkey/api/module/ModuleProperty.java +++ b/api/src/org/labkey/api/module/ModuleProperty.java @@ -19,12 +19,12 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.json.JSONObject; -import org.labkey.api.audit.AbstractAuditTypeProvider; import org.labkey.api.audit.AuditLogService; import org.labkey.api.audit.provider.ModulePropertiesAuditProvider; import org.labkey.api.data.Container; import org.labkey.api.data.ContainerManager; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.security.User; import org.labkey.api.security.permissions.AdminPermission; import org.labkey.api.security.permissions.Permission; @@ -295,7 +295,7 @@ public void saveValue(@Nullable User user, Container c, @Nullable String value) validate(user, c, value); - PropertyManager.PropertyMap props = PropertyManager.getWritableProperties(PropertyManager.SHARED_USER, c, getCategory(), true); + WritablePropertyMap props = PropertyManager.getWritableProperties(PropertyManager.SHARED_USER, c, getCategory(), true); Object oldValue = props.get(getName()); String auditComment; if (!StringUtils.isEmpty(value)) diff --git a/api/src/org/labkey/api/security/AuthenticationManager.java b/api/src/org/labkey/api/security/AuthenticationManager.java index 94112ebfdc0..56a25bbc0f3 100644 --- a/api/src/org/labkey/api/security/AuthenticationManager.java +++ b/api/src/org/labkey/api/security/AuthenticationManager.java @@ -47,6 +47,7 @@ import org.labkey.api.data.Project; import org.labkey.api.data.PropertyManager; import org.labkey.api.data.PropertyManager.PropertyMap; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.RuntimeSQLException; import org.labkey.api.data.SimpleFilter; import org.labkey.api.data.Table; @@ -293,7 +294,7 @@ public static void saveAuthSetting(User user, String key, boolean value) private static void saveAuthSetting(User user, String key, String value, String action) { - PropertyMap props = PropertyManager.getWritableProperties(AUTHENTICATION_CATEGORY, true); + WritablePropertyMap props = PropertyManager.getWritableProperties(AUTHENTICATION_CATEGORY, true); props.put(key, value); addAuthSettingAuditEvent(user, key, action); props.save(); diff --git a/api/src/org/labkey/api/security/Encryption.java b/api/src/org/labkey/api/security/Encryption.java index 11a28212045..0da3ee1ffc5 100644 --- a/api/src/org/labkey/api/security/Encryption.java +++ b/api/src/org/labkey/api/security/Encryption.java @@ -16,6 +16,7 @@ package org.labkey.api.security; import com.google.common.primitives.Bytes; +import jakarta.servlet.ServletContext; import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; @@ -30,7 +31,7 @@ import org.labkey.api.data.ContainerManager; import org.labkey.api.data.EncryptedPropertyStore; import org.labkey.api.data.PropertyManager; -import org.labkey.api.data.PropertyManager.PropertyMap; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.PropertyStore; import org.labkey.api.module.ModuleLoader; import org.labkey.api.security.permissions.TroubleshooterPermission; @@ -53,7 +54,6 @@ import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.PBEKeySpec; import javax.crypto.spec.SecretKeySpec; -import jakarta.servlet.ServletContext; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; @@ -139,7 +139,7 @@ private static void testEncryptionKey() PropertyManager.deleteSetDirectly(PropertyManager.SHARED_USER, ContainerManager.getRoot().getId(), TEST_ENCRYPTION_CATEGORY, (EncryptedPropertyStore)PropertyManager.getEncryptedStore()); // This will likely throw if the encryption key has changed - PropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(TEST_ENCRYPTION_CATEGORY, true); + WritablePropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(TEST_ENCRYPTION_CATEGORY, true); if (map.isEmpty()) { @@ -246,7 +246,7 @@ private static byte[] getStandardSalt() if (null != salt) return Base64.decodeBase64(salt); - PropertyMap map = store.getWritableProperties(CATEGORY, true); + WritablePropertyMap map = store.getWritableProperties(CATEGORY, true); byte[] bytes = generateRandomBytes(16); map.put(SALT_KEY, Base64.encodeBase64String(bytes)); diff --git a/api/src/org/labkey/api/security/SecurityManager.java b/api/src/org/labkey/api/security/SecurityManager.java index 26b2c1d007e..b112c27f52a 100644 --- a/api/src/org/labkey/api/security/SecurityManager.java +++ b/api/src/org/labkey/api/security/SecurityManager.java @@ -49,6 +49,7 @@ import org.labkey.api.data.DbScope.Transaction; import org.labkey.api.data.Filter; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.RuntimeSQLException; import org.labkey.api.data.SQLFragment; import org.labkey.api.data.Selector; @@ -2681,7 +2682,7 @@ public static boolean shouldNewSubfoldersInheritPermissions(Container project) public static void setNewSubfoldersInheritPermissions(Container project, User user, boolean inherit) { - PropertyManager.PropertyMap props = PropertyManager.getWritableProperties(project, SUBFOLDERS_INHERIT_PERMISSIONS_NAME, true); + WritablePropertyMap props = PropertyManager.getWritableProperties(project, SUBFOLDERS_INHERIT_PERMISSIONS_NAME, true); props.put(SUBFOLDERS_INHERIT_PERMISSIONS_NAME, Boolean.toString(inherit)); props.save(); addAuditEvent(project, user, String.format("Container %s was updated so that new subfolders would " + (inherit ? "" : "not ") + "inherit security permissions", project.getName()), 0); diff --git a/api/src/org/labkey/api/settings/AbstractCustomLabelProvider.java b/api/src/org/labkey/api/settings/AbstractCustomLabelProvider.java index 710296bf0bc..c523f3458e1 100644 --- a/api/src/org/labkey/api/settings/AbstractCustomLabelProvider.java +++ b/api/src/org/labkey/api/settings/AbstractCustomLabelProvider.java @@ -7,6 +7,7 @@ import org.labkey.api.audit.provider.SiteSettingsAuditProvider; import org.labkey.api.data.Container; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.PropertyStore; import org.labkey.api.query.ValidationException; import org.labkey.api.security.User; @@ -104,7 +105,7 @@ public void saveLabels(HashMap updatedLabels, @Nullable Containe if (auditUser != null) event = getUpdateLabelEvent(labelContainer, sanitizedLabels); - PropertyManager.PropertyMap labelStore = labelContainer == null ? _normalStore.getWritableProperties(getLabelGroup(), true) : _normalStore.getWritableProperties(labelContainer, getLabelGroup(), true); + WritablePropertyMap labelStore = labelContainer == null ? _normalStore.getWritableProperties(getLabelGroup(), true) : _normalStore.getWritableProperties(labelContainer, getLabelGroup(), true); labelStore.putAll(sanitizedLabels); labelStore.save(); diff --git a/api/src/org/labkey/api/settings/AbstractWriteableSettingsGroup.java b/api/src/org/labkey/api/settings/AbstractWriteableSettingsGroup.java index 09a491b99b4..b3010386575 100644 --- a/api/src/org/labkey/api/settings/AbstractWriteableSettingsGroup.java +++ b/api/src/org/labkey/api/settings/AbstractWriteableSettingsGroup.java @@ -21,7 +21,7 @@ import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.Container; import org.labkey.api.data.PropertyManager; -import org.labkey.api.data.PropertyManager.PropertyMap; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.security.User; import org.labkey.api.util.PageFlowUtil; @@ -29,13 +29,11 @@ /** * Subclass of {@link AbstractSettingsGroup} that allows mutating the property values. - * User: adam - * Date: Aug 2, 2008 */ public abstract class AbstractWriteableSettingsGroup extends AbstractSettingsGroup { - private PropertyMap _properties = null; - private PropertyMap _oldProps = null; + private WritablePropertyMap _properties = null; + private WritablePropertyMap _oldProps = null; /** Human-readable description of these settings that's written to the audit log **/ protected abstract String getType(); @@ -46,7 +44,7 @@ protected void makeWriteable(Container c) _oldProps = getWriteableProperties(c); } - protected PropertyMap getWriteableProperties(Container c) + protected WritablePropertyMap getWriteableProperties(Container c) { return PropertyManager.getWritableProperties(getPropertyConfigUser(), c, getGroupName(), true); } diff --git a/api/src/org/labkey/api/settings/NetworkDriveProps.java b/api/src/org/labkey/api/settings/NetworkDriveProps.java index 78c11beba61..04bfc0d7937 100644 --- a/api/src/org/labkey/api/settings/NetworkDriveProps.java +++ b/api/src/org/labkey/api/settings/NetworkDriveProps.java @@ -18,6 +18,7 @@ import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.Nullable; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; public class NetworkDriveProps { @@ -75,7 +76,7 @@ private static void saveStringValue(String key, String value) { if (StringUtils.isNotBlank(value)) { - PropertyManager.PropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(NETWORK_DRIVE_CATEGORY, true); + WritablePropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(NETWORK_DRIVE_CATEGORY, true); map.put(key, value); map.save(); } diff --git a/api/src/org/labkey/api/settings/PreferenceService.java b/api/src/org/labkey/api/settings/PreferenceService.java index f9ebcdfaf20..8b0afe0a1e4 100644 --- a/api/src/org/labkey/api/settings/PreferenceService.java +++ b/api/src/org/labkey/api/settings/PreferenceService.java @@ -16,13 +16,14 @@ package org.labkey.api.settings; +import jakarta.servlet.http.HttpSession; import org.labkey.api.data.Container; import org.labkey.api.data.ContainerManager; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.security.User; import org.labkey.api.view.HttpView; -import jakarta.servlet.http.HttpSession; import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -80,7 +81,7 @@ public Container findContainerFor(String name, Container initialScope) Container c = initialScope; while (c != null) { - Map p = getPreferences(c, false); + Map p = getReadOnlyPreferences(c); if (p != null) { if (p.containsKey(name)) @@ -104,7 +105,7 @@ public boolean isInherited(String name, Container container) public void setProperty(String name, String value, Container container) { - PropertyManager.PropertyMap prefs = getPreferences(container, true); + WritablePropertyMap prefs = getWritablePreferences(container); prefs.put(name, value); prefs.save(); @@ -121,7 +122,7 @@ public void setProperty(String name, String value, User user) } else { - PropertyManager.PropertyMap prefs = getPreferences(user, true); + WritablePropertyMap prefs = getWritablePreferences(user); prefs.put(name, value); prefs.save(); } @@ -129,7 +130,7 @@ public void setProperty(String name, String value, User user) public void deleteProperty(String name, Container container) { - PropertyManager.PropertyMap prefs = getPreferences(container, true); + WritablePropertyMap prefs = getWritablePreferences(container); prefs.remove(name); prefs.save(); @@ -145,7 +146,7 @@ public void deleteProperty(String name, User user) } else { - PropertyManager.PropertyMap prefs = getPreferences(user, true); + WritablePropertyMap prefs = getWritablePreferences(user); prefs.remove(name); prefs.save(); } @@ -165,7 +166,7 @@ private Map getPreferences(Container container) while (!stack.isEmpty()) { Container c = stack.pop(); - Map p = getPreferences(c, false); + Map p = getReadOnlyPreferences(c); if (p != null) { prefs.putAll(p); @@ -193,20 +194,14 @@ private PropertyManager.PropertyMap getPreferences(User user) return PropertyManager.getProperties(user, ContainerManager.getRoot(), PREFERENCE_SERVICE_MAP_KEY); } - private PropertyManager.PropertyMap getPreferences(Container container, boolean writable) + private WritablePropertyMap getWritablePreferences(Container container) { - if (writable) - return PropertyManager.getWritableProperties(container, PREFERENCE_SERVICE_MAP_KEY, true); - else - return getReadOnlyPreferences(container); + return PropertyManager.getWritableProperties(container, PREFERENCE_SERVICE_MAP_KEY, true); } - private PropertyManager.PropertyMap getPreferences(User user, boolean writable) + private WritablePropertyMap getWritablePreferences(User user) { - if (writable) - return PropertyManager.getWritableProperties(user, ContainerManager.getRoot(), PREFERENCE_SERVICE_MAP_KEY, true); - else - return getPreferences(user); + return PropertyManager.getWritableProperties(user, ContainerManager.getRoot(), PREFERENCE_SERVICE_MAP_KEY, true); } private PropertyManager.PropertyMap getReadOnlyPreferences(Container container) diff --git a/api/src/org/labkey/api/settings/TemplateProperties.java b/api/src/org/labkey/api/settings/TemplateProperties.java index 981cbefe2f9..b8a5b7bfb8b 100644 --- a/api/src/org/labkey/api/settings/TemplateProperties.java +++ b/api/src/org/labkey/api/settings/TemplateProperties.java @@ -20,6 +20,7 @@ import org.jetbrains.annotations.Nullable; import org.labkey.api.data.Container; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.module.Module; import org.labkey.api.module.ModuleHtmlView; import org.labkey.api.module.ModuleLoader; @@ -119,7 +120,7 @@ default void setIsShowOnlyInProjectRoot(boolean showOnlyInProjectRoot) private void setProperty(String propName, String value) { - PropertyManager.PropertyMap map; + WritablePropertyMap map; Container container = getContainer(); if (container != null) diff --git a/api/src/org/labkey/api/util/DateUtil.java b/api/src/org/labkey/api/util/DateUtil.java index 1427f7ff0ab..5ac8e63a122 100644 --- a/api/src/org/labkey/api/util/DateUtil.java +++ b/api/src/org/labkey/api/util/DateUtil.java @@ -1160,7 +1160,7 @@ public static String formatIsoDate() return formatIsoDate(new Date()); } - @Deprecated // Use formatIsoDate(); + @Deprecated // Use formatIsoDate(Date); public static String formatDateISO8601(@Nullable Date date) { return formatIsoDate(date); @@ -1175,7 +1175,7 @@ public static String formatIsoDate(@Nullable Date date) return formatDateTime(date, ISO_DATE_FORMAT_STRING); } - @Deprecated // Use formatIsoDateShortTime() instead + @Deprecated // Use formatIsoDateShortTime(Date) instead public static String formatDateTimeISO8601(Date date) { return formatIsoDateShortTime(date); diff --git a/api/src/org/labkey/api/util/SystemMaintenance.java b/api/src/org/labkey/api/util/SystemMaintenance.java index 9f82710bf87..71f8288628d 100644 --- a/api/src/org/labkey/api/util/SystemMaintenance.java +++ b/api/src/org/labkey/api/util/SystemMaintenance.java @@ -21,6 +21,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.quartz.CronScheduleBuilder; import org.quartz.JobBuilder; import org.quartz.JobDetail; @@ -171,7 +172,7 @@ public static SystemMaintenanceProperties getProperties() public static void setProperties(Set enabledTasks, String time) { - PropertyManager.PropertyMap writableProps = PropertyManager.getWritableProperties(SET_NAME, true); + WritablePropertyMap writableProps = PropertyManager.getWritableProperties(SET_NAME, true); Set enabled = new HashSet<>(enabledTasks); Set disabled = getTasks().stream() @@ -189,7 +190,7 @@ public static void setProperties(Set enabledTasks, String time) public static void enableTask(String taskToEnable) { - PropertyManager.PropertyMap writableProps = PropertyManager.getWritableProperties(SET_NAME, true); + WritablePropertyMap writableProps = PropertyManager.getWritableProperties(SET_NAME, true); String disabled = writableProps.get(DISABLED_TASKS_PROPERTY_NAME); String enabled = writableProps.get(ENABLED_TASKS_PROPERTY_NAME); diff --git a/api/src/org/labkey/api/util/emailTemplate/EmailTemplateService.java b/api/src/org/labkey/api/util/emailTemplate/EmailTemplateService.java index fb8877905c9..e3b6a6d7ebe 100644 --- a/api/src/org/labkey/api/util/emailTemplate/EmailTemplateService.java +++ b/api/src/org/labkey/api/util/emailTemplate/EmailTemplateService.java @@ -20,6 +20,8 @@ import org.labkey.api.data.Container; import org.labkey.api.data.ContainerManager; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.PropertyMap; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.PropertySchema; import org.labkey.api.data.SQLFragment; import org.labkey.api.data.SqlExecutor; @@ -37,9 +39,6 @@ /** * Manages admin-customized email templates by persisting in the property store. - * - * User: Karl Lum - * Date: Jan 15, 2007 */ public class EmailTemplateService { @@ -113,12 +112,14 @@ public List getEditableEmailTemplates(Container c) return templates; } - private PropertyManager.PropertyMap getProperties(Container c, boolean writable) + private PropertyMap getProperties(Container c) + { + return PropertyManager.getProperties(c, EMAIL_TEMPLATE_PROPERTIES_MAP_NAME); + } + + private WritablePropertyMap getWritableProperties(Container c) { - if (writable) - return PropertyManager.getWritableProperties(c, EMAIL_TEMPLATE_PROPERTIES_MAP_NAME, true); - else - return PropertyManager.getProperties(c, EMAIL_TEMPLATE_PROPERTIES_MAP_NAME); + return PropertyManager.getWritableProperties(c, EMAIL_TEMPLATE_PROPERTIES_MAP_NAME, true); } private Map, EmailTemplate> _getEmailTemplates(Container c) @@ -143,7 +144,7 @@ private Map, EmailTemplate> _getEmailTemplates(Co private void addTemplates(Map, EmailTemplate> templates, Container c) { - Map map = getProperties(c, false); + Map map = getProperties(c); for (Map.Entry entry : map.entrySet()) { final String key = entry.getKey(); @@ -226,7 +227,7 @@ public void saveEmailTemplate(EmailTemplate template, Container c) { throw new NotFoundException("Cannot save template " + c + " in " + c); } - PropertyManager.PropertyMap map = getProperties(c, true); + WritablePropertyMap map = getWritableProperties(c); final String className = template.getClass().getName(); map.put(className + EMAIL_TEMPLATE_DELIM + MESSAGE_SUBJECT_PART, template.getSubject()); @@ -238,7 +239,7 @@ public void saveEmailTemplate(EmailTemplate template, Container c) public void deleteEmailTemplate(EmailTemplate template, Container c) { - PropertyManager.PropertyMap map = getProperties(c, true); + WritablePropertyMap map = getWritableProperties(c); final String className = template.getClass().getName(); map.remove(className + EMAIL_TEMPLATE_DELIM + MESSAGE_SUBJECT_PART); diff --git a/core/src/org/labkey/core/analytics/AnalyticsServiceImpl.java b/core/src/org/labkey/core/analytics/AnalyticsServiceImpl.java index 57819987757..412a91a09d0 100644 --- a/core/src/org/labkey/core/analytics/AnalyticsServiceImpl.java +++ b/core/src/org/labkey/core/analytics/AnalyticsServiceImpl.java @@ -21,6 +21,7 @@ import org.labkey.api.data.Container; import org.labkey.api.data.ContainerManager; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.module.ModuleLoader; import org.labkey.api.security.User; import org.labkey.api.settings.AbstractWriteableSettingsGroup; @@ -268,7 +269,7 @@ public String getTrackingScript(ViewContext context) public static void populateSettingsWithStartupProps() { - PropertyManager.PropertyMap properties = PropertyManager.getWritableProperties(PROP_CATEGORY, true); + WritablePropertyMap properties = PropertyManager.getWritableProperties(PROP_CATEGORY, true); ModuleLoader.getInstance().handleStartupProperties(new StandardStartupPropertyHandler<>(PROP_CATEGORY, AnalyticsProperty.class) { @Override diff --git a/core/src/org/labkey/core/login/DbLoginAuthenticationProvider.java b/core/src/org/labkey/core/login/DbLoginAuthenticationProvider.java index b2088660c2f..07ff554ce04 100644 --- a/core/src/org/labkey/core/login/DbLoginAuthenticationProvider.java +++ b/core/src/org/labkey/core/login/DbLoginAuthenticationProvider.java @@ -21,6 +21,7 @@ import org.labkey.api.cache.Throttle; import org.labkey.api.data.Container; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.module.ModuleLoader; import org.labkey.api.security.ApiKeyManager; import org.labkey.api.security.AuthenticationManager.AuthenticationValidator; @@ -187,7 +188,7 @@ public void handle(Map map) { if (!map.isEmpty()) { - PropertyManager.PropertyMap propertyMap = PropertyManager.getWritableProperties(DATABASE_AUTHENTICATION_CATEGORY_KEY, true); + WritablePropertyMap propertyMap = PropertyManager.getWritableProperties(DATABASE_AUTHENTICATION_CATEGORY_KEY, true); propertyMap.clear(); map.forEach((key, value)->propertyMap.put(key.getPropertyName(), value.getValue())); propertyMap.save(); diff --git a/core/src/org/labkey/core/login/DbLoginManager.java b/core/src/org/labkey/core/login/DbLoginManager.java index 2ab940d7519..f2bc3ad22d8 100644 --- a/core/src/org/labkey/core/login/DbLoginManager.java +++ b/core/src/org/labkey/core/login/DbLoginManager.java @@ -15,13 +15,14 @@ */ package org.labkey.core.login; +import jakarta.servlet.http.HttpServletRequest; import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; import org.labkey.api.audit.AuditLogService; import org.labkey.api.data.Container; import org.labkey.api.data.ContainerManager; import org.labkey.api.data.PropertyManager; -import org.labkey.api.data.PropertyManager.PropertyMap; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.security.AuthenticationConfigurationCache; import org.labkey.api.security.AuthenticationManager; import org.labkey.api.security.AuthenticationManager.AuthenticationResult; @@ -42,7 +43,6 @@ import org.labkey.core.login.LoginController.SaveDbLoginPropertiesForm; import org.springframework.validation.BindException; -import jakarta.servlet.http.HttpServletRequest; import java.util.Arrays; import java.util.Collection; import java.util.LinkedList; @@ -154,7 +154,7 @@ public static void saveProperties(User user, SaveDbLoginPropertiesForm form) { Map oldProperties = getProperties(); - PropertyMap map = PropertyManager.getWritableProperties(DATABASE_AUTHENTICATION_CATEGORY_KEY, true); + WritablePropertyMap map = PropertyManager.getWritableProperties(DATABASE_AUTHENTICATION_CATEGORY_KEY, true); map.clear(); map.put(Key.Strength.toString(), form.getStrength()); map.put(Key.Expiration.toString(), form.getExpiration()); diff --git a/core/src/org/labkey/core/metrics/SimpleMetricsServiceImpl.java b/core/src/org/labkey/core/metrics/SimpleMetricsServiceImpl.java index 866f612ecd5..55f26e09c3c 100644 --- a/core/src/org/labkey/core/metrics/SimpleMetricsServiceImpl.java +++ b/core/src/org/labkey/core/metrics/SimpleMetricsServiceImpl.java @@ -4,8 +4,9 @@ import org.jetbrains.annotations.NotNull; import org.labkey.api.action.SpringActionController; import org.labkey.api.data.PropertyManager; -import org.labkey.api.module.ModuleLoader; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.module.Module; +import org.labkey.api.module.ModuleLoader; import org.labkey.api.settings.AppProps; import org.labkey.api.usageMetrics.SimpleMetricsService; import org.labkey.api.usageMetrics.UsageMetricsProvider; @@ -162,7 +163,7 @@ public long increment(@NotNull String requestedModuleName, @NotNull String featu { // This is the first time we've seen a module/area combination so save the new listing immediately, // which is important so that we know to reload it after the server restarts - PropertyManager.PropertyMap updatedListing = PropertyManager.getWritableProperties(getRootScoping(), true); + WritablePropertyMap updatedListing = PropertyManager.getWritableProperties(getRootScoping(), true); String existingAreas = updatedListing.get(moduleName); String updatedAreas = existingAreas == null ? featureArea : existingAreas + "," + featureArea; updatedListing.put(moduleName, updatedAreas); @@ -223,7 +224,7 @@ private void save() Module module = ModuleLoader.getInstance().getModule(modules.getKey()); if (module != null) { - PropertyManager.PropertyMap storedProps = PropertyManager.getWritableProperties(getScoping(module, areas.getKey()), true); + WritablePropertyMap storedProps = PropertyManager.getWritableProperties(getScoping(module, areas.getKey()), true); for (Map.Entry metricCount : areas.getValue().entrySet()) { storedProps.put(metricCount.getKey(), Long.toString(metricCount.getValue().longValue())); diff --git a/core/src/org/labkey/core/notification/EmailServiceImpl.java b/core/src/org/labkey/core/notification/EmailServiceImpl.java index f427a96877a..3fa7bbb70e4 100644 --- a/core/src/org/labkey/core/notification/EmailServiceImpl.java +++ b/core/src/org/labkey/core/notification/EmailServiceImpl.java @@ -15,6 +15,18 @@ */ package org.labkey.core.notification; +import jakarta.activation.DataHandler; +import jakarta.activation.DataSource; +import jakarta.activation.FileDataSource; +import jakarta.mail.BodyPart; +import jakarta.mail.Message; +import jakarta.mail.MessagingException; +import jakarta.mail.Part; +import jakarta.mail.internet.InternetAddress; +import jakarta.mail.internet.MimeBodyPart; +import jakarta.mail.internet.MimeMessage; +import jakarta.mail.internet.MimeMultipart; +import jakarta.servlet.http.HttpServletRequest; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.Nullable; @@ -24,7 +36,7 @@ import org.junit.rules.ExpectedException; import org.labkey.api.data.Container; import org.labkey.api.data.PropertyManager; -import org.labkey.api.data.PropertyManager.PropertyMap; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.module.Module; import org.labkey.api.module.ModuleLoader; import org.labkey.api.notification.EmailMessage; @@ -40,18 +52,6 @@ import org.labkey.api.view.WebPartView; import org.springframework.mock.web.MockHttpServletResponse; -import jakarta.activation.DataHandler; -import jakarta.activation.DataSource; -import jakarta.activation.FileDataSource; -import jakarta.mail.BodyPart; -import jakarta.mail.Message; -import jakarta.mail.MessagingException; -import jakarta.mail.Part; -import jakarta.mail.internet.InternetAddress; -import jakarta.mail.internet.MimeBodyPart; -import jakarta.mail.internet.MimeMessage; -import jakarta.mail.internet.MimeMultipart; -import jakarta.servlet.http.HttpServletRequest; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; @@ -109,7 +109,7 @@ public EmailMessage createMessage(String from, List to, String subject) @Override public void setEmailPref(User user, Container container, EmailPref pref, String value) { - PropertyMap props = PropertyManager.getWritableProperties(user, container, EMAIL_PREF_CATEGORY, true); + WritablePropertyMap props = PropertyManager.getWritableProperties(user, container, EMAIL_PREF_CATEGORY, true); props.put(pref.getId(), value); props.save(); @@ -160,9 +160,8 @@ public String getDefaultEmailPref(Container container, EmailPref pref) @Override public void setDefaultEmailPref(Container container, EmailPref pref, String value) { - PropertyMap props = PropertyManager.getWritableProperties(container, EMAIL_PREF_CATEGORY, true); + WritablePropertyMap props = PropertyManager.getWritableProperties(container, EMAIL_PREF_CATEGORY, true); props.put(pref.getId(), value); - props.save(); } diff --git a/core/src/org/labkey/core/reports/ScriptEngineManagerImpl.java b/core/src/org/labkey/core/reports/ScriptEngineManagerImpl.java index 9da8921496f..a33c0cd9c8f 100644 --- a/core/src/org/labkey/core/reports/ScriptEngineManagerImpl.java +++ b/core/src/org/labkey/core/reports/ScriptEngineManagerImpl.java @@ -31,6 +31,7 @@ import org.labkey.api.data.CoreSchema; import org.labkey.api.data.DbScope; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.SQLFragment; import org.labkey.api.data.SimpleFilter; import org.labkey.api.data.SqlExecutor; @@ -626,8 +627,7 @@ private static String getProp(String prop, String mapName) private static void setProp(String prop, String value, String mapName) { - PropertyManager.PropertyMap map = PropertyManager.getWritableProperties(mapName, true); - + WritablePropertyMap map = PropertyManager.getWritableProperties(mapName, true); map.put(prop, value); map.save(); } diff --git a/issues/src/org/labkey/issue/model/IssueManager.java b/issues/src/org/labkey/issue/model/IssueManager.java index 82bf78f24bb..4d168d941dd 100644 --- a/issues/src/org/labkey/issue/model/IssueManager.java +++ b/issues/src/org/labkey/issue/model/IssueManager.java @@ -39,6 +39,7 @@ import org.labkey.api.data.Entity; import org.labkey.api.data.ObjectFactory; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.Results; import org.labkey.api.data.SQLFragment; import org.labkey.api.data.SimpleFilter; @@ -610,8 +611,8 @@ private static String getPropMapName(String issueDefName) private static void deleteProperties(Container container, String issueDefName) { - PropertyManager.PropertyMap properties = PropertyManager.getProperties(container, getPropMapName(issueDefName)); - if (!properties.isEmpty()) + WritablePropertyMap properties = PropertyManager.getWritableProperties(container, getPropMapName(issueDefName), false); + if (properties != null) { properties.delete(); } @@ -631,7 +632,7 @@ public static void saveEntryTypeNames(Container container, String issueDefName, public static void saveEntryTypeNames(Container container, String issueDefName, String singularName, String pluralName) { - PropertyManager.PropertyMap props = PropertyManager.getWritableProperties(container, getPropMapName(issueDefName), true); + WritablePropertyMap props = PropertyManager.getWritableProperties(container, getPropMapName(issueDefName), true); props.put(PROP_ENTRY_TYPE_NAME_SINGULAR, singularName); props.put(PROP_ENTRY_TYPE_NAME_PLURAL, pluralName); props.save(); @@ -644,7 +645,7 @@ private static String getPropertyValue(Container c, String issueDefName, String private static void setPropertyValue(Container c, String issueDefName, String key, String value) { - PropertyManager.PropertyMap props = PropertyManager.getWritableProperties(c, getPropMapName(issueDefName), true); + WritablePropertyMap props = PropertyManager.getWritableProperties(c, getPropMapName(issueDefName), true); props.put(key, value); props.save(); } diff --git a/mothership/src/org/labkey/mothership/MothershipManager.java b/mothership/src/org/labkey/mothership/MothershipManager.java index 694253d5716..c95e5b7ffba 100644 --- a/mothership/src/org/labkey/mothership/MothershipManager.java +++ b/mothership/src/org/labkey/mothership/MothershipManager.java @@ -27,6 +27,7 @@ import org.labkey.api.data.DbSchemaType; import org.labkey.api.data.DbScope; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.SimpleFilter; import org.labkey.api.data.SqlExecutor; import org.labkey.api.data.Table; @@ -440,7 +441,7 @@ public SqlDialect getDialect() return getSchema().getSqlDialect(); } - private PropertyManager.PropertyMap getWritableProperties(Container c) + private WritablePropertyMap getWritableProperties(Container c) { return PropertyManager.getWritableProperties(c, UPGRADE_MESSAGE_PROPERTY_CATEGORY, true); } @@ -480,7 +481,7 @@ public String getMarketingMessage(Container c) private void saveProperty(Container c, String name, String value) { - PropertyManager.PropertyMap props = getWritableProperties(c); + WritablePropertyMap props = getWritableProperties(c); props.put(name, value); props.save(); } diff --git a/mothership/test/src/org/labkey/test/tests/mothership/MothershipReportTest.java b/mothership/test/src/org/labkey/test/tests/mothership/MothershipReportTest.java index 70ab457175e..7f08e6adf0f 100644 --- a/mothership/test/src/org/labkey/test/tests/mothership/MothershipReportTest.java +++ b/mothership/test/src/org/labkey/test/tests/mothership/MothershipReportTest.java @@ -36,11 +36,15 @@ import org.labkey.test.util.mothership.MothershipHelper; import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; import java.net.URI; import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.Properties; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -97,15 +101,20 @@ public void testTopLevelItems() throws Exception checker().screenShotIfNewError("usage_report_items"); } - private String getDeployedDistributionName() + private String getDeployedDistributionName() throws IOException { - File distFile = new File(TestFileUtils.getDefaultWebAppRoot(), "WEB-INF/classes/distribution"); - if (distFile.exists()) + File propsFile = new File(TestFileUtils.getDefaultWebAppRoot(), "WEB-INF/classes/distribution.properties"); + if (propsFile.exists()) { // Deployed from distribution - return TestFileUtils.getFileContents(distFile).trim(); + Properties props = new Properties(); + try (InputStream in = new FileInputStream(propsFile)) + { + props.load(in); + } + return props.getProperty("name"); } - else if (distFile.getParentFile().isDirectory()) + else if (propsFile.getParentFile().isDirectory()) { // Local dev build return "localBuild"; diff --git a/pipeline/src/org/labkey/pipeline/api/PipelineEmailPreferences.java b/pipeline/src/org/labkey/pipeline/api/PipelineEmailPreferences.java index 2a7b7f8e66f..7178b76deb6 100644 --- a/pipeline/src/org/labkey/pipeline/api/PipelineEmailPreferences.java +++ b/pipeline/src/org/labkey/pipeline/api/PipelineEmailPreferences.java @@ -25,6 +25,7 @@ import org.labkey.api.data.Container; import org.labkey.api.data.ContainerManager; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.SimpleFilter; import org.labkey.api.data.TableSelector; import org.labkey.api.pipeline.PipelineJob; @@ -290,7 +291,7 @@ private void setNotificationTask(String interval, String startTime, Container c, private synchronized void addNotifyTask(Container c, int intervalInHours, boolean isSuccessNotification, Date nextTime) { - PropertyManager.PropertyMap taskMap = PropertyManager.getWritableProperties(PIPELINE_NOTIFICATION_TASKS, true); + WritablePropertyMap taskMap = PropertyManager.getWritableProperties(PIPELINE_NOTIFICATION_TASKS, true); final String key = getKey(c, isSuccessNotification); taskMap.put(key, c.getId()); @@ -321,7 +322,7 @@ private boolean isSuccessKey(String key) private synchronized void removeNotifyTask(Container c, boolean isSuccessNotification) { - PropertyManager.PropertyMap taskMap = PropertyManager.getWritableProperties(PIPELINE_NOTIFICATION_TASKS, true); + WritablePropertyMap taskMap = PropertyManager.getWritableProperties(PIPELINE_NOTIFICATION_TASKS, true); final String key = getKey(c, isSuccessNotification); if (taskMap.containsKey(key)) diff --git a/pipeline/src/org/labkey/pipeline/api/PipelineManager.java b/pipeline/src/org/labkey/pipeline/api/PipelineManager.java index 391aa953cee..5b89bff44c4 100644 --- a/pipeline/src/org/labkey/pipeline/api/PipelineManager.java +++ b/pipeline/src/org/labkey/pipeline/api/PipelineManager.java @@ -34,6 +34,7 @@ import org.labkey.api.data.Filter; import org.labkey.api.data.ObjectFactory; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.RuntimeSQLException; import org.labkey.api.data.SQLFragment; import org.labkey.api.data.SimpleFilter; @@ -257,7 +258,7 @@ static public void purge(Container container, User user) static void setPipelineProperty(Container container, String name, String value) { - PropertyManager.PropertyMap props = PropertyManager.getWritableProperties(container, "pipelineRoots", true); + WritablePropertyMap props = PropertyManager.getWritableProperties(container, "pipelineRoots", true); if (value == null) props.remove(name); else diff --git a/pipeline/src/org/labkey/pipeline/api/PipelineServiceImpl.java b/pipeline/src/org/labkey/pipeline/api/PipelineServiceImpl.java index 73ef6ac6bc3..cdc9410fb11 100644 --- a/pipeline/src/org/labkey/pipeline/api/PipelineServiceImpl.java +++ b/pipeline/src/org/labkey/pipeline/api/PipelineServiceImpl.java @@ -36,6 +36,7 @@ import org.labkey.api.data.ContainerManager; import org.labkey.api.data.NormalContainerType; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.SimpleFilter; import org.labkey.api.data.TableInfo; import org.labkey.api.data.TableSelector; @@ -676,7 +677,7 @@ public void rememberLastProtocolSetting(PipelineProtocolFactory factory, Contain { if (user.isGuest()) return; - PropertyManager.PropertyMap map = PropertyManager.getWritableProperties(user, container, PipelineServiceImpl.KEY_PREFERENCES, true); + WritablePropertyMap map = PropertyManager.getWritableProperties(user, container, PipelineServiceImpl.KEY_PREFERENCES, true); map.put(getLastProtocolKey(factory), protocolName); map.save(); } @@ -708,7 +709,7 @@ public void rememberLastSequenceDbSetting(PipelineProtocolFactory factory, Conta if (sequenceDbPath == null || sequenceDbPath.equals("/")) sequenceDbPath = ""; String fullPath = sequenceDbPath + sequenceDb; - PropertyManager.PropertyMap map = PropertyManager.getWritableProperties(user, container, + WritablePropertyMap map = PropertyManager.getWritableProperties(user, container, PipelineServiceImpl.KEY_PREFERENCES, true); map.put(PipelineServiceImpl.PREF_LASTSEQUENCEDB + "-" + factory.getName(), fullPath); map.save(); @@ -734,9 +735,9 @@ public void rememberLastSequenceDbPathsSetting(PipelineProtocolFactory factory, if (user.isGuest()) return; String sequenceDbPathsString = list2String(sequenceDbPathsList); - PropertyManager.PropertyMap map = PropertyManager.getWritableProperties(user, container, + WritablePropertyMap map = PropertyManager.getWritableProperties(user, container, PipelineServiceImpl.KEY_PREFERENCES, true); - if(sequenceDbPathsString == null || sequenceDbPathsString.length() == 0 || sequenceDbPathsString.length() >= 2000) + if (sequenceDbPathsString == null || sequenceDbPathsString.isEmpty() || sequenceDbPathsString.length() >= 2000) { map.remove(PipelineServiceImpl.PREF_LASTSEQUENCEDBPATHS + "-" + factory.getName()); } diff --git a/query/api-src/org/labkey/remoteapi/RemoteConnections.java b/query/api-src/org/labkey/remoteapi/RemoteConnections.java index f1c83dd140d..00683718a7e 100644 --- a/query/api-src/org/labkey/remoteapi/RemoteConnections.java +++ b/query/api-src/org/labkey/remoteapi/RemoteConnections.java @@ -20,6 +20,7 @@ import org.labkey.api.action.LabKeyError; import org.labkey.api.data.Container; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.security.ValidEmail; import org.springframework.validation.BindException; @@ -109,7 +110,7 @@ public static boolean createOrEditRemoteConnection(RemoteConnectionForm remoteCo // save the connection name in connectionMap String connectionsCategory = CONNECTION_KIND_QUERY.equals(connectionKind) ? REMOTE_QUERY_CONNECTIONS_CATEGORY : REMOTE_FILE_CONNECTIONS_CATEGORY; - PropertyManager.PropertyMap connectionMap = PropertyManager.getEncryptedStore().getWritableProperties(container, connectionsCategory, true); + WritablePropertyMap connectionMap = PropertyManager.getEncryptedStore().getWritableProperties(container, connectionsCategory, true); if ((!editing || changingName) && connectionMap.containsKey(makeRemoteConnectionKey(connectionsCategory, newName))) { errors.addError(new LabKeyError("There is already a remote connection with the name '" + newName + "'.")); @@ -128,7 +129,7 @@ public static boolean createOrEditRemoteConnection(RemoteConnectionForm remoteCo connectionMap.save(); // save the properties for the individual connection in the encrypted property store - PropertyManager.PropertyMap singleConnectionMap = PropertyManager.getEncryptedStore().getWritableProperties(container, newNameKey, true); + WritablePropertyMap singleConnectionMap = PropertyManager.getEncryptedStore().getWritableProperties(container, newNameKey, true); singleConnectionMap.put(RemoteConnections.FIELD_URL, url); singleConnectionMap.put(RemoteConnections.FIELD_USER, user); singleConnectionMap.put(RemoteConnections.FIELD_PASSWORD, password); @@ -144,7 +145,7 @@ public static boolean deleteRemoteConnection(RemoteConnectionForm remoteConnecti // delete the index String connectionsCategory = CONNECTION_KIND_QUERY.equals(remoteConnectionForm.getConnectionKind()) ? REMOTE_QUERY_CONNECTIONS_CATEGORY : REMOTE_FILE_CONNECTIONS_CATEGORY; - PropertyManager.PropertyMap connectionMap = PropertyManager.getEncryptedStore().getWritableProperties(container, connectionsCategory, false); + WritablePropertyMap connectionMap = PropertyManager.getEncryptedStore().getWritableProperties(container, connectionsCategory, false); connectionMap.remove(makeRemoteConnectionKey(connectionsCategory, name)); connectionMap.save(); diff --git a/query/src/org/labkey/query/controllers/OlapController.java b/query/src/org/labkey/query/controllers/OlapController.java index d4a474fd9bb..66ff86fea73 100644 --- a/query/src/org/labkey/query/controllers/OlapController.java +++ b/query/src/org/labkey/query/controllers/OlapController.java @@ -50,6 +50,7 @@ import org.labkey.api.data.CoreSchema; import org.labkey.api.data.DbSchema; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.PropertyStore; import org.labkey.api.data.QueryLogging; import org.labkey.api.data.RuntimeSQLException; @@ -1274,7 +1275,7 @@ private Map getSinglePageAppContext(Container c, String contextN private void updateSinglePageAppContext(Container c, String contextName, JSONObject defaults, JSONObject values) { - PropertyManager.PropertyMap map = PropertyManager.getWritableProperties(c, APP_CONTEXT_CATEGORY + ":" + contextName, true); + WritablePropertyMap map = PropertyManager.getWritableProperties(c, APP_CONTEXT_CATEGORY + ":" + contextName, true); if (defaults != null) map.put(APP_CONTEXT_DEFAULTS, defaults.toString(APP_CONTEXT_JSON_INDENT)); @@ -1283,12 +1284,11 @@ private void updateSinglePageAppContext(Container c, String contextName, JSONObj map.save(); - PropertyManager.PropertyMap allContexts = PropertyManager.getWritableProperties(c, APP_CONTEXT_CATEGORY, true); + WritablePropertyMap allContexts = PropertyManager.getWritableProperties(c, APP_CONTEXT_CATEGORY, true); allContexts.put(contextName, contextName); allContexts.save(); } - @NotNull private void deleteSinglePageAppContexts(Container c, String contextName) { // Delete the context settings @@ -1522,7 +1522,7 @@ public class SetActiveAppConfigAction extends MutatingApiAction @Override public Object execute(AppForm form, BindException errors) { - PropertyManager.PropertyMap activeAppConfig = PropertyManager.getWritableProperties(getContainer(), APP_ACTIVE_CONFIG_CATEGORY, true); + WritablePropertyMap activeAppConfig = PropertyManager.getWritableProperties(getContainer(), APP_ACTIVE_CONFIG_CATEGORY, true); activeAppConfig.put("configId", form.getConfigId()); activeAppConfig.put("name", form.getName()); activeAppConfig.put("schemaName", form.getSchemaName()); diff --git a/query/src/org/labkey/query/controllers/QueryController.java b/query/src/org/labkey/query/controllers/QueryController.java index f641a8c2f8c..017e442c9a9 100644 --- a/query/src/org/labkey/query/controllers/QueryController.java +++ b/query/src/org/labkey/query/controllers/QueryController.java @@ -60,6 +60,7 @@ import org.labkey.api.collections.Sets; import org.labkey.api.data.*; import org.labkey.api.data.PropertyManager.PropertyMap; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.dialect.JdbcMetaDataLocator; import org.labkey.api.data.dialect.SqlDialect; import org.labkey.api.dataiterator.DataIteratorBuilder; @@ -847,7 +848,9 @@ public void validateCommand(TestDataSourceForm target, Errors errors) @Override public boolean handlePost(TestDataSourceForm form, BindException errors) throws Exception { - PropertyManager.getWritableProperties(getCategory(form.getDataSource()), false).delete(); + WritablePropertyMap map = PropertyManager.getWritableProperties(getCategory(form.getDataSource()), false); + if (map != null) + map.delete(); return true; } @@ -869,7 +872,7 @@ private static String getCategory(String dataSourceName) public static void saveTestDataSourceProperties(TestDataSourceConfirmForm form) { - PropertyMap map = PropertyManager.getWritableProperties(getCategory(form.getDataSource()), true); + WritablePropertyMap map = PropertyManager.getWritableProperties(getCategory(form.getDataSource()), true); // Save empty entries as empty string to distinguish from null (which results in default values) map.put(TEST_DATA_SOURCE_SCHEMAS_PROPERTY, StringUtils.trimToEmpty(form.getExcludeSchemas())); map.put(TEST_DATA_SOURCE_TABLES_PROPERTY, StringUtils.trimToEmpty(form.getExcludeTables())); diff --git a/search/src/org/labkey/search/model/SearchPropertyManager.java b/search/src/org/labkey/search/model/SearchPropertyManager.java index 450c1dfa1b2..de98148884c 100644 --- a/search/src/org/labkey/search/model/SearchPropertyManager.java +++ b/search/src/org/labkey/search/model/SearchPropertyManager.java @@ -18,6 +18,7 @@ import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.Nullable; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.files.FileContentService; import org.labkey.api.search.SearchService; import org.labkey.api.security.User; @@ -115,7 +116,7 @@ private static String getProperty(String key) private static void setProperty(String key, String value) { - PropertyManager.PropertyMap m = PropertyManager.getWritableProperties(CATEGORY, true); + WritablePropertyMap m = PropertyManager.getWritableProperties(CATEGORY, true); m.put(key, value); m.save(); } diff --git a/specimen/src/org/labkey/specimen/actions/SpecimenController.java b/specimen/src/org/labkey/specimen/actions/SpecimenController.java index 44632ab5ef4..7a5a0657c84 100644 --- a/specimen/src/org/labkey/specimen/actions/SpecimenController.java +++ b/specimen/src/org/labkey/specimen/actions/SpecimenController.java @@ -50,6 +50,7 @@ import org.labkey.api.data.MenuButton; import org.labkey.api.data.ObjectFactory; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.RenderContext; import org.labkey.api.data.SimpleDisplayColumn; import org.labkey.api.data.SimpleFilter; @@ -5277,7 +5278,7 @@ public ModelAndView getView(EnabledSpecimenImportForm form, boolean reshow, Bind @Override public boolean handlePost(EnabledSpecimenImportForm form, BindException errors) throws Exception { - PropertyManager.PropertyMap props = PropertyManager.getWritableProperties(getContainer(), "enabledSpecimenImporter", true); + WritablePropertyMap props = PropertyManager.getWritableProperties(getContainer(), "enabledSpecimenImporter", true); props.put("active", form.getActiveTransform()); props.save(); return true; diff --git a/specimen/src/org/labkey/specimen/requirements/DefaultRequirementProvider.java b/specimen/src/org/labkey/specimen/requirements/DefaultRequirementProvider.java index 1468a56cea3..cc007f149ac 100644 --- a/specimen/src/org/labkey/specimen/requirements/DefaultRequirementProvider.java +++ b/specimen/src/org/labkey/specimen/requirements/DefaultRequirementProvider.java @@ -19,6 +19,7 @@ import org.labkey.api.data.Container; import org.labkey.api.data.DbScope; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.SimpleFilter; import org.labkey.api.data.Sort; import org.labkey.api.data.TableInfo; @@ -84,7 +85,7 @@ public R createDefaultRequirement(User user, R requirement, RequirementType type private synchronized String getDefaultRequirementPlaceholder(final Container container, RequirementType type, boolean createIfMissing) { - PropertyManager.PropertyMap props = PropertyManager.getWritableProperties(container, + WritablePropertyMap props = PropertyManager.getWritableProperties(container, "DefaultRequirement: " + getClass().getSimpleName(), true); String ownerEntityId = props.get(type.name()); if (ownerEntityId == null && createIfMissing) diff --git a/specimen/src/org/labkey/specimen/settings/SettingsManager.java b/specimen/src/org/labkey/specimen/settings/SettingsManager.java index fcff7ea8b4d..32d8ab95fd0 100644 --- a/specimen/src/org/labkey/specimen/settings/SettingsManager.java +++ b/specimen/src/org/labkey/specimen/settings/SettingsManager.java @@ -3,6 +3,7 @@ import org.labkey.api.action.SpringActionController; import org.labkey.api.data.Container; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.security.User; import org.labkey.api.security.UserManager; import org.labkey.api.specimen.settings.DisplaySettings; @@ -46,7 +47,7 @@ public RequestNotificationSettings getRequestNotificationSettings(Container cont public void saveRequestNotificationSettings(Container container, RequestNotificationSettings settings) { - PropertyManager.PropertyMap settingsMap = PropertyManager.getWritableProperties(UserManager.getGuestUser(), + WritablePropertyMap settingsMap = PropertyManager.getWritableProperties(UserManager.getGuestUser(), container, "SpecimenRequestNotifications", true); settings.populateMap(settingsMap); settingsMap.save(); @@ -54,7 +55,7 @@ public void saveRequestNotificationSettings(Container container, RequestNotifica public void saveDisplaySettings(Container container, DisplaySettings settings) { - PropertyManager.PropertyMap settingsMap = PropertyManager.getWritableProperties(UserManager.getGuestUser(), + WritablePropertyMap settingsMap = PropertyManager.getWritableProperties(UserManager.getGuestUser(), container, "SpecimenRequestDisplay", true); settings.populateMap(settingsMap); settingsMap.save(); @@ -62,7 +63,7 @@ public void saveDisplaySettings(Container container, DisplaySettings settings) public void saveStatusSettings(Container container, StatusSettings settings) { - PropertyManager.PropertyMap settingsMap = PropertyManager.getWritableProperties(UserManager.getGuestUser(), + WritablePropertyMap settingsMap = PropertyManager.getWritableProperties(UserManager.getGuestUser(), container, "SpecimenRequestStatus", true); settings.populateMap(settingsMap); settingsMap.save(); @@ -70,7 +71,7 @@ public void saveStatusSettings(Container container, StatusSettings settings) public void saveRepositorySettings(Container container, RepositorySettings settings) { - PropertyManager.PropertyMap settingsMap = PropertyManager.getWritableProperties(UserManager.getGuestUser(), + WritablePropertyMap settingsMap = PropertyManager.getWritableProperties(UserManager.getGuestUser(), container, "SpecimenRepositorySettings", true); settings.populateMap(settingsMap); settingsMap.save(); diff --git a/study/api-src/org/labkey/api/specimen/query/BaseSpecimenPivotTable.java b/study/api-src/org/labkey/api/specimen/query/BaseSpecimenPivotTable.java index 831b9efbefb..a6a4238b3ec 100644 --- a/study/api-src/org/labkey/api/specimen/query/BaseSpecimenPivotTable.java +++ b/study/api-src/org/labkey/api/specimen/query/BaseSpecimenPivotTable.java @@ -24,7 +24,7 @@ import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.MutableColumnInfo; import org.labkey.api.data.PropertyManager; -import org.labkey.api.data.PropertyManager.PropertyMap; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.TableInfo; import org.labkey.api.query.AliasedColumn; import org.labkey.api.query.FilteredTable; @@ -148,7 +148,7 @@ public void put(String key, int rowId) { synchronized (_container) { - PropertyMap typeNameIdMapWritable = PropertyManager.getWritableProperties(_container, CATEGORY_NAME, true); + WritablePropertyMap typeNameIdMapWritable = PropertyManager.getWritableProperties(_container, CATEGORY_NAME, true); String keyWithId = getKeyWithId(key, rowId); if (!typeNameIdMapWritable.containsKey(keyWithId)) diff --git a/study/src/org/labkey/study/controllers/StudyController.java b/study/src/org/labkey/study/controllers/StudyController.java index 2461ad98277..0eb11b45adf 100644 --- a/study/src/org/labkey/study/controllers/StudyController.java +++ b/study/src/org/labkey/study/controllers/StudyController.java @@ -78,6 +78,7 @@ import org.labkey.api.data.DbScope; import org.labkey.api.data.DisplayColumn; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.RenderContext; import org.labkey.api.data.Results; import org.labkey.api.data.ResultsFactory; @@ -5351,7 +5352,7 @@ public static String getDefaultView(ViewContext context, int datasetId) private void setDefaultView(int datasetId, String view) { - PropertyManager.PropertyMap viewMap = PropertyManager.getWritableProperties(getUser(), + WritablePropertyMap viewMap = PropertyManager.getWritableProperties(getUser(), getContainer(), DEFAULT_DATASET_VIEW, true); viewMap.put(Integer.toString(datasetId), view); @@ -7417,7 +7418,7 @@ public boolean handlePost(MasterPatientProviderSettings form, BindException erro MasterPatientIndexService svc = MasterPatientIndexService.getProvider(form.getType()); if (svc != null) { - PropertyManager.PropertyMap map = PropertyManager.getNormalStore().getWritableProperties(MasterPatientProviderSettings.CATEGORY, true); + WritablePropertyMap map = PropertyManager.getNormalStore().getWritableProperties(MasterPatientProviderSettings.CATEGORY, true); map.put(MasterPatientProviderSettings.TYPE, form.getType()); map.save(); diff --git a/study/src/org/labkey/study/model/StudyManager.java b/study/src/org/labkey/study/model/StudyManager.java index 0dbe6197fd4..4eafd54c855 100644 --- a/study/src/org/labkey/study/model/StudyManager.java +++ b/study/src/org/labkey/study/model/StudyManager.java @@ -60,6 +60,7 @@ import org.labkey.api.data.JdbcType; import org.labkey.api.data.PHI; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.RuntimeSQLException; import org.labkey.api.data.SQLFragment; import org.labkey.api.data.SimpleFilter; @@ -913,7 +914,7 @@ private boolean updateDatasetPropertyOverrides(User user, final DatasetDefinitio // update the override map Container c = datasetDefinition.getContainer(); String category = "dataset-overrides:" + datasetDefinition.getDatasetId(); - PropertyManager.PropertyMap map = null; + WritablePropertyMap map = null; if (!add.isEmpty()) { diff --git a/wiki/src/org/labkey/wiki/WikiController.java b/wiki/src/org/labkey/wiki/WikiController.java index 92d6dd319bf..6de6c06eb89 100644 --- a/wiki/src/org/labkey/wiki/WikiController.java +++ b/wiki/src/org/labkey/wiki/WikiController.java @@ -16,6 +16,7 @@ package org.labkey.wiki; +import jakarta.servlet.ServletException; import org.apache.commons.collections4.MultiValuedMap; import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; import org.apache.commons.lang3.StringUtils; @@ -42,6 +43,7 @@ import org.labkey.api.data.Container; import org.labkey.api.data.ContainerManager; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.exceptions.OptimisticConflictException; import org.labkey.api.module.FolderType; import org.labkey.api.module.FolderTypeManager; @@ -98,7 +100,6 @@ import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.Controller; -import jakarta.servlet.ServletException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -2308,7 +2309,7 @@ protected ApiResponse insertWiki(SaveWikiForm form) throws Exception //save the user's new page format so we can use it //as the default for the next new page - PropertyManager.PropertyMap properties = PropertyManager.getWritableProperties( + WritablePropertyMap properties = PropertyManager.getWritableProperties( user, c, SetEditorPreferenceAction.CAT_EDITOR_PREFERENCE, true); properties.put(PROP_DEFAULT_FORMAT, wikiversion.getRendererTypeEnum().name()); properties.save(); @@ -2659,7 +2660,7 @@ public class SetEditorPreferenceAction extends MutatingApiAction