components/org.wso2.carbon.identity.remotefetch.core/src/main/java/org/wso2/carbon/identity/remotefetch/core/implementations/actionHandlers/PollingActionListener.java
private void pollDirectory(ConfigDeployer deployer) {

        List<File> configFiles = null;

        try {
            configFiles = this.repo.listFiles();
        } catch (RemoteFetchCoreException e) {
            log.error("Error listing files from repository", e);
            return;
        }

        this.manageRevisions(configFiles);

        for (DeploymentRevision deploymentRevision : this.deploymentRevisionMap.values()) {
            String newHash = "";
            try {
                newHash = this.repo.getRevisionHash(deploymentRevision.getFile());
            } catch (RemoteFetchCoreException e) {
                log.error("Unable to get new hash for " + deploymentRevision.getItemName(), e);
            }

            // Deploy if new file or updated file
            if (this.deploymentRevisionChanged(deploymentRevision, newHash)) {

                deploymentRevision.setFileHash(newHash);
                try {
                    ConfigurationFileStream configurationFileStream = repo.getFile(deploymentRevision.getFile());
                    deployer.deploy(configurationFileStream);
                    deploymentRevision.setDeploymentStatus(DeploymentRevision.DEPLOYMENT_STATUS.DEPLOYED);
                } catch (RemoteFetchCoreException e) {
                    log.error("Error Deploying " + deploymentRevision.getFile().getName(), e);
                    deploymentRevision.setDeploymentStatus(DeploymentRevision.DEPLOYMENT_STATUS.ERROR_DEPLOYING);
                }

                // Set new deployment Date
                deploymentRevision.setDeployedDate(new Date());

                try {
                    this.deploymentRevisionDAO.updateDeploymentRevision(deploymentRevision);
                } catch (RemoteFetchCoreException e) {
                    log.error("Error updating DeploymentRevision for " + deploymentRevision.getItemName(), e);
                }
            }
        }
    }
/**
     * Poll directory for new files.
     * @param deployer
     */
Poll directory for new files.
@param deployer
Poll directory for new files . @param deployer
private void pollDirectory(ConfigDeployer deployer) {
        List<File> configFiles = null;
        try {
            configFiles = this.repo.listFiles();
        } catch (RemoteFetchCoreException e) {
            log.error("Error listing files from repository", e);
            return;
        }
        this.manageRevisions(configFiles);
        for (DeploymentRevision deploymentRevision : this.deploymentRevisionMap.values()) {
            String newHash = "";
            try {
                newHash = this.repo.getRevisionHash(deploymentRevision.getFile());
            } catch (RemoteFetchCoreException e) {
                log.error("Unable to get new hash for " + deploymentRevision.getItemName(), e);
            }
            if (this.deploymentRevisionChanged(deploymentRevision, newHash)) {
                deploymentRevision.setFileHash(newHash);
                try {
                    ConfigurationFileStream configurationFileStream = repo.getFile(deploymentRevision.getFile());
                    deployer.deploy(configurationFileStream);
                    deploymentRevision.setDeploymentStatus(DeploymentRevision.DEPLOYMENT_STATUS.DEPLOYED);
                } catch (RemoteFetchCoreException e) {
                    log.error("Error Deploying " + deploymentRevision.getFile().getName(), e);
                    deploymentRevision.setDeploymentStatus(DeploymentRevision.DEPLOYMENT_STATUS.ERROR_DEPLOYING);
                }
                deploymentRevision.setDeployedDate(new Date());
                try {
                    this.deploymentRevisionDAO.updateDeploymentRevision(deploymentRevision);
                } catch (RemoteFetchCoreException e) {
                    log.error("Error updating DeploymentRevision for " + deploymentRevision.getItemName(), e);
                }
            }
        }
    }
private void pollDirectory ( ConfigDeployer deployer ) { List < File > configFiles = null ; try { configFiles = this . repo . listFiles ( ) ; } catch ( RemoteFetchCoreException e ) { log . error ( "Error listing files from repository" , e ) ; return ; } this . manageRevisions ( configFiles ) ; for ( DeploymentRevision deploymentRevision : this . deploymentRevisionMap . values ( ) ) { String newHash = "" ; try { newHash = this . repo . getRevisionHash ( deploymentRevision . getFile ( ) ) ; } catch ( RemoteFetchCoreException e ) { log . error ( "Unable to get new hash for " + deploymentRevision . getItemName ( ) , e ) ; } if ( this . deploymentRevisionChanged ( deploymentRevision , newHash ) ) { deploymentRevision . setFileHash ( newHash ) ; try { ConfigurationFileStream configurationFileStream = repo . getFile ( deploymentRevision . getFile ( ) ) ; deployer . deploy ( configurationFileStream ) ; deploymentRevision . setDeploymentStatus ( DeploymentRevision . DEPLOYMENT_STATUS . DEPLOYED ) ; } catch ( RemoteFetchCoreException e ) { log . error ( "Error Deploying " + deploymentRevision . getFile ( ) . getName ( ) , e ) ; deploymentRevision . setDeploymentStatus ( DeploymentRevision . DEPLOYMENT_STATUS . ERROR_DEPLOYING ) ; } deploymentRevision . setDeployedDate ( new Date ( ) ) ; try { this . deploymentRevisionDAO . updateDeploymentRevision ( deploymentRevision ) ; } catch ( RemoteFetchCoreException e ) { log . error ( "Error updating DeploymentRevision for " + deploymentRevision . getItemName ( ) , e ) ; } } } }
Poll directory for new files.
Poll directory for new files .
// Deploy if new file or updated file // Set new deployment Date