Skip to content

Commit

Permalink
Checking for INGESTING dbs in initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioG70 authored and hmiguim committed Dec 12, 2023
1 parent 9669402 commit dd9ca5f
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,29 @@
*/
package com.databasepreservation.common.server;

import com.databasepreservation.common.client.ViewerConstants;
import com.databasepreservation.common.client.index.IndexResult;
import com.databasepreservation.common.client.index.filter.BasicSearchFilterParameter;
import com.databasepreservation.common.client.index.filter.Filter;
import com.databasepreservation.common.client.index.sort.Sorter;
import com.databasepreservation.common.client.models.structure.ViewerDatabase;
import com.databasepreservation.common.client.index.facets.Facets;
import com.databasepreservation.common.client.models.structure.ViewerDatabaseStatus;
import com.databasepreservation.common.client.models.structure.ViewerDatabaseValidationStatus;
import com.databasepreservation.common.server.index.utils.IterableDatabaseResult;
import org.apache.solr.client.solrj.SolrClient;
import org.roda.core.data.exceptions.GenericException;
import org.roda.core.data.exceptions.RequestNotValidException;
import org.roda.core.data.v2.index.sublist.Sublist;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.databasepreservation.common.server.activity.log.strategies.ActivityLogStrategyFactory;
import com.databasepreservation.common.server.index.DatabaseRowsSolrManager;
import com.databasepreservation.common.server.index.factory.SolrClientFactory;

import java.util.ArrayList;

/**
* @author Bruno Ferreira <bferreira@keep.pt>
*/
Expand All @@ -35,10 +50,25 @@ private static synchronized void instantiate() {
solrManager = new DatabaseRowsSolrManager(solrClient);
configurationManager = new ConfigurationManager();
activityLogStrategyFactory = new ActivityLogStrategyFactory();
try {
checkIngestingDBs();
} catch (GenericException | RequestNotValidException e) {
LOGGER.error("Error checking for ingesting databases in initialization: " + e.getMessage());
}
instantiated = true;
}
}

public static void checkIngestingDBs() throws RequestNotValidException, GenericException {
Filter ingestingFilter = new Filter(new BasicSearchFilterParameter(ViewerConstants.SOLR_DATABASES_STATUS, ViewerDatabaseStatus.INGESTING.toString()));

IterableDatabaseResult<ViewerDatabase> dataBases = solrManager.findAll(ViewerDatabase.class, ingestingFilter, Sorter.NONE, new ArrayList<>());

for (ViewerDatabase db : dataBases) {
solrManager.markDatabaseCollection(db.getUuid(), ViewerDatabaseStatus.ERROR);
}
}

public static Integer getEnvInt(String name, Integer defaultValue) {
Integer envInt;
try {
Expand Down

0 comments on commit dd9ca5f

Please sign in to comment.