public Subscription updateSubscription(SubscriptionUpdate subscriptionUpdate) {

		Subscription subscription = ocpiRepository
				.findSubscriptionByAuthorizationToken(subscriptionUpdate.authorizationToken);

		subscription.getEndpoints().clear();
		// store business details, version and endpoints for this subscription
		io.motown.ocpi.persistence.entities.BusinessDetails businessDetails = new io.motown.ocpi.persistence.entities.BusinessDetails();
		businessDetails.setName(subscriptionUpdate.credentials.business_details.name);
		businessDetails.setWebsite(subscriptionUpdate.credentials.business_details.website);

		subscription.setPartnerAuthorizationToken(subscriptionUpdate.credentials.token);

		subscription.setOcpiVersion(subscriptionUpdate.versionDetails.version);
		for (io.motown.ocpi.dto.Endpoint endpointDto : subscriptionUpdate.versionDetails.endpoints) {

			Endpoint endpoint = new Endpoint();
			endpoint.setIdentifier(endpointDto.identifier);
			endpoint.setUrl(endpointDto.url);
			// because the endpoints in 'versionInformationResponse' are not
			// DTO's (yet) we must instantiate ModuleIdentifier from value
			subscription.addToEndpoints(endpoint);
		}
		// generate new token which will invalidate the token that existed
		subscription.generateNewAuthorizationToken();

		return ocpiRepository.insertOrUpdate(subscription);
	}
public Subscription updateSubscription ( SubscriptionUpdate subscriptionUpdate ) { Subscription subscription = ocpiRepository . findSubscriptionByAuthorizationToken ( subscriptionUpdate . authorizationToken ) ; subscription . getEndpoints ( ) . clear ( ) ; io . motown . ocpi . persistence . entities . BusinessDetails businessDetails = new io . motown . ocpi . persistence . entities . BusinessDetails ( ) ; businessDetails . setName ( subscriptionUpdate . credentials . business_details . name ) ; businessDetails . setWebsite ( subscriptionUpdate . credentials . business_details . website ) ; subscription . setPartnerAuthorizationToken ( subscriptionUpdate . credentials . token ) ; subscription . setOcpiVersion ( subscriptionUpdate . versionDetails . version ) ; for ( io . motown . ocpi . dto . Endpoint endpointDto : subscriptionUpdate . versionDetails . endpoints ) { Endpoint endpoint = new Endpoint ( ) ; endpoint . setIdentifier ( endpointDto . identifier ) ; endpoint . setUrl ( endpointDto . url ) ; subscription . addToEndpoints ( endpoint ) ; } subscription . generateNewAuthorizationToken ( ) ; return ocpiRepository . insertOrUpdate ( subscription ) ; }
updateSubscription

@param subscriptionUpdate
@return persisted Subscription