Skip to content

Commit cb15cb9

Browse files
Getter For VCell Support ID
1 parent 83a326b commit cb15cb9

5 files changed

Lines changed: 33 additions & 10 deletions

File tree

vcell-core/src/main/java/cbit/vcell/resource/PropertyLoader.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ public static void setConfigProvider(VCellConfigProvider configProvider) {
5757
public static final String ADMINISTRATOR_ID = "2";
5858
public static final String TESTACCOUNT_USERID = "vcellNagios";
5959
public static final String VCELL_SUPPORT_USERID = "VCellSupport";
60-
public static final String vcellSupportId = record("vcell.user.support", ValueType.GEN);
6160

6261
public static final String vcellServerIDProperty = record("vcell.server.id",ValueType.GEN);
6362

vcell-rest/src/main/java/org/vcell/restq/StartUpTasks.java renamed to vcell-rest/src/main/java/org/vcell/restq/QuarkusStartUpTasks.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.vcell.restq;
22

3+
import cbit.sql.ServerStartUpTasks;
34
import cbit.vcell.modeldb.AdminDBTopLevel;
4-
import cbit.vcell.resource.PropertyLoader;
55
import io.quarkus.runtime.StartupEvent;
66
import jakarta.enterprise.context.ApplicationScoped;
77
import jakarta.enterprise.event.Observes;
@@ -15,18 +15,16 @@
1515
import java.sql.SQLException;
1616

1717
@ApplicationScoped
18-
public class StartUpTasks {
19-
private final static Logger logger = LogManager.getLogger(StartUpTasks.class);
18+
public class QuarkusStartUpTasks {
19+
private final static Logger logger = LogManager.getLogger(QuarkusStartUpTasks.class);
2020

2121
@Inject
2222
AgroalConnectionFactory connectionFactory;
2323

2424
public void onStartUp(@Observes StartupEvent ev) throws SQLException, DataAccessException {
2525
logger.info("Executing startup tasks");
26-
27-
AdminDBTopLevel adminDBTopLevel = new AdminDBTopLevel(connectionFactory);
28-
User vcellSupport = adminDBTopLevel.getVCellSupportUser(true);
29-
PropertyLoader.setProperty(PropertyLoader.vcellSupportId, vcellSupport.getID().toString());
26+
ServerStartUpTasks.executeStartUpTasks(connectionFactory);
27+
logger.info("Startup tasks executed successfully");
3028
}
3129

3230
}

vcell-rest/src/test/java/org/vcell/restq/auth/ACLSupportTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.vcell.restq.auth;
22

3+
import cbit.sql.ServerStartUpTasks;
34
import cbit.vcell.biomodel.BioModel;
45
import cbit.vcell.modeldb.AdminDBTopLevel;
56
import cbit.vcell.modeldb.DatabaseServerImpl;
@@ -132,6 +133,6 @@ public void testSpecialClaimsPeopleHave() throws SQLException, DataAccessExcepti
132133

133134
@Test
134135
public void testVCellSupportIDGrabbing(){
135-
Assertions.assertEquals(PropertyLoader.getRequiredProperty(PropertyLoader.vcellSupportId), "4");
136+
Assertions.assertEquals(ServerStartUpTasks.getVCellSupportID(), "4");
136137
}
137138
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package cbit.sql;
2+
3+
import cbit.vcell.modeldb.AdminDBTopLevel;
4+
import org.vcell.db.ConnectionFactory;
5+
import org.vcell.util.DataAccessException;
6+
import org.vcell.util.document.User;
7+
8+
import java.sql.SQLException;
9+
10+
public class ServerStartUpTasks {
11+
private static String vcellSupportID = null;
12+
13+
14+
public static void executeStartUpTasks(ConnectionFactory connectionFactory) throws SQLException, DataAccessException {
15+
AdminDBTopLevel adminDBTopLevel = new AdminDBTopLevel(connectionFactory);
16+
User user = adminDBTopLevel.getVCellSupportUser(true);
17+
vcellSupportID = user.getID().toString();
18+
}
19+
20+
public static String getVCellSupportID() {
21+
return vcellSupportID;
22+
}
23+
24+
}

vcell-server/src/main/java/cbit/vcell/modeldb/DatabasePolicySQL.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.util.Arrays;
1313
import java.util.List;
1414

15+
import cbit.sql.ServerStartUpTasks;
1516
import org.apache.logging.log4j.LogManager;
1617
import org.apache.logging.log4j.Logger;
1718
import org.vcell.db.DatabaseSyntax;
@@ -306,7 +307,7 @@ static String getVTableDirectSelectClause(VersionTable vTable,User user) {
306307

307308
String vcellSupportClause = "";
308309
if (user instanceof SpecialUser specialUser && specialUser.isVCellSupport()){
309-
vcellSupportClause = " OR " + GroupTable.table.userRef.getQualifiedColName() + " = " + PropertyLoader.getRequiredProperty(PropertyLoader.vcellSupportId);
310+
vcellSupportClause = " OR " + GroupTable.table.userRef.getQualifiedColName() + " = " + ServerStartUpTasks.getVCellSupportID();
310311
}
311312
String sql = " ( "+
312313
vTable.privacy.getQualifiedColName() + " = " + GroupTable.table.groupid.getQualifiedColName() +

0 commit comments

Comments
 (0)