@Test public void shouldRemoveBrowseNodeEntriesForDockerRepositories() throws Exception { assertThat(getBrowseNodeCountForRepository(DOCKER_PROXY_REPOSITORY), is(1L)); assertThat(getBrowseNodeCountForRepository(DOCKER_HOSTED_REPOSITORY), is(1L)); assertThat(getBrowseNodeCountForRepository(NPM_PROXY_REPOSITORY), is(1L)); upgrade.apply(); assertThat(getBrowseNodeCountForRepository(DOCKER_PROXY_REPOSITORY), is(0L)); assertThat(getBrowseNodeCountForRepository(DOCKER_HOSTED_REPOSITORY), is(0L)); assertThat(getBrowseNodeCountForRepository(NPM_PROXY_REPOSITORY), is(1L)); }
@Override public void apply() throws Exception { List<String> repositoryNames; try (ODatabaseDocumentTx configDb = configDatabaseInstance.get().connect()) { repositoryNames = configDb.<List<ODocument>>query( new OSQLSynchQuery<ODocument>(SELECT_DOCKER_REPOSITORIES)).stream() .map(d -> (String) d.field(P_REPOSITORY_NAME)) .collect(toList()); } if (repositoryNames != null && !repositoryNames.isEmpty()) { log.info("Deleting browse_node data from docker repositories to be rebuilt ({}).", repositoryNames); try (ODatabaseDocumentTx componentDb = componentDatabaseInstance.get().connect()) { OSchemaProxy schema = componentDb.getMetadata().getSchema(); if (schema.existsClass(C_BROWSE_NODE)) { componentDb.command(new OCommandSQL(DELETE_BROWSE_NODE_FROM_REPOSITORIES)).execute(repositoryNames); } } } }
ComponentDatabaseUpgrade_1_11 extends DatabaseUpgradeSupport { @Override public void apply() throws Exception { List<String> repositoryNames; try (ODatabaseDocumentTx configDb = configDatabaseInstance.get().connect()) { repositoryNames = configDb.<List<ODocument>>query( new OSQLSynchQuery<ODocument>(SELECT_DOCKER_REPOSITORIES)).stream() .map(d -> (String) d.field(P_REPOSITORY_NAME)) .collect(toList()); } if (repositoryNames != null && !repositoryNames.isEmpty()) { log.info("Deleting browse_node data from docker repositories to be rebuilt ({}).", repositoryNames); try (ODatabaseDocumentTx componentDb = componentDatabaseInstance.get().connect()) { OSchemaProxy schema = componentDb.getMetadata().getSchema(); if (schema.existsClass(C_BROWSE_NODE)) { componentDb.command(new OCommandSQL(DELETE_BROWSE_NODE_FROM_REPOSITORIES)).execute(repositoryNames); } } } } }
ComponentDatabaseUpgrade_1_11 extends DatabaseUpgradeSupport { @Override public void apply() throws Exception { List<String> repositoryNames; try (ODatabaseDocumentTx configDb = configDatabaseInstance.get().connect()) { repositoryNames = configDb.<List<ODocument>>query( new OSQLSynchQuery<ODocument>(SELECT_DOCKER_REPOSITORIES)).stream() .map(d -> (String) d.field(P_REPOSITORY_NAME)) .collect(toList()); } if (repositoryNames != null && !repositoryNames.isEmpty()) { log.info("Deleting browse_node data from docker repositories to be rebuilt ({}).", repositoryNames); try (ODatabaseDocumentTx componentDb = componentDatabaseInstance.get().connect()) { OSchemaProxy schema = componentDb.getMetadata().getSchema(); if (schema.existsClass(C_BROWSE_NODE)) { componentDb.command(new OCommandSQL(DELETE_BROWSE_NODE_FROM_REPOSITORIES)).execute(repositoryNames); } } } } @Inject  ComponentDatabaseUpgrade_1_11(
      @Named(DatabaseInstanceNames.CONFIG) final Provider<DatabaseInstance> configDatabaseInstance,
      @Named(DatabaseInstanceNames.COMPONENT) final Provider<DatabaseInstance> componentDatabaseInstance); }
ComponentDatabaseUpgrade_1_11 extends DatabaseUpgradeSupport { @Override public void apply() throws Exception { List<String> repositoryNames; try (ODatabaseDocumentTx configDb = configDatabaseInstance.get().connect()) { repositoryNames = configDb.<List<ODocument>>query( new OSQLSynchQuery<ODocument>(SELECT_DOCKER_REPOSITORIES)).stream() .map(d -> (String) d.field(P_REPOSITORY_NAME)) .collect(toList()); } if (repositoryNames != null && !repositoryNames.isEmpty()) { log.info("Deleting browse_node data from docker repositories to be rebuilt ({}).", repositoryNames); try (ODatabaseDocumentTx componentDb = componentDatabaseInstance.get().connect()) { OSchemaProxy schema = componentDb.getMetadata().getSchema(); if (schema.existsClass(C_BROWSE_NODE)) { componentDb.command(new OCommandSQL(DELETE_BROWSE_NODE_FROM_REPOSITORIES)).execute(repositoryNames); } } } } @Inject  ComponentDatabaseUpgrade_1_11(
      @Named(DatabaseInstanceNames.CONFIG) final Provider<DatabaseInstance> configDatabaseInstance,
      @Named(DatabaseInstanceNames.COMPONENT) final Provider<DatabaseInstance> componentDatabaseInstance); @Override void apply(); }
ComponentDatabaseUpgrade_1_11 extends DatabaseUpgradeSupport { @Override public void apply() throws Exception { List<String> repositoryNames; try (ODatabaseDocumentTx configDb = configDatabaseInstance.get().connect()) { repositoryNames = configDb.<List<ODocument>>query( new OSQLSynchQuery<ODocument>(SELECT_DOCKER_REPOSITORIES)).stream() .map(d -> (String) d.field(P_REPOSITORY_NAME)) .collect(toList()); } if (repositoryNames != null && !repositoryNames.isEmpty()) { log.info("Deleting browse_node data from docker repositories to be rebuilt ({}).", repositoryNames); try (ODatabaseDocumentTx componentDb = componentDatabaseInstance.get().connect()) { OSchemaProxy schema = componentDb.getMetadata().getSchema(); if (schema.existsClass(C_BROWSE_NODE)) { componentDb.command(new OCommandSQL(DELETE_BROWSE_NODE_FROM_REPOSITORIES)).execute(repositoryNames); } } } } @Inject  ComponentDatabaseUpgrade_1_11(
      @Named(DatabaseInstanceNames.CONFIG) final Provider<DatabaseInstance> configDatabaseInstance,
      @Named(DatabaseInstanceNames.COMPONENT) final Provider<DatabaseInstance> componentDatabaseInstance); @Override void apply();  }