Skip to content

Commit

Permalink
Use WritablePropertyMap (#450)
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-adam authored Oct 2, 2024
1 parent 1d534aa commit 6cdbf76
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 33 deletions.
11 changes: 6 additions & 5 deletions lincs/src/org/labkey/lincs/LincsController.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.json.JSONObject;
import org.labkey.api.action.MutatingApiAction;
import org.labkey.api.action.ReadOnlyApiAction;
import org.labkey.api.action.ApiResponse;
import org.labkey.api.action.ApiSimpleResponse;
import org.labkey.api.action.ApiUsageException;
import org.labkey.api.action.FormHandlerAction;
import org.labkey.api.action.FormViewAction;
import org.labkey.api.action.LabKeyError;
import org.labkey.api.action.MutatingApiAction;
import org.labkey.api.action.ReadOnlyApiAction;
import org.labkey.api.action.SimpleErrorView;
import org.labkey.api.action.SimpleViewAction;
import org.labkey.api.action.SpringActionController;
Expand All @@ -37,6 +37,7 @@
import org.labkey.api.data.DataRegion;
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.SimpleDisplayColumn;
import org.labkey.api.data.TableInfo;
Expand Down Expand Up @@ -1017,7 +1018,7 @@ public void validateCommand(ClueCredentialsForm target, Errors errors) {}
@Override
public boolean handlePost(ClueCredentialsForm form, BindException errors)
{
PropertyManager.PropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(getContainer(), LINCS_CLUE_CREDENTIALS, true);
WritablePropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(getContainer(), LINCS_CLUE_CREDENTIALS, true);
map.put(CLUE_SERVER_URI, form.getServerUri());
map.put(CLUE_API_KEY, form.getApiKey());
map.save();
Expand Down Expand Up @@ -1045,8 +1046,8 @@ public ModelAndView getSuccessView(ClueCredentialsForm form)
@Override
public ModelAndView getView(ClueCredentialsForm form, boolean reshow, BindException errors)
{
PropertyManager.PropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(getContainer(), LINCS_CLUE_CREDENTIALS, false);
if(map != null)
WritablePropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(getContainer(), LINCS_CLUE_CREDENTIALS, false);
if (map != null)
{
form.setServerUri(map.get(CLUE_SERVER_URI));
form.setApiKey(map.get(CLUE_API_KEY));
Expand Down
3 changes: 2 additions & 1 deletion lincs/src/org/labkey/lincs/cromwell/CromwellConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,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 java.net.URI;
import java.net.URISyntaxException;
Expand Down Expand Up @@ -68,7 +69,7 @@ public URI getAbortUri(String cromwellJobId)

public void save(@NotNull Container container)
{
PropertyManager.PropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(container, PROPS_CROMWELL, true);
WritablePropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(container, PROPS_CROMWELL, true);
map.put(PROP_CROMWELL_SERVER_URL, getCromwellServerUrl());
map.put(PROP_CROMWELL_SERVER_PORT, String.valueOf(getCromwellServerPort()));
map.save();
Expand Down
3 changes: 2 additions & 1 deletion lincs/src/org/labkey/lincs/psp/LincsPspUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.json.JSONObject;
import org.labkey.api.data.Container;
import org.labkey.api.data.PropertyManager;
import org.labkey.api.data.PropertyManager.WritablePropertyMap;
import org.labkey.api.files.FileContentService;
import org.labkey.api.security.User;
import org.labkey.api.targetedms.ITargetedMSRun;
Expand Down Expand Up @@ -35,7 +36,7 @@ public static PspEndpoint getPspEndpoint(Container container) throws LincsPspExc
try
{
// Only run if the psp endpoint configuration has been saved in the container
PropertyManager.PropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(container, LincsController.LINCS_CLUE_CREDENTIALS, false);
WritablePropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(container, LincsController.LINCS_CLUE_CREDENTIALS, false);
if(map != null)
{
pspUrl = map.get(LincsController.CLUE_SERVER_URI);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import org.labkey.api.data.DbScope;
import org.labkey.api.data.NormalContainerType;
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;
Expand Down Expand Up @@ -127,7 +128,6 @@
import org.labkey.api.util.ExceptionUtil;
import org.labkey.api.util.FileUtil;
import org.labkey.api.util.HtmlString;
import org.labkey.api.util.HtmlStringBuilder;
import org.labkey.api.util.Link;
import org.labkey.api.util.PageFlowUtil;
import org.labkey.api.util.Pair;
Expand Down Expand Up @@ -204,7 +204,6 @@
import org.labkey.panoramapublic.view.publish.CatalogEntryWebPart;
import org.springframework.validation.BindException;
import org.springframework.validation.Errors;
import org.springframework.validation.ObjectError;
import org.springframework.web.servlet.ModelAndView;

import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -981,7 +980,7 @@ public void validateCommand(DataCiteCredentialsForm form, Errors errors)
@Override
public boolean handlePost(DataCiteCredentialsForm form, BindException errors)
{
PropertyManager.PropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(DataCiteService.CREDENTIALS, true);
WritablePropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(DataCiteService.CREDENTIALS, true);
map.put(DataCiteService.USER, form.getProdUser());
map.put(DataCiteService.PASSWORD, form.getPassword());
map.put(DataCiteService.PREFIX, form.getDoiPrefix());
Expand Down Expand Up @@ -1013,7 +1012,7 @@ public ModelAndView getView(DataCiteCredentialsForm form, boolean reshow, BindEx
{
if(!reshow)
{
PropertyManager.PropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(DataCiteService.CREDENTIALS, false);
WritablePropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(DataCiteService.CREDENTIALS, false);
if(map != null)
{
// Force the user to re-enter the passwords; do not set them in the form
Expand Down Expand Up @@ -1132,7 +1131,7 @@ public void validateCommand(PXCredentialsForm form, Errors errors)
@Override
public boolean handlePost(PXCredentialsForm form, BindException errors)
{
PropertyManager.PropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(ProteomeXchangeService.PX_CREDENTIALS, true);
WritablePropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(ProteomeXchangeService.PX_CREDENTIALS, true);
map.put(ProteomeXchangeService.PX_USER, form.getUserName());
map.put(ProteomeXchangeService.PX_PASSWORD, form.getPassword());
map.save();
Expand Down Expand Up @@ -1160,7 +1159,7 @@ public ModelAndView getView(PXCredentialsForm form, boolean reshow, BindExceptio
{
if(!reshow)
{
PropertyManager.PropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(ProteomeXchangeService.PX_CREDENTIALS, false);
WritablePropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(ProteomeXchangeService.PX_CREDENTIALS, false);
if(map != null)
{
String user = map.get(ProteomeXchangeService.PX_USER);
Expand Down Expand Up @@ -4277,7 +4276,7 @@ public void addNavTrail(NavTree root)
@Override
public boolean handlePost(PxActionsForm form, BindException errors) throws ProteomeXchangeServiceException, PxException
{
PropertyManager.PropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(ProteomeXchangeService.PX_CREDENTIALS, false);
WritablePropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(ProteomeXchangeService.PX_CREDENTIALS, false);
String pxUser = null;
String pxPassword = null;
if(map != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.jetbrains.annotations.Nullable;
import org.json.JSONObject;
import org.labkey.api.data.PropertyManager;
import org.labkey.api.data.PropertyManager.WritablePropertyMap;
import org.labkey.api.util.Link;
import org.labkey.panoramapublic.model.ExperimentAnnotations;

Expand Down Expand Up @@ -182,7 +183,7 @@ private static DataCiteResponse doRequest(DataCiteConfig config, @Nullable JSONO
*/
private static DataCiteConfig getDataCiteConfig(boolean test) throws DataCiteException
{
PropertyManager.PropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(DataCiteService.CREDENTIALS, false);
WritablePropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(DataCiteService.CREDENTIALS, false);
return getConfig(map, null, test);
}

Expand All @@ -195,7 +196,7 @@ private static DataCiteConfig getDataCiteConfig(boolean test) throws DataCiteExc
@NotNull
private static DataCiteConfig getDataCiteConfig(@NotNull String doi) throws DataCiteException
{
PropertyManager.PropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(DataCiteService.CREDENTIALS, false);
WritablePropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(DataCiteService.CREDENTIALS, false);
DataCiteConfig testConfig = getConfig(map, doi, true);
DataCiteConfig config = getConfig(map, doi, false);
if(testConfig.hasPrefix(doi))
Expand All @@ -209,7 +210,7 @@ private static DataCiteConfig getDataCiteConfig(@NotNull String doi) throws Data
throw new DataCiteException("Unrecognized prefix in DOI: " + doi);
}

private static DataCiteConfig getConfig(PropertyManager.PropertyMap map, @Nullable String doi, boolean test) throws DataCiteException
private static DataCiteConfig getConfig(WritablePropertyMap map, @Nullable String doi, boolean test) throws DataCiteException
{
if(map == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.labkey.api.data.ContainerManager;
import org.labkey.api.data.DbScope;
import org.labkey.api.data.PropertyManager;
import org.labkey.api.data.PropertyManager.PropertyMap;
import org.labkey.api.exp.api.ExpData;
import org.labkey.api.exp.api.ExperimentService;
import org.labkey.api.files.FileContentService;
Expand Down Expand Up @@ -750,8 +751,8 @@ private static void addChar(List<Character> categoryChars, List<Character> passw

private void assignPxId(ExperimentAnnotations targetExpt, boolean useTestDb) throws ProteomeXchangeServiceException
{
PropertyManager.PropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(ProteomeXchangeService.PX_CREDENTIALS, false);
if(map != null)
PropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(ProteomeXchangeService.PX_CREDENTIALS, false);
if (map != null)
{
String user = map.get(ProteomeXchangeService.PX_USER);
String password = map.get(ProteomeXchangeService.PX_PASSWORD);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.labkey.api.data.ContainerManager;
import org.labkey.api.data.DbScope;
import org.labkey.api.data.PropertyManager;
import org.labkey.api.data.PropertyManager.WritablePropertyMap;
import org.labkey.api.exp.api.ExpExperiment;
import org.labkey.api.exp.api.ExperimentService;
import org.labkey.api.pipeline.AbstractTaskFactory;
Expand Down Expand Up @@ -120,7 +121,7 @@ private static void copyLibraryState(Container container, Container sourceContai
if (null != versionStr)
{
log.info(String.format("Setting the value of property '%s' to '%s'.", TargetedMSService.PROP_CHROM_LIB_REVISION, versionStr));
PropertyManager.PropertyMap targetPropMap = PropertyManager.getWritableProperties(container, TargetedMSService.MODULE_NAME, true);
WritablePropertyMap targetPropMap = PropertyManager.getWritableProperties(container, TargetedMSService.MODULE_NAME, true);
targetPropMap.put(TargetedMSService.PROP_CHROM_LIB_REVISION, versionStr);
targetPropMap.save();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@
import org.labkey.api.data.CompareType;
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.Table;
import org.labkey.api.data.TableSelector;
import org.labkey.api.query.FieldKey;
import org.labkey.api.security.User;
import org.labkey.api.view.ShortURLRecord;
import org.labkey.panoramapublic.PanoramaPublicManager;
import org.labkey.panoramapublic.catalog.CatalogEntrySettings;
import org.labkey.panoramapublic.catalog.CatalogImageAttachmentParent;
import org.labkey.panoramapublic.PanoramaPublicManager;
import org.labkey.panoramapublic.model.CatalogEntry;
import org.labkey.panoramapublic.model.ExperimentAnnotations;

Expand Down Expand Up @@ -210,7 +211,7 @@ private static List<Integer> getSubList(List<Integer> entryIdList, int displayCo

public static CatalogEntrySettings getCatalogEntrySettings()
{
PropertyManager.PropertyMap map = PropertyManager.getNormalStore().getWritableProperties(PANORAMA_PUBLIC_CATALOG, false);
WritablePropertyMap map = PropertyManager.getNormalStore().getWritableProperties(PANORAMA_PUBLIC_CATALOG, false);
if (map != null)
{
if (Boolean.parseBoolean(map.get(CATALOG_ENTRY_ENABLED)))
Expand All @@ -231,7 +232,7 @@ public static void saveCatalogEntrySettings(boolean enabled, @Nullable Long maxF
@Nullable Integer imgHeight, @Nullable Integer maxTextChars,
@Nullable Integer maxEntries)
{
PropertyManager.PropertyMap map = PropertyManager.getNormalStore().getWritableProperties(CatalogEntryManager.PANORAMA_PUBLIC_CATALOG, true);
WritablePropertyMap map = PropertyManager.getNormalStore().getWritableProperties(CatalogEntryManager.PANORAMA_PUBLIC_CATALOG, true);
map.put(CatalogEntryManager.CATALOG_ENTRY_ENABLED, Boolean.toString(enabled));
map.put(CatalogEntryManager.CATALOG_MAX_FILE_SIZE, maxFileSize != null ? String.valueOf(maxFileSize) : null);
map.put(CatalogEntryManager.CATALOG_IMG_WIDTH, imgWidth !=null ? String.valueOf(imgWidth) : null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.labkey.api.admin.FolderExportPermission;
import org.labkey.api.data.Container;
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.SqlSelector;
Expand Down Expand Up @@ -367,7 +368,7 @@ public static User getJournalAdminUser(Journal journal)

public static @Nullable PublicDataUser getPublicDataUser(@NotNull Journal journal)
{
PropertyManager.PropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(journal.getProject(), PUBLIC_DATA_USER, false);
WritablePropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(journal.getProject(), PUBLIC_DATA_USER, false);
if(map != null && map.get(USER_ID) != null)
{
User user = UserManager.getUser(Integer.parseInt(map.get(USER_ID)));
Expand All @@ -382,7 +383,7 @@ public static User getJournalAdminUser(Journal journal)

public static void savePublicDataUser(@NotNull Journal journal, @NotNull User user, @NotNull String password)
{
PropertyManager.PropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(journal.getProject(), PUBLIC_DATA_USER, true);
WritablePropertyMap map = PropertyManager.getEncryptedStore().getWritableProperties(journal.getProject(), PUBLIC_DATA_USER, true);
map.put(USER_ID, String.valueOf(user.getUserId()));
map.put(USER_PASSWORD, password);
map.save();
Expand Down
5 changes: 3 additions & 2 deletions signup/src/org/labkey/signup/SignUpAdmin.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
<%@ page import="org.labkey.api.data.Container" %>
<%@ page import="org.labkey.api.data.ContainerManager" %>
<%@ page import="org.labkey.api.data.PropertyManager" %>
<%@ page import="org.labkey.api.data.PropertyManager.WritablePropertyMap" %>
<%@ page import="org.labkey.api.security.Group" %>
<%@ page import="org.labkey.api.security.SecurityManager" %>
<%@ page import="org.labkey.api.security.User" %>
<%@ page import="org.labkey.api.view.HttpView" %>
<%@ page import="org.labkey.api.view.JspView" %>
<%@ page import="org.labkey.api.view.template.ClientDependencies" %>
<%@ page import="org.labkey.signup.SignUpController.AddGroupChangeProperty" %>
<%@ page import="org.labkey.signup.SignUpController.AddPropertyAction" %>
<%@ page import="org.labkey.signup.SignUpController.RemoveGroupChangeProperty" %>
Expand All @@ -18,7 +20,6 @@
<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.Set" %>
<%@ page import="org.labkey.api.view.template.ClientDependencies" %>
<%@ page extends="org.labkey.api.jsp.JspBase" %>

<%!
Expand Down Expand Up @@ -135,7 +136,7 @@
<th>Group B</th>
<th>&nbsp;</th>
</tr>
<% PropertyManager.PropertyMap groupToGroup = PropertyManager.getWritableProperties(SignUpModule.SIGNUP_GROUP_TO_GROUP, true);
<% WritablePropertyMap groupToGroup = PropertyManager.getWritableProperties(SignUpModule.SIGNUP_GROUP_TO_GROUP, true);
Set<String> keySet = groupToGroup.keySet();
for(String key: keySet) {
List<String> rules = Arrays.asList(groupToGroup.get(key).split("\\s*,\\s*"));
Expand Down
Loading

0 comments on commit 6cdbf76

Please sign in to comment.