diff --git a/youcat/README.md b/youcat/README.md index bb3babd3..903da4c7 100644 --- a/youcat/README.md +++ b/youcat/README.md @@ -82,18 +82,18 @@ See cadc-tap- The youcat.properties configures some admin and optional functions of the service. ``` -# configure the admin user +# (optional) configure the admin user org.opencadc.youcat.adminUser = {identity} -# (optional) configure schema creation in the database (default: false) +# (optional) schema creation in the database (default: false) org.opencadc.youcat.createSchemaInDB = true|false ``` The admin user can use the youcat API to create a new schema for a user. This will add the -schema to the `tap_schema.schemas` table and enable the user to create tables in that -schema. If the optional _createSchemaInDB_ flag is set to true, a schema created by admin -will be created in the database in addition to being added to the `tap_schema`. If false, -`youcat` will not create the schema in the database and just assume it exists and that the -`tapadm` pool has permission to create objects (tables and indices) in it. +schema to the `tap_schema.schemas` table with the specified owner and enable the owner to +further manage that schema. If the optional _createSchemaInDB_ flag is set to true, a schema +created by admin will be created in the database in addition to being added to the `tap_schema`. +If false, `youcat` will not create the schema in the database and just assume it exists and +that the `tapadm` pool has permission to create objects (tables and indices) in it. As hard-coded behaviours of `youcat` are extracted from the build and made configurable, the configuration options will usually be in this file (see **development plans** below). diff --git a/youcat/src/main/java/org/opencadc/youcat/YoucatInitAction.java b/youcat/src/main/java/org/opencadc/youcat/YoucatInitAction.java index a4a31712..22a2cbbd 100644 --- a/youcat/src/main/java/org/opencadc/youcat/YoucatInitAction.java +++ b/youcat/src/main/java/org/opencadc/youcat/YoucatInitAction.java @@ -109,11 +109,10 @@ private void initConfig() { sb.append("incomplete config: "); boolean ok = true; - String username = mvp.getFirstPropertyValue(YOUCAT_ADMIN); + String adminUser = mvp.getFirstPropertyValue(YOUCAT_ADMIN); sb.append("\n\t" + YOUCAT_ADMIN + ": "); - if (username == null) { + if (adminUser == null) { sb.append("MISSING"); - ok = false; } else { sb.append("OK"); } @@ -130,16 +129,19 @@ private void initConfig() { throw new InvalidConfigException(sb.toString()); } - HttpPrincipal hp = new HttpPrincipal(username); - Boolean createSchemaInDB = true; - if (yc != null && "false".equals(yc)) { - createSchemaInDB = false; + Boolean createSchemaInDB = false; // default: false for backwards compat + if (yc != null && "true".equals(yc)) { + createSchemaInDB = true; } try { Context ctx = new InitialContext(); - ctx.bind(jndiAdminKey, hp); - ctx.bind(jndiCreateSchemaKey, createSchemaInDB); - log.info("init: admin=" + hp + " createSchemaInDB=" + createSchemaInDB); + if (adminUser != null) { + ctx.bind(jndiAdminKey, new HttpPrincipal(adminUser)); + } + if (createSchemaInDB != null) { + ctx.bind(jndiCreateSchemaKey, createSchemaInDB); + } + log.info("init: admin=" + adminUser + " createSchemaInDB=" + createSchemaInDB); } catch (Exception ex) { log.error("Failed to create JNDI key(s): " + jndiAdminKey + "|" + jndiCreateSchemaKey, ex); }