Good day, I am new to Hybris and have taken over a project. I have the code below working on my local machine in SAP Hybris 2211.
private void sendLoadOrderDetailsWithAttachment (final BaseSiteModel baseSite,
final ByteArrayOutputStream csvContentStream,
final MyReportEmailProcessModel myEmailProcessModel,
final EmailMessageModel emailMessage,
final String attachmentName)
{
LOG.info("Starting email attachment process");
final DataInputStream dataInputStream = new DataInputStream(new ByteArrayInputStream(csvContentStream.toByteArray()));
final EmailAttachmentModel myEmailAttachment = emailService.createEmailAttachment(
dataInputStream, attachmentName +
configuration.getString(CoreConstants.PICKUPSLOT_FILE_EXTENSION, ".csv"),
configuration.getString(CoreConstants.PICKUPSLOT_FILE_MIME_TYPE, "text/csv"));
myEmailAttachment.setCatalogVersion(getPickupSlotCatalog());
modelService.save(myEmailAttachment);
final List<EmailAttachmentModel> emailAttachments = new ArrayList<>();
emailAttachments.add(myEmailAttachment);
emailMessage.setAttachments(emailAttachments);
modelService.save(emailMessage);
myEmailProcessModel.setAttachments(emailAttachments);
myEmailProcessModel.setEmails(Arrays.asList(emailMessage));
myEmailProcessModel.setSite(baseSite);
myEmailProcessModel.setStore(baseSite.getStores().stream().findFirst().get());
myEmailProcessModel.setLanguage(baseSite.getDefaultLanguage());
modelService.save(myEmailProcessModel);
LOG.info("Email attachment added, sending email");
businessProcessService.startProcess(myEmailProcessModel);
}
private CatalogVersionModel getPickupSlotCatalog()
{
return catalogVersionService.getCatalogVersion(configurationService.getConfiguration().getString("my.catalogID"),
configurationService.getConfiguration().getString("my.catalogVersion"));
}
I have the content catalog set in my properties file to a custom catalog that seems to be the same as the catalog in our cloud environement. However, when I deploy and test the code that is running via a cronjob. I get the error: [de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator@1cff0b24]:missing values for [catalogVersion] in model EmailAttachmentModel () to create a new EmailAttachment This error occurs no matter what I set the catalogID and version to in my cloud environment
When I switch the catalog variable in HAC, for example to a null string on my local machine, I get this error: CatalogVersion with catalogId '' and version '' not found! This makes me believe something is missing in the cloud environment to properly configure this to work, but I am not sure what it could be.
Any help would be appreciated.