private static LogServerSync deepCopy(LogServerSync source) { if (source == null) { return null; } if (source.getDeliveryStatuses() != null) { List<LogDeliveryStatus> statusList = new ArrayList<>(source.getDeliveryStatuses().size()); for (LogDeliveryStatus status : source.getDeliveryStatuses()) { statusList.add(new LogDeliveryStatus( status.getRequestId(), status.getResult(), status.getErrorCode())); } return new LogServerSync(statusList); } else { return new LogServerSync(); } }
/** * Convert response map to log server sync <code>LogServerSync</code>. * * @param responseMap the map for converting * @return the <code>LogServerSync</code> instance */ public static LogServerSync convert(Map<Integer, LogDeliveryMessage> responseMap) { List<LogDeliveryStatus> statusList = new ArrayList<>(); for (Entry<Integer, LogDeliveryMessage> response : responseMap.entrySet()) { LogDeliveryMessage message = response.getValue(); statusList.add( new LogDeliveryStatus(response.getKey(), message.isSuccess() ? SyncStatus.SUCCESS : SyncStatus.FAILURE, EntityConvertUtils.toErrorCode(message.getErrorCode()))); } return new LogServerSync(statusList); }
private static LogSyncResponse convert(LogServerSync source) { if (source == null) { return null; } LogSyncResponse sync = new LogSyncResponse(); List<org.kaaproject.kaa.common.endpoint.gen.LogDeliveryStatus> statuses = new ArrayList<>(); for (LogDeliveryStatus status : source.getDeliveryStatuses()) { statuses.add(convert(status)); } sync.setDeliveryStatuses(statuses); return sync; }
if (logSync != null ? !logSync.equals(that.logSync) : that.logSync != null) { return false;
@Override public int hashCode() { int result = requestId; result = 31 * result + (status != null ? status.hashCode() : 0); result = 31 * result + (bootstrapSync != null ? bootstrapSync.hashCode() : 0); result = 31 * result + (profileSync != null ? profileSync.hashCode() : 0); result = 31 * result + (configurationSync != null ? configurationSync.hashCode() : 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 + (redirectSync != null ? redirectSync.hashCode() : 0); result = 31 * result + (logSync != null ? logSync.hashCode() : 0); return result; }
private void encode(GrowingByteBuffer buf, LogServerSync logSync) { List<LogDeliveryStatus> statusList = logSync.getDeliveryStatuses(); int extensionSize = 4; if (statusList != null) { extensionSize += 4 * statusList.size(); } buildExtensionHeader(buf, LOGGING_EXTENSION_ID, NOTHING, NOTHING, extensionSize); if (statusList != null && !statusList.isEmpty()) { buf.putInt(statusList.size()); for (LogDeliveryStatus status : statusList) { buf.putShort((short) status.getRequestId()); buf.put(status.getResult() == SyncStatus.SUCCESS ? SUCCESS : FAILURE); buf.put(status.getErrorCode() != null ? (byte) status.getErrorCode().ordinal() : NOTHING); } } else { buf.putInt(0); } }