@Test public void convert() throws Exception { ClientType clientType = new ClientType(); clientType.setClientStatus("registered"); clientType.setIsAuthentication("SSLNOAUTH"); clientType.setIdentifier(ClientId.create("XRD2", "GOV", "M4", "SS1")); Client converted = clientConverter.convert(clientType); assertEquals("XRD2:GOV:M4:SS1", converted.getId()); assertEquals(ClientStatus.REGISTERED, converted.getStatus()); assertEquals("XRD2", converted.getInstanceId()); assertEquals("GOV", converted.getMemberClass()); assertEquals("M4", converted.getMemberCode()); assertEquals("SS1", converted.getSubsystemCode()); assertEquals(org.niis.xroad.restapi.openapi.model.ConnectionType.HTTPS_NO_AUTH, converted.getConnectionType()); assertEquals(MEMBER_NAME_PREFIX + "M4", converted.getMemberName()); }
public Client convert(ClientType clientType) { Client client = new Client(); client.setId(convertId(clientType.getIdentifier())); client.setInstanceId(clientType.getIdentifier().getXRoadInstance()); client.setMemberClass(clientType.getIdentifier().getMemberClass()); client.setMemberCode(clientType.getIdentifier().getMemberCode()); client.setSubsystemCode(clientType.getIdentifier().getSubsystemCode()); client.setMemberName(globalConfFacade.getMemberName(clientType.getIdentifier())); client.setOwner(clientType.getIdentifier().equals(securityServerOwner.getServerId().getOwner())); client.setHasValidLocalSignCert(ClientUtils.hasValidLocalSignCert(clientType.getIdentifier(), currentSecurityServerSignCertificates.getSignCertificateInfos())); Optional<ClientStatus> status = ClientStatusMapping.map(clientType.getClientStatus()); client.setStatus(status.orElse(null)); Optional<ConnectionType> connectionTypeEnum = ConnectionTypeMapping.map(clientType.getIsAuthentication()); client.setConnectionType(connectionTypeEnum.orElse(null)); return client; }
ClientConverter { public Client convert(ClientType clientType) { Client client = new Client(); client.setId(convertId(clientType.getIdentifier())); client.setInstanceId(clientType.getIdentifier().getXRoadInstance()); client.setMemberClass(clientType.getIdentifier().getMemberClass()); client.setMemberCode(clientType.getIdentifier().getMemberCode()); client.setSubsystemCode(clientType.getIdentifier().getSubsystemCode()); client.setMemberName(globalConfFacade.getMemberName(clientType.getIdentifier())); client.setOwner(clientType.getIdentifier().equals(securityServerOwner.getServerId().getOwner())); client.setHasValidLocalSignCert(ClientUtils.hasValidLocalSignCert(clientType.getIdentifier(), currentSecurityServerSignCertificates.getSignCertificateInfos())); Optional<ClientStatus> status = ClientStatusMapping.map(clientType.getClientStatus()); client.setStatus(status.orElse(null)); Optional<ConnectionType> connectionTypeEnum = ConnectionTypeMapping.map(clientType.getIsAuthentication()); client.setConnectionType(connectionTypeEnum.orElse(null)); return client; } }
ClientConverter { public Client convert(ClientType clientType) { Client client = new Client(); client.setId(convertId(clientType.getIdentifier())); client.setInstanceId(clientType.getIdentifier().getXRoadInstance()); client.setMemberClass(clientType.getIdentifier().getMemberClass()); client.setMemberCode(clientType.getIdentifier().getMemberCode()); client.setSubsystemCode(clientType.getIdentifier().getSubsystemCode()); client.setMemberName(globalConfFacade.getMemberName(clientType.getIdentifier())); client.setOwner(clientType.getIdentifier().equals(securityServerOwner.getServerId().getOwner())); client.setHasValidLocalSignCert(ClientUtils.hasValidLocalSignCert(clientType.getIdentifier(), currentSecurityServerSignCertificates.getSignCertificateInfos())); Optional<ClientStatus> status = ClientStatusMapping.map(clientType.getClientStatus()); client.setStatus(status.orElse(null)); Optional<ConnectionType> connectionTypeEnum = ConnectionTypeMapping.map(clientType.getIsAuthentication()); client.setConnectionType(connectionTypeEnum.orElse(null)); return client; } @Autowired  ClientConverter(GlobalConfFacade globalConfFacade,
            CurrentSecurityServerId securityServerOwner,
            CurrentSecurityServerSignCertificates currentSecurityServerSignCertificates); }
ClientConverter { public Client convert(ClientType clientType) { Client client = new Client(); client.setId(convertId(clientType.getIdentifier())); client.setInstanceId(clientType.getIdentifier().getXRoadInstance()); client.setMemberClass(clientType.getIdentifier().getMemberClass()); client.setMemberCode(clientType.getIdentifier().getMemberCode()); client.setSubsystemCode(clientType.getIdentifier().getSubsystemCode()); client.setMemberName(globalConfFacade.getMemberName(clientType.getIdentifier())); client.setOwner(clientType.getIdentifier().equals(securityServerOwner.getServerId().getOwner())); client.setHasValidLocalSignCert(ClientUtils.hasValidLocalSignCert(clientType.getIdentifier(), currentSecurityServerSignCertificates.getSignCertificateInfos())); Optional<ClientStatus> status = ClientStatusMapping.map(clientType.getClientStatus()); client.setStatus(status.orElse(null)); Optional<ConnectionType> connectionTypeEnum = ConnectionTypeMapping.map(clientType.getIsAuthentication()); client.setConnectionType(connectionTypeEnum.orElse(null)); return client; } @Autowired  ClientConverter(GlobalConfFacade globalConfFacade,
            CurrentSecurityServerId securityServerOwner,
            CurrentSecurityServerSignCertificates currentSecurityServerSignCertificates); Client convert(ClientType clientType); List<Client> convert(Iterable<ClientType> clientTypes); String convertId(ClientId clientId); String convertId(ClientId clientId, boolean includeType); ClientId convertId(String encodedId); List<ClientId> convertIds(List<String> encodedIds); Client convertMemberInfoToClient(MemberInfo memberInfo); List<Client> convertMemberInfosToClients(List<MemberInfo> memberInfos); boolean isEncodedSubsystemId(String encodedId); boolean isEncodedMemberId(String encodedId); boolean isEncodedClientId(String encodedId); }
ClientConverter { public Client convert(ClientType clientType) { Client client = new Client(); client.setId(convertId(clientType.getIdentifier())); client.setInstanceId(clientType.getIdentifier().getXRoadInstance()); client.setMemberClass(clientType.getIdentifier().getMemberClass()); client.setMemberCode(clientType.getIdentifier().getMemberCode()); client.setSubsystemCode(clientType.getIdentifier().getSubsystemCode()); client.setMemberName(globalConfFacade.getMemberName(clientType.getIdentifier())); client.setOwner(clientType.getIdentifier().equals(securityServerOwner.getServerId().getOwner())); client.setHasValidLocalSignCert(ClientUtils.hasValidLocalSignCert(clientType.getIdentifier(), currentSecurityServerSignCertificates.getSignCertificateInfos())); Optional<ClientStatus> status = ClientStatusMapping.map(clientType.getClientStatus()); client.setStatus(status.orElse(null)); Optional<ConnectionType> connectionTypeEnum = ConnectionTypeMapping.map(clientType.getIsAuthentication()); client.setConnectionType(connectionTypeEnum.orElse(null)); return client; } @Autowired  ClientConverter(GlobalConfFacade globalConfFacade,
            CurrentSecurityServerId securityServerOwner,
            CurrentSecurityServerSignCertificates currentSecurityServerSignCertificates); Client convert(ClientType clientType); List<Client> convert(Iterable<ClientType> clientTypes); String convertId(ClientId clientId); String convertId(ClientId clientId, boolean includeType); ClientId convertId(String encodedId); List<ClientId> convertIds(List<String> encodedIds); Client convertMemberInfoToClient(MemberInfo memberInfo); List<Client> convertMemberInfosToClients(List<MemberInfo> memberInfos); boolean isEncodedSubsystemId(String encodedId); boolean isEncodedMemberId(String encodedId); boolean isEncodedClientId(String encodedId); static final int INSTANCE_INDEX; static final int MEMBER_CLASS_INDEX; static final int MEMBER_CODE_INDEX; static final int SUBSYSTEM_CODE_INDEX; }