class ServiceClientIdentifierConverter {

    public ServiceClientIdentifierDto convertId(String encodedServiceClientIdentifier)
            throws BadServiceClientIdentifierException {
        ServiceClientIdentifierDto dto = new ServiceClientIdentifierDto();
        if (clientConverter.isEncodedSubsystemId(encodedServiceClientIdentifier)) {
            // subsystem
            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)) {
            // local group
            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 public  ServiceClientIdentifierConverter(ClientConverter clientConverter,
            GlobalGroupConverter globalGroupConverter);

}