Skip to content

Commit

Permalink
KAA-807: Changed sonar exclusions. Fixed major project issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
sashadidukh committed Jan 8, 2016
1 parent ba97ef6 commit 607e2a5
Show file tree
Hide file tree
Showing 40 changed files with 128 additions and 177 deletions.
Expand Up @@ -236,13 +236,13 @@ private void processUnion(Schema schema, GenerationContext genContext) {
context.put("TypeConverter", TypeConverter.class); context.put("TypeConverter", TypeConverter.class);
context.put("namespacePrefix", namespacePrefix); context.put("namespacePrefix", namespacePrefix);


StringWriter headerWriter = new StringWriter(); StringWriter hdrWriter = new StringWriter();
engine.getTemplate("union.h.vm").merge(context, headerWriter); engine.getTemplate("union.h.vm").merge(context, hdrWriter);
appendResult(headerWriter.toString(), true); appendResult(hdrWriter.toString(), true);


StringWriter sourceWriter = new StringWriter(); StringWriter srcWriter = new StringWriter();
engine.getTemplate("union.c.vm").merge(context, sourceWriter); engine.getTemplate("union.c.vm").merge(context, srcWriter);
appendResult(sourceWriter.toString(), false); appendResult(srcWriter.toString(), false);
} }


private void processRecord(Schema schema) { private void processRecord(Schema schema) {
Expand All @@ -253,13 +253,13 @@ private void processRecord(Schema schema) {
context.put("TypeConverter", TypeConverter.class); context.put("TypeConverter", TypeConverter.class);
context.put("namespacePrefix", namespacePrefix); context.put("namespacePrefix", namespacePrefix);


StringWriter headerWriter = new StringWriter(); StringWriter hdrWriter = new StringWriter();
engine.getTemplate("record.h.vm").merge(context, headerWriter); engine.getTemplate("record.h.vm").merge(context, hdrWriter);
appendResult(headerWriter.toString(), true); appendResult(hdrWriter.toString(), true);


StringWriter sourceWriter = new StringWriter(); StringWriter srcWriter = new StringWriter();
engine.getTemplate("record.c.vm").merge(context, sourceWriter); engine.getTemplate("record.c.vm").merge(context, srcWriter);
appendResult(sourceWriter.toString(), false); appendResult(srcWriter.toString(), false);
} }


private void processEnum(Schema schema) { private void processEnum(Schema schema) {
Expand Down
Expand Up @@ -58,14 +58,14 @@ public String getFieldName() {
} }


public boolean isTypeOut() { public boolean isTypeOut() {
return (direction != DirectionType.IN); return direction != DirectionType.IN;
} }


public boolean isTypeIn() { public boolean isTypeIn() {
return (direction != DirectionType.OUT); return direction != DirectionType.OUT;
} }


public boolean isTypeInOut() { public boolean isTypeInOut() {
return (direction == DirectionType.INOUT); return direction == DirectionType.INOUT;
} }
} }
Expand Up @@ -62,6 +62,6 @@ public static String toUpperUnderScore(String camelCaseName) {


public static String removePackageName(String fullClassName) { public static String removePackageName(String fullClassName) {
int index = fullClassName.lastIndexOf('.'); int index = fullClassName.lastIndexOf('.');
return (index == -1 ? fullClassName : fullClassName.substring(index + 1)); return index == -1 ? fullClassName : fullClassName.substring(index + 1);
} }
} }
Expand Up @@ -126,57 +126,57 @@ public static boolean isRecordNeedDeallocator(Schema schema) {


public static boolean isAvroPrimitive(Schema schema) { public static boolean isAvroPrimitive(Schema schema) {
Type type = schema.getType(); Type type = schema.getType();
return (type == Type.BOOLEAN || type == Type.INT || type == Type.LONG || return type == Type.BOOLEAN || type == Type.INT || type == Type.LONG ||
type == Type.ENUM || type == Type.FLOAT || type == Type.DOUBLE); type == Type.ENUM || type == Type.FLOAT || type == Type.DOUBLE;
} }


public static boolean isAvroNull(Schema schema) { public static boolean isAvroNull(Schema schema) {
return (schema.getType() == Type.NULL); return schema.getType() == Type.NULL;
} }


public static boolean isAvroFixed(Schema schema) { public static boolean isAvroFixed(Schema schema) {
return (schema.getType() == Type.FIXED); return schema.getType() == Type.FIXED;
} }


public static boolean isAvroRecord(Schema schema) { public static boolean isAvroRecord(Schema schema) {
return (schema.getType() == Type.RECORD); return schema.getType() == Type.RECORD;
} }


public static boolean isAvroUnion(Schema schema) { public static boolean isAvroUnion(Schema schema) {
return (schema.getType() == Type.UNION); return schema.getType() == Type.UNION;
} }


public static boolean isAvroArray(Schema schema) { public static boolean isAvroArray(Schema schema) {
return (schema.getType() == Type.ARRAY); return schema.getType() == Type.ARRAY;
} }


public static boolean isAvroEnum(Schema schema) { public static boolean isAvroEnum(Schema schema) {
return (schema.getType() == Type.ENUM); return schema.getType() == Type.ENUM;
} }


public static boolean isAvroString(Schema schema) { public static boolean isAvroString(Schema schema) {
return (schema.getType() == Type.STRING); return schema.getType() == Type.STRING;
} }


public static boolean isAvroBytes(Schema schema) { public static boolean isAvroBytes(Schema schema) {
return (schema.getType() == Type.BYTES); return schema.getType() == Type.BYTES;
} }


public static boolean isAvroFloat(Schema schema) { public static boolean isAvroFloat(Schema schema) {
return (schema.getType() == Type.FLOAT); return schema.getType() == Type.FLOAT;
} }


public static boolean isAvroDouble(Schema schema) { public static boolean isAvroDouble(Schema schema) {
return (schema.getType() == Type.DOUBLE); return schema.getType() == Type.DOUBLE;
} }


public static boolean isTypeOut(Schema schema) { public static boolean isTypeOut(Schema schema) {
String prop = schema.getProp(DIRECTION_FIELD); String prop = schema.getProp(DIRECTION_FIELD);
return (prop == null || prop.equalsIgnoreCase("out")); return prop == null || prop.equalsIgnoreCase("out");
} }


public static boolean isTypeIn(Schema schema) { public static boolean isTypeIn(Schema schema) {
String prop = schema.getProp(DIRECTION_FIELD); String prop = schema.getProp(DIRECTION_FIELD);
return (prop == null || prop.equalsIgnoreCase("in")); return prop == null || prop.equalsIgnoreCase("in");
} }
} }
Expand Up @@ -209,12 +209,12 @@ protected void setClientState(State state) {
bootstrapManager.setChannelManager(channelManager); bootstrapManager.setChannelManager(channelManager);
bootstrapManager.setFailoverManager(failoverManager); bootstrapManager.setFailoverManager(failoverManager);


profileManager = buildProfileManager(properties, kaaClientState, transportContext); profileManager = buildProfileManager(transportContext);
notificationManager = buildNotificationManager(properties, kaaClientState, transportContext); notificationManager = buildNotificationManager(kaaClientState, transportContext);
eventManager = buildEventManager(properties, kaaClientState, transportContext); eventManager = buildEventManager(kaaClientState, transportContext);
endpointRegistrationManager = buildRegistrationManager(properties, kaaClientState, transportContext); endpointRegistrationManager = buildRegistrationManager(kaaClientState, transportContext);
logCollector = buildLogCollector(properties, kaaClientState, transportContext); logCollector = buildLogCollector(transportContext);
configurationManager = buildConfigurationManager(properties, kaaClientState, transportContext, context.getExecutorContext()); configurationManager = buildConfigurationManager(properties, kaaClientState, context.getExecutorContext());


transportContext.getRedirectionTransport().setBootstrapManager(bootstrapManager); transportContext.getRedirectionTransport().setBootstrapManager(bootstrapManager);
transportContext.getBootstrapTransport().setBootstrapManager(bootstrapManager); transportContext.getBootstrapTransport().setBootstrapManager(bootstrapManager);
Expand Down Expand Up @@ -583,13 +583,13 @@ public void setDetachedListener(DetachEndpointFromUserCallback listener) {


protected TransportContext buildTransportContext(KaaClientProperties properties, KaaClientState kaaClientState) { protected TransportContext buildTransportContext(KaaClientProperties properties, KaaClientState kaaClientState) {
BootstrapTransport bootstrapTransport = buildBootstrapTransport(properties, kaaClientState); BootstrapTransport bootstrapTransport = buildBootstrapTransport(properties, kaaClientState);
ProfileTransport profileTransport = buildProfileTransport(properties, kaaClientState); ProfileTransport profileTransport = buildProfileTransport();
EventTransport eventTransport = buildEventTransport(properties, kaaClientState); EventTransport eventTransport = buildEventTransport(kaaClientState);
NotificationTransport notificationTransport = buildNotificationTransport(properties, kaaClientState); NotificationTransport notificationTransport = buildNotificationTransport();
ConfigurationTransport configurationTransport = buildConfigurationTransport(properties, kaaClientState); ConfigurationTransport configurationTransport = buildConfigurationTransport();
UserTransport userTransport = buildUserTransport(properties, kaaClientState); UserTransport userTransport = buildUserTransport();
RedirectionTransport redirectionTransport = buildRedirectionTransport(properties, kaaClientState); RedirectionTransport redirectionTransport = buildRedirectionTransport();
LogTransport logTransport = buildLogTransport(properties, kaaClientState); LogTransport logTransport = buildLogTransport();




EndpointObjectHash publicKeyHash = EndpointObjectHash.fromSHA1(kaaClientState.getPublicKey().getEncoded()); EndpointObjectHash publicKeyHash = EndpointObjectHash.fromSHA1(kaaClientState.getPublicKey().getEncoded());
Expand All @@ -604,9 +604,9 @@ protected TransportContext buildTransportContext(KaaClientProperties properties,
} }


protected KaaInternalChannelManager buildChannelManager(BootstrapManager bootstrapManager, Map<TransportProtocolId, List<TransportConnectionInfo>> bootstrapServers) { protected KaaInternalChannelManager buildChannelManager(BootstrapManager bootstrapManager, Map<TransportProtocolId, List<TransportConnectionInfo>> bootstrapServers) {
KaaInternalChannelManager channelManager = new DefaultChannelManager(bootstrapManager, bootstrapServers, context.getExecutorContext()); KaaInternalChannelManager kaaInternalChannelManager = new DefaultChannelManager(bootstrapManager, bootstrapServers, context.getExecutorContext());
channelManager.setConnectivityChecker(context.createConnectivityChecker()); kaaInternalChannelManager.setConnectivityChecker(context.createConnectivityChecker());
return channelManager; return kaaInternalChannelManager;
} }


protected void initializeChannels(KaaInternalChannelManager channelManager, TransportContext transportContext) { protected void initializeChannels(KaaInternalChannelManager channelManager, TransportContext transportContext) {
Expand Down Expand Up @@ -639,28 +639,28 @@ protected FailoverManager buildFailoverManager(KaaChannelManager channelManager)
} }


protected ResyncConfigurationManager buildConfigurationManager(KaaClientProperties properties, KaaClientState kaaClientState, protected ResyncConfigurationManager buildConfigurationManager(KaaClientProperties properties, KaaClientState kaaClientState,
TransportContext transportContext, ExecutorContext executorContext) { ExecutorContext executorContext) {
return new ResyncConfigurationManager(properties, kaaClientState, executorContext); return new ResyncConfigurationManager(properties, kaaClientState, executorContext);
} }


protected DefaultLogCollector buildLogCollector(KaaClientProperties properties, KaaClientState kaaClientState, TransportContext transportContext) { protected DefaultLogCollector buildLogCollector(TransportContext transportContext) {
return new DefaultLogCollector(transportContext.getLogTransport(), context.getExecutorContext(), channelManager, failoverManager); return new DefaultLogCollector(transportContext.getLogTransport(), context.getExecutorContext(), channelManager, failoverManager);
} }


protected DefaultEndpointRegistrationManager buildRegistrationManager(KaaClientProperties properties, KaaClientState kaaClientState, TransportContext transportContext) { protected DefaultEndpointRegistrationManager buildRegistrationManager(KaaClientState kaaClientState, TransportContext transportContext) {
return new DefaultEndpointRegistrationManager(kaaClientState, context.getExecutorContext(), return new DefaultEndpointRegistrationManager(kaaClientState, context.getExecutorContext(),
transportContext.getUserTransport(), transportContext.getProfileTransport()); transportContext.getUserTransport(), transportContext.getProfileTransport());
} }


protected DefaultEventManager buildEventManager(KaaClientProperties properties, KaaClientState kaaClientState, TransportContext transportContext) { protected DefaultEventManager buildEventManager(KaaClientState kaaClientState, TransportContext transportContext) {
return new DefaultEventManager(kaaClientState, context.getExecutorContext(), transportContext.getEventTransport()); return new DefaultEventManager(kaaClientState, context.getExecutorContext(), transportContext.getEventTransport());
} }


protected DefaultNotificationManager buildNotificationManager(KaaClientProperties properties, KaaClientState kaaClientState, TransportContext transportContext) { protected DefaultNotificationManager buildNotificationManager(KaaClientState kaaClientState, TransportContext transportContext) {
return new DefaultNotificationManager(kaaClientState, context.getExecutorContext(), transportContext.getNotificationTransport()); return new DefaultNotificationManager(kaaClientState, context.getExecutorContext(), transportContext.getNotificationTransport());
} }


protected ProfileManager buildProfileManager(KaaClientProperties properties, KaaClientState kaaClientState, TransportContext transportContext) { protected ProfileManager buildProfileManager(TransportContext transportContext) {
return new DefaultProfileManager(transportContext.getProfileTransport()); return new DefaultProfileManager(transportContext.getProfileTransport());
} }


Expand All @@ -676,37 +676,37 @@ protected BootstrapTransport buildBootstrapTransport(KaaClientProperties propert
return new DefaultBootstrapTransport(properties.getSdkToken()); return new DefaultBootstrapTransport(properties.getSdkToken());
} }


protected ProfileTransport buildProfileTransport(KaaClientProperties properties, KaaClientState kaaClientState) { protected ProfileTransport buildProfileTransport() {
ProfileTransport transport = new DefaultProfileTransport(); ProfileTransport transport = new DefaultProfileTransport();
transport.setClientProperties(this.properties); transport.setClientProperties(this.properties);
return transport; return transport;
} }


protected ConfigurationTransport buildConfigurationTransport(KaaClientProperties properties, KaaClientState kaaClientState) { protected ConfigurationTransport buildConfigurationTransport() {
ConfigurationTransport transport = new DefaultConfigurationTransport(); ConfigurationTransport transport = new DefaultConfigurationTransport();
// TODO: this should be part of properties and provided by user during // TODO: this should be part of properties and provided by user during
// SDK generation // SDK generation
transport.setResyncOnly(true); transport.setResyncOnly(true);
return transport; return transport;
} }


protected NotificationTransport buildNotificationTransport(KaaClientProperties properties, KaaClientState kaaClientState) { protected NotificationTransport buildNotificationTransport() {
return new DefaultNotificationTransport(); return new DefaultNotificationTransport();
} }


protected DefaultUserTransport buildUserTransport(KaaClientProperties properties, KaaClientState kaaClientState) { protected DefaultUserTransport buildUserTransport() {
return new DefaultUserTransport(); return new DefaultUserTransport();
} }


protected EventTransport buildEventTransport(KaaClientProperties properties, KaaClientState kaaClientState) { protected EventTransport buildEventTransport(KaaClientState kaaClientState) {
return new DefaultEventTransport(kaaClientState); return new DefaultEventTransport(kaaClientState);
} }


protected LogTransport buildLogTransport(KaaClientProperties properties, KaaClientState kaaClientState) { protected LogTransport buildLogTransport() {
return new DefaultLogTransport(); return new DefaultLogTransport();
} }


protected RedirectionTransport buildRedirectionTransport(KaaClientProperties properties, KaaClientState kaaClientState) { protected RedirectionTransport buildRedirectionTransport() {
return new DefaultRedirectionTransport(); return new DefaultRedirectionTransport();
} }
} }
Expand Up @@ -63,9 +63,11 @@ public synchronized void processResponse(byte[] response) throws IOException {


@Override @Override
public void preProcess() { public void preProcess() {
// Do nothing
} }


@Override @Override
public void postProcess() { public void postProcess() {
// Do nothing
} }
} }
Expand Up @@ -343,6 +343,7 @@ public TransportConnectionInfo getServer() {


@Override @Override
public void setConnectivityChecker(ConnectivityChecker checker) { public void setConnectivityChecker(ConnectivityChecker checker) {
// Do nothing
} }


@Override @Override
Expand Down
Expand Up @@ -24,21 +24,6 @@
import org.kaaproject.kaa.client.configuration.ConfigurationProcessor; import org.kaaproject.kaa.client.configuration.ConfigurationProcessor;
import org.kaaproject.kaa.client.schema.SchemaProcessor; import org.kaaproject.kaa.client.schema.SchemaProcessor;
import org.kaaproject.kaa.common.TransportType; import org.kaaproject.kaa.common.TransportType;
/*
* Copyright 2014 CyberVision, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.kaaproject.kaa.common.endpoint.gen.ConfigurationSyncRequest; import org.kaaproject.kaa.common.endpoint.gen.ConfigurationSyncRequest;
import org.kaaproject.kaa.common.endpoint.gen.ConfigurationSyncResponse; import org.kaaproject.kaa.common.endpoint.gen.ConfigurationSyncResponse;
import org.kaaproject.kaa.common.endpoint.gen.SyncResponseStatus; import org.kaaproject.kaa.common.endpoint.gen.SyncResponseStatus;
Expand Down
Expand Up @@ -102,7 +102,7 @@ public void onEventResponse(EventSyncResponse response) {
if (eventManager != null) { if (eventManager != null) {
if (!isEventSNSynchronized && response.getEventSequenceNumberResponse() != null) { if (!isEventSNSynchronized && response.getEventSequenceNumberResponse() != null) {
int lastSN = response.getEventSequenceNumberResponse().getSeqNum(); int lastSN = response.getEventSequenceNumberResponse().getSeqNum();
int expectedSN = (lastSN > 0 ? lastSN + 1 : lastSN); int expectedSN = lastSN > 0 ? lastSN + 1 : lastSN;


if (startEventSN.get() != expectedSN) { if (startEventSN.get() != expectedSN) {
startEventSN.set(expectedSN); startEventSN.set(expectedSN);
Expand Down
Expand Up @@ -131,7 +131,7 @@ public void produceEvent(String eventFqn, byte[] data, String target, Transactio
transport.sync(); transport.sync();
} }
} else { } else {
LOG.info("Adding event [eventClassFQN: {}, target: {}] to transaction {}", eventFqn, (target != null ? target : "broadcast"), LOG.info("Adding event [eventClassFQN: {}, target: {}] to transaction {}", eventFqn, target != null ? target : "broadcast",
trxId); // NOSONAR trxId); // NOSONAR
synchronized (trxGuard) { synchronized (trxGuard) {
List<Event> events = transactions.get(trxId); List<Event> events = transactions.get(trxId);
Expand Down
Expand Up @@ -110,15 +110,6 @@ private byte[] getResponseBody(HttpResponse response, boolean verifyResponse) th
} else { } else {
signature = new byte[0]; signature = new byte[0];
} }

// LOG.debug("Remote Public Key: {}" +
// messageEncDec.getRemotePublicKey().getEncoded().length);
// LOG.debug(MessageEncoderDecoder.bytesToHex(messageEncDec.getRemotePublicKey().getEncoded()));
// LOG.debug("Signature size: {}" + signature.length);
// LOG.debug(MessageEncoderDecoder.bytesToHex(signature));
// LOG.debug("Body size: {}" + body.length);
// LOG.debug(MessageEncoderDecoder.bytesToHex(body));

return verifyResponse(body, signature); return verifyResponse(body, signature);
} else { } else {
return body; return body;
Expand Down
Expand Up @@ -325,8 +325,8 @@ private void decodeVariableHeader() throws KaaTcpProtocolException {
} }


private void decodeKeepAlive() { private void decodeKeepAlive() {
int msb = ((buffer.get() & 0xFF) << 8); int msb = (buffer.get() & 0xFF) << 8;
int lsb = (buffer.get() & 0xFF); int lsb = buffer.get() & 0xFF;
keepAlive = (msb | lsb); keepAlive = (msb | lsb);
} }


Expand Down
Expand Up @@ -230,8 +230,8 @@ protected void decodeVariableHeader() throws KaaTcpProtocolException {
throw new KaaTcpProtocolException("Kaatcp protocol version missmatch"); throw new KaaTcpProtocolException("Kaatcp protocol version missmatch");
} }
} }
int msb = ((buffer.get() & 0xFF) << 8); int msb = (buffer.get() & 0xFF) << 8;
int lsb = (buffer.get() & 0xFF); int lsb = buffer.get() & 0xFF;
messageId = (msb | lsb); messageId = (msb | lsb);
byte flag = buffer.get(); byte flag = buffer.get();
if (((flag & 0xFF) & KAASYNC_REQUEST_FLAG) != 0) { if (((flag & 0xFF) & KAASYNC_REQUEST_FLAG) != 0) {
Expand Down
Expand Up @@ -41,14 +41,15 @@ public PingRequest() {
*/ */
@Override @Override
protected void pack() { protected void pack() {
// Do nothing
} }


/* (non-Javadoc) /* (non-Javadoc)
* @see org.kaaproject.kaa.common.channels.protocols.kaatcp.messages.mqttFrame#decode() * @see org.kaaproject.kaa.common.channels.protocols.kaatcp.messages.mqttFrame#decode()
*/ */
@Override @Override
protected void decode() throws KaaTcpProtocolException { protected void decode() throws KaaTcpProtocolException {

// Do nothing
} }


/* (non-Javadoc) /* (non-Javadoc)
Expand Down

0 comments on commit 607e2a5

Please sign in to comment.