/*
 * #%L
 * Bitrepository Integrity Client
 * *
 * $Id$
 * $HeadURL$
 * %%
 * Copyright (C) 2010 - 2011 The State and University Library, The Royal Library and The State Archives, Denmark
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as 
 * published by the Free Software Foundation, either version 2.1 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public 
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/lgpl-2.1.html>.
 * #L%
 */
package org.bitrepository.integrityservice.collector;

import org.bitrepository.access.ContributorQuery;
import org.bitrepository.access.getchecksums.GetChecksumsClient;
import org.bitrepository.access.getfileids.GetFileIDsClient;
import org.bitrepository.bitrepositoryelements.ChecksumSpecTYPE;
import org.bitrepository.client.eventhandler.EventHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collection;

/**
 * Integrity information collector that delegates collecting information to the clients.
 * TODO split into two different collectors. One for collecting the file ids and one for the checksums.
 */
public class DelegatingIntegrityInformationCollector implements IntegrityInformationCollector {
    /** The log.*/
    private Logger log = LoggerFactory.getLogger(getClass());

    /** The client for retrieving file IDs. */
    private final GetFileIDsClient getFileIDsClient;
    /** The client for retrieving checksums. */
    private final GetChecksumsClient getChecksumsClient;
    /** The audit trail manager.*/
    
    /**
     * @param getFileIDsClient The client for retrieving file IDs
     * @param getChecksumsClient The client for retrieving checksums.
     */
    public DelegatingIntegrityInformationCollector(
            GetFileIDsClient getFileIDsClient,
            GetChecksumsClient getChecksumsClient) {
        this.getFileIDsClient = getFileIDsClient;
        this.getChecksumsClient = getChecksumsClient;
    }

    @Override
    public synchronized void getFileIDs(String collectionID, Collection<String> pillarIDs, String auditTrailInformation, 
            ContributorQuery[] queries, EventHandler eventHandler) {
        try {getFileIDsClient.getFileIDs(collectionID, queries, null, null, eventHandler);
        } catch (Exception e) {
            // Barrier
            log.error("Unexpected failure!", e);
        }
    }

    @Override
    public synchronized void getChecksums(String collectionID, Collection<String> pillarIDs, ChecksumSpecTYPE checksumType, 
            String auditTrailInformation, ContributorQuery[] queries, EventHandler eventHandler) {
        try {getChecksumsClient.getChecksums(collectionID, queries, null, checksumType, null, eventHandler,
                    auditTrailInformation);
        } catch (Exception e) {
            log.error("Unexpected failure!", e);
        }
    }
}

@@ -3039,16 +3039,29 @@
    try %7B
+%0A            
 getCheck

Rework after review CR-BITMAG-253