Search in sources :

Example 6 with BindingMode

use of org.eclipse.leshan.core.request.BindingMode in project leshan by eclipse.

the class RegistrationUpdate method update.

/**
 * Returns an updated version of the registration.
 *
 * @param registration the registration to update
 * @return the updated registration
 */
public Registration update(Registration registration) {
    Identity identity = this.identity != null ? this.identity : registration.getIdentity();
    Link[] linkObject = this.objectLinks != null ? this.objectLinks : registration.getObjectLinks();
    long lifeTimeInSec = this.lifeTimeInSec != null ? this.lifeTimeInSec : registration.getLifeTimeInSec();
    BindingMode bindingMode = this.bindingMode != null ? this.bindingMode : registration.getBindingMode();
    String smsNumber = this.smsNumber != null ? this.smsNumber : registration.getSmsNumber();
    Map<String, String> additionalAttributes = this.additionalAttributes.isEmpty() ? registration.getAdditionalRegistrationAttributes() : updateAdditionalAttributes(registration.getAdditionalRegistrationAttributes());
    // this needs to be done in any case, even if no properties have changed, in order
    // to extend the client registration time-to-live period ...
    Date lastUpdate = new Date();
    Registration.Builder builder = new Registration.Builder(registration.getId(), registration.getEndpoint(), identity, registration.getRegistrationEndpointAddress());
    builder.lwM2mVersion(registration.getLwM2mVersion()).lifeTimeInSec(lifeTimeInSec).smsNumber(smsNumber).bindingMode(bindingMode).objectLinks(linkObject).registrationDate(registration.getRegistrationDate()).lastUpdate(lastUpdate).additionalRegistrationAttributes(additionalAttributes);
    return builder.build();
}
Also used : Identity(org.eclipse.leshan.core.request.Identity) Link(org.eclipse.leshan.Link) BindingMode(org.eclipse.leshan.core.request.BindingMode) Date(java.util.Date)

Aggregations

Link (org.eclipse.leshan.Link)6 BindingMode (org.eclipse.leshan.core.request.BindingMode)6 HashMap (java.util.HashMap)4 Identity (org.eclipse.leshan.core.request.Identity)4 EndpointContextUtil.extractIdentity (org.eclipse.leshan.core.californium.EndpointContextUtil.extractIdentity)2 JsonArray (com.eclipsesource.json.JsonArray)1 JsonObject (com.eclipsesource.json.JsonObject)1 JsonValue (com.eclipsesource.json.JsonValue)1 InetSocketAddress (java.net.InetSocketAddress)1 Date (java.util.Date)1 RegisterRequest (org.eclipse.leshan.core.request.RegisterRequest)1 UpdateRequest (org.eclipse.leshan.core.request.UpdateRequest)1 RegisterResponse (org.eclipse.leshan.core.response.RegisterResponse)1 UpdateResponse (org.eclipse.leshan.core.response.UpdateResponse)1 RegistrationUpdate (org.eclipse.leshan.server.registration.RegistrationUpdate)1