Skip to content
Merged
14 changes: 13 additions & 1 deletion api/src/org/labkey/api/audit/query/DefaultAuditTypeTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,14 @@
import org.labkey.api.query.QueryUpdateService;
import org.labkey.api.query.UserSchema;
import org.labkey.api.query.column.BuiltInColumnTypes;
import org.labkey.api.security.SecurityManager;
import org.labkey.api.security.User;
import org.labkey.api.security.UserPrincipal;
import org.labkey.api.security.permissions.Permission;
import org.labkey.api.security.permissions.ReadPermission;
import org.labkey.api.security.roles.CanSeeAuditLogRole;
import org.labkey.api.security.roles.Role;
import org.labkey.api.security.roles.RoleManager;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -114,7 +119,14 @@ protected void initColumns()
@Override
protected SimpleFilter.FilterClause getContainerFilterClause(ContainerFilter filter, FieldKey fieldKey)
{
return filter.createFilterClause(getSchema(), fieldKey, CanSeeAuditLogPermission.class, Set.of());
// TODO: Setting a contextual role on the container filter clause should not be necessary; the user passed
// (separately) to the ContainerFilter should have the appropriate permission. However, some app actions
// (GetTransactionRowIdsAction, maybe GetLocationHistoryAction, etc.) have been relying on this behavior. Clean
// this up soon, but not for 26.3. Note that this is the only code path that passes contextual roles into
// createFilterClause(), so we could eliminate that option during clean up.
User user = (null == getUserSchema()) ? null : getUserSchema().getUser();
Set<Role> roles = SecurityManager.canSeeAuditLog(user) ? RoleManager.roleSet(CanSeeAuditLogRole.class) : null;
return filter.createFilterClause(getSchema(), fieldKey, CanSeeAuditLogPermission.class, roles);
}

// Subclasses may override this to provide customizations to the column
Expand Down
4 changes: 2 additions & 2 deletions api/src/org/labkey/api/data/ContainerFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ public SimpleFilter.FilterClause createFilterClause(DbSchema schema, FieldKey co
}

/** Create a FilterClause that restricts based on the containers that meet the filter and user that meets the permission*/
public SimpleFilter.FilterClause createFilterClause(DbSchema schema, FieldKey containerFilterColumn, Class<? extends Permission> permission, Set<Role> roles)
public SimpleFilter.FilterClause createFilterClause(DbSchema schema, FieldKey containerFilterColumn, Class<? extends Permission> permission, Set<Role> contextualRoles)
{
return new ContainerClause(schema, containerFilterColumn, this, permission, roles);
return new ContainerClause(schema, containerFilterColumn, this, permission, contextualRoles);
}


Expand Down
2 changes: 1 addition & 1 deletion api/src/org/labkey/api/data/RecordFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public RecordFactory(Class<K> clazz)
{
Object[] params = Arrays.stream(_parameters).map(p -> {
Object value = m.get(p.getName());
return ConvertUtils.convert(value, p.getType());
return value != null ? ConvertUtils.convert(value, p.getType()) : null;
}).toArray();

try
Expand Down
1 change: 1 addition & 0 deletions api/src/org/labkey/api/data/SqlScriptExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ public void execute()
{
LOG.info("Executing {}", upgradeMethod.getDisplayName());
_moduleContext.invokeUpgradeMethod(upgradeMethod);
LOG.info("Finished executing {}", upgradeMethod.getDisplayName());
}
}
catch (NoSuchMethodException e)
Expand Down
18 changes: 18 additions & 0 deletions api/src/org/labkey/api/data/dialect/PostgreSqlService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.labkey.api.data.dialect;

import org.labkey.api.services.ServiceRegistry;

public interface PostgreSqlService
{
static PostgreSqlService get()
{
return ServiceRegistry.get().getService(PostgreSqlService.class);
}

static void setInstance(PostgreSqlService impl)
{
ServiceRegistry.get().registerService(PostgreSqlService.class, impl);
}

BasePostgreSqlDialect getDialect();
}
46 changes: 0 additions & 46 deletions api/src/org/labkey/api/query/QueryView.java
Original file line number Diff line number Diff line change
Expand Up @@ -1050,52 +1050,6 @@ public ActionButton createDeleteButton(boolean showConfirmation)
return null;
}

public ActionButton createDeleteAllRowsButton(String tableNoun)
{
ActionButton deleteAllRows = new ActionButton("Delete All Rows");
deleteAllRows.setDisplayPermission(AdminPermission.class);
deleteAllRows.setActionType(ActionButton.Action.SCRIPT);
deleteAllRows.setScript(
"LABKEY.requiresExt4Sandbox(function() {" +
"Ext4.Msg.confirm('Confirm Deletion', 'Are you sure you wish to delete all rows in this " + tableNoun + "? This action cannot be undone and will result in an empty " + tableNoun + ".', function(button){" +
"if (button == 'yes'){" +
"var waitMask = Ext4.Msg.wait('Deleting Rows...', 'Delete Rows'); " +
"Ext4.Ajax.request({ " +
"url : LABKEY.ActionURL.buildURL('query', 'truncateTable'), " +
"method : 'POST', " +
"success: function(response) " +
"{" +
"waitMask.close(); " +
"var data = Ext4.JSON.decode(response.responseText); " +
"Ext4.Msg.show({ " +
"title : 'Success', " +
"buttons : Ext4.MessageBox.OK, " +
"msg : data.deletedRows + ' rows deleted', " +
"fn: function(btn) " +
"{ " +
"if(btn == 'ok') " +
"{ " +
"window.location.reload(); " +
"} " +
"} " +
"})" +
"}, " +
"failure : function(response, opts) " +
"{ " +
"waitMask.close(); " +
"Ext4.getBody().unmask(); " +
"LABKEY.Utils.displayAjaxErrorResponse(response, opts); " +
"}, " +
"jsonData : {schemaName : " + PageFlowUtil.jsString(getQueryDef().getSchema().getName()) + ", queryName : " + PageFlowUtil.jsString(getQueryDef().getName()) + "}, " +
"scope : this " +
"});" +
"}" +
"});" +
"});"
);
return deleteAllRows;
}

public ActionButton createInsertMenuButton()
{
return createInsertMenuButton(null, null);
Expand Down
7 changes: 4 additions & 3 deletions audit/src/org/labkey/audit/AuditController.java
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,12 @@ public void validateForm(AuditTransactionForm form, Errors errors)
public Object execute(AuditTransactionForm form, BindException errors)
{
List<Long> rowIds;
ContainerFilter cf = ContainerFilter.getContainerFilterByName(form.getContainerFilter(), getContainer(), getUser());
User elevatedUser = ElevatedUser.ensureCanSeeAuditLogRole(getContainer(), getUser());
ContainerFilter cf = ContainerFilter.getContainerFilterByName(form.getContainerFilter(), getContainer(), elevatedUser);
if (form.isSampleType())
rowIds = AuditLogImpl.get().getTransactionSampleIds(form.getTransactionAuditId(), ElevatedUser.ensureCanSeeAuditLogRole(getContainer(), getUser()), getContainer(), cf);
rowIds = AuditLogImpl.get().getTransactionSampleIds(form.getTransactionAuditId(), elevatedUser, getContainer(), cf);
else
rowIds = AuditLogImpl.get().getTransactionSourceIds(form.getTransactionAuditId(), ElevatedUser.ensureCanSeeAuditLogRole(getContainer(), getUser()), getContainer(), cf);
rowIds = AuditLogImpl.get().getTransactionSourceIds(form.getTransactionAuditId(), elevatedUser, getContainer(), cf);

ApiSimpleResponse response = new ApiSimpleResponse();
response.put("success", true);
Expand Down
7 changes: 4 additions & 3 deletions core/src/org/labkey/core/CoreModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
import org.labkey.api.data.TestSchema;
import org.labkey.api.data.WorkbookContainerType;
import org.labkey.api.data.dialect.BasePostgreSqlDialect;
import org.labkey.api.data.dialect.PostgreSqlService;
import org.labkey.api.data.dialect.SqlDialect;
import org.labkey.api.data.dialect.SqlDialectManager;
import org.labkey.api.data.dialect.SqlDialectRegistry;
Expand All @@ -88,6 +89,7 @@
import org.labkey.api.files.FileBrowserConfigWriter;
import org.labkey.api.files.FileContentService;
import org.labkey.api.markdown.MarkdownService;
import org.labkey.api.mcp.McpService;
import org.labkey.api.message.settings.MessageConfigService;
import org.labkey.api.migration.DatabaseMigrationService;
import org.labkey.api.module.FolderType;
Expand All @@ -98,7 +100,6 @@
import org.labkey.api.module.SchemaUpdateType;
import org.labkey.api.module.SpringModule;
import org.labkey.api.module.Summary;
import org.labkey.api.mcp.McpService;
import org.labkey.api.notification.EmailMessage;
import org.labkey.api.notification.EmailService;
import org.labkey.api.notification.NotificationMenuView;
Expand Down Expand Up @@ -253,9 +254,9 @@
import org.labkey.core.login.DbLoginAuthenticationProvider;
import org.labkey.core.login.DbLoginManager;
import org.labkey.core.login.LoginController;
import org.labkey.core.mcp.McpServiceImpl;
import org.labkey.core.metrics.SimpleMetricsServiceImpl;
import org.labkey.core.metrics.WebSocketConnectionManager;
import org.labkey.core.mcp.McpServiceImpl;
import org.labkey.core.notification.EmailPreferenceConfigServiceImpl;
import org.labkey.core.notification.EmailPreferenceContainerListener;
import org.labkey.core.notification.EmailPreferenceUserListener;
Expand Down Expand Up @@ -560,11 +561,11 @@ public QuerySchema createSchema(DefaultSchema schema, Module module)
ScriptEngineManagerImpl.registerEncryptionMigrationHandler();

McpService.get().register(new CoreMcp());
PostgreSqlService.setInstance(PostgreSqlDialectFactory::getLatestSupportedDialect);

deleteTempFiles();
}


private void deleteTempFiles()
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1605,6 +1605,7 @@ public boolean handlePost(UpgradeCodeForm form, BindException errors) throws Exc
{
LOG.info("Executing {}.{}(ModuleContext moduleContext)", _method.getDeclaringClass().getSimpleName(), _method.getName());
_method.invoke(_code, _ctx);
LOG.info("Finished executing {}.{}(ModuleContext moduleContext)", _method.getDeclaringClass().getSimpleName(), _method.getName());
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.junit.Assert;
import org.junit.Test;
import org.labkey.api.data.dialect.AbstractDialectRetrievalTestCase;
import org.labkey.api.data.dialect.BasePostgreSqlDialect;
import org.labkey.api.data.dialect.DatabaseNotSupportedException;
import org.labkey.api.data.dialect.JdbcHelperTest;
import org.labkey.api.data.dialect.PostgreSqlServerType;
Expand Down Expand Up @@ -145,6 +146,11 @@ public static PostgreSql_13_Dialect getOldestSupportedDialect()
return new PostgreSql_13_Dialect();
}

public static BasePostgreSqlDialect getLatestSupportedDialect()
{
return new PostgreSql_18_Dialect();
}

public static class DialectRetrievalTestCase extends AbstractDialectRetrievalTestCase
{
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- SQL Server only
EXEC core.executeJavaUpgradeCode 'shortenAllStorageNames';
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ async function verifyPropertiesFilesOnServer(
// Note: this is a hack to allow us to make requests to the webdav controller. The IntegrationTestServer
// request method uses ActionURL to generate URLS, but webdav URLs are not ActionURLs, so we need to
// override the AgentProvider to generate the proper webdav URL.
url = `/_webdav/${requestOptions.containerPath}/%40files/assaydata?method=JSON`;
url = `${LABKEY.contextPath}/_webdav/${requestOptions.containerPath}/%40files/assaydata?method=JSON`;
return agent.get(url);
},
requestOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,12 @@ public void afterSchema(DatabaseMigrationConfiguration configuration, DbSchema s

DbScope sourceScope = configuration.getSourceScope();
DbScope targetScope = configuration.getTargetScope();
DbSchema biologicsSourceSchema = sourceScope.getSchema("biologics", DbSchemaType.Migration);
DbSchema biologicsTargetSchema = targetScope.getSchema("biologics", DbSchemaType.Module);

if (biologicsSourceSchema.existsInDatabase() && biologicsTargetSchema.existsInDatabase())
if (sourceScope.getSchemaNames().contains("biologics") && targetScope.getSchemaNames().contains("biologics"))
{
DbSchema biologicsSourceSchema = sourceScope.getSchema("biologics", DbSchemaType.Migration);
DbSchema biologicsTargetSchema = targetScope.getSchema("biologics", DbSchemaType.Module);

TableInfo sourceTable = biologicsSourceSchema.getTable("SequenceIdentity");
TableInfo targetTable = biologicsTargetSchema.getTable("SequenceIdentity");

Expand Down
2 changes: 1 addition & 1 deletion experiment/src/org/labkey/experiment/ExperimentModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public String getName()
@Override
public Double getSchemaVersion()
{
return 26.004;
return 26.005;
}

@Nullable
Expand Down
Loading
Loading