use of no.difi.meldingsutveksling.domain.Organisasjonsnummer in project efm-integrasjonspunkt by felleslosninger.
the class NextMoveOutMessageFactory method setDefaults.
private void setDefaults(StandardBusinessDocument sbd, ServiceRecord serviceRecord) {
sbd.getScopes().stream().filter(p -> !StringUtils.hasText(p.getInstanceIdentifier())).forEach(p -> p.setInstanceIdentifier(uuidGenerator.generate()));
if (sbd.getSenderIdentifier() == null) {
Organisasjonsnummer org = Organisasjonsnummer.from(properties.getOrg().getNumber());
sbd.getStandardBusinessDocumentHeader().addSender(new Sender().setIdentifier(new PartnerIdentification().setValue(org.asIso6523()).setAuthority(org.authority())));
}
DocumentIdentification documentIdentification = sbd.getStandardBusinessDocumentHeader().getDocumentIdentification();
if (documentIdentification.getInstanceIdentifier() == null) {
documentIdentification.setInstanceIdentifier(uuidGenerator.generate());
}
if (documentIdentification.getCreationDateAndTime() == null) {
documentIdentification.setCreationDateAndTime(OffsetDateTime.now(clock));
}
if (!sbd.getExpectedResponseDateTime().isPresent()) {
OffsetDateTime ttl = OffsetDateTime.now(clock).plusHours(properties.getNextmove().getDefaultTtlHours());
if (sbd.getScope(ScopeType.CONVERSATION_ID).getScopeInformation().isEmpty()) {
CorrelationInformation ci = new CorrelationInformation().setExpectedResponseDateTime(ttl);
sbd.getScope(ScopeType.CONVERSATION_ID).getScopeInformation().add(ci);
} else {
sbd.getScope(ScopeType.CONVERSATION_ID).getScopeInformation().stream().findFirst().ifPresent(ci -> ci.setExpectedResponseDateTime(ttl));
}
}
if (serviceRecord.getServiceIdentifier() == DPO && !isNullOrEmpty(properties.getDpo().getMessageChannel())) {
Optional<Scope> mcScope = sbd.findScope(ScopeType.MESSAGE_CHANNEL);
if (!mcScope.isPresent()) {
sbd.getScopes().add(ScopeFactory.fromIdentifier(ScopeType.MESSAGE_CHANNEL, properties.getDpo().getMessageChannel()));
}
if (mcScope.isPresent() && isNullOrEmpty(mcScope.get().getIdentifier())) {
mcScope.get().setIdentifier(properties.getDpo().getMessageChannel());
}
}
if (serviceRecord.getServiceIdentifier() == DPI) {
setDpiDefaults(sbd, serviceRecord);
}
}
use of no.difi.meldingsutveksling.domain.Organisasjonsnummer in project efm-integrasjonspunkt by felleslosninger.
the class SvarInnPutMessageForwarder method forward.
private void forward(Forsendelse forsendelse, Reject reject) {
MDC.put(NextMoveConsts.CORRELATION_ID, forsendelse.getId());
SvarInnPutMessageBuilder builder = new SvarInnPutMessageBuilder(forsendelse, clock, putMessageRequestFactory);
svarInnService.getAttachments(forsendelse, reject).forEach(builder::streamedFile);
if (!Strings.isNullOrEmpty(properties.getFiks().getInn().getFallbackSenderOrgNr())) {
builder.setFallbackSenderOrgNr(properties.getFiks().getInn().getFallbackSenderOrgNr());
}
PutMessageRequestType putMessage = builder.build();
if (builder.getDokumentTypeList().isEmpty()) {
Audit.error("Zipfile is empty: skipping message", Markers.append("fiks-id", forsendelse.getId()));
return;
}
Conversation c = conversationService.registerConversation(new MessageInformable() {
@Override
public String getConversationId() {
return forsendelse.getId();
}
@Override
public String getMessageId() {
return forsendelse.getId();
}
@Override
public Organisasjonsnummer getSender() {
return Organisasjonsnummer.from(putMessage.getEnvelope().getSender().getOrgnr());
}
@Override
public Organisasjonsnummer getReceiver() {
return Organisasjonsnummer.from(putMessage.getEnvelope().getReceiver().getOrgnr());
}
@Override
public String getProcessIdentifier() {
return properties.getArkivmelding().getDefaultProcess();
}
@Override
public String getDocumentIdentifier() {
return properties.getArkivmelding().getDefaultDocumentType();
}
@Override
public ConversationDirection getDirection() {
return ConversationDirection.INCOMING;
}
@Override
public ServiceIdentifier getServiceIdentifier() {
return ServiceIdentifier.DPF;
}
@Override
public OffsetDateTime getExpiry() {
return OffsetDateTime.now(clock).plusHours(properties.getNextmove().getDefaultTtlHours());
}
});
conversationService.registerStatus(c.getMessageId(), INNKOMMENDE_MOTTATT);
String missingFields = getMissingFields(forsendelse, putMessage, builder.getDokumentTypeList());
if (!missingFields.isEmpty()) {
handleError(putMessage, forsendelse.getId(), "Validation failed - missing fields: " + missingFields);
return;
}
final PutMessageResponseType response = localNoark.sendEduMelding(putMessage);
if ("OK".equals(response.getResult().getType())) {
Audit.info("Message successfully forwarded");
conversationService.registerStatus(c.getMessageId(), INNKOMMENDE_LEVERT);
svarInnService.confirmMessage(forsendelse.getId());
} else if ("WARNING".equals(response.getResult().getType())) {
Audit.info(format("Archive system responded with warning for message with fiks-id %s", forsendelse.getId()), PutMessageResponseMarkers.markerFrom(response));
conversationService.registerStatus(c.getMessageId(), INNKOMMENDE_LEVERT);
svarInnService.confirmMessage(forsendelse.getId());
} else {
Audit.error(format("Message with fiks-id %s failed", forsendelse.getId()), PutMessageResponseMarkers.markerFrom(response));
handleError(putMessage, forsendelse.getId(), "Archive system responded with error: " + response.getResult().getMessage().get(0).getText());
}
}
Aggregations