net.loginbuddy.config/src/main/java/net/loginbuddy/config/loginbuddy/LoginbuddyUtil.java
/**
     * Replaces the current list of clients with the given one. However, the requesting client will not be replaced/ removed!
     * @param requestingClientId the client_id of the client that initiated the method.
     * @param clientsAsJsonString the JSON list of clients to replace the existing ones.
     * @return
     * @throws IllegalArgumentException
     */
Replaces the current list of clients with the given one. However, the requesting client will not be replaced/ removed.
@param requestingClientId the client_id of the client that initiated the method.
@param clientsAsJsonString the JSON list of clients to replace the existing ones.
Replaces the current list of clients with the given one . However the requesting client will not be replaced / removed . @param requestingClientId the client_id of the client that initiated the method . @param clientsAsJsonString the JSON list of clients to replace the existing ones .
public List<Clients> replaceClients(String requestingClientId, String clientsAsJsonString) throws IllegalArgumentException {
        try {
            List<Clients> newClients = new ArrayList<>();
            if(clientsAsJsonString.startsWith("[")) {
                newClients.addAll(Arrays.asList(MAPPER.readValue(clientsAsJsonString, Clients[].class)));
            } else {
                newClients.add(MAPPER.readValue(clientsAsJsonString, Clients.class));
            }
            if(requestingClientId != null) {
                if (getClientConfigByClientId(newClients, requestingClientId) == null) {
                    Clients tempClient = getClientConfigByClientId(requestingClientId);
                    if(tempClient != null) {
                        newClients.add(tempClient);
                    } else {
                        throw new IllegalArgumentException("The given client_id is unknown!");
                    }
                }
            }
            return loader.save(newClients);
        } catch(Exception e) {
            throw new IllegalArgumentException(e.getMessage());
        }
    }
public List < Clients > replaceClients ( String requestingClientId , String clientsAsJsonString ) throws IllegalArgumentException { try { List < Clients > newClients = new ArrayList < > ( ) ; if ( clientsAsJsonString . startsWith ( "[" ) ) { newClients . addAll ( Arrays . asList ( MAPPER . readValue ( clientsAsJsonString , Clients [ ] . class ) ) ) ; } else { newClients . add ( MAPPER . readValue ( clientsAsJsonString , Clients . class ) ) ; } if ( requestingClientId != null ) { if ( getClientConfigByClientId ( newClients , requestingClientId ) == null ) { Clients tempClient = getClientConfigByClientId ( requestingClientId ) ; if ( tempClient != null ) { newClients . add ( tempClient ) ; } else { throw new IllegalArgumentException ( "The given client_id is unknown!" ) ; } } } return loader . save ( newClients ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( e . getMessage ( ) ) ; } }
Replaces the current list of clients with the given one.
Replaces the current list of clients with the given one .