class UpdatePnfEntryInAai implements JavaDelegate {

    @Override
    public void execute(DelegateExecution execution) throws Exception {
        String pnfCorrelationId = String.valueOf(execution.getVariable(PNF_CORRELATION_ID));
        Optional<Pnf> pnfAaiEntry = pnfManagement.getEntryFor(pnfCorrelationId);

        if (!pnfAaiEntry.isPresent()) {
            exceptionUtil.buildAndThrowWorkflowException(execution, 404,
                    "AAI entry for PNF: " + PNF_CORRELATION_ID + " does not exist");
        }

        Pnf pnf = pnfAaiEntry.get();
        String pnfSoftwareVersion = String.valueOf(execution.getVariable(PRC_TARGET_SOFTWARE_VERSION));
        pnf.setSwVersion(pnfSoftwareVersion);

        pnfManagement.updateEntry(pnfCorrelationId, pnf);
        logger.debug("AAI entry is updated for pnf correlation id: {}, pnf uuid: {} with swVersion: {}",
                pnf.getPnfName(), pnfCorrelationId, pnfSoftwareVersion);
    }

}