class AssessmentPackageFileImporter {

    public AssessmentPackage importAssessmentPackageData(final File importSandboxDirectory,
            final MultipartFile multipartFile)
            throws AssessmentPackageDataImportException {
        Assert.notNull(importSandboxDirectory, "importSandboxDirectory");
        Assert.notNull(multipartFile, "multipartFile");
        AssessmentPackage assessmentPackage = null;

        final String contentType = ServiceUtilities.computeContentType(multipartFile);
        if ("application/xml".equals(contentType) || "text/xml".equals(contentType) || contentType.endsWith("+xml")) {
            /* Looks like an XML content type */
            logger.debug("Import data uses a known XML MIME type {} so saving to {} and treating as XML", contentType, importSandboxDirectory);
            assessmentPackage = importStandaloneXml(importSandboxDirectory, multipartFile);
        }
        else {
            /* Try to treat as a ZIP */
            final boolean zipSuccess = tryUnpackZipFile(importSandboxDirectory, multipartFile);
            if (zipSuccess) {
                logger.debug("Import data was successfully expanded as a ZIP file");
                assessmentPackage = processUnpackedZip(importSandboxDirectory);
            }
            else {
                logger.warn("Import data with MIME type {} was neither a supported XML MIME type nor a ZIP file (containing at least one entry)", contentType);
                throw new AssessmentPackageDataImportException(ImportFailureReason.NOT_XML_OR_ZIP);
            }
        }

        logger.info("Successfully imported data for new {}", assessmentPackage);
        return assessmentPackage;
    }

}