Search in sources :

Example 1 with Certification

use of org.opensmartgridplatform.domain.core.valueobjects.Certification in project open-smart-grid-platform by OSGP.

the class DeviceManagementServiceTest method testUpdateDeviceSslCertification.

@Test
public void testUpdateDeviceSslCertification() throws FunctionalException {
    final Device device = mock(Device.class);
    when(device.getIpAddress()).thenReturn(TEST_IP);
    when(this.deviceDomainService.searchActiveDevice(TEST_DEVICE, ComponentType.DOMAIN_CORE)).thenReturn(device);
    final Certification certification = new Certification("testUrl", "testDomain");
    this.deviceManagementService.updateDeviceSslCertification(TEST_ORGANISATION, TEST_DEVICE, TEST_UID, certification, TEST_MESSAGE_TYPE, TEST_PRIORITY);
    verify(this.osgpCoreRequestManager).send(this.argumentRequestMessage.capture(), this.argumentMessageType.capture(), this.argumentPriority.capture(), this.argumentIpAddress.capture());
    final RequestMessage expectedRequestMessage = this.createNewRequestMessage(this.domainCoreMapper.map(certification, CertificationDto.class));
    assertThat(this.argumentRequestMessage.getValue()).usingRecursiveComparison().isEqualTo(expectedRequestMessage);
    assertThat(this.argumentMessageType.getValue()).isEqualTo(TEST_MESSAGE_TYPE);
    assertThat(this.argumentPriority.getValue()).isEqualTo(TEST_PRIORITY);
    assertThat(this.argumentIpAddress.getValue()).isEqualTo(TEST_IP);
}
Also used : CertificationDto(org.opensmartgridplatform.dto.valueobjects.CertificationDto) Device(org.opensmartgridplatform.domain.core.entities.Device) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) Certification(org.opensmartgridplatform.domain.core.valueobjects.Certification) Test(org.junit.jupiter.api.Test)

Example 2 with Certification

use of org.opensmartgridplatform.domain.core.valueobjects.Certification in project open-smart-grid-platform by OSGP.

the class CommonUpdateDeviceSslCertificationRequestMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) {
    LOGGER.debug("Processing update device ssl certification message");
    String correlationUid = null;
    String messageType = null;
    int messagePriority = MessagePriorityEnum.DEFAULT.getPriority();
    String organisationIdentification = null;
    String deviceIdentification = null;
    try {
        correlationUid = message.getJMSCorrelationID();
        messageType = message.getJMSType();
        messagePriority = message.getJMSPriority();
        organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
        deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
    } catch (final JMSException e) {
        LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
        LOGGER.debug("correlationUid: {}", correlationUid);
        LOGGER.debug("messageType: {}", messageType);
        LOGGER.debug("messagePriority: {}", messagePriority);
        LOGGER.debug("organisationIdentification: {}", organisationIdentification);
        LOGGER.debug("deviceIdentification: {}", deviceIdentification);
        return;
    }
    try {
        final Certification certification = (Certification) message.getObject();
        LOGGER.info("Calling application service function: {}", messageType);
        this.deviceManagementService.updateDeviceSslCertification(organisationIdentification, deviceIdentification, correlationUid, certification, messageType, messagePriority);
    } catch (final Exception e) {
        this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, messageType, messagePriority);
    }
}
Also used : JMSException(javax.jms.JMSException) Certification(org.opensmartgridplatform.domain.core.valueobjects.Certification) JMSException(javax.jms.JMSException)

Example 3 with Certification

use of org.opensmartgridplatform.domain.core.valueobjects.Certification in project open-smart-grid-platform by OSGP.

the class DeviceManagementEndpoint method updateDeviceSslCertification.

@PayloadRoot(localPart = "UpdateDeviceSslCertificationRequest", namespace = DEVICE_MANAGEMENT_NAMESPACE)
@ResponsePayload
public UpdateDeviceSslCertificationAsyncResponse updateDeviceSslCertification(@OrganisationIdentification final String organisationIdentification, @RequestPayload final UpdateDeviceSslCertificationRequest request, @MessagePriority final String messagePriority) throws OsgpException {
    LOGGER.info("Update Device Ssl Certification Request received from organisation: {} for device: {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), messagePriority);
    final UpdateDeviceSslCertificationAsyncResponse response = new UpdateDeviceSslCertificationAsyncResponse();
    try {
        final Certification certification = this.deviceManagementMapper.map(request.getCertification(), Certification.class);
        final String correlationUid = this.deviceManagementService.enqueueUpdateDeviceSslCertificationRequest(organisationIdentification, request.getDeviceIdentification(), certification, MessagePriorityEnum.getMessagePriority(messagePriority));
        final AsyncResponse asyncResponse = new AsyncResponse();
        asyncResponse.setCorrelationUid(correlationUid);
        asyncResponse.setDeviceId(request.getDeviceIdentification());
        response.setAsyncResponse(asyncResponse);
    } catch (final ConstraintViolationException e) {
        throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.WS_CORE, new ValidationException(e.getConstraintViolations()));
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) ConstraintViolationException(javax.validation.ConstraintViolationException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) SetDeviceLifecycleStatusAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.SetDeviceLifecycleStatusAsyncResponse) AsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse) SetDeviceVerificationKeyAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.SetDeviceVerificationKeyAsyncResponse) SetEventNotificationsAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.SetEventNotificationsAsyncResponse) UpdateDeviceCdmaSettingsAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.UpdateDeviceCdmaSettingsAsyncResponse) UpdateDeviceSslCertificationAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.UpdateDeviceSslCertificationAsyncResponse) UpdateDeviceSslCertificationAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.UpdateDeviceSslCertificationAsyncResponse) Certification(org.opensmartgridplatform.domain.core.valueobjects.Certification) ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ConstraintViolationException(javax.validation.ConstraintViolationException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Aggregations

Certification (org.opensmartgridplatform.domain.core.valueobjects.Certification)3 JMSException (javax.jms.JMSException)1 ConstraintViolationException (javax.validation.ConstraintViolationException)1 Test (org.junit.jupiter.api.Test)1 AsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse)1 SetDeviceLifecycleStatusAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.SetDeviceLifecycleStatusAsyncResponse)1 SetDeviceVerificationKeyAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.SetDeviceVerificationKeyAsyncResponse)1 SetEventNotificationsAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.SetEventNotificationsAsyncResponse)1 UpdateDeviceCdmaSettingsAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.UpdateDeviceCdmaSettingsAsyncResponse)1 UpdateDeviceSslCertificationAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.UpdateDeviceSslCertificationAsyncResponse)1 Device (org.opensmartgridplatform.domain.core.entities.Device)1 ValidationException (org.opensmartgridplatform.domain.core.exceptions.ValidationException)1 CertificationDto (org.opensmartgridplatform.dto.valueobjects.CertificationDto)1 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1 RequestMessage (org.opensmartgridplatform.shared.infra.jms.RequestMessage)1 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)1 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)1