Tabnine Logo
ClientSyncMetaData
Code IndexAdd Tabnine to your IDE (free)

How to use
ClientSyncMetaData
in
org.kaaproject.kaa.server.sync

Best Java code snippets using org.kaaproject.kaa.server.sync.ClientSyncMetaData (Showing top 19 results out of 315)

origin: kaaproject/kaa

private void parseClientSyncMetaData(ClientSync sync,
                   ByteBuffer buf,
                   int options,
                   int payloadLength)
  throws PlatformEncDecException {
 sync.setRequestId(buf.getInt());
 ClientSyncMetaData md = new ClientSyncMetaData();
 if (hasOption(options, CLIENT_META_SYNC_TIMEOUT_OPTION)) {
  md.setTimeout((long) buf.getInt());
 }
 if (hasOption(options, CLIENT_META_SYNC_KEY_HASH_OPTION)) {
  md.setEndpointPublicKeyHash(getNewByteBuffer(buf, PUBLIC_KEY_HASH_SIZE));
 }
 if (hasOption(options, CLIENT_META_SYNC_PROFILE_HASH_OPTION)) {
  md.setProfileHash(getNewByteBuffer(buf, PROFILE_HASH_SIZE));
 }
 if (hasOption(options, CLIENT_META_SYNC_SDK_TOKEN_OPTION)) {
  md.setSdkToken(getUtf8String(buf, Constants.SDK_TOKEN_SIZE));
 }
 sync.setClientSyncMetaData(md);
}
origin: kaaproject/kaa

public String getAppToken() {
 return metaData.getApplicationToken();
}
origin: kaaproject/kaa

 protected EndpointObjectHash getEndpointObjectHash(ClientSync request) {
  return EndpointObjectHash.fromBytes(
    request.getClientSyncMetaData().getEndpointPublicKeyHash().array());
 }
}
origin: kaaproject/kaa

private void addAppTokenToClientSyncMetaData(ClientSyncMetaData clientSyncMetaData) {
 clientSyncMetaData.setApplicationToken(getAppToken(clientSyncMetaData.getSdkToken()));
}
origin: kaaproject/kaa

 metaData.setProfileHash(ByteBuffer.wrap(profile.getProfileHash()));
 context.setProfileSyncResponse(profileSyncResponse);
 LOG.debug("[{}][{}] fetching profile.", context.getEndpointKey(), context.getRequestHash());
 EndpointObjectHash endpointHash = EndpointObjectHash.fromBytes(
   metaData.getEndpointPublicKeyHash().array());
 profile = profileService.getProfile(endpointHash);
 LOG.trace("[{}][{}] fetched profile {}.",
if (!Arrays.equals(profile.getProfileHash(), toByteArray(metaData.getProfileHash()))) {
 LOG.debug("[{}] Profile hash mismatch. Profile resync needed", context.getEndpointKey());
 if (LOG.isTraceEnabled()) {
    MessageEncoderDecoder.bytesToHex(profile.getProfileHash()));
  LOG.trace("[{}] client profile hash is {}", context.getEndpointKey(),
    MessageEncoderDecoder.bytesToHex(toByteArray(metaData.getProfileHash())));
  metaData.getApplicationToken(), context.getEndpointKey(), profile, false);
origin: kaaproject/kaa

request.setRequestId(other.getRequestId());
request.getClientSyncMetaData()
  .setProfileHash(other.getClientSyncMetaData().getProfileHash());
LOG.debug("[{}] Updated request id and profile hash", channelUuid);
ClientSync diff = new ClientSync();
diff.setClientSyncMetaData(other.getClientSyncMetaData());
diff.setUseConfigurationRawSchema(other.isUseConfigurationRawSchema());
if (request.getClientSyncMetaData().getApplicationToken() != null) {
 LOG.debug("Setting application token, as it was null: {}",
   request.getClientSyncMetaData().getApplicationToken());
 diff.getClientSyncMetaData()
   .setApplicationToken(request.getClientSyncMetaData().getApplicationToken());
} else {
 LOG.trace("[{}] Application token is null for request", request);
origin: kaaproject/kaa

private EndpointProfileDto updateEndpoint(String endpointId,
                     int requestHash,
                     ClientSyncMetaData metaData,
                     ProfileClientSync request) {
 LOG.debug("[{}][{}] update endpoint. request: {}", endpointId, requestHash, request);
 EndpointObjectHash endpointKeyHash = EndpointObjectHash.fromBytes(
   toByteArray(metaData.getEndpointPublicKeyHash()));
 UpdateProfileRequest updateRequest = new UpdateProfileRequest(
   metaData.getApplicationToken(),
   endpointKeyHash,
   request.getEndpointAccessToken(),
   request.getProfileBody().array(),
   metaData.getSdkToken());
 EndpointProfileDto endpointProfile = profileService.updateProfile(updateRequest);
 LOG.debug("profile updated. id: {}, endpointKeyHash: {}",
   endpointProfile.getId(), endpointProfile.getEndpointKeyHash());
 return endpointProfile;
}
origin: kaaproject/kaa

private EndpointProfileDto registerEndpoint(String endpointId, int requestHash, ClientSyncMetaData metaData, ProfileClientSync request) {
 LOG.debug("[{}][{}] register endpoint. request: {}", endpointId, requestHash, request);
 byte[] endpointKey = toByteArray(request.getEndpointPublicKey());
 byte[] profileBody = toByteArray(request.getProfileBody());
 RegisterProfileRequest registerProfileRequest = new RegisterProfileRequest(
   metaData.getApplicationToken(), endpointKey,
   metaData.getSdkToken(), profileBody, request.getEndpointAccessToken());
 EndpointProfileDto endpointProfile = profileService.registerProfile(registerProfileRequest);
 LOG.debug("profile registered. id: {}, endpointKeyHash: {}",
   endpointProfile.getId(), endpointProfile.getEndpointKeyHash());
 return endpointProfile;
}
origin: kaaproject/kaa

/**
 * Return true if client sync information is valid or false if not.
 *
 * @return true if valid, false if not
 */
public boolean isValid() {
 ClientSyncMetaData md = this.getClientSyncMetaData();
 // TODO: validate if public key hash matches hash of public key during
 // profile registration command.
 if (md.getProfileHash() == null) {
  ProfileClientSync profileRequest = this.getProfileSync();
  if (profileRequest == null || profileRequest.getEndpointPublicKey() == null) {
   return false;
  }
 }
 return true;
}
origin: kaaproject/kaa

@Override
public SyncContext syncUseConfigurationRawSchema(SyncContext context,
                         boolean useConfigurationRawSchema) {
 EndpointProfileDto profile = context.getEndpointProfile();
 if (profile.isUseConfigurationRawSchema() != useConfigurationRawSchema) {
  ClientSyncMetaData metaData = context.getMetaData();
  EndpointObjectHash endpointKeyHash = EndpointObjectHash.fromBytes(
    toByteArray(metaData.getEndpointPublicKeyHash()));
  profile = profileService.updateProfile(metaData, endpointKeyHash, useConfigurationRawSchema);
  profile = syncProfileState(
    metaData.getApplicationToken(), context.getEndpointKey(), profile, false);
  context.setNotificationVersion(profile);
 }
 return context;
}
origin: kaaproject/kaa

private String getSdkToken(ClientSync request) {
 return request.getClientSyncMetaData().getSdkToken();
}
origin: kaaproject/kaa

private long getDelay(SyncRequestMessage requestMessage, long start) {
 return requestMessage.getRequest()
   .getClientSyncMetaData()
   .getTimeout() - (System.currentTimeMillis() - start);
}
origin: kaaproject/kaa

private static ClientSyncMetaData convert(SyncRequestMetaData source) {
 if (source == null) {
  return null;
 }
 return new ClientSyncMetaData(
   null, source.getSdkToken(), source.getEndpointPublicKeyHash(),
   source.getProfileHash(), source.getTimeout());
}
origin: kaaproject/kaa

 ? !clientSyncMetaData.equals(that.clientSyncMetaData)
 : that.clientSyncMetaData != null) {
return false;
origin: kaaproject/kaa

@Override
public int hashCode() {
 int result = requestId;
 result = 31 * result + (clientSyncMetaData != null ? clientSyncMetaData.hashCode() : 0);
 result = 31 * result + (bootstrapSync != null ? bootstrapSync.hashCode() : 0);
 result = 31 * result + (profileSync != null ? profileSync.hashCode() : 0);
 result = 31 * result + (forceConfigurationSync ? 1 : 0);
 result = 31 * result + (configurationSync != null ? configurationSync.hashCode() : 0);
 result = 31 * result + (forceNotificationSync ? 1 : 0);
 result = 31 * result + (notificationSync != null ? notificationSync.hashCode() : 0);
 result = 31 * result + (userSync != null ? userSync.hashCode() : 0);
 result = 31 * result + (eventSync != null ? eventSync.hashCode() : 0);
 result = 31 * result + (logSync != null ? logSync.hashCode() : 0);
 result = 31 * result + (useConfigurationRawSchema ? 1 : 0);
 return result;
}
origin: kaaproject/kaa

@Override
public EndpointProfileDto updateProfile(ClientSyncMetaData metaData,
                    EndpointObjectHash keyHash,
                    boolean useConfigurationRawSchema) {
 LOG.debug("Updating Profile for {}", keyHash);
 EndpointProfileDto dto = endpointService.findEndpointProfileByKeyHash(keyHash.getData());
 AppSeqNumber appSeqNumber = cacheService.getAppSeqNumber(metaData.getApplicationToken());
 SdkProfileDto sdkProfile = cacheService.getSdkProfileBySdkToken(metaData.getSdkToken());
 Function<EndpointProfileDto, EndpointProfileDto> updateFunction = profile -> {
  populateVersionStates(appSeqNumber.getTenantId(), profile, sdkProfile);
  profile.setGroupState(new ArrayList<>());
  profile.setUseConfigurationRawSchema(useConfigurationRawSchema);
  profile.setSequenceNumber(0);
  return profile;
 };
 return updateProfile(updateFunction.apply(dto), (storedProfile, newProfile) -> {
  return updateFunction.apply(storedProfile);
 });
}
origin: kaaproject/kaa

@Override
public SyncContext syncConfiguration(SyncContext context, ConfigurationClientSync request)
  throws GetDeltaException {
 if (request != null) {
  GetDeltaResponse confResponse = calculateConfigurationDelta(
    context.getMetaData().getApplicationToken(), request, context);
  ConfigurationServerSync confSyncResponse = buildConfSyncResponse(confResponse);
  context.setConfigurationSyncResponse(confSyncResponse);
 }
 return context;
}
origin: kaaproject/kaa

@Override
public SyncContext processEventListenerRequests(SyncContext context, EventClientSync request) {
 if (request != null) {
  ClientSyncMetaData metaData = context.getMetaData();
  LOG.trace("[{}][{}] procesing event sync request {}.",
    context.getEndpointKey(), context.getRequestHash(), request);
  EventServerSync eventSyncResponse = processEventSyncResponse(
    context.getEndpointKey(), context.getRequestHash(),
    metaData.getApplicationToken(), request, context.getEndpointProfile());
  context.setEventSyncResponse(eventSyncResponse);
 }
 return context;
}
origin: kaaproject/kaa

@Override
public SyncContext syncNotification(SyncContext context, NotificationClientSync request) {
 if (request != null) {
  GetNotificationResponse notificationResponse = calculateNotificationDelta(
    context.getMetaData().getApplicationToken(), request,
    context);
  context.setSubscriptionStates(notificationResponse.getSubscriptionStates());
  NotificationServerSync nfSyncResponse = buildNotificationSyncResponse(notificationResponse);
  context.setNotificationSyncResponse(nfSyncResponse);
  if (notificationResponse.isSubscriptionListChanged()) {
   EndpointProfileDto profileDto = context.getEndpointProfile();
   Function<EndpointProfileDto, EndpointProfileDto> updateFunction = profile -> {
    profile.setSubscriptions(new ArrayList<>(notificationResponse.getSubscriptionSet()));
    return profile;
   };
   context.setNotificationVersion(profileService.updateProfile(
     updateFunction.apply(profileDto), (storedProfile, newProfile) -> {
      return updateFunction.apply(storedProfile);
     }));
  }
 }
 return context;
}
org.kaaproject.kaa.server.syncClientSyncMetaData

Most used methods

  • getProfileHash
    Gets the value of the 'profileHash' field.
  • setProfileHash
    Sets the value of the 'profileHash' field.
  • <init>
    All-args constructor.
  • equals
  • getApplicationToken
    Gets the value of the 'applicationToken' field.
  • getEndpointPublicKeyHash
    Gets the value of the 'endpointPublicKeyHash' field.
  • getSdkToken
  • getTimeout
    Gets the value of the 'timeout' field.
  • hashCode
  • setApplicationToken
    Sets the value of the 'applicationToken' field.
  • setEndpointPublicKeyHash
    Sets the value of the 'endpointPublicKeyHash' field.
  • setSdkToken
  • setEndpointPublicKeyHash,
  • setSdkToken,
  • setTimeout

Popular in Java

  • Creating JSON documents from java classes using gson
  • setScale (BigDecimal)
  • getResourceAsStream (ClassLoader)
  • onRequestPermissionsResult (Fragment)
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now