Changes For Knowledge Center Dev (#13043)

This commit is contained in:
Mohit Yadav 2023-08-31 11:42:34 +05:30 committed by GitHub
parent cc04a0d245
commit 673512d7f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 6 deletions

View File

@ -202,7 +202,7 @@ public abstract class EntityRepository<T extends EntityInterface> {
/** Fields that can be updated during PUT operation */
@Getter protected final Fields putFields;
EntityRepository(
protected EntityRepository(
String collectionPath,
String entityType,
Class<T> entityClass,

View File

@ -167,9 +167,7 @@ public final class CollectionRegistry {
CollectionDetails details = e.getValue();
String resourceClass = details.resourceClass;
try {
CollectionDAO daoObject = jdbi.onDemand(CollectionDAO.class);
Objects.requireNonNull(daoObject, "CollectionDAO must not be null");
Object resource = createResource(daoObject, resourceClass, config, authorizer, authenticatorHandler);
Object resource = createResource(jdbi, resourceClass, config, authorizer, authenticatorHandler);
details.setResource(resource);
environment.jersey().register(resource);
LOG.info("Registering {} with order {}", resourceClass, details.order);
@ -231,13 +229,18 @@ public final class CollectionRegistry {
/** Create a resource class based on dependencies declared in @Collection annotation */
private static Object createResource(
CollectionDAO daoObject,
Jdbi jdbi,
String resourceClass,
OpenMetadataApplicationConfig config,
Authorizer authorizer,
AuthenticatorHandler authHandler)
throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException,
InstantiationException {
// Decorate Collection DAO
CollectionDAO daoObject = jdbi.onDemand(CollectionDAO.class);
Objects.requireNonNull(daoObject, "CollectionDAO must not be null");
Object resource = null;
Class<?> clz = Class.forName(resourceClass);
@ -250,7 +253,11 @@ public final class CollectionRegistry {
clz.getDeclaredConstructor(CollectionDAO.class, Authorizer.class, AuthenticatorHandler.class)
.newInstance(daoObject, authorizer, authHandler);
} catch (NoSuchMethodException ex) {
resource = Class.forName(resourceClass).getConstructor().newInstance();
try {
resource = clz.getDeclaredConstructor(Jdbi.class, Authorizer.class).newInstance(jdbi, authorizer);
} catch (NoSuchMethodException exe) {
resource = Class.forName(resourceClass).getConstructor().newInstance();
}
}
} catch (Exception ex) {
LOG.warn("Exception encountered", ex);