private void insertOrUpdateToken ( io . motown . ocpi . dto . Token tokenUpdate , Integer subscriptionId ) { Token token = ocpiRepository . findTokenByUidAndIssuingCompany ( tokenUpdate . uid , tokenUpdate . issuer ) ; if ( token == null ) { token = new Token ( ) ; token . setUid ( tokenUpdate . uid ) ; token . setSubscriptionId ( subscriptionId ) ; token . setDateCreated ( new Date ( ) ) ; } token . setTokenType ( tokenUpdate . type ) ; token . setAuthId ( tokenUpdate . auth_id ) ; token . setVisualNumber ( tokenUpdate . visual_number ) ; token . setIssuingCompany ( tokenUpdate . issuer ) ; token . setValid ( tokenUpdate . valid ) ; token . setWhitelist ( tokenUpdate . whitelist ) ; token . setLanguageCode ( tokenUpdate . languageCode ) ; try { token . setLastUpdated ( AppConfig . DATE_FORMAT . parse ( tokenUpdate . last_updated ) ) ; } catch ( ParseException e ) { throw new RuntimeException ( e ) ; } ocpiRepository . insertOrUpdate ( token ) ; }
Inserts a token or updates it if an existing token is found with the same uid and issuing - company