com.hp.autonomy.searchcomponents.idol.databases.IdolDatabasesService Maven / Gradle / Ivy
/*
* Copyright 2015 Hewlett-Packard Development Company, L.P.
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
*/
package com.hp.autonomy.searchcomponents.idol.databases;
import com.autonomy.aci.client.services.AciErrorException;
import com.autonomy.aci.client.services.AciService;
import com.autonomy.aci.client.services.Processor;
import com.autonomy.aci.client.util.AciParameters;
import com.hp.autonomy.idolutils.processors.AciResponseJaxbProcessorFactory;
import com.hp.autonomy.searchcomponents.core.databases.DatabasesService;
import com.hp.autonomy.types.idol.Database;
import com.hp.autonomy.types.idol.GetStatusResponseData;
import com.hp.autonomy.types.requests.idol.actions.status.StatusActions;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@Data
@Service
public class IdolDatabasesService implements DatabasesService {
private final AciService contentAciService;
private final Processor responseProcessor;
@Autowired
public IdolDatabasesService(final AciService contentAciService, final AciResponseJaxbProcessorFactory aciResponseProcessorFactory) {
this.contentAciService = contentAciService;
responseProcessor = aciResponseProcessorFactory.createAciResponseProcessor(GetStatusResponseData.class);
}
@Override
public Set getDatabases(final IdolDatabasesRequest request) throws AciErrorException {
final GetStatusResponseData responseData = contentAciService.executeAction(new AciParameters(StatusActions.GetStatus.name()), responseProcessor);
final List allDatabases = responseData.getDatabases().getDatabase();
final Set publicDatabases = new LinkedHashSet<>();
for (final Database database : allDatabases) {
if (!database.isInternal()) {
publicDatabases.add(database);
}
}
return publicDatabases;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy