use of org.sagebionetworks.bridge.models.apps.App in project BridgeServer2 by Sage-Bionetworks.
the class DefaultAppBootstrapper method onApplicationEvent.
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
List<TableDescription> tables = annotationBasedTableCreator.getTables("org.sagebionetworks.bridge.dynamodb");
dynamoInitializer.init(tables);
s3Initializer.initBuckets();
RequestContext.set(new RequestContext.Builder().withCallerAppId(API_APP_ID).withCallerRoles(ImmutableSet.of(SUPERADMIN)).withCallerUserId("DefaultStudyBootstrapper").build());
// The integration bootstrap account should be ADMIN in production, and SUPERADMIN in other environments.
// It should have the Synapse user ID of the synapse.user set for the integration tests.
String adminEmail = bridgeConfig.get("admin.email");
String adminSynUserId = bridgeConfig.get("admin.synapse.user.id");
Roles adminRole = (bridgeConfig.getEnvironment() == PROD) ? ADMIN : SUPERADMIN;
boolean bootstrapUserConfigured = (adminEmail != null && adminSynUserId != null);
StudyParticipant admin = new StudyParticipant.Builder().withEmail(adminEmail).withSynapseUserId(adminSynUserId).withDataGroups(Sets.newHashSet(TEST_USER_GROUP)).withSharingScope(NO_SHARING).withRoles(Sets.newHashSet(adminRole)).build();
App app = createApp(API_APP_ID, "Test App", provided -> {
provided.setMinAgeOfConsent(18);
provided.setDataGroups(Sets.newHashSet(TEST_DATA_GROUPS));
provided.setTaskIdentifiers(Sets.newHashSet(TEST_TASK_IDENTIFIERS));
provided.setUserProfileAttributes(Sets.newHashSet("can_be_recontacted"));
});
if (bootstrapUserConfigured) {
createAccount(app, admin);
}
App app2 = createApp(API_2_APP_ID, "Test App 2", null);
if (bootstrapUserConfigured) {
createAccount(app2, admin);
}
App shared = createApp(SHARED_APP_ID, "Shared App", null);
if (bootstrapUserConfigured && bridgeConfig.getEnvironment() != Environment.PROD) {
createAccount(shared, admin);
}
}
use of org.sagebionetworks.bridge.models.apps.App in project BridgeServer2 by Sage-Bionetworks.
the class DynamoAppDao method createApp.
@Override
public App createApp(App app) {
checkNotNull(app);
checkArgument(app.getVersion() == null, "%s has a version; may not be new", "app");
try {
mapper.save(app);
} catch (ConditionalCheckFailedException e) {
// in the create scenario, this should be a hash key clash.
throw new EntityAlreadyExistsException(App.class, "identifier", app.getIdentifier());
}
return app;
}
use of org.sagebionetworks.bridge.models.apps.App in project BridgeServer2 by Sage-Bionetworks.
the class DynamoAppDao method deactivateApp.
@Override
public void deactivateApp(String appId) {
checkNotNull(appId);
if (appWhitelist.contains(appId)) {
throw new UnauthorizedException(appId + " is protected by whitelist.");
}
App app = getApp(appId);
app.setActive(false);
updateApp(app);
}
use of org.sagebionetworks.bridge.models.apps.App in project BridgeServer2 by Sage-Bionetworks.
the class DynamoAppDaoTest method deleteApp.
@Test
public void deleteApp() {
App app = App.create();
app.setIdentifier(TEST_APP_ID);
dao.deleteApp(app);
verify(mockMapper).delete(app);
}
use of org.sagebionetworks.bridge.models.apps.App in project BridgeServer2 by Sage-Bionetworks.
the class DynamoAppDaoTest method getApp.
@Test
public void getApp() {
DynamoApp saved = new DynamoApp();
doReturn(saved).when(mockMapper).load(any());
App result = dao.getApp(TEST_APP_ID);
assertSame(result, saved);
verify(mockMapper).load(appCaptor.capture());
App key = appCaptor.getValue();
assertEquals(key.getIdentifier(), TEST_APP_ID);
}
Aggregations