// Path: src/de/neuland/firefly/migration/MigrationRepository.java
// @Repository
// @Scope("prototype")
// public class MigrationRepository {
//     @Autowired private ModelService modelService;
// 
//     public FireflyMigrationModel findByPk(PK pk) {
//         return modelService.get(pk);
//     }
// 
//     public FireflyMigrationModel create() {
//         return modelService.create(FireflyMigrationModel.class);
//     }
// 
//     public void save(FireflyMigrationModel migration) {
//         modelService.save(migration);
//     }
// }
// 
// Path: src/de/neuland/firefly/constants/FireflyConstants.java
// public static final String NO_HMC_XML_MD5 = "NO_HMC_XML";
// 
// Path: src/de/neuland/firefly/constants/FireflyConstants.java
// public static final String NO_ITEMS_XML_MD5 = "NO_ITEMS_XML";
// 
// Path: src/de/neuland/firefly/utils/MD5Util.java
// public static String generateMD5(String baseValue) {
//     return generateMD5(baseValue, "UTF-8", "MD5");
// }
// 
// Path: src/de/neuland/firefly/utils/XMLUtil.java
// public static String loadAndNormalizeXML(File xmlFile) throws ParserConfigurationException, SAXException, IOException, TransformerException {
//     DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
//     DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
//     Document doc = dBuilder.parse(xmlFile);
// 
//     removeRecursively(doc);
//     doc.normalizeDocument();
// 
//     TransformerFactory tf = TransformerFactory.newInstance();
//     Transformer transformer = tf.newTransformer();
//     transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
//     transformer.setOutputProperty(OutputKeys.INDENT, "no");
//     StringWriter normalizedXml = new StringWriter();
//     transformer.transform(new DOMSource(doc), new StreamResult(normalizedXml));
//     return normalizedXml.toString();
// }


import de.hybris.platform.core.PK;
import de.neuland.firefly.migration.MigrationRepository;
import de.neuland.firefly.model.FireflyExtensionModel;
import de.neuland.firefly.model.FireflyExtensionStateModel;
import de.neuland.firefly.model.FireflyMigrationModel;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.xml.sax.SAXException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import static de.neuland.firefly.constants.FireflyConstants.NO_HMC_XML_MD5;
import static de.neuland.firefly.constants.FireflyConstants.NO_ITEMS_XML_MD5;
import static de.neuland.firefly.utils.MD5Util.generateMD5;
import static de.neuland.firefly.utils.XMLUtil.loadAndNormalizeXML;
import static java.util.Arrays.asList;
        return ToStringBuilder.reflectionToString(this);
    }

    private boolean containsItemDefinitionHash(String itemsDefinitionHash, List<FireflyExtensionStateModel> states) {
        for (FireflyExtensionStateModel state : states) {
            if (StringUtils.equals(itemsDefinitionHash, state.getItemsDefinitionHash())) {
                return true;
            }
        }
        return false;
    }

    private boolean containsHmcDefinitionHash(String hmcDefinitionHash, List<FireflyExtensionStateModel> states) {
        for (FireflyExtensionStateModel state : states) {
            if (StringUtils.equals(hmcDefinitionHash, state.getHmcDefinitionHash())) {
                return true;
            }
        }
        return false;
    }

    private boolean equalsHash(FireflyExtensionStateModel lastState, String itemsDefinitionHash, String hmcDefinitionHash) {
        return lastState != null &&
               StringUtils.equals(lastState.getItemsDefinitionHash(), itemsDefinitionHash) &&
               StringUtils.equals(lastState.getHmcDefinitionHash(), hmcDefinitionHash);
    }

    private String getHashFromFile(File xml, String defaultHash) {
        if (xml.exists()) {
            try {
// Path: src/de/neuland/firefly/migration/MigrationRepository.java
// @Repository
// @Scope("prototype")
// public class MigrationRepository {
//     @Autowired private ModelService modelService;
// 
//     public FireflyMigrationModel findByPk(PK pk) {
//         return modelService.get(pk);
//     }
// 
//     public FireflyMigrationModel create() {
//         return modelService.create(FireflyMigrationModel.class);
//     }
// 
//     public void save(FireflyMigrationModel migration) {
//         modelService.save(migration);
//     }
// }
// 
// Path: src/de/neuland/firefly/constants/FireflyConstants.java
// public static final String NO_HMC_XML_MD5 = "NO_HMC_XML";
// 
// Path: src/de/neuland/firefly/constants/FireflyConstants.java
// public static final String NO_ITEMS_XML_MD5 = "NO_ITEMS_XML";
// 
// Path: src/de/neuland/firefly/utils/MD5Util.java
// public static String generateMD5(String baseValue) {
//     return generateMD5(baseValue, "UTF-8", "MD5");
// }
// 
// Path: src/de/neuland/firefly/utils/XMLUtil.java
// public static String loadAndNormalizeXML(File xmlFile) throws ParserConfigurationException, SAXException, IOException, TransformerException {
//     DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
//     DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
//     Document doc = dBuilder.parse(xmlFile);
// 
//     removeRecursively(doc);
//     doc.normalizeDocument();
// 
//     TransformerFactory tf = TransformerFactory.newInstance();
//     Transformer transformer = tf.newTransformer();
//     transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
//     transformer.setOutputProperty(OutputKeys.INDENT, "no");
//     StringWriter normalizedXml = new StringWriter();
//     transformer.transform(new DOMSource(doc), new StreamResult(normalizedXml));
//     return normalizedXml.toString();
// }


// Path: src/de/neuland/firefly/extensionfinder/FireflyExtension.java
import de.hybris.platform.core.PK;
import de.neuland.firefly.migration.MigrationRepository;
import de.neuland.firefly.model.FireflyExtensionModel;
import de.neuland.firefly.model.FireflyExtensionStateModel;
import de.neuland.firefly.model.FireflyMigrationModel;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.xml.sax.SAXException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import static de.neuland.firefly.constants.FireflyConstants.NO_HMC_XML_MD5;
import static de.neuland.firefly.constants.FireflyConstants.NO_ITEMS_XML_MD5;
import static de.neuland.firefly.utils.MD5Util.generateMD5;
import static de.neuland.firefly.utils.XMLUtil.loadAndNormalizeXML;
import static java.util.Arrays.asList;

        return ToStringBuilder.reflectionToString(this);
    }

    private boolean containsItemDefinitionHash(String itemsDefinitionHash, List<FireflyExtensionStateModel> states) {
        for (FireflyExtensionStateModel state : states) {
            if (StringUtils.equals(itemsDefinitionHash, state.getItemsDefinitionHash())) {
                return true;
            }
        }
        return false;
    }

    private boolean containsHmcDefinitionHash(String hmcDefinitionHash, List<FireflyExtensionStateModel> states) {
        for (FireflyExtensionStateModel state : states) {
            if (StringUtils.equals(hmcDefinitionHash, state.getHmcDefinitionHash())) {
                return true;
            }
        }
        return false;
    }

    private boolean equalsHash(FireflyExtensionStateModel lastState, String itemsDefinitionHash, String hmcDefinitionHash) {
        return lastState != null &&
               StringUtils.equals(lastState.getItemsDefinitionHash(), itemsDefinitionHash) &&
               StringUtils.equals(lastState.getHmcDefinitionHash(), hmcDefinitionHash);
    }

    private String getHashFromFile(File xml, String defaultHash) {
        if (xml.exists()) {
            try {
                return generateMD5(loadAndNormalizeXML(xml));