@Test public void convertGlobalGroup() throws Exception { ServiceClientIdentifierDto dto = converter.convertId("DEV:security-server-owners"); assertEquals(false, dto.isLocalGroup()); assertEquals(null, dto.getLocalGroupId()); assertEquals(XRoadObjectType.GLOBALGROUP, dto.getXRoadId().getObjectType()); assertTrue(dto.getXRoadId() instanceof GlobalGroupId); GlobalGroupId globalGroupId = (GlobalGroupId) dto.getXRoadId(); assertEquals("security-server-owners", globalGroupId.getGroupCode()); assertEquals("DEV", globalGroupId.getXRoadInstance()); }
public ServiceClientIdentifierDto convertId(String encodedServiceClientIdentifier) throws BadServiceClientIdentifierException { ServiceClientIdentifierDto dto = new ServiceClientIdentifierDto(); if (clientConverter.isEncodedSubsystemId(encodedServiceClientIdentifier)) { ClientId clientId = clientConverter.convertId(encodedServiceClientIdentifier); dto.setXRoadId(clientId); } else if (globalGroupConverter.isEncodedGlobalGroupId(encodedServiceClientIdentifier)) { GlobalGroupId globalGroupId = globalGroupConverter.convertId(encodedServiceClientIdentifier); dto.setXRoadId(globalGroupId); } else if (StringUtils.isNumeric(encodedServiceClientIdentifier)) { Long id; try { id = Long.parseLong(encodedServiceClientIdentifier); } catch (NumberFormatException e) { throw new BadServiceClientIdentifierException(encodedServiceClientIdentifier); } dto.setLocalGroupId(id); } else { throw new BadServiceClientIdentifierException(encodedServiceClientIdentifier); } return dto; }
ServiceClientIdentifierConverter { public ServiceClientIdentifierDto convertId(String encodedServiceClientIdentifier) throws BadServiceClientIdentifierException { ServiceClientIdentifierDto dto = new ServiceClientIdentifierDto(); if (clientConverter.isEncodedSubsystemId(encodedServiceClientIdentifier)) { ClientId clientId = clientConverter.convertId(encodedServiceClientIdentifier); dto.setXRoadId(clientId); } else if (globalGroupConverter.isEncodedGlobalGroupId(encodedServiceClientIdentifier)) { GlobalGroupId globalGroupId = globalGroupConverter.convertId(encodedServiceClientIdentifier); dto.setXRoadId(globalGroupId); } else if (StringUtils.isNumeric(encodedServiceClientIdentifier)) { Long id; try { id = Long.parseLong(encodedServiceClientIdentifier); } catch (NumberFormatException e) { throw new BadServiceClientIdentifierException(encodedServiceClientIdentifier); } dto.setLocalGroupId(id); } else { throw new BadServiceClientIdentifierException(encodedServiceClientIdentifier); } return dto; } }
ServiceClientIdentifierConverter { public ServiceClientIdentifierDto convertId(String encodedServiceClientIdentifier) throws BadServiceClientIdentifierException { ServiceClientIdentifierDto dto = new ServiceClientIdentifierDto(); if (clientConverter.isEncodedSubsystemId(encodedServiceClientIdentifier)) { ClientId clientId = clientConverter.convertId(encodedServiceClientIdentifier); dto.setXRoadId(clientId); } else if (globalGroupConverter.isEncodedGlobalGroupId(encodedServiceClientIdentifier)) { GlobalGroupId globalGroupId = globalGroupConverter.convertId(encodedServiceClientIdentifier); dto.setXRoadId(globalGroupId); } else if (StringUtils.isNumeric(encodedServiceClientIdentifier)) { Long id; try { id = Long.parseLong(encodedServiceClientIdentifier); } catch (NumberFormatException e) { throw new BadServiceClientIdentifierException(encodedServiceClientIdentifier); } dto.setLocalGroupId(id); } else { throw new BadServiceClientIdentifierException(encodedServiceClientIdentifier); } return dto; } @Autowired  ServiceClientIdentifierConverter(ClientConverter clientConverter,
            GlobalGroupConverter globalGroupConverter); }
ServiceClientIdentifierConverter { public ServiceClientIdentifierDto convertId(String encodedServiceClientIdentifier) throws BadServiceClientIdentifierException { ServiceClientIdentifierDto dto = new ServiceClientIdentifierDto(); if (clientConverter.isEncodedSubsystemId(encodedServiceClientIdentifier)) { ClientId clientId = clientConverter.convertId(encodedServiceClientIdentifier); dto.setXRoadId(clientId); } else if (globalGroupConverter.isEncodedGlobalGroupId(encodedServiceClientIdentifier)) { GlobalGroupId globalGroupId = globalGroupConverter.convertId(encodedServiceClientIdentifier); dto.setXRoadId(globalGroupId); } else if (StringUtils.isNumeric(encodedServiceClientIdentifier)) { Long id; try { id = Long.parseLong(encodedServiceClientIdentifier); } catch (NumberFormatException e) { throw new BadServiceClientIdentifierException(encodedServiceClientIdentifier); } dto.setLocalGroupId(id); } else { throw new BadServiceClientIdentifierException(encodedServiceClientIdentifier); } return dto; } @Autowired  ServiceClientIdentifierConverter(ClientConverter clientConverter,
            GlobalGroupConverter globalGroupConverter); ServiceClientIdentifierDto convertId(String encodedServiceClientIdentifier); List<ServiceClientIdentifierDto> convertIds(Iterable<String> encodedServiceClientIdentifiers); }
ServiceClientIdentifierConverter { public ServiceClientIdentifierDto convertId(String encodedServiceClientIdentifier) throws BadServiceClientIdentifierException { ServiceClientIdentifierDto dto = new ServiceClientIdentifierDto(); if (clientConverter.isEncodedSubsystemId(encodedServiceClientIdentifier)) { ClientId clientId = clientConverter.convertId(encodedServiceClientIdentifier); dto.setXRoadId(clientId); } else if (globalGroupConverter.isEncodedGlobalGroupId(encodedServiceClientIdentifier)) { GlobalGroupId globalGroupId = globalGroupConverter.convertId(encodedServiceClientIdentifier); dto.setXRoadId(globalGroupId); } else if (StringUtils.isNumeric(encodedServiceClientIdentifier)) { Long id; try { id = Long.parseLong(encodedServiceClientIdentifier); } catch (NumberFormatException e) { throw new BadServiceClientIdentifierException(encodedServiceClientIdentifier); } dto.setLocalGroupId(id); } else { throw new BadServiceClientIdentifierException(encodedServiceClientIdentifier); } return dto; } @Autowired  ServiceClientIdentifierConverter(ClientConverter clientConverter,
            GlobalGroupConverter globalGroupConverter); ServiceClientIdentifierDto convertId(String encodedServiceClientIdentifier); List<ServiceClientIdentifierDto> convertIds(Iterable<String> encodedServiceClientIdentifiers);  }