class EcmFolderCreatedEventHandler implements ApplicationListener<EcmEvent> {

    public void onEcmFolderCreated(EcmEvent folderCreated)
    {
        log.debug("Handling new folder {}", folderCreated.getNodeId());

        if (getFolderAndFilesUtils().lookupArkCaseFolder(folderCreated.getNodeId()) != null)
        {
            return;
        }

        AcmFolder parentFolder = getFolderAndFilesUtils().lookupArkCaseFolder(folderCreated.getParentNodeId());
        if (parentFolder == null)
        {
            log.debug("Parent folder is not in ArkCase, so not creating the new folder {}", folderCreated.getNodeId());
            return;
        }

        AcmFolder newFolder = prepareFolder(parentFolder, folderCreated);

        try
        {
            // new folder should have creator and modifier of the user that took the action in the ECM system
            getAuditPropertyEntityAdapter().setUserId(folderCreated.getUserId());
            AcmFolder created = getFolderDao().save(newFolder);

            getFileParticipantService().setFolderParticipantsFromParentFolder(created);
            created = getFolderDao().save(created);

            log.debug("Finished creating new folder with node id {}, ArkCase id {}", folderCreated.getNodeId(), created.getId());
        }
        catch (PersistenceException pe)
        {
            log.error("Cannot create new folder with CMIS ID {}: [{}]", folderCreated.getNodeId(), pe.getMessage(), pe);
        }
    }

}